{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DynamoDB.Types.GlobalTableGlobalSecondaryIndexSettingsUpdate where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DynamoDB.Types.AttributeValue
import Amazonka.DynamoDB.Types.AutoScalingSettingsUpdate
import Amazonka.DynamoDB.Types.WriteRequest
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'
  { -- | Auto scaling settings for managing a global secondary index\'s write
    -- capacity units.
    GlobalTableGlobalSecondaryIndexSettingsUpdate
-> Maybe AutoScalingSettingsUpdate
provisionedWriteCapacityAutoScalingSettingsUpdate :: Prelude.Maybe AutoScalingSettingsUpdate,
    -- | The maximum number of writes consumed per second before DynamoDB returns
    -- a @ThrottlingException.@
    GlobalTableGlobalSecondaryIndexSettingsUpdate -> Maybe Natural
provisionedWriteCapacityUnits :: Prelude.Maybe Prelude.Natural,
    -- | 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
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]
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
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.
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:
--
-- 'provisionedWriteCapacityAutoScalingSettingsUpdate', 'globalTableGlobalSecondaryIndexSettingsUpdate_provisionedWriteCapacityAutoScalingSettingsUpdate' - Auto scaling settings for managing a global secondary index\'s write
-- capacity units.
--
-- 'provisionedWriteCapacityUnits', 'globalTableGlobalSecondaryIndexSettingsUpdate_provisionedWriteCapacityUnits' - The maximum number of writes consumed per second before DynamoDB returns
-- a @ThrottlingException.@
--
-- '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'
      { $sel:provisionedWriteCapacityAutoScalingSettingsUpdate:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: Maybe AutoScalingSettingsUpdate
provisionedWriteCapacityAutoScalingSettingsUpdate =
          forall a. Maybe a
Prelude.Nothing,
        $sel:provisionedWriteCapacityUnits:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: Maybe Natural
provisionedWriteCapacityUnits =
          forall a. Maybe a
Prelude.Nothing,
        $sel:indexName:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: Text
indexName = Text
pIndexName_
      }

-- | Auto scaling settings for managing a global secondary index\'s write
-- capacity units.
globalTableGlobalSecondaryIndexSettingsUpdate_provisionedWriteCapacityAutoScalingSettingsUpdate :: Lens.Lens' GlobalTableGlobalSecondaryIndexSettingsUpdate (Prelude.Maybe AutoScalingSettingsUpdate)
globalTableGlobalSecondaryIndexSettingsUpdate_provisionedWriteCapacityAutoScalingSettingsUpdate :: Lens'
  GlobalTableGlobalSecondaryIndexSettingsUpdate
  (Maybe AutoScalingSettingsUpdate)
globalTableGlobalSecondaryIndexSettingsUpdate_provisionedWriteCapacityAutoScalingSettingsUpdate = 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 maximum number of writes consumed per second before DynamoDB returns
-- a @ThrottlingException.@
globalTableGlobalSecondaryIndexSettingsUpdate_provisionedWriteCapacityUnits :: Lens.Lens' GlobalTableGlobalSecondaryIndexSettingsUpdate (Prelude.Maybe Prelude.Natural)
globalTableGlobalSecondaryIndexSettingsUpdate_provisionedWriteCapacityUnits :: Lens' GlobalTableGlobalSecondaryIndexSettingsUpdate (Maybe Natural)
globalTableGlobalSecondaryIndexSettingsUpdate_provisionedWriteCapacityUnits = 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)

-- | 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 :: Lens' GlobalTableGlobalSecondaryIndexSettingsUpdate Text
globalTableGlobalSecondaryIndexSettingsUpdate_indexName = 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
  where
  hashWithSalt :: Int -> GlobalTableGlobalSecondaryIndexSettingsUpdate -> Int
hashWithSalt
    Int
_salt
    GlobalTableGlobalSecondaryIndexSettingsUpdate' {Maybe Natural
Maybe AutoScalingSettingsUpdate
Text
indexName :: Text
provisionedWriteCapacityUnits :: Maybe Natural
provisionedWriteCapacityAutoScalingSettingsUpdate :: Maybe AutoScalingSettingsUpdate
$sel:indexName:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: GlobalTableGlobalSecondaryIndexSettingsUpdate -> Text
$sel:provisionedWriteCapacityUnits:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: GlobalTableGlobalSecondaryIndexSettingsUpdate -> Maybe Natural
$sel:provisionedWriteCapacityAutoScalingSettingsUpdate:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: GlobalTableGlobalSecondaryIndexSettingsUpdate
-> Maybe AutoScalingSettingsUpdate
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AutoScalingSettingsUpdate
provisionedWriteCapacityAutoScalingSettingsUpdate
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
provisionedWriteCapacityUnits
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
indexName

instance
  Prelude.NFData
    GlobalTableGlobalSecondaryIndexSettingsUpdate
  where
  rnf :: GlobalTableGlobalSecondaryIndexSettingsUpdate -> ()
rnf
    GlobalTableGlobalSecondaryIndexSettingsUpdate' {Maybe Natural
Maybe AutoScalingSettingsUpdate
Text
indexName :: Text
provisionedWriteCapacityUnits :: Maybe Natural
provisionedWriteCapacityAutoScalingSettingsUpdate :: Maybe AutoScalingSettingsUpdate
$sel:indexName:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: GlobalTableGlobalSecondaryIndexSettingsUpdate -> Text
$sel:provisionedWriteCapacityUnits:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: GlobalTableGlobalSecondaryIndexSettingsUpdate -> Maybe Natural
$sel:provisionedWriteCapacityAutoScalingSettingsUpdate:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: GlobalTableGlobalSecondaryIndexSettingsUpdate
-> Maybe AutoScalingSettingsUpdate
..} =
      forall a. NFData a => a -> ()
Prelude.rnf
        Maybe AutoScalingSettingsUpdate
provisionedWriteCapacityAutoScalingSettingsUpdate
        seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
provisionedWriteCapacityUnits
        seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
indexName

instance
  Data.ToJSON
    GlobalTableGlobalSecondaryIndexSettingsUpdate
  where
  toJSON :: GlobalTableGlobalSecondaryIndexSettingsUpdate -> Value
toJSON
    GlobalTableGlobalSecondaryIndexSettingsUpdate' {Maybe Natural
Maybe AutoScalingSettingsUpdate
Text
indexName :: Text
provisionedWriteCapacityUnits :: Maybe Natural
provisionedWriteCapacityAutoScalingSettingsUpdate :: Maybe AutoScalingSettingsUpdate
$sel:indexName:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: GlobalTableGlobalSecondaryIndexSettingsUpdate -> Text
$sel:provisionedWriteCapacityUnits:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: GlobalTableGlobalSecondaryIndexSettingsUpdate -> Maybe Natural
$sel:provisionedWriteCapacityAutoScalingSettingsUpdate:GlobalTableGlobalSecondaryIndexSettingsUpdate' :: GlobalTableGlobalSecondaryIndexSettingsUpdate
-> Maybe AutoScalingSettingsUpdate
..} =
      [Pair] -> Value
Data.object
        ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
            [ ( Key
"ProvisionedWriteCapacityAutoScalingSettingsUpdate"
                  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 AutoScalingSettingsUpdate
provisionedWriteCapacityAutoScalingSettingsUpdate,
              (Key
"ProvisionedWriteCapacityUnits" 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
provisionedWriteCapacityUnits,
              forall a. a -> Maybe a
Prelude.Just (Key
"IndexName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
indexName)
            ]
        )