{-# 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.Wisdom.ListAssistants
-- 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 information about assistants.
--
-- This operation returns paginated results.
module Amazonka.Wisdom.ListAssistants
  ( -- * Creating a Request
    ListAssistants (..),
    newListAssistants,

    -- * Request Lenses
    listAssistants_maxResults,
    listAssistants_nextToken,

    -- * Destructuring the Response
    ListAssistantsResponse (..),
    newListAssistantsResponse,

    -- * Response Lenses
    listAssistantsResponse_nextToken,
    listAssistantsResponse_httpStatus,
    listAssistantsResponse_assistantSummaries,
  )
where

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

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

-- |
-- Create a value of 'ListAssistants' 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', 'listAssistants_maxResults' - The maximum number of results to return per page.
--
-- 'nextToken', 'listAssistants_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.
newListAssistants ::
  ListAssistants
newListAssistants :: ListAssistants
newListAssistants =
  ListAssistants'
    { $sel:maxResults:ListAssistants' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAssistants' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

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

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

instance Core.AWSPager ListAssistants where
  page :: ListAssistants
-> AWSResponse ListAssistants -> Maybe ListAssistants
page ListAssistants
rq AWSResponse ListAssistants
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAssistants
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListAssistantsResponse (Maybe Text)
listAssistantsResponse_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 ListAssistants
rs
            forall s a. s -> Getting a s a -> a
Lens.^. Lens' ListAssistantsResponse [AssistantSummary]
listAssistantsResponse_assistantSummaries
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListAssistants
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListAssistants (Maybe Text)
listAssistants_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListAssistants
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListAssistantsResponse (Maybe Text)
listAssistantsResponse_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 ListAssistants where
  type
    AWSResponse ListAssistants =
      ListAssistantsResponse
  request :: (Service -> Service) -> ListAssistants -> Request ListAssistants
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 ListAssistants
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListAssistants)))
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 -> [AssistantSummary] -> ListAssistantsResponse
ListAssistantsResponse'
            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
"assistantSummaries"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
      )

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

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

instance Data.ToHeaders ListAssistants where
  toHeaders :: ListAssistants -> 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 ListAssistants where
  toPath :: ListAssistants -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/assistants"

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

-- |
-- Create a value of 'ListAssistantsResponse' 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', 'listAssistantsResponse_nextToken' - If there are additional results, this is the token for the next set of
-- results.
--
-- 'httpStatus', 'listAssistantsResponse_httpStatus' - The response's http status code.
--
-- 'assistantSummaries', 'listAssistantsResponse_assistantSummaries' - Information about the assistants.
newListAssistantsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAssistantsResponse
newListAssistantsResponse :: Int -> ListAssistantsResponse
newListAssistantsResponse Int
pHttpStatus_ =
  ListAssistantsResponse'
    { $sel:nextToken:ListAssistantsResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAssistantsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:assistantSummaries:ListAssistantsResponse' :: [AssistantSummary]
assistantSummaries = forall a. Monoid a => a
Prelude.mempty
    }

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

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

-- | Information about the assistants.
listAssistantsResponse_assistantSummaries :: Lens.Lens' ListAssistantsResponse [AssistantSummary]
listAssistantsResponse_assistantSummaries :: Lens' ListAssistantsResponse [AssistantSummary]
listAssistantsResponse_assistantSummaries = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssistantsResponse' {[AssistantSummary]
assistantSummaries :: [AssistantSummary]
$sel:assistantSummaries:ListAssistantsResponse' :: ListAssistantsResponse -> [AssistantSummary]
assistantSummaries} -> [AssistantSummary]
assistantSummaries) (\s :: ListAssistantsResponse
s@ListAssistantsResponse' {} [AssistantSummary]
a -> ListAssistantsResponse
s {$sel:assistantSummaries:ListAssistantsResponse' :: [AssistantSummary]
assistantSummaries = [AssistantSummary]
a} :: ListAssistantsResponse) 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 ListAssistantsResponse where
  rnf :: ListAssistantsResponse -> ()
rnf ListAssistantsResponse' {Int
[AssistantSummary]
Maybe Text
assistantSummaries :: [AssistantSummary]
httpStatus :: Int
nextToken :: Maybe Text
$sel:assistantSummaries:ListAssistantsResponse' :: ListAssistantsResponse -> [AssistantSummary]
$sel:httpStatus:ListAssistantsResponse' :: ListAssistantsResponse -> Int
$sel:nextToken:ListAssistantsResponse' :: ListAssistantsResponse -> 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 [AssistantSummary]
assistantSummaries