{-# 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.AssociateChannelFlow
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Associates a channel flow with a channel. Once associated, all messages
-- to that channel go through channel flow processors. To stop processing,
-- use the @DisassociateChannelFlow@ API.
--
-- Only administrators or channel moderators can associate a channel flow.
-- The @x-amz-chime-bearer@ request header is mandatory. Use the
-- @AppInstanceUserArn@ of the user that makes the API call as the value in
-- the header.
module Amazonka.ChimeSDKMessaging.AssociateChannelFlow
  ( -- * Creating a Request
    AssociateChannelFlow (..),
    newAssociateChannelFlow,

    -- * Request Lenses
    associateChannelFlow_channelArn,
    associateChannelFlow_channelFlowArn,
    associateChannelFlow_chimeBearer,

    -- * Destructuring the Response
    AssociateChannelFlowResponse (..),
    newAssociateChannelFlowResponse,
  )
where

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

-- | /See:/ 'newAssociateChannelFlow' smart constructor.
data AssociateChannelFlow = AssociateChannelFlow'
  { -- | The ARN of the channel.
    AssociateChannelFlow -> Text
channelArn :: Prelude.Text,
    -- | The ARN of the channel flow.
    AssociateChannelFlow -> Text
channelFlowArn :: Prelude.Text,
    -- | The @AppInstanceUserArn@ of the user making the API call.
    AssociateChannelFlow -> Text
chimeBearer :: Prelude.Text
  }
  deriving (AssociateChannelFlow -> AssociateChannelFlow -> Bool
(AssociateChannelFlow -> AssociateChannelFlow -> Bool)
-> (AssociateChannelFlow -> AssociateChannelFlow -> Bool)
-> Eq AssociateChannelFlow
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateChannelFlow -> AssociateChannelFlow -> Bool
$c/= :: AssociateChannelFlow -> AssociateChannelFlow -> Bool
== :: AssociateChannelFlow -> AssociateChannelFlow -> Bool
$c== :: AssociateChannelFlow -> AssociateChannelFlow -> Bool
Prelude.Eq, ReadPrec [AssociateChannelFlow]
ReadPrec AssociateChannelFlow
Int -> ReadS AssociateChannelFlow
ReadS [AssociateChannelFlow]
(Int -> ReadS AssociateChannelFlow)
-> ReadS [AssociateChannelFlow]
-> ReadPrec AssociateChannelFlow
-> ReadPrec [AssociateChannelFlow]
-> Read AssociateChannelFlow
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateChannelFlow]
$creadListPrec :: ReadPrec [AssociateChannelFlow]
readPrec :: ReadPrec AssociateChannelFlow
$creadPrec :: ReadPrec AssociateChannelFlow
readList :: ReadS [AssociateChannelFlow]
$creadList :: ReadS [AssociateChannelFlow]
readsPrec :: Int -> ReadS AssociateChannelFlow
$creadsPrec :: Int -> ReadS AssociateChannelFlow
Prelude.Read, Int -> AssociateChannelFlow -> ShowS
[AssociateChannelFlow] -> ShowS
AssociateChannelFlow -> String
(Int -> AssociateChannelFlow -> ShowS)
-> (AssociateChannelFlow -> String)
-> ([AssociateChannelFlow] -> ShowS)
-> Show AssociateChannelFlow
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateChannelFlow] -> ShowS
$cshowList :: [AssociateChannelFlow] -> ShowS
show :: AssociateChannelFlow -> String
$cshow :: AssociateChannelFlow -> String
showsPrec :: Int -> AssociateChannelFlow -> ShowS
$cshowsPrec :: Int -> AssociateChannelFlow -> ShowS
Prelude.Show, (forall x. AssociateChannelFlow -> Rep AssociateChannelFlow x)
-> (forall x. Rep AssociateChannelFlow x -> AssociateChannelFlow)
-> Generic AssociateChannelFlow
forall x. Rep AssociateChannelFlow x -> AssociateChannelFlow
forall x. AssociateChannelFlow -> Rep AssociateChannelFlow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociateChannelFlow x -> AssociateChannelFlow
$cfrom :: forall x. AssociateChannelFlow -> Rep AssociateChannelFlow x
Prelude.Generic)

-- |
-- Create a value of 'AssociateChannelFlow' 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:
--
-- 'channelArn', 'associateChannelFlow_channelArn' - The ARN of the channel.
--
-- 'channelFlowArn', 'associateChannelFlow_channelFlowArn' - The ARN of the channel flow.
--
-- 'chimeBearer', 'associateChannelFlow_chimeBearer' - The @AppInstanceUserArn@ of the user making the API call.
newAssociateChannelFlow ::
  -- | 'channelArn'
  Prelude.Text ->
  -- | 'channelFlowArn'
  Prelude.Text ->
  -- | 'chimeBearer'
  Prelude.Text ->
  AssociateChannelFlow
newAssociateChannelFlow :: Text -> Text -> Text -> AssociateChannelFlow
newAssociateChannelFlow
  Text
pChannelArn_
  Text
pChannelFlowArn_
  Text
pChimeBearer_ =
    AssociateChannelFlow' :: Text -> Text -> Text -> AssociateChannelFlow
AssociateChannelFlow'
      { $sel:channelArn:AssociateChannelFlow' :: Text
channelArn = Text
pChannelArn_,
        $sel:channelFlowArn:AssociateChannelFlow' :: Text
channelFlowArn = Text
pChannelFlowArn_,
        $sel:chimeBearer:AssociateChannelFlow' :: Text
chimeBearer = Text
pChimeBearer_
      }

-- | The ARN of the channel.
associateChannelFlow_channelArn :: Lens.Lens' AssociateChannelFlow Prelude.Text
associateChannelFlow_channelArn :: (Text -> f Text) -> AssociateChannelFlow -> f AssociateChannelFlow
associateChannelFlow_channelArn = (AssociateChannelFlow -> Text)
-> (AssociateChannelFlow -> Text -> AssociateChannelFlow)
-> Lens AssociateChannelFlow AssociateChannelFlow Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateChannelFlow' {Text
channelArn :: Text
$sel:channelArn:AssociateChannelFlow' :: AssociateChannelFlow -> Text
channelArn} -> Text
channelArn) (\s :: AssociateChannelFlow
s@AssociateChannelFlow' {} Text
a -> AssociateChannelFlow
s {$sel:channelArn:AssociateChannelFlow' :: Text
channelArn = Text
a} :: AssociateChannelFlow)

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

-- | The @AppInstanceUserArn@ of the user making the API call.
associateChannelFlow_chimeBearer :: Lens.Lens' AssociateChannelFlow Prelude.Text
associateChannelFlow_chimeBearer :: (Text -> f Text) -> AssociateChannelFlow -> f AssociateChannelFlow
associateChannelFlow_chimeBearer = (AssociateChannelFlow -> Text)
-> (AssociateChannelFlow -> Text -> AssociateChannelFlow)
-> Lens AssociateChannelFlow AssociateChannelFlow Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateChannelFlow' {Text
chimeBearer :: Text
$sel:chimeBearer:AssociateChannelFlow' :: AssociateChannelFlow -> Text
chimeBearer} -> Text
chimeBearer) (\s :: AssociateChannelFlow
s@AssociateChannelFlow' {} Text
a -> AssociateChannelFlow
s {$sel:chimeBearer:AssociateChannelFlow' :: Text
chimeBearer = Text
a} :: AssociateChannelFlow)

instance Core.AWSRequest AssociateChannelFlow where
  type
    AWSResponse AssociateChannelFlow =
      AssociateChannelFlowResponse
  request :: AssociateChannelFlow -> Request AssociateChannelFlow
request = Service -> AssociateChannelFlow -> Request AssociateChannelFlow
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AssociateChannelFlow
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateChannelFlow)))
response =
    AWSResponse AssociateChannelFlow
-> Logger
-> Service
-> Proxy AssociateChannelFlow
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateChannelFlow)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse AssociateChannelFlow
AssociateChannelFlowResponse
AssociateChannelFlowResponse'

instance Prelude.Hashable AssociateChannelFlow

instance Prelude.NFData AssociateChannelFlow

instance Core.ToHeaders AssociateChannelFlow where
  toHeaders :: AssociateChannelFlow -> [Header]
toHeaders AssociateChannelFlow' {Text
chimeBearer :: Text
channelFlowArn :: Text
channelArn :: Text
$sel:chimeBearer:AssociateChannelFlow' :: AssociateChannelFlow -> Text
$sel:channelFlowArn:AssociateChannelFlow' :: AssociateChannelFlow -> Text
$sel:channelArn:AssociateChannelFlow' :: AssociateChannelFlow -> Text
..} =
    [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [HeaderName
"x-amz-chime-bearer" HeaderName -> Text -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# Text
chimeBearer]

instance Core.ToJSON AssociateChannelFlow where
  toJSON :: AssociateChannelFlow -> Value
toJSON AssociateChannelFlow' {Text
chimeBearer :: Text
channelFlowArn :: Text
channelArn :: Text
$sel:chimeBearer:AssociateChannelFlow' :: AssociateChannelFlow -> Text
$sel:channelFlowArn:AssociateChannelFlow' :: AssociateChannelFlow -> Text
$sel:channelArn:AssociateChannelFlow' :: AssociateChannelFlow -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ChannelFlowArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
channelFlowArn)
          ]
      )

instance Core.ToPath AssociateChannelFlow where
  toPath :: AssociateChannelFlow -> ByteString
toPath AssociateChannelFlow' {Text
chimeBearer :: Text
channelFlowArn :: Text
channelArn :: Text
$sel:chimeBearer:AssociateChannelFlow' :: AssociateChannelFlow -> Text
$sel:channelFlowArn:AssociateChannelFlow' :: AssociateChannelFlow -> Text
$sel:channelArn:AssociateChannelFlow' :: AssociateChannelFlow -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/channels/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
channelArn, ByteString
"/channel-flow"]

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

-- | /See:/ 'newAssociateChannelFlowResponse' smart constructor.
data AssociateChannelFlowResponse = AssociateChannelFlowResponse'
  {
  }
  deriving (AssociateChannelFlowResponse
-> AssociateChannelFlowResponse -> Bool
(AssociateChannelFlowResponse
 -> AssociateChannelFlowResponse -> Bool)
-> (AssociateChannelFlowResponse
    -> AssociateChannelFlowResponse -> Bool)
-> Eq AssociateChannelFlowResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateChannelFlowResponse
-> AssociateChannelFlowResponse -> Bool
$c/= :: AssociateChannelFlowResponse
-> AssociateChannelFlowResponse -> Bool
== :: AssociateChannelFlowResponse
-> AssociateChannelFlowResponse -> Bool
$c== :: AssociateChannelFlowResponse
-> AssociateChannelFlowResponse -> Bool
Prelude.Eq, ReadPrec [AssociateChannelFlowResponse]
ReadPrec AssociateChannelFlowResponse
Int -> ReadS AssociateChannelFlowResponse
ReadS [AssociateChannelFlowResponse]
(Int -> ReadS AssociateChannelFlowResponse)
-> ReadS [AssociateChannelFlowResponse]
-> ReadPrec AssociateChannelFlowResponse
-> ReadPrec [AssociateChannelFlowResponse]
-> Read AssociateChannelFlowResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateChannelFlowResponse]
$creadListPrec :: ReadPrec [AssociateChannelFlowResponse]
readPrec :: ReadPrec AssociateChannelFlowResponse
$creadPrec :: ReadPrec AssociateChannelFlowResponse
readList :: ReadS [AssociateChannelFlowResponse]
$creadList :: ReadS [AssociateChannelFlowResponse]
readsPrec :: Int -> ReadS AssociateChannelFlowResponse
$creadsPrec :: Int -> ReadS AssociateChannelFlowResponse
Prelude.Read, Int -> AssociateChannelFlowResponse -> ShowS
[AssociateChannelFlowResponse] -> ShowS
AssociateChannelFlowResponse -> String
(Int -> AssociateChannelFlowResponse -> ShowS)
-> (AssociateChannelFlowResponse -> String)
-> ([AssociateChannelFlowResponse] -> ShowS)
-> Show AssociateChannelFlowResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateChannelFlowResponse] -> ShowS
$cshowList :: [AssociateChannelFlowResponse] -> ShowS
show :: AssociateChannelFlowResponse -> String
$cshow :: AssociateChannelFlowResponse -> String
showsPrec :: Int -> AssociateChannelFlowResponse -> ShowS
$cshowsPrec :: Int -> AssociateChannelFlowResponse -> ShowS
Prelude.Show, (forall x.
 AssociateChannelFlowResponse -> Rep AssociateChannelFlowResponse x)
-> (forall x.
    Rep AssociateChannelFlowResponse x -> AssociateChannelFlowResponse)
-> Generic AssociateChannelFlowResponse
forall x.
Rep AssociateChannelFlowResponse x -> AssociateChannelFlowResponse
forall x.
AssociateChannelFlowResponse -> Rep AssociateChannelFlowResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateChannelFlowResponse x -> AssociateChannelFlowResponse
$cfrom :: forall x.
AssociateChannelFlowResponse -> Rep AssociateChannelFlowResponse x
Prelude.Generic)

-- |
-- Create a value of 'AssociateChannelFlowResponse' 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.
newAssociateChannelFlowResponse ::
  AssociateChannelFlowResponse
newAssociateChannelFlowResponse :: AssociateChannelFlowResponse
newAssociateChannelFlowResponse =
  AssociateChannelFlowResponse
AssociateChannelFlowResponse'

instance Prelude.NFData AssociateChannelFlowResponse