{-# 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.DescribeChannelMembership
-- 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 user\'s channel membership.
--
-- 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.DescribeChannelMembership
  ( -- * Creating a Request
    DescribeChannelMembership (..),
    newDescribeChannelMembership,

    -- * Request Lenses
    describeChannelMembership_channelArn,
    describeChannelMembership_memberArn,
    describeChannelMembership_chimeBearer,

    -- * Destructuring the Response
    DescribeChannelMembershipResponse (..),
    newDescribeChannelMembershipResponse,

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

-- |
-- Create a value of 'DescribeChannelMembership' 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', 'describeChannelMembership_channelArn' - The ARN of the channel.
--
-- 'memberArn', 'describeChannelMembership_memberArn' - The ARN of the member.
--
-- 'chimeBearer', 'describeChannelMembership_chimeBearer' - The @AppInstanceUserArn@ of the user that makes the API call.
newDescribeChannelMembership ::
  -- | 'channelArn'
  Prelude.Text ->
  -- | 'memberArn'
  Prelude.Text ->
  -- | 'chimeBearer'
  Prelude.Text ->
  DescribeChannelMembership
newDescribeChannelMembership :: Text -> Text -> Text -> DescribeChannelMembership
newDescribeChannelMembership
  Text
pChannelArn_
  Text
pMemberArn_
  Text
pChimeBearer_ =
    DescribeChannelMembership' :: Text -> Text -> Text -> DescribeChannelMembership
DescribeChannelMembership'
      { $sel:channelArn:DescribeChannelMembership' :: Text
channelArn =
          Text
pChannelArn_,
        $sel:memberArn:DescribeChannelMembership' :: Text
memberArn = Text
pMemberArn_,
        $sel:chimeBearer:DescribeChannelMembership' :: Text
chimeBearer = Text
pChimeBearer_
      }

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

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

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

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

instance Prelude.NFData DescribeChannelMembership

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

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

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

-- |
-- Create a value of 'DescribeChannelMembershipResponse' 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:
--
-- 'channelMembership', 'describeChannelMembershipResponse_channelMembership' - The details of the membership.
--
-- 'httpStatus', 'describeChannelMembershipResponse_httpStatus' - The response's http status code.
newDescribeChannelMembershipResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeChannelMembershipResponse
newDescribeChannelMembershipResponse :: Int -> DescribeChannelMembershipResponse
newDescribeChannelMembershipResponse Int
pHttpStatus_ =
  DescribeChannelMembershipResponse' :: Maybe ChannelMembership -> Int -> DescribeChannelMembershipResponse
DescribeChannelMembershipResponse'
    { $sel:channelMembership:DescribeChannelMembershipResponse' :: Maybe ChannelMembership
channelMembership =
        Maybe ChannelMembership
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeChannelMembershipResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The details of the membership.
describeChannelMembershipResponse_channelMembership :: Lens.Lens' DescribeChannelMembershipResponse (Prelude.Maybe ChannelMembership)
describeChannelMembershipResponse_channelMembership :: (Maybe ChannelMembership -> f (Maybe ChannelMembership))
-> DescribeChannelMembershipResponse
-> f DescribeChannelMembershipResponse
describeChannelMembershipResponse_channelMembership = (DescribeChannelMembershipResponse -> Maybe ChannelMembership)
-> (DescribeChannelMembershipResponse
    -> Maybe ChannelMembership -> DescribeChannelMembershipResponse)
-> Lens
     DescribeChannelMembershipResponse
     DescribeChannelMembershipResponse
     (Maybe ChannelMembership)
     (Maybe ChannelMembership)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeChannelMembershipResponse' {Maybe ChannelMembership
channelMembership :: Maybe ChannelMembership
$sel:channelMembership:DescribeChannelMembershipResponse' :: DescribeChannelMembershipResponse -> Maybe ChannelMembership
channelMembership} -> Maybe ChannelMembership
channelMembership) (\s :: DescribeChannelMembershipResponse
s@DescribeChannelMembershipResponse' {} Maybe ChannelMembership
a -> DescribeChannelMembershipResponse
s {$sel:channelMembership:DescribeChannelMembershipResponse' :: Maybe ChannelMembership
channelMembership = Maybe ChannelMembership
a} :: DescribeChannelMembershipResponse)

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

instance
  Prelude.NFData
    DescribeChannelMembershipResponse