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

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.ProvisionedThroughputOverride
import qualified Amazonka.Lens as Lens
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
(ReplicaGlobalSecondaryIndex
 -> ReplicaGlobalSecondaryIndex -> Bool)
-> (ReplicaGlobalSecondaryIndex
    -> ReplicaGlobalSecondaryIndex -> Bool)
-> Eq ReplicaGlobalSecondaryIndex
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]
(Int -> ReadS ReplicaGlobalSecondaryIndex)
-> ReadS [ReplicaGlobalSecondaryIndex]
-> ReadPrec ReplicaGlobalSecondaryIndex
-> ReadPrec [ReplicaGlobalSecondaryIndex]
-> Read 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
(Int -> ReplicaGlobalSecondaryIndex -> ShowS)
-> (ReplicaGlobalSecondaryIndex -> String)
-> ([ReplicaGlobalSecondaryIndex] -> ShowS)
-> Show ReplicaGlobalSecondaryIndex
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.
 ReplicaGlobalSecondaryIndex -> Rep ReplicaGlobalSecondaryIndex x)
-> (forall x.
    Rep ReplicaGlobalSecondaryIndex x -> ReplicaGlobalSecondaryIndex)
-> Generic ReplicaGlobalSecondaryIndex
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' :: Maybe ProvisionedThroughputOverride
-> Text -> ReplicaGlobalSecondaryIndex
ReplicaGlobalSecondaryIndex'
    { $sel:provisionedThroughputOverride:ReplicaGlobalSecondaryIndex' :: Maybe ProvisionedThroughputOverride
provisionedThroughputOverride =
        Maybe 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 :: (Maybe ProvisionedThroughputOverride
 -> f (Maybe ProvisionedThroughputOverride))
-> ReplicaGlobalSecondaryIndex -> f ReplicaGlobalSecondaryIndex
replicaGlobalSecondaryIndex_provisionedThroughputOverride = (ReplicaGlobalSecondaryIndex
 -> Maybe ProvisionedThroughputOverride)
-> (ReplicaGlobalSecondaryIndex
    -> Maybe ProvisionedThroughputOverride
    -> ReplicaGlobalSecondaryIndex)
-> Lens
     ReplicaGlobalSecondaryIndex
     ReplicaGlobalSecondaryIndex
     (Maybe ProvisionedThroughputOverride)
     (Maybe 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 :: (Text -> f Text)
-> ReplicaGlobalSecondaryIndex -> f ReplicaGlobalSecondaryIndex
replicaGlobalSecondaryIndex_indexName = (ReplicaGlobalSecondaryIndex -> Text)
-> (ReplicaGlobalSecondaryIndex
    -> Text -> ReplicaGlobalSecondaryIndex)
-> Lens
     ReplicaGlobalSecondaryIndex ReplicaGlobalSecondaryIndex Text Text
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

instance Prelude.NFData ReplicaGlobalSecondaryIndex

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ProvisionedThroughputOverride" Text -> ProvisionedThroughputOverride -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ProvisionedThroughputOverride -> Pair)
-> Maybe ProvisionedThroughputOverride -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ProvisionedThroughputOverride
provisionedThroughputOverride,
            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)
          ]
      )