{-# 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.DescribeChannel
-- 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 in an Amazon Chime @AppInstance@.
--
-- 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.DescribeChannel
  ( -- * Creating a Request
    DescribeChannel (..),
    newDescribeChannel,

    -- * Request Lenses
    describeChannel_chimeBearer,
    describeChannel_channelArn,

    -- * Destructuring the Response
    DescribeChannelResponse (..),
    newDescribeChannelResponse,

    -- * Response Lenses
    describeChannelResponse_channel,
    describeChannelResponse_httpStatus,
  )
where

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

-- |
-- Create a value of 'DescribeChannel' 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', 'describeChannel_chimeBearer' - The @AppInstanceUserArn@ of the user that makes the API call.
--
-- 'channelArn', 'describeChannel_channelArn' - The ARN of the channel.
newDescribeChannel ::
  -- | 'channelArn'
  Prelude.Text ->
  DescribeChannel
newDescribeChannel :: Text -> DescribeChannel
newDescribeChannel Text
pChannelArn_ =
  DescribeChannel' :: Maybe Text -> Text -> DescribeChannel
DescribeChannel'
    { $sel:chimeBearer:DescribeChannel' :: Maybe Text
chimeBearer = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:channelArn:DescribeChannel' :: Text
channelArn = Text
pChannelArn_
    }

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

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

instance Core.AWSRequest DescribeChannel where
  type
    AWSResponse DescribeChannel =
      DescribeChannelResponse
  request :: DescribeChannel -> Request DescribeChannel
request = Service -> DescribeChannel -> Request DescribeChannel
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeChannel)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeChannel))
-> Logger
-> Service
-> Proxy DescribeChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeChannel)))
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 Channel -> Int -> DescribeChannelResponse
DescribeChannelResponse'
            (Maybe Channel -> Int -> DescribeChannelResponse)
-> Either String (Maybe Channel)
-> Either String (Int -> DescribeChannelResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Channel)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Channel")
            Either String (Int -> DescribeChannelResponse)
-> Either String Int -> Either String DescribeChannelResponse
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 DescribeChannel

instance Prelude.NFData DescribeChannel

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

instance Core.ToPath DescribeChannel where
  toPath :: DescribeChannel -> ByteString
toPath DescribeChannel' {Maybe Text
Text
channelArn :: Text
chimeBearer :: Maybe Text
$sel:channelArn:DescribeChannel' :: DescribeChannel -> Text
$sel:chimeBearer:DescribeChannel' :: DescribeChannel -> Maybe 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]

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

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

-- |
-- Create a value of 'DescribeChannelResponse' 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:
--
-- 'channel', 'describeChannelResponse_channel' - The channel details.
--
-- 'httpStatus', 'describeChannelResponse_httpStatus' - The response's http status code.
newDescribeChannelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeChannelResponse
newDescribeChannelResponse :: Int -> DescribeChannelResponse
newDescribeChannelResponse Int
pHttpStatus_ =
  DescribeChannelResponse' :: Maybe Channel -> Int -> DescribeChannelResponse
DescribeChannelResponse'
    { $sel:channel:DescribeChannelResponse' :: Maybe Channel
channel = Maybe Channel
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeChannelResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The channel details.
describeChannelResponse_channel :: Lens.Lens' DescribeChannelResponse (Prelude.Maybe Channel)
describeChannelResponse_channel :: (Maybe Channel -> f (Maybe Channel))
-> DescribeChannelResponse -> f DescribeChannelResponse
describeChannelResponse_channel = (DescribeChannelResponse -> Maybe Channel)
-> (DescribeChannelResponse
    -> Maybe Channel -> DescribeChannelResponse)
-> Lens
     DescribeChannelResponse
     DescribeChannelResponse
     (Maybe Channel)
     (Maybe Channel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeChannelResponse' {Maybe Channel
channel :: Maybe Channel
$sel:channel:DescribeChannelResponse' :: DescribeChannelResponse -> Maybe Channel
channel} -> Maybe Channel
channel) (\s :: DescribeChannelResponse
s@DescribeChannelResponse' {} Maybe Channel
a -> DescribeChannelResponse
s {$sel:channel:DescribeChannelResponse' :: Maybe Channel
channel = Maybe Channel
a} :: DescribeChannelResponse)

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

instance Prelude.NFData DescribeChannelResponse