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

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.BillingMode
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains the details for the read\/write capacity mode.
--
-- /See:/ 'newBillingModeSummary' smart constructor.
data BillingModeSummary = BillingModeSummary'
  { -- | Represents the time when @PAY_PER_REQUEST@ was last set as the
    -- read\/write capacity mode.
    BillingModeSummary -> Maybe POSIX
lastUpdateToPayPerRequestDateTime :: Prelude.Maybe Core.POSIX,
    -- | Controls how you are charged for read and write throughput and how you
    -- manage capacity. This setting can be changed later.
    --
    -- -   @PROVISIONED@ - Sets the read\/write capacity mode to @PROVISIONED@.
    --     We recommend using @PROVISIONED@ for predictable workloads.
    --
    -- -   @PAY_PER_REQUEST@ - Sets the read\/write capacity mode to
    --     @PAY_PER_REQUEST@. We recommend using @PAY_PER_REQUEST@ for
    --     unpredictable workloads.
    BillingModeSummary -> Maybe BillingMode
billingMode :: Prelude.Maybe BillingMode
  }
  deriving (BillingModeSummary -> BillingModeSummary -> Bool
(BillingModeSummary -> BillingModeSummary -> Bool)
-> (BillingModeSummary -> BillingModeSummary -> Bool)
-> Eq BillingModeSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BillingModeSummary -> BillingModeSummary -> Bool
$c/= :: BillingModeSummary -> BillingModeSummary -> Bool
== :: BillingModeSummary -> BillingModeSummary -> Bool
$c== :: BillingModeSummary -> BillingModeSummary -> Bool
Prelude.Eq, ReadPrec [BillingModeSummary]
ReadPrec BillingModeSummary
Int -> ReadS BillingModeSummary
ReadS [BillingModeSummary]
(Int -> ReadS BillingModeSummary)
-> ReadS [BillingModeSummary]
-> ReadPrec BillingModeSummary
-> ReadPrec [BillingModeSummary]
-> Read BillingModeSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BillingModeSummary]
$creadListPrec :: ReadPrec [BillingModeSummary]
readPrec :: ReadPrec BillingModeSummary
$creadPrec :: ReadPrec BillingModeSummary
readList :: ReadS [BillingModeSummary]
$creadList :: ReadS [BillingModeSummary]
readsPrec :: Int -> ReadS BillingModeSummary
$creadsPrec :: Int -> ReadS BillingModeSummary
Prelude.Read, Int -> BillingModeSummary -> ShowS
[BillingModeSummary] -> ShowS
BillingModeSummary -> String
(Int -> BillingModeSummary -> ShowS)
-> (BillingModeSummary -> String)
-> ([BillingModeSummary] -> ShowS)
-> Show BillingModeSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BillingModeSummary] -> ShowS
$cshowList :: [BillingModeSummary] -> ShowS
show :: BillingModeSummary -> String
$cshow :: BillingModeSummary -> String
showsPrec :: Int -> BillingModeSummary -> ShowS
$cshowsPrec :: Int -> BillingModeSummary -> ShowS
Prelude.Show, (forall x. BillingModeSummary -> Rep BillingModeSummary x)
-> (forall x. Rep BillingModeSummary x -> BillingModeSummary)
-> Generic BillingModeSummary
forall x. Rep BillingModeSummary x -> BillingModeSummary
forall x. BillingModeSummary -> Rep BillingModeSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BillingModeSummary x -> BillingModeSummary
$cfrom :: forall x. BillingModeSummary -> Rep BillingModeSummary x
Prelude.Generic)

-- |
-- Create a value of 'BillingModeSummary' 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:
--
-- 'lastUpdateToPayPerRequestDateTime', 'billingModeSummary_lastUpdateToPayPerRequestDateTime' - Represents the time when @PAY_PER_REQUEST@ was last set as the
-- read\/write capacity mode.
--
-- 'billingMode', 'billingModeSummary_billingMode' - Controls how you are charged for read and write throughput and how you
-- manage capacity. This setting can be changed later.
--
-- -   @PROVISIONED@ - Sets the read\/write capacity mode to @PROVISIONED@.
--     We recommend using @PROVISIONED@ for predictable workloads.
--
-- -   @PAY_PER_REQUEST@ - Sets the read\/write capacity mode to
--     @PAY_PER_REQUEST@. We recommend using @PAY_PER_REQUEST@ for
--     unpredictable workloads.
newBillingModeSummary ::
  BillingModeSummary
newBillingModeSummary :: BillingModeSummary
newBillingModeSummary =
  BillingModeSummary' :: Maybe POSIX -> Maybe BillingMode -> BillingModeSummary
BillingModeSummary'
    { $sel:lastUpdateToPayPerRequestDateTime:BillingModeSummary' :: Maybe POSIX
lastUpdateToPayPerRequestDateTime =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:billingMode:BillingModeSummary' :: Maybe BillingMode
billingMode = Maybe BillingMode
forall a. Maybe a
Prelude.Nothing
    }

-- | Represents the time when @PAY_PER_REQUEST@ was last set as the
-- read\/write capacity mode.
billingModeSummary_lastUpdateToPayPerRequestDateTime :: Lens.Lens' BillingModeSummary (Prelude.Maybe Prelude.UTCTime)
billingModeSummary_lastUpdateToPayPerRequestDateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> BillingModeSummary -> f BillingModeSummary
billingModeSummary_lastUpdateToPayPerRequestDateTime = (BillingModeSummary -> Maybe POSIX)
-> (BillingModeSummary -> Maybe POSIX -> BillingModeSummary)
-> Lens
     BillingModeSummary BillingModeSummary (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BillingModeSummary' {Maybe POSIX
lastUpdateToPayPerRequestDateTime :: Maybe POSIX
$sel:lastUpdateToPayPerRequestDateTime:BillingModeSummary' :: BillingModeSummary -> Maybe POSIX
lastUpdateToPayPerRequestDateTime} -> Maybe POSIX
lastUpdateToPayPerRequestDateTime) (\s :: BillingModeSummary
s@BillingModeSummary' {} Maybe POSIX
a -> BillingModeSummary
s {$sel:lastUpdateToPayPerRequestDateTime:BillingModeSummary' :: Maybe POSIX
lastUpdateToPayPerRequestDateTime = Maybe POSIX
a} :: BillingModeSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> BillingModeSummary -> f BillingModeSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> BillingModeSummary
-> f BillingModeSummary
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

-- | Controls how you are charged for read and write throughput and how you
-- manage capacity. This setting can be changed later.
--
-- -   @PROVISIONED@ - Sets the read\/write capacity mode to @PROVISIONED@.
--     We recommend using @PROVISIONED@ for predictable workloads.
--
-- -   @PAY_PER_REQUEST@ - Sets the read\/write capacity mode to
--     @PAY_PER_REQUEST@. We recommend using @PAY_PER_REQUEST@ for
--     unpredictable workloads.
billingModeSummary_billingMode :: Lens.Lens' BillingModeSummary (Prelude.Maybe BillingMode)
billingModeSummary_billingMode :: (Maybe BillingMode -> f (Maybe BillingMode))
-> BillingModeSummary -> f BillingModeSummary
billingModeSummary_billingMode = (BillingModeSummary -> Maybe BillingMode)
-> (BillingModeSummary -> Maybe BillingMode -> BillingModeSummary)
-> Lens
     BillingModeSummary
     BillingModeSummary
     (Maybe BillingMode)
     (Maybe BillingMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BillingModeSummary' {Maybe BillingMode
billingMode :: Maybe BillingMode
$sel:billingMode:BillingModeSummary' :: BillingModeSummary -> Maybe BillingMode
billingMode} -> Maybe BillingMode
billingMode) (\s :: BillingModeSummary
s@BillingModeSummary' {} Maybe BillingMode
a -> BillingModeSummary
s {$sel:billingMode:BillingModeSummary' :: Maybe BillingMode
billingMode = Maybe BillingMode
a} :: BillingModeSummary)

instance Core.FromJSON BillingModeSummary where
  parseJSON :: Value -> Parser BillingModeSummary
parseJSON =
    String
-> (Object -> Parser BillingModeSummary)
-> Value
-> Parser BillingModeSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BillingModeSummary"
      ( \Object
x ->
          Maybe POSIX -> Maybe BillingMode -> BillingModeSummary
BillingModeSummary'
            (Maybe POSIX -> Maybe BillingMode -> BillingModeSummary)
-> Parser (Maybe POSIX)
-> Parser (Maybe BillingMode -> BillingModeSummary)
forall (f :: * -> *) a b. Functor 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
"LastUpdateToPayPerRequestDateTime")
            Parser (Maybe BillingMode -> BillingModeSummary)
-> Parser (Maybe BillingMode) -> Parser BillingModeSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe BillingMode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BillingMode")
      )

instance Prelude.Hashable BillingModeSummary

instance Prelude.NFData BillingModeSummary