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

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

-- | Represents the amount of provisioned throughput capacity consumed on a
-- table or an index.
--
-- /See:/ 'newCapacity' smart constructor.
data Capacity = Capacity'
  { -- | The total number of read capacity units consumed on a table or an index.
    Capacity -> Maybe Double
readCapacityUnits :: Prelude.Maybe Prelude.Double,
    -- | The total number of capacity units consumed on a table or an index.
    Capacity -> Maybe Double
capacityUnits :: Prelude.Maybe Prelude.Double,
    -- | The total number of write capacity units consumed on a table or an
    -- index.
    Capacity -> Maybe Double
writeCapacityUnits :: Prelude.Maybe Prelude.Double
  }
  deriving (Capacity -> Capacity -> Bool
(Capacity -> Capacity -> Bool)
-> (Capacity -> Capacity -> Bool) -> Eq Capacity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Capacity -> Capacity -> Bool
$c/= :: Capacity -> Capacity -> Bool
== :: Capacity -> Capacity -> Bool
$c== :: Capacity -> Capacity -> Bool
Prelude.Eq, ReadPrec [Capacity]
ReadPrec Capacity
Int -> ReadS Capacity
ReadS [Capacity]
(Int -> ReadS Capacity)
-> ReadS [Capacity]
-> ReadPrec Capacity
-> ReadPrec [Capacity]
-> Read Capacity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Capacity]
$creadListPrec :: ReadPrec [Capacity]
readPrec :: ReadPrec Capacity
$creadPrec :: ReadPrec Capacity
readList :: ReadS [Capacity]
$creadList :: ReadS [Capacity]
readsPrec :: Int -> ReadS Capacity
$creadsPrec :: Int -> ReadS Capacity
Prelude.Read, Int -> Capacity -> ShowS
[Capacity] -> ShowS
Capacity -> String
(Int -> Capacity -> ShowS)
-> (Capacity -> String) -> ([Capacity] -> ShowS) -> Show Capacity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Capacity] -> ShowS
$cshowList :: [Capacity] -> ShowS
show :: Capacity -> String
$cshow :: Capacity -> String
showsPrec :: Int -> Capacity -> ShowS
$cshowsPrec :: Int -> Capacity -> ShowS
Prelude.Show, (forall x. Capacity -> Rep Capacity x)
-> (forall x. Rep Capacity x -> Capacity) -> Generic Capacity
forall x. Rep Capacity x -> Capacity
forall x. Capacity -> Rep Capacity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Capacity x -> Capacity
$cfrom :: forall x. Capacity -> Rep Capacity x
Prelude.Generic)

-- |
-- Create a value of 'Capacity' 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', 'capacity_readCapacityUnits' - The total number of read capacity units consumed on a table or an index.
--
-- 'capacityUnits', 'capacity_capacityUnits' - The total number of capacity units consumed on a table or an index.
--
-- 'writeCapacityUnits', 'capacity_writeCapacityUnits' - The total number of write capacity units consumed on a table or an
-- index.
newCapacity ::
  Capacity
newCapacity :: Capacity
newCapacity =
  Capacity' :: Maybe Double -> Maybe Double -> Maybe Double -> Capacity
Capacity'
    { $sel:readCapacityUnits:Capacity' :: Maybe Double
readCapacityUnits = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:capacityUnits:Capacity' :: Maybe Double
capacityUnits = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:writeCapacityUnits:Capacity' :: Maybe Double
writeCapacityUnits = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | The total number of read capacity units consumed on a table or an index.
capacity_readCapacityUnits :: Lens.Lens' Capacity (Prelude.Maybe Prelude.Double)
capacity_readCapacityUnits :: (Maybe Double -> f (Maybe Double)) -> Capacity -> f Capacity
capacity_readCapacityUnits = (Capacity -> Maybe Double)
-> (Capacity -> Maybe Double -> Capacity)
-> Lens Capacity Capacity (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Capacity' {Maybe Double
readCapacityUnits :: Maybe Double
$sel:readCapacityUnits:Capacity' :: Capacity -> Maybe Double
readCapacityUnits} -> Maybe Double
readCapacityUnits) (\s :: Capacity
s@Capacity' {} Maybe Double
a -> Capacity
s {$sel:readCapacityUnits:Capacity' :: Maybe Double
readCapacityUnits = Maybe Double
a} :: Capacity)

-- | The total number of capacity units consumed on a table or an index.
capacity_capacityUnits :: Lens.Lens' Capacity (Prelude.Maybe Prelude.Double)
capacity_capacityUnits :: (Maybe Double -> f (Maybe Double)) -> Capacity -> f Capacity
capacity_capacityUnits = (Capacity -> Maybe Double)
-> (Capacity -> Maybe Double -> Capacity)
-> Lens Capacity Capacity (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Capacity' {Maybe Double
capacityUnits :: Maybe Double
$sel:capacityUnits:Capacity' :: Capacity -> Maybe Double
capacityUnits} -> Maybe Double
capacityUnits) (\s :: Capacity
s@Capacity' {} Maybe Double
a -> Capacity
s {$sel:capacityUnits:Capacity' :: Maybe Double
capacityUnits = Maybe Double
a} :: Capacity)

-- | The total number of write capacity units consumed on a table or an
-- index.
capacity_writeCapacityUnits :: Lens.Lens' Capacity (Prelude.Maybe Prelude.Double)
capacity_writeCapacityUnits :: (Maybe Double -> f (Maybe Double)) -> Capacity -> f Capacity
capacity_writeCapacityUnits = (Capacity -> Maybe Double)
-> (Capacity -> Maybe Double -> Capacity)
-> Lens Capacity Capacity (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Capacity' {Maybe Double
writeCapacityUnits :: Maybe Double
$sel:writeCapacityUnits:Capacity' :: Capacity -> Maybe Double
writeCapacityUnits} -> Maybe Double
writeCapacityUnits) (\s :: Capacity
s@Capacity' {} Maybe Double
a -> Capacity
s {$sel:writeCapacityUnits:Capacity' :: Maybe Double
writeCapacityUnits = Maybe Double
a} :: Capacity)

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

instance Prelude.Hashable Capacity

instance Prelude.NFData Capacity