{-# 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.DisassociateChannelFlow
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disassociates a channel flow from all its channels. Once disassociated,
-- all messages to that channel stop going through the channel flow
-- processor.
--
-- Only administrators or channel moderators can disassociate 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.DisassociateChannelFlow
  ( -- * Creating a Request
    DisassociateChannelFlow (..),
    newDisassociateChannelFlow,

    -- * Request Lenses
    disassociateChannelFlow_channelArn,
    disassociateChannelFlow_channelFlowArn,
    disassociateChannelFlow_chimeBearer,

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

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

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

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

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

instance Core.AWSRequest DisassociateChannelFlow where
  type
    AWSResponse DisassociateChannelFlow =
      DisassociateChannelFlowResponse
  request :: (Service -> Service)
-> DisassociateChannelFlow -> Request DisassociateChannelFlow
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DisassociateChannelFlow
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateChannelFlow)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      DisassociateChannelFlowResponse
DisassociateChannelFlowResponse'

instance Prelude.Hashable DisassociateChannelFlow where
  hashWithSalt :: Int -> DisassociateChannelFlow -> Int
hashWithSalt Int
_salt DisassociateChannelFlow' {Text
chimeBearer :: Text
channelFlowArn :: Text
channelArn :: Text
$sel:chimeBearer:DisassociateChannelFlow' :: DisassociateChannelFlow -> Text
$sel:channelFlowArn:DisassociateChannelFlow' :: DisassociateChannelFlow -> Text
$sel:channelArn:DisassociateChannelFlow' :: DisassociateChannelFlow -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
channelArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
channelFlowArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
chimeBearer

instance Prelude.NFData DisassociateChannelFlow where
  rnf :: DisassociateChannelFlow -> ()
rnf DisassociateChannelFlow' {Text
chimeBearer :: Text
channelFlowArn :: Text
channelArn :: Text
$sel:chimeBearer:DisassociateChannelFlow' :: DisassociateChannelFlow -> Text
$sel:channelFlowArn:DisassociateChannelFlow' :: DisassociateChannelFlow -> Text
$sel:channelArn:DisassociateChannelFlow' :: DisassociateChannelFlow -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
channelArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 Text
chimeBearer

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

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

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

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

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

instance
  Prelude.NFData
    DisassociateChannelFlowResponse
  where
  rnf :: DisassociateChannelFlowResponse -> ()
rnf DisassociateChannelFlowResponse
_ = ()