{-# 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.UpdateTable
-- 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)
--
-- Modifies the provisioned throughput settings, global secondary indexes,
-- or DynamoDB Streams settings for a given table.
--
-- You can only perform one of the following operations at once:
--
-- -   Modify the provisioned throughput settings of the table.
--
-- -   Enable or disable DynamoDB Streams on the table.
--
-- -   Remove a global secondary index from the table.
--
-- -   Create a new global secondary index on the table. After the index
--     begins backfilling, you can use @UpdateTable@ to perform other
--     operations.
--
-- @UpdateTable@ is an asynchronous operation; while it is executing, the
-- table status changes from @ACTIVE@ to @UPDATING@. While it is
-- @UPDATING@, you cannot issue another @UpdateTable@ request. When the
-- table returns to the @ACTIVE@ state, the @UpdateTable@ operation is
-- complete.
module Amazonka.DynamoDB.UpdateTable
  ( -- * Creating a Request
    UpdateTable (..),
    newUpdateTable,

    -- * Request Lenses
    updateTable_attributeDefinitions,
    updateTable_provisionedThroughput,
    updateTable_sSESpecification,
    updateTable_replicaUpdates,
    updateTable_globalSecondaryIndexUpdates,
    updateTable_billingMode,
    updateTable_streamSpecification,
    updateTable_tableName,

    -- * Destructuring the Response
    UpdateTableResponse (..),
    newUpdateTableResponse,

    -- * Response Lenses
    updateTableResponse_tableDescription,
    updateTableResponse_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 an @UpdateTable@ operation.
--
-- /See:/ 'newUpdateTable' smart constructor.
data UpdateTable = UpdateTable'
  { -- | An array of attributes that describe the key schema for the table and
    -- indexes. If you are adding a new global secondary index to the table,
    -- @AttributeDefinitions@ must include the key element(s) of the new index.
    UpdateTable -> Maybe [AttributeDefinition]
attributeDefinitions :: Prelude.Maybe [AttributeDefinition],
    -- | The new provisioned throughput settings for the specified table or
    -- index.
    UpdateTable -> Maybe ProvisionedThroughput
provisionedThroughput :: Prelude.Maybe ProvisionedThroughput,
    -- | The new server-side encryption settings for the specified table.
    UpdateTable -> Maybe SSESpecification
sSESpecification :: Prelude.Maybe SSESpecification,
    -- | A list of replica update actions (create, delete, or update) for the
    -- table.
    --
    -- This property only applies to
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables.V2.html Version 2019.11.21>
    -- of global tables.
    UpdateTable -> Maybe (NonEmpty ReplicationGroupUpdate)
replicaUpdates :: Prelude.Maybe (Prelude.NonEmpty ReplicationGroupUpdate),
    -- | An array of one or more global secondary indexes for the table. For each
    -- index in the array, you can request one action:
    --
    -- -   @Create@ - add a new global secondary index to the table.
    --
    -- -   @Update@ - modify the provisioned throughput settings of an existing
    --     global secondary index.
    --
    -- -   @Delete@ - remove a global secondary index from the table.
    --
    -- You can create or delete only one global secondary index per
    -- @UpdateTable@ operation.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.OnlineOps.html Managing Global Secondary Indexes>
    -- in the /Amazon DynamoDB Developer Guide/.
    UpdateTable -> Maybe [GlobalSecondaryIndexUpdate]
globalSecondaryIndexUpdates :: Prelude.Maybe [GlobalSecondaryIndexUpdate],
    -- | Controls how you are charged for read and write throughput and how you
    -- manage capacity. When switching from pay-per-request to provisioned
    -- capacity, initial provisioned capacity values must be set. The initial
    -- provisioned capacity values are estimated based on the consumed read and
    -- write capacity of your table and global secondary indexes over the past
    -- 30 minutes.
    --
    -- -   @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>.
    UpdateTable -> Maybe BillingMode
billingMode :: Prelude.Maybe BillingMode,
    -- | Represents the DynamoDB Streams configuration for the table.
    --
    -- You receive a @ResourceInUseException@ if you try to enable a stream on
    -- a table that already has a stream, or if you try to disable a stream on
    -- a table that doesn\'t have a stream.
    UpdateTable -> Maybe StreamSpecification
streamSpecification :: Prelude.Maybe StreamSpecification,
    -- | The name of the table to be updated.
    UpdateTable -> Text
tableName :: Prelude.Text
  }
  deriving (UpdateTable -> UpdateTable -> Bool
(UpdateTable -> UpdateTable -> Bool)
-> (UpdateTable -> UpdateTable -> Bool) -> Eq UpdateTable
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateTable -> UpdateTable -> Bool
$c/= :: UpdateTable -> UpdateTable -> Bool
== :: UpdateTable -> UpdateTable -> Bool
$c== :: UpdateTable -> UpdateTable -> Bool
Prelude.Eq, ReadPrec [UpdateTable]
ReadPrec UpdateTable
Int -> ReadS UpdateTable
ReadS [UpdateTable]
(Int -> ReadS UpdateTable)
-> ReadS [UpdateTable]
-> ReadPrec UpdateTable
-> ReadPrec [UpdateTable]
-> Read UpdateTable
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateTable]
$creadListPrec :: ReadPrec [UpdateTable]
readPrec :: ReadPrec UpdateTable
$creadPrec :: ReadPrec UpdateTable
readList :: ReadS [UpdateTable]
$creadList :: ReadS [UpdateTable]
readsPrec :: Int -> ReadS UpdateTable
$creadsPrec :: Int -> ReadS UpdateTable
Prelude.Read, Int -> UpdateTable -> ShowS
[UpdateTable] -> ShowS
UpdateTable -> String
(Int -> UpdateTable -> ShowS)
-> (UpdateTable -> String)
-> ([UpdateTable] -> ShowS)
-> Show UpdateTable
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateTable] -> ShowS
$cshowList :: [UpdateTable] -> ShowS
show :: UpdateTable -> String
$cshow :: UpdateTable -> String
showsPrec :: Int -> UpdateTable -> ShowS
$cshowsPrec :: Int -> UpdateTable -> ShowS
Prelude.Show, (forall x. UpdateTable -> Rep UpdateTable x)
-> (forall x. Rep UpdateTable x -> UpdateTable)
-> Generic UpdateTable
forall x. Rep UpdateTable x -> UpdateTable
forall x. UpdateTable -> Rep UpdateTable x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateTable x -> UpdateTable
$cfrom :: forall x. UpdateTable -> Rep UpdateTable x
Prelude.Generic)

-- |
-- Create a value of 'UpdateTable' 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:
--
-- 'attributeDefinitions', 'updateTable_attributeDefinitions' - An array of attributes that describe the key schema for the table and
-- indexes. If you are adding a new global secondary index to the table,
-- @AttributeDefinitions@ must include the key element(s) of the new index.
--
-- 'provisionedThroughput', 'updateTable_provisionedThroughput' - The new provisioned throughput settings for the specified table or
-- index.
--
-- 'sSESpecification', 'updateTable_sSESpecification' - The new server-side encryption settings for the specified table.
--
-- 'replicaUpdates', 'updateTable_replicaUpdates' - A list of replica update actions (create, delete, or update) for the
-- table.
--
-- This property only applies to
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables.V2.html Version 2019.11.21>
-- of global tables.
--
-- 'globalSecondaryIndexUpdates', 'updateTable_globalSecondaryIndexUpdates' - An array of one or more global secondary indexes for the table. For each
-- index in the array, you can request one action:
--
-- -   @Create@ - add a new global secondary index to the table.
--
-- -   @Update@ - modify the provisioned throughput settings of an existing
--     global secondary index.
--
-- -   @Delete@ - remove a global secondary index from the table.
--
-- You can create or delete only one global secondary index per
-- @UpdateTable@ operation.
--
-- For more information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.OnlineOps.html Managing Global Secondary Indexes>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- 'billingMode', 'updateTable_billingMode' - Controls how you are charged for read and write throughput and how you
-- manage capacity. When switching from pay-per-request to provisioned
-- capacity, initial provisioned capacity values must be set. The initial
-- provisioned capacity values are estimated based on the consumed read and
-- write capacity of your table and global secondary indexes over the past
-- 30 minutes.
--
-- -   @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>.
--
-- 'streamSpecification', 'updateTable_streamSpecification' - Represents the DynamoDB Streams configuration for the table.
--
-- You receive a @ResourceInUseException@ if you try to enable a stream on
-- a table that already has a stream, or if you try to disable a stream on
-- a table that doesn\'t have a stream.
--
-- 'tableName', 'updateTable_tableName' - The name of the table to be updated.
newUpdateTable ::
  -- | 'tableName'
  Prelude.Text ->
  UpdateTable
newUpdateTable :: Text -> UpdateTable
newUpdateTable Text
pTableName_ =
  UpdateTable' :: Maybe [AttributeDefinition]
-> Maybe ProvisionedThroughput
-> Maybe SSESpecification
-> Maybe (NonEmpty ReplicationGroupUpdate)
-> Maybe [GlobalSecondaryIndexUpdate]
-> Maybe BillingMode
-> Maybe StreamSpecification
-> Text
-> UpdateTable
UpdateTable'
    { $sel:attributeDefinitions:UpdateTable' :: Maybe [AttributeDefinition]
attributeDefinitions =
        Maybe [AttributeDefinition]
forall a. Maybe a
Prelude.Nothing,
      $sel:provisionedThroughput:UpdateTable' :: Maybe ProvisionedThroughput
provisionedThroughput = Maybe ProvisionedThroughput
forall a. Maybe a
Prelude.Nothing,
      $sel:sSESpecification:UpdateTable' :: Maybe SSESpecification
sSESpecification = Maybe SSESpecification
forall a. Maybe a
Prelude.Nothing,
      $sel:replicaUpdates:UpdateTable' :: Maybe (NonEmpty ReplicationGroupUpdate)
replicaUpdates = Maybe (NonEmpty ReplicationGroupUpdate)
forall a. Maybe a
Prelude.Nothing,
      $sel:globalSecondaryIndexUpdates:UpdateTable' :: Maybe [GlobalSecondaryIndexUpdate]
globalSecondaryIndexUpdates = Maybe [GlobalSecondaryIndexUpdate]
forall a. Maybe a
Prelude.Nothing,
      $sel:billingMode:UpdateTable' :: Maybe BillingMode
billingMode = Maybe BillingMode
forall a. Maybe a
Prelude.Nothing,
      $sel:streamSpecification:UpdateTable' :: Maybe StreamSpecification
streamSpecification = Maybe StreamSpecification
forall a. Maybe a
Prelude.Nothing,
      $sel:tableName:UpdateTable' :: Text
tableName = Text
pTableName_
    }

-- | An array of attributes that describe the key schema for the table and
-- indexes. If you are adding a new global secondary index to the table,
-- @AttributeDefinitions@ must include the key element(s) of the new index.
updateTable_attributeDefinitions :: Lens.Lens' UpdateTable (Prelude.Maybe [AttributeDefinition])
updateTable_attributeDefinitions :: (Maybe [AttributeDefinition] -> f (Maybe [AttributeDefinition]))
-> UpdateTable -> f UpdateTable
updateTable_attributeDefinitions = (UpdateTable -> Maybe [AttributeDefinition])
-> (UpdateTable -> Maybe [AttributeDefinition] -> UpdateTable)
-> Lens
     UpdateTable
     UpdateTable
     (Maybe [AttributeDefinition])
     (Maybe [AttributeDefinition])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTable' {Maybe [AttributeDefinition]
attributeDefinitions :: Maybe [AttributeDefinition]
$sel:attributeDefinitions:UpdateTable' :: UpdateTable -> Maybe [AttributeDefinition]
attributeDefinitions} -> Maybe [AttributeDefinition]
attributeDefinitions) (\s :: UpdateTable
s@UpdateTable' {} Maybe [AttributeDefinition]
a -> UpdateTable
s {$sel:attributeDefinitions:UpdateTable' :: Maybe [AttributeDefinition]
attributeDefinitions = Maybe [AttributeDefinition]
a} :: UpdateTable) ((Maybe [AttributeDefinition] -> f (Maybe [AttributeDefinition]))
 -> UpdateTable -> f UpdateTable)
-> ((Maybe [AttributeDefinition]
     -> f (Maybe [AttributeDefinition]))
    -> Maybe [AttributeDefinition] -> f (Maybe [AttributeDefinition]))
-> (Maybe [AttributeDefinition] -> f (Maybe [AttributeDefinition]))
-> UpdateTable
-> f UpdateTable
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AttributeDefinition]
  [AttributeDefinition]
  [AttributeDefinition]
  [AttributeDefinition]
-> Iso
     (Maybe [AttributeDefinition])
     (Maybe [AttributeDefinition])
     (Maybe [AttributeDefinition])
     (Maybe [AttributeDefinition])
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
  [AttributeDefinition]
  [AttributeDefinition]
  [AttributeDefinition]
  [AttributeDefinition]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The new provisioned throughput settings for the specified table or
-- index.
updateTable_provisionedThroughput :: Lens.Lens' UpdateTable (Prelude.Maybe ProvisionedThroughput)
updateTable_provisionedThroughput :: (Maybe ProvisionedThroughput -> f (Maybe ProvisionedThroughput))
-> UpdateTable -> f UpdateTable
updateTable_provisionedThroughput = (UpdateTable -> Maybe ProvisionedThroughput)
-> (UpdateTable -> Maybe ProvisionedThroughput -> UpdateTable)
-> Lens
     UpdateTable
     UpdateTable
     (Maybe ProvisionedThroughput)
     (Maybe ProvisionedThroughput)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTable' {Maybe ProvisionedThroughput
provisionedThroughput :: Maybe ProvisionedThroughput
$sel:provisionedThroughput:UpdateTable' :: UpdateTable -> Maybe ProvisionedThroughput
provisionedThroughput} -> Maybe ProvisionedThroughput
provisionedThroughput) (\s :: UpdateTable
s@UpdateTable' {} Maybe ProvisionedThroughput
a -> UpdateTable
s {$sel:provisionedThroughput:UpdateTable' :: Maybe ProvisionedThroughput
provisionedThroughput = Maybe ProvisionedThroughput
a} :: UpdateTable)

-- | The new server-side encryption settings for the specified table.
updateTable_sSESpecification :: Lens.Lens' UpdateTable (Prelude.Maybe SSESpecification)
updateTable_sSESpecification :: (Maybe SSESpecification -> f (Maybe SSESpecification))
-> UpdateTable -> f UpdateTable
updateTable_sSESpecification = (UpdateTable -> Maybe SSESpecification)
-> (UpdateTable -> Maybe SSESpecification -> UpdateTable)
-> Lens
     UpdateTable
     UpdateTable
     (Maybe SSESpecification)
     (Maybe SSESpecification)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTable' {Maybe SSESpecification
sSESpecification :: Maybe SSESpecification
$sel:sSESpecification:UpdateTable' :: UpdateTable -> Maybe SSESpecification
sSESpecification} -> Maybe SSESpecification
sSESpecification) (\s :: UpdateTable
s@UpdateTable' {} Maybe SSESpecification
a -> UpdateTable
s {$sel:sSESpecification:UpdateTable' :: Maybe SSESpecification
sSESpecification = Maybe SSESpecification
a} :: UpdateTable)

-- | A list of replica update actions (create, delete, or update) for the
-- table.
--
-- This property only applies to
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables.V2.html Version 2019.11.21>
-- of global tables.
updateTable_replicaUpdates :: Lens.Lens' UpdateTable (Prelude.Maybe (Prelude.NonEmpty ReplicationGroupUpdate))
updateTable_replicaUpdates :: (Maybe (NonEmpty ReplicationGroupUpdate)
 -> f (Maybe (NonEmpty ReplicationGroupUpdate)))
-> UpdateTable -> f UpdateTable
updateTable_replicaUpdates = (UpdateTable -> Maybe (NonEmpty ReplicationGroupUpdate))
-> (UpdateTable
    -> Maybe (NonEmpty ReplicationGroupUpdate) -> UpdateTable)
-> Lens
     UpdateTable
     UpdateTable
     (Maybe (NonEmpty ReplicationGroupUpdate))
     (Maybe (NonEmpty ReplicationGroupUpdate))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTable' {Maybe (NonEmpty ReplicationGroupUpdate)
replicaUpdates :: Maybe (NonEmpty ReplicationGroupUpdate)
$sel:replicaUpdates:UpdateTable' :: UpdateTable -> Maybe (NonEmpty ReplicationGroupUpdate)
replicaUpdates} -> Maybe (NonEmpty ReplicationGroupUpdate)
replicaUpdates) (\s :: UpdateTable
s@UpdateTable' {} Maybe (NonEmpty ReplicationGroupUpdate)
a -> UpdateTable
s {$sel:replicaUpdates:UpdateTable' :: Maybe (NonEmpty ReplicationGroupUpdate)
replicaUpdates = Maybe (NonEmpty ReplicationGroupUpdate)
a} :: UpdateTable) ((Maybe (NonEmpty ReplicationGroupUpdate)
  -> f (Maybe (NonEmpty ReplicationGroupUpdate)))
 -> UpdateTable -> f UpdateTable)
-> ((Maybe (NonEmpty ReplicationGroupUpdate)
     -> f (Maybe (NonEmpty ReplicationGroupUpdate)))
    -> Maybe (NonEmpty ReplicationGroupUpdate)
    -> f (Maybe (NonEmpty ReplicationGroupUpdate)))
-> (Maybe (NonEmpty ReplicationGroupUpdate)
    -> f (Maybe (NonEmpty ReplicationGroupUpdate)))
-> UpdateTable
-> f UpdateTable
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty ReplicationGroupUpdate)
  (NonEmpty ReplicationGroupUpdate)
  (NonEmpty ReplicationGroupUpdate)
  (NonEmpty ReplicationGroupUpdate)
-> Iso
     (Maybe (NonEmpty ReplicationGroupUpdate))
     (Maybe (NonEmpty ReplicationGroupUpdate))
     (Maybe (NonEmpty ReplicationGroupUpdate))
     (Maybe (NonEmpty ReplicationGroupUpdate))
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
  (NonEmpty ReplicationGroupUpdate)
  (NonEmpty ReplicationGroupUpdate)
  (NonEmpty ReplicationGroupUpdate)
  (NonEmpty ReplicationGroupUpdate)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array of one or more global secondary indexes for the table. For each
-- index in the array, you can request one action:
--
-- -   @Create@ - add a new global secondary index to the table.
--
-- -   @Update@ - modify the provisioned throughput settings of an existing
--     global secondary index.
--
-- -   @Delete@ - remove a global secondary index from the table.
--
-- You can create or delete only one global secondary index per
-- @UpdateTable@ operation.
--
-- For more information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.OnlineOps.html Managing Global Secondary Indexes>
-- in the /Amazon DynamoDB Developer Guide/.
updateTable_globalSecondaryIndexUpdates :: Lens.Lens' UpdateTable (Prelude.Maybe [GlobalSecondaryIndexUpdate])
updateTable_globalSecondaryIndexUpdates :: (Maybe [GlobalSecondaryIndexUpdate]
 -> f (Maybe [GlobalSecondaryIndexUpdate]))
-> UpdateTable -> f UpdateTable
updateTable_globalSecondaryIndexUpdates = (UpdateTable -> Maybe [GlobalSecondaryIndexUpdate])
-> (UpdateTable
    -> Maybe [GlobalSecondaryIndexUpdate] -> UpdateTable)
-> Lens
     UpdateTable
     UpdateTable
     (Maybe [GlobalSecondaryIndexUpdate])
     (Maybe [GlobalSecondaryIndexUpdate])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTable' {Maybe [GlobalSecondaryIndexUpdate]
globalSecondaryIndexUpdates :: Maybe [GlobalSecondaryIndexUpdate]
$sel:globalSecondaryIndexUpdates:UpdateTable' :: UpdateTable -> Maybe [GlobalSecondaryIndexUpdate]
globalSecondaryIndexUpdates} -> Maybe [GlobalSecondaryIndexUpdate]
globalSecondaryIndexUpdates) (\s :: UpdateTable
s@UpdateTable' {} Maybe [GlobalSecondaryIndexUpdate]
a -> UpdateTable
s {$sel:globalSecondaryIndexUpdates:UpdateTable' :: Maybe [GlobalSecondaryIndexUpdate]
globalSecondaryIndexUpdates = Maybe [GlobalSecondaryIndexUpdate]
a} :: UpdateTable) ((Maybe [GlobalSecondaryIndexUpdate]
  -> f (Maybe [GlobalSecondaryIndexUpdate]))
 -> UpdateTable -> f UpdateTable)
-> ((Maybe [GlobalSecondaryIndexUpdate]
     -> f (Maybe [GlobalSecondaryIndexUpdate]))
    -> Maybe [GlobalSecondaryIndexUpdate]
    -> f (Maybe [GlobalSecondaryIndexUpdate]))
-> (Maybe [GlobalSecondaryIndexUpdate]
    -> f (Maybe [GlobalSecondaryIndexUpdate]))
-> UpdateTable
-> f UpdateTable
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [GlobalSecondaryIndexUpdate]
  [GlobalSecondaryIndexUpdate]
  [GlobalSecondaryIndexUpdate]
  [GlobalSecondaryIndexUpdate]
-> Iso
     (Maybe [GlobalSecondaryIndexUpdate])
     (Maybe [GlobalSecondaryIndexUpdate])
     (Maybe [GlobalSecondaryIndexUpdate])
     (Maybe [GlobalSecondaryIndexUpdate])
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
  [GlobalSecondaryIndexUpdate]
  [GlobalSecondaryIndexUpdate]
  [GlobalSecondaryIndexUpdate]
  [GlobalSecondaryIndexUpdate]
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. When switching from pay-per-request to provisioned
-- capacity, initial provisioned capacity values must be set. The initial
-- provisioned capacity values are estimated based on the consumed read and
-- write capacity of your table and global secondary indexes over the past
-- 30 minutes.
--
-- -   @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>.
updateTable_billingMode :: Lens.Lens' UpdateTable (Prelude.Maybe BillingMode)
updateTable_billingMode :: (Maybe BillingMode -> f (Maybe BillingMode))
-> UpdateTable -> f UpdateTable
updateTable_billingMode = (UpdateTable -> Maybe BillingMode)
-> (UpdateTable -> Maybe BillingMode -> UpdateTable)
-> Lens
     UpdateTable UpdateTable (Maybe BillingMode) (Maybe BillingMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTable' {Maybe BillingMode
billingMode :: Maybe BillingMode
$sel:billingMode:UpdateTable' :: UpdateTable -> Maybe BillingMode
billingMode} -> Maybe BillingMode
billingMode) (\s :: UpdateTable
s@UpdateTable' {} Maybe BillingMode
a -> UpdateTable
s {$sel:billingMode:UpdateTable' :: Maybe BillingMode
billingMode = Maybe BillingMode
a} :: UpdateTable)

-- | Represents the DynamoDB Streams configuration for the table.
--
-- You receive a @ResourceInUseException@ if you try to enable a stream on
-- a table that already has a stream, or if you try to disable a stream on
-- a table that doesn\'t have a stream.
updateTable_streamSpecification :: Lens.Lens' UpdateTable (Prelude.Maybe StreamSpecification)
updateTable_streamSpecification :: (Maybe StreamSpecification -> f (Maybe StreamSpecification))
-> UpdateTable -> f UpdateTable
updateTable_streamSpecification = (UpdateTable -> Maybe StreamSpecification)
-> (UpdateTable -> Maybe StreamSpecification -> UpdateTable)
-> Lens
     UpdateTable
     UpdateTable
     (Maybe StreamSpecification)
     (Maybe StreamSpecification)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTable' {Maybe StreamSpecification
streamSpecification :: Maybe StreamSpecification
$sel:streamSpecification:UpdateTable' :: UpdateTable -> Maybe StreamSpecification
streamSpecification} -> Maybe StreamSpecification
streamSpecification) (\s :: UpdateTable
s@UpdateTable' {} Maybe StreamSpecification
a -> UpdateTable
s {$sel:streamSpecification:UpdateTable' :: Maybe StreamSpecification
streamSpecification = Maybe StreamSpecification
a} :: UpdateTable)

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

instance Core.AWSRequest UpdateTable where
  type AWSResponse UpdateTable = UpdateTableResponse
  request :: UpdateTable -> Request UpdateTable
request = Service -> UpdateTable -> Request UpdateTable
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateTable
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateTable)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateTable))
-> Logger
-> Service
-> Proxy UpdateTable
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateTable)))
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 -> UpdateTableResponse
UpdateTableResponse'
            (Maybe TableDescription -> Int -> UpdateTableResponse)
-> Either String (Maybe TableDescription)
-> Either String (Int -> UpdateTableResponse)
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 -> UpdateTableResponse)
-> Either String Int -> Either String UpdateTableResponse
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 UpdateTable

instance Prelude.NFData UpdateTable

instance Core.ToHeaders UpdateTable where
  toHeaders :: UpdateTable -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateTable -> 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.UpdateTable" ::
                          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 UpdateTable where
  toJSON :: UpdateTable -> Value
toJSON UpdateTable' {Maybe [AttributeDefinition]
Maybe [GlobalSecondaryIndexUpdate]
Maybe (NonEmpty ReplicationGroupUpdate)
Maybe BillingMode
Maybe ProvisionedThroughput
Maybe SSESpecification
Maybe StreamSpecification
Text
tableName :: Text
streamSpecification :: Maybe StreamSpecification
billingMode :: Maybe BillingMode
globalSecondaryIndexUpdates :: Maybe [GlobalSecondaryIndexUpdate]
replicaUpdates :: Maybe (NonEmpty ReplicationGroupUpdate)
sSESpecification :: Maybe SSESpecification
provisionedThroughput :: Maybe ProvisionedThroughput
attributeDefinitions :: Maybe [AttributeDefinition]
$sel:tableName:UpdateTable' :: UpdateTable -> Text
$sel:streamSpecification:UpdateTable' :: UpdateTable -> Maybe StreamSpecification
$sel:billingMode:UpdateTable' :: UpdateTable -> Maybe BillingMode
$sel:globalSecondaryIndexUpdates:UpdateTable' :: UpdateTable -> Maybe [GlobalSecondaryIndexUpdate]
$sel:replicaUpdates:UpdateTable' :: UpdateTable -> Maybe (NonEmpty ReplicationGroupUpdate)
$sel:sSESpecification:UpdateTable' :: UpdateTable -> Maybe SSESpecification
$sel:provisionedThroughput:UpdateTable' :: UpdateTable -> Maybe ProvisionedThroughput
$sel:attributeDefinitions:UpdateTable' :: UpdateTable -> Maybe [AttributeDefinition]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AttributeDefinitions" Text -> [AttributeDefinition] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([AttributeDefinition] -> Pair)
-> Maybe [AttributeDefinition] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AttributeDefinition]
attributeDefinitions,
            (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
"ReplicaUpdates" Text -> NonEmpty ReplicationGroupUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty ReplicationGroupUpdate -> Pair)
-> Maybe (NonEmpty ReplicationGroupUpdate) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty ReplicationGroupUpdate)
replicaUpdates,
            (Text
"GlobalSecondaryIndexUpdates" Text -> [GlobalSecondaryIndexUpdate] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([GlobalSecondaryIndexUpdate] -> Pair)
-> Maybe [GlobalSecondaryIndexUpdate] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [GlobalSecondaryIndexUpdate]
globalSecondaryIndexUpdates,
            (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
"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
"TableName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
tableName)
          ]
      )

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

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

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

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

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

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

instance Prelude.NFData UpdateTableResponse