{-# 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.Support.DescribeCommunications
-- 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 communications and attachments for one or more support cases.
-- Use the @afterTime@ and @beforeTime@ parameters to filter by date. You
-- can use the @caseId@ parameter to restrict the results to a specific
-- case.
--
-- Case data is available for 12 months after creation. If a case was
-- created more than 12 months ago, a request for data might cause an
-- error.
--
-- You can use the @maxResults@ and @nextToken@ parameters to control the
-- pagination of the results. Set @maxResults@ to the number of cases that
-- you want to display on each page, and use @nextToken@ to specify the
-- resumption of pagination.
--
-- -   You must have a Business or Enterprise Support plan to use the AWS
--     Support API.
--
-- -   If you call the AWS Support API from an account that does not have a
--     Business or Enterprise Support plan, the
--     @SubscriptionRequiredException@ error message appears. For
--     information about changing your support plan, see
--     <http://aws.amazon.com/premiumsupport/ AWS Support>.
--
-- This operation returns paginated results.
module Amazonka.Support.DescribeCommunications
  ( -- * Creating a Request
    DescribeCommunications (..),
    newDescribeCommunications,

    -- * Request Lenses
    describeCommunications_afterTime,
    describeCommunications_beforeTime,
    describeCommunications_nextToken,
    describeCommunications_maxResults,
    describeCommunications_caseId,

    -- * Destructuring the Response
    DescribeCommunicationsResponse (..),
    newDescribeCommunicationsResponse,

    -- * Response Lenses
    describeCommunicationsResponse_nextToken,
    describeCommunicationsResponse_communications,
    describeCommunicationsResponse_httpStatus,
  )
where

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
import Amazonka.Support.Types

-- | /See:/ 'newDescribeCommunications' smart constructor.
data DescribeCommunications = DescribeCommunications'
  { -- | The start date for a filtered date search on support case
    -- communications. Case communications are available for 12 months after
    -- creation.
    DescribeCommunications -> Maybe Text
afterTime :: Prelude.Maybe Prelude.Text,
    -- | The end date for a filtered date search on support case communications.
    -- Case communications are available for 12 months after creation.
    DescribeCommunications -> Maybe Text
beforeTime :: Prelude.Maybe Prelude.Text,
    -- | A resumption point for pagination.
    DescribeCommunications -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return before paginating.
    DescribeCommunications -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The support case ID requested or returned in the call. The case ID is an
    -- alphanumeric string formatted as shown in this example:
    -- case-/12345678910-2013-c4c1d2bf33c5cf47/
    DescribeCommunications -> Text
caseId :: Prelude.Text
  }
  deriving (DescribeCommunications -> DescribeCommunications -> Bool
(DescribeCommunications -> DescribeCommunications -> Bool)
-> (DescribeCommunications -> DescribeCommunications -> Bool)
-> Eq DescribeCommunications
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeCommunications -> DescribeCommunications -> Bool
$c/= :: DescribeCommunications -> DescribeCommunications -> Bool
== :: DescribeCommunications -> DescribeCommunications -> Bool
$c== :: DescribeCommunications -> DescribeCommunications -> Bool
Prelude.Eq, ReadPrec [DescribeCommunications]
ReadPrec DescribeCommunications
Int -> ReadS DescribeCommunications
ReadS [DescribeCommunications]
(Int -> ReadS DescribeCommunications)
-> ReadS [DescribeCommunications]
-> ReadPrec DescribeCommunications
-> ReadPrec [DescribeCommunications]
-> Read DescribeCommunications
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeCommunications]
$creadListPrec :: ReadPrec [DescribeCommunications]
readPrec :: ReadPrec DescribeCommunications
$creadPrec :: ReadPrec DescribeCommunications
readList :: ReadS [DescribeCommunications]
$creadList :: ReadS [DescribeCommunications]
readsPrec :: Int -> ReadS DescribeCommunications
$creadsPrec :: Int -> ReadS DescribeCommunications
Prelude.Read, Int -> DescribeCommunications -> ShowS
[DescribeCommunications] -> ShowS
DescribeCommunications -> String
(Int -> DescribeCommunications -> ShowS)
-> (DescribeCommunications -> String)
-> ([DescribeCommunications] -> ShowS)
-> Show DescribeCommunications
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeCommunications] -> ShowS
$cshowList :: [DescribeCommunications] -> ShowS
show :: DescribeCommunications -> String
$cshow :: DescribeCommunications -> String
showsPrec :: Int -> DescribeCommunications -> ShowS
$cshowsPrec :: Int -> DescribeCommunications -> ShowS
Prelude.Show, (forall x. DescribeCommunications -> Rep DescribeCommunications x)
-> (forall x.
    Rep DescribeCommunications x -> DescribeCommunications)
-> Generic DescribeCommunications
forall x. Rep DescribeCommunications x -> DescribeCommunications
forall x. DescribeCommunications -> Rep DescribeCommunications x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeCommunications x -> DescribeCommunications
$cfrom :: forall x. DescribeCommunications -> Rep DescribeCommunications x
Prelude.Generic)

-- |
-- Create a value of 'DescribeCommunications' 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:
--
-- 'afterTime', 'describeCommunications_afterTime' - The start date for a filtered date search on support case
-- communications. Case communications are available for 12 months after
-- creation.
--
-- 'beforeTime', 'describeCommunications_beforeTime' - The end date for a filtered date search on support case communications.
-- Case communications are available for 12 months after creation.
--
-- 'nextToken', 'describeCommunications_nextToken' - A resumption point for pagination.
--
-- 'maxResults', 'describeCommunications_maxResults' - The maximum number of results to return before paginating.
--
-- 'caseId', 'describeCommunications_caseId' - The support case ID requested or returned in the call. The case ID is an
-- alphanumeric string formatted as shown in this example:
-- case-/12345678910-2013-c4c1d2bf33c5cf47/
newDescribeCommunications ::
  -- | 'caseId'
  Prelude.Text ->
  DescribeCommunications
newDescribeCommunications :: Text -> DescribeCommunications
newDescribeCommunications Text
pCaseId_ =
  DescribeCommunications' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Text
-> DescribeCommunications
DescribeCommunications'
    { $sel:afterTime:DescribeCommunications' :: Maybe Text
afterTime =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:beforeTime:DescribeCommunications' :: Maybe Text
beforeTime = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeCommunications' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:DescribeCommunications' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:caseId:DescribeCommunications' :: Text
caseId = Text
pCaseId_
    }

-- | The start date for a filtered date search on support case
-- communications. Case communications are available for 12 months after
-- creation.
describeCommunications_afterTime :: Lens.Lens' DescribeCommunications (Prelude.Maybe Prelude.Text)
describeCommunications_afterTime :: (Maybe Text -> f (Maybe Text))
-> DescribeCommunications -> f DescribeCommunications
describeCommunications_afterTime = (DescribeCommunications -> Maybe Text)
-> (DescribeCommunications -> Maybe Text -> DescribeCommunications)
-> Lens
     DescribeCommunications
     DescribeCommunications
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCommunications' {Maybe Text
afterTime :: Maybe Text
$sel:afterTime:DescribeCommunications' :: DescribeCommunications -> Maybe Text
afterTime} -> Maybe Text
afterTime) (\s :: DescribeCommunications
s@DescribeCommunications' {} Maybe Text
a -> DescribeCommunications
s {$sel:afterTime:DescribeCommunications' :: Maybe Text
afterTime = Maybe Text
a} :: DescribeCommunications)

-- | The end date for a filtered date search on support case communications.
-- Case communications are available for 12 months after creation.
describeCommunications_beforeTime :: Lens.Lens' DescribeCommunications (Prelude.Maybe Prelude.Text)
describeCommunications_beforeTime :: (Maybe Text -> f (Maybe Text))
-> DescribeCommunications -> f DescribeCommunications
describeCommunications_beforeTime = (DescribeCommunications -> Maybe Text)
-> (DescribeCommunications -> Maybe Text -> DescribeCommunications)
-> Lens
     DescribeCommunications
     DescribeCommunications
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCommunications' {Maybe Text
beforeTime :: Maybe Text
$sel:beforeTime:DescribeCommunications' :: DescribeCommunications -> Maybe Text
beforeTime} -> Maybe Text
beforeTime) (\s :: DescribeCommunications
s@DescribeCommunications' {} Maybe Text
a -> DescribeCommunications
s {$sel:beforeTime:DescribeCommunications' :: Maybe Text
beforeTime = Maybe Text
a} :: DescribeCommunications)

-- | A resumption point for pagination.
describeCommunications_nextToken :: Lens.Lens' DescribeCommunications (Prelude.Maybe Prelude.Text)
describeCommunications_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeCommunications -> f DescribeCommunications
describeCommunications_nextToken = (DescribeCommunications -> Maybe Text)
-> (DescribeCommunications -> Maybe Text -> DescribeCommunications)
-> Lens
     DescribeCommunications
     DescribeCommunications
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCommunications' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeCommunications' :: DescribeCommunications -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeCommunications
s@DescribeCommunications' {} Maybe Text
a -> DescribeCommunications
s {$sel:nextToken:DescribeCommunications' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeCommunications)

-- | The maximum number of results to return before paginating.
describeCommunications_maxResults :: Lens.Lens' DescribeCommunications (Prelude.Maybe Prelude.Natural)
describeCommunications_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> DescribeCommunications -> f DescribeCommunications
describeCommunications_maxResults = (DescribeCommunications -> Maybe Natural)
-> (DescribeCommunications
    -> Maybe Natural -> DescribeCommunications)
-> Lens
     DescribeCommunications
     DescribeCommunications
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCommunications' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:DescribeCommunications' :: DescribeCommunications -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: DescribeCommunications
s@DescribeCommunications' {} Maybe Natural
a -> DescribeCommunications
s {$sel:maxResults:DescribeCommunications' :: Maybe Natural
maxResults = Maybe Natural
a} :: DescribeCommunications)

-- | The support case ID requested or returned in the call. The case ID is an
-- alphanumeric string formatted as shown in this example:
-- case-/12345678910-2013-c4c1d2bf33c5cf47/
describeCommunications_caseId :: Lens.Lens' DescribeCommunications Prelude.Text
describeCommunications_caseId :: (Text -> f Text)
-> DescribeCommunications -> f DescribeCommunications
describeCommunications_caseId = (DescribeCommunications -> Text)
-> (DescribeCommunications -> Text -> DescribeCommunications)
-> Lens DescribeCommunications DescribeCommunications Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCommunications' {Text
caseId :: Text
$sel:caseId:DescribeCommunications' :: DescribeCommunications -> Text
caseId} -> Text
caseId) (\s :: DescribeCommunications
s@DescribeCommunications' {} Text
a -> DescribeCommunications
s {$sel:caseId:DescribeCommunications' :: Text
caseId = Text
a} :: DescribeCommunications)

instance Core.AWSPager DescribeCommunications where
  page :: DescribeCommunications
-> AWSResponse DescribeCommunications
-> Maybe DescribeCommunications
page DescribeCommunications
rq AWSResponse DescribeCommunications
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeCommunications
DescribeCommunicationsResponse
rs
            DescribeCommunicationsResponse
-> Getting (First Text) DescribeCommunicationsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeCommunicationsResponse
-> Const (First Text) DescribeCommunicationsResponse
Lens' DescribeCommunicationsResponse (Maybe Text)
describeCommunicationsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeCommunicationsResponse
 -> Const (First Text) DescribeCommunicationsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeCommunicationsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeCommunications
forall a. Maybe a
Prelude.Nothing
    | Maybe [Communication] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeCommunications
DescribeCommunicationsResponse
rs
            DescribeCommunicationsResponse
-> Getting
     (First [Communication])
     DescribeCommunicationsResponse
     [Communication]
-> Maybe [Communication]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Communication]
 -> Const (First [Communication]) (Maybe [Communication]))
-> DescribeCommunicationsResponse
-> Const (First [Communication]) DescribeCommunicationsResponse
Lens' DescribeCommunicationsResponse (Maybe [Communication])
describeCommunicationsResponse_communications
              ((Maybe [Communication]
  -> Const (First [Communication]) (Maybe [Communication]))
 -> DescribeCommunicationsResponse
 -> Const (First [Communication]) DescribeCommunicationsResponse)
-> (([Communication]
     -> Const (First [Communication]) [Communication])
    -> Maybe [Communication]
    -> Const (First [Communication]) (Maybe [Communication]))
-> Getting
     (First [Communication])
     DescribeCommunicationsResponse
     [Communication]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Communication] -> Const (First [Communication]) [Communication])
-> Maybe [Communication]
-> Const (First [Communication]) (Maybe [Communication])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeCommunications
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeCommunications -> Maybe DescribeCommunications
forall a. a -> Maybe a
Prelude.Just (DescribeCommunications -> Maybe DescribeCommunications)
-> DescribeCommunications -> Maybe DescribeCommunications
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeCommunications
rq
          DescribeCommunications
-> (DescribeCommunications -> DescribeCommunications)
-> DescribeCommunications
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeCommunications -> Identity DescribeCommunications
Lens
  DescribeCommunications
  DescribeCommunications
  (Maybe Text)
  (Maybe Text)
describeCommunications_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeCommunications -> Identity DescribeCommunications)
-> Maybe Text -> DescribeCommunications -> DescribeCommunications
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeCommunications
DescribeCommunicationsResponse
rs
          DescribeCommunicationsResponse
-> Getting (First Text) DescribeCommunicationsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeCommunicationsResponse
-> Const (First Text) DescribeCommunicationsResponse
Lens' DescribeCommunicationsResponse (Maybe Text)
describeCommunicationsResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeCommunicationsResponse
 -> Const (First Text) DescribeCommunicationsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeCommunicationsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest DescribeCommunications where
  type
    AWSResponse DescribeCommunications =
      DescribeCommunicationsResponse
  request :: DescribeCommunications -> Request DescribeCommunications
request = Service -> DescribeCommunications -> Request DescribeCommunications
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeCommunications
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeCommunications)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeCommunications))
-> Logger
-> Service
-> Proxy DescribeCommunications
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeCommunications)))
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 [Communication] -> Int -> DescribeCommunicationsResponse
DescribeCommunicationsResponse'
            (Maybe Text
 -> Maybe [Communication] -> Int -> DescribeCommunicationsResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [Communication] -> Int -> DescribeCommunicationsResponse)
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
"nextToken")
            Either
  String
  (Maybe [Communication] -> Int -> DescribeCommunicationsResponse)
-> Either String (Maybe [Communication])
-> Either String (Int -> DescribeCommunicationsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [Communication]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"communications" Either String (Maybe (Maybe [Communication]))
-> Maybe [Communication] -> Either String (Maybe [Communication])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Communication]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> DescribeCommunicationsResponse)
-> Either String Int
-> Either String DescribeCommunicationsResponse
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 DescribeCommunications

instance Prelude.NFData DescribeCommunications

instance Core.ToHeaders DescribeCommunications where
  toHeaders :: DescribeCommunications -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeCommunications -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSSupport_20130415.DescribeCommunications" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DescribeCommunications where
  toJSON :: DescribeCommunications -> Value
toJSON DescribeCommunications' {Maybe Natural
Maybe Text
Text
caseId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
beforeTime :: Maybe Text
afterTime :: Maybe Text
$sel:caseId:DescribeCommunications' :: DescribeCommunications -> Text
$sel:maxResults:DescribeCommunications' :: DescribeCommunications -> Maybe Natural
$sel:nextToken:DescribeCommunications' :: DescribeCommunications -> Maybe Text
$sel:beforeTime:DescribeCommunications' :: DescribeCommunications -> Maybe Text
$sel:afterTime:DescribeCommunications' :: DescribeCommunications -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"afterTime" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
afterTime,
            (Text
"beforeTime" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
beforeTime,
            (Text
"nextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"maxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"caseId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
caseId)
          ]
      )

instance Core.ToPath DescribeCommunications where
  toPath :: DescribeCommunications -> ByteString
toPath = ByteString -> DescribeCommunications -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | The communications returned by the DescribeCommunications operation.
--
-- /See:/ 'newDescribeCommunicationsResponse' smart constructor.
data DescribeCommunicationsResponse = DescribeCommunicationsResponse'
  { -- | A resumption point for pagination.
    DescribeCommunicationsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The communications for the case.
    DescribeCommunicationsResponse -> Maybe [Communication]
communications :: Prelude.Maybe [Communication],
    -- | The response's http status code.
    DescribeCommunicationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeCommunicationsResponse
-> DescribeCommunicationsResponse -> Bool
(DescribeCommunicationsResponse
 -> DescribeCommunicationsResponse -> Bool)
-> (DescribeCommunicationsResponse
    -> DescribeCommunicationsResponse -> Bool)
-> Eq DescribeCommunicationsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeCommunicationsResponse
-> DescribeCommunicationsResponse -> Bool
$c/= :: DescribeCommunicationsResponse
-> DescribeCommunicationsResponse -> Bool
== :: DescribeCommunicationsResponse
-> DescribeCommunicationsResponse -> Bool
$c== :: DescribeCommunicationsResponse
-> DescribeCommunicationsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeCommunicationsResponse]
ReadPrec DescribeCommunicationsResponse
Int -> ReadS DescribeCommunicationsResponse
ReadS [DescribeCommunicationsResponse]
(Int -> ReadS DescribeCommunicationsResponse)
-> ReadS [DescribeCommunicationsResponse]
-> ReadPrec DescribeCommunicationsResponse
-> ReadPrec [DescribeCommunicationsResponse]
-> Read DescribeCommunicationsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeCommunicationsResponse]
$creadListPrec :: ReadPrec [DescribeCommunicationsResponse]
readPrec :: ReadPrec DescribeCommunicationsResponse
$creadPrec :: ReadPrec DescribeCommunicationsResponse
readList :: ReadS [DescribeCommunicationsResponse]
$creadList :: ReadS [DescribeCommunicationsResponse]
readsPrec :: Int -> ReadS DescribeCommunicationsResponse
$creadsPrec :: Int -> ReadS DescribeCommunicationsResponse
Prelude.Read, Int -> DescribeCommunicationsResponse -> ShowS
[DescribeCommunicationsResponse] -> ShowS
DescribeCommunicationsResponse -> String
(Int -> DescribeCommunicationsResponse -> ShowS)
-> (DescribeCommunicationsResponse -> String)
-> ([DescribeCommunicationsResponse] -> ShowS)
-> Show DescribeCommunicationsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeCommunicationsResponse] -> ShowS
$cshowList :: [DescribeCommunicationsResponse] -> ShowS
show :: DescribeCommunicationsResponse -> String
$cshow :: DescribeCommunicationsResponse -> String
showsPrec :: Int -> DescribeCommunicationsResponse -> ShowS
$cshowsPrec :: Int -> DescribeCommunicationsResponse -> ShowS
Prelude.Show, (forall x.
 DescribeCommunicationsResponse
 -> Rep DescribeCommunicationsResponse x)
-> (forall x.
    Rep DescribeCommunicationsResponse x
    -> DescribeCommunicationsResponse)
-> Generic DescribeCommunicationsResponse
forall x.
Rep DescribeCommunicationsResponse x
-> DescribeCommunicationsResponse
forall x.
DescribeCommunicationsResponse
-> Rep DescribeCommunicationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeCommunicationsResponse x
-> DescribeCommunicationsResponse
$cfrom :: forall x.
DescribeCommunicationsResponse
-> Rep DescribeCommunicationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeCommunicationsResponse' 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', 'describeCommunicationsResponse_nextToken' - A resumption point for pagination.
--
-- 'communications', 'describeCommunicationsResponse_communications' - The communications for the case.
--
-- 'httpStatus', 'describeCommunicationsResponse_httpStatus' - The response's http status code.
newDescribeCommunicationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeCommunicationsResponse
newDescribeCommunicationsResponse :: Int -> DescribeCommunicationsResponse
newDescribeCommunicationsResponse Int
pHttpStatus_ =
  DescribeCommunicationsResponse' :: Maybe Text
-> Maybe [Communication] -> Int -> DescribeCommunicationsResponse
DescribeCommunicationsResponse'
    { $sel:nextToken:DescribeCommunicationsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:communications:DescribeCommunicationsResponse' :: Maybe [Communication]
communications = Maybe [Communication]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeCommunicationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A resumption point for pagination.
describeCommunicationsResponse_nextToken :: Lens.Lens' DescribeCommunicationsResponse (Prelude.Maybe Prelude.Text)
describeCommunicationsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeCommunicationsResponse
-> f DescribeCommunicationsResponse
describeCommunicationsResponse_nextToken = (DescribeCommunicationsResponse -> Maybe Text)
-> (DescribeCommunicationsResponse
    -> Maybe Text -> DescribeCommunicationsResponse)
-> Lens' DescribeCommunicationsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCommunicationsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeCommunicationsResponse' :: DescribeCommunicationsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeCommunicationsResponse
s@DescribeCommunicationsResponse' {} Maybe Text
a -> DescribeCommunicationsResponse
s {$sel:nextToken:DescribeCommunicationsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeCommunicationsResponse)

-- | The communications for the case.
describeCommunicationsResponse_communications :: Lens.Lens' DescribeCommunicationsResponse (Prelude.Maybe [Communication])
describeCommunicationsResponse_communications :: (Maybe [Communication] -> f (Maybe [Communication]))
-> DescribeCommunicationsResponse
-> f DescribeCommunicationsResponse
describeCommunicationsResponse_communications = (DescribeCommunicationsResponse -> Maybe [Communication])
-> (DescribeCommunicationsResponse
    -> Maybe [Communication] -> DescribeCommunicationsResponse)
-> Lens' DescribeCommunicationsResponse (Maybe [Communication])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCommunicationsResponse' {Maybe [Communication]
communications :: Maybe [Communication]
$sel:communications:DescribeCommunicationsResponse' :: DescribeCommunicationsResponse -> Maybe [Communication]
communications} -> Maybe [Communication]
communications) (\s :: DescribeCommunicationsResponse
s@DescribeCommunicationsResponse' {} Maybe [Communication]
a -> DescribeCommunicationsResponse
s {$sel:communications:DescribeCommunicationsResponse' :: Maybe [Communication]
communications = Maybe [Communication]
a} :: DescribeCommunicationsResponse) ((Maybe [Communication] -> f (Maybe [Communication]))
 -> DescribeCommunicationsResponse
 -> f DescribeCommunicationsResponse)
-> ((Maybe [Communication] -> f (Maybe [Communication]))
    -> Maybe [Communication] -> f (Maybe [Communication]))
-> (Maybe [Communication] -> f (Maybe [Communication]))
-> DescribeCommunicationsResponse
-> f DescribeCommunicationsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [Communication] [Communication] [Communication] [Communication]
-> Iso
     (Maybe [Communication])
     (Maybe [Communication])
     (Maybe [Communication])
     (Maybe [Communication])
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
  [Communication] [Communication] [Communication] [Communication]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    DescribeCommunicationsResponse