{-# 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.Connect.ListPrompts
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Provides information about the prompts for the specified Amazon Connect
-- instance.
--
-- This operation returns paginated results.
module Amazonka.Connect.ListPrompts
  ( -- * Creating a Request
    ListPrompts (..),
    newListPrompts,

    -- * Request Lenses
    listPrompts_maxResults,
    listPrompts_nextToken,
    listPrompts_instanceId,

    -- * Destructuring the Response
    ListPromptsResponse (..),
    newListPromptsResponse,

    -- * Response Lenses
    listPromptsResponse_nextToken,
    listPromptsResponse_promptSummaryList,
    listPromptsResponse_httpStatus,
  )
where

import Amazonka.Connect.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:/ 'newListPrompts' smart constructor.
data ListPrompts = ListPrompts'
  { -- | The maximum number of results to return per page. The default MaxResult
    -- size is 100.
    ListPrompts -> 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.
    ListPrompts -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The identifier of the Amazon Connect instance.
    ListPrompts -> Text
instanceId :: Prelude.Text
  }
  deriving (ListPrompts -> ListPrompts -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPrompts -> ListPrompts -> Bool
$c/= :: ListPrompts -> ListPrompts -> Bool
== :: ListPrompts -> ListPrompts -> Bool
$c== :: ListPrompts -> ListPrompts -> Bool
Prelude.Eq, ReadPrec [ListPrompts]
ReadPrec ListPrompts
Int -> ReadS ListPrompts
ReadS [ListPrompts]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPrompts]
$creadListPrec :: ReadPrec [ListPrompts]
readPrec :: ReadPrec ListPrompts
$creadPrec :: ReadPrec ListPrompts
readList :: ReadS [ListPrompts]
$creadList :: ReadS [ListPrompts]
readsPrec :: Int -> ReadS ListPrompts
$creadsPrec :: Int -> ReadS ListPrompts
Prelude.Read, Int -> ListPrompts -> ShowS
[ListPrompts] -> ShowS
ListPrompts -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPrompts] -> ShowS
$cshowList :: [ListPrompts] -> ShowS
show :: ListPrompts -> String
$cshow :: ListPrompts -> String
showsPrec :: Int -> ListPrompts -> ShowS
$cshowsPrec :: Int -> ListPrompts -> ShowS
Prelude.Show, forall x. Rep ListPrompts x -> ListPrompts
forall x. ListPrompts -> Rep ListPrompts x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPrompts x -> ListPrompts
$cfrom :: forall x. ListPrompts -> Rep ListPrompts x
Prelude.Generic)

-- |
-- Create a value of 'ListPrompts' 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', 'listPrompts_maxResults' - The maximum number of results to return per page. The default MaxResult
-- size is 100.
--
-- 'nextToken', 'listPrompts_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.
--
-- 'instanceId', 'listPrompts_instanceId' - The identifier of the Amazon Connect instance.
newListPrompts ::
  -- | 'instanceId'
  Prelude.Text ->
  ListPrompts
newListPrompts :: Text -> ListPrompts
newListPrompts Text
pInstanceId_ =
  ListPrompts'
    { $sel:maxResults:ListPrompts' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListPrompts' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceId:ListPrompts' :: Text
instanceId = Text
pInstanceId_
    }

-- | The maximum number of results to return per page. The default MaxResult
-- size is 100.
listPrompts_maxResults :: Lens.Lens' ListPrompts (Prelude.Maybe Prelude.Natural)
listPrompts_maxResults :: Lens' ListPrompts (Maybe Natural)
listPrompts_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPrompts' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListPrompts' :: ListPrompts -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListPrompts
s@ListPrompts' {} Maybe Natural
a -> ListPrompts
s {$sel:maxResults:ListPrompts' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListPrompts)

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

-- | The identifier of the Amazon Connect instance.
listPrompts_instanceId :: Lens.Lens' ListPrompts Prelude.Text
listPrompts_instanceId :: Lens' ListPrompts Text
listPrompts_instanceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPrompts' {Text
instanceId :: Text
$sel:instanceId:ListPrompts' :: ListPrompts -> Text
instanceId} -> Text
instanceId) (\s :: ListPrompts
s@ListPrompts' {} Text
a -> ListPrompts
s {$sel:instanceId:ListPrompts' :: Text
instanceId = Text
a} :: ListPrompts)

instance Core.AWSPager ListPrompts where
  page :: ListPrompts -> AWSResponse ListPrompts -> Maybe ListPrompts
page ListPrompts
rq AWSResponse ListPrompts
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListPrompts
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListPromptsResponse (Maybe Text)
listPromptsResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListPrompts
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListPromptsResponse (Maybe [PromptSummary])
listPromptsResponse_promptSummaryList
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListPrompts
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListPrompts (Maybe Text)
listPrompts_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListPrompts
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListPromptsResponse (Maybe Text)
listPromptsResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListPrompts where
  type AWSResponse ListPrompts = ListPromptsResponse
  request :: (Service -> Service) -> ListPrompts -> Request ListPrompts
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListPrompts
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListPrompts)))
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 -> Maybe [PromptSummary] -> Int -> ListPromptsResponse
ListPromptsResponse'
            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.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"PromptSummaryList"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            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))
      )

instance Prelude.Hashable ListPrompts where
  hashWithSalt :: Int -> ListPrompts -> Int
hashWithSalt Int
_salt ListPrompts' {Maybe Natural
Maybe Text
Text
instanceId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:instanceId:ListPrompts' :: ListPrompts -> Text
$sel:nextToken:ListPrompts' :: ListPrompts -> Maybe Text
$sel:maxResults:ListPrompts' :: ListPrompts -> 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
instanceId

instance Prelude.NFData ListPrompts where
  rnf :: ListPrompts -> ()
rnf ListPrompts' {Maybe Natural
Maybe Text
Text
instanceId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:instanceId:ListPrompts' :: ListPrompts -> Text
$sel:nextToken:ListPrompts' :: ListPrompts -> Maybe Text
$sel:maxResults:ListPrompts' :: ListPrompts -> 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
instanceId

instance Data.ToHeaders ListPrompts where
  toHeaders :: ListPrompts -> 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.ToPath ListPrompts where
  toPath :: ListPrompts -> ByteString
toPath ListPrompts' {Maybe Natural
Maybe Text
Text
instanceId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:instanceId:ListPrompts' :: ListPrompts -> Text
$sel:nextToken:ListPrompts' :: ListPrompts -> Maybe Text
$sel:maxResults:ListPrompts' :: ListPrompts -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/prompts-summary/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
instanceId]

instance Data.ToQuery ListPrompts where
  toQuery :: ListPrompts -> QueryString
toQuery ListPrompts' {Maybe Natural
Maybe Text
Text
instanceId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:instanceId:ListPrompts' :: ListPrompts -> Text
$sel:nextToken:ListPrompts' :: ListPrompts -> Maybe Text
$sel:maxResults:ListPrompts' :: ListPrompts -> 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:/ 'newListPromptsResponse' smart constructor.
data ListPromptsResponse = ListPromptsResponse'
  { -- | If there are additional results, this is the token for the next set of
    -- results.
    ListPromptsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Information about the prompts.
    ListPromptsResponse -> Maybe [PromptSummary]
promptSummaryList :: Prelude.Maybe [PromptSummary],
    -- | The response's http status code.
    ListPromptsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListPromptsResponse -> ListPromptsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPromptsResponse -> ListPromptsResponse -> Bool
$c/= :: ListPromptsResponse -> ListPromptsResponse -> Bool
== :: ListPromptsResponse -> ListPromptsResponse -> Bool
$c== :: ListPromptsResponse -> ListPromptsResponse -> Bool
Prelude.Eq, ReadPrec [ListPromptsResponse]
ReadPrec ListPromptsResponse
Int -> ReadS ListPromptsResponse
ReadS [ListPromptsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPromptsResponse]
$creadListPrec :: ReadPrec [ListPromptsResponse]
readPrec :: ReadPrec ListPromptsResponse
$creadPrec :: ReadPrec ListPromptsResponse
readList :: ReadS [ListPromptsResponse]
$creadList :: ReadS [ListPromptsResponse]
readsPrec :: Int -> ReadS ListPromptsResponse
$creadsPrec :: Int -> ReadS ListPromptsResponse
Prelude.Read, Int -> ListPromptsResponse -> ShowS
[ListPromptsResponse] -> ShowS
ListPromptsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPromptsResponse] -> ShowS
$cshowList :: [ListPromptsResponse] -> ShowS
show :: ListPromptsResponse -> String
$cshow :: ListPromptsResponse -> String
showsPrec :: Int -> ListPromptsResponse -> ShowS
$cshowsPrec :: Int -> ListPromptsResponse -> ShowS
Prelude.Show, forall x. Rep ListPromptsResponse x -> ListPromptsResponse
forall x. ListPromptsResponse -> Rep ListPromptsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPromptsResponse x -> ListPromptsResponse
$cfrom :: forall x. ListPromptsResponse -> Rep ListPromptsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListPromptsResponse' 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', 'listPromptsResponse_nextToken' - If there are additional results, this is the token for the next set of
-- results.
--
-- 'promptSummaryList', 'listPromptsResponse_promptSummaryList' - Information about the prompts.
--
-- 'httpStatus', 'listPromptsResponse_httpStatus' - The response's http status code.
newListPromptsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListPromptsResponse
newListPromptsResponse :: Int -> ListPromptsResponse
newListPromptsResponse Int
pHttpStatus_ =
  ListPromptsResponse'
    { $sel:nextToken:ListPromptsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:promptSummaryList:ListPromptsResponse' :: Maybe [PromptSummary]
promptSummaryList = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListPromptsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | If there are additional results, this is the token for the next set of
-- results.
listPromptsResponse_nextToken :: Lens.Lens' ListPromptsResponse (Prelude.Maybe Prelude.Text)
listPromptsResponse_nextToken :: Lens' ListPromptsResponse (Maybe Text)
listPromptsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPromptsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListPromptsResponse' :: ListPromptsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListPromptsResponse
s@ListPromptsResponse' {} Maybe Text
a -> ListPromptsResponse
s {$sel:nextToken:ListPromptsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListPromptsResponse)

-- | Information about the prompts.
listPromptsResponse_promptSummaryList :: Lens.Lens' ListPromptsResponse (Prelude.Maybe [PromptSummary])
listPromptsResponse_promptSummaryList :: Lens' ListPromptsResponse (Maybe [PromptSummary])
listPromptsResponse_promptSummaryList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPromptsResponse' {Maybe [PromptSummary]
promptSummaryList :: Maybe [PromptSummary]
$sel:promptSummaryList:ListPromptsResponse' :: ListPromptsResponse -> Maybe [PromptSummary]
promptSummaryList} -> Maybe [PromptSummary]
promptSummaryList) (\s :: ListPromptsResponse
s@ListPromptsResponse' {} Maybe [PromptSummary]
a -> ListPromptsResponse
s {$sel:promptSummaryList:ListPromptsResponse' :: Maybe [PromptSummary]
promptSummaryList = Maybe [PromptSummary]
a} :: ListPromptsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListPromptsResponse where
  rnf :: ListPromptsResponse -> ()
rnf ListPromptsResponse' {Int
Maybe [PromptSummary]
Maybe Text
httpStatus :: Int
promptSummaryList :: Maybe [PromptSummary]
nextToken :: Maybe Text
$sel:httpStatus:ListPromptsResponse' :: ListPromptsResponse -> Int
$sel:promptSummaryList:ListPromptsResponse' :: ListPromptsResponse -> Maybe [PromptSummary]
$sel:nextToken:ListPromptsResponse' :: ListPromptsResponse -> 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 Maybe [PromptSummary]
promptSummaryList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus