{-# 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.RedshiftData.ListDatabases
-- 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)
--
-- List the databases in a cluster. A token is returned to page through the
-- database list. Depending on the authorization method, use one of the
-- following combinations of request parameters:
--
-- -   Secrets Manager - specify the Amazon Resource Name (ARN) of the
--     secret, the database name, and the cluster identifier that matches
--     the cluster in the secret.
--
-- -   Temporary credentials - specify the cluster identifier, the database
--     name, and the database user name. Permission to call the
--     @redshift:GetClusterCredentials@ operation is required to use this
--     method.
--
-- This operation returns paginated results.
module Amazonka.RedshiftData.ListDatabases
  ( -- * Creating a Request
    ListDatabases (..),
    newListDatabases,

    -- * Request Lenses
    listDatabases_dbUser,
    listDatabases_nextToken,
    listDatabases_secretArn,
    listDatabases_maxResults,
    listDatabases_clusterIdentifier,
    listDatabases_database,

    -- * Destructuring the Response
    ListDatabasesResponse (..),
    newListDatabasesResponse,

    -- * Response Lenses
    listDatabasesResponse_nextToken,
    listDatabasesResponse_databases,
    listDatabasesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.RedshiftData.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListDatabases' smart constructor.
data ListDatabases = ListDatabases'
  { -- | The database user name. This parameter is required when authenticating
    -- using temporary credentials.
    ListDatabases -> Maybe Text
dbUser :: Prelude.Maybe Prelude.Text,
    -- | A value that indicates the starting point for the next set of response
    -- records in a subsequent request. If a value is returned in a response,
    -- you can retrieve the next set of records by providing this returned
    -- NextToken value in the next NextToken parameter and retrying the
    -- command. If the NextToken field is empty, all response records have been
    -- retrieved for the request.
    ListDatabases -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The name or ARN of the secret that enables access to the database. This
    -- parameter is required when authenticating using Secrets Manager.
    ListDatabases -> Maybe Text
secretArn :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of databases to return in the response. If more
    -- databases exist than fit in one response, then @NextToken@ is returned
    -- to page through the results.
    ListDatabases -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The cluster identifier. This parameter is required when authenticating
    -- using either Secrets Manager or temporary credentials.
    ListDatabases -> Text
clusterIdentifier :: Prelude.Text,
    -- | The name of the database. This parameter is required when authenticating
    -- using either Secrets Manager or temporary credentials.
    ListDatabases -> Text
database :: Prelude.Text
  }
  deriving (ListDatabases -> ListDatabases -> Bool
(ListDatabases -> ListDatabases -> Bool)
-> (ListDatabases -> ListDatabases -> Bool) -> Eq ListDatabases
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDatabases -> ListDatabases -> Bool
$c/= :: ListDatabases -> ListDatabases -> Bool
== :: ListDatabases -> ListDatabases -> Bool
$c== :: ListDatabases -> ListDatabases -> Bool
Prelude.Eq, ReadPrec [ListDatabases]
ReadPrec ListDatabases
Int -> ReadS ListDatabases
ReadS [ListDatabases]
(Int -> ReadS ListDatabases)
-> ReadS [ListDatabases]
-> ReadPrec ListDatabases
-> ReadPrec [ListDatabases]
-> Read ListDatabases
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDatabases]
$creadListPrec :: ReadPrec [ListDatabases]
readPrec :: ReadPrec ListDatabases
$creadPrec :: ReadPrec ListDatabases
readList :: ReadS [ListDatabases]
$creadList :: ReadS [ListDatabases]
readsPrec :: Int -> ReadS ListDatabases
$creadsPrec :: Int -> ReadS ListDatabases
Prelude.Read, Int -> ListDatabases -> ShowS
[ListDatabases] -> ShowS
ListDatabases -> String
(Int -> ListDatabases -> ShowS)
-> (ListDatabases -> String)
-> ([ListDatabases] -> ShowS)
-> Show ListDatabases
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDatabases] -> ShowS
$cshowList :: [ListDatabases] -> ShowS
show :: ListDatabases -> String
$cshow :: ListDatabases -> String
showsPrec :: Int -> ListDatabases -> ShowS
$cshowsPrec :: Int -> ListDatabases -> ShowS
Prelude.Show, (forall x. ListDatabases -> Rep ListDatabases x)
-> (forall x. Rep ListDatabases x -> ListDatabases)
-> Generic ListDatabases
forall x. Rep ListDatabases x -> ListDatabases
forall x. ListDatabases -> Rep ListDatabases x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDatabases x -> ListDatabases
$cfrom :: forall x. ListDatabases -> Rep ListDatabases x
Prelude.Generic)

-- |
-- Create a value of 'ListDatabases' 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:
--
-- 'dbUser', 'listDatabases_dbUser' - The database user name. This parameter is required when authenticating
-- using temporary credentials.
--
-- 'nextToken', 'listDatabases_nextToken' - A value that indicates the starting point for the next set of response
-- records in a subsequent request. If a value is returned in a response,
-- you can retrieve the next set of records by providing this returned
-- NextToken value in the next NextToken parameter and retrying the
-- command. If the NextToken field is empty, all response records have been
-- retrieved for the request.
--
-- 'secretArn', 'listDatabases_secretArn' - The name or ARN of the secret that enables access to the database. This
-- parameter is required when authenticating using Secrets Manager.
--
-- 'maxResults', 'listDatabases_maxResults' - The maximum number of databases to return in the response. If more
-- databases exist than fit in one response, then @NextToken@ is returned
-- to page through the results.
--
-- 'clusterIdentifier', 'listDatabases_clusterIdentifier' - The cluster identifier. This parameter is required when authenticating
-- using either Secrets Manager or temporary credentials.
--
-- 'database', 'listDatabases_database' - The name of the database. This parameter is required when authenticating
-- using either Secrets Manager or temporary credentials.
newListDatabases ::
  -- | 'clusterIdentifier'
  Prelude.Text ->
  -- | 'database'
  Prelude.Text ->
  ListDatabases
newListDatabases :: Text -> Text -> ListDatabases
newListDatabases Text
pClusterIdentifier_ Text
pDatabase_ =
  ListDatabases' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Text
-> Text
-> ListDatabases
ListDatabases'
    { $sel:dbUser:ListDatabases' :: Maybe Text
dbUser = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDatabases' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:secretArn:ListDatabases' :: Maybe Text
secretArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListDatabases' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:clusterIdentifier:ListDatabases' :: Text
clusterIdentifier = Text
pClusterIdentifier_,
      $sel:database:ListDatabases' :: Text
database = Text
pDatabase_
    }

-- | The database user name. This parameter is required when authenticating
-- using temporary credentials.
listDatabases_dbUser :: Lens.Lens' ListDatabases (Prelude.Maybe Prelude.Text)
listDatabases_dbUser :: (Maybe Text -> f (Maybe Text)) -> ListDatabases -> f ListDatabases
listDatabases_dbUser = (ListDatabases -> Maybe Text)
-> (ListDatabases -> Maybe Text -> ListDatabases)
-> Lens ListDatabases ListDatabases (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDatabases' {Maybe Text
dbUser :: Maybe Text
$sel:dbUser:ListDatabases' :: ListDatabases -> Maybe Text
dbUser} -> Maybe Text
dbUser) (\s :: ListDatabases
s@ListDatabases' {} Maybe Text
a -> ListDatabases
s {$sel:dbUser:ListDatabases' :: Maybe Text
dbUser = Maybe Text
a} :: ListDatabases)

-- | A value that indicates the starting point for the next set of response
-- records in a subsequent request. If a value is returned in a response,
-- you can retrieve the next set of records by providing this returned
-- NextToken value in the next NextToken parameter and retrying the
-- command. If the NextToken field is empty, all response records have been
-- retrieved for the request.
listDatabases_nextToken :: Lens.Lens' ListDatabases (Prelude.Maybe Prelude.Text)
listDatabases_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListDatabases -> f ListDatabases
listDatabases_nextToken = (ListDatabases -> Maybe Text)
-> (ListDatabases -> Maybe Text -> ListDatabases)
-> Lens ListDatabases ListDatabases (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDatabases' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDatabases' :: ListDatabases -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDatabases
s@ListDatabases' {} Maybe Text
a -> ListDatabases
s {$sel:nextToken:ListDatabases' :: Maybe Text
nextToken = Maybe Text
a} :: ListDatabases)

-- | The name or ARN of the secret that enables access to the database. This
-- parameter is required when authenticating using Secrets Manager.
listDatabases_secretArn :: Lens.Lens' ListDatabases (Prelude.Maybe Prelude.Text)
listDatabases_secretArn :: (Maybe Text -> f (Maybe Text)) -> ListDatabases -> f ListDatabases
listDatabases_secretArn = (ListDatabases -> Maybe Text)
-> (ListDatabases -> Maybe Text -> ListDatabases)
-> Lens ListDatabases ListDatabases (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDatabases' {Maybe Text
secretArn :: Maybe Text
$sel:secretArn:ListDatabases' :: ListDatabases -> Maybe Text
secretArn} -> Maybe Text
secretArn) (\s :: ListDatabases
s@ListDatabases' {} Maybe Text
a -> ListDatabases
s {$sel:secretArn:ListDatabases' :: Maybe Text
secretArn = Maybe Text
a} :: ListDatabases)

-- | The maximum number of databases to return in the response. If more
-- databases exist than fit in one response, then @NextToken@ is returned
-- to page through the results.
listDatabases_maxResults :: Lens.Lens' ListDatabases (Prelude.Maybe Prelude.Natural)
listDatabases_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListDatabases -> f ListDatabases
listDatabases_maxResults = (ListDatabases -> Maybe Natural)
-> (ListDatabases -> Maybe Natural -> ListDatabases)
-> Lens ListDatabases ListDatabases (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDatabases' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListDatabases' :: ListDatabases -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListDatabases
s@ListDatabases' {} Maybe Natural
a -> ListDatabases
s {$sel:maxResults:ListDatabases' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListDatabases)

-- | The cluster identifier. This parameter is required when authenticating
-- using either Secrets Manager or temporary credentials.
listDatabases_clusterIdentifier :: Lens.Lens' ListDatabases Prelude.Text
listDatabases_clusterIdentifier :: (Text -> f Text) -> ListDatabases -> f ListDatabases
listDatabases_clusterIdentifier = (ListDatabases -> Text)
-> (ListDatabases -> Text -> ListDatabases)
-> Lens ListDatabases ListDatabases Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDatabases' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:ListDatabases' :: ListDatabases -> Text
clusterIdentifier} -> Text
clusterIdentifier) (\s :: ListDatabases
s@ListDatabases' {} Text
a -> ListDatabases
s {$sel:clusterIdentifier:ListDatabases' :: Text
clusterIdentifier = Text
a} :: ListDatabases)

-- | The name of the database. This parameter is required when authenticating
-- using either Secrets Manager or temporary credentials.
listDatabases_database :: Lens.Lens' ListDatabases Prelude.Text
listDatabases_database :: (Text -> f Text) -> ListDatabases -> f ListDatabases
listDatabases_database = (ListDatabases -> Text)
-> (ListDatabases -> Text -> ListDatabases)
-> Lens ListDatabases ListDatabases Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDatabases' {Text
database :: Text
$sel:database:ListDatabases' :: ListDatabases -> Text
database} -> Text
database) (\s :: ListDatabases
s@ListDatabases' {} Text
a -> ListDatabases
s {$sel:database:ListDatabases' :: Text
database = Text
a} :: ListDatabases)

instance Core.AWSPager ListDatabases where
  page :: ListDatabases -> AWSResponse ListDatabases -> Maybe ListDatabases
page ListDatabases
rq AWSResponse ListDatabases
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListDatabases
ListDatabasesResponse
rs
            ListDatabasesResponse
-> Getting (First Text) ListDatabasesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListDatabasesResponse
-> Const (First Text) ListDatabasesResponse
Lens' ListDatabasesResponse (Maybe Text)
listDatabasesResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListDatabasesResponse
 -> Const (First Text) ListDatabasesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListDatabasesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListDatabases
forall a. Maybe a
Prelude.Nothing
    | Maybe [Text] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListDatabases
ListDatabasesResponse
rs
            ListDatabasesResponse
-> Getting (First [Text]) ListDatabasesResponse [Text]
-> Maybe [Text]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
-> ListDatabasesResponse
-> Const (First [Text]) ListDatabasesResponse
Lens' ListDatabasesResponse (Maybe [Text])
listDatabasesResponse_databases ((Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
 -> ListDatabasesResponse
 -> Const (First [Text]) ListDatabasesResponse)
-> (([Text] -> Const (First [Text]) [Text])
    -> Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
-> Getting (First [Text]) ListDatabasesResponse [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> Const (First [Text]) [Text])
-> Maybe [Text] -> Const (First [Text]) (Maybe [Text])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListDatabases
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListDatabases -> Maybe ListDatabases
forall a. a -> Maybe a
Prelude.Just (ListDatabases -> Maybe ListDatabases)
-> ListDatabases -> Maybe ListDatabases
forall a b. (a -> b) -> a -> b
Prelude.$
        ListDatabases
rq
          ListDatabases -> (ListDatabases -> ListDatabases) -> ListDatabases
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListDatabases -> Identity ListDatabases
Lens ListDatabases ListDatabases (Maybe Text) (Maybe Text)
listDatabases_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListDatabases -> Identity ListDatabases)
-> Maybe Text -> ListDatabases -> ListDatabases
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListDatabases
ListDatabasesResponse
rs
          ListDatabasesResponse
-> Getting (First Text) ListDatabasesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListDatabasesResponse
-> Const (First Text) ListDatabasesResponse
Lens' ListDatabasesResponse (Maybe Text)
listDatabasesResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListDatabasesResponse
 -> Const (First Text) ListDatabasesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListDatabasesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListDatabases where
  type
    AWSResponse ListDatabases =
      ListDatabasesResponse
  request :: ListDatabases -> Request ListDatabases
request = Service -> ListDatabases -> Request ListDatabases
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListDatabases
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDatabases)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListDatabases))
-> Logger
-> Service
-> Proxy ListDatabases
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDatabases)))
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 Text -> Maybe [Text] -> Int -> ListDatabasesResponse
ListDatabasesResponse'
            (Maybe Text -> Maybe [Text] -> Int -> ListDatabasesResponse)
-> Either String (Maybe Text)
-> Either String (Maybe [Text] -> Int -> ListDatabasesResponse)
forall (f :: * -> *) a b. Functor 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 (Maybe [Text] -> Int -> ListDatabasesResponse)
-> Either String (Maybe [Text])
-> Either String (Int -> ListDatabasesResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Databases" Either String (Maybe (Maybe [Text]))
-> Maybe [Text] -> Either String (Maybe [Text])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> ListDatabasesResponse)
-> Either String Int -> Either String ListDatabasesResponse
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 ListDatabases

instance Prelude.NFData ListDatabases

instance Core.ToHeaders ListDatabases where
  toHeaders :: ListDatabases -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListDatabases -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"RedshiftData.ListDatabases" :: Prelude.ByteString),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON ListDatabases where
  toJSON :: ListDatabases -> Value
toJSON ListDatabases' {Maybe Natural
Maybe Text
Text
database :: Text
clusterIdentifier :: Text
maxResults :: Maybe Natural
secretArn :: Maybe Text
nextToken :: Maybe Text
dbUser :: Maybe Text
$sel:database:ListDatabases' :: ListDatabases -> Text
$sel:clusterIdentifier:ListDatabases' :: ListDatabases -> Text
$sel:maxResults:ListDatabases' :: ListDatabases -> Maybe Natural
$sel:secretArn:ListDatabases' :: ListDatabases -> Maybe Text
$sel:nextToken:ListDatabases' :: ListDatabases -> Maybe Text
$sel:dbUser:ListDatabases' :: ListDatabases -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DbUser" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
dbUser,
            (Text
"NextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"SecretArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
secretArn,
            (Text
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ClusterIdentifier" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
clusterIdentifier),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Database" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
database)
          ]
      )

instance Core.ToPath ListDatabases where
  toPath :: ListDatabases -> ByteString
toPath = ByteString -> ListDatabases -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery ListDatabases where
  toQuery :: ListDatabases -> QueryString
toQuery = QueryString -> ListDatabases -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newListDatabasesResponse' smart constructor.
data ListDatabasesResponse = ListDatabasesResponse'
  { -- | A value that indicates the starting point for the next set of response
    -- records in a subsequent request. If a value is returned in a response,
    -- you can retrieve the next set of records by providing this returned
    -- NextToken value in the next NextToken parameter and retrying the
    -- command. If the NextToken field is empty, all response records have been
    -- retrieved for the request.
    ListDatabasesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The names of databases.
    ListDatabasesResponse -> Maybe [Text]
databases :: Prelude.Maybe [Prelude.Text],
    -- | The response's http status code.
    ListDatabasesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDatabasesResponse -> ListDatabasesResponse -> Bool
(ListDatabasesResponse -> ListDatabasesResponse -> Bool)
-> (ListDatabasesResponse -> ListDatabasesResponse -> Bool)
-> Eq ListDatabasesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDatabasesResponse -> ListDatabasesResponse -> Bool
$c/= :: ListDatabasesResponse -> ListDatabasesResponse -> Bool
== :: ListDatabasesResponse -> ListDatabasesResponse -> Bool
$c== :: ListDatabasesResponse -> ListDatabasesResponse -> Bool
Prelude.Eq, ReadPrec [ListDatabasesResponse]
ReadPrec ListDatabasesResponse
Int -> ReadS ListDatabasesResponse
ReadS [ListDatabasesResponse]
(Int -> ReadS ListDatabasesResponse)
-> ReadS [ListDatabasesResponse]
-> ReadPrec ListDatabasesResponse
-> ReadPrec [ListDatabasesResponse]
-> Read ListDatabasesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDatabasesResponse]
$creadListPrec :: ReadPrec [ListDatabasesResponse]
readPrec :: ReadPrec ListDatabasesResponse
$creadPrec :: ReadPrec ListDatabasesResponse
readList :: ReadS [ListDatabasesResponse]
$creadList :: ReadS [ListDatabasesResponse]
readsPrec :: Int -> ReadS ListDatabasesResponse
$creadsPrec :: Int -> ReadS ListDatabasesResponse
Prelude.Read, Int -> ListDatabasesResponse -> ShowS
[ListDatabasesResponse] -> ShowS
ListDatabasesResponse -> String
(Int -> ListDatabasesResponse -> ShowS)
-> (ListDatabasesResponse -> String)
-> ([ListDatabasesResponse] -> ShowS)
-> Show ListDatabasesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDatabasesResponse] -> ShowS
$cshowList :: [ListDatabasesResponse] -> ShowS
show :: ListDatabasesResponse -> String
$cshow :: ListDatabasesResponse -> String
showsPrec :: Int -> ListDatabasesResponse -> ShowS
$cshowsPrec :: Int -> ListDatabasesResponse -> ShowS
Prelude.Show, (forall x. ListDatabasesResponse -> Rep ListDatabasesResponse x)
-> (forall x. Rep ListDatabasesResponse x -> ListDatabasesResponse)
-> Generic ListDatabasesResponse
forall x. Rep ListDatabasesResponse x -> ListDatabasesResponse
forall x. ListDatabasesResponse -> Rep ListDatabasesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDatabasesResponse x -> ListDatabasesResponse
$cfrom :: forall x. ListDatabasesResponse -> Rep ListDatabasesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListDatabasesResponse' 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', 'listDatabasesResponse_nextToken' - A value that indicates the starting point for the next set of response
-- records in a subsequent request. If a value is returned in a response,
-- you can retrieve the next set of records by providing this returned
-- NextToken value in the next NextToken parameter and retrying the
-- command. If the NextToken field is empty, all response records have been
-- retrieved for the request.
--
-- 'databases', 'listDatabasesResponse_databases' - The names of databases.
--
-- 'httpStatus', 'listDatabasesResponse_httpStatus' - The response's http status code.
newListDatabasesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDatabasesResponse
newListDatabasesResponse :: Int -> ListDatabasesResponse
newListDatabasesResponse Int
pHttpStatus_ =
  ListDatabasesResponse' :: Maybe Text -> Maybe [Text] -> Int -> ListDatabasesResponse
ListDatabasesResponse'
    { $sel:nextToken:ListDatabasesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:databases:ListDatabasesResponse' :: Maybe [Text]
databases = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDatabasesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A value that indicates the starting point for the next set of response
-- records in a subsequent request. If a value is returned in a response,
-- you can retrieve the next set of records by providing this returned
-- NextToken value in the next NextToken parameter and retrying the
-- command. If the NextToken field is empty, all response records have been
-- retrieved for the request.
listDatabasesResponse_nextToken :: Lens.Lens' ListDatabasesResponse (Prelude.Maybe Prelude.Text)
listDatabasesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListDatabasesResponse -> f ListDatabasesResponse
listDatabasesResponse_nextToken = (ListDatabasesResponse -> Maybe Text)
-> (ListDatabasesResponse -> Maybe Text -> ListDatabasesResponse)
-> Lens' ListDatabasesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDatabasesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDatabasesResponse' :: ListDatabasesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDatabasesResponse
s@ListDatabasesResponse' {} Maybe Text
a -> ListDatabasesResponse
s {$sel:nextToken:ListDatabasesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListDatabasesResponse)

-- | The names of databases.
listDatabasesResponse_databases :: Lens.Lens' ListDatabasesResponse (Prelude.Maybe [Prelude.Text])
listDatabasesResponse_databases :: (Maybe [Text] -> f (Maybe [Text]))
-> ListDatabasesResponse -> f ListDatabasesResponse
listDatabasesResponse_databases = (ListDatabasesResponse -> Maybe [Text])
-> (ListDatabasesResponse -> Maybe [Text] -> ListDatabasesResponse)
-> Lens' ListDatabasesResponse (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDatabasesResponse' {Maybe [Text]
databases :: Maybe [Text]
$sel:databases:ListDatabasesResponse' :: ListDatabasesResponse -> Maybe [Text]
databases} -> Maybe [Text]
databases) (\s :: ListDatabasesResponse
s@ListDatabasesResponse' {} Maybe [Text]
a -> ListDatabasesResponse
s {$sel:databases:ListDatabasesResponse' :: Maybe [Text]
databases = Maybe [Text]
a} :: ListDatabasesResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> ListDatabasesResponse -> f ListDatabasesResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ListDatabasesResponse
-> f ListDatabasesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListDatabasesResponse