{-# 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.ConnectCases.ListLayouts
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists all layouts in the given cases domain. Each list item is a
-- condensed summary object of the layout.
module Amazonka.ConnectCases.ListLayouts
  ( -- * Creating a Request
    ListLayouts (..),
    newListLayouts,

    -- * Request Lenses
    listLayouts_maxResults,
    listLayouts_nextToken,
    listLayouts_domainId,

    -- * Destructuring the Response
    ListLayoutsResponse (..),
    newListLayoutsResponse,

    -- * Response Lenses
    listLayoutsResponse_nextToken,
    listLayoutsResponse_httpStatus,
    listLayoutsResponse_layouts,
  )
where

import Amazonka.ConnectCases.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListLayouts' smart constructor.
data ListLayouts = ListLayouts'
  { -- | The maximum number of results to return per page.
    ListLayouts -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token for the next set of results. Use the value returned in the
    -- previous response in the next request to retrieve the next set of
    -- results.
    ListLayouts -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier of the Cases domain.
    ListLayouts -> Text
domainId :: Prelude.Text
  }
  deriving (ListLayouts -> ListLayouts -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListLayouts -> ListLayouts -> Bool
$c/= :: ListLayouts -> ListLayouts -> Bool
== :: ListLayouts -> ListLayouts -> Bool
$c== :: ListLayouts -> ListLayouts -> Bool
Prelude.Eq, ReadPrec [ListLayouts]
ReadPrec ListLayouts
Int -> ReadS ListLayouts
ReadS [ListLayouts]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListLayouts]
$creadListPrec :: ReadPrec [ListLayouts]
readPrec :: ReadPrec ListLayouts
$creadPrec :: ReadPrec ListLayouts
readList :: ReadS [ListLayouts]
$creadList :: ReadS [ListLayouts]
readsPrec :: Int -> ReadS ListLayouts
$creadsPrec :: Int -> ReadS ListLayouts
Prelude.Read, Int -> ListLayouts -> ShowS
[ListLayouts] -> ShowS
ListLayouts -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListLayouts] -> ShowS
$cshowList :: [ListLayouts] -> ShowS
show :: ListLayouts -> String
$cshow :: ListLayouts -> String
showsPrec :: Int -> ListLayouts -> ShowS
$cshowsPrec :: Int -> ListLayouts -> ShowS
Prelude.Show, forall x. Rep ListLayouts x -> ListLayouts
forall x. ListLayouts -> Rep ListLayouts x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListLayouts x -> ListLayouts
$cfrom :: forall x. ListLayouts -> Rep ListLayouts x
Prelude.Generic)

-- |
-- Create a value of 'ListLayouts' 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:
--
-- 'maxResults', 'listLayouts_maxResults' - The maximum number of results to return per page.
--
-- 'nextToken', 'listLayouts_nextToken' - The token for the next set of results. Use the value returned in the
-- previous response in the next request to retrieve the next set of
-- results.
--
-- 'domainId', 'listLayouts_domainId' - The unique identifier of the Cases domain.
newListLayouts ::
  -- | 'domainId'
  Prelude.Text ->
  ListLayouts
newListLayouts :: Text -> ListLayouts
newListLayouts Text
pDomainId_ =
  ListLayouts'
    { $sel:maxResults:ListLayouts' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListLayouts' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:domainId:ListLayouts' :: Text
domainId = Text
pDomainId_
    }

-- | The maximum number of results to return per page.
listLayouts_maxResults :: Lens.Lens' ListLayouts (Prelude.Maybe Prelude.Natural)
listLayouts_maxResults :: Lens' ListLayouts (Maybe Natural)
listLayouts_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListLayouts' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListLayouts' :: ListLayouts -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListLayouts
s@ListLayouts' {} Maybe Natural
a -> ListLayouts
s {$sel:maxResults:ListLayouts' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListLayouts)

-- | The token for the next set of results. Use the value returned in the
-- previous response in the next request to retrieve the next set of
-- results.
listLayouts_nextToken :: Lens.Lens' ListLayouts (Prelude.Maybe Prelude.Text)
listLayouts_nextToken :: Lens' ListLayouts (Maybe Text)
listLayouts_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListLayouts' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListLayouts' :: ListLayouts -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListLayouts
s@ListLayouts' {} Maybe Text
a -> ListLayouts
s {$sel:nextToken:ListLayouts' :: Maybe Text
nextToken = Maybe Text
a} :: ListLayouts)

-- | The unique identifier of the Cases domain.
listLayouts_domainId :: Lens.Lens' ListLayouts Prelude.Text
listLayouts_domainId :: Lens' ListLayouts Text
listLayouts_domainId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListLayouts' {Text
domainId :: Text
$sel:domainId:ListLayouts' :: ListLayouts -> Text
domainId} -> Text
domainId) (\s :: ListLayouts
s@ListLayouts' {} Text
a -> ListLayouts
s {$sel:domainId:ListLayouts' :: Text
domainId = Text
a} :: ListLayouts)

instance Core.AWSRequest ListLayouts where
  type AWSResponse ListLayouts = ListLayoutsResponse
  request :: (Service -> Service) -> ListLayouts -> Request ListLayouts
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListLayouts
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListLayouts)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> [LayoutSummary] -> ListLayoutsResponse
ListLayoutsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"nextToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"layouts" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ListLayouts where
  hashWithSalt :: Int -> ListLayouts -> Int
hashWithSalt Int
_salt ListLayouts' {Maybe Natural
Maybe Text
Text
domainId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:domainId:ListLayouts' :: ListLayouts -> Text
$sel:nextToken:ListLayouts' :: ListLayouts -> Maybe Text
$sel:maxResults:ListLayouts' :: ListLayouts -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domainId

instance Prelude.NFData ListLayouts where
  rnf :: ListLayouts -> ()
rnf ListLayouts' {Maybe Natural
Maybe Text
Text
domainId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:domainId:ListLayouts' :: ListLayouts -> Text
$sel:nextToken:ListLayouts' :: ListLayouts -> Maybe Text
$sel:maxResults:ListLayouts' :: ListLayouts -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
domainId

instance Data.ToHeaders ListLayouts where
  toHeaders :: ListLayouts -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON ListLayouts where
  toJSON :: ListLayouts -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

instance Data.ToPath ListLayouts where
  toPath :: ListLayouts -> ByteString
toPath ListLayouts' {Maybe Natural
Maybe Text
Text
domainId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:domainId:ListLayouts' :: ListLayouts -> Text
$sel:nextToken:ListLayouts' :: ListLayouts -> Maybe Text
$sel:maxResults:ListLayouts' :: ListLayouts -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/domains/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
domainId, ByteString
"/layouts-list"]

instance Data.ToQuery ListLayouts where
  toQuery :: ListLayouts -> QueryString
toQuery ListLayouts' {Maybe Natural
Maybe Text
Text
domainId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:domainId:ListLayouts' :: ListLayouts -> Text
$sel:nextToken:ListLayouts' :: ListLayouts -> Maybe Text
$sel:maxResults:ListLayouts' :: ListLayouts -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newListLayoutsResponse' smart constructor.
data ListLayoutsResponse = ListLayoutsResponse'
  { -- | The token for the next set of results. This is null if there are no more
    -- results to return.
    ListLayoutsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListLayoutsResponse -> Int
httpStatus :: Prelude.Int,
    -- | The layouts for the domain.
    ListLayoutsResponse -> [LayoutSummary]
layouts :: [LayoutSummary]
  }
  deriving (ListLayoutsResponse -> ListLayoutsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListLayoutsResponse -> ListLayoutsResponse -> Bool
$c/= :: ListLayoutsResponse -> ListLayoutsResponse -> Bool
== :: ListLayoutsResponse -> ListLayoutsResponse -> Bool
$c== :: ListLayoutsResponse -> ListLayoutsResponse -> Bool
Prelude.Eq, ReadPrec [ListLayoutsResponse]
ReadPrec ListLayoutsResponse
Int -> ReadS ListLayoutsResponse
ReadS [ListLayoutsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListLayoutsResponse]
$creadListPrec :: ReadPrec [ListLayoutsResponse]
readPrec :: ReadPrec ListLayoutsResponse
$creadPrec :: ReadPrec ListLayoutsResponse
readList :: ReadS [ListLayoutsResponse]
$creadList :: ReadS [ListLayoutsResponse]
readsPrec :: Int -> ReadS ListLayoutsResponse
$creadsPrec :: Int -> ReadS ListLayoutsResponse
Prelude.Read, Int -> ListLayoutsResponse -> ShowS
[ListLayoutsResponse] -> ShowS
ListLayoutsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListLayoutsResponse] -> ShowS
$cshowList :: [ListLayoutsResponse] -> ShowS
show :: ListLayoutsResponse -> String
$cshow :: ListLayoutsResponse -> String
showsPrec :: Int -> ListLayoutsResponse -> ShowS
$cshowsPrec :: Int -> ListLayoutsResponse -> ShowS
Prelude.Show, forall x. Rep ListLayoutsResponse x -> ListLayoutsResponse
forall x. ListLayoutsResponse -> Rep ListLayoutsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListLayoutsResponse x -> ListLayoutsResponse
$cfrom :: forall x. ListLayoutsResponse -> Rep ListLayoutsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListLayoutsResponse' 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', 'listLayoutsResponse_nextToken' - The token for the next set of results. This is null if there are no more
-- results to return.
--
-- 'httpStatus', 'listLayoutsResponse_httpStatus' - The response's http status code.
--
-- 'layouts', 'listLayoutsResponse_layouts' - The layouts for the domain.
newListLayoutsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListLayoutsResponse
newListLayoutsResponse :: Int -> ListLayoutsResponse
newListLayoutsResponse Int
pHttpStatus_ =
  ListLayoutsResponse'
    { $sel:nextToken:ListLayoutsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListLayoutsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:layouts:ListLayoutsResponse' :: [LayoutSummary]
layouts = forall a. Monoid a => a
Prelude.mempty
    }

-- | The token for the next set of results. This is null if there are no more
-- results to return.
listLayoutsResponse_nextToken :: Lens.Lens' ListLayoutsResponse (Prelude.Maybe Prelude.Text)
listLayoutsResponse_nextToken :: Lens' ListLayoutsResponse (Maybe Text)
listLayoutsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListLayoutsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListLayoutsResponse' :: ListLayoutsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListLayoutsResponse
s@ListLayoutsResponse' {} Maybe Text
a -> ListLayoutsResponse
s {$sel:nextToken:ListLayoutsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListLayoutsResponse)

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

-- | The layouts for the domain.
listLayoutsResponse_layouts :: Lens.Lens' ListLayoutsResponse [LayoutSummary]
listLayoutsResponse_layouts :: Lens' ListLayoutsResponse [LayoutSummary]
listLayoutsResponse_layouts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListLayoutsResponse' {[LayoutSummary]
layouts :: [LayoutSummary]
$sel:layouts:ListLayoutsResponse' :: ListLayoutsResponse -> [LayoutSummary]
layouts} -> [LayoutSummary]
layouts) (\s :: ListLayoutsResponse
s@ListLayoutsResponse' {} [LayoutSummary]
a -> ListLayoutsResponse
s {$sel:layouts:ListLayoutsResponse' :: [LayoutSummary]
layouts = [LayoutSummary]
a} :: ListLayoutsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData ListLayoutsResponse where
  rnf :: ListLayoutsResponse -> ()
rnf ListLayoutsResponse' {Int
[LayoutSummary]
Maybe Text
layouts :: [LayoutSummary]
httpStatus :: Int
nextToken :: Maybe Text
$sel:layouts:ListLayoutsResponse' :: ListLayoutsResponse -> [LayoutSummary]
$sel:httpStatus:ListLayoutsResponse' :: ListLayoutsResponse -> Int
$sel:nextToken:ListLayoutsResponse' :: ListLayoutsResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [LayoutSummary]
layouts