{-# 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.Glue.GetPartitions
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves information about the partitions in a table.
--
-- This operation returns paginated results.
module Amazonka.Glue.GetPartitions
  ( -- * Creating a Request
    GetPartitions (..),
    newGetPartitions,

    -- * Request Lenses
    getPartitions_catalogId,
    getPartitions_excludeColumnSchema,
    getPartitions_expression,
    getPartitions_maxResults,
    getPartitions_nextToken,
    getPartitions_queryAsOfTime,
    getPartitions_segment,
    getPartitions_transactionId,
    getPartitions_databaseName,
    getPartitions_tableName,

    -- * Destructuring the Response
    GetPartitionsResponse (..),
    newGetPartitionsResponse,

    -- * Response Lenses
    getPartitionsResponse_nextToken,
    getPartitionsResponse_partitions,
    getPartitionsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetPartitions' smart constructor.
data GetPartitions = GetPartitions'
  { -- | The ID of the Data Catalog where the partitions in question reside. If
    -- none is provided, the Amazon Web Services account ID is used by default.
    GetPartitions -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | When true, specifies not returning the partition column schema. Useful
    -- when you are interested only in other partition attributes such as
    -- partition values or location. This approach avoids the problem of a
    -- large response by not returning duplicate data.
    GetPartitions -> Maybe Bool
excludeColumnSchema :: Prelude.Maybe Prelude.Bool,
    -- | An expression that filters the partitions to be returned.
    --
    -- The expression uses SQL syntax similar to the SQL @WHERE@ filter clause.
    -- The SQL statement parser
    -- <http://jsqlparser.sourceforge.net/home.php JSQLParser> parses the
    -- expression.
    --
    -- /Operators/: The following are the operators that you can use in the
    -- @Expression@ API call:
    --
    -- [=]
    --     Checks whether the values of the two operands are equal; if yes,
    --     then the condition becomes true.
    --
    --     Example: Assume \'variable a\' holds 10 and \'variable b\' holds 20.
    --
    --     (a = b) is not true.
    --
    -- [\< >]
    --     Checks whether the values of two operands are equal; if the values
    --     are not equal, then the condition becomes true.
    --
    --     Example: (a \< > b) is true.
    --
    -- [>]
    --     Checks whether the value of the left operand is greater than the
    --     value of the right operand; if yes, then the condition becomes true.
    --
    --     Example: (a > b) is not true.
    --
    -- [\<]
    --     Checks whether the value of the left operand is less than the value
    --     of the right operand; if yes, then the condition becomes true.
    --
    --     Example: (a \< b) is true.
    --
    -- [>=]
    --     Checks whether the value of the left operand is greater than or
    --     equal to the value of the right operand; if yes, then the condition
    --     becomes true.
    --
    --     Example: (a >= b) is not true.
    --
    -- [\<=]
    --     Checks whether the value of the left operand is less than or equal
    --     to the value of the right operand; if yes, then the condition
    --     becomes true.
    --
    --     Example: (a \<= b) is true.
    --
    -- [AND, OR, IN, BETWEEN, LIKE, NOT, IS NULL]
    --     Logical operators.
    --
    -- /Supported Partition Key Types/: The following are the supported
    -- partition keys.
    --
    -- -   @string@
    --
    -- -   @date@
    --
    -- -   @timestamp@
    --
    -- -   @int@
    --
    -- -   @bigint@
    --
    -- -   @long@
    --
    -- -   @tinyint@
    --
    -- -   @smallint@
    --
    -- -   @decimal@
    --
    -- If an type is encountered that is not valid, an exception is thrown.
    --
    -- The following list shows the valid operators on each type. When you
    -- define a crawler, the @partitionKey@ type is created as a @STRING@, to
    -- be compatible with the catalog partitions.
    --
    -- /Sample API Call/:
    GetPartitions -> Maybe Text
expression :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of partitions to return in a single response.
    GetPartitions -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | A continuation token, if this is not the first call to retrieve these
    -- partitions.
    GetPartitions -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The time as of when to read the partition contents. If not set, the most
    -- recent transaction commit time will be used. Cannot be specified along
    -- with @TransactionId@.
    GetPartitions -> Maybe POSIX
queryAsOfTime :: Prelude.Maybe Data.POSIX,
    -- | The segment of the table\'s partitions to scan in this request.
    GetPartitions -> Maybe Segment
segment :: Prelude.Maybe Segment,
    -- | The transaction ID at which to read the partition contents.
    GetPartitions -> Maybe Text
transactionId :: Prelude.Maybe Prelude.Text,
    -- | The name of the catalog database where the partitions reside.
    GetPartitions -> Text
databaseName :: Prelude.Text,
    -- | The name of the partitions\' table.
    GetPartitions -> Text
tableName :: Prelude.Text
  }
  deriving (GetPartitions -> GetPartitions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetPartitions -> GetPartitions -> Bool
$c/= :: GetPartitions -> GetPartitions -> Bool
== :: GetPartitions -> GetPartitions -> Bool
$c== :: GetPartitions -> GetPartitions -> Bool
Prelude.Eq, ReadPrec [GetPartitions]
ReadPrec GetPartitions
Int -> ReadS GetPartitions
ReadS [GetPartitions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetPartitions]
$creadListPrec :: ReadPrec [GetPartitions]
readPrec :: ReadPrec GetPartitions
$creadPrec :: ReadPrec GetPartitions
readList :: ReadS [GetPartitions]
$creadList :: ReadS [GetPartitions]
readsPrec :: Int -> ReadS GetPartitions
$creadsPrec :: Int -> ReadS GetPartitions
Prelude.Read, Int -> GetPartitions -> ShowS
[GetPartitions] -> ShowS
GetPartitions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPartitions] -> ShowS
$cshowList :: [GetPartitions] -> ShowS
show :: GetPartitions -> String
$cshow :: GetPartitions -> String
showsPrec :: Int -> GetPartitions -> ShowS
$cshowsPrec :: Int -> GetPartitions -> ShowS
Prelude.Show, forall x. Rep GetPartitions x -> GetPartitions
forall x. GetPartitions -> Rep GetPartitions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetPartitions x -> GetPartitions
$cfrom :: forall x. GetPartitions -> Rep GetPartitions x
Prelude.Generic)

-- |
-- Create a value of 'GetPartitions' 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:
--
-- 'catalogId', 'getPartitions_catalogId' - The ID of the Data Catalog where the partitions in question reside. If
-- none is provided, the Amazon Web Services account ID is used by default.
--
-- 'excludeColumnSchema', 'getPartitions_excludeColumnSchema' - When true, specifies not returning the partition column schema. Useful
-- when you are interested only in other partition attributes such as
-- partition values or location. This approach avoids the problem of a
-- large response by not returning duplicate data.
--
-- 'expression', 'getPartitions_expression' - An expression that filters the partitions to be returned.
--
-- The expression uses SQL syntax similar to the SQL @WHERE@ filter clause.
-- The SQL statement parser
-- <http://jsqlparser.sourceforge.net/home.php JSQLParser> parses the
-- expression.
--
-- /Operators/: The following are the operators that you can use in the
-- @Expression@ API call:
--
-- [=]
--     Checks whether the values of the two operands are equal; if yes,
--     then the condition becomes true.
--
--     Example: Assume \'variable a\' holds 10 and \'variable b\' holds 20.
--
--     (a = b) is not true.
--
-- [\< >]
--     Checks whether the values of two operands are equal; if the values
--     are not equal, then the condition becomes true.
--
--     Example: (a \< > b) is true.
--
-- [>]
--     Checks whether the value of the left operand is greater than the
--     value of the right operand; if yes, then the condition becomes true.
--
--     Example: (a > b) is not true.
--
-- [\<]
--     Checks whether the value of the left operand is less than the value
--     of the right operand; if yes, then the condition becomes true.
--
--     Example: (a \< b) is true.
--
-- [>=]
--     Checks whether the value of the left operand is greater than or
--     equal to the value of the right operand; if yes, then the condition
--     becomes true.
--
--     Example: (a >= b) is not true.
--
-- [\<=]
--     Checks whether the value of the left operand is less than or equal
--     to the value of the right operand; if yes, then the condition
--     becomes true.
--
--     Example: (a \<= b) is true.
--
-- [AND, OR, IN, BETWEEN, LIKE, NOT, IS NULL]
--     Logical operators.
--
-- /Supported Partition Key Types/: The following are the supported
-- partition keys.
--
-- -   @string@
--
-- -   @date@
--
-- -   @timestamp@
--
-- -   @int@
--
-- -   @bigint@
--
-- -   @long@
--
-- -   @tinyint@
--
-- -   @smallint@
--
-- -   @decimal@
--
-- If an type is encountered that is not valid, an exception is thrown.
--
-- The following list shows the valid operators on each type. When you
-- define a crawler, the @partitionKey@ type is created as a @STRING@, to
-- be compatible with the catalog partitions.
--
-- /Sample API Call/:
--
-- 'maxResults', 'getPartitions_maxResults' - The maximum number of partitions to return in a single response.
--
-- 'nextToken', 'getPartitions_nextToken' - A continuation token, if this is not the first call to retrieve these
-- partitions.
--
-- 'queryAsOfTime', 'getPartitions_queryAsOfTime' - The time as of when to read the partition contents. If not set, the most
-- recent transaction commit time will be used. Cannot be specified along
-- with @TransactionId@.
--
-- 'segment', 'getPartitions_segment' - The segment of the table\'s partitions to scan in this request.
--
-- 'transactionId', 'getPartitions_transactionId' - The transaction ID at which to read the partition contents.
--
-- 'databaseName', 'getPartitions_databaseName' - The name of the catalog database where the partitions reside.
--
-- 'tableName', 'getPartitions_tableName' - The name of the partitions\' table.
newGetPartitions ::
  -- | 'databaseName'
  Prelude.Text ->
  -- | 'tableName'
  Prelude.Text ->
  GetPartitions
newGetPartitions :: Text -> Text -> GetPartitions
newGetPartitions Text
pDatabaseName_ Text
pTableName_ =
  GetPartitions'
    { $sel:catalogId:GetPartitions' :: Maybe Text
catalogId = forall a. Maybe a
Prelude.Nothing,
      $sel:excludeColumnSchema:GetPartitions' :: Maybe Bool
excludeColumnSchema = forall a. Maybe a
Prelude.Nothing,
      $sel:expression:GetPartitions' :: Maybe Text
expression = forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:GetPartitions' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetPartitions' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:queryAsOfTime:GetPartitions' :: Maybe POSIX
queryAsOfTime = forall a. Maybe a
Prelude.Nothing,
      $sel:segment:GetPartitions' :: Maybe Segment
segment = forall a. Maybe a
Prelude.Nothing,
      $sel:transactionId:GetPartitions' :: Maybe Text
transactionId = forall a. Maybe a
Prelude.Nothing,
      $sel:databaseName:GetPartitions' :: Text
databaseName = Text
pDatabaseName_,
      $sel:tableName:GetPartitions' :: Text
tableName = Text
pTableName_
    }

-- | The ID of the Data Catalog where the partitions in question reside. If
-- none is provided, the Amazon Web Services account ID is used by default.
getPartitions_catalogId :: Lens.Lens' GetPartitions (Prelude.Maybe Prelude.Text)
getPartitions_catalogId :: Lens' GetPartitions (Maybe Text)
getPartitions_catalogId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPartitions' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:GetPartitions' :: GetPartitions -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: GetPartitions
s@GetPartitions' {} Maybe Text
a -> GetPartitions
s {$sel:catalogId:GetPartitions' :: Maybe Text
catalogId = Maybe Text
a} :: GetPartitions)

-- | When true, specifies not returning the partition column schema. Useful
-- when you are interested only in other partition attributes such as
-- partition values or location. This approach avoids the problem of a
-- large response by not returning duplicate data.
getPartitions_excludeColumnSchema :: Lens.Lens' GetPartitions (Prelude.Maybe Prelude.Bool)
getPartitions_excludeColumnSchema :: Lens' GetPartitions (Maybe Bool)
getPartitions_excludeColumnSchema = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPartitions' {Maybe Bool
excludeColumnSchema :: Maybe Bool
$sel:excludeColumnSchema:GetPartitions' :: GetPartitions -> Maybe Bool
excludeColumnSchema} -> Maybe Bool
excludeColumnSchema) (\s :: GetPartitions
s@GetPartitions' {} Maybe Bool
a -> GetPartitions
s {$sel:excludeColumnSchema:GetPartitions' :: Maybe Bool
excludeColumnSchema = Maybe Bool
a} :: GetPartitions)

-- | An expression that filters the partitions to be returned.
--
-- The expression uses SQL syntax similar to the SQL @WHERE@ filter clause.
-- The SQL statement parser
-- <http://jsqlparser.sourceforge.net/home.php JSQLParser> parses the
-- expression.
--
-- /Operators/: The following are the operators that you can use in the
-- @Expression@ API call:
--
-- [=]
--     Checks whether the values of the two operands are equal; if yes,
--     then the condition becomes true.
--
--     Example: Assume \'variable a\' holds 10 and \'variable b\' holds 20.
--
--     (a = b) is not true.
--
-- [\< >]
--     Checks whether the values of two operands are equal; if the values
--     are not equal, then the condition becomes true.
--
--     Example: (a \< > b) is true.
--
-- [>]
--     Checks whether the value of the left operand is greater than the
--     value of the right operand; if yes, then the condition becomes true.
--
--     Example: (a > b) is not true.
--
-- [\<]
--     Checks whether the value of the left operand is less than the value
--     of the right operand; if yes, then the condition becomes true.
--
--     Example: (a \< b) is true.
--
-- [>=]
--     Checks whether the value of the left operand is greater than or
--     equal to the value of the right operand; if yes, then the condition
--     becomes true.
--
--     Example: (a >= b) is not true.
--
-- [\<=]
--     Checks whether the value of the left operand is less than or equal
--     to the value of the right operand; if yes, then the condition
--     becomes true.
--
--     Example: (a \<= b) is true.
--
-- [AND, OR, IN, BETWEEN, LIKE, NOT, IS NULL]
--     Logical operators.
--
-- /Supported Partition Key Types/: The following are the supported
-- partition keys.
--
-- -   @string@
--
-- -   @date@
--
-- -   @timestamp@
--
-- -   @int@
--
-- -   @bigint@
--
-- -   @long@
--
-- -   @tinyint@
--
-- -   @smallint@
--
-- -   @decimal@
--
-- If an type is encountered that is not valid, an exception is thrown.
--
-- The following list shows the valid operators on each type. When you
-- define a crawler, the @partitionKey@ type is created as a @STRING@, to
-- be compatible with the catalog partitions.
--
-- /Sample API Call/:
getPartitions_expression :: Lens.Lens' GetPartitions (Prelude.Maybe Prelude.Text)
getPartitions_expression :: Lens' GetPartitions (Maybe Text)
getPartitions_expression = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPartitions' {Maybe Text
expression :: Maybe Text
$sel:expression:GetPartitions' :: GetPartitions -> Maybe Text
expression} -> Maybe Text
expression) (\s :: GetPartitions
s@GetPartitions' {} Maybe Text
a -> GetPartitions
s {$sel:expression:GetPartitions' :: Maybe Text
expression = Maybe Text
a} :: GetPartitions)

-- | The maximum number of partitions to return in a single response.
getPartitions_maxResults :: Lens.Lens' GetPartitions (Prelude.Maybe Prelude.Natural)
getPartitions_maxResults :: Lens' GetPartitions (Maybe Natural)
getPartitions_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPartitions' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:GetPartitions' :: GetPartitions -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: GetPartitions
s@GetPartitions' {} Maybe Natural
a -> GetPartitions
s {$sel:maxResults:GetPartitions' :: Maybe Natural
maxResults = Maybe Natural
a} :: GetPartitions)

-- | A continuation token, if this is not the first call to retrieve these
-- partitions.
getPartitions_nextToken :: Lens.Lens' GetPartitions (Prelude.Maybe Prelude.Text)
getPartitions_nextToken :: Lens' GetPartitions (Maybe Text)
getPartitions_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPartitions' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetPartitions' :: GetPartitions -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetPartitions
s@GetPartitions' {} Maybe Text
a -> GetPartitions
s {$sel:nextToken:GetPartitions' :: Maybe Text
nextToken = Maybe Text
a} :: GetPartitions)

-- | The time as of when to read the partition contents. If not set, the most
-- recent transaction commit time will be used. Cannot be specified along
-- with @TransactionId@.
getPartitions_queryAsOfTime :: Lens.Lens' GetPartitions (Prelude.Maybe Prelude.UTCTime)
getPartitions_queryAsOfTime :: Lens' GetPartitions (Maybe UTCTime)
getPartitions_queryAsOfTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPartitions' {Maybe POSIX
queryAsOfTime :: Maybe POSIX
$sel:queryAsOfTime:GetPartitions' :: GetPartitions -> Maybe POSIX
queryAsOfTime} -> Maybe POSIX
queryAsOfTime) (\s :: GetPartitions
s@GetPartitions' {} Maybe POSIX
a -> GetPartitions
s {$sel:queryAsOfTime:GetPartitions' :: Maybe POSIX
queryAsOfTime = Maybe POSIX
a} :: GetPartitions) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The segment of the table\'s partitions to scan in this request.
getPartitions_segment :: Lens.Lens' GetPartitions (Prelude.Maybe Segment)
getPartitions_segment :: Lens' GetPartitions (Maybe Segment)
getPartitions_segment = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPartitions' {Maybe Segment
segment :: Maybe Segment
$sel:segment:GetPartitions' :: GetPartitions -> Maybe Segment
segment} -> Maybe Segment
segment) (\s :: GetPartitions
s@GetPartitions' {} Maybe Segment
a -> GetPartitions
s {$sel:segment:GetPartitions' :: Maybe Segment
segment = Maybe Segment
a} :: GetPartitions)

-- | The transaction ID at which to read the partition contents.
getPartitions_transactionId :: Lens.Lens' GetPartitions (Prelude.Maybe Prelude.Text)
getPartitions_transactionId :: Lens' GetPartitions (Maybe Text)
getPartitions_transactionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPartitions' {Maybe Text
transactionId :: Maybe Text
$sel:transactionId:GetPartitions' :: GetPartitions -> Maybe Text
transactionId} -> Maybe Text
transactionId) (\s :: GetPartitions
s@GetPartitions' {} Maybe Text
a -> GetPartitions
s {$sel:transactionId:GetPartitions' :: Maybe Text
transactionId = Maybe Text
a} :: GetPartitions)

-- | The name of the catalog database where the partitions reside.
getPartitions_databaseName :: Lens.Lens' GetPartitions Prelude.Text
getPartitions_databaseName :: Lens' GetPartitions Text
getPartitions_databaseName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPartitions' {Text
databaseName :: Text
$sel:databaseName:GetPartitions' :: GetPartitions -> Text
databaseName} -> Text
databaseName) (\s :: GetPartitions
s@GetPartitions' {} Text
a -> GetPartitions
s {$sel:databaseName:GetPartitions' :: Text
databaseName = Text
a} :: GetPartitions)

-- | The name of the partitions\' table.
getPartitions_tableName :: Lens.Lens' GetPartitions Prelude.Text
getPartitions_tableName :: Lens' GetPartitions Text
getPartitions_tableName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPartitions' {Text
tableName :: Text
$sel:tableName:GetPartitions' :: GetPartitions -> Text
tableName} -> Text
tableName) (\s :: GetPartitions
s@GetPartitions' {} Text
a -> GetPartitions
s {$sel:tableName:GetPartitions' :: Text
tableName = Text
a} :: GetPartitions)

instance Core.AWSPager GetPartitions where
  page :: GetPartitions -> AWSResponse GetPartitions -> Maybe GetPartitions
page GetPartitions
rq AWSResponse GetPartitions
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetPartitions
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetPartitionsResponse (Maybe Text)
getPartitionsResponse_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 GetPartitions
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetPartitionsResponse (Maybe [Partition])
getPartitionsResponse_partitions
            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.$ GetPartitions
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' GetPartitions (Maybe Text)
getPartitions_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetPartitions
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetPartitionsResponse (Maybe Text)
getPartitionsResponse_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 GetPartitions where
  type
    AWSResponse GetPartitions =
      GetPartitionsResponse
  request :: (Service -> Service) -> GetPartitions -> Request GetPartitions
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 GetPartitions
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetPartitions)))
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 [Partition] -> Int -> GetPartitionsResponse
GetPartitionsResponse'
            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
"NextToken")
            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
"Partitions" 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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetPartitions where
  hashWithSalt :: Int -> GetPartitions -> Int
hashWithSalt Int
_salt GetPartitions' {Maybe Bool
Maybe Natural
Maybe Text
Maybe POSIX
Maybe Segment
Text
tableName :: Text
databaseName :: Text
transactionId :: Maybe Text
segment :: Maybe Segment
queryAsOfTime :: Maybe POSIX
nextToken :: Maybe Text
maxResults :: Maybe Natural
expression :: Maybe Text
excludeColumnSchema :: Maybe Bool
catalogId :: Maybe Text
$sel:tableName:GetPartitions' :: GetPartitions -> Text
$sel:databaseName:GetPartitions' :: GetPartitions -> Text
$sel:transactionId:GetPartitions' :: GetPartitions -> Maybe Text
$sel:segment:GetPartitions' :: GetPartitions -> Maybe Segment
$sel:queryAsOfTime:GetPartitions' :: GetPartitions -> Maybe POSIX
$sel:nextToken:GetPartitions' :: GetPartitions -> Maybe Text
$sel:maxResults:GetPartitions' :: GetPartitions -> Maybe Natural
$sel:expression:GetPartitions' :: GetPartitions -> Maybe Text
$sel:excludeColumnSchema:GetPartitions' :: GetPartitions -> Maybe Bool
$sel:catalogId:GetPartitions' :: GetPartitions -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
catalogId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
excludeColumnSchema
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
expression
      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 POSIX
queryAsOfTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Segment
segment
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
transactionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
databaseName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tableName

instance Prelude.NFData GetPartitions where
  rnf :: GetPartitions -> ()
rnf GetPartitions' {Maybe Bool
Maybe Natural
Maybe Text
Maybe POSIX
Maybe Segment
Text
tableName :: Text
databaseName :: Text
transactionId :: Maybe Text
segment :: Maybe Segment
queryAsOfTime :: Maybe POSIX
nextToken :: Maybe Text
maxResults :: Maybe Natural
expression :: Maybe Text
excludeColumnSchema :: Maybe Bool
catalogId :: Maybe Text
$sel:tableName:GetPartitions' :: GetPartitions -> Text
$sel:databaseName:GetPartitions' :: GetPartitions -> Text
$sel:transactionId:GetPartitions' :: GetPartitions -> Maybe Text
$sel:segment:GetPartitions' :: GetPartitions -> Maybe Segment
$sel:queryAsOfTime:GetPartitions' :: GetPartitions -> Maybe POSIX
$sel:nextToken:GetPartitions' :: GetPartitions -> Maybe Text
$sel:maxResults:GetPartitions' :: GetPartitions -> Maybe Natural
$sel:expression:GetPartitions' :: GetPartitions -> Maybe Text
$sel:excludeColumnSchema:GetPartitions' :: GetPartitions -> Maybe Bool
$sel:catalogId:GetPartitions' :: GetPartitions -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
catalogId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
excludeColumnSchema
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
expression
      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 POSIX
queryAsOfTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Segment
segment
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
transactionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
databaseName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
tableName

instance Data.ToHeaders GetPartitions where
  toHeaders :: GetPartitions -> 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
"AWSGlue.GetPartitions" :: 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 GetPartitions where
  toJSON :: GetPartitions -> Value
toJSON GetPartitions' {Maybe Bool
Maybe Natural
Maybe Text
Maybe POSIX
Maybe Segment
Text
tableName :: Text
databaseName :: Text
transactionId :: Maybe Text
segment :: Maybe Segment
queryAsOfTime :: Maybe POSIX
nextToken :: Maybe Text
maxResults :: Maybe Natural
expression :: Maybe Text
excludeColumnSchema :: Maybe Bool
catalogId :: Maybe Text
$sel:tableName:GetPartitions' :: GetPartitions -> Text
$sel:databaseName:GetPartitions' :: GetPartitions -> Text
$sel:transactionId:GetPartitions' :: GetPartitions -> Maybe Text
$sel:segment:GetPartitions' :: GetPartitions -> Maybe Segment
$sel:queryAsOfTime:GetPartitions' :: GetPartitions -> Maybe POSIX
$sel:nextToken:GetPartitions' :: GetPartitions -> Maybe Text
$sel:maxResults:GetPartitions' :: GetPartitions -> Maybe Natural
$sel:expression:GetPartitions' :: GetPartitions -> Maybe Text
$sel:excludeColumnSchema:GetPartitions' :: GetPartitions -> Maybe Bool
$sel:catalogId:GetPartitions' :: GetPartitions -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CatalogId" 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
catalogId,
            (Key
"ExcludeColumnSchema" 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 Bool
excludeColumnSchema,
            (Key
"Expression" 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
expression,
            (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
"QueryAsOfTime" 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 POSIX
queryAsOfTime,
            (Key
"Segment" 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 Segment
segment,
            (Key
"TransactionId" 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
transactionId,
            forall a. a -> Maybe a
Prelude.Just (Key
"DatabaseName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
databaseName),
            forall a. a -> Maybe a
Prelude.Just (Key
"TableName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
tableName)
          ]
      )

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

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

-- | /See:/ 'newGetPartitionsResponse' smart constructor.
data GetPartitionsResponse = GetPartitionsResponse'
  { -- | A continuation token, if the returned list of partitions does not
    -- include the last one.
    GetPartitionsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of requested partitions.
    GetPartitionsResponse -> Maybe [Partition]
partitions :: Prelude.Maybe [Partition],
    -- | The response's http status code.
    GetPartitionsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetPartitionsResponse -> GetPartitionsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetPartitionsResponse -> GetPartitionsResponse -> Bool
$c/= :: GetPartitionsResponse -> GetPartitionsResponse -> Bool
== :: GetPartitionsResponse -> GetPartitionsResponse -> Bool
$c== :: GetPartitionsResponse -> GetPartitionsResponse -> Bool
Prelude.Eq, ReadPrec [GetPartitionsResponse]
ReadPrec GetPartitionsResponse
Int -> ReadS GetPartitionsResponse
ReadS [GetPartitionsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetPartitionsResponse]
$creadListPrec :: ReadPrec [GetPartitionsResponse]
readPrec :: ReadPrec GetPartitionsResponse
$creadPrec :: ReadPrec GetPartitionsResponse
readList :: ReadS [GetPartitionsResponse]
$creadList :: ReadS [GetPartitionsResponse]
readsPrec :: Int -> ReadS GetPartitionsResponse
$creadsPrec :: Int -> ReadS GetPartitionsResponse
Prelude.Read, Int -> GetPartitionsResponse -> ShowS
[GetPartitionsResponse] -> ShowS
GetPartitionsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPartitionsResponse] -> ShowS
$cshowList :: [GetPartitionsResponse] -> ShowS
show :: GetPartitionsResponse -> String
$cshow :: GetPartitionsResponse -> String
showsPrec :: Int -> GetPartitionsResponse -> ShowS
$cshowsPrec :: Int -> GetPartitionsResponse -> ShowS
Prelude.Show, forall x. Rep GetPartitionsResponse x -> GetPartitionsResponse
forall x. GetPartitionsResponse -> Rep GetPartitionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetPartitionsResponse x -> GetPartitionsResponse
$cfrom :: forall x. GetPartitionsResponse -> Rep GetPartitionsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetPartitionsResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'nextToken', 'getPartitionsResponse_nextToken' - A continuation token, if the returned list of partitions does not
-- include the last one.
--
-- 'partitions', 'getPartitionsResponse_partitions' - A list of requested partitions.
--
-- 'httpStatus', 'getPartitionsResponse_httpStatus' - The response's http status code.
newGetPartitionsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetPartitionsResponse
newGetPartitionsResponse :: Int -> GetPartitionsResponse
newGetPartitionsResponse Int
pHttpStatus_ =
  GetPartitionsResponse'
    { $sel:nextToken:GetPartitionsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:partitions:GetPartitionsResponse' :: Maybe [Partition]
partitions = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetPartitionsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A continuation token, if the returned list of partitions does not
-- include the last one.
getPartitionsResponse_nextToken :: Lens.Lens' GetPartitionsResponse (Prelude.Maybe Prelude.Text)
getPartitionsResponse_nextToken :: Lens' GetPartitionsResponse (Maybe Text)
getPartitionsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPartitionsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetPartitionsResponse' :: GetPartitionsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetPartitionsResponse
s@GetPartitionsResponse' {} Maybe Text
a -> GetPartitionsResponse
s {$sel:nextToken:GetPartitionsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetPartitionsResponse)

-- | A list of requested partitions.
getPartitionsResponse_partitions :: Lens.Lens' GetPartitionsResponse (Prelude.Maybe [Partition])
getPartitionsResponse_partitions :: Lens' GetPartitionsResponse (Maybe [Partition])
getPartitionsResponse_partitions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPartitionsResponse' {Maybe [Partition]
partitions :: Maybe [Partition]
$sel:partitions:GetPartitionsResponse' :: GetPartitionsResponse -> Maybe [Partition]
partitions} -> Maybe [Partition]
partitions) (\s :: GetPartitionsResponse
s@GetPartitionsResponse' {} Maybe [Partition]
a -> GetPartitionsResponse
s {$sel:partitions:GetPartitionsResponse' :: Maybe [Partition]
partitions = Maybe [Partition]
a} :: GetPartitionsResponse) 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

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

instance Prelude.NFData GetPartitionsResponse where
  rnf :: GetPartitionsResponse -> ()
rnf GetPartitionsResponse' {Int
Maybe [Partition]
Maybe Text
httpStatus :: Int
partitions :: Maybe [Partition]
nextToken :: Maybe Text
$sel:httpStatus:GetPartitionsResponse' :: GetPartitionsResponse -> Int
$sel:partitions:GetPartitionsResponse' :: GetPartitionsResponse -> Maybe [Partition]
$sel:nextToken:GetPartitionsResponse' :: GetPartitionsResponse -> Maybe Text
..} =
    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 [Partition]
partitions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus