{-# 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.Chime.ListBots
-- 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 the bots associated with the administrator\'s Amazon Chime
-- Enterprise account ID.
module Amazonka.Chime.ListBots
  ( -- * Creating a Request
    ListBots (..),
    newListBots,

    -- * Request Lenses
    listBots_maxResults,
    listBots_nextToken,
    listBots_accountId,

    -- * Destructuring the Response
    ListBotsResponse (..),
    newListBotsResponse,

    -- * Response Lenses
    listBotsResponse_bots,
    listBotsResponse_nextToken,
    listBotsResponse_httpStatus,
  )
where

import Amazonka.Chime.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:/ 'newListBots' smart constructor.
data ListBots = ListBots'
  { -- | The maximum number of results to return in a single call. The default is
    -- 10.
    ListBots -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token to use to retrieve the next page of results.
    ListBots -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Chime account ID.
    ListBots -> Text
accountId :: Prelude.Text
  }
  deriving (ListBots -> ListBots -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListBots -> ListBots -> Bool
$c/= :: ListBots -> ListBots -> Bool
== :: ListBots -> ListBots -> Bool
$c== :: ListBots -> ListBots -> Bool
Prelude.Eq, ReadPrec [ListBots]
ReadPrec ListBots
Int -> ReadS ListBots
ReadS [ListBots]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListBots]
$creadListPrec :: ReadPrec [ListBots]
readPrec :: ReadPrec ListBots
$creadPrec :: ReadPrec ListBots
readList :: ReadS [ListBots]
$creadList :: ReadS [ListBots]
readsPrec :: Int -> ReadS ListBots
$creadsPrec :: Int -> ReadS ListBots
Prelude.Read, Int -> ListBots -> ShowS
[ListBots] -> ShowS
ListBots -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListBots] -> ShowS
$cshowList :: [ListBots] -> ShowS
show :: ListBots -> String
$cshow :: ListBots -> String
showsPrec :: Int -> ListBots -> ShowS
$cshowsPrec :: Int -> ListBots -> ShowS
Prelude.Show, forall x. Rep ListBots x -> ListBots
forall x. ListBots -> Rep ListBots x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListBots x -> ListBots
$cfrom :: forall x. ListBots -> Rep ListBots x
Prelude.Generic)

-- |
-- Create a value of 'ListBots' 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', 'listBots_maxResults' - The maximum number of results to return in a single call. The default is
-- 10.
--
-- 'nextToken', 'listBots_nextToken' - The token to use to retrieve the next page of results.
--
-- 'accountId', 'listBots_accountId' - The Amazon Chime account ID.
newListBots ::
  -- | 'accountId'
  Prelude.Text ->
  ListBots
newListBots :: Text -> ListBots
newListBots Text
pAccountId_ =
  ListBots'
    { $sel:maxResults:ListBots' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListBots' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:ListBots' :: Text
accountId = Text
pAccountId_
    }

-- | The maximum number of results to return in a single call. The default is
-- 10.
listBots_maxResults :: Lens.Lens' ListBots (Prelude.Maybe Prelude.Natural)
listBots_maxResults :: Lens' ListBots (Maybe Natural)
listBots_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBots' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListBots' :: ListBots -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListBots
s@ListBots' {} Maybe Natural
a -> ListBots
s {$sel:maxResults:ListBots' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListBots)

-- | The token to use to retrieve the next page of results.
listBots_nextToken :: Lens.Lens' ListBots (Prelude.Maybe Prelude.Text)
listBots_nextToken :: Lens' ListBots (Maybe Text)
listBots_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBots' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListBots' :: ListBots -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListBots
s@ListBots' {} Maybe Text
a -> ListBots
s {$sel:nextToken:ListBots' :: Maybe Text
nextToken = Maybe Text
a} :: ListBots)

-- | The Amazon Chime account ID.
listBots_accountId :: Lens.Lens' ListBots Prelude.Text
listBots_accountId :: Lens' ListBots Text
listBots_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBots' {Text
accountId :: Text
$sel:accountId:ListBots' :: ListBots -> Text
accountId} -> Text
accountId) (\s :: ListBots
s@ListBots' {} Text
a -> ListBots
s {$sel:accountId:ListBots' :: Text
accountId = Text
a} :: ListBots)

instance Core.AWSRequest ListBots where
  type AWSResponse ListBots = ListBotsResponse
  request :: (Service -> Service) -> ListBots -> Request ListBots
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 ListBots
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListBots)))
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 [Bot] -> Maybe Text -> Int -> ListBotsResponse
ListBotsResponse'
            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
"Bots" 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.<*> (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))
      )

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

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

instance Data.ToHeaders ListBots where
  toHeaders :: ListBots -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath ListBots where
  toPath :: ListBots -> ByteString
toPath ListBots' {Maybe Natural
Maybe Text
Text
accountId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:accountId:ListBots' :: ListBots -> Text
$sel:nextToken:ListBots' :: ListBots -> Maybe Text
$sel:maxResults:ListBots' :: ListBots -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/accounts/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
accountId, ByteString
"/bots"]

instance Data.ToQuery ListBots where
  toQuery :: ListBots -> QueryString
toQuery ListBots' {Maybe Natural
Maybe Text
Text
accountId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:accountId:ListBots' :: ListBots -> Text
$sel:nextToken:ListBots' :: ListBots -> Maybe Text
$sel:maxResults:ListBots' :: ListBots -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"max-results" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"next-token" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newListBotsResponse' smart constructor.
data ListBotsResponse = ListBotsResponse'
  { -- | List of bots and bot details.
    ListBotsResponse -> Maybe [Bot]
bots :: Prelude.Maybe [Bot],
    -- | The token to use to retrieve the next page of results.
    ListBotsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListBotsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListBotsResponse -> ListBotsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListBotsResponse -> ListBotsResponse -> Bool
$c/= :: ListBotsResponse -> ListBotsResponse -> Bool
== :: ListBotsResponse -> ListBotsResponse -> Bool
$c== :: ListBotsResponse -> ListBotsResponse -> Bool
Prelude.Eq, Int -> ListBotsResponse -> ShowS
[ListBotsResponse] -> ShowS
ListBotsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListBotsResponse] -> ShowS
$cshowList :: [ListBotsResponse] -> ShowS
show :: ListBotsResponse -> String
$cshow :: ListBotsResponse -> String
showsPrec :: Int -> ListBotsResponse -> ShowS
$cshowsPrec :: Int -> ListBotsResponse -> ShowS
Prelude.Show, forall x. Rep ListBotsResponse x -> ListBotsResponse
forall x. ListBotsResponse -> Rep ListBotsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListBotsResponse x -> ListBotsResponse
$cfrom :: forall x. ListBotsResponse -> Rep ListBotsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListBotsResponse' 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:
--
-- 'bots', 'listBotsResponse_bots' - List of bots and bot details.
--
-- 'nextToken', 'listBotsResponse_nextToken' - The token to use to retrieve the next page of results.
--
-- 'httpStatus', 'listBotsResponse_httpStatus' - The response's http status code.
newListBotsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListBotsResponse
newListBotsResponse :: Int -> ListBotsResponse
newListBotsResponse Int
pHttpStatus_ =
  ListBotsResponse'
    { $sel:bots:ListBotsResponse' :: Maybe [Bot]
bots = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListBotsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListBotsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | List of bots and bot details.
listBotsResponse_bots :: Lens.Lens' ListBotsResponse (Prelude.Maybe [Bot])
listBotsResponse_bots :: Lens' ListBotsResponse (Maybe [Bot])
listBotsResponse_bots = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBotsResponse' {Maybe [Bot]
bots :: Maybe [Bot]
$sel:bots:ListBotsResponse' :: ListBotsResponse -> Maybe [Bot]
bots} -> Maybe [Bot]
bots) (\s :: ListBotsResponse
s@ListBotsResponse' {} Maybe [Bot]
a -> ListBotsResponse
s {$sel:bots:ListBotsResponse' :: Maybe [Bot]
bots = Maybe [Bot]
a} :: ListBotsResponse) 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 token to use to retrieve the next page of results.
listBotsResponse_nextToken :: Lens.Lens' ListBotsResponse (Prelude.Maybe Prelude.Text)
listBotsResponse_nextToken :: Lens' ListBotsResponse (Maybe Text)
listBotsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBotsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListBotsResponse' :: ListBotsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListBotsResponse
s@ListBotsResponse' {} Maybe Text
a -> ListBotsResponse
s {$sel:nextToken:ListBotsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListBotsResponse)

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

instance Prelude.NFData ListBotsResponse where
  rnf :: ListBotsResponse -> ()
rnf ListBotsResponse' {Int
Maybe [Bot]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
bots :: Maybe [Bot]
$sel:httpStatus:ListBotsResponse' :: ListBotsResponse -> Int
$sel:nextToken:ListBotsResponse' :: ListBotsResponse -> Maybe Text
$sel:bots:ListBotsResponse' :: ListBotsResponse -> Maybe [Bot]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Bot]
bots
      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 Int
httpStatus