{-# 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.KeySpaces.CreateTable
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- The @CreateTable@ operation adds a new table to the specified keyspace.
-- Within a keyspace, table names must be unique.
--
-- @CreateTable@ is an asynchronous operation. When the request is
-- received, the status of the table is set to @CREATING@. You can monitor
-- the creation status of the new table by using the @GetTable@ operation,
-- which returns the current @status@ of the table. You can start using a
-- table when the status is @ACTIVE@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/keyspaces/latest/devguide/working-with-tables.html#tables-create Creating tables>
-- in the /Amazon Keyspaces Developer Guide/.
module Amazonka.KeySpaces.CreateTable
  ( -- * Creating a Request
    CreateTable (..),
    newCreateTable,

    -- * Request Lenses
    createTable_capacitySpecification,
    createTable_comment,
    createTable_defaultTimeToLive,
    createTable_encryptionSpecification,
    createTable_pointInTimeRecovery,
    createTable_tags,
    createTable_ttl,
    createTable_keyspaceName,
    createTable_tableName,
    createTable_schemaDefinition,

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

    -- * Response Lenses
    createTableResponse_httpStatus,
    createTableResponse_resourceArn,
  )
where

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

-- | /See:/ 'newCreateTable' smart constructor.
data CreateTable = CreateTable'
  { -- | Specifies the read\/write throughput capacity mode for the table. The
    -- options are:
    --
    -- • @throughputMode:PAY_PER_REQUEST@ and
    --
    -- • @throughputMode:PROVISIONED@ - Provisioned capacity mode requires
    -- @readCapacityUnits@ and @writeCapacityUnits@ as input.
    --
    -- The default is @throughput_mode:PAY_PER_REQUEST@.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/keyspaces/latest/devguide/ReadWriteCapacityMode.html Read\/write capacity modes>
    -- in the /Amazon Keyspaces Developer Guide/.
    CreateTable -> Maybe CapacitySpecification
capacitySpecification :: Prelude.Maybe CapacitySpecification,
    -- | This parameter allows to enter a description of the table.
    CreateTable -> Maybe Comment
comment :: Prelude.Maybe Comment,
    -- | The default Time to Live setting in seconds for the table.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/keyspaces/latest/devguide/TTL-how-it-works.html#ttl-howitworks_default_ttl Setting the default TTL value for a table>
    -- in the /Amazon Keyspaces Developer Guide/.
    CreateTable -> Maybe Natural
defaultTimeToLive :: Prelude.Maybe Prelude.Natural,
    -- | Specifies how the encryption key for encryption at rest is managed for
    -- the table. You can choose one of the following KMS key (KMS key):
    --
    -- • @type:AWS_OWNED_KMS_KEY@ - This key is owned by Amazon Keyspaces.
    --
    -- • @type:CUSTOMER_MANAGED_KMS_KEY@ - This key is stored in your account
    -- and is created, owned, and managed by you. This option requires the
    -- @kms_key_identifier@ of the KMS key in Amazon Resource Name (ARN) format
    -- as input.
    --
    -- The default is @type:AWS_OWNED_KMS_KEY@.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/keyspaces/latest/devguide/EncryptionAtRest.html Encryption at rest>
    -- in the /Amazon Keyspaces Developer Guide/.
    CreateTable -> Maybe EncryptionSpecification
encryptionSpecification :: Prelude.Maybe EncryptionSpecification,
    -- | Specifies if @pointInTimeRecovery@ is enabled or disabled for the table.
    -- The options are:
    --
    -- • @ENABLED@
    --
    -- • @DISABLED@
    --
    -- If it\'s not specified, the default is @DISABLED@.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/keyspaces/latest/devguide/PointInTimeRecovery.html Point-in-time recovery>
    -- in the /Amazon Keyspaces Developer Guide/.
    CreateTable -> Maybe PointInTimeRecovery
pointInTimeRecovery :: Prelude.Maybe PointInTimeRecovery,
    -- | A list of key-value pair tags to be attached to the resource.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/keyspaces/latest/devguide/tagging-keyspaces.html Adding tags and labels to Amazon Keyspaces resources>
    -- in the /Amazon Keyspaces Developer Guide/.
    CreateTable -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag),
    -- | Enables Time to Live custom settings for the table. The options are:
    --
    -- • @status:enabled@
    --
    -- • @status:disabled@
    --
    -- The default is @status:disabled@. After @ttl@ is enabled, you can\'t
    -- disable it for the table.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/keyspaces/latest/devguide/TTL.html Expiring data by using Amazon Keyspaces Time to Live (TTL)>
    -- in the /Amazon Keyspaces Developer Guide/.
    CreateTable -> Maybe TimeToLive
ttl :: Prelude.Maybe TimeToLive,
    -- | The name of the keyspace that the table is going to be created in.
    CreateTable -> Text
keyspaceName :: Prelude.Text,
    -- | The name of the table.
    CreateTable -> Text
tableName :: Prelude.Text,
    -- | The @schemaDefinition@ consists of the following parameters.
    --
    -- For each column to be created:
    --
    -- • @name@ - The name of the column.
    --
    -- • @type@ - An Amazon Keyspaces data type. For more information, see
    -- <https://docs.aws.amazon.com/keyspaces/latest/devguide/cql.elements.html#cql.data-types Data types>
    -- in the /Amazon Keyspaces Developer Guide/.
    --
    -- The primary key of the table consists of the following columns:
    --
    -- • @partitionKeys@ - The partition key can be a single column, or it can
    -- be a compound value composed of two or more columns. The partition key
    -- portion of the primary key is required and determines how Amazon
    -- Keyspaces stores your data.
    --
    -- • @name@ - The name of each partition key column.
    --
    -- • @clusteringKeys@ - The optional clustering column portion of your
    -- primary key determines how the data is clustered and sorted within each
    -- partition.
    --
    -- • @name@ - The name of the clustering column.
    --
    -- • @orderBy@ - Sets the ascendant (@ASC@) or descendant (@DESC@) order
    -- modifier.
    --
    -- To define a column as static use @staticColumns@ - Static columns store
    -- values that are shared by all rows in the same partition:
    --
    -- • @name@ - The name of the column.
    --
    -- • @type@ - An Amazon Keyspaces data type.
    CreateTable -> SchemaDefinition
schemaDefinition :: SchemaDefinition
  }
  deriving (CreateTable -> CreateTable -> Bool
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]
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
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. 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:
--
-- 'capacitySpecification', 'createTable_capacitySpecification' - Specifies the read\/write throughput capacity mode for the table. The
-- options are:
--
-- • @throughputMode:PAY_PER_REQUEST@ and
--
-- • @throughputMode:PROVISIONED@ - Provisioned capacity mode requires
-- @readCapacityUnits@ and @writeCapacityUnits@ as input.
--
-- The default is @throughput_mode:PAY_PER_REQUEST@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/keyspaces/latest/devguide/ReadWriteCapacityMode.html Read\/write capacity modes>
-- in the /Amazon Keyspaces Developer Guide/.
--
-- 'comment', 'createTable_comment' - This parameter allows to enter a description of the table.
--
-- 'defaultTimeToLive', 'createTable_defaultTimeToLive' - The default Time to Live setting in seconds for the table.
--
-- For more information, see
-- <https://docs.aws.amazon.com/keyspaces/latest/devguide/TTL-how-it-works.html#ttl-howitworks_default_ttl Setting the default TTL value for a table>
-- in the /Amazon Keyspaces Developer Guide/.
--
-- 'encryptionSpecification', 'createTable_encryptionSpecification' - Specifies how the encryption key for encryption at rest is managed for
-- the table. You can choose one of the following KMS key (KMS key):
--
-- • @type:AWS_OWNED_KMS_KEY@ - This key is owned by Amazon Keyspaces.
--
-- • @type:CUSTOMER_MANAGED_KMS_KEY@ - This key is stored in your account
-- and is created, owned, and managed by you. This option requires the
-- @kms_key_identifier@ of the KMS key in Amazon Resource Name (ARN) format
-- as input.
--
-- The default is @type:AWS_OWNED_KMS_KEY@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/keyspaces/latest/devguide/EncryptionAtRest.html Encryption at rest>
-- in the /Amazon Keyspaces Developer Guide/.
--
-- 'pointInTimeRecovery', 'createTable_pointInTimeRecovery' - Specifies if @pointInTimeRecovery@ is enabled or disabled for the table.
-- The options are:
--
-- • @ENABLED@
--
-- • @DISABLED@
--
-- If it\'s not specified, the default is @DISABLED@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/keyspaces/latest/devguide/PointInTimeRecovery.html Point-in-time recovery>
-- in the /Amazon Keyspaces Developer Guide/.
--
-- 'tags', 'createTable_tags' - A list of key-value pair tags to be attached to the resource.
--
-- For more information, see
-- <https://docs.aws.amazon.com/keyspaces/latest/devguide/tagging-keyspaces.html Adding tags and labels to Amazon Keyspaces resources>
-- in the /Amazon Keyspaces Developer Guide/.
--
-- 'ttl', 'createTable_ttl' - Enables Time to Live custom settings for the table. The options are:
--
-- • @status:enabled@
--
-- • @status:disabled@
--
-- The default is @status:disabled@. After @ttl@ is enabled, you can\'t
-- disable it for the table.
--
-- For more information, see
-- <https://docs.aws.amazon.com/keyspaces/latest/devguide/TTL.html Expiring data by using Amazon Keyspaces Time to Live (TTL)>
-- in the /Amazon Keyspaces Developer Guide/.
--
-- 'keyspaceName', 'createTable_keyspaceName' - The name of the keyspace that the table is going to be created in.
--
-- 'tableName', 'createTable_tableName' - The name of the table.
--
-- 'schemaDefinition', 'createTable_schemaDefinition' - The @schemaDefinition@ consists of the following parameters.
--
-- For each column to be created:
--
-- • @name@ - The name of the column.
--
-- • @type@ - An Amazon Keyspaces data type. For more information, see
-- <https://docs.aws.amazon.com/keyspaces/latest/devguide/cql.elements.html#cql.data-types Data types>
-- in the /Amazon Keyspaces Developer Guide/.
--
-- The primary key of the table consists of the following columns:
--
-- • @partitionKeys@ - The partition key can be a single column, or it can
-- be a compound value composed of two or more columns. The partition key
-- portion of the primary key is required and determines how Amazon
-- Keyspaces stores your data.
--
-- • @name@ - The name of each partition key column.
--
-- • @clusteringKeys@ - The optional clustering column portion of your
-- primary key determines how the data is clustered and sorted within each
-- partition.
--
-- • @name@ - The name of the clustering column.
--
-- • @orderBy@ - Sets the ascendant (@ASC@) or descendant (@DESC@) order
-- modifier.
--
-- To define a column as static use @staticColumns@ - Static columns store
-- values that are shared by all rows in the same partition:
--
-- • @name@ - The name of the column.
--
-- • @type@ - An Amazon Keyspaces data type.
newCreateTable ::
  -- | 'keyspaceName'
  Prelude.Text ->
  -- | 'tableName'
  Prelude.Text ->
  -- | 'schemaDefinition'
  SchemaDefinition ->
  CreateTable
newCreateTable :: Text -> Text -> SchemaDefinition -> CreateTable
newCreateTable
  Text
pKeyspaceName_
  Text
pTableName_
  SchemaDefinition
pSchemaDefinition_ =
    CreateTable'
      { $sel:capacitySpecification:CreateTable' :: Maybe CapacitySpecification
capacitySpecification =
          forall a. Maybe a
Prelude.Nothing,
        $sel:comment:CreateTable' :: Maybe Comment
comment = forall a. Maybe a
Prelude.Nothing,
        $sel:defaultTimeToLive:CreateTable' :: Maybe Natural
defaultTimeToLive = forall a. Maybe a
Prelude.Nothing,
        $sel:encryptionSpecification:CreateTable' :: Maybe EncryptionSpecification
encryptionSpecification = forall a. Maybe a
Prelude.Nothing,
        $sel:pointInTimeRecovery:CreateTable' :: Maybe PointInTimeRecovery
pointInTimeRecovery = forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateTable' :: Maybe (NonEmpty Tag)
tags = forall a. Maybe a
Prelude.Nothing,
        $sel:ttl:CreateTable' :: Maybe TimeToLive
ttl = forall a. Maybe a
Prelude.Nothing,
        $sel:keyspaceName:CreateTable' :: Text
keyspaceName = Text
pKeyspaceName_,
        $sel:tableName:CreateTable' :: Text
tableName = Text
pTableName_,
        $sel:schemaDefinition:CreateTable' :: SchemaDefinition
schemaDefinition = SchemaDefinition
pSchemaDefinition_
      }

-- | Specifies the read\/write throughput capacity mode for the table. The
-- options are:
--
-- • @throughputMode:PAY_PER_REQUEST@ and
--
-- • @throughputMode:PROVISIONED@ - Provisioned capacity mode requires
-- @readCapacityUnits@ and @writeCapacityUnits@ as input.
--
-- The default is @throughput_mode:PAY_PER_REQUEST@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/keyspaces/latest/devguide/ReadWriteCapacityMode.html Read\/write capacity modes>
-- in the /Amazon Keyspaces Developer Guide/.
createTable_capacitySpecification :: Lens.Lens' CreateTable (Prelude.Maybe CapacitySpecification)
createTable_capacitySpecification :: Lens' CreateTable (Maybe CapacitySpecification)
createTable_capacitySpecification = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {Maybe CapacitySpecification
capacitySpecification :: Maybe CapacitySpecification
$sel:capacitySpecification:CreateTable' :: CreateTable -> Maybe CapacitySpecification
capacitySpecification} -> Maybe CapacitySpecification
capacitySpecification) (\s :: CreateTable
s@CreateTable' {} Maybe CapacitySpecification
a -> CreateTable
s {$sel:capacitySpecification:CreateTable' :: Maybe CapacitySpecification
capacitySpecification = Maybe CapacitySpecification
a} :: CreateTable)

-- | This parameter allows to enter a description of the table.
createTable_comment :: Lens.Lens' CreateTable (Prelude.Maybe Comment)
createTable_comment :: Lens' CreateTable (Maybe Comment)
createTable_comment = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {Maybe Comment
comment :: Maybe Comment
$sel:comment:CreateTable' :: CreateTable -> Maybe Comment
comment} -> Maybe Comment
comment) (\s :: CreateTable
s@CreateTable' {} Maybe Comment
a -> CreateTable
s {$sel:comment:CreateTable' :: Maybe Comment
comment = Maybe Comment
a} :: CreateTable)

-- | The default Time to Live setting in seconds for the table.
--
-- For more information, see
-- <https://docs.aws.amazon.com/keyspaces/latest/devguide/TTL-how-it-works.html#ttl-howitworks_default_ttl Setting the default TTL value for a table>
-- in the /Amazon Keyspaces Developer Guide/.
createTable_defaultTimeToLive :: Lens.Lens' CreateTable (Prelude.Maybe Prelude.Natural)
createTable_defaultTimeToLive :: Lens' CreateTable (Maybe Natural)
createTable_defaultTimeToLive = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {Maybe Natural
defaultTimeToLive :: Maybe Natural
$sel:defaultTimeToLive:CreateTable' :: CreateTable -> Maybe Natural
defaultTimeToLive} -> Maybe Natural
defaultTimeToLive) (\s :: CreateTable
s@CreateTable' {} Maybe Natural
a -> CreateTable
s {$sel:defaultTimeToLive:CreateTable' :: Maybe Natural
defaultTimeToLive = Maybe Natural
a} :: CreateTable)

-- | Specifies how the encryption key for encryption at rest is managed for
-- the table. You can choose one of the following KMS key (KMS key):
--
-- • @type:AWS_OWNED_KMS_KEY@ - This key is owned by Amazon Keyspaces.
--
-- • @type:CUSTOMER_MANAGED_KMS_KEY@ - This key is stored in your account
-- and is created, owned, and managed by you. This option requires the
-- @kms_key_identifier@ of the KMS key in Amazon Resource Name (ARN) format
-- as input.
--
-- The default is @type:AWS_OWNED_KMS_KEY@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/keyspaces/latest/devguide/EncryptionAtRest.html Encryption at rest>
-- in the /Amazon Keyspaces Developer Guide/.
createTable_encryptionSpecification :: Lens.Lens' CreateTable (Prelude.Maybe EncryptionSpecification)
createTable_encryptionSpecification :: Lens' CreateTable (Maybe EncryptionSpecification)
createTable_encryptionSpecification = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {Maybe EncryptionSpecification
encryptionSpecification :: Maybe EncryptionSpecification
$sel:encryptionSpecification:CreateTable' :: CreateTable -> Maybe EncryptionSpecification
encryptionSpecification} -> Maybe EncryptionSpecification
encryptionSpecification) (\s :: CreateTable
s@CreateTable' {} Maybe EncryptionSpecification
a -> CreateTable
s {$sel:encryptionSpecification:CreateTable' :: Maybe EncryptionSpecification
encryptionSpecification = Maybe EncryptionSpecification
a} :: CreateTable)

-- | Specifies if @pointInTimeRecovery@ is enabled or disabled for the table.
-- The options are:
--
-- • @ENABLED@
--
-- • @DISABLED@
--
-- If it\'s not specified, the default is @DISABLED@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/keyspaces/latest/devguide/PointInTimeRecovery.html Point-in-time recovery>
-- in the /Amazon Keyspaces Developer Guide/.
createTable_pointInTimeRecovery :: Lens.Lens' CreateTable (Prelude.Maybe PointInTimeRecovery)
createTable_pointInTimeRecovery :: Lens' CreateTable (Maybe PointInTimeRecovery)
createTable_pointInTimeRecovery = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {Maybe PointInTimeRecovery
pointInTimeRecovery :: Maybe PointInTimeRecovery
$sel:pointInTimeRecovery:CreateTable' :: CreateTable -> Maybe PointInTimeRecovery
pointInTimeRecovery} -> Maybe PointInTimeRecovery
pointInTimeRecovery) (\s :: CreateTable
s@CreateTable' {} Maybe PointInTimeRecovery
a -> CreateTable
s {$sel:pointInTimeRecovery:CreateTable' :: Maybe PointInTimeRecovery
pointInTimeRecovery = Maybe PointInTimeRecovery
a} :: CreateTable)

-- | A list of key-value pair tags to be attached to the resource.
--
-- For more information, see
-- <https://docs.aws.amazon.com/keyspaces/latest/devguide/tagging-keyspaces.html Adding tags and labels to Amazon Keyspaces resources>
-- in the /Amazon Keyspaces Developer Guide/.
createTable_tags :: Lens.Lens' CreateTable (Prelude.Maybe (Prelude.NonEmpty Tag))
createTable_tags :: Lens' CreateTable (Maybe (NonEmpty Tag))
createTable_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:CreateTable' :: CreateTable -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: CreateTable
s@CreateTable' {} Maybe (NonEmpty Tag)
a -> CreateTable
s {$sel:tags:CreateTable' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: CreateTable) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Enables Time to Live custom settings for the table. The options are:
--
-- • @status:enabled@
--
-- • @status:disabled@
--
-- The default is @status:disabled@. After @ttl@ is enabled, you can\'t
-- disable it for the table.
--
-- For more information, see
-- <https://docs.aws.amazon.com/keyspaces/latest/devguide/TTL.html Expiring data by using Amazon Keyspaces Time to Live (TTL)>
-- in the /Amazon Keyspaces Developer Guide/.
createTable_ttl :: Lens.Lens' CreateTable (Prelude.Maybe TimeToLive)
createTable_ttl :: Lens' CreateTable (Maybe TimeToLive)
createTable_ttl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {Maybe TimeToLive
ttl :: Maybe TimeToLive
$sel:ttl:CreateTable' :: CreateTable -> Maybe TimeToLive
ttl} -> Maybe TimeToLive
ttl) (\s :: CreateTable
s@CreateTable' {} Maybe TimeToLive
a -> CreateTable
s {$sel:ttl:CreateTable' :: Maybe TimeToLive
ttl = Maybe TimeToLive
a} :: CreateTable)

-- | The name of the keyspace that the table is going to be created in.
createTable_keyspaceName :: Lens.Lens' CreateTable Prelude.Text
createTable_keyspaceName :: Lens' CreateTable Text
createTable_keyspaceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {Text
keyspaceName :: Text
$sel:keyspaceName:CreateTable' :: CreateTable -> Text
keyspaceName} -> Text
keyspaceName) (\s :: CreateTable
s@CreateTable' {} Text
a -> CreateTable
s {$sel:keyspaceName:CreateTable' :: Text
keyspaceName = Text
a} :: CreateTable)

-- | The name of the table.
createTable_tableName :: Lens.Lens' CreateTable Prelude.Text
createTable_tableName :: Lens' CreateTable Text
createTable_tableName = 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)

-- | The @schemaDefinition@ consists of the following parameters.
--
-- For each column to be created:
--
-- • @name@ - The name of the column.
--
-- • @type@ - An Amazon Keyspaces data type. For more information, see
-- <https://docs.aws.amazon.com/keyspaces/latest/devguide/cql.elements.html#cql.data-types Data types>
-- in the /Amazon Keyspaces Developer Guide/.
--
-- The primary key of the table consists of the following columns:
--
-- • @partitionKeys@ - The partition key can be a single column, or it can
-- be a compound value composed of two or more columns. The partition key
-- portion of the primary key is required and determines how Amazon
-- Keyspaces stores your data.
--
-- • @name@ - The name of each partition key column.
--
-- • @clusteringKeys@ - The optional clustering column portion of your
-- primary key determines how the data is clustered and sorted within each
-- partition.
--
-- • @name@ - The name of the clustering column.
--
-- • @orderBy@ - Sets the ascendant (@ASC@) or descendant (@DESC@) order
-- modifier.
--
-- To define a column as static use @staticColumns@ - Static columns store
-- values that are shared by all rows in the same partition:
--
-- • @name@ - The name of the column.
--
-- • @type@ - An Amazon Keyspaces data type.
createTable_schemaDefinition :: Lens.Lens' CreateTable SchemaDefinition
createTable_schemaDefinition :: Lens' CreateTable SchemaDefinition
createTable_schemaDefinition = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {SchemaDefinition
schemaDefinition :: SchemaDefinition
$sel:schemaDefinition:CreateTable' :: CreateTable -> SchemaDefinition
schemaDefinition} -> SchemaDefinition
schemaDefinition) (\s :: CreateTable
s@CreateTable' {} SchemaDefinition
a -> CreateTable
s {$sel:schemaDefinition:CreateTable' :: SchemaDefinition
schemaDefinition = SchemaDefinition
a} :: CreateTable)

instance Core.AWSRequest CreateTable where
  type AWSResponse CreateTable = CreateTableResponse
  request :: (Service -> Service) -> CreateTable -> Request CreateTable
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateTable
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateTable)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> Text -> CreateTableResponse
CreateTableResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"resourceArn")
      )

instance Prelude.Hashable CreateTable where
  hashWithSalt :: Int -> CreateTable -> Int
hashWithSalt Int
_salt CreateTable' {Maybe Natural
Maybe (NonEmpty Tag)
Maybe Comment
Maybe EncryptionSpecification
Maybe PointInTimeRecovery
Maybe CapacitySpecification
Maybe TimeToLive
Text
SchemaDefinition
schemaDefinition :: SchemaDefinition
tableName :: Text
keyspaceName :: Text
ttl :: Maybe TimeToLive
tags :: Maybe (NonEmpty Tag)
pointInTimeRecovery :: Maybe PointInTimeRecovery
encryptionSpecification :: Maybe EncryptionSpecification
defaultTimeToLive :: Maybe Natural
comment :: Maybe Comment
capacitySpecification :: Maybe CapacitySpecification
$sel:schemaDefinition:CreateTable' :: CreateTable -> SchemaDefinition
$sel:tableName:CreateTable' :: CreateTable -> Text
$sel:keyspaceName:CreateTable' :: CreateTable -> Text
$sel:ttl:CreateTable' :: CreateTable -> Maybe TimeToLive
$sel:tags:CreateTable' :: CreateTable -> Maybe (NonEmpty Tag)
$sel:pointInTimeRecovery:CreateTable' :: CreateTable -> Maybe PointInTimeRecovery
$sel:encryptionSpecification:CreateTable' :: CreateTable -> Maybe EncryptionSpecification
$sel:defaultTimeToLive:CreateTable' :: CreateTable -> Maybe Natural
$sel:comment:CreateTable' :: CreateTable -> Maybe Comment
$sel:capacitySpecification:CreateTable' :: CreateTable -> Maybe CapacitySpecification
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CapacitySpecification
capacitySpecification
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Comment
comment
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
defaultTimeToLive
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EncryptionSpecification
encryptionSpecification
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PointInTimeRecovery
pointInTimeRecovery
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Tag)
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TimeToLive
ttl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
keyspaceName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tableName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SchemaDefinition
schemaDefinition

instance Prelude.NFData CreateTable where
  rnf :: CreateTable -> ()
rnf CreateTable' {Maybe Natural
Maybe (NonEmpty Tag)
Maybe Comment
Maybe EncryptionSpecification
Maybe PointInTimeRecovery
Maybe CapacitySpecification
Maybe TimeToLive
Text
SchemaDefinition
schemaDefinition :: SchemaDefinition
tableName :: Text
keyspaceName :: Text
ttl :: Maybe TimeToLive
tags :: Maybe (NonEmpty Tag)
pointInTimeRecovery :: Maybe PointInTimeRecovery
encryptionSpecification :: Maybe EncryptionSpecification
defaultTimeToLive :: Maybe Natural
comment :: Maybe Comment
capacitySpecification :: Maybe CapacitySpecification
$sel:schemaDefinition:CreateTable' :: CreateTable -> SchemaDefinition
$sel:tableName:CreateTable' :: CreateTable -> Text
$sel:keyspaceName:CreateTable' :: CreateTable -> Text
$sel:ttl:CreateTable' :: CreateTable -> Maybe TimeToLive
$sel:tags:CreateTable' :: CreateTable -> Maybe (NonEmpty Tag)
$sel:pointInTimeRecovery:CreateTable' :: CreateTable -> Maybe PointInTimeRecovery
$sel:encryptionSpecification:CreateTable' :: CreateTable -> Maybe EncryptionSpecification
$sel:defaultTimeToLive:CreateTable' :: CreateTable -> Maybe Natural
$sel:comment:CreateTable' :: CreateTable -> Maybe Comment
$sel:capacitySpecification:CreateTable' :: CreateTable -> Maybe CapacitySpecification
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CapacitySpecification
capacitySpecification
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Comment
comment
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
defaultTimeToLive
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EncryptionSpecification
encryptionSpecification
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PointInTimeRecovery
pointInTimeRecovery
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Tag)
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TimeToLive
ttl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
keyspaceName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
tableName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf SchemaDefinition
schemaDefinition

instance Data.ToHeaders CreateTable where
  toHeaders :: CreateTable -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"KeyspacesService.CreateTable" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON CreateTable where
  toJSON :: CreateTable -> Value
toJSON CreateTable' {Maybe Natural
Maybe (NonEmpty Tag)
Maybe Comment
Maybe EncryptionSpecification
Maybe PointInTimeRecovery
Maybe CapacitySpecification
Maybe TimeToLive
Text
SchemaDefinition
schemaDefinition :: SchemaDefinition
tableName :: Text
keyspaceName :: Text
ttl :: Maybe TimeToLive
tags :: Maybe (NonEmpty Tag)
pointInTimeRecovery :: Maybe PointInTimeRecovery
encryptionSpecification :: Maybe EncryptionSpecification
defaultTimeToLive :: Maybe Natural
comment :: Maybe Comment
capacitySpecification :: Maybe CapacitySpecification
$sel:schemaDefinition:CreateTable' :: CreateTable -> SchemaDefinition
$sel:tableName:CreateTable' :: CreateTable -> Text
$sel:keyspaceName:CreateTable' :: CreateTable -> Text
$sel:ttl:CreateTable' :: CreateTable -> Maybe TimeToLive
$sel:tags:CreateTable' :: CreateTable -> Maybe (NonEmpty Tag)
$sel:pointInTimeRecovery:CreateTable' :: CreateTable -> Maybe PointInTimeRecovery
$sel:encryptionSpecification:CreateTable' :: CreateTable -> Maybe EncryptionSpecification
$sel:defaultTimeToLive:CreateTable' :: CreateTable -> Maybe Natural
$sel:comment:CreateTable' :: CreateTable -> Maybe Comment
$sel:capacitySpecification:CreateTable' :: CreateTable -> Maybe CapacitySpecification
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"capacitySpecification" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CapacitySpecification
capacitySpecification,
            (Key
"comment" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Comment
comment,
            (Key
"defaultTimeToLive" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
defaultTimeToLive,
            (Key
"encryptionSpecification" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EncryptionSpecification
encryptionSpecification,
            (Key
"pointInTimeRecovery" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PointInTimeRecovery
pointInTimeRecovery,
            (Key
"tags" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Tag)
tags,
            (Key
"ttl" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TimeToLive
ttl,
            forall a. a -> Maybe a
Prelude.Just (Key
"keyspaceName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
keyspaceName),
            forall a. a -> Maybe a
Prelude.Just (Key
"tableName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
tableName),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"schemaDefinition" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= SchemaDefinition
schemaDefinition)
          ]
      )

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

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

-- | /See:/ 'newCreateTableResponse' smart constructor.
data CreateTableResponse = CreateTableResponse'
  { -- | The response's http status code.
    CreateTableResponse -> Int
httpStatus :: Prelude.Int,
    -- | The unique identifier of the table in the format of an Amazon Resource
    -- Name (ARN).
    CreateTableResponse -> Text
resourceArn :: Prelude.Text
  }
  deriving (CreateTableResponse -> CreateTableResponse -> Bool
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]
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
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. 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:
--
-- 'httpStatus', 'createTableResponse_httpStatus' - The response's http status code.
--
-- 'resourceArn', 'createTableResponse_resourceArn' - The unique identifier of the table in the format of an Amazon Resource
-- Name (ARN).
newCreateTableResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'resourceArn'
  Prelude.Text ->
  CreateTableResponse
newCreateTableResponse :: Int -> Text -> CreateTableResponse
newCreateTableResponse Int
pHttpStatus_ Text
pResourceArn_ =
  CreateTableResponse'
    { $sel:httpStatus:CreateTableResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:resourceArn:CreateTableResponse' :: Text
resourceArn = Text
pResourceArn_
    }

-- | The response's http status code.
createTableResponse_httpStatus :: Lens.Lens' CreateTableResponse Prelude.Int
createTableResponse_httpStatus :: Lens' CreateTableResponse Int
createTableResponse_httpStatus = 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)

-- | The unique identifier of the table in the format of an Amazon Resource
-- Name (ARN).
createTableResponse_resourceArn :: Lens.Lens' CreateTableResponse Prelude.Text
createTableResponse_resourceArn :: Lens' CreateTableResponse Text
createTableResponse_resourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTableResponse' {Text
resourceArn :: Text
$sel:resourceArn:CreateTableResponse' :: CreateTableResponse -> Text
resourceArn} -> Text
resourceArn) (\s :: CreateTableResponse
s@CreateTableResponse' {} Text
a -> CreateTableResponse
s {$sel:resourceArn:CreateTableResponse' :: Text
resourceArn = Text
a} :: CreateTableResponse)

instance Prelude.NFData CreateTableResponse where
  rnf :: CreateTableResponse -> ()
rnf CreateTableResponse' {Int
Text
resourceArn :: Text
httpStatus :: Int
$sel:resourceArn:CreateTableResponse' :: CreateTableResponse -> Text
$sel:httpStatus:CreateTableResponse' :: CreateTableResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceArn