{-# 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-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.ProvisionedThroughputDescription 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.WriteRequest
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 date and time of the last provisioned throughput decrease for this
    -- table.
    ProvisionedThroughputDescription -> Maybe POSIX
lastDecreaseDateTime :: Prelude.Maybe Data.POSIX,
    -- | The date and time of the last provisioned throughput increase for this
    -- table.
    ProvisionedThroughputDescription -> Maybe POSIX
lastIncreaseDateTime :: Prelude.Maybe Data.POSIX,
    -- | 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 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 maximum number of writes consumed per second before DynamoDB returns
    -- a @ThrottlingException@.
    ProvisionedThroughputDescription -> Maybe Natural
writeCapacityUnits :: Prelude.Maybe Prelude.Natural
  }
  deriving (ProvisionedThroughputDescription
-> ProvisionedThroughputDescription -> Bool
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]
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
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.
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:
--
-- 'lastDecreaseDateTime', 'provisionedThroughputDescription_lastDecreaseDateTime' - The date and time of the last provisioned throughput decrease for this
-- table.
--
-- 'lastIncreaseDateTime', 'provisionedThroughputDescription_lastIncreaseDateTime' - The date and time of the last provisioned throughput increase for this
-- table.
--
-- '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/.
--
-- '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.
--
-- 'writeCapacityUnits', 'provisionedThroughputDescription_writeCapacityUnits' - The maximum number of writes consumed per second before DynamoDB returns
-- a @ThrottlingException@.
newProvisionedThroughputDescription ::
  ProvisionedThroughputDescription
newProvisionedThroughputDescription :: ProvisionedThroughputDescription
newProvisionedThroughputDescription =
  ProvisionedThroughputDescription'
    { $sel:lastDecreaseDateTime:ProvisionedThroughputDescription' :: Maybe POSIX
lastDecreaseDateTime =
        forall a. Maybe a
Prelude.Nothing,
      $sel:lastIncreaseDateTime:ProvisionedThroughputDescription' :: Maybe POSIX
lastIncreaseDateTime = forall a. Maybe a
Prelude.Nothing,
      $sel:numberOfDecreasesToday:ProvisionedThroughputDescription' :: Maybe Natural
numberOfDecreasesToday = forall a. Maybe a
Prelude.Nothing,
      $sel:readCapacityUnits:ProvisionedThroughputDescription' :: Maybe Natural
readCapacityUnits = forall a. Maybe a
Prelude.Nothing,
      $sel:writeCapacityUnits:ProvisionedThroughputDescription' :: Maybe Natural
writeCapacityUnits = forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time of the last provisioned throughput decrease for this
-- table.
provisionedThroughputDescription_lastDecreaseDateTime :: Lens.Lens' ProvisionedThroughputDescription (Prelude.Maybe Prelude.UTCTime)
provisionedThroughputDescription_lastDecreaseDateTime :: Lens' ProvisionedThroughputDescription (Maybe UTCTime)
provisionedThroughputDescription_lastDecreaseDateTime = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The date and time of the last provisioned throughput increase for this
-- table.
provisionedThroughputDescription_lastIncreaseDateTime :: Lens.Lens' ProvisionedThroughputDescription (Prelude.Maybe Prelude.UTCTime)
provisionedThroughputDescription_lastIncreaseDateTime :: Lens' ProvisionedThroughputDescription (Maybe UTCTime)
provisionedThroughputDescription_lastIncreaseDateTime = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | 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 :: Lens' ProvisionedThroughputDescription (Maybe Natural)
provisionedThroughputDescription_numberOfDecreasesToday = 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 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 :: Lens' ProvisionedThroughputDescription (Maybe Natural)
provisionedThroughputDescription_readCapacityUnits = 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 maximum number of writes consumed per second before DynamoDB returns
-- a @ThrottlingException@.
provisionedThroughputDescription_writeCapacityUnits :: Lens.Lens' ProvisionedThroughputDescription (Prelude.Maybe Prelude.Natural)
provisionedThroughputDescription_writeCapacityUnits :: Lens' ProvisionedThroughputDescription (Maybe Natural)
provisionedThroughputDescription_writeCapacityUnits = 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)

instance
  Data.FromJSON
    ProvisionedThroughputDescription
  where
  parseJSON :: Value -> Parser ProvisionedThroughputDescription
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ProvisionedThroughputDescription"
      ( \Object
x ->
          Maybe POSIX
-> Maybe POSIX
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> ProvisionedThroughputDescription
ProvisionedThroughputDescription'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"LastDecreaseDateTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"LastIncreaseDateTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"NumberOfDecreasesToday")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ReadCapacityUnits")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"WriteCapacityUnits")
      )

instance
  Prelude.Hashable
    ProvisionedThroughputDescription
  where
  hashWithSalt :: Int -> ProvisionedThroughputDescription -> Int
hashWithSalt
    Int
_salt
    ProvisionedThroughputDescription' {Maybe Natural
Maybe POSIX
writeCapacityUnits :: Maybe Natural
readCapacityUnits :: Maybe Natural
numberOfDecreasesToday :: Maybe Natural
lastIncreaseDateTime :: Maybe POSIX
lastDecreaseDateTime :: Maybe POSIX
$sel:writeCapacityUnits:ProvisionedThroughputDescription' :: ProvisionedThroughputDescription -> Maybe Natural
$sel:readCapacityUnits:ProvisionedThroughputDescription' :: ProvisionedThroughputDescription -> Maybe Natural
$sel:numberOfDecreasesToday:ProvisionedThroughputDescription' :: ProvisionedThroughputDescription -> Maybe Natural
$sel:lastIncreaseDateTime:ProvisionedThroughputDescription' :: ProvisionedThroughputDescription -> Maybe POSIX
$sel:lastDecreaseDateTime:ProvisionedThroughputDescription' :: ProvisionedThroughputDescription -> Maybe POSIX
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastDecreaseDateTime
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastIncreaseDateTime
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
numberOfDecreasesToday
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
readCapacityUnits
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
writeCapacityUnits

instance
  Prelude.NFData
    ProvisionedThroughputDescription
  where
  rnf :: ProvisionedThroughputDescription -> ()
rnf ProvisionedThroughputDescription' {Maybe Natural
Maybe POSIX
writeCapacityUnits :: Maybe Natural
readCapacityUnits :: Maybe Natural
numberOfDecreasesToday :: Maybe Natural
lastIncreaseDateTime :: Maybe POSIX
lastDecreaseDateTime :: Maybe POSIX
$sel:writeCapacityUnits:ProvisionedThroughputDescription' :: ProvisionedThroughputDescription -> Maybe Natural
$sel:readCapacityUnits:ProvisionedThroughputDescription' :: ProvisionedThroughputDescription -> Maybe Natural
$sel:numberOfDecreasesToday:ProvisionedThroughputDescription' :: ProvisionedThroughputDescription -> Maybe Natural
$sel:lastIncreaseDateTime:ProvisionedThroughputDescription' :: ProvisionedThroughputDescription -> Maybe POSIX
$sel:lastDecreaseDateTime:ProvisionedThroughputDescription' :: ProvisionedThroughputDescription -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastDecreaseDateTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastIncreaseDateTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
numberOfDecreasesToday
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
readCapacityUnits
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
writeCapacityUnits