{-# 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.ReplicaGlobalSecondaryIndex
-- 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.ReplicaGlobalSecondaryIndex 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.ProvisionedThroughputOverride
import Amazonka.DynamoDB.Types.WriteRequest
import qualified Amazonka.Prelude as Prelude

-- | Represents the properties of a replica global secondary index.
--
-- /See:/ 'newReplicaGlobalSecondaryIndex' smart constructor.
data ReplicaGlobalSecondaryIndex = ReplicaGlobalSecondaryIndex'
  { -- | Replica table GSI-specific provisioned throughput. If not specified,
    -- uses the source table GSI\'s read capacity settings.
    ReplicaGlobalSecondaryIndex -> Maybe ProvisionedThroughputOverride
provisionedThroughputOverride :: Prelude.Maybe ProvisionedThroughputOverride,
    -- | The name of the global secondary index.
    ReplicaGlobalSecondaryIndex -> Text
indexName :: Prelude.Text
  }
  deriving (ReplicaGlobalSecondaryIndex -> ReplicaGlobalSecondaryIndex -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReplicaGlobalSecondaryIndex -> ReplicaGlobalSecondaryIndex -> Bool
$c/= :: ReplicaGlobalSecondaryIndex -> ReplicaGlobalSecondaryIndex -> Bool
== :: ReplicaGlobalSecondaryIndex -> ReplicaGlobalSecondaryIndex -> Bool
$c== :: ReplicaGlobalSecondaryIndex -> ReplicaGlobalSecondaryIndex -> Bool
Prelude.Eq, ReadPrec [ReplicaGlobalSecondaryIndex]
ReadPrec ReplicaGlobalSecondaryIndex
Int -> ReadS ReplicaGlobalSecondaryIndex
ReadS [ReplicaGlobalSecondaryIndex]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReplicaGlobalSecondaryIndex]
$creadListPrec :: ReadPrec [ReplicaGlobalSecondaryIndex]
readPrec :: ReadPrec ReplicaGlobalSecondaryIndex
$creadPrec :: ReadPrec ReplicaGlobalSecondaryIndex
readList :: ReadS [ReplicaGlobalSecondaryIndex]
$creadList :: ReadS [ReplicaGlobalSecondaryIndex]
readsPrec :: Int -> ReadS ReplicaGlobalSecondaryIndex
$creadsPrec :: Int -> ReadS ReplicaGlobalSecondaryIndex
Prelude.Read, Int -> ReplicaGlobalSecondaryIndex -> ShowS
[ReplicaGlobalSecondaryIndex] -> ShowS
ReplicaGlobalSecondaryIndex -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReplicaGlobalSecondaryIndex] -> ShowS
$cshowList :: [ReplicaGlobalSecondaryIndex] -> ShowS
show :: ReplicaGlobalSecondaryIndex -> String
$cshow :: ReplicaGlobalSecondaryIndex -> String
showsPrec :: Int -> ReplicaGlobalSecondaryIndex -> ShowS
$cshowsPrec :: Int -> ReplicaGlobalSecondaryIndex -> ShowS
Prelude.Show, forall x.
Rep ReplicaGlobalSecondaryIndex x -> ReplicaGlobalSecondaryIndex
forall x.
ReplicaGlobalSecondaryIndex -> Rep ReplicaGlobalSecondaryIndex x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ReplicaGlobalSecondaryIndex x -> ReplicaGlobalSecondaryIndex
$cfrom :: forall x.
ReplicaGlobalSecondaryIndex -> Rep ReplicaGlobalSecondaryIndex x
Prelude.Generic)

-- |
-- Create a value of 'ReplicaGlobalSecondaryIndex' 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:
--
-- 'provisionedThroughputOverride', 'replicaGlobalSecondaryIndex_provisionedThroughputOverride' - Replica table GSI-specific provisioned throughput. If not specified,
-- uses the source table GSI\'s read capacity settings.
--
-- 'indexName', 'replicaGlobalSecondaryIndex_indexName' - The name of the global secondary index.
newReplicaGlobalSecondaryIndex ::
  -- | 'indexName'
  Prelude.Text ->
  ReplicaGlobalSecondaryIndex
newReplicaGlobalSecondaryIndex :: Text -> ReplicaGlobalSecondaryIndex
newReplicaGlobalSecondaryIndex Text
pIndexName_ =
  ReplicaGlobalSecondaryIndex'
    { $sel:provisionedThroughputOverride:ReplicaGlobalSecondaryIndex' :: Maybe ProvisionedThroughputOverride
provisionedThroughputOverride =
        forall a. Maybe a
Prelude.Nothing,
      $sel:indexName:ReplicaGlobalSecondaryIndex' :: Text
indexName = Text
pIndexName_
    }

-- | Replica table GSI-specific provisioned throughput. If not specified,
-- uses the source table GSI\'s read capacity settings.
replicaGlobalSecondaryIndex_provisionedThroughputOverride :: Lens.Lens' ReplicaGlobalSecondaryIndex (Prelude.Maybe ProvisionedThroughputOverride)
replicaGlobalSecondaryIndex_provisionedThroughputOverride :: Lens'
  ReplicaGlobalSecondaryIndex (Maybe ProvisionedThroughputOverride)
replicaGlobalSecondaryIndex_provisionedThroughputOverride = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicaGlobalSecondaryIndex' {Maybe ProvisionedThroughputOverride
provisionedThroughputOverride :: Maybe ProvisionedThroughputOverride
$sel:provisionedThroughputOverride:ReplicaGlobalSecondaryIndex' :: ReplicaGlobalSecondaryIndex -> Maybe ProvisionedThroughputOverride
provisionedThroughputOverride} -> Maybe ProvisionedThroughputOverride
provisionedThroughputOverride) (\s :: ReplicaGlobalSecondaryIndex
s@ReplicaGlobalSecondaryIndex' {} Maybe ProvisionedThroughputOverride
a -> ReplicaGlobalSecondaryIndex
s {$sel:provisionedThroughputOverride:ReplicaGlobalSecondaryIndex' :: Maybe ProvisionedThroughputOverride
provisionedThroughputOverride = Maybe ProvisionedThroughputOverride
a} :: ReplicaGlobalSecondaryIndex)

-- | The name of the global secondary index.
replicaGlobalSecondaryIndex_indexName :: Lens.Lens' ReplicaGlobalSecondaryIndex Prelude.Text
replicaGlobalSecondaryIndex_indexName :: Lens' ReplicaGlobalSecondaryIndex Text
replicaGlobalSecondaryIndex_indexName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicaGlobalSecondaryIndex' {Text
indexName :: Text
$sel:indexName:ReplicaGlobalSecondaryIndex' :: ReplicaGlobalSecondaryIndex -> Text
indexName} -> Text
indexName) (\s :: ReplicaGlobalSecondaryIndex
s@ReplicaGlobalSecondaryIndex' {} Text
a -> ReplicaGlobalSecondaryIndex
s {$sel:indexName:ReplicaGlobalSecondaryIndex' :: Text
indexName = Text
a} :: ReplicaGlobalSecondaryIndex)

instance Prelude.Hashable ReplicaGlobalSecondaryIndex where
  hashWithSalt :: Int -> ReplicaGlobalSecondaryIndex -> Int
hashWithSalt Int
_salt ReplicaGlobalSecondaryIndex' {Maybe ProvisionedThroughputOverride
Text
indexName :: Text
provisionedThroughputOverride :: Maybe ProvisionedThroughputOverride
$sel:indexName:ReplicaGlobalSecondaryIndex' :: ReplicaGlobalSecondaryIndex -> Text
$sel:provisionedThroughputOverride:ReplicaGlobalSecondaryIndex' :: ReplicaGlobalSecondaryIndex -> Maybe ProvisionedThroughputOverride
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ProvisionedThroughputOverride
provisionedThroughputOverride
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
indexName

instance Prelude.NFData ReplicaGlobalSecondaryIndex where
  rnf :: ReplicaGlobalSecondaryIndex -> ()
rnf ReplicaGlobalSecondaryIndex' {Maybe ProvisionedThroughputOverride
Text
indexName :: Text
provisionedThroughputOverride :: Maybe ProvisionedThroughputOverride
$sel:indexName:ReplicaGlobalSecondaryIndex' :: ReplicaGlobalSecondaryIndex -> Text
$sel:provisionedThroughputOverride:ReplicaGlobalSecondaryIndex' :: ReplicaGlobalSecondaryIndex -> Maybe ProvisionedThroughputOverride
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ProvisionedThroughputOverride
provisionedThroughputOverride
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
indexName

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