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

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

-- | Represents the provisioned throughput settings for the table, consisting
-- of read and write capacity units, along with data about increases and
-- decreases.
--
-- /See:/ 'newProvisionedThroughputDescription' smart constructor.
data ProvisionedThroughputDescription = ProvisionedThroughputDescription'
  { -- | The maximum number of strongly consistent reads consumed per second
    -- before DynamoDB returns a @ThrottlingException@. Eventually consistent
    -- reads require less effort than strongly consistent reads, so a setting
    -- of 50 @ReadCapacityUnits@ per second provides 100 eventually consistent
    -- @ReadCapacityUnits@ per second.
    ProvisionedThroughputDescription -> Maybe Natural
readCapacityUnits :: Prelude.Maybe Prelude.Natural,
    -- | The date and time of the last provisioned throughput decrease for this
    -- table.
    ProvisionedThroughputDescription -> Maybe POSIX
lastDecreaseDateTime :: Prelude.Maybe Core.POSIX,
    -- | The maximum number of writes consumed per second before DynamoDB returns
    -- a @ThrottlingException@.
    ProvisionedThroughputDescription -> Maybe Natural
writeCapacityUnits :: Prelude.Maybe Prelude.Natural,
    -- | The number of provisioned throughput decreases for this table during
    -- this UTC calendar day. For current maximums on provisioned throughput
    -- decreases, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html Service, Account, and Table Quotas>
    -- in the /Amazon DynamoDB Developer Guide/.
    ProvisionedThroughputDescription -> Maybe Natural
numberOfDecreasesToday :: Prelude.Maybe Prelude.Natural,
    -- | The date and time of the last provisioned throughput increase for this
    -- table.
    ProvisionedThroughputDescription -> Maybe POSIX
lastIncreaseDateTime :: Prelude.Maybe Core.POSIX
  }
  deriving (ProvisionedThroughputDescription
-> ProvisionedThroughputDescription -> Bool
(ProvisionedThroughputDescription
 -> ProvisionedThroughputDescription -> Bool)
-> (ProvisionedThroughputDescription
    -> ProvisionedThroughputDescription -> Bool)
-> Eq ProvisionedThroughputDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProvisionedThroughputDescription
-> ProvisionedThroughputDescription -> Bool
$c/= :: ProvisionedThroughputDescription
-> ProvisionedThroughputDescription -> Bool
== :: ProvisionedThroughputDescription
-> ProvisionedThroughputDescription -> Bool
$c== :: ProvisionedThroughputDescription
-> ProvisionedThroughputDescription -> Bool
Prelude.Eq, ReadPrec [ProvisionedThroughputDescription]
ReadPrec ProvisionedThroughputDescription
Int -> ReadS ProvisionedThroughputDescription
ReadS [ProvisionedThroughputDescription]
(Int -> ReadS ProvisionedThroughputDescription)
-> ReadS [ProvisionedThroughputDescription]
-> ReadPrec ProvisionedThroughputDescription
-> ReadPrec [ProvisionedThroughputDescription]
-> Read ProvisionedThroughputDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProvisionedThroughputDescription]
$creadListPrec :: ReadPrec [ProvisionedThroughputDescription]
readPrec :: ReadPrec ProvisionedThroughputDescription
$creadPrec :: ReadPrec ProvisionedThroughputDescription
readList :: ReadS [ProvisionedThroughputDescription]
$creadList :: ReadS [ProvisionedThroughputDescription]
readsPrec :: Int -> ReadS ProvisionedThroughputDescription
$creadsPrec :: Int -> ReadS ProvisionedThroughputDescription
Prelude.Read, Int -> ProvisionedThroughputDescription -> ShowS
[ProvisionedThroughputDescription] -> ShowS
ProvisionedThroughputDescription -> String
(Int -> ProvisionedThroughputDescription -> ShowS)
-> (ProvisionedThroughputDescription -> String)
-> ([ProvisionedThroughputDescription] -> ShowS)
-> Show ProvisionedThroughputDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProvisionedThroughputDescription] -> ShowS
$cshowList :: [ProvisionedThroughputDescription] -> ShowS
show :: ProvisionedThroughputDescription -> String
$cshow :: ProvisionedThroughputDescription -> String
showsPrec :: Int -> ProvisionedThroughputDescription -> ShowS
$cshowsPrec :: Int -> ProvisionedThroughputDescription -> ShowS
Prelude.Show, (forall x.
 ProvisionedThroughputDescription
 -> Rep ProvisionedThroughputDescription x)
-> (forall x.
    Rep ProvisionedThroughputDescription x
    -> ProvisionedThroughputDescription)
-> Generic ProvisionedThroughputDescription
forall x.
Rep ProvisionedThroughputDescription x
-> ProvisionedThroughputDescription
forall x.
ProvisionedThroughputDescription
-> Rep ProvisionedThroughputDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ProvisionedThroughputDescription x
-> ProvisionedThroughputDescription
$cfrom :: forall x.
ProvisionedThroughputDescription
-> Rep ProvisionedThroughputDescription x
Prelude.Generic)

-- |
-- Create a value of 'ProvisionedThroughputDescription' 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', 'provisionedThroughputDescription_readCapacityUnits' - The maximum number of strongly consistent reads consumed per second
-- before DynamoDB returns a @ThrottlingException@. Eventually consistent
-- reads require less effort than strongly consistent reads, so a setting
-- of 50 @ReadCapacityUnits@ per second provides 100 eventually consistent
-- @ReadCapacityUnits@ per second.
--
-- 'lastDecreaseDateTime', 'provisionedThroughputDescription_lastDecreaseDateTime' - The date and time of the last provisioned throughput decrease for this
-- table.
--
-- 'writeCapacityUnits', 'provisionedThroughputDescription_writeCapacityUnits' - The maximum number of writes consumed per second before DynamoDB returns
-- a @ThrottlingException@.
--
-- 'numberOfDecreasesToday', 'provisionedThroughputDescription_numberOfDecreasesToday' - The number of provisioned throughput decreases for this table during
-- this UTC calendar day. For current maximums on provisioned throughput
-- decreases, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html Service, Account, and Table Quotas>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- 'lastIncreaseDateTime', 'provisionedThroughputDescription_lastIncreaseDateTime' - The date and time of the last provisioned throughput increase for this
-- table.
newProvisionedThroughputDescription ::
  ProvisionedThroughputDescription
newProvisionedThroughputDescription :: ProvisionedThroughputDescription
newProvisionedThroughputDescription =
  ProvisionedThroughputDescription' :: Maybe Natural
-> Maybe POSIX
-> Maybe Natural
-> Maybe Natural
-> Maybe POSIX
-> ProvisionedThroughputDescription
ProvisionedThroughputDescription'
    { $sel:readCapacityUnits:ProvisionedThroughputDescription' :: Maybe Natural
readCapacityUnits =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:lastDecreaseDateTime:ProvisionedThroughputDescription' :: Maybe POSIX
lastDecreaseDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:writeCapacityUnits:ProvisionedThroughputDescription' :: Maybe Natural
writeCapacityUnits = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:numberOfDecreasesToday:ProvisionedThroughputDescription' :: Maybe Natural
numberOfDecreasesToday = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:lastIncreaseDateTime:ProvisionedThroughputDescription' :: Maybe POSIX
lastIncreaseDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of strongly consistent reads consumed per second
-- before DynamoDB returns a @ThrottlingException@. Eventually consistent
-- reads require less effort than strongly consistent reads, so a setting
-- of 50 @ReadCapacityUnits@ per second provides 100 eventually consistent
-- @ReadCapacityUnits@ per second.
provisionedThroughputDescription_readCapacityUnits :: Lens.Lens' ProvisionedThroughputDescription (Prelude.Maybe Prelude.Natural)
provisionedThroughputDescription_readCapacityUnits :: (Maybe Natural -> f (Maybe Natural))
-> ProvisionedThroughputDescription
-> f ProvisionedThroughputDescription
provisionedThroughputDescription_readCapacityUnits = (ProvisionedThroughputDescription -> Maybe Natural)
-> (ProvisionedThroughputDescription
    -> Maybe Natural -> ProvisionedThroughputDescription)
-> Lens
     ProvisionedThroughputDescription
     ProvisionedThroughputDescription
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProvisionedThroughputDescription' {Maybe Natural
readCapacityUnits :: Maybe Natural
$sel:readCapacityUnits:ProvisionedThroughputDescription' :: ProvisionedThroughputDescription -> Maybe Natural
readCapacityUnits} -> Maybe Natural
readCapacityUnits) (\s :: ProvisionedThroughputDescription
s@ProvisionedThroughputDescription' {} Maybe Natural
a -> ProvisionedThroughputDescription
s {$sel:readCapacityUnits:ProvisionedThroughputDescription' :: Maybe Natural
readCapacityUnits = Maybe Natural
a} :: ProvisionedThroughputDescription)

-- | The date and time of the last provisioned throughput decrease for this
-- table.
provisionedThroughputDescription_lastDecreaseDateTime :: Lens.Lens' ProvisionedThroughputDescription (Prelude.Maybe Prelude.UTCTime)
provisionedThroughputDescription_lastDecreaseDateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ProvisionedThroughputDescription
-> f ProvisionedThroughputDescription
provisionedThroughputDescription_lastDecreaseDateTime = (ProvisionedThroughputDescription -> Maybe POSIX)
-> (ProvisionedThroughputDescription
    -> Maybe POSIX -> ProvisionedThroughputDescription)
-> Lens
     ProvisionedThroughputDescription
     ProvisionedThroughputDescription
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProvisionedThroughputDescription' {Maybe POSIX
lastDecreaseDateTime :: Maybe POSIX
$sel:lastDecreaseDateTime:ProvisionedThroughputDescription' :: ProvisionedThroughputDescription -> Maybe POSIX
lastDecreaseDateTime} -> Maybe POSIX
lastDecreaseDateTime) (\s :: ProvisionedThroughputDescription
s@ProvisionedThroughputDescription' {} Maybe POSIX
a -> ProvisionedThroughputDescription
s {$sel:lastDecreaseDateTime:ProvisionedThroughputDescription' :: Maybe POSIX
lastDecreaseDateTime = Maybe POSIX
a} :: ProvisionedThroughputDescription) ((Maybe POSIX -> f (Maybe POSIX))
 -> ProvisionedThroughputDescription
 -> f ProvisionedThroughputDescription)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ProvisionedThroughputDescription
-> f ProvisionedThroughputDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The maximum number of writes consumed per second before DynamoDB returns
-- a @ThrottlingException@.
provisionedThroughputDescription_writeCapacityUnits :: Lens.Lens' ProvisionedThroughputDescription (Prelude.Maybe Prelude.Natural)
provisionedThroughputDescription_writeCapacityUnits :: (Maybe Natural -> f (Maybe Natural))
-> ProvisionedThroughputDescription
-> f ProvisionedThroughputDescription
provisionedThroughputDescription_writeCapacityUnits = (ProvisionedThroughputDescription -> Maybe Natural)
-> (ProvisionedThroughputDescription
    -> Maybe Natural -> ProvisionedThroughputDescription)
-> Lens
     ProvisionedThroughputDescription
     ProvisionedThroughputDescription
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProvisionedThroughputDescription' {Maybe Natural
writeCapacityUnits :: Maybe Natural
$sel:writeCapacityUnits:ProvisionedThroughputDescription' :: ProvisionedThroughputDescription -> Maybe Natural
writeCapacityUnits} -> Maybe Natural
writeCapacityUnits) (\s :: ProvisionedThroughputDescription
s@ProvisionedThroughputDescription' {} Maybe Natural
a -> ProvisionedThroughputDescription
s {$sel:writeCapacityUnits:ProvisionedThroughputDescription' :: Maybe Natural
writeCapacityUnits = Maybe Natural
a} :: ProvisionedThroughputDescription)

-- | The number of provisioned throughput decreases for this table during
-- this UTC calendar day. For current maximums on provisioned throughput
-- decreases, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html Service, Account, and Table Quotas>
-- in the /Amazon DynamoDB Developer Guide/.
provisionedThroughputDescription_numberOfDecreasesToday :: Lens.Lens' ProvisionedThroughputDescription (Prelude.Maybe Prelude.Natural)
provisionedThroughputDescription_numberOfDecreasesToday :: (Maybe Natural -> f (Maybe Natural))
-> ProvisionedThroughputDescription
-> f ProvisionedThroughputDescription
provisionedThroughputDescription_numberOfDecreasesToday = (ProvisionedThroughputDescription -> Maybe Natural)
-> (ProvisionedThroughputDescription
    -> Maybe Natural -> ProvisionedThroughputDescription)
-> Lens
     ProvisionedThroughputDescription
     ProvisionedThroughputDescription
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProvisionedThroughputDescription' {Maybe Natural
numberOfDecreasesToday :: Maybe Natural
$sel:numberOfDecreasesToday:ProvisionedThroughputDescription' :: ProvisionedThroughputDescription -> Maybe Natural
numberOfDecreasesToday} -> Maybe Natural
numberOfDecreasesToday) (\s :: ProvisionedThroughputDescription
s@ProvisionedThroughputDescription' {} Maybe Natural
a -> ProvisionedThroughputDescription
s {$sel:numberOfDecreasesToday:ProvisionedThroughputDescription' :: Maybe Natural
numberOfDecreasesToday = Maybe Natural
a} :: ProvisionedThroughputDescription)

-- | The date and time of the last provisioned throughput increase for this
-- table.
provisionedThroughputDescription_lastIncreaseDateTime :: Lens.Lens' ProvisionedThroughputDescription (Prelude.Maybe Prelude.UTCTime)
provisionedThroughputDescription_lastIncreaseDateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ProvisionedThroughputDescription
-> f ProvisionedThroughputDescription
provisionedThroughputDescription_lastIncreaseDateTime = (ProvisionedThroughputDescription -> Maybe POSIX)
-> (ProvisionedThroughputDescription
    -> Maybe POSIX -> ProvisionedThroughputDescription)
-> Lens
     ProvisionedThroughputDescription
     ProvisionedThroughputDescription
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProvisionedThroughputDescription' {Maybe POSIX
lastIncreaseDateTime :: Maybe POSIX
$sel:lastIncreaseDateTime:ProvisionedThroughputDescription' :: ProvisionedThroughputDescription -> Maybe POSIX
lastIncreaseDateTime} -> Maybe POSIX
lastIncreaseDateTime) (\s :: ProvisionedThroughputDescription
s@ProvisionedThroughputDescription' {} Maybe POSIX
a -> ProvisionedThroughputDescription
s {$sel:lastIncreaseDateTime:ProvisionedThroughputDescription' :: Maybe POSIX
lastIncreaseDateTime = Maybe POSIX
a} :: ProvisionedThroughputDescription) ((Maybe POSIX -> f (Maybe POSIX))
 -> ProvisionedThroughputDescription
 -> f ProvisionedThroughputDescription)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ProvisionedThroughputDescription
-> f ProvisionedThroughputDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance
  Core.FromJSON
    ProvisionedThroughputDescription
  where
  parseJSON :: Value -> Parser ProvisionedThroughputDescription
parseJSON =
    String
-> (Object -> Parser ProvisionedThroughputDescription)
-> Value
-> Parser ProvisionedThroughputDescription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ProvisionedThroughputDescription"
      ( \Object
x ->
          Maybe Natural
-> Maybe POSIX
-> Maybe Natural
-> Maybe Natural
-> Maybe POSIX
-> ProvisionedThroughputDescription
ProvisionedThroughputDescription'
            (Maybe Natural
 -> Maybe POSIX
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe POSIX
 -> ProvisionedThroughputDescription)
-> Parser (Maybe Natural)
-> Parser
     (Maybe POSIX
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe POSIX
      -> ProvisionedThroughputDescription)
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")
            Parser
  (Maybe POSIX
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe POSIX
   -> ProvisionedThroughputDescription)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Natural
      -> Maybe Natural
      -> Maybe POSIX
      -> ProvisionedThroughputDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LastDecreaseDateTime")
            Parser
  (Maybe Natural
   -> Maybe Natural
   -> Maybe POSIX
   -> ProvisionedThroughputDescription)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural -> Maybe POSIX -> ProvisionedThroughputDescription)
forall (f :: * -> *) a b. Applicative f => 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
"WriteCapacityUnits")
            Parser
  (Maybe Natural -> Maybe POSIX -> ProvisionedThroughputDescription)
-> Parser (Maybe Natural)
-> Parser (Maybe POSIX -> ProvisionedThroughputDescription)
forall (f :: * -> *) a b. Applicative f => 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
"NumberOfDecreasesToday")
            Parser (Maybe POSIX -> ProvisionedThroughputDescription)
-> Parser (Maybe POSIX) -> Parser ProvisionedThroughputDescription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LastIncreaseDateTime")
      )

instance
  Prelude.Hashable
    ProvisionedThroughputDescription

instance
  Prelude.NFData
    ProvisionedThroughputDescription