{-# 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.DescribeTable
-- 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)
--
-- Describes the detailed information about a table from metadata in the
-- cluster. The information includes its columns. A token is returned to
-- page through the column 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.DescribeTable
  ( -- * Creating a Request
    DescribeTable (..),
    newDescribeTable,

    -- * Request Lenses
    describeTable_dbUser,
    describeTable_connectedDatabase,
    describeTable_schema,
    describeTable_nextToken,
    describeTable_secretArn,
    describeTable_table,
    describeTable_maxResults,
    describeTable_clusterIdentifier,
    describeTable_database,

    -- * Destructuring the Response
    DescribeTableResponse (..),
    newDescribeTableResponse,

    -- * Response Lenses
    describeTableResponse_columnList,
    describeTableResponse_nextToken,
    describeTableResponse_tableName,
    describeTableResponse_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:/ 'newDescribeTable' smart constructor.
data DescribeTable = DescribeTable'
  { -- | The database user name. This parameter is required when authenticating
    -- using temporary credentials.
    DescribeTable -> Maybe Text
dbUser :: Prelude.Maybe Prelude.Text,
    -- | A database name. The connected database is specified when you connect
    -- with your authentication credentials.
    DescribeTable -> Maybe Text
connectedDatabase :: Prelude.Maybe Prelude.Text,
    -- | The schema that contains the table. If no schema is specified, then
    -- matching tables for all schemas are returned.
    DescribeTable -> Maybe Text
schema :: 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.
    DescribeTable -> 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.
    DescribeTable -> Maybe Text
secretArn :: Prelude.Maybe Prelude.Text,
    -- | The table name. If no table is specified, then all tables for all
    -- matching schemas are returned. If no table and no schema is specified,
    -- then all tables for all schemas in the database are returned
    DescribeTable -> Maybe Text
table :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of tables to return in the response. If more tables
    -- exist than fit in one response, then @NextToken@ is returned to page
    -- through the results.
    DescribeTable -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The cluster identifier. This parameter is required when authenticating
    -- using either Secrets Manager or temporary credentials.
    DescribeTable -> Text
clusterIdentifier :: Prelude.Text,
    -- | The name of the database that contains the tables to be described. If
    -- @ConnectedDatabase@ is not specified, this is also the database to
    -- connect to with your authentication credentials.
    DescribeTable -> Text
database :: Prelude.Text
  }
  deriving (DescribeTable -> DescribeTable -> Bool
(DescribeTable -> DescribeTable -> Bool)
-> (DescribeTable -> DescribeTable -> Bool) -> Eq DescribeTable
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeTable -> DescribeTable -> Bool
$c/= :: DescribeTable -> DescribeTable -> Bool
== :: DescribeTable -> DescribeTable -> Bool
$c== :: DescribeTable -> DescribeTable -> Bool
Prelude.Eq, ReadPrec [DescribeTable]
ReadPrec DescribeTable
Int -> ReadS DescribeTable
ReadS [DescribeTable]
(Int -> ReadS DescribeTable)
-> ReadS [DescribeTable]
-> ReadPrec DescribeTable
-> ReadPrec [DescribeTable]
-> Read DescribeTable
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeTable]
$creadListPrec :: ReadPrec [DescribeTable]
readPrec :: ReadPrec DescribeTable
$creadPrec :: ReadPrec DescribeTable
readList :: ReadS [DescribeTable]
$creadList :: ReadS [DescribeTable]
readsPrec :: Int -> ReadS DescribeTable
$creadsPrec :: Int -> ReadS DescribeTable
Prelude.Read, Int -> DescribeTable -> ShowS
[DescribeTable] -> ShowS
DescribeTable -> String
(Int -> DescribeTable -> ShowS)
-> (DescribeTable -> String)
-> ([DescribeTable] -> ShowS)
-> Show DescribeTable
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeTable] -> ShowS
$cshowList :: [DescribeTable] -> ShowS
show :: DescribeTable -> String
$cshow :: DescribeTable -> String
showsPrec :: Int -> DescribeTable -> ShowS
$cshowsPrec :: Int -> DescribeTable -> ShowS
Prelude.Show, (forall x. DescribeTable -> Rep DescribeTable x)
-> (forall x. Rep DescribeTable x -> DescribeTable)
-> Generic DescribeTable
forall x. Rep DescribeTable x -> DescribeTable
forall x. DescribeTable -> Rep DescribeTable x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeTable x -> DescribeTable
$cfrom :: forall x. DescribeTable -> Rep DescribeTable x
Prelude.Generic)

-- |
-- Create a value of 'DescribeTable' 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', 'describeTable_dbUser' - The database user name. This parameter is required when authenticating
-- using temporary credentials.
--
-- 'connectedDatabase', 'describeTable_connectedDatabase' - A database name. The connected database is specified when you connect
-- with your authentication credentials.
--
-- 'schema', 'describeTable_schema' - The schema that contains the table. If no schema is specified, then
-- matching tables for all schemas are returned.
--
-- 'nextToken', 'describeTable_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', 'describeTable_secretArn' - The name or ARN of the secret that enables access to the database. This
-- parameter is required when authenticating using Secrets Manager.
--
-- 'table', 'describeTable_table' - The table name. If no table is specified, then all tables for all
-- matching schemas are returned. If no table and no schema is specified,
-- then all tables for all schemas in the database are returned
--
-- 'maxResults', 'describeTable_maxResults' - The maximum number of tables to return in the response. If more tables
-- exist than fit in one response, then @NextToken@ is returned to page
-- through the results.
--
-- 'clusterIdentifier', 'describeTable_clusterIdentifier' - The cluster identifier. This parameter is required when authenticating
-- using either Secrets Manager or temporary credentials.
--
-- 'database', 'describeTable_database' - The name of the database that contains the tables to be described. If
-- @ConnectedDatabase@ is not specified, this is also the database to
-- connect to with your authentication credentials.
newDescribeTable ::
  -- | 'clusterIdentifier'
  Prelude.Text ->
  -- | 'database'
  Prelude.Text ->
  DescribeTable
newDescribeTable :: Text -> Text -> DescribeTable
newDescribeTable Text
pClusterIdentifier_ Text
pDatabase_ =
  DescribeTable' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Text
-> Text
-> DescribeTable
DescribeTable'
    { $sel:dbUser:DescribeTable' :: Maybe Text
dbUser = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:connectedDatabase:DescribeTable' :: Maybe Text
connectedDatabase = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:schema:DescribeTable' :: Maybe Text
schema = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeTable' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:secretArn:DescribeTable' :: Maybe Text
secretArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:table:DescribeTable' :: Maybe Text
table = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:DescribeTable' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:clusterIdentifier:DescribeTable' :: Text
clusterIdentifier = Text
pClusterIdentifier_,
      $sel:database:DescribeTable' :: Text
database = Text
pDatabase_
    }

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

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

-- | The schema that contains the table. If no schema is specified, then
-- matching tables for all schemas are returned.
describeTable_schema :: Lens.Lens' DescribeTable (Prelude.Maybe Prelude.Text)
describeTable_schema :: (Maybe Text -> f (Maybe Text)) -> DescribeTable -> f DescribeTable
describeTable_schema = (DescribeTable -> Maybe Text)
-> (DescribeTable -> Maybe Text -> DescribeTable)
-> Lens DescribeTable DescribeTable (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTable' {Maybe Text
schema :: Maybe Text
$sel:schema:DescribeTable' :: DescribeTable -> Maybe Text
schema} -> Maybe Text
schema) (\s :: DescribeTable
s@DescribeTable' {} Maybe Text
a -> DescribeTable
s {$sel:schema:DescribeTable' :: Maybe Text
schema = Maybe Text
a} :: DescribeTable)

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

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

-- | The table name. If no table is specified, then all tables for all
-- matching schemas are returned. If no table and no schema is specified,
-- then all tables for all schemas in the database are returned
describeTable_table :: Lens.Lens' DescribeTable (Prelude.Maybe Prelude.Text)
describeTable_table :: (Maybe Text -> f (Maybe Text)) -> DescribeTable -> f DescribeTable
describeTable_table = (DescribeTable -> Maybe Text)
-> (DescribeTable -> Maybe Text -> DescribeTable)
-> Lens DescribeTable DescribeTable (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTable' {Maybe Text
table :: Maybe Text
$sel:table:DescribeTable' :: DescribeTable -> Maybe Text
table} -> Maybe Text
table) (\s :: DescribeTable
s@DescribeTable' {} Maybe Text
a -> DescribeTable
s {$sel:table:DescribeTable' :: Maybe Text
table = Maybe Text
a} :: DescribeTable)

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

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

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

instance Core.AWSPager DescribeTable where
  page :: DescribeTable -> AWSResponse DescribeTable -> Maybe DescribeTable
page DescribeTable
rq AWSResponse DescribeTable
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeTable
DescribeTableResponse
rs
            DescribeTableResponse
-> Getting (First Text) DescribeTableResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeTableResponse
-> Const (First Text) DescribeTableResponse
Lens' DescribeTableResponse (Maybe Text)
describeTableResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeTableResponse
 -> Const (First Text) DescribeTableResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeTableResponse 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 DescribeTable
forall a. Maybe a
Prelude.Nothing
    | Maybe [ColumnMetadata] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeTable
DescribeTableResponse
rs
            DescribeTableResponse
-> Getting
     (First [ColumnMetadata]) DescribeTableResponse [ColumnMetadata]
-> Maybe [ColumnMetadata]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [ColumnMetadata]
 -> Const (First [ColumnMetadata]) (Maybe [ColumnMetadata]))
-> DescribeTableResponse
-> Const (First [ColumnMetadata]) DescribeTableResponse
Lens' DescribeTableResponse (Maybe [ColumnMetadata])
describeTableResponse_columnList
              ((Maybe [ColumnMetadata]
  -> Const (First [ColumnMetadata]) (Maybe [ColumnMetadata]))
 -> DescribeTableResponse
 -> Const (First [ColumnMetadata]) DescribeTableResponse)
-> (([ColumnMetadata]
     -> Const (First [ColumnMetadata]) [ColumnMetadata])
    -> Maybe [ColumnMetadata]
    -> Const (First [ColumnMetadata]) (Maybe [ColumnMetadata]))
-> Getting
     (First [ColumnMetadata]) DescribeTableResponse [ColumnMetadata]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ColumnMetadata]
 -> Const (First [ColumnMetadata]) [ColumnMetadata])
-> Maybe [ColumnMetadata]
-> Const (First [ColumnMetadata]) (Maybe [ColumnMetadata])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeTable
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeTable -> Maybe DescribeTable
forall a. a -> Maybe a
Prelude.Just (DescribeTable -> Maybe DescribeTable)
-> DescribeTable -> Maybe DescribeTable
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeTable
rq
          DescribeTable -> (DescribeTable -> DescribeTable) -> DescribeTable
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeTable -> Identity DescribeTable
Lens DescribeTable DescribeTable (Maybe Text) (Maybe Text)
describeTable_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeTable -> Identity DescribeTable)
-> Maybe Text -> DescribeTable -> DescribeTable
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeTable
DescribeTableResponse
rs
          DescribeTableResponse
-> Getting (First Text) DescribeTableResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeTableResponse
-> Const (First Text) DescribeTableResponse
Lens' DescribeTableResponse (Maybe Text)
describeTableResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeTableResponse
 -> Const (First Text) DescribeTableResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeTableResponse 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 DescribeTable where
  type
    AWSResponse DescribeTable =
      DescribeTableResponse
  request :: DescribeTable -> Request DescribeTable
request = Service -> DescribeTable -> Request DescribeTable
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeTable
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeTable)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeTable))
-> Logger
-> Service
-> Proxy DescribeTable
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeTable)))
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 [ColumnMetadata]
-> Maybe Text -> Maybe Text -> Int -> DescribeTableResponse
DescribeTableResponse'
            (Maybe [ColumnMetadata]
 -> Maybe Text -> Maybe Text -> Int -> DescribeTableResponse)
-> Either String (Maybe [ColumnMetadata])
-> Either
     String (Maybe Text -> Maybe Text -> Int -> DescribeTableResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [ColumnMetadata]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ColumnList" Either String (Maybe (Maybe [ColumnMetadata]))
-> Maybe [ColumnMetadata] -> Either String (Maybe [ColumnMetadata])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ColumnMetadata]
forall a. Monoid a => a
Prelude.mempty)
            Either
  String (Maybe Text -> Maybe Text -> Int -> DescribeTableResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> DescribeTableResponse)
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 (Maybe Text -> Int -> DescribeTableResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribeTableResponse)
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
"TableName")
            Either String (Int -> DescribeTableResponse)
-> Either String Int -> Either String DescribeTableResponse
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 DescribeTable

instance Prelude.NFData DescribeTable

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

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

-- | /See:/ 'newDescribeTableResponse' smart constructor.
data DescribeTableResponse = DescribeTableResponse'
  { -- | A list of columns in the table.
    DescribeTableResponse -> Maybe [ColumnMetadata]
columnList :: Prelude.Maybe [ColumnMetadata],
    -- | 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.
    DescribeTableResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The table name.
    DescribeTableResponse -> Maybe Text
tableName :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeTableResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeTableResponse -> DescribeTableResponse -> Bool
(DescribeTableResponse -> DescribeTableResponse -> Bool)
-> (DescribeTableResponse -> DescribeTableResponse -> Bool)
-> Eq DescribeTableResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeTableResponse -> DescribeTableResponse -> Bool
$c/= :: DescribeTableResponse -> DescribeTableResponse -> Bool
== :: DescribeTableResponse -> DescribeTableResponse -> Bool
$c== :: DescribeTableResponse -> DescribeTableResponse -> Bool
Prelude.Eq, ReadPrec [DescribeTableResponse]
ReadPrec DescribeTableResponse
Int -> ReadS DescribeTableResponse
ReadS [DescribeTableResponse]
(Int -> ReadS DescribeTableResponse)
-> ReadS [DescribeTableResponse]
-> ReadPrec DescribeTableResponse
-> ReadPrec [DescribeTableResponse]
-> Read DescribeTableResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeTableResponse]
$creadListPrec :: ReadPrec [DescribeTableResponse]
readPrec :: ReadPrec DescribeTableResponse
$creadPrec :: ReadPrec DescribeTableResponse
readList :: ReadS [DescribeTableResponse]
$creadList :: ReadS [DescribeTableResponse]
readsPrec :: Int -> ReadS DescribeTableResponse
$creadsPrec :: Int -> ReadS DescribeTableResponse
Prelude.Read, Int -> DescribeTableResponse -> ShowS
[DescribeTableResponse] -> ShowS
DescribeTableResponse -> String
(Int -> DescribeTableResponse -> ShowS)
-> (DescribeTableResponse -> String)
-> ([DescribeTableResponse] -> ShowS)
-> Show DescribeTableResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeTableResponse] -> ShowS
$cshowList :: [DescribeTableResponse] -> ShowS
show :: DescribeTableResponse -> String
$cshow :: DescribeTableResponse -> String
showsPrec :: Int -> DescribeTableResponse -> ShowS
$cshowsPrec :: Int -> DescribeTableResponse -> ShowS
Prelude.Show, (forall x. DescribeTableResponse -> Rep DescribeTableResponse x)
-> (forall x. Rep DescribeTableResponse x -> DescribeTableResponse)
-> Generic DescribeTableResponse
forall x. Rep DescribeTableResponse x -> DescribeTableResponse
forall x. DescribeTableResponse -> Rep DescribeTableResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeTableResponse x -> DescribeTableResponse
$cfrom :: forall x. DescribeTableResponse -> Rep DescribeTableResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeTableResponse' 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:
--
-- 'columnList', 'describeTableResponse_columnList' - A list of columns in the table.
--
-- 'nextToken', 'describeTableResponse_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.
--
-- 'tableName', 'describeTableResponse_tableName' - The table name.
--
-- 'httpStatus', 'describeTableResponse_httpStatus' - The response's http status code.
newDescribeTableResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeTableResponse
newDescribeTableResponse :: Int -> DescribeTableResponse
newDescribeTableResponse Int
pHttpStatus_ =
  DescribeTableResponse' :: Maybe [ColumnMetadata]
-> Maybe Text -> Maybe Text -> Int -> DescribeTableResponse
DescribeTableResponse'
    { $sel:columnList:DescribeTableResponse' :: Maybe [ColumnMetadata]
columnList =
        Maybe [ColumnMetadata]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeTableResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tableName:DescribeTableResponse' :: Maybe Text
tableName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeTableResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of columns in the table.
describeTableResponse_columnList :: Lens.Lens' DescribeTableResponse (Prelude.Maybe [ColumnMetadata])
describeTableResponse_columnList :: (Maybe [ColumnMetadata] -> f (Maybe [ColumnMetadata]))
-> DescribeTableResponse -> f DescribeTableResponse
describeTableResponse_columnList = (DescribeTableResponse -> Maybe [ColumnMetadata])
-> (DescribeTableResponse
    -> Maybe [ColumnMetadata] -> DescribeTableResponse)
-> Lens' DescribeTableResponse (Maybe [ColumnMetadata])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTableResponse' {Maybe [ColumnMetadata]
columnList :: Maybe [ColumnMetadata]
$sel:columnList:DescribeTableResponse' :: DescribeTableResponse -> Maybe [ColumnMetadata]
columnList} -> Maybe [ColumnMetadata]
columnList) (\s :: DescribeTableResponse
s@DescribeTableResponse' {} Maybe [ColumnMetadata]
a -> DescribeTableResponse
s {$sel:columnList:DescribeTableResponse' :: Maybe [ColumnMetadata]
columnList = Maybe [ColumnMetadata]
a} :: DescribeTableResponse) ((Maybe [ColumnMetadata] -> f (Maybe [ColumnMetadata]))
 -> DescribeTableResponse -> f DescribeTableResponse)
-> ((Maybe [ColumnMetadata] -> f (Maybe [ColumnMetadata]))
    -> Maybe [ColumnMetadata] -> f (Maybe [ColumnMetadata]))
-> (Maybe [ColumnMetadata] -> f (Maybe [ColumnMetadata]))
-> DescribeTableResponse
-> f DescribeTableResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ColumnMetadata] [ColumnMetadata] [ColumnMetadata] [ColumnMetadata]
-> Iso
     (Maybe [ColumnMetadata])
     (Maybe [ColumnMetadata])
     (Maybe [ColumnMetadata])
     (Maybe [ColumnMetadata])
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
  [ColumnMetadata] [ColumnMetadata] [ColumnMetadata] [ColumnMetadata]
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.
describeTableResponse_nextToken :: Lens.Lens' DescribeTableResponse (Prelude.Maybe Prelude.Text)
describeTableResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeTableResponse -> f DescribeTableResponse
describeTableResponse_nextToken = (DescribeTableResponse -> Maybe Text)
-> (DescribeTableResponse -> Maybe Text -> DescribeTableResponse)
-> Lens' DescribeTableResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTableResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeTableResponse' :: DescribeTableResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeTableResponse
s@DescribeTableResponse' {} Maybe Text
a -> DescribeTableResponse
s {$sel:nextToken:DescribeTableResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeTableResponse)

-- | The table name.
describeTableResponse_tableName :: Lens.Lens' DescribeTableResponse (Prelude.Maybe Prelude.Text)
describeTableResponse_tableName :: (Maybe Text -> f (Maybe Text))
-> DescribeTableResponse -> f DescribeTableResponse
describeTableResponse_tableName = (DescribeTableResponse -> Maybe Text)
-> (DescribeTableResponse -> Maybe Text -> DescribeTableResponse)
-> Lens' DescribeTableResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTableResponse' {Maybe Text
tableName :: Maybe Text
$sel:tableName:DescribeTableResponse' :: DescribeTableResponse -> Maybe Text
tableName} -> Maybe Text
tableName) (\s :: DescribeTableResponse
s@DescribeTableResponse' {} Maybe Text
a -> DescribeTableResponse
s {$sel:tableName:DescribeTableResponse' :: Maybe Text
tableName = Maybe Text
a} :: DescribeTableResponse)

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

instance Prelude.NFData DescribeTableResponse