{-# 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.KeySpaces.Types.CapacitySpecification
-- 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.KeySpaces.Types.CapacitySpecification where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.KeySpaces.Types.ThroughputMode
import qualified Amazonka.Prelude as Prelude

-- | Amazon Keyspaces has two read\/write capacity modes for processing reads
-- and writes on your tables:
--
-- • On-demand (default)
--
-- • Provisioned
--
-- The read\/write capacity mode that you choose controls how you are
-- charged for read and write throughput and how table throughput capacity
-- is managed.
--
-- For more information, see
-- <https://docs.aws.amazon.com/keyspaces/latest/devguide/ReadWriteCapacityMode.html Read\/write capacity modes>
-- in the /Amazon Keyspaces Developer Guide/.
--
-- /See:/ 'newCapacitySpecification' smart constructor.
data CapacitySpecification = CapacitySpecification'
  { -- | The throughput capacity specified for @read@ operations defined in
    -- @read capacity units@ @(RCUs)@.
    CapacitySpecification -> Maybe Natural
readCapacityUnits :: Prelude.Maybe Prelude.Natural,
    -- | The throughput capacity specified for @write@ operations defined in
    -- @write capacity units@ @(WCUs)@.
    CapacitySpecification -> Maybe Natural
writeCapacityUnits :: Prelude.Maybe Prelude.Natural,
    -- | The read\/write throughput capacity mode for a table. The options are:
    --
    -- • @throughputMode:PAY_PER_REQUEST@ and
    --
    -- • @throughputMode:PROVISIONED@ - Provisioned capacity mode requires
    -- @readCapacityUnits@ and @writeCapacityUnits@ as input.
    --
    -- The default is @throughput_mode:PAY_PER_REQUEST@.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/keyspaces/latest/devguide/ReadWriteCapacityMode.html Read\/write capacity modes>
    -- in the /Amazon Keyspaces Developer Guide/.
    CapacitySpecification -> ThroughputMode
throughputMode :: ThroughputMode
  }
  deriving (CapacitySpecification -> CapacitySpecification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CapacitySpecification -> CapacitySpecification -> Bool
$c/= :: CapacitySpecification -> CapacitySpecification -> Bool
== :: CapacitySpecification -> CapacitySpecification -> Bool
$c== :: CapacitySpecification -> CapacitySpecification -> Bool
Prelude.Eq, ReadPrec [CapacitySpecification]
ReadPrec CapacitySpecification
Int -> ReadS CapacitySpecification
ReadS [CapacitySpecification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CapacitySpecification]
$creadListPrec :: ReadPrec [CapacitySpecification]
readPrec :: ReadPrec CapacitySpecification
$creadPrec :: ReadPrec CapacitySpecification
readList :: ReadS [CapacitySpecification]
$creadList :: ReadS [CapacitySpecification]
readsPrec :: Int -> ReadS CapacitySpecification
$creadsPrec :: Int -> ReadS CapacitySpecification
Prelude.Read, Int -> CapacitySpecification -> ShowS
[CapacitySpecification] -> ShowS
CapacitySpecification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CapacitySpecification] -> ShowS
$cshowList :: [CapacitySpecification] -> ShowS
show :: CapacitySpecification -> String
$cshow :: CapacitySpecification -> String
showsPrec :: Int -> CapacitySpecification -> ShowS
$cshowsPrec :: Int -> CapacitySpecification -> ShowS
Prelude.Show, forall x. Rep CapacitySpecification x -> CapacitySpecification
forall x. CapacitySpecification -> Rep CapacitySpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CapacitySpecification x -> CapacitySpecification
$cfrom :: forall x. CapacitySpecification -> Rep CapacitySpecification x
Prelude.Generic)

-- |
-- Create a value of 'CapacitySpecification' 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', 'capacitySpecification_readCapacityUnits' - The throughput capacity specified for @read@ operations defined in
-- @read capacity units@ @(RCUs)@.
--
-- 'writeCapacityUnits', 'capacitySpecification_writeCapacityUnits' - The throughput capacity specified for @write@ operations defined in
-- @write capacity units@ @(WCUs)@.
--
-- 'throughputMode', 'capacitySpecification_throughputMode' - The read\/write throughput capacity mode for a table. The options are:
--
-- • @throughputMode:PAY_PER_REQUEST@ and
--
-- • @throughputMode:PROVISIONED@ - Provisioned capacity mode requires
-- @readCapacityUnits@ and @writeCapacityUnits@ as input.
--
-- The default is @throughput_mode:PAY_PER_REQUEST@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/keyspaces/latest/devguide/ReadWriteCapacityMode.html Read\/write capacity modes>
-- in the /Amazon Keyspaces Developer Guide/.
newCapacitySpecification ::
  -- | 'throughputMode'
  ThroughputMode ->
  CapacitySpecification
newCapacitySpecification :: ThroughputMode -> CapacitySpecification
newCapacitySpecification ThroughputMode
pThroughputMode_ =
  CapacitySpecification'
    { $sel:readCapacityUnits:CapacitySpecification' :: Maybe Natural
readCapacityUnits =
        forall a. Maybe a
Prelude.Nothing,
      $sel:writeCapacityUnits:CapacitySpecification' :: Maybe Natural
writeCapacityUnits = forall a. Maybe a
Prelude.Nothing,
      $sel:throughputMode:CapacitySpecification' :: ThroughputMode
throughputMode = ThroughputMode
pThroughputMode_
    }

-- | The throughput capacity specified for @read@ operations defined in
-- @read capacity units@ @(RCUs)@.
capacitySpecification_readCapacityUnits :: Lens.Lens' CapacitySpecification (Prelude.Maybe Prelude.Natural)
capacitySpecification_readCapacityUnits :: Lens' CapacitySpecification (Maybe Natural)
capacitySpecification_readCapacityUnits = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CapacitySpecification' {Maybe Natural
readCapacityUnits :: Maybe Natural
$sel:readCapacityUnits:CapacitySpecification' :: CapacitySpecification -> Maybe Natural
readCapacityUnits} -> Maybe Natural
readCapacityUnits) (\s :: CapacitySpecification
s@CapacitySpecification' {} Maybe Natural
a -> CapacitySpecification
s {$sel:readCapacityUnits:CapacitySpecification' :: Maybe Natural
readCapacityUnits = Maybe Natural
a} :: CapacitySpecification)

-- | The throughput capacity specified for @write@ operations defined in
-- @write capacity units@ @(WCUs)@.
capacitySpecification_writeCapacityUnits :: Lens.Lens' CapacitySpecification (Prelude.Maybe Prelude.Natural)
capacitySpecification_writeCapacityUnits :: Lens' CapacitySpecification (Maybe Natural)
capacitySpecification_writeCapacityUnits = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CapacitySpecification' {Maybe Natural
writeCapacityUnits :: Maybe Natural
$sel:writeCapacityUnits:CapacitySpecification' :: CapacitySpecification -> Maybe Natural
writeCapacityUnits} -> Maybe Natural
writeCapacityUnits) (\s :: CapacitySpecification
s@CapacitySpecification' {} Maybe Natural
a -> CapacitySpecification
s {$sel:writeCapacityUnits:CapacitySpecification' :: Maybe Natural
writeCapacityUnits = Maybe Natural
a} :: CapacitySpecification)

-- | The read\/write throughput capacity mode for a table. The options are:
--
-- • @throughputMode:PAY_PER_REQUEST@ and
--
-- • @throughputMode:PROVISIONED@ - Provisioned capacity mode requires
-- @readCapacityUnits@ and @writeCapacityUnits@ as input.
--
-- The default is @throughput_mode:PAY_PER_REQUEST@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/keyspaces/latest/devguide/ReadWriteCapacityMode.html Read\/write capacity modes>
-- in the /Amazon Keyspaces Developer Guide/.
capacitySpecification_throughputMode :: Lens.Lens' CapacitySpecification ThroughputMode
capacitySpecification_throughputMode :: Lens' CapacitySpecification ThroughputMode
capacitySpecification_throughputMode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CapacitySpecification' {ThroughputMode
throughputMode :: ThroughputMode
$sel:throughputMode:CapacitySpecification' :: CapacitySpecification -> ThroughputMode
throughputMode} -> ThroughputMode
throughputMode) (\s :: CapacitySpecification
s@CapacitySpecification' {} ThroughputMode
a -> CapacitySpecification
s {$sel:throughputMode:CapacitySpecification' :: ThroughputMode
throughputMode = ThroughputMode
a} :: CapacitySpecification)

instance Prelude.Hashable CapacitySpecification where
  hashWithSalt :: Int -> CapacitySpecification -> Int
hashWithSalt Int
_salt CapacitySpecification' {Maybe Natural
ThroughputMode
throughputMode :: ThroughputMode
writeCapacityUnits :: Maybe Natural
readCapacityUnits :: Maybe Natural
$sel:throughputMode:CapacitySpecification' :: CapacitySpecification -> ThroughputMode
$sel:writeCapacityUnits:CapacitySpecification' :: CapacitySpecification -> Maybe Natural
$sel:readCapacityUnits:CapacitySpecification' :: CapacitySpecification -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
readCapacityUnits
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
writeCapacityUnits
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ThroughputMode
throughputMode

instance Prelude.NFData CapacitySpecification where
  rnf :: CapacitySpecification -> ()
rnf CapacitySpecification' {Maybe Natural
ThroughputMode
throughputMode :: ThroughputMode
writeCapacityUnits :: Maybe Natural
readCapacityUnits :: Maybe Natural
$sel:throughputMode:CapacitySpecification' :: CapacitySpecification -> ThroughputMode
$sel:writeCapacityUnits:CapacitySpecification' :: CapacitySpecification -> Maybe Natural
$sel:readCapacityUnits:CapacitySpecification' :: CapacitySpecification -> Maybe Natural
..} =
    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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ThroughputMode
throughputMode

instance Data.ToJSON CapacitySpecification where
  toJSON :: CapacitySpecification -> Value
toJSON CapacitySpecification' {Maybe Natural
ThroughputMode
throughputMode :: ThroughputMode
writeCapacityUnits :: Maybe Natural
readCapacityUnits :: Maybe Natural
$sel:throughputMode:CapacitySpecification' :: CapacitySpecification -> ThroughputMode
$sel:writeCapacityUnits:CapacitySpecification' :: CapacitySpecification -> Maybe Natural
$sel:readCapacityUnits:CapacitySpecification' :: CapacitySpecification -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"readCapacityUnits" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
readCapacityUnits,
            (Key
"writeCapacityUnits" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
writeCapacityUnits,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"throughputMode" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ThroughputMode
throughputMode)
          ]
      )