{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- 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_nextToken,
    listBots_maxResults,
    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.Lens as Lens
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 token to use to retrieve the next page of results.
    ListBots -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return in a single call. The default is
    -- 10.
    ListBots -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The Amazon Chime account ID.
    ListBots -> Text
accountId :: Prelude.Text
  }
  deriving (ListBots -> ListBots -> Bool
(ListBots -> ListBots -> Bool)
-> (ListBots -> ListBots -> Bool) -> Eq ListBots
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]
(Int -> ReadS ListBots)
-> ReadS [ListBots]
-> ReadPrec ListBots
-> ReadPrec [ListBots]
-> Read 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
(Int -> ListBots -> ShowS)
-> (ListBots -> String) -> ([ListBots] -> ShowS) -> Show ListBots
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. ListBots -> Rep ListBots x)
-> (forall x. Rep ListBots x -> ListBots) -> Generic ListBots
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:
--
-- 'nextToken', 'listBots_nextToken' - The token to use to retrieve the next page of results.
--
-- 'maxResults', 'listBots_maxResults' - The maximum number of results to return in a single call. The default is
-- 10.
--
-- 'accountId', 'listBots_accountId' - The Amazon Chime account ID.
newListBots ::
  -- | 'accountId'
  Prelude.Text ->
  ListBots
newListBots :: Text -> ListBots
newListBots Text
pAccountId_ =
  ListBots' :: Maybe Text -> Maybe Natural -> Text -> ListBots
ListBots'
    { $sel:nextToken:ListBots' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListBots' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:ListBots' :: Text
accountId = Text
pAccountId_
    }

-- | The token to use to retrieve the next page of results.
listBots_nextToken :: Lens.Lens' ListBots (Prelude.Maybe Prelude.Text)
listBots_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListBots -> f ListBots
listBots_nextToken = (ListBots -> Maybe Text)
-> (ListBots -> Maybe Text -> ListBots)
-> Lens ListBots ListBots (Maybe Text) (Maybe Text)
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 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 :: (Maybe Natural -> f (Maybe Natural)) -> ListBots -> f ListBots
listBots_maxResults = (ListBots -> Maybe Natural)
-> (ListBots -> Maybe Natural -> ListBots)
-> Lens ListBots ListBots (Maybe Natural) (Maybe Natural)
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 Amazon Chime account ID.
listBots_accountId :: Lens.Lens' ListBots Prelude.Text
listBots_accountId :: (Text -> f Text) -> ListBots -> f ListBots
listBots_accountId = (ListBots -> Text)
-> (ListBots -> Text -> ListBots)
-> Lens ListBots ListBots Text Text
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 :: ListBots -> Request ListBots
request = Service -> ListBots -> Request ListBots
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListBots
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListBots)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListBots))
-> Logger
-> Service
-> Proxy ListBots
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListBots)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> 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'
            (Maybe [Bot] -> Maybe Text -> Int -> ListBotsResponse)
-> Either String (Maybe [Bot])
-> Either String (Maybe Text -> Int -> ListBotsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Bot]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Bots" Either String (Maybe (Maybe [Bot]))
-> Maybe [Bot] -> Either String (Maybe [Bot])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Bot]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Maybe Text -> Int -> ListBotsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListBotsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either String (Int -> ListBotsResponse)
-> Either String Int -> Either String ListBotsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListBots

instance Prelude.NFData ListBots

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

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

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

-- | /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
(ListBotsResponse -> ListBotsResponse -> Bool)
-> (ListBotsResponse -> ListBotsResponse -> Bool)
-> Eq ListBotsResponse
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
(Int -> ListBotsResponse -> ShowS)
-> (ListBotsResponse -> String)
-> ([ListBotsResponse] -> ShowS)
-> Show ListBotsResponse
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. ListBotsResponse -> Rep ListBotsResponse x)
-> (forall x. Rep ListBotsResponse x -> ListBotsResponse)
-> Generic ListBotsResponse
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' :: Maybe [Bot] -> Maybe Text -> Int -> ListBotsResponse
ListBotsResponse'
    { $sel:bots:ListBotsResponse' :: Maybe [Bot]
bots = Maybe [Bot]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListBotsResponse' :: Maybe Text
nextToken = Maybe Text
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 :: (Maybe [Bot] -> f (Maybe [Bot]))
-> ListBotsResponse -> f ListBotsResponse
listBotsResponse_bots = (ListBotsResponse -> Maybe [Bot])
-> (ListBotsResponse -> Maybe [Bot] -> ListBotsResponse)
-> Lens
     ListBotsResponse ListBotsResponse (Maybe [Bot]) (Maybe [Bot])
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) ((Maybe [Bot] -> f (Maybe [Bot]))
 -> ListBotsResponse -> f ListBotsResponse)
-> ((Maybe [Bot] -> f (Maybe [Bot]))
    -> Maybe [Bot] -> f (Maybe [Bot]))
-> (Maybe [Bot] -> f (Maybe [Bot]))
-> ListBotsResponse
-> f ListBotsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Bot] [Bot] [Bot] [Bot]
-> Iso (Maybe [Bot]) (Maybe [Bot]) (Maybe [Bot]) (Maybe [Bot])
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 AnIso [Bot] [Bot] [Bot] [Bot]
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 :: (Maybe Text -> f (Maybe Text))
-> ListBotsResponse -> f ListBotsResponse
listBotsResponse_nextToken = (ListBotsResponse -> Maybe Text)
-> (ListBotsResponse -> Maybe Text -> ListBotsResponse)
-> Lens ListBotsResponse ListBotsResponse (Maybe Text) (Maybe Text)
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 :: (Int -> f Int) -> ListBotsResponse -> f ListBotsResponse
listBotsResponse_httpStatus = (ListBotsResponse -> Int)
-> (ListBotsResponse -> Int -> ListBotsResponse)
-> Lens ListBotsResponse ListBotsResponse Int Int
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