{-# 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.Chime.CreateChannelBan
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Permanently bans a member from a channel. Moderators can\'t add banned
-- members to a channel. To undo a ban, you first have to
-- @DeleteChannelBan@, and then @CreateChannelMembership@. Bans are cleaned
-- up when you delete users or channels.
--
-- If you ban a user who is already part of a channel, that user is
-- automatically kicked from the channel.
--
-- 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.Chime.CreateChannelBan
  ( -- * Creating a Request
    CreateChannelBan (..),
    newCreateChannelBan,

    -- * Request Lenses
    createChannelBan_chimeBearer,
    createChannelBan_channelArn,
    createChannelBan_memberArn,

    -- * Destructuring the Response
    CreateChannelBanResponse (..),
    newCreateChannelBanResponse,

    -- * Response Lenses
    createChannelBanResponse_channelArn,
    createChannelBanResponse_member,
    createChannelBanResponse_httpStatus,
  )
where

import Amazonka.Chime.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:/ 'newCreateChannelBan' smart constructor.
data CreateChannelBan = CreateChannelBan'
  { -- | The @AppInstanceUserArn@ of the user that makes the API call.
    CreateChannelBan -> Maybe Text
chimeBearer :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the ban request.
    CreateChannelBan -> Text
channelArn :: Prelude.Text,
    -- | The ARN of the member being banned.
    CreateChannelBan -> Text
memberArn :: Prelude.Text
  }
  deriving (CreateChannelBan -> CreateChannelBan -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateChannelBan -> CreateChannelBan -> Bool
$c/= :: CreateChannelBan -> CreateChannelBan -> Bool
== :: CreateChannelBan -> CreateChannelBan -> Bool
$c== :: CreateChannelBan -> CreateChannelBan -> Bool
Prelude.Eq, ReadPrec [CreateChannelBan]
ReadPrec CreateChannelBan
Int -> ReadS CreateChannelBan
ReadS [CreateChannelBan]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateChannelBan]
$creadListPrec :: ReadPrec [CreateChannelBan]
readPrec :: ReadPrec CreateChannelBan
$creadPrec :: ReadPrec CreateChannelBan
readList :: ReadS [CreateChannelBan]
$creadList :: ReadS [CreateChannelBan]
readsPrec :: Int -> ReadS CreateChannelBan
$creadsPrec :: Int -> ReadS CreateChannelBan
Prelude.Read, Int -> CreateChannelBan -> ShowS
[CreateChannelBan] -> ShowS
CreateChannelBan -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateChannelBan] -> ShowS
$cshowList :: [CreateChannelBan] -> ShowS
show :: CreateChannelBan -> String
$cshow :: CreateChannelBan -> String
showsPrec :: Int -> CreateChannelBan -> ShowS
$cshowsPrec :: Int -> CreateChannelBan -> ShowS
Prelude.Show, forall x. Rep CreateChannelBan x -> CreateChannelBan
forall x. CreateChannelBan -> Rep CreateChannelBan x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateChannelBan x -> CreateChannelBan
$cfrom :: forall x. CreateChannelBan -> Rep CreateChannelBan x
Prelude.Generic)

-- |
-- Create a value of 'CreateChannelBan' 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:
--
-- 'chimeBearer', 'createChannelBan_chimeBearer' - The @AppInstanceUserArn@ of the user that makes the API call.
--
-- 'channelArn', 'createChannelBan_channelArn' - The ARN of the ban request.
--
-- 'memberArn', 'createChannelBan_memberArn' - The ARN of the member being banned.
newCreateChannelBan ::
  -- | 'channelArn'
  Prelude.Text ->
  -- | 'memberArn'
  Prelude.Text ->
  CreateChannelBan
newCreateChannelBan :: Text -> Text -> CreateChannelBan
newCreateChannelBan Text
pChannelArn_ Text
pMemberArn_ =
  CreateChannelBan'
    { $sel:chimeBearer:CreateChannelBan' :: Maybe Text
chimeBearer = forall a. Maybe a
Prelude.Nothing,
      $sel:channelArn:CreateChannelBan' :: Text
channelArn = Text
pChannelArn_,
      $sel:memberArn:CreateChannelBan' :: Text
memberArn = Text
pMemberArn_
    }

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

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

-- | The ARN of the member being banned.
createChannelBan_memberArn :: Lens.Lens' CreateChannelBan Prelude.Text
createChannelBan_memberArn :: Lens' CreateChannelBan Text
createChannelBan_memberArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateChannelBan' {Text
memberArn :: Text
$sel:memberArn:CreateChannelBan' :: CreateChannelBan -> Text
memberArn} -> Text
memberArn) (\s :: CreateChannelBan
s@CreateChannelBan' {} Text
a -> CreateChannelBan
s {$sel:memberArn:CreateChannelBan' :: Text
memberArn = Text
a} :: CreateChannelBan)

instance Core.AWSRequest CreateChannelBan where
  type
    AWSResponse CreateChannelBan =
      CreateChannelBanResponse
  request :: (Service -> Service)
-> CreateChannelBan -> Request CreateChannelBan
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateChannelBan
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateChannelBan)))
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 -> Maybe Identity -> Int -> CreateChannelBanResponse
CreateChannelBanResponse'
            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
"ChannelArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Member")
            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 CreateChannelBan where
  hashWithSalt :: Int -> CreateChannelBan -> Int
hashWithSalt Int
_salt CreateChannelBan' {Maybe Text
Text
memberArn :: Text
channelArn :: Text
chimeBearer :: Maybe Text
$sel:memberArn:CreateChannelBan' :: CreateChannelBan -> Text
$sel:channelArn:CreateChannelBan' :: CreateChannelBan -> Text
$sel:chimeBearer:CreateChannelBan' :: CreateChannelBan -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
chimeBearer
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
channelArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
memberArn

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

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

instance Data.ToJSON CreateChannelBan where
  toJSON :: CreateChannelBan -> Value
toJSON CreateChannelBan' {Maybe Text
Text
memberArn :: Text
channelArn :: Text
chimeBearer :: Maybe Text
$sel:memberArn:CreateChannelBan' :: CreateChannelBan -> Text
$sel:channelArn:CreateChannelBan' :: CreateChannelBan -> Text
$sel:chimeBearer:CreateChannelBan' :: CreateChannelBan -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"MemberArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
memberArn)]
      )

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

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

-- | /See:/ 'newCreateChannelBanResponse' smart constructor.
data CreateChannelBanResponse = CreateChannelBanResponse'
  { -- | The ARN of the response to the ban request.
    CreateChannelBanResponse -> Maybe Text
channelArn :: Prelude.Maybe Prelude.Text,
    -- | The @ChannelArn@ and @BannedIdentity@ of the member in the ban response.
    CreateChannelBanResponse -> Maybe Identity
member :: Prelude.Maybe Identity,
    -- | The response's http status code.
    CreateChannelBanResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateChannelBanResponse -> CreateChannelBanResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateChannelBanResponse -> CreateChannelBanResponse -> Bool
$c/= :: CreateChannelBanResponse -> CreateChannelBanResponse -> Bool
== :: CreateChannelBanResponse -> CreateChannelBanResponse -> Bool
$c== :: CreateChannelBanResponse -> CreateChannelBanResponse -> Bool
Prelude.Eq, Int -> CreateChannelBanResponse -> ShowS
[CreateChannelBanResponse] -> ShowS
CreateChannelBanResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateChannelBanResponse] -> ShowS
$cshowList :: [CreateChannelBanResponse] -> ShowS
show :: CreateChannelBanResponse -> String
$cshow :: CreateChannelBanResponse -> String
showsPrec :: Int -> CreateChannelBanResponse -> ShowS
$cshowsPrec :: Int -> CreateChannelBanResponse -> ShowS
Prelude.Show, forall x.
Rep CreateChannelBanResponse x -> CreateChannelBanResponse
forall x.
CreateChannelBanResponse -> Rep CreateChannelBanResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateChannelBanResponse x -> CreateChannelBanResponse
$cfrom :: forall x.
CreateChannelBanResponse -> Rep CreateChannelBanResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateChannelBanResponse' 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', 'createChannelBanResponse_channelArn' - The ARN of the response to the ban request.
--
-- 'member', 'createChannelBanResponse_member' - The @ChannelArn@ and @BannedIdentity@ of the member in the ban response.
--
-- 'httpStatus', 'createChannelBanResponse_httpStatus' - The response's http status code.
newCreateChannelBanResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateChannelBanResponse
newCreateChannelBanResponse :: Int -> CreateChannelBanResponse
newCreateChannelBanResponse Int
pHttpStatus_ =
  CreateChannelBanResponse'
    { $sel:channelArn:CreateChannelBanResponse' :: Maybe Text
channelArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:member:CreateChannelBanResponse' :: Maybe Identity
member = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateChannelBanResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ARN of the response to the ban request.
createChannelBanResponse_channelArn :: Lens.Lens' CreateChannelBanResponse (Prelude.Maybe Prelude.Text)
createChannelBanResponse_channelArn :: Lens' CreateChannelBanResponse (Maybe Text)
createChannelBanResponse_channelArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateChannelBanResponse' {Maybe Text
channelArn :: Maybe Text
$sel:channelArn:CreateChannelBanResponse' :: CreateChannelBanResponse -> Maybe Text
channelArn} -> Maybe Text
channelArn) (\s :: CreateChannelBanResponse
s@CreateChannelBanResponse' {} Maybe Text
a -> CreateChannelBanResponse
s {$sel:channelArn:CreateChannelBanResponse' :: Maybe Text
channelArn = Maybe Text
a} :: CreateChannelBanResponse)

-- | The @ChannelArn@ and @BannedIdentity@ of the member in the ban response.
createChannelBanResponse_member :: Lens.Lens' CreateChannelBanResponse (Prelude.Maybe Identity)
createChannelBanResponse_member :: Lens' CreateChannelBanResponse (Maybe Identity)
createChannelBanResponse_member = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateChannelBanResponse' {Maybe Identity
member :: Maybe Identity
$sel:member:CreateChannelBanResponse' :: CreateChannelBanResponse -> Maybe Identity
member} -> Maybe Identity
member) (\s :: CreateChannelBanResponse
s@CreateChannelBanResponse' {} Maybe Identity
a -> CreateChannelBanResponse
s {$sel:member:CreateChannelBanResponse' :: Maybe Identity
member = Maybe Identity
a} :: CreateChannelBanResponse)

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

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