{-# 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.ReplicaSettingsUpdate
-- 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.ReplicaSettingsUpdate where

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

-- | Represents the settings for a global table in a Region that will be
-- modified.
--
-- /See:/ 'newReplicaSettingsUpdate' smart constructor.
data ReplicaSettingsUpdate = ReplicaSettingsUpdate'
  { -- | Auto scaling settings for managing a global table replica\'s read
    -- capacity units.
    ReplicaSettingsUpdate -> Maybe AutoScalingSettingsUpdate
replicaProvisionedReadCapacityAutoScalingSettingsUpdate :: Prelude.Maybe AutoScalingSettingsUpdate,
    -- | The maximum number of strongly consistent reads consumed per second
    -- before DynamoDB returns a @ThrottlingException@. For more information,
    -- see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#ProvisionedThroughput Specifying Read and Write Requirements>
    -- in the /Amazon DynamoDB Developer Guide/.
    ReplicaSettingsUpdate -> Maybe Natural
replicaProvisionedReadCapacityUnits :: Prelude.Maybe Prelude.Natural,
    -- | Represents the settings of a global secondary index for a global table
    -- that will be modified.
    ReplicaSettingsUpdate
-> Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
replicaGlobalSecondaryIndexSettingsUpdate :: Prelude.Maybe (Prelude.NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate),
    -- | The Region of the replica to be added.
    ReplicaSettingsUpdate -> Text
regionName :: Prelude.Text
  }
  deriving (ReplicaSettingsUpdate -> ReplicaSettingsUpdate -> Bool
(ReplicaSettingsUpdate -> ReplicaSettingsUpdate -> Bool)
-> (ReplicaSettingsUpdate -> ReplicaSettingsUpdate -> Bool)
-> Eq ReplicaSettingsUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReplicaSettingsUpdate -> ReplicaSettingsUpdate -> Bool
$c/= :: ReplicaSettingsUpdate -> ReplicaSettingsUpdate -> Bool
== :: ReplicaSettingsUpdate -> ReplicaSettingsUpdate -> Bool
$c== :: ReplicaSettingsUpdate -> ReplicaSettingsUpdate -> Bool
Prelude.Eq, ReadPrec [ReplicaSettingsUpdate]
ReadPrec ReplicaSettingsUpdate
Int -> ReadS ReplicaSettingsUpdate
ReadS [ReplicaSettingsUpdate]
(Int -> ReadS ReplicaSettingsUpdate)
-> ReadS [ReplicaSettingsUpdate]
-> ReadPrec ReplicaSettingsUpdate
-> ReadPrec [ReplicaSettingsUpdate]
-> Read ReplicaSettingsUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReplicaSettingsUpdate]
$creadListPrec :: ReadPrec [ReplicaSettingsUpdate]
readPrec :: ReadPrec ReplicaSettingsUpdate
$creadPrec :: ReadPrec ReplicaSettingsUpdate
readList :: ReadS [ReplicaSettingsUpdate]
$creadList :: ReadS [ReplicaSettingsUpdate]
readsPrec :: Int -> ReadS ReplicaSettingsUpdate
$creadsPrec :: Int -> ReadS ReplicaSettingsUpdate
Prelude.Read, Int -> ReplicaSettingsUpdate -> ShowS
[ReplicaSettingsUpdate] -> ShowS
ReplicaSettingsUpdate -> String
(Int -> ReplicaSettingsUpdate -> ShowS)
-> (ReplicaSettingsUpdate -> String)
-> ([ReplicaSettingsUpdate] -> ShowS)
-> Show ReplicaSettingsUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReplicaSettingsUpdate] -> ShowS
$cshowList :: [ReplicaSettingsUpdate] -> ShowS
show :: ReplicaSettingsUpdate -> String
$cshow :: ReplicaSettingsUpdate -> String
showsPrec :: Int -> ReplicaSettingsUpdate -> ShowS
$cshowsPrec :: Int -> ReplicaSettingsUpdate -> ShowS
Prelude.Show, (forall x. ReplicaSettingsUpdate -> Rep ReplicaSettingsUpdate x)
-> (forall x. Rep ReplicaSettingsUpdate x -> ReplicaSettingsUpdate)
-> Generic ReplicaSettingsUpdate
forall x. Rep ReplicaSettingsUpdate x -> ReplicaSettingsUpdate
forall x. ReplicaSettingsUpdate -> Rep ReplicaSettingsUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReplicaSettingsUpdate x -> ReplicaSettingsUpdate
$cfrom :: forall x. ReplicaSettingsUpdate -> Rep ReplicaSettingsUpdate x
Prelude.Generic)

-- |
-- Create a value of 'ReplicaSettingsUpdate' 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:
--
-- 'replicaProvisionedReadCapacityAutoScalingSettingsUpdate', 'replicaSettingsUpdate_replicaProvisionedReadCapacityAutoScalingSettingsUpdate' - Auto scaling settings for managing a global table replica\'s read
-- capacity units.
--
-- 'replicaProvisionedReadCapacityUnits', 'replicaSettingsUpdate_replicaProvisionedReadCapacityUnits' - The maximum number of strongly consistent reads consumed per second
-- before DynamoDB returns a @ThrottlingException@. For more information,
-- see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#ProvisionedThroughput Specifying Read and Write Requirements>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- 'replicaGlobalSecondaryIndexSettingsUpdate', 'replicaSettingsUpdate_replicaGlobalSecondaryIndexSettingsUpdate' - Represents the settings of a global secondary index for a global table
-- that will be modified.
--
-- 'regionName', 'replicaSettingsUpdate_regionName' - The Region of the replica to be added.
newReplicaSettingsUpdate ::
  -- | 'regionName'
  Prelude.Text ->
  ReplicaSettingsUpdate
newReplicaSettingsUpdate :: Text -> ReplicaSettingsUpdate
newReplicaSettingsUpdate Text
pRegionName_ =
  ReplicaSettingsUpdate' :: Maybe AutoScalingSettingsUpdate
-> Maybe Natural
-> Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
-> Text
-> ReplicaSettingsUpdate
ReplicaSettingsUpdate'
    { $sel:replicaProvisionedReadCapacityAutoScalingSettingsUpdate:ReplicaSettingsUpdate' :: Maybe AutoScalingSettingsUpdate
replicaProvisionedReadCapacityAutoScalingSettingsUpdate =
        Maybe AutoScalingSettingsUpdate
forall a. Maybe a
Prelude.Nothing,
      $sel:replicaProvisionedReadCapacityUnits:ReplicaSettingsUpdate' :: Maybe Natural
replicaProvisionedReadCapacityUnits =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:replicaGlobalSecondaryIndexSettingsUpdate:ReplicaSettingsUpdate' :: Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
replicaGlobalSecondaryIndexSettingsUpdate =
        Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
forall a. Maybe a
Prelude.Nothing,
      $sel:regionName:ReplicaSettingsUpdate' :: Text
regionName = Text
pRegionName_
    }

-- | Auto scaling settings for managing a global table replica\'s read
-- capacity units.
replicaSettingsUpdate_replicaProvisionedReadCapacityAutoScalingSettingsUpdate :: Lens.Lens' ReplicaSettingsUpdate (Prelude.Maybe AutoScalingSettingsUpdate)
replicaSettingsUpdate_replicaProvisionedReadCapacityAutoScalingSettingsUpdate :: (Maybe AutoScalingSettingsUpdate
 -> f (Maybe AutoScalingSettingsUpdate))
-> ReplicaSettingsUpdate -> f ReplicaSettingsUpdate
replicaSettingsUpdate_replicaProvisionedReadCapacityAutoScalingSettingsUpdate = (ReplicaSettingsUpdate -> Maybe AutoScalingSettingsUpdate)
-> (ReplicaSettingsUpdate
    -> Maybe AutoScalingSettingsUpdate -> ReplicaSettingsUpdate)
-> Lens
     ReplicaSettingsUpdate
     ReplicaSettingsUpdate
     (Maybe AutoScalingSettingsUpdate)
     (Maybe AutoScalingSettingsUpdate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicaSettingsUpdate' {Maybe AutoScalingSettingsUpdate
replicaProvisionedReadCapacityAutoScalingSettingsUpdate :: Maybe AutoScalingSettingsUpdate
$sel:replicaProvisionedReadCapacityAutoScalingSettingsUpdate:ReplicaSettingsUpdate' :: ReplicaSettingsUpdate -> Maybe AutoScalingSettingsUpdate
replicaProvisionedReadCapacityAutoScalingSettingsUpdate} -> Maybe AutoScalingSettingsUpdate
replicaProvisionedReadCapacityAutoScalingSettingsUpdate) (\s :: ReplicaSettingsUpdate
s@ReplicaSettingsUpdate' {} Maybe AutoScalingSettingsUpdate
a -> ReplicaSettingsUpdate
s {$sel:replicaProvisionedReadCapacityAutoScalingSettingsUpdate:ReplicaSettingsUpdate' :: Maybe AutoScalingSettingsUpdate
replicaProvisionedReadCapacityAutoScalingSettingsUpdate = Maybe AutoScalingSettingsUpdate
a} :: ReplicaSettingsUpdate)

-- | The maximum number of strongly consistent reads consumed per second
-- before DynamoDB returns a @ThrottlingException@. For more information,
-- see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#ProvisionedThroughput Specifying Read and Write Requirements>
-- in the /Amazon DynamoDB Developer Guide/.
replicaSettingsUpdate_replicaProvisionedReadCapacityUnits :: Lens.Lens' ReplicaSettingsUpdate (Prelude.Maybe Prelude.Natural)
replicaSettingsUpdate_replicaProvisionedReadCapacityUnits :: (Maybe Natural -> f (Maybe Natural))
-> ReplicaSettingsUpdate -> f ReplicaSettingsUpdate
replicaSettingsUpdate_replicaProvisionedReadCapacityUnits = (ReplicaSettingsUpdate -> Maybe Natural)
-> (ReplicaSettingsUpdate
    -> Maybe Natural -> ReplicaSettingsUpdate)
-> Lens
     ReplicaSettingsUpdate
     ReplicaSettingsUpdate
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicaSettingsUpdate' {Maybe Natural
replicaProvisionedReadCapacityUnits :: Maybe Natural
$sel:replicaProvisionedReadCapacityUnits:ReplicaSettingsUpdate' :: ReplicaSettingsUpdate -> Maybe Natural
replicaProvisionedReadCapacityUnits} -> Maybe Natural
replicaProvisionedReadCapacityUnits) (\s :: ReplicaSettingsUpdate
s@ReplicaSettingsUpdate' {} Maybe Natural
a -> ReplicaSettingsUpdate
s {$sel:replicaProvisionedReadCapacityUnits:ReplicaSettingsUpdate' :: Maybe Natural
replicaProvisionedReadCapacityUnits = Maybe Natural
a} :: ReplicaSettingsUpdate)

-- | Represents the settings of a global secondary index for a global table
-- that will be modified.
replicaSettingsUpdate_replicaGlobalSecondaryIndexSettingsUpdate :: Lens.Lens' ReplicaSettingsUpdate (Prelude.Maybe (Prelude.NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate))
replicaSettingsUpdate_replicaGlobalSecondaryIndexSettingsUpdate :: (Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
 -> f (Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)))
-> ReplicaSettingsUpdate -> f ReplicaSettingsUpdate
replicaSettingsUpdate_replicaGlobalSecondaryIndexSettingsUpdate = (ReplicaSettingsUpdate
 -> Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate))
-> (ReplicaSettingsUpdate
    -> Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
    -> ReplicaSettingsUpdate)
-> Lens
     ReplicaSettingsUpdate
     ReplicaSettingsUpdate
     (Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate))
     (Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicaSettingsUpdate' {Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
replicaGlobalSecondaryIndexSettingsUpdate :: Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
$sel:replicaGlobalSecondaryIndexSettingsUpdate:ReplicaSettingsUpdate' :: ReplicaSettingsUpdate
-> Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
replicaGlobalSecondaryIndexSettingsUpdate} -> Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
replicaGlobalSecondaryIndexSettingsUpdate) (\s :: ReplicaSettingsUpdate
s@ReplicaSettingsUpdate' {} Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
a -> ReplicaSettingsUpdate
s {$sel:replicaGlobalSecondaryIndexSettingsUpdate:ReplicaSettingsUpdate' :: Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
replicaGlobalSecondaryIndexSettingsUpdate = Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
a} :: ReplicaSettingsUpdate) ((Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
  -> f (Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)))
 -> ReplicaSettingsUpdate -> f ReplicaSettingsUpdate)
-> ((Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
     -> f (Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)))
    -> Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
    -> f (Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)))
-> (Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
    -> f (Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)))
-> ReplicaSettingsUpdate
-> f ReplicaSettingsUpdate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
  (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
  (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
  (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
-> Iso
     (Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate))
     (Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate))
     (Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate))
     (Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate))
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 ReplicaGlobalSecondaryIndexSettingsUpdate)
  (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
  (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
  (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Region of the replica to be added.
replicaSettingsUpdate_regionName :: Lens.Lens' ReplicaSettingsUpdate Prelude.Text
replicaSettingsUpdate_regionName :: (Text -> f Text)
-> ReplicaSettingsUpdate -> f ReplicaSettingsUpdate
replicaSettingsUpdate_regionName = (ReplicaSettingsUpdate -> Text)
-> (ReplicaSettingsUpdate -> Text -> ReplicaSettingsUpdate)
-> Lens ReplicaSettingsUpdate ReplicaSettingsUpdate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicaSettingsUpdate' {Text
regionName :: Text
$sel:regionName:ReplicaSettingsUpdate' :: ReplicaSettingsUpdate -> Text
regionName} -> Text
regionName) (\s :: ReplicaSettingsUpdate
s@ReplicaSettingsUpdate' {} Text
a -> ReplicaSettingsUpdate
s {$sel:regionName:ReplicaSettingsUpdate' :: Text
regionName = Text
a} :: ReplicaSettingsUpdate)

instance Prelude.Hashable ReplicaSettingsUpdate

instance Prelude.NFData ReplicaSettingsUpdate

instance Core.ToJSON ReplicaSettingsUpdate where
  toJSON :: ReplicaSettingsUpdate -> Value
toJSON ReplicaSettingsUpdate' {Maybe Natural
Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
Maybe AutoScalingSettingsUpdate
Text
regionName :: Text
replicaGlobalSecondaryIndexSettingsUpdate :: Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
replicaProvisionedReadCapacityUnits :: Maybe Natural
replicaProvisionedReadCapacityAutoScalingSettingsUpdate :: Maybe AutoScalingSettingsUpdate
$sel:regionName:ReplicaSettingsUpdate' :: ReplicaSettingsUpdate -> Text
$sel:replicaGlobalSecondaryIndexSettingsUpdate:ReplicaSettingsUpdate' :: ReplicaSettingsUpdate
-> Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
$sel:replicaProvisionedReadCapacityUnits:ReplicaSettingsUpdate' :: ReplicaSettingsUpdate -> Maybe Natural
$sel:replicaProvisionedReadCapacityAutoScalingSettingsUpdate:ReplicaSettingsUpdate' :: ReplicaSettingsUpdate -> Maybe AutoScalingSettingsUpdate
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ ( Text
"ReplicaProvisionedReadCapacityAutoScalingSettingsUpdate"
                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
replicaProvisionedReadCapacityAutoScalingSettingsUpdate,
            (Text
"ReplicaProvisionedReadCapacityUnits" 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
replicaProvisionedReadCapacityUnits,
            (Text
"ReplicaGlobalSecondaryIndexSettingsUpdate" Text -> NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate -> Pair)
-> Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
-> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty ReplicaGlobalSecondaryIndexSettingsUpdate)
replicaGlobalSecondaryIndexSettingsUpdate,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RegionName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
regionName)
          ]
      )