{-# 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.DynamoDB.CreateTable
-- 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)
--
-- The @CreateTable@ operation adds a new table to your account. In an AWS
-- account, table names must be unique within each Region. That is, you can
-- have two tables with same name if you create the tables in different
-- Regions.
--
-- @CreateTable@ is an asynchronous operation. Upon receiving a
-- @CreateTable@ request, DynamoDB immediately returns a response with a
-- @TableStatus@ of @CREATING@. After the table is created, DynamoDB sets
-- the @TableStatus@ to @ACTIVE@. You can perform read and write operations
-- only on an @ACTIVE@ table.
--
-- You can optionally define secondary indexes on the new table, as part of
-- the @CreateTable@ operation. If you want to create multiple tables with
-- secondary indexes on them, you must create the tables sequentially. Only
-- one table with secondary indexes can be in the @CREATING@ state at any
-- given time.
--
-- You can use the @DescribeTable@ action to check the table status.
module Amazonka.DynamoDB.CreateTable
  ( -- * Creating a Request
    CreateTable (..),
    newCreateTable,

    -- * Request Lenses
    createTable_provisionedThroughput,
    createTable_sSESpecification,
    createTable_globalSecondaryIndexes,
    createTable_localSecondaryIndexes,
    createTable_billingMode,
    createTable_tags,
    createTable_streamSpecification,
    createTable_attributeDefinitions,
    createTable_tableName,
    createTable_keySchema,

    -- * Destructuring the Response
    CreateTableResponse (..),
    newCreateTableResponse,

    -- * Response Lenses
    createTableResponse_tableDescription,
    createTableResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.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

-- | Represents the input of a @CreateTable@ operation.
--
-- /See:/ 'newCreateTable' smart constructor.
data CreateTable = CreateTable'
  { -- | Represents the provisioned throughput settings for a specified table or
    -- index. The settings can be modified using the @UpdateTable@ operation.
    --
    -- If you set BillingMode as @PROVISIONED@, you must specify this property.
    -- If you set BillingMode as @PAY_PER_REQUEST@, you cannot specify this
    -- property.
    --
    -- For current minimum and maximum provisioned throughput values, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html Service, Account, and Table Quotas>
    -- in the /Amazon DynamoDB Developer Guide/.
    CreateTable -> Maybe ProvisionedThroughput
provisionedThroughput :: Prelude.Maybe ProvisionedThroughput,
    -- | Represents the settings used to enable server-side encryption.
    CreateTable -> Maybe SSESpecification
sSESpecification :: Prelude.Maybe SSESpecification,
    -- | One or more global secondary indexes (the maximum is 20) to be created
    -- on the table. Each global secondary index in the array includes the
    -- following:
    --
    -- -   @IndexName@ - The name of the global secondary index. Must be unique
    --     only for this table.
    --
    -- -   @KeySchema@ - Specifies the key schema for the global secondary
    --     index.
    --
    -- -   @Projection@ - Specifies attributes that are copied (projected) from
    --     the table into the index. These are in addition to the primary key
    --     attributes and index key attributes, which are automatically
    --     projected. Each attribute specification is composed of:
    --
    --     -   @ProjectionType@ - One of the following:
    --
    --         -   @KEYS_ONLY@ - Only the index and primary keys are projected
    --             into the index.
    --
    --         -   @INCLUDE@ - Only the specified table attributes are
    --             projected into the index. The list of projected attributes
    --             is in @NonKeyAttributes@.
    --
    --         -   @ALL@ - All of the table attributes are projected into the
    --             index.
    --
    --     -   @NonKeyAttributes@ - A list of one or more non-key attribute
    --         names that are projected into the secondary index. The total
    --         count of attributes provided in @NonKeyAttributes@, summed
    --         across all of the secondary indexes, must not exceed 100. If you
    --         project the same attribute into two different indexes, this
    --         counts as two distinct attributes when determining the total.
    --
    -- -   @ProvisionedThroughput@ - The provisioned throughput settings for
    --     the global secondary index, consisting of read and write capacity
    --     units.
    CreateTable -> Maybe [GlobalSecondaryIndex]
globalSecondaryIndexes :: Prelude.Maybe [GlobalSecondaryIndex],
    -- | One or more local secondary indexes (the maximum is 5) to be created on
    -- the table. Each index is scoped to a given partition key value. There is
    -- a 10 GB size limit per partition key value; otherwise, the size of a
    -- local secondary index is unconstrained.
    --
    -- Each local secondary index in the array includes the following:
    --
    -- -   @IndexName@ - The name of the local secondary index. Must be unique
    --     only for this table.
    --
    -- -   @KeySchema@ - Specifies the key schema for the local secondary
    --     index. The key schema must begin with the same partition key as the
    --     table.
    --
    -- -   @Projection@ - Specifies attributes that are copied (projected) from
    --     the table into the index. These are in addition to the primary key
    --     attributes and index key attributes, which are automatically
    --     projected. Each attribute specification is composed of:
    --
    --     -   @ProjectionType@ - One of the following:
    --
    --         -   @KEYS_ONLY@ - Only the index and primary keys are projected
    --             into the index.
    --
    --         -   @INCLUDE@ - Only the specified table attributes are
    --             projected into the index. The list of projected attributes
    --             is in @NonKeyAttributes@.
    --
    --         -   @ALL@ - All of the table attributes are projected into the
    --             index.
    --
    --     -   @NonKeyAttributes@ - A list of one or more non-key attribute
    --         names that are projected into the secondary index. The total
    --         count of attributes provided in @NonKeyAttributes@, summed
    --         across all of the secondary indexes, must not exceed 100. If you
    --         project the same attribute into two different indexes, this
    --         counts as two distinct attributes when determining the total.
    CreateTable -> Maybe [LocalSecondaryIndex]
localSecondaryIndexes :: Prelude.Maybe [LocalSecondaryIndex],
    -- | Controls how you are charged for read and write throughput and how you
    -- manage capacity. This setting can be changed later.
    --
    -- -   @PROVISIONED@ - We recommend using @PROVISIONED@ for predictable
    --     workloads. @PROVISIONED@ sets the billing mode to
    --     <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html#HowItWorks.ProvisionedThroughput.Manual Provisioned Mode>.
    --
    -- -   @PAY_PER_REQUEST@ - We recommend using @PAY_PER_REQUEST@ for
    --     unpredictable workloads. @PAY_PER_REQUEST@ sets the billing mode to
    --     <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html#HowItWorks.OnDemand On-Demand Mode>.
    CreateTable -> Maybe BillingMode
billingMode :: Prelude.Maybe BillingMode,
    -- | A list of key-value pairs to label the table. For more information, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tagging.html Tagging for DynamoDB>.
    CreateTable -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The settings for DynamoDB Streams on the table. These settings consist
    -- of:
    --
    -- -   @StreamEnabled@ - Indicates whether DynamoDB Streams is to be
    --     enabled (true) or disabled (false).
    --
    -- -   @StreamViewType@ - When an item in the table is modified,
    --     @StreamViewType@ determines what information is written to the
    --     table\'s stream. Valid values for @StreamViewType@ are:
    --
    --     -   @KEYS_ONLY@ - Only the key attributes of the modified item are
    --         written to the stream.
    --
    --     -   @NEW_IMAGE@ - The entire item, as it appears after it was
    --         modified, is written to the stream.
    --
    --     -   @OLD_IMAGE@ - The entire item, as it appeared before it was
    --         modified, is written to the stream.
    --
    --     -   @NEW_AND_OLD_IMAGES@ - Both the new and the old item images of
    --         the item are written to the stream.
    CreateTable -> Maybe StreamSpecification
streamSpecification :: Prelude.Maybe StreamSpecification,
    -- | An array of attributes that describe the key schema for the table and
    -- indexes.
    CreateTable -> [AttributeDefinition]
attributeDefinitions :: [AttributeDefinition],
    -- | The name of the table to create.
    CreateTable -> Text
tableName :: Prelude.Text,
    -- | Specifies the attributes that make up the primary key for a table or an
    -- index. The attributes in @KeySchema@ must also be defined in the
    -- @AttributeDefinitions@ array. For more information, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html Data Model>
    -- in the /Amazon DynamoDB Developer Guide/.
    --
    -- Each @KeySchemaElement@ in the array is composed of:
    --
    -- -   @AttributeName@ - The name of this key attribute.
    --
    -- -   @KeyType@ - The role that the key attribute will assume:
    --
    --     -   @HASH@ - partition key
    --
    --     -   @RANGE@ - sort key
    --
    -- The partition key of an item is also known as its /hash attribute/. The
    -- term \"hash attribute\" derives from the DynamoDB usage of an internal
    -- hash function to evenly distribute data items across partitions, based
    -- on their partition key values.
    --
    -- The sort key of an item is also known as its /range attribute/. The term
    -- \"range attribute\" derives from the way DynamoDB stores items with the
    -- same partition key physically close together, in sorted order by the
    -- sort key value.
    --
    -- For a simple primary key (partition key), you must provide exactly one
    -- element with a @KeyType@ of @HASH@.
    --
    -- For a composite primary key (partition key and sort key), you must
    -- provide exactly two elements, in this order: The first element must have
    -- a @KeyType@ of @HASH@, and the second element must have a @KeyType@ of
    -- @RANGE@.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#WorkingWithTables.primary.key Working with Tables>
    -- in the /Amazon DynamoDB Developer Guide/.
    CreateTable -> NonEmpty KeySchemaElement
keySchema :: Prelude.NonEmpty KeySchemaElement
  }
  deriving (CreateTable -> CreateTable -> Bool
(CreateTable -> CreateTable -> Bool)
-> (CreateTable -> CreateTable -> Bool) -> Eq CreateTable
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTable -> CreateTable -> Bool
$c/= :: CreateTable -> CreateTable -> Bool
== :: CreateTable -> CreateTable -> Bool
$c== :: CreateTable -> CreateTable -> Bool
Prelude.Eq, ReadPrec [CreateTable]
ReadPrec CreateTable
Int -> ReadS CreateTable
ReadS [CreateTable]
(Int -> ReadS CreateTable)
-> ReadS [CreateTable]
-> ReadPrec CreateTable
-> ReadPrec [CreateTable]
-> Read CreateTable
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTable]
$creadListPrec :: ReadPrec [CreateTable]
readPrec :: ReadPrec CreateTable
$creadPrec :: ReadPrec CreateTable
readList :: ReadS [CreateTable]
$creadList :: ReadS [CreateTable]
readsPrec :: Int -> ReadS CreateTable
$creadsPrec :: Int -> ReadS CreateTable
Prelude.Read, Int -> CreateTable -> ShowS
[CreateTable] -> ShowS
CreateTable -> String
(Int -> CreateTable -> ShowS)
-> (CreateTable -> String)
-> ([CreateTable] -> ShowS)
-> Show CreateTable
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTable] -> ShowS
$cshowList :: [CreateTable] -> ShowS
show :: CreateTable -> String
$cshow :: CreateTable -> String
showsPrec :: Int -> CreateTable -> ShowS
$cshowsPrec :: Int -> CreateTable -> ShowS
Prelude.Show, (forall x. CreateTable -> Rep CreateTable x)
-> (forall x. Rep CreateTable x -> CreateTable)
-> Generic CreateTable
forall x. Rep CreateTable x -> CreateTable
forall x. CreateTable -> Rep CreateTable x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateTable x -> CreateTable
$cfrom :: forall x. CreateTable -> Rep CreateTable x
Prelude.Generic)

-- |
-- Create a value of 'CreateTable' 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:
--
-- 'provisionedThroughput', 'createTable_provisionedThroughput' - Represents the provisioned throughput settings for a specified table or
-- index. The settings can be modified using the @UpdateTable@ operation.
--
-- If you set BillingMode as @PROVISIONED@, you must specify this property.
-- If you set BillingMode as @PAY_PER_REQUEST@, you cannot specify this
-- property.
--
-- For current minimum and maximum provisioned throughput values, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html Service, Account, and Table Quotas>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- 'sSESpecification', 'createTable_sSESpecification' - Represents the settings used to enable server-side encryption.
--
-- 'globalSecondaryIndexes', 'createTable_globalSecondaryIndexes' - One or more global secondary indexes (the maximum is 20) to be created
-- on the table. Each global secondary index in the array includes the
-- following:
--
-- -   @IndexName@ - The name of the global secondary index. Must be unique
--     only for this table.
--
-- -   @KeySchema@ - Specifies the key schema for the global secondary
--     index.
--
-- -   @Projection@ - Specifies attributes that are copied (projected) from
--     the table into the index. These are in addition to the primary key
--     attributes and index key attributes, which are automatically
--     projected. Each attribute specification is composed of:
--
--     -   @ProjectionType@ - One of the following:
--
--         -   @KEYS_ONLY@ - Only the index and primary keys are projected
--             into the index.
--
--         -   @INCLUDE@ - Only the specified table attributes are
--             projected into the index. The list of projected attributes
--             is in @NonKeyAttributes@.
--
--         -   @ALL@ - All of the table attributes are projected into the
--             index.
--
--     -   @NonKeyAttributes@ - A list of one or more non-key attribute
--         names that are projected into the secondary index. The total
--         count of attributes provided in @NonKeyAttributes@, summed
--         across all of the secondary indexes, must not exceed 100. If you
--         project the same attribute into two different indexes, this
--         counts as two distinct attributes when determining the total.
--
-- -   @ProvisionedThroughput@ - The provisioned throughput settings for
--     the global secondary index, consisting of read and write capacity
--     units.
--
-- 'localSecondaryIndexes', 'createTable_localSecondaryIndexes' - One or more local secondary indexes (the maximum is 5) to be created on
-- the table. Each index is scoped to a given partition key value. There is
-- a 10 GB size limit per partition key value; otherwise, the size of a
-- local secondary index is unconstrained.
--
-- Each local secondary index in the array includes the following:
--
-- -   @IndexName@ - The name of the local secondary index. Must be unique
--     only for this table.
--
-- -   @KeySchema@ - Specifies the key schema for the local secondary
--     index. The key schema must begin with the same partition key as the
--     table.
--
-- -   @Projection@ - Specifies attributes that are copied (projected) from
--     the table into the index. These are in addition to the primary key
--     attributes and index key attributes, which are automatically
--     projected. Each attribute specification is composed of:
--
--     -   @ProjectionType@ - One of the following:
--
--         -   @KEYS_ONLY@ - Only the index and primary keys are projected
--             into the index.
--
--         -   @INCLUDE@ - Only the specified table attributes are
--             projected into the index. The list of projected attributes
--             is in @NonKeyAttributes@.
--
--         -   @ALL@ - All of the table attributes are projected into the
--             index.
--
--     -   @NonKeyAttributes@ - A list of one or more non-key attribute
--         names that are projected into the secondary index. The total
--         count of attributes provided in @NonKeyAttributes@, summed
--         across all of the secondary indexes, must not exceed 100. If you
--         project the same attribute into two different indexes, this
--         counts as two distinct attributes when determining the total.
--
-- 'billingMode', 'createTable_billingMode' - Controls how you are charged for read and write throughput and how you
-- manage capacity. This setting can be changed later.
--
-- -   @PROVISIONED@ - We recommend using @PROVISIONED@ for predictable
--     workloads. @PROVISIONED@ sets the billing mode to
--     <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html#HowItWorks.ProvisionedThroughput.Manual Provisioned Mode>.
--
-- -   @PAY_PER_REQUEST@ - We recommend using @PAY_PER_REQUEST@ for
--     unpredictable workloads. @PAY_PER_REQUEST@ sets the billing mode to
--     <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html#HowItWorks.OnDemand On-Demand Mode>.
--
-- 'tags', 'createTable_tags' - A list of key-value pairs to label the table. For more information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tagging.html Tagging for DynamoDB>.
--
-- 'streamSpecification', 'createTable_streamSpecification' - The settings for DynamoDB Streams on the table. These settings consist
-- of:
--
-- -   @StreamEnabled@ - Indicates whether DynamoDB Streams is to be
--     enabled (true) or disabled (false).
--
-- -   @StreamViewType@ - When an item in the table is modified,
--     @StreamViewType@ determines what information is written to the
--     table\'s stream. Valid values for @StreamViewType@ are:
--
--     -   @KEYS_ONLY@ - Only the key attributes of the modified item are
--         written to the stream.
--
--     -   @NEW_IMAGE@ - The entire item, as it appears after it was
--         modified, is written to the stream.
--
--     -   @OLD_IMAGE@ - The entire item, as it appeared before it was
--         modified, is written to the stream.
--
--     -   @NEW_AND_OLD_IMAGES@ - Both the new and the old item images of
--         the item are written to the stream.
--
-- 'attributeDefinitions', 'createTable_attributeDefinitions' - An array of attributes that describe the key schema for the table and
-- indexes.
--
-- 'tableName', 'createTable_tableName' - The name of the table to create.
--
-- 'keySchema', 'createTable_keySchema' - Specifies the attributes that make up the primary key for a table or an
-- index. The attributes in @KeySchema@ must also be defined in the
-- @AttributeDefinitions@ array. For more information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html Data Model>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- Each @KeySchemaElement@ in the array is composed of:
--
-- -   @AttributeName@ - The name of this key attribute.
--
-- -   @KeyType@ - The role that the key attribute will assume:
--
--     -   @HASH@ - partition key
--
--     -   @RANGE@ - sort key
--
-- The partition key of an item is also known as its /hash attribute/. The
-- term \"hash attribute\" derives from the DynamoDB usage of an internal
-- hash function to evenly distribute data items across partitions, based
-- on their partition key values.
--
-- The sort key of an item is also known as its /range attribute/. The term
-- \"range attribute\" derives from the way DynamoDB stores items with the
-- same partition key physically close together, in sorted order by the
-- sort key value.
--
-- For a simple primary key (partition key), you must provide exactly one
-- element with a @KeyType@ of @HASH@.
--
-- For a composite primary key (partition key and sort key), you must
-- provide exactly two elements, in this order: The first element must have
-- a @KeyType@ of @HASH@, and the second element must have a @KeyType@ of
-- @RANGE@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#WorkingWithTables.primary.key Working with Tables>
-- in the /Amazon DynamoDB Developer Guide/.
newCreateTable ::
  -- | 'tableName'
  Prelude.Text ->
  -- | 'keySchema'
  Prelude.NonEmpty KeySchemaElement ->
  CreateTable
newCreateTable :: Text -> NonEmpty KeySchemaElement -> CreateTable
newCreateTable Text
pTableName_ NonEmpty KeySchemaElement
pKeySchema_ =
  CreateTable' :: Maybe ProvisionedThroughput
-> Maybe SSESpecification
-> Maybe [GlobalSecondaryIndex]
-> Maybe [LocalSecondaryIndex]
-> Maybe BillingMode
-> Maybe [Tag]
-> Maybe StreamSpecification
-> [AttributeDefinition]
-> Text
-> NonEmpty KeySchemaElement
-> CreateTable
CreateTable'
    { $sel:provisionedThroughput:CreateTable' :: Maybe ProvisionedThroughput
provisionedThroughput =
        Maybe ProvisionedThroughput
forall a. Maybe a
Prelude.Nothing,
      $sel:sSESpecification:CreateTable' :: Maybe SSESpecification
sSESpecification = Maybe SSESpecification
forall a. Maybe a
Prelude.Nothing,
      $sel:globalSecondaryIndexes:CreateTable' :: Maybe [GlobalSecondaryIndex]
globalSecondaryIndexes = Maybe [GlobalSecondaryIndex]
forall a. Maybe a
Prelude.Nothing,
      $sel:localSecondaryIndexes:CreateTable' :: Maybe [LocalSecondaryIndex]
localSecondaryIndexes = Maybe [LocalSecondaryIndex]
forall a. Maybe a
Prelude.Nothing,
      $sel:billingMode:CreateTable' :: Maybe BillingMode
billingMode = Maybe BillingMode
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateTable' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:streamSpecification:CreateTable' :: Maybe StreamSpecification
streamSpecification = Maybe StreamSpecification
forall a. Maybe a
Prelude.Nothing,
      $sel:attributeDefinitions:CreateTable' :: [AttributeDefinition]
attributeDefinitions = [AttributeDefinition]
forall a. Monoid a => a
Prelude.mempty,
      $sel:tableName:CreateTable' :: Text
tableName = Text
pTableName_,
      $sel:keySchema:CreateTable' :: NonEmpty KeySchemaElement
keySchema = Tagged
  (NonEmpty KeySchemaElement) (Identity (NonEmpty KeySchemaElement))
-> Tagged
     (NonEmpty KeySchemaElement) (Identity (NonEmpty KeySchemaElement))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty KeySchemaElement) (Identity (NonEmpty KeySchemaElement))
 -> Tagged
      (NonEmpty KeySchemaElement) (Identity (NonEmpty KeySchemaElement)))
-> NonEmpty KeySchemaElement -> NonEmpty KeySchemaElement
forall t b. AReview t b -> b -> t
Lens.# NonEmpty KeySchemaElement
pKeySchema_
    }

-- | Represents the provisioned throughput settings for a specified table or
-- index. The settings can be modified using the @UpdateTable@ operation.
--
-- If you set BillingMode as @PROVISIONED@, you must specify this property.
-- If you set BillingMode as @PAY_PER_REQUEST@, you cannot specify this
-- property.
--
-- For current minimum and maximum provisioned throughput values, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html Service, Account, and Table Quotas>
-- in the /Amazon DynamoDB Developer Guide/.
createTable_provisionedThroughput :: Lens.Lens' CreateTable (Prelude.Maybe ProvisionedThroughput)
createTable_provisionedThroughput :: (Maybe ProvisionedThroughput -> f (Maybe ProvisionedThroughput))
-> CreateTable -> f CreateTable
createTable_provisionedThroughput = (CreateTable -> Maybe ProvisionedThroughput)
-> (CreateTable -> Maybe ProvisionedThroughput -> CreateTable)
-> Lens
     CreateTable
     CreateTable
     (Maybe ProvisionedThroughput)
     (Maybe ProvisionedThroughput)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {Maybe ProvisionedThroughput
provisionedThroughput :: Maybe ProvisionedThroughput
$sel:provisionedThroughput:CreateTable' :: CreateTable -> Maybe ProvisionedThroughput
provisionedThroughput} -> Maybe ProvisionedThroughput
provisionedThroughput) (\s :: CreateTable
s@CreateTable' {} Maybe ProvisionedThroughput
a -> CreateTable
s {$sel:provisionedThroughput:CreateTable' :: Maybe ProvisionedThroughput
provisionedThroughput = Maybe ProvisionedThroughput
a} :: CreateTable)

-- | Represents the settings used to enable server-side encryption.
createTable_sSESpecification :: Lens.Lens' CreateTable (Prelude.Maybe SSESpecification)
createTable_sSESpecification :: (Maybe SSESpecification -> f (Maybe SSESpecification))
-> CreateTable -> f CreateTable
createTable_sSESpecification = (CreateTable -> Maybe SSESpecification)
-> (CreateTable -> Maybe SSESpecification -> CreateTable)
-> Lens
     CreateTable
     CreateTable
     (Maybe SSESpecification)
     (Maybe SSESpecification)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {Maybe SSESpecification
sSESpecification :: Maybe SSESpecification
$sel:sSESpecification:CreateTable' :: CreateTable -> Maybe SSESpecification
sSESpecification} -> Maybe SSESpecification
sSESpecification) (\s :: CreateTable
s@CreateTable' {} Maybe SSESpecification
a -> CreateTable
s {$sel:sSESpecification:CreateTable' :: Maybe SSESpecification
sSESpecification = Maybe SSESpecification
a} :: CreateTable)

-- | One or more global secondary indexes (the maximum is 20) to be created
-- on the table. Each global secondary index in the array includes the
-- following:
--
-- -   @IndexName@ - The name of the global secondary index. Must be unique
--     only for this table.
--
-- -   @KeySchema@ - Specifies the key schema for the global secondary
--     index.
--
-- -   @Projection@ - Specifies attributes that are copied (projected) from
--     the table into the index. These are in addition to the primary key
--     attributes and index key attributes, which are automatically
--     projected. Each attribute specification is composed of:
--
--     -   @ProjectionType@ - One of the following:
--
--         -   @KEYS_ONLY@ - Only the index and primary keys are projected
--             into the index.
--
--         -   @INCLUDE@ - Only the specified table attributes are
--             projected into the index. The list of projected attributes
--             is in @NonKeyAttributes@.
--
--         -   @ALL@ - All of the table attributes are projected into the
--             index.
--
--     -   @NonKeyAttributes@ - A list of one or more non-key attribute
--         names that are projected into the secondary index. The total
--         count of attributes provided in @NonKeyAttributes@, summed
--         across all of the secondary indexes, must not exceed 100. If you
--         project the same attribute into two different indexes, this
--         counts as two distinct attributes when determining the total.
--
-- -   @ProvisionedThroughput@ - The provisioned throughput settings for
--     the global secondary index, consisting of read and write capacity
--     units.
createTable_globalSecondaryIndexes :: Lens.Lens' CreateTable (Prelude.Maybe [GlobalSecondaryIndex])
createTable_globalSecondaryIndexes :: (Maybe [GlobalSecondaryIndex] -> f (Maybe [GlobalSecondaryIndex]))
-> CreateTable -> f CreateTable
createTable_globalSecondaryIndexes = (CreateTable -> Maybe [GlobalSecondaryIndex])
-> (CreateTable -> Maybe [GlobalSecondaryIndex] -> CreateTable)
-> Lens
     CreateTable
     CreateTable
     (Maybe [GlobalSecondaryIndex])
     (Maybe [GlobalSecondaryIndex])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {Maybe [GlobalSecondaryIndex]
globalSecondaryIndexes :: Maybe [GlobalSecondaryIndex]
$sel:globalSecondaryIndexes:CreateTable' :: CreateTable -> Maybe [GlobalSecondaryIndex]
globalSecondaryIndexes} -> Maybe [GlobalSecondaryIndex]
globalSecondaryIndexes) (\s :: CreateTable
s@CreateTable' {} Maybe [GlobalSecondaryIndex]
a -> CreateTable
s {$sel:globalSecondaryIndexes:CreateTable' :: Maybe [GlobalSecondaryIndex]
globalSecondaryIndexes = Maybe [GlobalSecondaryIndex]
a} :: CreateTable) ((Maybe [GlobalSecondaryIndex] -> f (Maybe [GlobalSecondaryIndex]))
 -> CreateTable -> f CreateTable)
-> ((Maybe [GlobalSecondaryIndex]
     -> f (Maybe [GlobalSecondaryIndex]))
    -> Maybe [GlobalSecondaryIndex]
    -> f (Maybe [GlobalSecondaryIndex]))
-> (Maybe [GlobalSecondaryIndex]
    -> f (Maybe [GlobalSecondaryIndex]))
-> CreateTable
-> f CreateTable
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [GlobalSecondaryIndex]
  [GlobalSecondaryIndex]
  [GlobalSecondaryIndex]
  [GlobalSecondaryIndex]
-> Iso
     (Maybe [GlobalSecondaryIndex])
     (Maybe [GlobalSecondaryIndex])
     (Maybe [GlobalSecondaryIndex])
     (Maybe [GlobalSecondaryIndex])
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
  [GlobalSecondaryIndex]
  [GlobalSecondaryIndex]
  [GlobalSecondaryIndex]
  [GlobalSecondaryIndex]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | One or more local secondary indexes (the maximum is 5) to be created on
-- the table. Each index is scoped to a given partition key value. There is
-- a 10 GB size limit per partition key value; otherwise, the size of a
-- local secondary index is unconstrained.
--
-- Each local secondary index in the array includes the following:
--
-- -   @IndexName@ - The name of the local secondary index. Must be unique
--     only for this table.
--
-- -   @KeySchema@ - Specifies the key schema for the local secondary
--     index. The key schema must begin with the same partition key as the
--     table.
--
-- -   @Projection@ - Specifies attributes that are copied (projected) from
--     the table into the index. These are in addition to the primary key
--     attributes and index key attributes, which are automatically
--     projected. Each attribute specification is composed of:
--
--     -   @ProjectionType@ - One of the following:
--
--         -   @KEYS_ONLY@ - Only the index and primary keys are projected
--             into the index.
--
--         -   @INCLUDE@ - Only the specified table attributes are
--             projected into the index. The list of projected attributes
--             is in @NonKeyAttributes@.
--
--         -   @ALL@ - All of the table attributes are projected into the
--             index.
--
--     -   @NonKeyAttributes@ - A list of one or more non-key attribute
--         names that are projected into the secondary index. The total
--         count of attributes provided in @NonKeyAttributes@, summed
--         across all of the secondary indexes, must not exceed 100. If you
--         project the same attribute into two different indexes, this
--         counts as two distinct attributes when determining the total.
createTable_localSecondaryIndexes :: Lens.Lens' CreateTable (Prelude.Maybe [LocalSecondaryIndex])
createTable_localSecondaryIndexes :: (Maybe [LocalSecondaryIndex] -> f (Maybe [LocalSecondaryIndex]))
-> CreateTable -> f CreateTable
createTable_localSecondaryIndexes = (CreateTable -> Maybe [LocalSecondaryIndex])
-> (CreateTable -> Maybe [LocalSecondaryIndex] -> CreateTable)
-> Lens
     CreateTable
     CreateTable
     (Maybe [LocalSecondaryIndex])
     (Maybe [LocalSecondaryIndex])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {Maybe [LocalSecondaryIndex]
localSecondaryIndexes :: Maybe [LocalSecondaryIndex]
$sel:localSecondaryIndexes:CreateTable' :: CreateTable -> Maybe [LocalSecondaryIndex]
localSecondaryIndexes} -> Maybe [LocalSecondaryIndex]
localSecondaryIndexes) (\s :: CreateTable
s@CreateTable' {} Maybe [LocalSecondaryIndex]
a -> CreateTable
s {$sel:localSecondaryIndexes:CreateTable' :: Maybe [LocalSecondaryIndex]
localSecondaryIndexes = Maybe [LocalSecondaryIndex]
a} :: CreateTable) ((Maybe [LocalSecondaryIndex] -> f (Maybe [LocalSecondaryIndex]))
 -> CreateTable -> f CreateTable)
-> ((Maybe [LocalSecondaryIndex]
     -> f (Maybe [LocalSecondaryIndex]))
    -> Maybe [LocalSecondaryIndex] -> f (Maybe [LocalSecondaryIndex]))
-> (Maybe [LocalSecondaryIndex] -> f (Maybe [LocalSecondaryIndex]))
-> CreateTable
-> f CreateTable
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [LocalSecondaryIndex]
  [LocalSecondaryIndex]
  [LocalSecondaryIndex]
  [LocalSecondaryIndex]
-> Iso
     (Maybe [LocalSecondaryIndex])
     (Maybe [LocalSecondaryIndex])
     (Maybe [LocalSecondaryIndex])
     (Maybe [LocalSecondaryIndex])
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
  [LocalSecondaryIndex]
  [LocalSecondaryIndex]
  [LocalSecondaryIndex]
  [LocalSecondaryIndex]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Controls how you are charged for read and write throughput and how you
-- manage capacity. This setting can be changed later.
--
-- -   @PROVISIONED@ - We recommend using @PROVISIONED@ for predictable
--     workloads. @PROVISIONED@ sets the billing mode to
--     <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html#HowItWorks.ProvisionedThroughput.Manual Provisioned Mode>.
--
-- -   @PAY_PER_REQUEST@ - We recommend using @PAY_PER_REQUEST@ for
--     unpredictable workloads. @PAY_PER_REQUEST@ sets the billing mode to
--     <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html#HowItWorks.OnDemand On-Demand Mode>.
createTable_billingMode :: Lens.Lens' CreateTable (Prelude.Maybe BillingMode)
createTable_billingMode :: (Maybe BillingMode -> f (Maybe BillingMode))
-> CreateTable -> f CreateTable
createTable_billingMode = (CreateTable -> Maybe BillingMode)
-> (CreateTable -> Maybe BillingMode -> CreateTable)
-> Lens
     CreateTable CreateTable (Maybe BillingMode) (Maybe BillingMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {Maybe BillingMode
billingMode :: Maybe BillingMode
$sel:billingMode:CreateTable' :: CreateTable -> Maybe BillingMode
billingMode} -> Maybe BillingMode
billingMode) (\s :: CreateTable
s@CreateTable' {} Maybe BillingMode
a -> CreateTable
s {$sel:billingMode:CreateTable' :: Maybe BillingMode
billingMode = Maybe BillingMode
a} :: CreateTable)

-- | A list of key-value pairs to label the table. For more information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tagging.html Tagging for DynamoDB>.
createTable_tags :: Lens.Lens' CreateTable (Prelude.Maybe [Tag])
createTable_tags :: (Maybe [Tag] -> f (Maybe [Tag])) -> CreateTable -> f CreateTable
createTable_tags = (CreateTable -> Maybe [Tag])
-> (CreateTable -> Maybe [Tag] -> CreateTable)
-> Lens CreateTable CreateTable (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateTable' :: CreateTable -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateTable
s@CreateTable' {} Maybe [Tag]
a -> CreateTable
s {$sel:tags:CreateTable' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateTable) ((Maybe [Tag] -> f (Maybe [Tag])) -> CreateTable -> f CreateTable)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateTable
-> f CreateTable
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The settings for DynamoDB Streams on the table. These settings consist
-- of:
--
-- -   @StreamEnabled@ - Indicates whether DynamoDB Streams is to be
--     enabled (true) or disabled (false).
--
-- -   @StreamViewType@ - When an item in the table is modified,
--     @StreamViewType@ determines what information is written to the
--     table\'s stream. Valid values for @StreamViewType@ are:
--
--     -   @KEYS_ONLY@ - Only the key attributes of the modified item are
--         written to the stream.
--
--     -   @NEW_IMAGE@ - The entire item, as it appears after it was
--         modified, is written to the stream.
--
--     -   @OLD_IMAGE@ - The entire item, as it appeared before it was
--         modified, is written to the stream.
--
--     -   @NEW_AND_OLD_IMAGES@ - Both the new and the old item images of
--         the item are written to the stream.
createTable_streamSpecification :: Lens.Lens' CreateTable (Prelude.Maybe StreamSpecification)
createTable_streamSpecification :: (Maybe StreamSpecification -> f (Maybe StreamSpecification))
-> CreateTable -> f CreateTable
createTable_streamSpecification = (CreateTable -> Maybe StreamSpecification)
-> (CreateTable -> Maybe StreamSpecification -> CreateTable)
-> Lens
     CreateTable
     CreateTable
     (Maybe StreamSpecification)
     (Maybe StreamSpecification)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {Maybe StreamSpecification
streamSpecification :: Maybe StreamSpecification
$sel:streamSpecification:CreateTable' :: CreateTable -> Maybe StreamSpecification
streamSpecification} -> Maybe StreamSpecification
streamSpecification) (\s :: CreateTable
s@CreateTable' {} Maybe StreamSpecification
a -> CreateTable
s {$sel:streamSpecification:CreateTable' :: Maybe StreamSpecification
streamSpecification = Maybe StreamSpecification
a} :: CreateTable)

-- | An array of attributes that describe the key schema for the table and
-- indexes.
createTable_attributeDefinitions :: Lens.Lens' CreateTable [AttributeDefinition]
createTable_attributeDefinitions :: ([AttributeDefinition] -> f [AttributeDefinition])
-> CreateTable -> f CreateTable
createTable_attributeDefinitions = (CreateTable -> [AttributeDefinition])
-> (CreateTable -> [AttributeDefinition] -> CreateTable)
-> Lens
     CreateTable CreateTable [AttributeDefinition] [AttributeDefinition]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {[AttributeDefinition]
attributeDefinitions :: [AttributeDefinition]
$sel:attributeDefinitions:CreateTable' :: CreateTable -> [AttributeDefinition]
attributeDefinitions} -> [AttributeDefinition]
attributeDefinitions) (\s :: CreateTable
s@CreateTable' {} [AttributeDefinition]
a -> CreateTable
s {$sel:attributeDefinitions:CreateTable' :: [AttributeDefinition]
attributeDefinitions = [AttributeDefinition]
a} :: CreateTable) (([AttributeDefinition] -> f [AttributeDefinition])
 -> CreateTable -> f CreateTable)
-> (([AttributeDefinition] -> f [AttributeDefinition])
    -> [AttributeDefinition] -> f [AttributeDefinition])
-> ([AttributeDefinition] -> f [AttributeDefinition])
-> CreateTable
-> f CreateTable
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([AttributeDefinition] -> f [AttributeDefinition])
-> [AttributeDefinition] -> f [AttributeDefinition]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the table to create.
createTable_tableName :: Lens.Lens' CreateTable Prelude.Text
createTable_tableName :: (Text -> f Text) -> CreateTable -> f CreateTable
createTable_tableName = (CreateTable -> Text)
-> (CreateTable -> Text -> CreateTable)
-> Lens CreateTable CreateTable Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {Text
tableName :: Text
$sel:tableName:CreateTable' :: CreateTable -> Text
tableName} -> Text
tableName) (\s :: CreateTable
s@CreateTable' {} Text
a -> CreateTable
s {$sel:tableName:CreateTable' :: Text
tableName = Text
a} :: CreateTable)

-- | Specifies the attributes that make up the primary key for a table or an
-- index. The attributes in @KeySchema@ must also be defined in the
-- @AttributeDefinitions@ array. For more information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html Data Model>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- Each @KeySchemaElement@ in the array is composed of:
--
-- -   @AttributeName@ - The name of this key attribute.
--
-- -   @KeyType@ - The role that the key attribute will assume:
--
--     -   @HASH@ - partition key
--
--     -   @RANGE@ - sort key
--
-- The partition key of an item is also known as its /hash attribute/. The
-- term \"hash attribute\" derives from the DynamoDB usage of an internal
-- hash function to evenly distribute data items across partitions, based
-- on their partition key values.
--
-- The sort key of an item is also known as its /range attribute/. The term
-- \"range attribute\" derives from the way DynamoDB stores items with the
-- same partition key physically close together, in sorted order by the
-- sort key value.
--
-- For a simple primary key (partition key), you must provide exactly one
-- element with a @KeyType@ of @HASH@.
--
-- For a composite primary key (partition key and sort key), you must
-- provide exactly two elements, in this order: The first element must have
-- a @KeyType@ of @HASH@, and the second element must have a @KeyType@ of
-- @RANGE@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#WorkingWithTables.primary.key Working with Tables>
-- in the /Amazon DynamoDB Developer Guide/.
createTable_keySchema :: Lens.Lens' CreateTable (Prelude.NonEmpty KeySchemaElement)
createTable_keySchema :: (NonEmpty KeySchemaElement -> f (NonEmpty KeySchemaElement))
-> CreateTable -> f CreateTable
createTable_keySchema = (CreateTable -> NonEmpty KeySchemaElement)
-> (CreateTable -> NonEmpty KeySchemaElement -> CreateTable)
-> Lens
     CreateTable
     CreateTable
     (NonEmpty KeySchemaElement)
     (NonEmpty KeySchemaElement)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {NonEmpty KeySchemaElement
keySchema :: NonEmpty KeySchemaElement
$sel:keySchema:CreateTable' :: CreateTable -> NonEmpty KeySchemaElement
keySchema} -> NonEmpty KeySchemaElement
keySchema) (\s :: CreateTable
s@CreateTable' {} NonEmpty KeySchemaElement
a -> CreateTable
s {$sel:keySchema:CreateTable' :: NonEmpty KeySchemaElement
keySchema = NonEmpty KeySchemaElement
a} :: CreateTable) ((NonEmpty KeySchemaElement -> f (NonEmpty KeySchemaElement))
 -> CreateTable -> f CreateTable)
-> ((NonEmpty KeySchemaElement -> f (NonEmpty KeySchemaElement))
    -> NonEmpty KeySchemaElement -> f (NonEmpty KeySchemaElement))
-> (NonEmpty KeySchemaElement -> f (NonEmpty KeySchemaElement))
-> CreateTable
-> f CreateTable
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty KeySchemaElement -> f (NonEmpty KeySchemaElement))
-> NonEmpty KeySchemaElement -> f (NonEmpty KeySchemaElement)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest CreateTable where
  type AWSResponse CreateTable = CreateTableResponse
  request :: CreateTable -> Request CreateTable
request = Service -> CreateTable -> Request CreateTable
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateTable
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateTable)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateTable))
-> Logger
-> Service
-> Proxy CreateTable
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateTable)))
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 TableDescription -> Int -> CreateTableResponse
CreateTableResponse'
            (Maybe TableDescription -> Int -> CreateTableResponse)
-> Either String (Maybe TableDescription)
-> Either String (Int -> CreateTableResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe TableDescription)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"TableDescription")
            Either String (Int -> CreateTableResponse)
-> Either String Int -> Either String CreateTableResponse
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 CreateTable

instance Prelude.NFData CreateTable

instance Core.ToHeaders CreateTable where
  toHeaders :: CreateTable -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateTable -> 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
"DynamoDB_20120810.CreateTable" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON CreateTable where
  toJSON :: CreateTable -> Value
toJSON CreateTable' {[AttributeDefinition]
Maybe [LocalSecondaryIndex]
Maybe [GlobalSecondaryIndex]
Maybe [Tag]
Maybe BillingMode
Maybe ProvisionedThroughput
Maybe SSESpecification
Maybe StreamSpecification
NonEmpty KeySchemaElement
Text
keySchema :: NonEmpty KeySchemaElement
tableName :: Text
attributeDefinitions :: [AttributeDefinition]
streamSpecification :: Maybe StreamSpecification
tags :: Maybe [Tag]
billingMode :: Maybe BillingMode
localSecondaryIndexes :: Maybe [LocalSecondaryIndex]
globalSecondaryIndexes :: Maybe [GlobalSecondaryIndex]
sSESpecification :: Maybe SSESpecification
provisionedThroughput :: Maybe ProvisionedThroughput
$sel:keySchema:CreateTable' :: CreateTable -> NonEmpty KeySchemaElement
$sel:tableName:CreateTable' :: CreateTable -> Text
$sel:attributeDefinitions:CreateTable' :: CreateTable -> [AttributeDefinition]
$sel:streamSpecification:CreateTable' :: CreateTable -> Maybe StreamSpecification
$sel:tags:CreateTable' :: CreateTable -> Maybe [Tag]
$sel:billingMode:CreateTable' :: CreateTable -> Maybe BillingMode
$sel:localSecondaryIndexes:CreateTable' :: CreateTable -> Maybe [LocalSecondaryIndex]
$sel:globalSecondaryIndexes:CreateTable' :: CreateTable -> Maybe [GlobalSecondaryIndex]
$sel:sSESpecification:CreateTable' :: CreateTable -> Maybe SSESpecification
$sel:provisionedThroughput:CreateTable' :: CreateTable -> Maybe ProvisionedThroughput
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ProvisionedThroughput" Text -> ProvisionedThroughput -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ProvisionedThroughput -> Pair)
-> Maybe ProvisionedThroughput -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ProvisionedThroughput
provisionedThroughput,
            (Text
"SSESpecification" Text -> SSESpecification -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (SSESpecification -> Pair) -> Maybe SSESpecification -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SSESpecification
sSESpecification,
            (Text
"GlobalSecondaryIndexes" Text -> [GlobalSecondaryIndex] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([GlobalSecondaryIndex] -> Pair)
-> Maybe [GlobalSecondaryIndex] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [GlobalSecondaryIndex]
globalSecondaryIndexes,
            (Text
"LocalSecondaryIndexes" Text -> [LocalSecondaryIndex] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([LocalSecondaryIndex] -> Pair)
-> Maybe [LocalSecondaryIndex] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [LocalSecondaryIndex]
localSecondaryIndexes,
            (Text
"BillingMode" Text -> BillingMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (BillingMode -> Pair) -> Maybe BillingMode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe BillingMode
billingMode,
            (Text
"Tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            (Text
"StreamSpecification" Text -> StreamSpecification -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (StreamSpecification -> Pair)
-> Maybe StreamSpecification -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StreamSpecification
streamSpecification,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"AttributeDefinitions"
                  Text -> [AttributeDefinition] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [AttributeDefinition]
attributeDefinitions
              ),
            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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"KeySchema" Text -> NonEmpty KeySchemaElement -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty KeySchemaElement
keySchema)
          ]
      )

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

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

-- | Represents the output of a @CreateTable@ operation.
--
-- /See:/ 'newCreateTableResponse' smart constructor.
data CreateTableResponse = CreateTableResponse'
  { -- | Represents the properties of the table.
    CreateTableResponse -> Maybe TableDescription
tableDescription :: Prelude.Maybe TableDescription,
    -- | The response's http status code.
    CreateTableResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateTableResponse -> CreateTableResponse -> Bool
(CreateTableResponse -> CreateTableResponse -> Bool)
-> (CreateTableResponse -> CreateTableResponse -> Bool)
-> Eq CreateTableResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTableResponse -> CreateTableResponse -> Bool
$c/= :: CreateTableResponse -> CreateTableResponse -> Bool
== :: CreateTableResponse -> CreateTableResponse -> Bool
$c== :: CreateTableResponse -> CreateTableResponse -> Bool
Prelude.Eq, ReadPrec [CreateTableResponse]
ReadPrec CreateTableResponse
Int -> ReadS CreateTableResponse
ReadS [CreateTableResponse]
(Int -> ReadS CreateTableResponse)
-> ReadS [CreateTableResponse]
-> ReadPrec CreateTableResponse
-> ReadPrec [CreateTableResponse]
-> Read CreateTableResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTableResponse]
$creadListPrec :: ReadPrec [CreateTableResponse]
readPrec :: ReadPrec CreateTableResponse
$creadPrec :: ReadPrec CreateTableResponse
readList :: ReadS [CreateTableResponse]
$creadList :: ReadS [CreateTableResponse]
readsPrec :: Int -> ReadS CreateTableResponse
$creadsPrec :: Int -> ReadS CreateTableResponse
Prelude.Read, Int -> CreateTableResponse -> ShowS
[CreateTableResponse] -> ShowS
CreateTableResponse -> String
(Int -> CreateTableResponse -> ShowS)
-> (CreateTableResponse -> String)
-> ([CreateTableResponse] -> ShowS)
-> Show CreateTableResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTableResponse] -> ShowS
$cshowList :: [CreateTableResponse] -> ShowS
show :: CreateTableResponse -> String
$cshow :: CreateTableResponse -> String
showsPrec :: Int -> CreateTableResponse -> ShowS
$cshowsPrec :: Int -> CreateTableResponse -> ShowS
Prelude.Show, (forall x. CreateTableResponse -> Rep CreateTableResponse x)
-> (forall x. Rep CreateTableResponse x -> CreateTableResponse)
-> Generic CreateTableResponse
forall x. Rep CreateTableResponse x -> CreateTableResponse
forall x. CreateTableResponse -> Rep CreateTableResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateTableResponse x -> CreateTableResponse
$cfrom :: forall x. CreateTableResponse -> Rep CreateTableResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateTableResponse' 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:
--
-- 'tableDescription', 'createTableResponse_tableDescription' - Represents the properties of the table.
--
-- 'httpStatus', 'createTableResponse_httpStatus' - The response's http status code.
newCreateTableResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateTableResponse
newCreateTableResponse :: Int -> CreateTableResponse
newCreateTableResponse Int
pHttpStatus_ =
  CreateTableResponse' :: Maybe TableDescription -> Int -> CreateTableResponse
CreateTableResponse'
    { $sel:tableDescription:CreateTableResponse' :: Maybe TableDescription
tableDescription =
        Maybe TableDescription
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateTableResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Represents the properties of the table.
createTableResponse_tableDescription :: Lens.Lens' CreateTableResponse (Prelude.Maybe TableDescription)
createTableResponse_tableDescription :: (Maybe TableDescription -> f (Maybe TableDescription))
-> CreateTableResponse -> f CreateTableResponse
createTableResponse_tableDescription = (CreateTableResponse -> Maybe TableDescription)
-> (CreateTableResponse
    -> Maybe TableDescription -> CreateTableResponse)
-> Lens
     CreateTableResponse
     CreateTableResponse
     (Maybe TableDescription)
     (Maybe TableDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTableResponse' {Maybe TableDescription
tableDescription :: Maybe TableDescription
$sel:tableDescription:CreateTableResponse' :: CreateTableResponse -> Maybe TableDescription
tableDescription} -> Maybe TableDescription
tableDescription) (\s :: CreateTableResponse
s@CreateTableResponse' {} Maybe TableDescription
a -> CreateTableResponse
s {$sel:tableDescription:CreateTableResponse' :: Maybe TableDescription
tableDescription = Maybe TableDescription
a} :: CreateTableResponse)

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

instance Prelude.NFData CreateTableResponse