{-# 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-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)
--
-- 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_nextToken,
    getPartitions_expression,
    getPartitions_segment,
    getPartitions_maxResults,
    getPartitions_databaseName,
    getPartitions_tableName,

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

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

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types
import qualified Amazonka.Lens as Lens
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,
    -- | A continuation token, if this is not the first call to retrieve these
    -- partitions.
    GetPartitions -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | 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 segment of the table\'s partitions to scan in this request.
    GetPartitions -> Maybe Segment
segment :: Prelude.Maybe Segment,
    -- | The maximum number of partitions to return in a single response.
    GetPartitions -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | 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
(GetPartitions -> GetPartitions -> Bool)
-> (GetPartitions -> GetPartitions -> Bool) -> Eq GetPartitions
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]
(Int -> ReadS GetPartitions)
-> ReadS [GetPartitions]
-> ReadPrec GetPartitions
-> ReadPrec [GetPartitions]
-> Read 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
(Int -> GetPartitions -> ShowS)
-> (GetPartitions -> String)
-> ([GetPartitions] -> ShowS)
-> Show GetPartitions
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. GetPartitions -> Rep GetPartitions x)
-> (forall x. Rep GetPartitions x -> GetPartitions)
-> Generic GetPartitions
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.
--
-- 'nextToken', 'getPartitions_nextToken' - A continuation token, if this is not the first call to retrieve these
-- partitions.
--
-- '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/:
--
-- 'segment', 'getPartitions_segment' - The segment of the table\'s partitions to scan in this request.
--
-- 'maxResults', 'getPartitions_maxResults' - The maximum number of partitions to return in a single response.
--
-- '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' :: Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Segment
-> Maybe Natural
-> Text
-> Text
-> GetPartitions
GetPartitions'
    { $sel:catalogId:GetPartitions' :: Maybe Text
catalogId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:excludeColumnSchema:GetPartitions' :: Maybe Bool
excludeColumnSchema = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetPartitions' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:expression:GetPartitions' :: Maybe Text
expression = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:segment:GetPartitions' :: Maybe Segment
segment = Maybe Segment
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:GetPartitions' :: Maybe Natural
maxResults = Maybe Natural
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 :: (Maybe Text -> f (Maybe Text)) -> GetPartitions -> f GetPartitions
getPartitions_catalogId = (GetPartitions -> Maybe Text)
-> (GetPartitions -> Maybe Text -> GetPartitions)
-> Lens GetPartitions GetPartitions (Maybe Text) (Maybe Text)
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 :: (Maybe Bool -> f (Maybe Bool)) -> GetPartitions -> f GetPartitions
getPartitions_excludeColumnSchema = (GetPartitions -> Maybe Bool)
-> (GetPartitions -> Maybe Bool -> GetPartitions)
-> Lens GetPartitions GetPartitions (Maybe Bool) (Maybe Bool)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> GetPartitions -> f GetPartitions
getPartitions_nextToken = (GetPartitions -> Maybe Text)
-> (GetPartitions -> Maybe Text -> GetPartitions)
-> Lens GetPartitions GetPartitions (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> GetPartitions -> f GetPartitions
getPartitions_expression = (GetPartitions -> Maybe Text)
-> (GetPartitions -> Maybe Text -> GetPartitions)
-> Lens GetPartitions GetPartitions (Maybe Text) (Maybe Text)
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 segment of the table\'s partitions to scan in this request.
getPartitions_segment :: Lens.Lens' GetPartitions (Prelude.Maybe Segment)
getPartitions_segment :: (Maybe Segment -> f (Maybe Segment))
-> GetPartitions -> f GetPartitions
getPartitions_segment = (GetPartitions -> Maybe Segment)
-> (GetPartitions -> Maybe Segment -> GetPartitions)
-> Lens GetPartitions GetPartitions (Maybe Segment) (Maybe 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 maximum number of partitions to return in a single response.
getPartitions_maxResults :: Lens.Lens' GetPartitions (Prelude.Maybe Prelude.Natural)
getPartitions_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> GetPartitions -> f GetPartitions
getPartitions_maxResults = (GetPartitions -> Maybe Natural)
-> (GetPartitions -> Maybe Natural -> GetPartitions)
-> Lens GetPartitions GetPartitions (Maybe Natural) (Maybe Natural)
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)

-- | The name of the catalog database where the partitions reside.
getPartitions_databaseName :: Lens.Lens' GetPartitions Prelude.Text
getPartitions_databaseName :: (Text -> f Text) -> GetPartitions -> f GetPartitions
getPartitions_databaseName = (GetPartitions -> Text)
-> (GetPartitions -> Text -> GetPartitions)
-> Lens GetPartitions GetPartitions Text Text
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 :: (Text -> f Text) -> GetPartitions -> f GetPartitions
getPartitions_tableName = (GetPartitions -> Text)
-> (GetPartitions -> Text -> GetPartitions)
-> Lens GetPartitions GetPartitions Text Text
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
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetPartitions
GetPartitionsResponse
rs
            GetPartitionsResponse
-> Getting (First Text) GetPartitionsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetPartitionsResponse
-> Const (First Text) GetPartitionsResponse
Lens' GetPartitionsResponse (Maybe Text)
getPartitionsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetPartitionsResponse
 -> Const (First Text) GetPartitionsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetPartitionsResponse 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 GetPartitions
forall a. Maybe a
Prelude.Nothing
    | Maybe [Partition] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetPartitions
GetPartitionsResponse
rs
            GetPartitionsResponse
-> Getting (First [Partition]) GetPartitionsResponse [Partition]
-> Maybe [Partition]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Partition]
 -> Const (First [Partition]) (Maybe [Partition]))
-> GetPartitionsResponse
-> Const (First [Partition]) GetPartitionsResponse
Lens' GetPartitionsResponse (Maybe [Partition])
getPartitionsResponse_partitions
              ((Maybe [Partition]
  -> Const (First [Partition]) (Maybe [Partition]))
 -> GetPartitionsResponse
 -> Const (First [Partition]) GetPartitionsResponse)
-> (([Partition] -> Const (First [Partition]) [Partition])
    -> Maybe [Partition]
    -> Const (First [Partition]) (Maybe [Partition]))
-> Getting (First [Partition]) GetPartitionsResponse [Partition]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Partition] -> Const (First [Partition]) [Partition])
-> Maybe [Partition]
-> Const (First [Partition]) (Maybe [Partition])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe GetPartitions
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      GetPartitions -> Maybe GetPartitions
forall a. a -> Maybe a
Prelude.Just (GetPartitions -> Maybe GetPartitions)
-> GetPartitions -> Maybe GetPartitions
forall a b. (a -> b) -> a -> b
Prelude.$
        GetPartitions
rq
          GetPartitions -> (GetPartitions -> GetPartitions) -> GetPartitions
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> GetPartitions -> Identity GetPartitions
Lens GetPartitions GetPartitions (Maybe Text) (Maybe Text)
getPartitions_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> GetPartitions -> Identity GetPartitions)
-> Maybe Text -> GetPartitions -> GetPartitions
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetPartitions
GetPartitionsResponse
rs
          GetPartitionsResponse
-> Getting (First Text) GetPartitionsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetPartitionsResponse
-> Const (First Text) GetPartitionsResponse
Lens' GetPartitionsResponse (Maybe Text)
getPartitionsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetPartitionsResponse
 -> Const (First Text) GetPartitionsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetPartitionsResponse 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 GetPartitions where
  type
    AWSResponse GetPartitions =
      GetPartitionsResponse
  request :: GetPartitions -> Request GetPartitions
request = Service -> GetPartitions -> Request GetPartitions
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetPartitions
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetPartitions)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetPartitions))
-> Logger
-> Service
-> Proxy GetPartitions
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetPartitions)))
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 [Partition] -> Maybe Text -> Int -> GetPartitionsResponse
GetPartitionsResponse'
            (Maybe [Partition] -> Maybe Text -> Int -> GetPartitionsResponse)
-> Either String (Maybe [Partition])
-> Either String (Maybe Text -> Int -> GetPartitionsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Partition]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Partitions" Either String (Maybe (Maybe [Partition]))
-> Maybe [Partition] -> Either String (Maybe [Partition])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Partition]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Maybe Text -> Int -> GetPartitionsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetPartitionsResponse)
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 -> GetPartitionsResponse)
-> Either String Int -> Either String GetPartitionsResponse
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 GetPartitions

instance Prelude.NFData GetPartitions

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

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

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

-- | /See:/ 'newGetPartitionsResponse' smart constructor.
data GetPartitionsResponse = GetPartitionsResponse'
  { -- | A list of requested partitions.
    GetPartitionsResponse -> Maybe [Partition]
partitions :: Prelude.Maybe [Partition],
    -- | A continuation token, if the returned list of partitions does not
    -- include the last one.
    GetPartitionsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetPartitionsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetPartitionsResponse -> GetPartitionsResponse -> Bool
(GetPartitionsResponse -> GetPartitionsResponse -> Bool)
-> (GetPartitionsResponse -> GetPartitionsResponse -> Bool)
-> Eq GetPartitionsResponse
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]
(Int -> ReadS GetPartitionsResponse)
-> ReadS [GetPartitionsResponse]
-> ReadPrec GetPartitionsResponse
-> ReadPrec [GetPartitionsResponse]
-> Read 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
(Int -> GetPartitionsResponse -> ShowS)
-> (GetPartitionsResponse -> String)
-> ([GetPartitionsResponse] -> ShowS)
-> Show GetPartitionsResponse
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. GetPartitionsResponse -> Rep GetPartitionsResponse x)
-> (forall x. Rep GetPartitionsResponse x -> GetPartitionsResponse)
-> Generic GetPartitionsResponse
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:
--
-- 'partitions', 'getPartitionsResponse_partitions' - A list of requested partitions.
--
-- 'nextToken', 'getPartitionsResponse_nextToken' - A continuation token, if the returned list of partitions does not
-- include the last one.
--
-- 'httpStatus', 'getPartitionsResponse_httpStatus' - The response's http status code.
newGetPartitionsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetPartitionsResponse
newGetPartitionsResponse :: Int -> GetPartitionsResponse
newGetPartitionsResponse Int
pHttpStatus_ =
  GetPartitionsResponse' :: Maybe [Partition] -> Maybe Text -> Int -> GetPartitionsResponse
GetPartitionsResponse'
    { $sel:partitions:GetPartitionsResponse' :: Maybe [Partition]
partitions =
        Maybe [Partition]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetPartitionsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetPartitionsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of requested partitions.
getPartitionsResponse_partitions :: Lens.Lens' GetPartitionsResponse (Prelude.Maybe [Partition])
getPartitionsResponse_partitions :: (Maybe [Partition] -> f (Maybe [Partition]))
-> GetPartitionsResponse -> f GetPartitionsResponse
getPartitionsResponse_partitions = (GetPartitionsResponse -> Maybe [Partition])
-> (GetPartitionsResponse
    -> Maybe [Partition] -> GetPartitionsResponse)
-> Lens' GetPartitionsResponse (Maybe [Partition])
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) ((Maybe [Partition] -> f (Maybe [Partition]))
 -> GetPartitionsResponse -> f GetPartitionsResponse)
-> ((Maybe [Partition] -> f (Maybe [Partition]))
    -> Maybe [Partition] -> f (Maybe [Partition]))
-> (Maybe [Partition] -> f (Maybe [Partition]))
-> GetPartitionsResponse
-> f GetPartitionsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Partition] [Partition] [Partition] [Partition]
-> Iso
     (Maybe [Partition])
     (Maybe [Partition])
     (Maybe [Partition])
     (Maybe [Partition])
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 [Partition] [Partition] [Partition] [Partition]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> GetPartitionsResponse -> f GetPartitionsResponse
getPartitionsResponse_nextToken = (GetPartitionsResponse -> Maybe Text)
-> (GetPartitionsResponse -> Maybe Text -> GetPartitionsResponse)
-> Lens' GetPartitionsResponse (Maybe Text)
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)

-- | The response's http status code.
getPartitionsResponse_httpStatus :: Lens.Lens' GetPartitionsResponse Prelude.Int
getPartitionsResponse_httpStatus :: (Int -> f Int) -> GetPartitionsResponse -> f GetPartitionsResponse
getPartitionsResponse_httpStatus = (GetPartitionsResponse -> Int)
-> (GetPartitionsResponse -> Int -> GetPartitionsResponse)
-> Lens GetPartitionsResponse GetPartitionsResponse Int Int
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