{-# 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.ListFields
-- 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 fields in a Cases domain.
module Amazonka.ConnectCases.ListFields
  ( -- * Creating a Request
    ListFields (..),
    newListFields,

    -- * Request Lenses
    listFields_maxResults,
    listFields_nextToken,
    listFields_domainId,

    -- * Destructuring the Response
    ListFieldsResponse (..),
    newListFieldsResponse,

    -- * Response Lenses
    listFieldsResponse_nextToken,
    listFieldsResponse_httpStatus,
    listFieldsResponse_fields,
  )
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:/ 'newListFields' smart constructor.
data ListFields = ListFields'
  { -- | The maximum number of results to return per page.
    ListFields -> 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.
    ListFields -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier of the Cases domain.
    ListFields -> Text
domainId :: Prelude.Text
  }
  deriving (ListFields -> ListFields -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListFields -> ListFields -> Bool
$c/= :: ListFields -> ListFields -> Bool
== :: ListFields -> ListFields -> Bool
$c== :: ListFields -> ListFields -> Bool
Prelude.Eq, ReadPrec [ListFields]
ReadPrec ListFields
Int -> ReadS ListFields
ReadS [ListFields]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListFields]
$creadListPrec :: ReadPrec [ListFields]
readPrec :: ReadPrec ListFields
$creadPrec :: ReadPrec ListFields
readList :: ReadS [ListFields]
$creadList :: ReadS [ListFields]
readsPrec :: Int -> ReadS ListFields
$creadsPrec :: Int -> ReadS ListFields
Prelude.Read, Int -> ListFields -> ShowS
[ListFields] -> ShowS
ListFields -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListFields] -> ShowS
$cshowList :: [ListFields] -> ShowS
show :: ListFields -> String
$cshow :: ListFields -> String
showsPrec :: Int -> ListFields -> ShowS
$cshowsPrec :: Int -> ListFields -> ShowS
Prelude.Show, forall x. Rep ListFields x -> ListFields
forall x. ListFields -> Rep ListFields x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListFields x -> ListFields
$cfrom :: forall x. ListFields -> Rep ListFields x
Prelude.Generic)

-- |
-- Create a value of 'ListFields' 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', 'listFields_maxResults' - The maximum number of results to return per page.
--
-- 'nextToken', 'listFields_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', 'listFields_domainId' - The unique identifier of the Cases domain.
newListFields ::
  -- | 'domainId'
  Prelude.Text ->
  ListFields
newListFields :: Text -> ListFields
newListFields Text
pDomainId_ =
  ListFields'
    { $sel:maxResults:ListFields' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListFields' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:domainId:ListFields' :: Text
domainId = Text
pDomainId_
    }

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

-- | 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.
listFields_nextToken :: Lens.Lens' ListFields (Prelude.Maybe Prelude.Text)
listFields_nextToken :: Lens' ListFields (Maybe Text)
listFields_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFields' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListFields' :: ListFields -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListFields
s@ListFields' {} Maybe Text
a -> ListFields
s {$sel:nextToken:ListFields' :: Maybe Text
nextToken = Maybe Text
a} :: ListFields)

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

instance Core.AWSRequest ListFields where
  type AWSResponse ListFields = ListFieldsResponse
  request :: (Service -> Service) -> ListFields -> Request ListFields
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 ListFields
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListFields)))
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 -> [FieldSummary] -> ListFieldsResponse
ListFieldsResponse'
            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
"fields" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ListFields where
  hashWithSalt :: Int -> ListFields -> Int
hashWithSalt Int
_salt ListFields' {Maybe Natural
Maybe Text
Text
domainId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:domainId:ListFields' :: ListFields -> Text
$sel:nextToken:ListFields' :: ListFields -> Maybe Text
$sel:maxResults:ListFields' :: ListFields -> 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 ListFields where
  rnf :: ListFields -> ()
rnf ListFields' {Maybe Natural
Maybe Text
Text
domainId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:domainId:ListFields' :: ListFields -> Text
$sel:nextToken:ListFields' :: ListFields -> Maybe Text
$sel:maxResults:ListFields' :: ListFields -> 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 ListFields where
  toHeaders :: ListFields -> 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 ListFields where
  toJSON :: ListFields -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

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

instance Data.ToQuery ListFields where
  toQuery :: ListFields -> QueryString
toQuery ListFields' {Maybe Natural
Maybe Text
Text
domainId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:domainId:ListFields' :: ListFields -> Text
$sel:nextToken:ListFields' :: ListFields -> Maybe Text
$sel:maxResults:ListFields' :: ListFields -> 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:/ 'newListFieldsResponse' smart constructor.
data ListFieldsResponse = ListFieldsResponse'
  { -- | The token for the next set of results. This is null if there are no more
    -- results to return.
    ListFieldsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListFieldsResponse -> Int
httpStatus :: Prelude.Int,
    -- | List of detailed field information.
    ListFieldsResponse -> [FieldSummary]
fields :: [FieldSummary]
  }
  deriving (ListFieldsResponse -> ListFieldsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListFieldsResponse -> ListFieldsResponse -> Bool
$c/= :: ListFieldsResponse -> ListFieldsResponse -> Bool
== :: ListFieldsResponse -> ListFieldsResponse -> Bool
$c== :: ListFieldsResponse -> ListFieldsResponse -> Bool
Prelude.Eq, ReadPrec [ListFieldsResponse]
ReadPrec ListFieldsResponse
Int -> ReadS ListFieldsResponse
ReadS [ListFieldsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListFieldsResponse]
$creadListPrec :: ReadPrec [ListFieldsResponse]
readPrec :: ReadPrec ListFieldsResponse
$creadPrec :: ReadPrec ListFieldsResponse
readList :: ReadS [ListFieldsResponse]
$creadList :: ReadS [ListFieldsResponse]
readsPrec :: Int -> ReadS ListFieldsResponse
$creadsPrec :: Int -> ReadS ListFieldsResponse
Prelude.Read, Int -> ListFieldsResponse -> ShowS
[ListFieldsResponse] -> ShowS
ListFieldsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListFieldsResponse] -> ShowS
$cshowList :: [ListFieldsResponse] -> ShowS
show :: ListFieldsResponse -> String
$cshow :: ListFieldsResponse -> String
showsPrec :: Int -> ListFieldsResponse -> ShowS
$cshowsPrec :: Int -> ListFieldsResponse -> ShowS
Prelude.Show, forall x. Rep ListFieldsResponse x -> ListFieldsResponse
forall x. ListFieldsResponse -> Rep ListFieldsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListFieldsResponse x -> ListFieldsResponse
$cfrom :: forall x. ListFieldsResponse -> Rep ListFieldsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListFieldsResponse' 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', 'listFieldsResponse_nextToken' - The token for the next set of results. This is null if there are no more
-- results to return.
--
-- 'httpStatus', 'listFieldsResponse_httpStatus' - The response's http status code.
--
-- 'fields', 'listFieldsResponse_fields' - List of detailed field information.
newListFieldsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListFieldsResponse
newListFieldsResponse :: Int -> ListFieldsResponse
newListFieldsResponse Int
pHttpStatus_ =
  ListFieldsResponse'
    { $sel:nextToken:ListFieldsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListFieldsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:fields:ListFieldsResponse' :: [FieldSummary]
fields = 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.
listFieldsResponse_nextToken :: Lens.Lens' ListFieldsResponse (Prelude.Maybe Prelude.Text)
listFieldsResponse_nextToken :: Lens' ListFieldsResponse (Maybe Text)
listFieldsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFieldsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListFieldsResponse' :: ListFieldsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListFieldsResponse
s@ListFieldsResponse' {} Maybe Text
a -> ListFieldsResponse
s {$sel:nextToken:ListFieldsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListFieldsResponse)

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

-- | List of detailed field information.
listFieldsResponse_fields :: Lens.Lens' ListFieldsResponse [FieldSummary]
listFieldsResponse_fields :: Lens' ListFieldsResponse [FieldSummary]
listFieldsResponse_fields = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFieldsResponse' {[FieldSummary]
fields :: [FieldSummary]
$sel:fields:ListFieldsResponse' :: ListFieldsResponse -> [FieldSummary]
fields} -> [FieldSummary]
fields) (\s :: ListFieldsResponse
s@ListFieldsResponse' {} [FieldSummary]
a -> ListFieldsResponse
s {$sel:fields:ListFieldsResponse' :: [FieldSummary]
fields = [FieldSummary]
a} :: ListFieldsResponse) 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 ListFieldsResponse where
  rnf :: ListFieldsResponse -> ()
rnf ListFieldsResponse' {Int
[FieldSummary]
Maybe Text
fields :: [FieldSummary]
httpStatus :: Int
nextToken :: Maybe Text
$sel:fields:ListFieldsResponse' :: ListFieldsResponse -> [FieldSummary]
$sel:httpStatus:ListFieldsResponse' :: ListFieldsResponse -> Int
$sel:nextToken:ListFieldsResponse' :: ListFieldsResponse -> 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 [FieldSummary]
fields