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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Replica-specific provisioned throughput settings. If not specified, uses
-- the source table\'s provisioned throughput settings.
--
-- /See:/ 'newProvisionedThroughputOverride' smart constructor.
data ProvisionedThroughputOverride = ProvisionedThroughputOverride'
  { -- | Replica-specific read capacity units. If not specified, uses the source
    -- table\'s read capacity settings.
    ProvisionedThroughputOverride -> Maybe Natural
readCapacityUnits :: Prelude.Maybe Prelude.Natural
  }
  deriving (ProvisionedThroughputOverride
-> ProvisionedThroughputOverride -> Bool
(ProvisionedThroughputOverride
 -> ProvisionedThroughputOverride -> Bool)
-> (ProvisionedThroughputOverride
    -> ProvisionedThroughputOverride -> Bool)
-> Eq ProvisionedThroughputOverride
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProvisionedThroughputOverride
-> ProvisionedThroughputOverride -> Bool
$c/= :: ProvisionedThroughputOverride
-> ProvisionedThroughputOverride -> Bool
== :: ProvisionedThroughputOverride
-> ProvisionedThroughputOverride -> Bool
$c== :: ProvisionedThroughputOverride
-> ProvisionedThroughputOverride -> Bool
Prelude.Eq, ReadPrec [ProvisionedThroughputOverride]
ReadPrec ProvisionedThroughputOverride
Int -> ReadS ProvisionedThroughputOverride
ReadS [ProvisionedThroughputOverride]
(Int -> ReadS ProvisionedThroughputOverride)
-> ReadS [ProvisionedThroughputOverride]
-> ReadPrec ProvisionedThroughputOverride
-> ReadPrec [ProvisionedThroughputOverride]
-> Read ProvisionedThroughputOverride
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProvisionedThroughputOverride]
$creadListPrec :: ReadPrec [ProvisionedThroughputOverride]
readPrec :: ReadPrec ProvisionedThroughputOverride
$creadPrec :: ReadPrec ProvisionedThroughputOverride
readList :: ReadS [ProvisionedThroughputOverride]
$creadList :: ReadS [ProvisionedThroughputOverride]
readsPrec :: Int -> ReadS ProvisionedThroughputOverride
$creadsPrec :: Int -> ReadS ProvisionedThroughputOverride
Prelude.Read, Int -> ProvisionedThroughputOverride -> ShowS
[ProvisionedThroughputOverride] -> ShowS
ProvisionedThroughputOverride -> String
(Int -> ProvisionedThroughputOverride -> ShowS)
-> (ProvisionedThroughputOverride -> String)
-> ([ProvisionedThroughputOverride] -> ShowS)
-> Show ProvisionedThroughputOverride
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProvisionedThroughputOverride] -> ShowS
$cshowList :: [ProvisionedThroughputOverride] -> ShowS
show :: ProvisionedThroughputOverride -> String
$cshow :: ProvisionedThroughputOverride -> String
showsPrec :: Int -> ProvisionedThroughputOverride -> ShowS
$cshowsPrec :: Int -> ProvisionedThroughputOverride -> ShowS
Prelude.Show, (forall x.
 ProvisionedThroughputOverride
 -> Rep ProvisionedThroughputOverride x)
-> (forall x.
    Rep ProvisionedThroughputOverride x
    -> ProvisionedThroughputOverride)
-> Generic ProvisionedThroughputOverride
forall x.
Rep ProvisionedThroughputOverride x
-> ProvisionedThroughputOverride
forall x.
ProvisionedThroughputOverride
-> Rep ProvisionedThroughputOverride x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ProvisionedThroughputOverride x
-> ProvisionedThroughputOverride
$cfrom :: forall x.
ProvisionedThroughputOverride
-> Rep ProvisionedThroughputOverride x
Prelude.Generic)

-- |
-- Create a value of 'ProvisionedThroughputOverride' 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:
--
-- 'readCapacityUnits', 'provisionedThroughputOverride_readCapacityUnits' - Replica-specific read capacity units. If not specified, uses the source
-- table\'s read capacity settings.
newProvisionedThroughputOverride ::
  ProvisionedThroughputOverride
newProvisionedThroughputOverride :: ProvisionedThroughputOverride
newProvisionedThroughputOverride =
  ProvisionedThroughputOverride' :: Maybe Natural -> ProvisionedThroughputOverride
ProvisionedThroughputOverride'
    { $sel:readCapacityUnits:ProvisionedThroughputOverride' :: Maybe Natural
readCapacityUnits =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Replica-specific read capacity units. If not specified, uses the source
-- table\'s read capacity settings.
provisionedThroughputOverride_readCapacityUnits :: Lens.Lens' ProvisionedThroughputOverride (Prelude.Maybe Prelude.Natural)
provisionedThroughputOverride_readCapacityUnits :: (Maybe Natural -> f (Maybe Natural))
-> ProvisionedThroughputOverride -> f ProvisionedThroughputOverride
provisionedThroughputOverride_readCapacityUnits = (ProvisionedThroughputOverride -> Maybe Natural)
-> (ProvisionedThroughputOverride
    -> Maybe Natural -> ProvisionedThroughputOverride)
-> Lens
     ProvisionedThroughputOverride
     ProvisionedThroughputOverride
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProvisionedThroughputOverride' {Maybe Natural
readCapacityUnits :: Maybe Natural
$sel:readCapacityUnits:ProvisionedThroughputOverride' :: ProvisionedThroughputOverride -> Maybe Natural
readCapacityUnits} -> Maybe Natural
readCapacityUnits) (\s :: ProvisionedThroughputOverride
s@ProvisionedThroughputOverride' {} Maybe Natural
a -> ProvisionedThroughputOverride
s {$sel:readCapacityUnits:ProvisionedThroughputOverride' :: Maybe Natural
readCapacityUnits = Maybe Natural
a} :: ProvisionedThroughputOverride)

instance Core.FromJSON ProvisionedThroughputOverride where
  parseJSON :: Value -> Parser ProvisionedThroughputOverride
parseJSON =
    String
-> (Object -> Parser ProvisionedThroughputOverride)
-> Value
-> Parser ProvisionedThroughputOverride
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ProvisionedThroughputOverride"
      ( \Object
x ->
          Maybe Natural -> ProvisionedThroughputOverride
ProvisionedThroughputOverride'
            (Maybe Natural -> ProvisionedThroughputOverride)
-> Parser (Maybe Natural) -> Parser ProvisionedThroughputOverride
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ReadCapacityUnits")
      )

instance
  Prelude.Hashable
    ProvisionedThroughputOverride

instance Prelude.NFData ProvisionedThroughputOverride

instance Core.ToJSON ProvisionedThroughputOverride where
  toJSON :: ProvisionedThroughputOverride -> Value
toJSON ProvisionedThroughputOverride' {Maybe Natural
readCapacityUnits :: Maybe Natural
$sel:readCapacityUnits:ProvisionedThroughputOverride' :: ProvisionedThroughputOverride -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ReadCapacityUnits" 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
readCapacityUnits
          ]
      )