{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.GlobalTableGlobalSecondaryIndexSettingsUpdate
-- 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)
module Amazonka.DynamoDB.Types.GlobalTableGlobalSecondaryIndexSettingsUpdate where

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.AutoScalingSettingsUpdate
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents the settings of a global secondary index for a global table
-- that will be modified.
--
-- /See:/ 'newGlobalTableGlobalSecondaryIndexSettingsUpdate' smart constructor.
data GlobalTableGlobalSecondaryIndexSettingsUpdate = GlobalTableGlobalSecondaryIndexSettingsUpdate'
  { -- | The maximum number of writes consumed per second before DynamoDB returns
    -- a @ThrottlingException.@
    GlobalTableGlobalSecondaryIndexSettingsUpdate -> Maybe Natural
provisionedWriteCapacityUnits :: Prelude.Maybe Prelude.Natural,
    -- | Auto scaling settings for managing a global secondary index\'s write
    -- capacity units.
    GlobalTableGlobalSecondaryIndexSettingsUpdate
-> Maybe AutoScalingSettingsUpdate
provisionedWriteCapacityAutoScalingSettingsUpdate :: Prelude.Maybe AutoScalingSettingsUpdate,
    -- | The name of the global secondary index. The name must be unique among
    -- all other indexes on this table.
    GlobalTableGlobalSecondaryIndexSettingsUpdate -> Text
indexName :: Prelude.Text
  }
  deriving (GlobalTableGlobalSecondaryIndexSettingsUpdate
-> GlobalTableGlobalSecondaryIndexSettingsUpdate -> Bool
(GlobalTableGlobalSecondaryIndexSettingsUpdate
 -> GlobalTableGlobalSecondaryIndexSettingsUpdate -> Bool)
-> (GlobalTableGlobalSecondaryIndexSettingsUpdate
    -> GlobalTableGlobalSecondaryIndexSettingsUpdate -> Bool)
-> Eq GlobalTableGlobalSecondaryIndexSettingsUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GlobalTableGlobalSecondaryIndexSettingsUpdate
-> GlobalTableGlobalSecondaryIndexSettingsUpdate -> Bool
$c/= :: GlobalTableGlobalSecondaryIndexSettingsUpdate
-> GlobalTableGlobalSecondaryIndexSettingsUpdate -> Bool
== :: GlobalTableGlobalSecondaryIndexSettingsUpdate
-> GlobalTableGlobalSecondaryIndexSettingsUpdate -> Bool
$c== :: GlobalTableGlobalSecondaryIndexSettingsUpdate
-> GlobalTableGlobalSecondaryIndexSettingsUpdate -> Bool
Prelude.Eq, ReadPrec [GlobalTableGlobalSecondaryIndexSettingsUpdate]
ReadPrec GlobalTableGlobalSecondaryIndexSettingsUpdate
Int -> ReadS GlobalTableGlobalSecondaryIndexSettingsUpdate
ReadS [GlobalTableGlobalSecondaryIndexSettingsUpdate]
(Int -> ReadS GlobalTableGlobalSecondaryIndexSettingsUpdate)
-> ReadS [GlobalTableGlobalSecondaryIndexSettingsUpdate]
-> ReadPrec GlobalTableGlobalSecondaryIndexSettingsUpdate
-> ReadPrec [GlobalTableGlobalSecondaryIndexSettingsUpdate]
-> Read GlobalTableGlobalSecondaryIndexSettingsUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GlobalTableGlobalSecondaryIndexSettingsUpdate]
$creadListPrec :: ReadPrec [GlobalTableGlobalSecondaryIndexSettingsUpdate]
readPrec :: ReadPrec GlobalTableGlobalSecondaryIndexSettingsUpdate
$creadPrec :: ReadPrec GlobalTableGlobalSecondaryIndexSettingsUpdate
readList :: ReadS [GlobalTableGlobalSecondaryIndexSettingsUpdate]
$creadList :: ReadS [GlobalTableGlobalSecondaryIndexSettingsUpdate]
readsPrec :: Int -> ReadS GlobalTableGlobalSecondaryIndexSettingsUpdate
$creadsPrec :: Int -> ReadS GlobalTableGlobalSecondaryIndexSettingsUpdate
Prelude.Read, Int -> GlobalTableGlobalSecondaryIndexSettingsUpdate -> ShowS
[GlobalTableGlobalSecondaryIndexSettingsUpdate] -> ShowS
GlobalTableGlobalSecondaryIndexSettingsUpdate -> String
(Int -> GlobalTableGlobalSecondaryIndexSettingsUpdate -> ShowS)
-> (GlobalTableGlobalSecondaryIndexSettingsUpdate -> String)
-> ([GlobalTableGlobalSecondaryIndexSettingsUpdate] -> ShowS)
-> Show GlobalTableGlobalSecondaryIndexSettingsUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GlobalTableGlobalSecondaryIndexSettingsUpdate] -> ShowS
$cshowList :: [GlobalTableGlobalSecondaryIndexSettingsUpdate] -> ShowS
show :: GlobalTableGlobalSecondaryIndexSettingsUpdate -> String
$cshow :: GlobalTableGlobalSecondaryIndexSettingsUpdate -> String
showsPrec :: Int -> GlobalTableGlobalSecondaryIndexSettingsUpdate -> ShowS
$cshowsPrec :: Int -> GlobalTableGlobalSecondaryIndexSettingsUpdate -> ShowS
Prelude.Show, (forall x.
 GlobalTableGlobalSecondaryIndexSettingsUpdate
 -> Rep GlobalTableGlobalSecondaryIndexSettingsUpdate x)
-> (forall x.
    Rep GlobalTableGlobalSecondaryIndexSettingsUpdate x
    -> GlobalTableGlobalSecondaryIndexSettingsUpdate)
-> Generic GlobalTableGlobalSecondaryIndexSettingsUpdate
forall x.
Rep GlobalTableGlobalSecondaryIndexSettingsUpdate x
-> GlobalTableGlobalSecondaryIndexSettingsUpdate
forall x.
GlobalTableGlobalSecondaryIndexSettingsUpdate
-> Rep GlobalTableGlobalSecondaryIndexSettingsUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GlobalTableGlobalSecondaryIndexSettingsUpdate x
-> GlobalTableGlobalSecondaryIndexSettingsUpdate
$cfrom :: forall x.
GlobalTableGlobalSecondaryIndexSettingsUpdate
-> Rep GlobalTableGlobalSecondaryIndexSettingsUpdate x
Prelude.Generic)

-- |
-- Create a value of 'GlobalTableGlobalSecondaryIndexSettingsUpdate' 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:
--
-- 'provisionedWriteCapacityUnits', 'globalTableGlobalSecondaryIndexSettingsUpdate_provisionedWriteCapacityUnits' - The maximum number of writes consumed per second before DynamoDB returns
-- a @ThrottlingException.@
--
-- 'provisionedWriteCapacityAutoScalingSettingsUpdate', 'globalTableGlobalSecondaryIndexSettingsUpdate_provisionedWriteCapacityAutoScalingSettingsUpdate' - Auto scaling settings for managing a global secondary index\'s write
-- capacity units.
--
-- 'indexName', 'globalTableGlobalSecondaryIndexSettingsUpdate_indexName' - The name of the global secondary index. The name must be unique among
-- all other indexes on this table.
newGlobalTableGlobalSecondaryIndexSettingsUpdate ::
  -- | 'indexName'
  Prelude.Text ->
  GlobalTableGlobalSecondaryIndexSettingsUpdate
newGlobalTableGlobalSecondaryIndexSettingsUpdate :: Text -> GlobalTableGlobalSecondaryIndexSettingsUpdate
newGlobalTableGlobalSecondaryIndexSettingsUpdate
  Text
pIndexName_ =
    GlobalTableGlobalSecondaryIndexSettingsUpdate' :: Maybe Natural
-> Maybe AutoScalingSettingsUpdate
-> Text
-> GlobalTableGlobalSecondaryIndexSettingsUpdate
GlobalTableGlobalSecondaryIndexSettingsUpdate'
      { $sel:provisionedWriteCapacityUnits:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: Maybe Natural
provisionedWriteCapacityUnits =
          Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:provisionedWriteCapacityAutoScalingSettingsUpdate:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: Maybe AutoScalingSettingsUpdate
provisionedWriteCapacityAutoScalingSettingsUpdate =
          Maybe AutoScalingSettingsUpdate
forall a. Maybe a
Prelude.Nothing,
        $sel:indexName:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: Text
indexName = Text
pIndexName_
      }

-- | The maximum number of writes consumed per second before DynamoDB returns
-- a @ThrottlingException.@
globalTableGlobalSecondaryIndexSettingsUpdate_provisionedWriteCapacityUnits :: Lens.Lens' GlobalTableGlobalSecondaryIndexSettingsUpdate (Prelude.Maybe Prelude.Natural)
globalTableGlobalSecondaryIndexSettingsUpdate_provisionedWriteCapacityUnits :: (Maybe Natural -> f (Maybe Natural))
-> GlobalTableGlobalSecondaryIndexSettingsUpdate
-> f GlobalTableGlobalSecondaryIndexSettingsUpdate
globalTableGlobalSecondaryIndexSettingsUpdate_provisionedWriteCapacityUnits = (GlobalTableGlobalSecondaryIndexSettingsUpdate -> Maybe Natural)
-> (GlobalTableGlobalSecondaryIndexSettingsUpdate
    -> Maybe Natural -> GlobalTableGlobalSecondaryIndexSettingsUpdate)
-> Lens
     GlobalTableGlobalSecondaryIndexSettingsUpdate
     GlobalTableGlobalSecondaryIndexSettingsUpdate
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalTableGlobalSecondaryIndexSettingsUpdate' {Maybe Natural
provisionedWriteCapacityUnits :: Maybe Natural
$sel:provisionedWriteCapacityUnits:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: GlobalTableGlobalSecondaryIndexSettingsUpdate -> Maybe Natural
provisionedWriteCapacityUnits} -> Maybe Natural
provisionedWriteCapacityUnits) (\s :: GlobalTableGlobalSecondaryIndexSettingsUpdate
s@GlobalTableGlobalSecondaryIndexSettingsUpdate' {} Maybe Natural
a -> GlobalTableGlobalSecondaryIndexSettingsUpdate
s {$sel:provisionedWriteCapacityUnits:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: Maybe Natural
provisionedWriteCapacityUnits = Maybe Natural
a} :: GlobalTableGlobalSecondaryIndexSettingsUpdate)

-- | Auto scaling settings for managing a global secondary index\'s write
-- capacity units.
globalTableGlobalSecondaryIndexSettingsUpdate_provisionedWriteCapacityAutoScalingSettingsUpdate :: Lens.Lens' GlobalTableGlobalSecondaryIndexSettingsUpdate (Prelude.Maybe AutoScalingSettingsUpdate)
globalTableGlobalSecondaryIndexSettingsUpdate_provisionedWriteCapacityAutoScalingSettingsUpdate :: (Maybe AutoScalingSettingsUpdate
 -> f (Maybe AutoScalingSettingsUpdate))
-> GlobalTableGlobalSecondaryIndexSettingsUpdate
-> f GlobalTableGlobalSecondaryIndexSettingsUpdate
globalTableGlobalSecondaryIndexSettingsUpdate_provisionedWriteCapacityAutoScalingSettingsUpdate = (GlobalTableGlobalSecondaryIndexSettingsUpdate
 -> Maybe AutoScalingSettingsUpdate)
-> (GlobalTableGlobalSecondaryIndexSettingsUpdate
    -> Maybe AutoScalingSettingsUpdate
    -> GlobalTableGlobalSecondaryIndexSettingsUpdate)
-> Lens
     GlobalTableGlobalSecondaryIndexSettingsUpdate
     GlobalTableGlobalSecondaryIndexSettingsUpdate
     (Maybe AutoScalingSettingsUpdate)
     (Maybe AutoScalingSettingsUpdate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalTableGlobalSecondaryIndexSettingsUpdate' {Maybe AutoScalingSettingsUpdate
provisionedWriteCapacityAutoScalingSettingsUpdate :: Maybe AutoScalingSettingsUpdate
$sel:provisionedWriteCapacityAutoScalingSettingsUpdate:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: GlobalTableGlobalSecondaryIndexSettingsUpdate
-> Maybe AutoScalingSettingsUpdate
provisionedWriteCapacityAutoScalingSettingsUpdate} -> Maybe AutoScalingSettingsUpdate
provisionedWriteCapacityAutoScalingSettingsUpdate) (\s :: GlobalTableGlobalSecondaryIndexSettingsUpdate
s@GlobalTableGlobalSecondaryIndexSettingsUpdate' {} Maybe AutoScalingSettingsUpdate
a -> GlobalTableGlobalSecondaryIndexSettingsUpdate
s {$sel:provisionedWriteCapacityAutoScalingSettingsUpdate:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: Maybe AutoScalingSettingsUpdate
provisionedWriteCapacityAutoScalingSettingsUpdate = Maybe AutoScalingSettingsUpdate
a} :: GlobalTableGlobalSecondaryIndexSettingsUpdate)

-- | The name of the global secondary index. The name must be unique among
-- all other indexes on this table.
globalTableGlobalSecondaryIndexSettingsUpdate_indexName :: Lens.Lens' GlobalTableGlobalSecondaryIndexSettingsUpdate Prelude.Text
globalTableGlobalSecondaryIndexSettingsUpdate_indexName :: (Text -> f Text)
-> GlobalTableGlobalSecondaryIndexSettingsUpdate
-> f GlobalTableGlobalSecondaryIndexSettingsUpdate
globalTableGlobalSecondaryIndexSettingsUpdate_indexName = (GlobalTableGlobalSecondaryIndexSettingsUpdate -> Text)
-> (GlobalTableGlobalSecondaryIndexSettingsUpdate
    -> Text -> GlobalTableGlobalSecondaryIndexSettingsUpdate)
-> Lens
     GlobalTableGlobalSecondaryIndexSettingsUpdate
     GlobalTableGlobalSecondaryIndexSettingsUpdate
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalTableGlobalSecondaryIndexSettingsUpdate' {Text
indexName :: Text
$sel:indexName:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: GlobalTableGlobalSecondaryIndexSettingsUpdate -> Text
indexName} -> Text
indexName) (\s :: GlobalTableGlobalSecondaryIndexSettingsUpdate
s@GlobalTableGlobalSecondaryIndexSettingsUpdate' {} Text
a -> GlobalTableGlobalSecondaryIndexSettingsUpdate
s {$sel:indexName:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: Text
indexName = Text
a} :: GlobalTableGlobalSecondaryIndexSettingsUpdate)

instance
  Prelude.Hashable
    GlobalTableGlobalSecondaryIndexSettingsUpdate

instance
  Prelude.NFData
    GlobalTableGlobalSecondaryIndexSettingsUpdate

instance
  Core.ToJSON
    GlobalTableGlobalSecondaryIndexSettingsUpdate
  where
  toJSON :: GlobalTableGlobalSecondaryIndexSettingsUpdate -> Value
toJSON
    GlobalTableGlobalSecondaryIndexSettingsUpdate' {Maybe Natural
Maybe AutoScalingSettingsUpdate
Text
indexName :: Text
provisionedWriteCapacityAutoScalingSettingsUpdate :: Maybe AutoScalingSettingsUpdate
provisionedWriteCapacityUnits :: Maybe Natural
$sel:indexName:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: GlobalTableGlobalSecondaryIndexSettingsUpdate -> Text
$sel:provisionedWriteCapacityAutoScalingSettingsUpdate:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: GlobalTableGlobalSecondaryIndexSettingsUpdate
-> Maybe AutoScalingSettingsUpdate
$sel:provisionedWriteCapacityUnits:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: GlobalTableGlobalSecondaryIndexSettingsUpdate -> Maybe Natural
..} =
      [Pair] -> Value
Core.object
        ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
            [ (Text
"ProvisionedWriteCapacityUnits" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
                (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
provisionedWriteCapacityUnits,
              ( Text
"ProvisionedWriteCapacityAutoScalingSettingsUpdate"
                  Text -> AutoScalingSettingsUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=
              )
                (AutoScalingSettingsUpdate -> Pair)
-> Maybe AutoScalingSettingsUpdate -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AutoScalingSettingsUpdate
provisionedWriteCapacityAutoScalingSettingsUpdate,
              Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"IndexName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
indexName)
            ]
        )