{-# 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.ListChannelMessages
-- 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)
--
-- List all the messages in a channel. Returns a paginated list of
-- @ChannelMessages@. By default, sorted by creation timestamp in
-- descending order.
--
-- Redacted messages appear in the results as empty, since they are only
-- redacted, not deleted. Deleted messages do not appear in the results.
-- This action always returns the latest version of an edited message.
--
-- Also, 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.ListChannelMessages
  ( -- * Creating a Request
    ListChannelMessages (..),
    newListChannelMessages,

    -- * Request Lenses
    listChannelMessages_nextToken,
    listChannelMessages_notBefore,
    listChannelMessages_sortOrder,
    listChannelMessages_maxResults,
    listChannelMessages_notAfter,
    listChannelMessages_channelArn,
    listChannelMessages_chimeBearer,

    -- * Destructuring the Response
    ListChannelMessagesResponse (..),
    newListChannelMessagesResponse,

    -- * Response Lenses
    listChannelMessagesResponse_channelArn,
    listChannelMessagesResponse_nextToken,
    listChannelMessagesResponse_channelMessages,
    listChannelMessagesResponse_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:/ 'newListChannelMessages' smart constructor.
data ListChannelMessages = ListChannelMessages'
  { -- | The token passed by previous API calls until all requested messages are
    -- returned.
    ListChannelMessages -> Maybe (Sensitive Text)
nextToken :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The initial or starting time stamp for your requested messages.
    ListChannelMessages -> Maybe POSIX
notBefore :: Prelude.Maybe Core.POSIX,
    -- | The order in which you want messages sorted. Default is Descending,
    -- based on time created.
    ListChannelMessages -> Maybe SortOrder
sortOrder :: Prelude.Maybe SortOrder,
    -- | The maximum number of messages that you want returned.
    ListChannelMessages -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The final or ending time stamp for your requested messages.
    ListChannelMessages -> Maybe POSIX
notAfter :: Prelude.Maybe Core.POSIX,
    -- | The ARN of the channel.
    ListChannelMessages -> Text
channelArn :: Prelude.Text,
    -- | The @AppInstanceUserArn@ of the user that makes the API call.
    ListChannelMessages -> Text
chimeBearer :: Prelude.Text
  }
  deriving (ListChannelMessages -> ListChannelMessages -> Bool
(ListChannelMessages -> ListChannelMessages -> Bool)
-> (ListChannelMessages -> ListChannelMessages -> Bool)
-> Eq ListChannelMessages
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListChannelMessages -> ListChannelMessages -> Bool
$c/= :: ListChannelMessages -> ListChannelMessages -> Bool
== :: ListChannelMessages -> ListChannelMessages -> Bool
$c== :: ListChannelMessages -> ListChannelMessages -> Bool
Prelude.Eq, Int -> ListChannelMessages -> ShowS
[ListChannelMessages] -> ShowS
ListChannelMessages -> String
(Int -> ListChannelMessages -> ShowS)
-> (ListChannelMessages -> String)
-> ([ListChannelMessages] -> ShowS)
-> Show ListChannelMessages
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListChannelMessages] -> ShowS
$cshowList :: [ListChannelMessages] -> ShowS
show :: ListChannelMessages -> String
$cshow :: ListChannelMessages -> String
showsPrec :: Int -> ListChannelMessages -> ShowS
$cshowsPrec :: Int -> ListChannelMessages -> ShowS
Prelude.Show, (forall x. ListChannelMessages -> Rep ListChannelMessages x)
-> (forall x. Rep ListChannelMessages x -> ListChannelMessages)
-> Generic ListChannelMessages
forall x. Rep ListChannelMessages x -> ListChannelMessages
forall x. ListChannelMessages -> Rep ListChannelMessages x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListChannelMessages x -> ListChannelMessages
$cfrom :: forall x. ListChannelMessages -> Rep ListChannelMessages x
Prelude.Generic)

-- |
-- Create a value of 'ListChannelMessages' 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:
--
-- 'nextToken', 'listChannelMessages_nextToken' - The token passed by previous API calls until all requested messages are
-- returned.
--
-- 'notBefore', 'listChannelMessages_notBefore' - The initial or starting time stamp for your requested messages.
--
-- 'sortOrder', 'listChannelMessages_sortOrder' - The order in which you want messages sorted. Default is Descending,
-- based on time created.
--
-- 'maxResults', 'listChannelMessages_maxResults' - The maximum number of messages that you want returned.
--
-- 'notAfter', 'listChannelMessages_notAfter' - The final or ending time stamp for your requested messages.
--
-- 'channelArn', 'listChannelMessages_channelArn' - The ARN of the channel.
--
-- 'chimeBearer', 'listChannelMessages_chimeBearer' - The @AppInstanceUserArn@ of the user that makes the API call.
newListChannelMessages ::
  -- | 'channelArn'
  Prelude.Text ->
  -- | 'chimeBearer'
  Prelude.Text ->
  ListChannelMessages
newListChannelMessages :: Text -> Text -> ListChannelMessages
newListChannelMessages Text
pChannelArn_ Text
pChimeBearer_ =
  ListChannelMessages' :: Maybe (Sensitive Text)
-> Maybe POSIX
-> Maybe SortOrder
-> Maybe Natural
-> Maybe POSIX
-> Text
-> Text
-> ListChannelMessages
ListChannelMessages'
    { $sel:nextToken:ListChannelMessages' :: Maybe (Sensitive Text)
nextToken = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:notBefore:ListChannelMessages' :: Maybe POSIX
notBefore = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:sortOrder:ListChannelMessages' :: Maybe SortOrder
sortOrder = Maybe SortOrder
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListChannelMessages' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:notAfter:ListChannelMessages' :: Maybe POSIX
notAfter = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:channelArn:ListChannelMessages' :: Text
channelArn = Text
pChannelArn_,
      $sel:chimeBearer:ListChannelMessages' :: Text
chimeBearer = Text
pChimeBearer_
    }

-- | The token passed by previous API calls until all requested messages are
-- returned.
listChannelMessages_nextToken :: Lens.Lens' ListChannelMessages (Prelude.Maybe Prelude.Text)
listChannelMessages_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListChannelMessages -> f ListChannelMessages
listChannelMessages_nextToken = (ListChannelMessages -> Maybe (Sensitive Text))
-> (ListChannelMessages
    -> Maybe (Sensitive Text) -> ListChannelMessages)
-> Lens
     ListChannelMessages
     ListChannelMessages
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListChannelMessages' {Maybe (Sensitive Text)
nextToken :: Maybe (Sensitive Text)
$sel:nextToken:ListChannelMessages' :: ListChannelMessages -> Maybe (Sensitive Text)
nextToken} -> Maybe (Sensitive Text)
nextToken) (\s :: ListChannelMessages
s@ListChannelMessages' {} Maybe (Sensitive Text)
a -> ListChannelMessages
s {$sel:nextToken:ListChannelMessages' :: Maybe (Sensitive Text)
nextToken = Maybe (Sensitive Text)
a} :: ListChannelMessages) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> ListChannelMessages -> f ListChannelMessages)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> ListChannelMessages
-> f ListChannelMessages
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The initial or starting time stamp for your requested messages.
listChannelMessages_notBefore :: Lens.Lens' ListChannelMessages (Prelude.Maybe Prelude.UTCTime)
listChannelMessages_notBefore :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ListChannelMessages -> f ListChannelMessages
listChannelMessages_notBefore = (ListChannelMessages -> Maybe POSIX)
-> (ListChannelMessages -> Maybe POSIX -> ListChannelMessages)
-> Lens
     ListChannelMessages ListChannelMessages (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListChannelMessages' {Maybe POSIX
notBefore :: Maybe POSIX
$sel:notBefore:ListChannelMessages' :: ListChannelMessages -> Maybe POSIX
notBefore} -> Maybe POSIX
notBefore) (\s :: ListChannelMessages
s@ListChannelMessages' {} Maybe POSIX
a -> ListChannelMessages
s {$sel:notBefore:ListChannelMessages' :: Maybe POSIX
notBefore = Maybe POSIX
a} :: ListChannelMessages) ((Maybe POSIX -> f (Maybe POSIX))
 -> ListChannelMessages -> f ListChannelMessages)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListChannelMessages
-> f ListChannelMessages
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The order in which you want messages sorted. Default is Descending,
-- based on time created.
listChannelMessages_sortOrder :: Lens.Lens' ListChannelMessages (Prelude.Maybe SortOrder)
listChannelMessages_sortOrder :: (Maybe SortOrder -> f (Maybe SortOrder))
-> ListChannelMessages -> f ListChannelMessages
listChannelMessages_sortOrder = (ListChannelMessages -> Maybe SortOrder)
-> (ListChannelMessages -> Maybe SortOrder -> ListChannelMessages)
-> Lens
     ListChannelMessages
     ListChannelMessages
     (Maybe SortOrder)
     (Maybe SortOrder)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListChannelMessages' {Maybe SortOrder
sortOrder :: Maybe SortOrder
$sel:sortOrder:ListChannelMessages' :: ListChannelMessages -> Maybe SortOrder
sortOrder} -> Maybe SortOrder
sortOrder) (\s :: ListChannelMessages
s@ListChannelMessages' {} Maybe SortOrder
a -> ListChannelMessages
s {$sel:sortOrder:ListChannelMessages' :: Maybe SortOrder
sortOrder = Maybe SortOrder
a} :: ListChannelMessages)

-- | The maximum number of messages that you want returned.
listChannelMessages_maxResults :: Lens.Lens' ListChannelMessages (Prelude.Maybe Prelude.Natural)
listChannelMessages_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListChannelMessages -> f ListChannelMessages
listChannelMessages_maxResults = (ListChannelMessages -> Maybe Natural)
-> (ListChannelMessages -> Maybe Natural -> ListChannelMessages)
-> Lens
     ListChannelMessages
     ListChannelMessages
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListChannelMessages' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListChannelMessages' :: ListChannelMessages -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListChannelMessages
s@ListChannelMessages' {} Maybe Natural
a -> ListChannelMessages
s {$sel:maxResults:ListChannelMessages' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListChannelMessages)

-- | The final or ending time stamp for your requested messages.
listChannelMessages_notAfter :: Lens.Lens' ListChannelMessages (Prelude.Maybe Prelude.UTCTime)
listChannelMessages_notAfter :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ListChannelMessages -> f ListChannelMessages
listChannelMessages_notAfter = (ListChannelMessages -> Maybe POSIX)
-> (ListChannelMessages -> Maybe POSIX -> ListChannelMessages)
-> Lens
     ListChannelMessages ListChannelMessages (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListChannelMessages' {Maybe POSIX
notAfter :: Maybe POSIX
$sel:notAfter:ListChannelMessages' :: ListChannelMessages -> Maybe POSIX
notAfter} -> Maybe POSIX
notAfter) (\s :: ListChannelMessages
s@ListChannelMessages' {} Maybe POSIX
a -> ListChannelMessages
s {$sel:notAfter:ListChannelMessages' :: Maybe POSIX
notAfter = Maybe POSIX
a} :: ListChannelMessages) ((Maybe POSIX -> f (Maybe POSIX))
 -> ListChannelMessages -> f ListChannelMessages)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListChannelMessages
-> f ListChannelMessages
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

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

instance Core.AWSRequest ListChannelMessages where
  type
    AWSResponse ListChannelMessages =
      ListChannelMessagesResponse
  request :: ListChannelMessages -> Request ListChannelMessages
request = Service -> ListChannelMessages -> Request ListChannelMessages
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListChannelMessages
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListChannelMessages)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListChannelMessages))
-> Logger
-> Service
-> Proxy ListChannelMessages
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListChannelMessages)))
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 Text
-> Maybe (Sensitive Text)
-> Maybe [ChannelMessageSummary]
-> Int
-> ListChannelMessagesResponse
ListChannelMessagesResponse'
            (Maybe Text
 -> Maybe (Sensitive Text)
 -> Maybe [ChannelMessageSummary]
 -> Int
 -> ListChannelMessagesResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe (Sensitive Text)
      -> Maybe [ChannelMessageSummary]
      -> Int
      -> ListChannelMessagesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ChannelArn")
            Either
  String
  (Maybe (Sensitive Text)
   -> Maybe [ChannelMessageSummary]
   -> Int
   -> ListChannelMessagesResponse)
-> Either String (Maybe (Sensitive Text))
-> Either
     String
     (Maybe [ChannelMessageSummary]
      -> Int -> ListChannelMessagesResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either
  String
  (Maybe [ChannelMessageSummary]
   -> Int -> ListChannelMessagesResponse)
-> Either String (Maybe [ChannelMessageSummary])
-> Either String (Int -> ListChannelMessagesResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text -> Either String (Maybe (Maybe [ChannelMessageSummary]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ChannelMessages"
                            Either String (Maybe (Maybe [ChannelMessageSummary]))
-> Maybe [ChannelMessageSummary]
-> Either String (Maybe [ChannelMessageSummary])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ChannelMessageSummary]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> ListChannelMessagesResponse)
-> Either String Int -> Either String ListChannelMessagesResponse
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 ListChannelMessages

instance Prelude.NFData ListChannelMessages

instance Core.ToHeaders ListChannelMessages where
  toHeaders :: ListChannelMessages -> ResponseHeaders
toHeaders ListChannelMessages' {Maybe Natural
Maybe (Sensitive Text)
Maybe POSIX
Maybe SortOrder
Text
chimeBearer :: Text
channelArn :: Text
notAfter :: Maybe POSIX
maxResults :: Maybe Natural
sortOrder :: Maybe SortOrder
notBefore :: Maybe POSIX
nextToken :: Maybe (Sensitive Text)
$sel:chimeBearer:ListChannelMessages' :: ListChannelMessages -> Text
$sel:channelArn:ListChannelMessages' :: ListChannelMessages -> Text
$sel:notAfter:ListChannelMessages' :: ListChannelMessages -> Maybe POSIX
$sel:maxResults:ListChannelMessages' :: ListChannelMessages -> Maybe Natural
$sel:sortOrder:ListChannelMessages' :: ListChannelMessages -> Maybe SortOrder
$sel:notBefore:ListChannelMessages' :: ListChannelMessages -> Maybe POSIX
$sel:nextToken:ListChannelMessages' :: ListChannelMessages -> Maybe (Sensitive 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 ListChannelMessages where
  toPath :: ListChannelMessages -> ByteString
toPath ListChannelMessages' {Maybe Natural
Maybe (Sensitive Text)
Maybe POSIX
Maybe SortOrder
Text
chimeBearer :: Text
channelArn :: Text
notAfter :: Maybe POSIX
maxResults :: Maybe Natural
sortOrder :: Maybe SortOrder
notBefore :: Maybe POSIX
nextToken :: Maybe (Sensitive Text)
$sel:chimeBearer:ListChannelMessages' :: ListChannelMessages -> Text
$sel:channelArn:ListChannelMessages' :: ListChannelMessages -> Text
$sel:notAfter:ListChannelMessages' :: ListChannelMessages -> Maybe POSIX
$sel:maxResults:ListChannelMessages' :: ListChannelMessages -> Maybe Natural
$sel:sortOrder:ListChannelMessages' :: ListChannelMessages -> Maybe SortOrder
$sel:notBefore:ListChannelMessages' :: ListChannelMessages -> Maybe POSIX
$sel:nextToken:ListChannelMessages' :: ListChannelMessages -> Maybe (Sensitive 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
"/messages"]

instance Core.ToQuery ListChannelMessages where
  toQuery :: ListChannelMessages -> QueryString
toQuery ListChannelMessages' {Maybe Natural
Maybe (Sensitive Text)
Maybe POSIX
Maybe SortOrder
Text
chimeBearer :: Text
channelArn :: Text
notAfter :: Maybe POSIX
maxResults :: Maybe Natural
sortOrder :: Maybe SortOrder
notBefore :: Maybe POSIX
nextToken :: Maybe (Sensitive Text)
$sel:chimeBearer:ListChannelMessages' :: ListChannelMessages -> Text
$sel:channelArn:ListChannelMessages' :: ListChannelMessages -> Text
$sel:notAfter:ListChannelMessages' :: ListChannelMessages -> Maybe POSIX
$sel:maxResults:ListChannelMessages' :: ListChannelMessages -> Maybe Natural
$sel:sortOrder:ListChannelMessages' :: ListChannelMessages -> Maybe SortOrder
$sel:notBefore:ListChannelMessages' :: ListChannelMessages -> Maybe POSIX
$sel:nextToken:ListChannelMessages' :: ListChannelMessages -> Maybe (Sensitive Text)
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"next-token" ByteString -> Maybe (Sensitive Text) -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe (Sensitive Text)
nextToken,
        ByteString
"not-before" ByteString -> Maybe POSIX -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe POSIX
notBefore,
        ByteString
"sort-order" ByteString -> Maybe SortOrder -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe SortOrder
sortOrder,
        ByteString
"max-results" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
maxResults,
        ByteString
"not-after" ByteString -> Maybe POSIX -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe POSIX
notAfter
      ]

-- | /See:/ 'newListChannelMessagesResponse' smart constructor.
data ListChannelMessagesResponse = ListChannelMessagesResponse'
  { -- | The ARN of the channel containing the requested messages.
    ListChannelMessagesResponse -> Maybe Text
channelArn :: Prelude.Maybe Prelude.Text,
    -- | The token passed by previous API calls until all requested messages are
    -- returned.
    ListChannelMessagesResponse -> Maybe (Sensitive Text)
nextToken :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The information about, and content of, each requested message.
    ListChannelMessagesResponse -> Maybe [ChannelMessageSummary]
channelMessages :: Prelude.Maybe [ChannelMessageSummary],
    -- | The response's http status code.
    ListChannelMessagesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListChannelMessagesResponse -> ListChannelMessagesResponse -> Bool
(ListChannelMessagesResponse
 -> ListChannelMessagesResponse -> Bool)
-> (ListChannelMessagesResponse
    -> ListChannelMessagesResponse -> Bool)
-> Eq ListChannelMessagesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListChannelMessagesResponse -> ListChannelMessagesResponse -> Bool
$c/= :: ListChannelMessagesResponse -> ListChannelMessagesResponse -> Bool
== :: ListChannelMessagesResponse -> ListChannelMessagesResponse -> Bool
$c== :: ListChannelMessagesResponse -> ListChannelMessagesResponse -> Bool
Prelude.Eq, Int -> ListChannelMessagesResponse -> ShowS
[ListChannelMessagesResponse] -> ShowS
ListChannelMessagesResponse -> String
(Int -> ListChannelMessagesResponse -> ShowS)
-> (ListChannelMessagesResponse -> String)
-> ([ListChannelMessagesResponse] -> ShowS)
-> Show ListChannelMessagesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListChannelMessagesResponse] -> ShowS
$cshowList :: [ListChannelMessagesResponse] -> ShowS
show :: ListChannelMessagesResponse -> String
$cshow :: ListChannelMessagesResponse -> String
showsPrec :: Int -> ListChannelMessagesResponse -> ShowS
$cshowsPrec :: Int -> ListChannelMessagesResponse -> ShowS
Prelude.Show, (forall x.
 ListChannelMessagesResponse -> Rep ListChannelMessagesResponse x)
-> (forall x.
    Rep ListChannelMessagesResponse x -> ListChannelMessagesResponse)
-> Generic ListChannelMessagesResponse
forall x.
Rep ListChannelMessagesResponse x -> ListChannelMessagesResponse
forall x.
ListChannelMessagesResponse -> Rep ListChannelMessagesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListChannelMessagesResponse x -> ListChannelMessagesResponse
$cfrom :: forall x.
ListChannelMessagesResponse -> Rep ListChannelMessagesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListChannelMessagesResponse' 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', 'listChannelMessagesResponse_channelArn' - The ARN of the channel containing the requested messages.
--
-- 'nextToken', 'listChannelMessagesResponse_nextToken' - The token passed by previous API calls until all requested messages are
-- returned.
--
-- 'channelMessages', 'listChannelMessagesResponse_channelMessages' - The information about, and content of, each requested message.
--
-- 'httpStatus', 'listChannelMessagesResponse_httpStatus' - The response's http status code.
newListChannelMessagesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListChannelMessagesResponse
newListChannelMessagesResponse :: Int -> ListChannelMessagesResponse
newListChannelMessagesResponse Int
pHttpStatus_ =
  ListChannelMessagesResponse' :: Maybe Text
-> Maybe (Sensitive Text)
-> Maybe [ChannelMessageSummary]
-> Int
-> ListChannelMessagesResponse
ListChannelMessagesResponse'
    { $sel:channelArn:ListChannelMessagesResponse' :: Maybe Text
channelArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListChannelMessagesResponse' :: Maybe (Sensitive Text)
nextToken = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:channelMessages:ListChannelMessagesResponse' :: Maybe [ChannelMessageSummary]
channelMessages = Maybe [ChannelMessageSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListChannelMessagesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ARN of the channel containing the requested messages.
listChannelMessagesResponse_channelArn :: Lens.Lens' ListChannelMessagesResponse (Prelude.Maybe Prelude.Text)
listChannelMessagesResponse_channelArn :: (Maybe Text -> f (Maybe Text))
-> ListChannelMessagesResponse -> f ListChannelMessagesResponse
listChannelMessagesResponse_channelArn = (ListChannelMessagesResponse -> Maybe Text)
-> (ListChannelMessagesResponse
    -> Maybe Text -> ListChannelMessagesResponse)
-> Lens
     ListChannelMessagesResponse
     ListChannelMessagesResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListChannelMessagesResponse' {Maybe Text
channelArn :: Maybe Text
$sel:channelArn:ListChannelMessagesResponse' :: ListChannelMessagesResponse -> Maybe Text
channelArn} -> Maybe Text
channelArn) (\s :: ListChannelMessagesResponse
s@ListChannelMessagesResponse' {} Maybe Text
a -> ListChannelMessagesResponse
s {$sel:channelArn:ListChannelMessagesResponse' :: Maybe Text
channelArn = Maybe Text
a} :: ListChannelMessagesResponse)

-- | The token passed by previous API calls until all requested messages are
-- returned.
listChannelMessagesResponse_nextToken :: Lens.Lens' ListChannelMessagesResponse (Prelude.Maybe Prelude.Text)
listChannelMessagesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListChannelMessagesResponse -> f ListChannelMessagesResponse
listChannelMessagesResponse_nextToken = (ListChannelMessagesResponse -> Maybe (Sensitive Text))
-> (ListChannelMessagesResponse
    -> Maybe (Sensitive Text) -> ListChannelMessagesResponse)
-> Lens
     ListChannelMessagesResponse
     ListChannelMessagesResponse
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListChannelMessagesResponse' {Maybe (Sensitive Text)
nextToken :: Maybe (Sensitive Text)
$sel:nextToken:ListChannelMessagesResponse' :: ListChannelMessagesResponse -> Maybe (Sensitive Text)
nextToken} -> Maybe (Sensitive Text)
nextToken) (\s :: ListChannelMessagesResponse
s@ListChannelMessagesResponse' {} Maybe (Sensitive Text)
a -> ListChannelMessagesResponse
s {$sel:nextToken:ListChannelMessagesResponse' :: Maybe (Sensitive Text)
nextToken = Maybe (Sensitive Text)
a} :: ListChannelMessagesResponse) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> ListChannelMessagesResponse -> f ListChannelMessagesResponse)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> ListChannelMessagesResponse
-> f ListChannelMessagesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The information about, and content of, each requested message.
listChannelMessagesResponse_channelMessages :: Lens.Lens' ListChannelMessagesResponse (Prelude.Maybe [ChannelMessageSummary])
listChannelMessagesResponse_channelMessages :: (Maybe [ChannelMessageSummary]
 -> f (Maybe [ChannelMessageSummary]))
-> ListChannelMessagesResponse -> f ListChannelMessagesResponse
listChannelMessagesResponse_channelMessages = (ListChannelMessagesResponse -> Maybe [ChannelMessageSummary])
-> (ListChannelMessagesResponse
    -> Maybe [ChannelMessageSummary] -> ListChannelMessagesResponse)
-> Lens
     ListChannelMessagesResponse
     ListChannelMessagesResponse
     (Maybe [ChannelMessageSummary])
     (Maybe [ChannelMessageSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListChannelMessagesResponse' {Maybe [ChannelMessageSummary]
channelMessages :: Maybe [ChannelMessageSummary]
$sel:channelMessages:ListChannelMessagesResponse' :: ListChannelMessagesResponse -> Maybe [ChannelMessageSummary]
channelMessages} -> Maybe [ChannelMessageSummary]
channelMessages) (\s :: ListChannelMessagesResponse
s@ListChannelMessagesResponse' {} Maybe [ChannelMessageSummary]
a -> ListChannelMessagesResponse
s {$sel:channelMessages:ListChannelMessagesResponse' :: Maybe [ChannelMessageSummary]
channelMessages = Maybe [ChannelMessageSummary]
a} :: ListChannelMessagesResponse) ((Maybe [ChannelMessageSummary]
  -> f (Maybe [ChannelMessageSummary]))
 -> ListChannelMessagesResponse -> f ListChannelMessagesResponse)
-> ((Maybe [ChannelMessageSummary]
     -> f (Maybe [ChannelMessageSummary]))
    -> Maybe [ChannelMessageSummary]
    -> f (Maybe [ChannelMessageSummary]))
-> (Maybe [ChannelMessageSummary]
    -> f (Maybe [ChannelMessageSummary]))
-> ListChannelMessagesResponse
-> f ListChannelMessagesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ChannelMessageSummary]
  [ChannelMessageSummary]
  [ChannelMessageSummary]
  [ChannelMessageSummary]
-> Iso
     (Maybe [ChannelMessageSummary])
     (Maybe [ChannelMessageSummary])
     (Maybe [ChannelMessageSummary])
     (Maybe [ChannelMessageSummary])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [ChannelMessageSummary]
  [ChannelMessageSummary]
  [ChannelMessageSummary]
  [ChannelMessageSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListChannelMessagesResponse