{-# 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.DescribeChannelBan
-- 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)
--
-- Returns the full details of a channel ban.
--
-- 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.DescribeChannelBan
  ( -- * Creating a Request
    DescribeChannelBan (..),
    newDescribeChannelBan,

    -- * Request Lenses
    describeChannelBan_channelArn,
    describeChannelBan_memberArn,
    describeChannelBan_chimeBearer,

    -- * Destructuring the Response
    DescribeChannelBanResponse (..),
    newDescribeChannelBanResponse,

    -- * Response Lenses
    describeChannelBanResponse_channelBan,
    describeChannelBanResponse_httpStatus,
  )
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:/ 'newDescribeChannelBan' smart constructor.
data DescribeChannelBan = DescribeChannelBan'
  { -- | The ARN of the channel from which the user is banned.
    DescribeChannelBan -> Text
channelArn :: Prelude.Text,
    -- | The ARN of the member being banned.
    DescribeChannelBan -> Text
memberArn :: Prelude.Text,
    -- | The @AppInstanceUserArn@ of the user that makes the API call.
    DescribeChannelBan -> Text
chimeBearer :: Prelude.Text
  }
  deriving (DescribeChannelBan -> DescribeChannelBan -> Bool
(DescribeChannelBan -> DescribeChannelBan -> Bool)
-> (DescribeChannelBan -> DescribeChannelBan -> Bool)
-> Eq DescribeChannelBan
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeChannelBan -> DescribeChannelBan -> Bool
$c/= :: DescribeChannelBan -> DescribeChannelBan -> Bool
== :: DescribeChannelBan -> DescribeChannelBan -> Bool
$c== :: DescribeChannelBan -> DescribeChannelBan -> Bool
Prelude.Eq, ReadPrec [DescribeChannelBan]
ReadPrec DescribeChannelBan
Int -> ReadS DescribeChannelBan
ReadS [DescribeChannelBan]
(Int -> ReadS DescribeChannelBan)
-> ReadS [DescribeChannelBan]
-> ReadPrec DescribeChannelBan
-> ReadPrec [DescribeChannelBan]
-> Read DescribeChannelBan
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeChannelBan]
$creadListPrec :: ReadPrec [DescribeChannelBan]
readPrec :: ReadPrec DescribeChannelBan
$creadPrec :: ReadPrec DescribeChannelBan
readList :: ReadS [DescribeChannelBan]
$creadList :: ReadS [DescribeChannelBan]
readsPrec :: Int -> ReadS DescribeChannelBan
$creadsPrec :: Int -> ReadS DescribeChannelBan
Prelude.Read, Int -> DescribeChannelBan -> ShowS
[DescribeChannelBan] -> ShowS
DescribeChannelBan -> String
(Int -> DescribeChannelBan -> ShowS)
-> (DescribeChannelBan -> String)
-> ([DescribeChannelBan] -> ShowS)
-> Show DescribeChannelBan
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeChannelBan] -> ShowS
$cshowList :: [DescribeChannelBan] -> ShowS
show :: DescribeChannelBan -> String
$cshow :: DescribeChannelBan -> String
showsPrec :: Int -> DescribeChannelBan -> ShowS
$cshowsPrec :: Int -> DescribeChannelBan -> ShowS
Prelude.Show, (forall x. DescribeChannelBan -> Rep DescribeChannelBan x)
-> (forall x. Rep DescribeChannelBan x -> DescribeChannelBan)
-> Generic DescribeChannelBan
forall x. Rep DescribeChannelBan x -> DescribeChannelBan
forall x. DescribeChannelBan -> Rep DescribeChannelBan x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeChannelBan x -> DescribeChannelBan
$cfrom :: forall x. DescribeChannelBan -> Rep DescribeChannelBan x
Prelude.Generic)

-- |
-- Create a value of 'DescribeChannelBan' 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', 'describeChannelBan_channelArn' - The ARN of the channel from which the user is banned.
--
-- 'memberArn', 'describeChannelBan_memberArn' - The ARN of the member being banned.
--
-- 'chimeBearer', 'describeChannelBan_chimeBearer' - The @AppInstanceUserArn@ of the user that makes the API call.
newDescribeChannelBan ::
  -- | 'channelArn'
  Prelude.Text ->
  -- | 'memberArn'
  Prelude.Text ->
  -- | 'chimeBearer'
  Prelude.Text ->
  DescribeChannelBan
newDescribeChannelBan :: Text -> Text -> Text -> DescribeChannelBan
newDescribeChannelBan
  Text
pChannelArn_
  Text
pMemberArn_
  Text
pChimeBearer_ =
    DescribeChannelBan' :: Text -> Text -> Text -> DescribeChannelBan
DescribeChannelBan'
      { $sel:channelArn:DescribeChannelBan' :: Text
channelArn = Text
pChannelArn_,
        $sel:memberArn:DescribeChannelBan' :: Text
memberArn = Text
pMemberArn_,
        $sel:chimeBearer:DescribeChannelBan' :: Text
chimeBearer = Text
pChimeBearer_
      }

-- | The ARN of the channel from which the user is banned.
describeChannelBan_channelArn :: Lens.Lens' DescribeChannelBan Prelude.Text
describeChannelBan_channelArn :: (Text -> f Text) -> DescribeChannelBan -> f DescribeChannelBan
describeChannelBan_channelArn = (DescribeChannelBan -> Text)
-> (DescribeChannelBan -> Text -> DescribeChannelBan)
-> Lens DescribeChannelBan DescribeChannelBan Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeChannelBan' {Text
channelArn :: Text
$sel:channelArn:DescribeChannelBan' :: DescribeChannelBan -> Text
channelArn} -> Text
channelArn) (\s :: DescribeChannelBan
s@DescribeChannelBan' {} Text
a -> DescribeChannelBan
s {$sel:channelArn:DescribeChannelBan' :: Text
channelArn = Text
a} :: DescribeChannelBan)

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

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

instance Core.AWSRequest DescribeChannelBan where
  type
    AWSResponse DescribeChannelBan =
      DescribeChannelBanResponse
  request :: DescribeChannelBan -> Request DescribeChannelBan
request = Service -> DescribeChannelBan -> Request DescribeChannelBan
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeChannelBan
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeChannelBan)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeChannelBan))
-> Logger
-> Service
-> Proxy DescribeChannelBan
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeChannelBan)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ChannelBan -> Int -> DescribeChannelBanResponse
DescribeChannelBanResponse'
            (Maybe ChannelBan -> Int -> DescribeChannelBanResponse)
-> Either String (Maybe ChannelBan)
-> Either String (Int -> DescribeChannelBanResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ChannelBan)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ChannelBan")
            Either String (Int -> DescribeChannelBanResponse)
-> Either String Int -> Either String DescribeChannelBanResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DescribeChannelBan

instance Prelude.NFData DescribeChannelBan

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

instance Core.ToPath DescribeChannelBan where
  toPath :: DescribeChannelBan -> ByteString
toPath DescribeChannelBan' {Text
chimeBearer :: Text
memberArn :: Text
channelArn :: Text
$sel:chimeBearer:DescribeChannelBan' :: DescribeChannelBan -> Text
$sel:memberArn:DescribeChannelBan' :: DescribeChannelBan -> Text
$sel:channelArn:DescribeChannelBan' :: DescribeChannelBan -> 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
"/bans/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
memberArn
      ]

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

-- | /See:/ 'newDescribeChannelBanResponse' smart constructor.
data DescribeChannelBanResponse = DescribeChannelBanResponse'
  { -- | The details of the ban.
    DescribeChannelBanResponse -> Maybe ChannelBan
channelBan :: Prelude.Maybe ChannelBan,
    -- | The response's http status code.
    DescribeChannelBanResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeChannelBanResponse -> DescribeChannelBanResponse -> Bool
(DescribeChannelBanResponse -> DescribeChannelBanResponse -> Bool)
-> (DescribeChannelBanResponse
    -> DescribeChannelBanResponse -> Bool)
-> Eq DescribeChannelBanResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeChannelBanResponse -> DescribeChannelBanResponse -> Bool
$c/= :: DescribeChannelBanResponse -> DescribeChannelBanResponse -> Bool
== :: DescribeChannelBanResponse -> DescribeChannelBanResponse -> Bool
$c== :: DescribeChannelBanResponse -> DescribeChannelBanResponse -> Bool
Prelude.Eq, Int -> DescribeChannelBanResponse -> ShowS
[DescribeChannelBanResponse] -> ShowS
DescribeChannelBanResponse -> String
(Int -> DescribeChannelBanResponse -> ShowS)
-> (DescribeChannelBanResponse -> String)
-> ([DescribeChannelBanResponse] -> ShowS)
-> Show DescribeChannelBanResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeChannelBanResponse] -> ShowS
$cshowList :: [DescribeChannelBanResponse] -> ShowS
show :: DescribeChannelBanResponse -> String
$cshow :: DescribeChannelBanResponse -> String
showsPrec :: Int -> DescribeChannelBanResponse -> ShowS
$cshowsPrec :: Int -> DescribeChannelBanResponse -> ShowS
Prelude.Show, (forall x.
 DescribeChannelBanResponse -> Rep DescribeChannelBanResponse x)
-> (forall x.
    Rep DescribeChannelBanResponse x -> DescribeChannelBanResponse)
-> Generic DescribeChannelBanResponse
forall x.
Rep DescribeChannelBanResponse x -> DescribeChannelBanResponse
forall x.
DescribeChannelBanResponse -> Rep DescribeChannelBanResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeChannelBanResponse x -> DescribeChannelBanResponse
$cfrom :: forall x.
DescribeChannelBanResponse -> Rep DescribeChannelBanResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeChannelBanResponse' 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:
--
-- 'channelBan', 'describeChannelBanResponse_channelBan' - The details of the ban.
--
-- 'httpStatus', 'describeChannelBanResponse_httpStatus' - The response's http status code.
newDescribeChannelBanResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeChannelBanResponse
newDescribeChannelBanResponse :: Int -> DescribeChannelBanResponse
newDescribeChannelBanResponse Int
pHttpStatus_ =
  DescribeChannelBanResponse' :: Maybe ChannelBan -> Int -> DescribeChannelBanResponse
DescribeChannelBanResponse'
    { $sel:channelBan:DescribeChannelBanResponse' :: Maybe ChannelBan
channelBan =
        Maybe ChannelBan
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeChannelBanResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The details of the ban.
describeChannelBanResponse_channelBan :: Lens.Lens' DescribeChannelBanResponse (Prelude.Maybe ChannelBan)
describeChannelBanResponse_channelBan :: (Maybe ChannelBan -> f (Maybe ChannelBan))
-> DescribeChannelBanResponse -> f DescribeChannelBanResponse
describeChannelBanResponse_channelBan = (DescribeChannelBanResponse -> Maybe ChannelBan)
-> (DescribeChannelBanResponse
    -> Maybe ChannelBan -> DescribeChannelBanResponse)
-> Lens
     DescribeChannelBanResponse
     DescribeChannelBanResponse
     (Maybe ChannelBan)
     (Maybe ChannelBan)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeChannelBanResponse' {Maybe ChannelBan
channelBan :: Maybe ChannelBan
$sel:channelBan:DescribeChannelBanResponse' :: DescribeChannelBanResponse -> Maybe ChannelBan
channelBan} -> Maybe ChannelBan
channelBan) (\s :: DescribeChannelBanResponse
s@DescribeChannelBanResponse' {} Maybe ChannelBan
a -> DescribeChannelBanResponse
s {$sel:channelBan:DescribeChannelBanResponse' :: Maybe ChannelBan
channelBan = Maybe ChannelBan
a} :: DescribeChannelBanResponse)

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

instance Prelude.NFData DescribeChannelBanResponse