{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 - when connecting to a cluster, specify the Amazon
--     Resource Name (ARN) of the secret, the database name, and the
--     cluster identifier that matches the cluster in the secret. When
--     connecting to a serverless workgroup, specify the Amazon Resource
--     Name (ARN) of the secret and the database name.
--
-- -   Temporary credentials - when connecting to a cluster, specify the
--     cluster identifier, the database name, and the database user name.
--     Also, permission to call the @redshift:GetClusterCredentials@
--     operation is required. When connecting to a serverless workgroup,
--     specify the workgroup name and database name. Also, permission to
--     call the @redshift-serverless:GetCredentials@ operation is required.
--
-- For more information about the Amazon Redshift Data API and CLI usage
-- examples, see
-- <https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html Using the Amazon Redshift Data API>
-- in the /Amazon Redshift Management Guide/.
--
-- This operation returns paginated results.
module Amazonka.RedshiftData.ListDatabases
  ( -- * Creating a Request
    ListDatabases (..),
    newListDatabases,

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

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

    -- * Response Lenses
    listDatabasesResponse_databases,
    listDatabasesResponse_nextToken,
    listDatabasesResponse_httpStatus,
  )
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 Amazonka.RedshiftData.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListDatabases' smart constructor.
data ListDatabases = ListDatabases'
  { -- | The cluster identifier. This parameter is required when connecting to a
    -- cluster and authenticating using either Secrets Manager or temporary
    -- credentials.
    ListDatabases -> Maybe Text
clusterIdentifier :: Prelude.Maybe Prelude.Text,
    -- | The database user name. This parameter is required when connecting to a
    -- cluster and authenticating using temporary credentials.
    ListDatabases -> Maybe Text
dbUser :: 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,
    -- | 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 serverless workgroup name. This parameter is required when
    -- connecting to a serverless workgroup and authenticating using either
    -- Secrets Manager or temporary credentials.
    ListDatabases -> Maybe Text
workgroupName :: Prelude.Maybe 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
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]
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
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. 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:
--
-- 'clusterIdentifier', 'listDatabases_clusterIdentifier' - The cluster identifier. This parameter is required when connecting to a
-- cluster and authenticating using either Secrets Manager or temporary
-- credentials.
--
-- 'dbUser', 'listDatabases_dbUser' - The database user name. This parameter is required when connecting to a
-- cluster and authenticating using temporary credentials.
--
-- '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.
--
-- '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.
--
-- 'workgroupName', 'listDatabases_workgroupName' - The serverless workgroup name. This parameter is required when
-- connecting to a serverless workgroup and 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 ::
  -- | 'database'
  Prelude.Text ->
  ListDatabases
newListDatabases :: Text -> ListDatabases
newListDatabases Text
pDatabase_ =
  ListDatabases'
    { $sel:clusterIdentifier:ListDatabases' :: Maybe Text
clusterIdentifier = forall a. Maybe a
Prelude.Nothing,
      $sel:dbUser:ListDatabases' :: Maybe Text
dbUser = forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListDatabases' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDatabases' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:secretArn:ListDatabases' :: Maybe Text
secretArn = forall a. Maybe a
Prelude.Nothing,
      $sel:workgroupName:ListDatabases' :: Maybe Text
workgroupName = forall a. Maybe a
Prelude.Nothing,
      $sel:database:ListDatabases' :: Text
database = Text
pDatabase_
    }

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

-- | The database user name. This parameter is required when connecting to a
-- cluster and authenticating using temporary credentials.
listDatabases_dbUser :: Lens.Lens' ListDatabases (Prelude.Maybe Prelude.Text)
listDatabases_dbUser :: Lens' ListDatabases (Maybe Text)
listDatabases_dbUser = 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)

-- | 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 :: Lens' ListDatabases (Maybe Natural)
listDatabases_maxResults = 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)

-- | 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 :: Lens' ListDatabases (Maybe Text)
listDatabases_nextToken = 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 :: Lens' ListDatabases (Maybe Text)
listDatabases_secretArn = 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 serverless workgroup name. This parameter is required when
-- connecting to a serverless workgroup and authenticating using either
-- Secrets Manager or temporary credentials.
listDatabases_workgroupName :: Lens.Lens' ListDatabases (Prelude.Maybe Prelude.Text)
listDatabases_workgroupName :: Lens' ListDatabases (Maybe Text)
listDatabases_workgroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDatabases' {Maybe Text
workgroupName :: Maybe Text
$sel:workgroupName:ListDatabases' :: ListDatabases -> Maybe Text
workgroupName} -> Maybe Text
workgroupName) (\s :: ListDatabases
s@ListDatabases' {} Maybe Text
a -> ListDatabases
s {$sel:workgroupName:ListDatabases' :: Maybe Text
workgroupName = Maybe 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 :: Lens' ListDatabases Text
listDatabases_database = 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
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListDatabases
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListDatabasesResponse (Maybe Text)
listDatabasesResponse_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 ListDatabases
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListDatabasesResponse (Maybe [Text])
listDatabasesResponse_databases
            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.$ ListDatabases
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListDatabases (Maybe Text)
listDatabases_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListDatabases
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListDatabasesResponse (Maybe Text)
listDatabasesResponse_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 ListDatabases where
  type
    AWSResponse ListDatabases =
      ListDatabasesResponse
  request :: (Service -> Service) -> ListDatabases -> Request ListDatabases
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListDatabases
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDatabases)))
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 Text -> Int -> ListDatabasesResponse
ListDatabasesResponse'
            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
"Databases" 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 ListDatabases where
  hashWithSalt :: Int -> ListDatabases -> Int
hashWithSalt Int
_salt ListDatabases' {Maybe Natural
Maybe Text
Text
database :: Text
workgroupName :: Maybe Text
secretArn :: Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
dbUser :: Maybe Text
clusterIdentifier :: Maybe Text
$sel:database:ListDatabases' :: ListDatabases -> Text
$sel:workgroupName:ListDatabases' :: ListDatabases -> Maybe Text
$sel:secretArn:ListDatabases' :: ListDatabases -> Maybe Text
$sel:nextToken:ListDatabases' :: ListDatabases -> Maybe Text
$sel:maxResults:ListDatabases' :: ListDatabases -> Maybe Natural
$sel:dbUser:ListDatabases' :: ListDatabases -> Maybe Text
$sel:clusterIdentifier:ListDatabases' :: ListDatabases -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clusterIdentifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dbUser
      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` Maybe Text
secretArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
workgroupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
database

instance Prelude.NFData ListDatabases where
  rnf :: ListDatabases -> ()
rnf ListDatabases' {Maybe Natural
Maybe Text
Text
database :: Text
workgroupName :: Maybe Text
secretArn :: Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
dbUser :: Maybe Text
clusterIdentifier :: Maybe Text
$sel:database:ListDatabases' :: ListDatabases -> Text
$sel:workgroupName:ListDatabases' :: ListDatabases -> Maybe Text
$sel:secretArn:ListDatabases' :: ListDatabases -> Maybe Text
$sel:nextToken:ListDatabases' :: ListDatabases -> Maybe Text
$sel:maxResults:ListDatabases' :: ListDatabases -> Maybe Natural
$sel:dbUser:ListDatabases' :: ListDatabases -> Maybe Text
$sel:clusterIdentifier:ListDatabases' :: ListDatabases -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clusterIdentifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dbUser
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 Maybe Text
secretArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
workgroupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
database

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

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

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

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

-- | /See:/ 'newListDatabasesResponse' smart constructor.
data ListDatabasesResponse = ListDatabasesResponse'
  { -- | The names of databases.
    ListDatabasesResponse -> Maybe [Text]
databases :: 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.
    ListDatabasesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListDatabasesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDatabasesResponse -> ListDatabasesResponse -> Bool
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]
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
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. 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:
--
-- 'databases', 'listDatabasesResponse_databases' - The names of databases.
--
-- '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.
--
-- 'httpStatus', 'listDatabasesResponse_httpStatus' - The response's http status code.
newListDatabasesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDatabasesResponse
newListDatabasesResponse :: Int -> ListDatabasesResponse
newListDatabasesResponse Int
pHttpStatus_ =
  ListDatabasesResponse'
    { $sel:databases:ListDatabasesResponse' :: Maybe [Text]
databases = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDatabasesResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDatabasesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The names of databases.
listDatabasesResponse_databases :: Lens.Lens' ListDatabasesResponse (Prelude.Maybe [Prelude.Text])
listDatabasesResponse_databases :: Lens' ListDatabasesResponse (Maybe [Text])
listDatabasesResponse_databases = 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) 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

-- | 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 :: Lens' ListDatabasesResponse (Maybe Text)
listDatabasesResponse_nextToken = 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 response's http status code.
listDatabasesResponse_httpStatus :: Lens.Lens' ListDatabasesResponse Prelude.Int
listDatabasesResponse_httpStatus :: Lens' ListDatabasesResponse Int
listDatabasesResponse_httpStatus = 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 where
  rnf :: ListDatabasesResponse -> ()
rnf ListDatabasesResponse' {Int
Maybe [Text]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
databases :: Maybe [Text]
$sel:httpStatus:ListDatabasesResponse' :: ListDatabasesResponse -> Int
$sel:nextToken:ListDatabasesResponse' :: ListDatabasesResponse -> Maybe Text
$sel:databases:ListDatabasesResponse' :: ListDatabasesResponse -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
databases
      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