{-# 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.ListSchemas
-- 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 schemas in a database. A token is returned to page through the
-- schema 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.ListSchemas
  ( -- * Creating a Request
    ListSchemas (..),
    newListSchemas,

    -- * Request Lenses
    listSchemas_dbUser,
    listSchemas_connectedDatabase,
    listSchemas_nextToken,
    listSchemas_secretArn,
    listSchemas_maxResults,
    listSchemas_schemaPattern,
    listSchemas_clusterIdentifier,
    listSchemas_database,

    -- * Destructuring the Response
    ListSchemasResponse (..),
    newListSchemasResponse,

    -- * Response Lenses
    listSchemasResponse_schemas,
    listSchemasResponse_nextToken,
    listSchemasResponse_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:/ 'newListSchemas' smart constructor.
data ListSchemas = ListSchemas'
  { -- | The database user name. This parameter is required when authenticating
    -- using temporary credentials.
    ListSchemas -> Maybe Text
dbUser :: Prelude.Maybe Prelude.Text,
    -- | A database name. The connected database is specified when you connect
    -- with your authentication credentials.
    ListSchemas -> Maybe Text
connectedDatabase :: 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.
    ListSchemas -> 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.
    ListSchemas -> Maybe Text
secretArn :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of schemas to return in the response. If more schemas
    -- exist than fit in one response, then @NextToken@ is returned to page
    -- through the results.
    ListSchemas -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | A pattern to filter results by schema name. Within a schema pattern,
    -- \"%\" means match any substring of 0 or more characters and \"_\" means
    -- match any one character. Only schema name entries matching the search
    -- pattern are returned.
    ListSchemas -> Maybe Text
schemaPattern :: Prelude.Maybe Prelude.Text,
    -- | The cluster identifier. This parameter is required when authenticating
    -- using either Secrets Manager or temporary credentials.
    ListSchemas -> Text
clusterIdentifier :: Prelude.Text,
    -- | The name of the database that contains the schemas to list. If
    -- @ConnectedDatabase@ is not specified, this is also the database to
    -- connect to with your authentication credentials.
    ListSchemas -> Text
database :: Prelude.Text
  }
  deriving (ListSchemas -> ListSchemas -> Bool
(ListSchemas -> ListSchemas -> Bool)
-> (ListSchemas -> ListSchemas -> Bool) -> Eq ListSchemas
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListSchemas -> ListSchemas -> Bool
$c/= :: ListSchemas -> ListSchemas -> Bool
== :: ListSchemas -> ListSchemas -> Bool
$c== :: ListSchemas -> ListSchemas -> Bool
Prelude.Eq, ReadPrec [ListSchemas]
ReadPrec ListSchemas
Int -> ReadS ListSchemas
ReadS [ListSchemas]
(Int -> ReadS ListSchemas)
-> ReadS [ListSchemas]
-> ReadPrec ListSchemas
-> ReadPrec [ListSchemas]
-> Read ListSchemas
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListSchemas]
$creadListPrec :: ReadPrec [ListSchemas]
readPrec :: ReadPrec ListSchemas
$creadPrec :: ReadPrec ListSchemas
readList :: ReadS [ListSchemas]
$creadList :: ReadS [ListSchemas]
readsPrec :: Int -> ReadS ListSchemas
$creadsPrec :: Int -> ReadS ListSchemas
Prelude.Read, Int -> ListSchemas -> ShowS
[ListSchemas] -> ShowS
ListSchemas -> String
(Int -> ListSchemas -> ShowS)
-> (ListSchemas -> String)
-> ([ListSchemas] -> ShowS)
-> Show ListSchemas
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListSchemas] -> ShowS
$cshowList :: [ListSchemas] -> ShowS
show :: ListSchemas -> String
$cshow :: ListSchemas -> String
showsPrec :: Int -> ListSchemas -> ShowS
$cshowsPrec :: Int -> ListSchemas -> ShowS
Prelude.Show, (forall x. ListSchemas -> Rep ListSchemas x)
-> (forall x. Rep ListSchemas x -> ListSchemas)
-> Generic ListSchemas
forall x. Rep ListSchemas x -> ListSchemas
forall x. ListSchemas -> Rep ListSchemas x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListSchemas x -> ListSchemas
$cfrom :: forall x. ListSchemas -> Rep ListSchemas x
Prelude.Generic)

-- |
-- Create a value of 'ListSchemas' 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', 'listSchemas_dbUser' - The database user name. This parameter is required when authenticating
-- using temporary credentials.
--
-- 'connectedDatabase', 'listSchemas_connectedDatabase' - A database name. The connected database is specified when you connect
-- with your authentication credentials.
--
-- 'nextToken', 'listSchemas_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', 'listSchemas_secretArn' - The name or ARN of the secret that enables access to the database. This
-- parameter is required when authenticating using Secrets Manager.
--
-- 'maxResults', 'listSchemas_maxResults' - The maximum number of schemas to return in the response. If more schemas
-- exist than fit in one response, then @NextToken@ is returned to page
-- through the results.
--
-- 'schemaPattern', 'listSchemas_schemaPattern' - A pattern to filter results by schema name. Within a schema pattern,
-- \"%\" means match any substring of 0 or more characters and \"_\" means
-- match any one character. Only schema name entries matching the search
-- pattern are returned.
--
-- 'clusterIdentifier', 'listSchemas_clusterIdentifier' - The cluster identifier. This parameter is required when authenticating
-- using either Secrets Manager or temporary credentials.
--
-- 'database', 'listSchemas_database' - The name of the database that contains the schemas to list. If
-- @ConnectedDatabase@ is not specified, this is also the database to
-- connect to with your authentication credentials.
newListSchemas ::
  -- | 'clusterIdentifier'
  Prelude.Text ->
  -- | 'database'
  Prelude.Text ->
  ListSchemas
newListSchemas :: Text -> Text -> ListSchemas
newListSchemas Text
pClusterIdentifier_ Text
pDatabase_ =
  ListSchemas' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Maybe Text
-> Text
-> Text
-> ListSchemas
ListSchemas'
    { $sel:dbUser:ListSchemas' :: Maybe Text
dbUser = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:connectedDatabase:ListSchemas' :: Maybe Text
connectedDatabase = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListSchemas' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:secretArn:ListSchemas' :: Maybe Text
secretArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListSchemas' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:schemaPattern:ListSchemas' :: Maybe Text
schemaPattern = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:clusterIdentifier:ListSchemas' :: Text
clusterIdentifier = Text
pClusterIdentifier_,
      $sel:database:ListSchemas' :: Text
database = Text
pDatabase_
    }

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

-- | A database name. The connected database is specified when you connect
-- with your authentication credentials.
listSchemas_connectedDatabase :: Lens.Lens' ListSchemas (Prelude.Maybe Prelude.Text)
listSchemas_connectedDatabase :: (Maybe Text -> f (Maybe Text)) -> ListSchemas -> f ListSchemas
listSchemas_connectedDatabase = (ListSchemas -> Maybe Text)
-> (ListSchemas -> Maybe Text -> ListSchemas)
-> Lens ListSchemas ListSchemas (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSchemas' {Maybe Text
connectedDatabase :: Maybe Text
$sel:connectedDatabase:ListSchemas' :: ListSchemas -> Maybe Text
connectedDatabase} -> Maybe Text
connectedDatabase) (\s :: ListSchemas
s@ListSchemas' {} Maybe Text
a -> ListSchemas
s {$sel:connectedDatabase:ListSchemas' :: Maybe Text
connectedDatabase = Maybe Text
a} :: ListSchemas)

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

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

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

-- | A pattern to filter results by schema name. Within a schema pattern,
-- \"%\" means match any substring of 0 or more characters and \"_\" means
-- match any one character. Only schema name entries matching the search
-- pattern are returned.
listSchemas_schemaPattern :: Lens.Lens' ListSchemas (Prelude.Maybe Prelude.Text)
listSchemas_schemaPattern :: (Maybe Text -> f (Maybe Text)) -> ListSchemas -> f ListSchemas
listSchemas_schemaPattern = (ListSchemas -> Maybe Text)
-> (ListSchemas -> Maybe Text -> ListSchemas)
-> Lens ListSchemas ListSchemas (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSchemas' {Maybe Text
schemaPattern :: Maybe Text
$sel:schemaPattern:ListSchemas' :: ListSchemas -> Maybe Text
schemaPattern} -> Maybe Text
schemaPattern) (\s :: ListSchemas
s@ListSchemas' {} Maybe Text
a -> ListSchemas
s {$sel:schemaPattern:ListSchemas' :: Maybe Text
schemaPattern = Maybe Text
a} :: ListSchemas)

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

-- | The name of the database that contains the schemas to list. If
-- @ConnectedDatabase@ is not specified, this is also the database to
-- connect to with your authentication credentials.
listSchemas_database :: Lens.Lens' ListSchemas Prelude.Text
listSchemas_database :: (Text -> f Text) -> ListSchemas -> f ListSchemas
listSchemas_database = (ListSchemas -> Text)
-> (ListSchemas -> Text -> ListSchemas)
-> Lens ListSchemas ListSchemas Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSchemas' {Text
database :: Text
$sel:database:ListSchemas' :: ListSchemas -> Text
database} -> Text
database) (\s :: ListSchemas
s@ListSchemas' {} Text
a -> ListSchemas
s {$sel:database:ListSchemas' :: Text
database = Text
a} :: ListSchemas)

instance Core.AWSPager ListSchemas where
  page :: ListSchemas -> AWSResponse ListSchemas -> Maybe ListSchemas
page ListSchemas
rq AWSResponse ListSchemas
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListSchemas
ListSchemasResponse
rs
            ListSchemasResponse
-> Getting (First Text) ListSchemasResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListSchemasResponse -> Const (First Text) ListSchemasResponse
Lens' ListSchemasResponse (Maybe Text)
listSchemasResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListSchemasResponse -> Const (First Text) ListSchemasResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListSchemasResponse 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 ListSchemas
forall a. Maybe a
Prelude.Nothing
    | Maybe [Text] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListSchemas
ListSchemasResponse
rs
            ListSchemasResponse
-> Getting (First [Text]) ListSchemasResponse [Text]
-> Maybe [Text]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
-> ListSchemasResponse -> Const (First [Text]) ListSchemasResponse
Lens' ListSchemasResponse (Maybe [Text])
listSchemasResponse_schemas ((Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
 -> ListSchemasResponse -> Const (First [Text]) ListSchemasResponse)
-> (([Text] -> Const (First [Text]) [Text])
    -> Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
-> Getting (First [Text]) ListSchemasResponse [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 ListSchemas
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListSchemas -> Maybe ListSchemas
forall a. a -> Maybe a
Prelude.Just (ListSchemas -> Maybe ListSchemas)
-> ListSchemas -> Maybe ListSchemas
forall a b. (a -> b) -> a -> b
Prelude.$
        ListSchemas
rq
          ListSchemas -> (ListSchemas -> ListSchemas) -> ListSchemas
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListSchemas -> Identity ListSchemas
Lens ListSchemas ListSchemas (Maybe Text) (Maybe Text)
listSchemas_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListSchemas -> Identity ListSchemas)
-> Maybe Text -> ListSchemas -> ListSchemas
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListSchemas
ListSchemasResponse
rs
          ListSchemasResponse
-> Getting (First Text) ListSchemasResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListSchemasResponse -> Const (First Text) ListSchemasResponse
Lens' ListSchemasResponse (Maybe Text)
listSchemasResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListSchemasResponse -> Const (First Text) ListSchemasResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListSchemasResponse 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 ListSchemas where
  type AWSResponse ListSchemas = ListSchemasResponse
  request :: ListSchemas -> Request ListSchemas
request = Service -> ListSchemas -> Request ListSchemas
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListSchemas
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListSchemas)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListSchemas))
-> Logger
-> Service
-> Proxy ListSchemas
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListSchemas)))
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 -> ListSchemasResponse
ListSchemasResponse'
            (Maybe [Text] -> Maybe Text -> Int -> ListSchemasResponse)
-> Either String (Maybe [Text])
-> Either String (Maybe Text -> Int -> ListSchemasResponse)
forall (f :: * -> *) a b. Functor 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
"Schemas" 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 (Maybe Text -> Int -> ListSchemasResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListSchemasResponse)
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 -> ListSchemasResponse)
-> Either String Int -> Either String ListSchemasResponse
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 ListSchemas

instance Prelude.NFData ListSchemas

instance Core.ToHeaders ListSchemas where
  toHeaders :: ListSchemas -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListSchemas -> 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.ListSchemas" :: 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 ListSchemas where
  toJSON :: ListSchemas -> Value
toJSON ListSchemas' {Maybe Natural
Maybe Text
Text
database :: Text
clusterIdentifier :: Text
schemaPattern :: Maybe Text
maxResults :: Maybe Natural
secretArn :: Maybe Text
nextToken :: Maybe Text
connectedDatabase :: Maybe Text
dbUser :: Maybe Text
$sel:database:ListSchemas' :: ListSchemas -> Text
$sel:clusterIdentifier:ListSchemas' :: ListSchemas -> Text
$sel:schemaPattern:ListSchemas' :: ListSchemas -> Maybe Text
$sel:maxResults:ListSchemas' :: ListSchemas -> Maybe Natural
$sel:secretArn:ListSchemas' :: ListSchemas -> Maybe Text
$sel:nextToken:ListSchemas' :: ListSchemas -> Maybe Text
$sel:connectedDatabase:ListSchemas' :: ListSchemas -> Maybe Text
$sel:dbUser:ListSchemas' :: ListSchemas -> 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
"ConnectedDatabase" 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
connectedDatabase,
            (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,
            (Text
"SchemaPattern" 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
schemaPattern,
            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 ListSchemas where
  toPath :: ListSchemas -> ByteString
toPath = ByteString -> ListSchemas -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newListSchemasResponse' smart constructor.
data ListSchemasResponse = ListSchemasResponse'
  { -- | The schemas that match the request pattern.
    ListSchemasResponse -> Maybe [Text]
schemas :: 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.
    ListSchemasResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListSchemasResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListSchemasResponse -> ListSchemasResponse -> Bool
(ListSchemasResponse -> ListSchemasResponse -> Bool)
-> (ListSchemasResponse -> ListSchemasResponse -> Bool)
-> Eq ListSchemasResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListSchemasResponse -> ListSchemasResponse -> Bool
$c/= :: ListSchemasResponse -> ListSchemasResponse -> Bool
== :: ListSchemasResponse -> ListSchemasResponse -> Bool
$c== :: ListSchemasResponse -> ListSchemasResponse -> Bool
Prelude.Eq, ReadPrec [ListSchemasResponse]
ReadPrec ListSchemasResponse
Int -> ReadS ListSchemasResponse
ReadS [ListSchemasResponse]
(Int -> ReadS ListSchemasResponse)
-> ReadS [ListSchemasResponse]
-> ReadPrec ListSchemasResponse
-> ReadPrec [ListSchemasResponse]
-> Read ListSchemasResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListSchemasResponse]
$creadListPrec :: ReadPrec [ListSchemasResponse]
readPrec :: ReadPrec ListSchemasResponse
$creadPrec :: ReadPrec ListSchemasResponse
readList :: ReadS [ListSchemasResponse]
$creadList :: ReadS [ListSchemasResponse]
readsPrec :: Int -> ReadS ListSchemasResponse
$creadsPrec :: Int -> ReadS ListSchemasResponse
Prelude.Read, Int -> ListSchemasResponse -> ShowS
[ListSchemasResponse] -> ShowS
ListSchemasResponse -> String
(Int -> ListSchemasResponse -> ShowS)
-> (ListSchemasResponse -> String)
-> ([ListSchemasResponse] -> ShowS)
-> Show ListSchemasResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListSchemasResponse] -> ShowS
$cshowList :: [ListSchemasResponse] -> ShowS
show :: ListSchemasResponse -> String
$cshow :: ListSchemasResponse -> String
showsPrec :: Int -> ListSchemasResponse -> ShowS
$cshowsPrec :: Int -> ListSchemasResponse -> ShowS
Prelude.Show, (forall x. ListSchemasResponse -> Rep ListSchemasResponse x)
-> (forall x. Rep ListSchemasResponse x -> ListSchemasResponse)
-> Generic ListSchemasResponse
forall x. Rep ListSchemasResponse x -> ListSchemasResponse
forall x. ListSchemasResponse -> Rep ListSchemasResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListSchemasResponse x -> ListSchemasResponse
$cfrom :: forall x. ListSchemasResponse -> Rep ListSchemasResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListSchemasResponse' 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:
--
-- 'schemas', 'listSchemasResponse_schemas' - The schemas that match the request pattern.
--
-- 'nextToken', 'listSchemasResponse_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', 'listSchemasResponse_httpStatus' - The response's http status code.
newListSchemasResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListSchemasResponse
newListSchemasResponse :: Int -> ListSchemasResponse
newListSchemasResponse Int
pHttpStatus_ =
  ListSchemasResponse' :: Maybe [Text] -> Maybe Text -> Int -> ListSchemasResponse
ListSchemasResponse'
    { $sel:schemas:ListSchemasResponse' :: Maybe [Text]
schemas = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListSchemasResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListSchemasResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The schemas that match the request pattern.
listSchemasResponse_schemas :: Lens.Lens' ListSchemasResponse (Prelude.Maybe [Prelude.Text])
listSchemasResponse_schemas :: (Maybe [Text] -> f (Maybe [Text]))
-> ListSchemasResponse -> f ListSchemasResponse
listSchemasResponse_schemas = (ListSchemasResponse -> Maybe [Text])
-> (ListSchemasResponse -> Maybe [Text] -> ListSchemasResponse)
-> Lens' ListSchemasResponse (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSchemasResponse' {Maybe [Text]
schemas :: Maybe [Text]
$sel:schemas:ListSchemasResponse' :: ListSchemasResponse -> Maybe [Text]
schemas} -> Maybe [Text]
schemas) (\s :: ListSchemasResponse
s@ListSchemasResponse' {} Maybe [Text]
a -> ListSchemasResponse
s {$sel:schemas:ListSchemasResponse' :: Maybe [Text]
schemas = Maybe [Text]
a} :: ListSchemasResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> ListSchemasResponse -> f ListSchemasResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ListSchemasResponse
-> f ListSchemasResponse
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

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

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

instance Prelude.NFData ListSchemasResponse