{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.ChimeSDKMessaging.UpdateChannelFlow
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates channel flow attributes. This is a developer API.
module Amazonka.ChimeSDKMessaging.UpdateChannelFlow
  ( -- * Creating a Request
    UpdateChannelFlow (..),
    newUpdateChannelFlow,

    -- * Request Lenses
    updateChannelFlow_channelFlowArn,
    updateChannelFlow_processors,
    updateChannelFlow_name,

    -- * Destructuring the Response
    UpdateChannelFlowResponse (..),
    newUpdateChannelFlowResponse,

    -- * Response Lenses
    updateChannelFlowResponse_channelFlowArn,
    updateChannelFlowResponse_httpStatus,
  )
where

import Amazonka.ChimeSDKMessaging.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateChannelFlow' smart constructor.
data UpdateChannelFlow = UpdateChannelFlow'
  { -- | The ARN of the channel flow.
    UpdateChannelFlow -> Text
channelFlowArn :: Prelude.Text,
    -- | Information about the processor Lambda functions
    UpdateChannelFlow -> NonEmpty Processor
processors :: Prelude.NonEmpty Processor,
    -- | The name of the channel flow.
    UpdateChannelFlow -> Sensitive Text
name :: Data.Sensitive Prelude.Text
  }
  deriving (UpdateChannelFlow -> UpdateChannelFlow -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateChannelFlow -> UpdateChannelFlow -> Bool
$c/= :: UpdateChannelFlow -> UpdateChannelFlow -> Bool
== :: UpdateChannelFlow -> UpdateChannelFlow -> Bool
$c== :: UpdateChannelFlow -> UpdateChannelFlow -> Bool
Prelude.Eq, Int -> UpdateChannelFlow -> ShowS
[UpdateChannelFlow] -> ShowS
UpdateChannelFlow -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateChannelFlow] -> ShowS
$cshowList :: [UpdateChannelFlow] -> ShowS
show :: UpdateChannelFlow -> String
$cshow :: UpdateChannelFlow -> String
showsPrec :: Int -> UpdateChannelFlow -> ShowS
$cshowsPrec :: Int -> UpdateChannelFlow -> ShowS
Prelude.Show, forall x. Rep UpdateChannelFlow x -> UpdateChannelFlow
forall x. UpdateChannelFlow -> Rep UpdateChannelFlow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateChannelFlow x -> UpdateChannelFlow
$cfrom :: forall x. UpdateChannelFlow -> Rep UpdateChannelFlow x
Prelude.Generic)

-- |
-- Create a value of 'UpdateChannelFlow' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'channelFlowArn', 'updateChannelFlow_channelFlowArn' - The ARN of the channel flow.
--
-- 'processors', 'updateChannelFlow_processors' - Information about the processor Lambda functions
--
-- 'name', 'updateChannelFlow_name' - The name of the channel flow.
newUpdateChannelFlow ::
  -- | 'channelFlowArn'
  Prelude.Text ->
  -- | 'processors'
  Prelude.NonEmpty Processor ->
  -- | 'name'
  Prelude.Text ->
  UpdateChannelFlow
newUpdateChannelFlow :: Text -> NonEmpty Processor -> Text -> UpdateChannelFlow
newUpdateChannelFlow
  Text
pChannelFlowArn_
  NonEmpty Processor
pProcessors_
  Text
pName_ =
    UpdateChannelFlow'
      { $sel:channelFlowArn:UpdateChannelFlow' :: Text
channelFlowArn =
          Text
pChannelFlowArn_,
        $sel:processors:UpdateChannelFlow' :: NonEmpty Processor
processors = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Processor
pProcessors_,
        $sel:name:UpdateChannelFlow' :: Sensitive Text
name = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pName_
      }

-- | The ARN of the channel flow.
updateChannelFlow_channelFlowArn :: Lens.Lens' UpdateChannelFlow Prelude.Text
updateChannelFlow_channelFlowArn :: Lens' UpdateChannelFlow Text
updateChannelFlow_channelFlowArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateChannelFlow' {Text
channelFlowArn :: Text
$sel:channelFlowArn:UpdateChannelFlow' :: UpdateChannelFlow -> Text
channelFlowArn} -> Text
channelFlowArn) (\s :: UpdateChannelFlow
s@UpdateChannelFlow' {} Text
a -> UpdateChannelFlow
s {$sel:channelFlowArn:UpdateChannelFlow' :: Text
channelFlowArn = Text
a} :: UpdateChannelFlow)

-- | Information about the processor Lambda functions
updateChannelFlow_processors :: Lens.Lens' UpdateChannelFlow (Prelude.NonEmpty Processor)
updateChannelFlow_processors :: Lens' UpdateChannelFlow (NonEmpty Processor)
updateChannelFlow_processors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateChannelFlow' {NonEmpty Processor
processors :: NonEmpty Processor
$sel:processors:UpdateChannelFlow' :: UpdateChannelFlow -> NonEmpty Processor
processors} -> NonEmpty Processor
processors) (\s :: UpdateChannelFlow
s@UpdateChannelFlow' {} NonEmpty Processor
a -> UpdateChannelFlow
s {$sel:processors:UpdateChannelFlow' :: NonEmpty Processor
processors = NonEmpty Processor
a} :: UpdateChannelFlow) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the channel flow.
updateChannelFlow_name :: Lens.Lens' UpdateChannelFlow Prelude.Text
updateChannelFlow_name :: Lens' UpdateChannelFlow Text
updateChannelFlow_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateChannelFlow' {Sensitive Text
name :: Sensitive Text
$sel:name:UpdateChannelFlow' :: UpdateChannelFlow -> Sensitive Text
name} -> Sensitive Text
name) (\s :: UpdateChannelFlow
s@UpdateChannelFlow' {} Sensitive Text
a -> UpdateChannelFlow
s {$sel:name:UpdateChannelFlow' :: Sensitive Text
name = Sensitive Text
a} :: UpdateChannelFlow) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

instance Core.AWSRequest UpdateChannelFlow where
  type
    AWSResponse UpdateChannelFlow =
      UpdateChannelFlowResponse
  request :: (Service -> Service)
-> UpdateChannelFlow -> Request UpdateChannelFlow
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateChannelFlow
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateChannelFlow)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> UpdateChannelFlowResponse
UpdateChannelFlowResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ChannelFlowArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdateChannelFlow where
  hashWithSalt :: Int -> UpdateChannelFlow -> Int
hashWithSalt Int
_salt UpdateChannelFlow' {NonEmpty Processor
Text
Sensitive Text
name :: Sensitive Text
processors :: NonEmpty Processor
channelFlowArn :: Text
$sel:name:UpdateChannelFlow' :: UpdateChannelFlow -> Sensitive Text
$sel:processors:UpdateChannelFlow' :: UpdateChannelFlow -> NonEmpty Processor
$sel:channelFlowArn:UpdateChannelFlow' :: UpdateChannelFlow -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
channelFlowArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Processor
processors
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
name

instance Prelude.NFData UpdateChannelFlow where
  rnf :: UpdateChannelFlow -> ()
rnf UpdateChannelFlow' {NonEmpty Processor
Text
Sensitive Text
name :: Sensitive Text
processors :: NonEmpty Processor
channelFlowArn :: Text
$sel:name:UpdateChannelFlow' :: UpdateChannelFlow -> Sensitive Text
$sel:processors:UpdateChannelFlow' :: UpdateChannelFlow -> NonEmpty Processor
$sel:channelFlowArn:UpdateChannelFlow' :: UpdateChannelFlow -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
channelFlowArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Processor
processors
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
name

instance Data.ToHeaders UpdateChannelFlow where
  toHeaders :: UpdateChannelFlow -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToJSON UpdateChannelFlow where
  toJSON :: UpdateChannelFlow -> Value
toJSON UpdateChannelFlow' {NonEmpty Processor
Text
Sensitive Text
name :: Sensitive Text
processors :: NonEmpty Processor
channelFlowArn :: Text
$sel:name:UpdateChannelFlow' :: UpdateChannelFlow -> Sensitive Text
$sel:processors:UpdateChannelFlow' :: UpdateChannelFlow -> NonEmpty Processor
$sel:channelFlowArn:UpdateChannelFlow' :: UpdateChannelFlow -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Processors" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Processor
processors),
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
name)
          ]
      )

instance Data.ToPath UpdateChannelFlow where
  toPath :: UpdateChannelFlow -> ByteString
toPath UpdateChannelFlow' {NonEmpty Processor
Text
Sensitive Text
name :: Sensitive Text
processors :: NonEmpty Processor
channelFlowArn :: Text
$sel:name:UpdateChannelFlow' :: UpdateChannelFlow -> Sensitive Text
$sel:processors:UpdateChannelFlow' :: UpdateChannelFlow -> NonEmpty Processor
$sel:channelFlowArn:UpdateChannelFlow' :: UpdateChannelFlow -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/channel-flows/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
channelFlowArn]

instance Data.ToQuery UpdateChannelFlow where
  toQuery :: UpdateChannelFlow -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newUpdateChannelFlowResponse' smart constructor.
data UpdateChannelFlowResponse = UpdateChannelFlowResponse'
  { -- | The ARN of the channel flow.
    UpdateChannelFlowResponse -> Maybe Text
channelFlowArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    UpdateChannelFlowResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateChannelFlowResponse -> UpdateChannelFlowResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateChannelFlowResponse -> UpdateChannelFlowResponse -> Bool
$c/= :: UpdateChannelFlowResponse -> UpdateChannelFlowResponse -> Bool
== :: UpdateChannelFlowResponse -> UpdateChannelFlowResponse -> Bool
$c== :: UpdateChannelFlowResponse -> UpdateChannelFlowResponse -> Bool
Prelude.Eq, ReadPrec [UpdateChannelFlowResponse]
ReadPrec UpdateChannelFlowResponse
Int -> ReadS UpdateChannelFlowResponse
ReadS [UpdateChannelFlowResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateChannelFlowResponse]
$creadListPrec :: ReadPrec [UpdateChannelFlowResponse]
readPrec :: ReadPrec UpdateChannelFlowResponse
$creadPrec :: ReadPrec UpdateChannelFlowResponse
readList :: ReadS [UpdateChannelFlowResponse]
$creadList :: ReadS [UpdateChannelFlowResponse]
readsPrec :: Int -> ReadS UpdateChannelFlowResponse
$creadsPrec :: Int -> ReadS UpdateChannelFlowResponse
Prelude.Read, Int -> UpdateChannelFlowResponse -> ShowS
[UpdateChannelFlowResponse] -> ShowS
UpdateChannelFlowResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateChannelFlowResponse] -> ShowS
$cshowList :: [UpdateChannelFlowResponse] -> ShowS
show :: UpdateChannelFlowResponse -> String
$cshow :: UpdateChannelFlowResponse -> String
showsPrec :: Int -> UpdateChannelFlowResponse -> ShowS
$cshowsPrec :: Int -> UpdateChannelFlowResponse -> ShowS
Prelude.Show, forall x.
Rep UpdateChannelFlowResponse x -> UpdateChannelFlowResponse
forall x.
UpdateChannelFlowResponse -> Rep UpdateChannelFlowResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateChannelFlowResponse x -> UpdateChannelFlowResponse
$cfrom :: forall x.
UpdateChannelFlowResponse -> Rep UpdateChannelFlowResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateChannelFlowResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'channelFlowArn', 'updateChannelFlowResponse_channelFlowArn' - The ARN of the channel flow.
--
-- 'httpStatus', 'updateChannelFlowResponse_httpStatus' - The response's http status code.
newUpdateChannelFlowResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateChannelFlowResponse
newUpdateChannelFlowResponse :: Int -> UpdateChannelFlowResponse
newUpdateChannelFlowResponse Int
pHttpStatus_ =
  UpdateChannelFlowResponse'
    { $sel:channelFlowArn:UpdateChannelFlowResponse' :: Maybe Text
channelFlowArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateChannelFlowResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ARN of the channel flow.
updateChannelFlowResponse_channelFlowArn :: Lens.Lens' UpdateChannelFlowResponse (Prelude.Maybe Prelude.Text)
updateChannelFlowResponse_channelFlowArn :: Lens' UpdateChannelFlowResponse (Maybe Text)
updateChannelFlowResponse_channelFlowArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateChannelFlowResponse' {Maybe Text
channelFlowArn :: Maybe Text
$sel:channelFlowArn:UpdateChannelFlowResponse' :: UpdateChannelFlowResponse -> Maybe Text
channelFlowArn} -> Maybe Text
channelFlowArn) (\s :: UpdateChannelFlowResponse
s@UpdateChannelFlowResponse' {} Maybe Text
a -> UpdateChannelFlowResponse
s {$sel:channelFlowArn:UpdateChannelFlowResponse' :: Maybe Text
channelFlowArn = Maybe Text
a} :: UpdateChannelFlowResponse)

-- | The response's http status code.
updateChannelFlowResponse_httpStatus :: Lens.Lens' UpdateChannelFlowResponse Prelude.Int
updateChannelFlowResponse_httpStatus :: Lens' UpdateChannelFlowResponse Int
updateChannelFlowResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateChannelFlowResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateChannelFlowResponse' :: UpdateChannelFlowResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateChannelFlowResponse
s@UpdateChannelFlowResponse' {} Int
a -> UpdateChannelFlowResponse
s {$sel:httpStatus:UpdateChannelFlowResponse' :: Int
httpStatus = Int
a} :: UpdateChannelFlowResponse)

instance Prelude.NFData UpdateChannelFlowResponse where
  rnf :: UpdateChannelFlowResponse -> ()
rnf UpdateChannelFlowResponse' {Int
Maybe Text
httpStatus :: Int
channelFlowArn :: Maybe Text
$sel:httpStatus:UpdateChannelFlowResponse' :: UpdateChannelFlowResponse -> Int
$sel:channelFlowArn:UpdateChannelFlowResponse' :: UpdateChannelFlowResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
channelFlowArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus