{-# 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.DescribeCases
-- 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 a list of cases that you specify by passing one or more case
-- IDs. You can use the @afterTime@ and @beforeTime@ parameters to filter
-- the cases by date. You can set values for the @includeResolvedCases@ and
-- @includeCommunications@ parameters to specify how much information to
-- return.
--
-- The response returns the following in JSON format:
--
-- -   One or more
--     <https://docs.aws.amazon.com/awssupport/latest/APIReference/API_CaseDetails.html CaseDetails>
--     data types.
--
-- -   One or more @nextToken@ values, which specify where to paginate the
--     returned records represented by the @CaseDetails@ objects.
--
-- Case data is available for 12 months after creation. If a case was
-- created more than 12 months ago, a request might return an error.
--
-- -   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.DescribeCases
  ( -- * Creating a Request
    DescribeCases (..),
    newDescribeCases,

    -- * Request Lenses
    describeCases_includeResolvedCases,
    describeCases_caseIdList,
    describeCases_afterTime,
    describeCases_beforeTime,
    describeCases_nextToken,
    describeCases_includeCommunications,
    describeCases_displayId,
    describeCases_language,
    describeCases_maxResults,

    -- * Destructuring the Response
    DescribeCasesResponse (..),
    newDescribeCasesResponse,

    -- * Response Lenses
    describeCasesResponse_cases,
    describeCasesResponse_nextToken,
    describeCasesResponse_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:/ 'newDescribeCases' smart constructor.
data DescribeCases = DescribeCases'
  { -- | Specifies whether to include resolved support cases in the
    -- @DescribeCases@ response. By default, resolved cases aren\'t included.
    DescribeCases -> Maybe Bool
includeResolvedCases :: Prelude.Maybe Prelude.Bool,
    -- | A list of ID numbers of the support cases you want returned. The maximum
    -- number of cases is 100.
    DescribeCases -> Maybe [Text]
caseIdList :: Prelude.Maybe [Prelude.Text],
    -- | The start date for a filtered date search on support case
    -- communications. Case communications are available for 12 months after
    -- creation.
    DescribeCases -> 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.
    DescribeCases -> Maybe Text
beforeTime :: Prelude.Maybe Prelude.Text,
    -- | A resumption point for pagination.
    DescribeCases -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Specifies whether to include communications in the @DescribeCases@
    -- response. By default, communications are included.
    DescribeCases -> Maybe Bool
includeCommunications :: Prelude.Maybe Prelude.Bool,
    -- | The ID displayed for a case in the AWS Support Center user interface.
    DescribeCases -> Maybe Text
displayId :: Prelude.Maybe Prelude.Text,
    -- | The ISO 639-1 code for the language in which AWS provides support. AWS
    -- Support currently supports English (\"en\") and Japanese (\"ja\").
    -- Language parameters must be passed explicitly for operations that take
    -- them.
    DescribeCases -> Maybe Text
language :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return before paginating.
    DescribeCases -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (DescribeCases -> DescribeCases -> Bool
(DescribeCases -> DescribeCases -> Bool)
-> (DescribeCases -> DescribeCases -> Bool) -> Eq DescribeCases
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeCases -> DescribeCases -> Bool
$c/= :: DescribeCases -> DescribeCases -> Bool
== :: DescribeCases -> DescribeCases -> Bool
$c== :: DescribeCases -> DescribeCases -> Bool
Prelude.Eq, ReadPrec [DescribeCases]
ReadPrec DescribeCases
Int -> ReadS DescribeCases
ReadS [DescribeCases]
(Int -> ReadS DescribeCases)
-> ReadS [DescribeCases]
-> ReadPrec DescribeCases
-> ReadPrec [DescribeCases]
-> Read DescribeCases
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeCases]
$creadListPrec :: ReadPrec [DescribeCases]
readPrec :: ReadPrec DescribeCases
$creadPrec :: ReadPrec DescribeCases
readList :: ReadS [DescribeCases]
$creadList :: ReadS [DescribeCases]
readsPrec :: Int -> ReadS DescribeCases
$creadsPrec :: Int -> ReadS DescribeCases
Prelude.Read, Int -> DescribeCases -> ShowS
[DescribeCases] -> ShowS
DescribeCases -> String
(Int -> DescribeCases -> ShowS)
-> (DescribeCases -> String)
-> ([DescribeCases] -> ShowS)
-> Show DescribeCases
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeCases] -> ShowS
$cshowList :: [DescribeCases] -> ShowS
show :: DescribeCases -> String
$cshow :: DescribeCases -> String
showsPrec :: Int -> DescribeCases -> ShowS
$cshowsPrec :: Int -> DescribeCases -> ShowS
Prelude.Show, (forall x. DescribeCases -> Rep DescribeCases x)
-> (forall x. Rep DescribeCases x -> DescribeCases)
-> Generic DescribeCases
forall x. Rep DescribeCases x -> DescribeCases
forall x. DescribeCases -> Rep DescribeCases x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeCases x -> DescribeCases
$cfrom :: forall x. DescribeCases -> Rep DescribeCases x
Prelude.Generic)

-- |
-- Create a value of 'DescribeCases' 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:
--
-- 'includeResolvedCases', 'describeCases_includeResolvedCases' - Specifies whether to include resolved support cases in the
-- @DescribeCases@ response. By default, resolved cases aren\'t included.
--
-- 'caseIdList', 'describeCases_caseIdList' - A list of ID numbers of the support cases you want returned. The maximum
-- number of cases is 100.
--
-- 'afterTime', 'describeCases_afterTime' - The start date for a filtered date search on support case
-- communications. Case communications are available for 12 months after
-- creation.
--
-- 'beforeTime', 'describeCases_beforeTime' - The end date for a filtered date search on support case communications.
-- Case communications are available for 12 months after creation.
--
-- 'nextToken', 'describeCases_nextToken' - A resumption point for pagination.
--
-- 'includeCommunications', 'describeCases_includeCommunications' - Specifies whether to include communications in the @DescribeCases@
-- response. By default, communications are included.
--
-- 'displayId', 'describeCases_displayId' - The ID displayed for a case in the AWS Support Center user interface.
--
-- 'language', 'describeCases_language' - The ISO 639-1 code for the language in which AWS provides support. AWS
-- Support currently supports English (\"en\") and Japanese (\"ja\").
-- Language parameters must be passed explicitly for operations that take
-- them.
--
-- 'maxResults', 'describeCases_maxResults' - The maximum number of results to return before paginating.
newDescribeCases ::
  DescribeCases
newDescribeCases :: DescribeCases
newDescribeCases =
  DescribeCases' :: Maybe Bool
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> DescribeCases
DescribeCases'
    { $sel:includeResolvedCases:DescribeCases' :: Maybe Bool
includeResolvedCases =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:caseIdList:DescribeCases' :: Maybe [Text]
caseIdList = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:afterTime:DescribeCases' :: Maybe Text
afterTime = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:beforeTime:DescribeCases' :: Maybe Text
beforeTime = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeCases' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:includeCommunications:DescribeCases' :: Maybe Bool
includeCommunications = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:displayId:DescribeCases' :: Maybe Text
displayId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:language:DescribeCases' :: Maybe Text
language = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:DescribeCases' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether to include resolved support cases in the
-- @DescribeCases@ response. By default, resolved cases aren\'t included.
describeCases_includeResolvedCases :: Lens.Lens' DescribeCases (Prelude.Maybe Prelude.Bool)
describeCases_includeResolvedCases :: (Maybe Bool -> f (Maybe Bool)) -> DescribeCases -> f DescribeCases
describeCases_includeResolvedCases = (DescribeCases -> Maybe Bool)
-> (DescribeCases -> Maybe Bool -> DescribeCases)
-> Lens DescribeCases DescribeCases (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCases' {Maybe Bool
includeResolvedCases :: Maybe Bool
$sel:includeResolvedCases:DescribeCases' :: DescribeCases -> Maybe Bool
includeResolvedCases} -> Maybe Bool
includeResolvedCases) (\s :: DescribeCases
s@DescribeCases' {} Maybe Bool
a -> DescribeCases
s {$sel:includeResolvedCases:DescribeCases' :: Maybe Bool
includeResolvedCases = Maybe Bool
a} :: DescribeCases)

-- | A list of ID numbers of the support cases you want returned. The maximum
-- number of cases is 100.
describeCases_caseIdList :: Lens.Lens' DescribeCases (Prelude.Maybe [Prelude.Text])
describeCases_caseIdList :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeCases -> f DescribeCases
describeCases_caseIdList = (DescribeCases -> Maybe [Text])
-> (DescribeCases -> Maybe [Text] -> DescribeCases)
-> Lens DescribeCases DescribeCases (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCases' {Maybe [Text]
caseIdList :: Maybe [Text]
$sel:caseIdList:DescribeCases' :: DescribeCases -> Maybe [Text]
caseIdList} -> Maybe [Text]
caseIdList) (\s :: DescribeCases
s@DescribeCases' {} Maybe [Text]
a -> DescribeCases
s {$sel:caseIdList:DescribeCases' :: Maybe [Text]
caseIdList = Maybe [Text]
a} :: DescribeCases) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeCases -> f DescribeCases)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeCases
-> f DescribeCases
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

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

-- | Specifies whether to include communications in the @DescribeCases@
-- response. By default, communications are included.
describeCases_includeCommunications :: Lens.Lens' DescribeCases (Prelude.Maybe Prelude.Bool)
describeCases_includeCommunications :: (Maybe Bool -> f (Maybe Bool)) -> DescribeCases -> f DescribeCases
describeCases_includeCommunications = (DescribeCases -> Maybe Bool)
-> (DescribeCases -> Maybe Bool -> DescribeCases)
-> Lens DescribeCases DescribeCases (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCases' {Maybe Bool
includeCommunications :: Maybe Bool
$sel:includeCommunications:DescribeCases' :: DescribeCases -> Maybe Bool
includeCommunications} -> Maybe Bool
includeCommunications) (\s :: DescribeCases
s@DescribeCases' {} Maybe Bool
a -> DescribeCases
s {$sel:includeCommunications:DescribeCases' :: Maybe Bool
includeCommunications = Maybe Bool
a} :: DescribeCases)

-- | The ID displayed for a case in the AWS Support Center user interface.
describeCases_displayId :: Lens.Lens' DescribeCases (Prelude.Maybe Prelude.Text)
describeCases_displayId :: (Maybe Text -> f (Maybe Text)) -> DescribeCases -> f DescribeCases
describeCases_displayId = (DescribeCases -> Maybe Text)
-> (DescribeCases -> Maybe Text -> DescribeCases)
-> Lens DescribeCases DescribeCases (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCases' {Maybe Text
displayId :: Maybe Text
$sel:displayId:DescribeCases' :: DescribeCases -> Maybe Text
displayId} -> Maybe Text
displayId) (\s :: DescribeCases
s@DescribeCases' {} Maybe Text
a -> DescribeCases
s {$sel:displayId:DescribeCases' :: Maybe Text
displayId = Maybe Text
a} :: DescribeCases)

-- | The ISO 639-1 code for the language in which AWS provides support. AWS
-- Support currently supports English (\"en\") and Japanese (\"ja\").
-- Language parameters must be passed explicitly for operations that take
-- them.
describeCases_language :: Lens.Lens' DescribeCases (Prelude.Maybe Prelude.Text)
describeCases_language :: (Maybe Text -> f (Maybe Text)) -> DescribeCases -> f DescribeCases
describeCases_language = (DescribeCases -> Maybe Text)
-> (DescribeCases -> Maybe Text -> DescribeCases)
-> Lens DescribeCases DescribeCases (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCases' {Maybe Text
language :: Maybe Text
$sel:language:DescribeCases' :: DescribeCases -> Maybe Text
language} -> Maybe Text
language) (\s :: DescribeCases
s@DescribeCases' {} Maybe Text
a -> DescribeCases
s {$sel:language:DescribeCases' :: Maybe Text
language = Maybe Text
a} :: DescribeCases)

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

instance Core.AWSPager DescribeCases where
  page :: DescribeCases -> AWSResponse DescribeCases -> Maybe DescribeCases
page DescribeCases
rq AWSResponse DescribeCases
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeCases
DescribeCasesResponse
rs
            DescribeCasesResponse
-> Getting (First Text) DescribeCasesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeCasesResponse
-> Const (First Text) DescribeCasesResponse
Lens' DescribeCasesResponse (Maybe Text)
describeCasesResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeCasesResponse
 -> Const (First Text) DescribeCasesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeCasesResponse 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 DescribeCases
forall a. Maybe a
Prelude.Nothing
    | Maybe [CaseDetails] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeCases
DescribeCasesResponse
rs
            DescribeCasesResponse
-> Getting
     (First [CaseDetails]) DescribeCasesResponse [CaseDetails]
-> Maybe [CaseDetails]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [CaseDetails]
 -> Const (First [CaseDetails]) (Maybe [CaseDetails]))
-> DescribeCasesResponse
-> Const (First [CaseDetails]) DescribeCasesResponse
Lens' DescribeCasesResponse (Maybe [CaseDetails])
describeCasesResponse_cases ((Maybe [CaseDetails]
  -> Const (First [CaseDetails]) (Maybe [CaseDetails]))
 -> DescribeCasesResponse
 -> Const (First [CaseDetails]) DescribeCasesResponse)
-> (([CaseDetails] -> Const (First [CaseDetails]) [CaseDetails])
    -> Maybe [CaseDetails]
    -> Const (First [CaseDetails]) (Maybe [CaseDetails]))
-> Getting
     (First [CaseDetails]) DescribeCasesResponse [CaseDetails]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([CaseDetails] -> Const (First [CaseDetails]) [CaseDetails])
-> Maybe [CaseDetails]
-> Const (First [CaseDetails]) (Maybe [CaseDetails])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeCases
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeCases -> Maybe DescribeCases
forall a. a -> Maybe a
Prelude.Just (DescribeCases -> Maybe DescribeCases)
-> DescribeCases -> Maybe DescribeCases
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeCases
rq
          DescribeCases -> (DescribeCases -> DescribeCases) -> DescribeCases
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeCases -> Identity DescribeCases
Lens DescribeCases DescribeCases (Maybe Text) (Maybe Text)
describeCases_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeCases -> Identity DescribeCases)
-> Maybe Text -> DescribeCases -> DescribeCases
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeCases
DescribeCasesResponse
rs
          DescribeCasesResponse
-> Getting (First Text) DescribeCasesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeCasesResponse
-> Const (First Text) DescribeCasesResponse
Lens' DescribeCasesResponse (Maybe Text)
describeCasesResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeCasesResponse
 -> Const (First Text) DescribeCasesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeCasesResponse 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 DescribeCases where
  type
    AWSResponse DescribeCases =
      DescribeCasesResponse
  request :: DescribeCases -> Request DescribeCases
request = Service -> DescribeCases -> Request DescribeCases
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeCases
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeCases)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeCases))
-> Logger
-> Service
-> Proxy DescribeCases
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeCases)))
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 [CaseDetails] -> Maybe Text -> Int -> DescribeCasesResponse
DescribeCasesResponse'
            (Maybe [CaseDetails] -> Maybe Text -> Int -> DescribeCasesResponse)
-> Either String (Maybe [CaseDetails])
-> Either String (Maybe Text -> Int -> DescribeCasesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [CaseDetails]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"cases" Either String (Maybe (Maybe [CaseDetails]))
-> Maybe [CaseDetails] -> Either String (Maybe [CaseDetails])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [CaseDetails]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Maybe Text -> Int -> DescribeCasesResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribeCasesResponse)
forall (f :: * -> *) a b. Applicative f => 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 (Int -> DescribeCasesResponse)
-> Either String Int -> Either String DescribeCasesResponse
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 DescribeCases

instance Prelude.NFData DescribeCases

instance Core.ToHeaders DescribeCases where
  toHeaders :: DescribeCases -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeCases -> 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.DescribeCases" ::
                          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 DescribeCases where
  toJSON :: DescribeCases -> Value
toJSON DescribeCases' {Maybe Bool
Maybe Natural
Maybe [Text]
Maybe Text
maxResults :: Maybe Natural
language :: Maybe Text
displayId :: Maybe Text
includeCommunications :: Maybe Bool
nextToken :: Maybe Text
beforeTime :: Maybe Text
afterTime :: Maybe Text
caseIdList :: Maybe [Text]
includeResolvedCases :: Maybe Bool
$sel:maxResults:DescribeCases' :: DescribeCases -> Maybe Natural
$sel:language:DescribeCases' :: DescribeCases -> Maybe Text
$sel:displayId:DescribeCases' :: DescribeCases -> Maybe Text
$sel:includeCommunications:DescribeCases' :: DescribeCases -> Maybe Bool
$sel:nextToken:DescribeCases' :: DescribeCases -> Maybe Text
$sel:beforeTime:DescribeCases' :: DescribeCases -> Maybe Text
$sel:afterTime:DescribeCases' :: DescribeCases -> Maybe Text
$sel:caseIdList:DescribeCases' :: DescribeCases -> Maybe [Text]
$sel:includeResolvedCases:DescribeCases' :: DescribeCases -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"includeResolvedCases" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
includeResolvedCases,
            (Text
"caseIdList" 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]
caseIdList,
            (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
"includeCommunications" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
includeCommunications,
            (Text
"displayId" 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
displayId,
            (Text
"language" 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
language,
            (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
          ]
      )

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

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

-- | Returns an array of
-- <https://docs.aws.amazon.com/awssupport/latest/APIReference/API_CaseDetails.html CaseDetails>
-- objects and a @nextToken@ that defines a point for pagination in the
-- result set.
--
-- /See:/ 'newDescribeCasesResponse' smart constructor.
data DescribeCasesResponse = DescribeCasesResponse'
  { -- | The details for the cases that match the request.
    DescribeCasesResponse -> Maybe [CaseDetails]
cases :: Prelude.Maybe [CaseDetails],
    -- | A resumption point for pagination.
    DescribeCasesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeCasesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeCasesResponse -> DescribeCasesResponse -> Bool
(DescribeCasesResponse -> DescribeCasesResponse -> Bool)
-> (DescribeCasesResponse -> DescribeCasesResponse -> Bool)
-> Eq DescribeCasesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeCasesResponse -> DescribeCasesResponse -> Bool
$c/= :: DescribeCasesResponse -> DescribeCasesResponse -> Bool
== :: DescribeCasesResponse -> DescribeCasesResponse -> Bool
$c== :: DescribeCasesResponse -> DescribeCasesResponse -> Bool
Prelude.Eq, ReadPrec [DescribeCasesResponse]
ReadPrec DescribeCasesResponse
Int -> ReadS DescribeCasesResponse
ReadS [DescribeCasesResponse]
(Int -> ReadS DescribeCasesResponse)
-> ReadS [DescribeCasesResponse]
-> ReadPrec DescribeCasesResponse
-> ReadPrec [DescribeCasesResponse]
-> Read DescribeCasesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeCasesResponse]
$creadListPrec :: ReadPrec [DescribeCasesResponse]
readPrec :: ReadPrec DescribeCasesResponse
$creadPrec :: ReadPrec DescribeCasesResponse
readList :: ReadS [DescribeCasesResponse]
$creadList :: ReadS [DescribeCasesResponse]
readsPrec :: Int -> ReadS DescribeCasesResponse
$creadsPrec :: Int -> ReadS DescribeCasesResponse
Prelude.Read, Int -> DescribeCasesResponse -> ShowS
[DescribeCasesResponse] -> ShowS
DescribeCasesResponse -> String
(Int -> DescribeCasesResponse -> ShowS)
-> (DescribeCasesResponse -> String)
-> ([DescribeCasesResponse] -> ShowS)
-> Show DescribeCasesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeCasesResponse] -> ShowS
$cshowList :: [DescribeCasesResponse] -> ShowS
show :: DescribeCasesResponse -> String
$cshow :: DescribeCasesResponse -> String
showsPrec :: Int -> DescribeCasesResponse -> ShowS
$cshowsPrec :: Int -> DescribeCasesResponse -> ShowS
Prelude.Show, (forall x. DescribeCasesResponse -> Rep DescribeCasesResponse x)
-> (forall x. Rep DescribeCasesResponse x -> DescribeCasesResponse)
-> Generic DescribeCasesResponse
forall x. Rep DescribeCasesResponse x -> DescribeCasesResponse
forall x. DescribeCasesResponse -> Rep DescribeCasesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeCasesResponse x -> DescribeCasesResponse
$cfrom :: forall x. DescribeCasesResponse -> Rep DescribeCasesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeCasesResponse' 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:
--
-- 'cases', 'describeCasesResponse_cases' - The details for the cases that match the request.
--
-- 'nextToken', 'describeCasesResponse_nextToken' - A resumption point for pagination.
--
-- 'httpStatus', 'describeCasesResponse_httpStatus' - The response's http status code.
newDescribeCasesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeCasesResponse
newDescribeCasesResponse :: Int -> DescribeCasesResponse
newDescribeCasesResponse Int
pHttpStatus_ =
  DescribeCasesResponse' :: Maybe [CaseDetails] -> Maybe Text -> Int -> DescribeCasesResponse
DescribeCasesResponse'
    { $sel:cases:DescribeCasesResponse' :: Maybe [CaseDetails]
cases = Maybe [CaseDetails]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeCasesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeCasesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The details for the cases that match the request.
describeCasesResponse_cases :: Lens.Lens' DescribeCasesResponse (Prelude.Maybe [CaseDetails])
describeCasesResponse_cases :: (Maybe [CaseDetails] -> f (Maybe [CaseDetails]))
-> DescribeCasesResponse -> f DescribeCasesResponse
describeCasesResponse_cases = (DescribeCasesResponse -> Maybe [CaseDetails])
-> (DescribeCasesResponse
    -> Maybe [CaseDetails] -> DescribeCasesResponse)
-> Lens' DescribeCasesResponse (Maybe [CaseDetails])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCasesResponse' {Maybe [CaseDetails]
cases :: Maybe [CaseDetails]
$sel:cases:DescribeCasesResponse' :: DescribeCasesResponse -> Maybe [CaseDetails]
cases} -> Maybe [CaseDetails]
cases) (\s :: DescribeCasesResponse
s@DescribeCasesResponse' {} Maybe [CaseDetails]
a -> DescribeCasesResponse
s {$sel:cases:DescribeCasesResponse' :: Maybe [CaseDetails]
cases = Maybe [CaseDetails]
a} :: DescribeCasesResponse) ((Maybe [CaseDetails] -> f (Maybe [CaseDetails]))
 -> DescribeCasesResponse -> f DescribeCasesResponse)
-> ((Maybe [CaseDetails] -> f (Maybe [CaseDetails]))
    -> Maybe [CaseDetails] -> f (Maybe [CaseDetails]))
-> (Maybe [CaseDetails] -> f (Maybe [CaseDetails]))
-> DescribeCasesResponse
-> f DescribeCasesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [CaseDetails] [CaseDetails] [CaseDetails] [CaseDetails]
-> Iso
     (Maybe [CaseDetails])
     (Maybe [CaseDetails])
     (Maybe [CaseDetails])
     (Maybe [CaseDetails])
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 [CaseDetails] [CaseDetails] [CaseDetails] [CaseDetails]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

instance Prelude.NFData DescribeCasesResponse