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

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

-- | Represents the auto scaling settings for a global table or global
-- secondary index.
--
-- /See:/ 'newAutoScalingSettingsDescription' smart constructor.
data AutoScalingSettingsDescription = AutoScalingSettingsDescription'
  { -- | Disabled auto scaling for this global table or global secondary index.
    AutoScalingSettingsDescription -> Maybe Bool
autoScalingDisabled :: Prelude.Maybe Prelude.Bool,
    -- | The minimum capacity units that a global table or global secondary index
    -- should be scaled down to.
    AutoScalingSettingsDescription -> Maybe Natural
minimumUnits :: Prelude.Maybe Prelude.Natural,
    -- | The maximum capacity units that a global table or global secondary index
    -- should be scaled up to.
    AutoScalingSettingsDescription -> Maybe Natural
maximumUnits :: Prelude.Maybe Prelude.Natural,
    -- | Information about the scaling policies.
    AutoScalingSettingsDescription
-> Maybe [AutoScalingPolicyDescription]
scalingPolicies :: Prelude.Maybe [AutoScalingPolicyDescription],
    -- | Role ARN used for configuring the auto scaling policy.
    AutoScalingSettingsDescription -> Maybe Text
autoScalingRoleArn :: Prelude.Maybe Prelude.Text
  }
  deriving (AutoScalingSettingsDescription
-> AutoScalingSettingsDescription -> Bool
(AutoScalingSettingsDescription
 -> AutoScalingSettingsDescription -> Bool)
-> (AutoScalingSettingsDescription
    -> AutoScalingSettingsDescription -> Bool)
-> Eq AutoScalingSettingsDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoScalingSettingsDescription
-> AutoScalingSettingsDescription -> Bool
$c/= :: AutoScalingSettingsDescription
-> AutoScalingSettingsDescription -> Bool
== :: AutoScalingSettingsDescription
-> AutoScalingSettingsDescription -> Bool
$c== :: AutoScalingSettingsDescription
-> AutoScalingSettingsDescription -> Bool
Prelude.Eq, ReadPrec [AutoScalingSettingsDescription]
ReadPrec AutoScalingSettingsDescription
Int -> ReadS AutoScalingSettingsDescription
ReadS [AutoScalingSettingsDescription]
(Int -> ReadS AutoScalingSettingsDescription)
-> ReadS [AutoScalingSettingsDescription]
-> ReadPrec AutoScalingSettingsDescription
-> ReadPrec [AutoScalingSettingsDescription]
-> Read AutoScalingSettingsDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutoScalingSettingsDescription]
$creadListPrec :: ReadPrec [AutoScalingSettingsDescription]
readPrec :: ReadPrec AutoScalingSettingsDescription
$creadPrec :: ReadPrec AutoScalingSettingsDescription
readList :: ReadS [AutoScalingSettingsDescription]
$creadList :: ReadS [AutoScalingSettingsDescription]
readsPrec :: Int -> ReadS AutoScalingSettingsDescription
$creadsPrec :: Int -> ReadS AutoScalingSettingsDescription
Prelude.Read, Int -> AutoScalingSettingsDescription -> ShowS
[AutoScalingSettingsDescription] -> ShowS
AutoScalingSettingsDescription -> String
(Int -> AutoScalingSettingsDescription -> ShowS)
-> (AutoScalingSettingsDescription -> String)
-> ([AutoScalingSettingsDescription] -> ShowS)
-> Show AutoScalingSettingsDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoScalingSettingsDescription] -> ShowS
$cshowList :: [AutoScalingSettingsDescription] -> ShowS
show :: AutoScalingSettingsDescription -> String
$cshow :: AutoScalingSettingsDescription -> String
showsPrec :: Int -> AutoScalingSettingsDescription -> ShowS
$cshowsPrec :: Int -> AutoScalingSettingsDescription -> ShowS
Prelude.Show, (forall x.
 AutoScalingSettingsDescription
 -> Rep AutoScalingSettingsDescription x)
-> (forall x.
    Rep AutoScalingSettingsDescription x
    -> AutoScalingSettingsDescription)
-> Generic AutoScalingSettingsDescription
forall x.
Rep AutoScalingSettingsDescription x
-> AutoScalingSettingsDescription
forall x.
AutoScalingSettingsDescription
-> Rep AutoScalingSettingsDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AutoScalingSettingsDescription x
-> AutoScalingSettingsDescription
$cfrom :: forall x.
AutoScalingSettingsDescription
-> Rep AutoScalingSettingsDescription x
Prelude.Generic)

-- |
-- Create a value of 'AutoScalingSettingsDescription' 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:
--
-- 'autoScalingDisabled', 'autoScalingSettingsDescription_autoScalingDisabled' - Disabled auto scaling for this global table or global secondary index.
--
-- 'minimumUnits', 'autoScalingSettingsDescription_minimumUnits' - The minimum capacity units that a global table or global secondary index
-- should be scaled down to.
--
-- 'maximumUnits', 'autoScalingSettingsDescription_maximumUnits' - The maximum capacity units that a global table or global secondary index
-- should be scaled up to.
--
-- 'scalingPolicies', 'autoScalingSettingsDescription_scalingPolicies' - Information about the scaling policies.
--
-- 'autoScalingRoleArn', 'autoScalingSettingsDescription_autoScalingRoleArn' - Role ARN used for configuring the auto scaling policy.
newAutoScalingSettingsDescription ::
  AutoScalingSettingsDescription
newAutoScalingSettingsDescription :: AutoScalingSettingsDescription
newAutoScalingSettingsDescription =
  AutoScalingSettingsDescription' :: Maybe Bool
-> Maybe Natural
-> Maybe Natural
-> Maybe [AutoScalingPolicyDescription]
-> Maybe Text
-> AutoScalingSettingsDescription
AutoScalingSettingsDescription'
    { $sel:autoScalingDisabled:AutoScalingSettingsDescription' :: Maybe Bool
autoScalingDisabled =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:minimumUnits:AutoScalingSettingsDescription' :: Maybe Natural
minimumUnits = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:maximumUnits:AutoScalingSettingsDescription' :: Maybe Natural
maximumUnits = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:scalingPolicies:AutoScalingSettingsDescription' :: Maybe [AutoScalingPolicyDescription]
scalingPolicies = Maybe [AutoScalingPolicyDescription]
forall a. Maybe a
Prelude.Nothing,
      $sel:autoScalingRoleArn:AutoScalingSettingsDescription' :: Maybe Text
autoScalingRoleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Disabled auto scaling for this global table or global secondary index.
autoScalingSettingsDescription_autoScalingDisabled :: Lens.Lens' AutoScalingSettingsDescription (Prelude.Maybe Prelude.Bool)
autoScalingSettingsDescription_autoScalingDisabled :: (Maybe Bool -> f (Maybe Bool))
-> AutoScalingSettingsDescription
-> f AutoScalingSettingsDescription
autoScalingSettingsDescription_autoScalingDisabled = (AutoScalingSettingsDescription -> Maybe Bool)
-> (AutoScalingSettingsDescription
    -> Maybe Bool -> AutoScalingSettingsDescription)
-> Lens
     AutoScalingSettingsDescription
     AutoScalingSettingsDescription
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingSettingsDescription' {Maybe Bool
autoScalingDisabled :: Maybe Bool
$sel:autoScalingDisabled:AutoScalingSettingsDescription' :: AutoScalingSettingsDescription -> Maybe Bool
autoScalingDisabled} -> Maybe Bool
autoScalingDisabled) (\s :: AutoScalingSettingsDescription
s@AutoScalingSettingsDescription' {} Maybe Bool
a -> AutoScalingSettingsDescription
s {$sel:autoScalingDisabled:AutoScalingSettingsDescription' :: Maybe Bool
autoScalingDisabled = Maybe Bool
a} :: AutoScalingSettingsDescription)

-- | The minimum capacity units that a global table or global secondary index
-- should be scaled down to.
autoScalingSettingsDescription_minimumUnits :: Lens.Lens' AutoScalingSettingsDescription (Prelude.Maybe Prelude.Natural)
autoScalingSettingsDescription_minimumUnits :: (Maybe Natural -> f (Maybe Natural))
-> AutoScalingSettingsDescription
-> f AutoScalingSettingsDescription
autoScalingSettingsDescription_minimumUnits = (AutoScalingSettingsDescription -> Maybe Natural)
-> (AutoScalingSettingsDescription
    -> Maybe Natural -> AutoScalingSettingsDescription)
-> Lens
     AutoScalingSettingsDescription
     AutoScalingSettingsDescription
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingSettingsDescription' {Maybe Natural
minimumUnits :: Maybe Natural
$sel:minimumUnits:AutoScalingSettingsDescription' :: AutoScalingSettingsDescription -> Maybe Natural
minimumUnits} -> Maybe Natural
minimumUnits) (\s :: AutoScalingSettingsDescription
s@AutoScalingSettingsDescription' {} Maybe Natural
a -> AutoScalingSettingsDescription
s {$sel:minimumUnits:AutoScalingSettingsDescription' :: Maybe Natural
minimumUnits = Maybe Natural
a} :: AutoScalingSettingsDescription)

-- | The maximum capacity units that a global table or global secondary index
-- should be scaled up to.
autoScalingSettingsDescription_maximumUnits :: Lens.Lens' AutoScalingSettingsDescription (Prelude.Maybe Prelude.Natural)
autoScalingSettingsDescription_maximumUnits :: (Maybe Natural -> f (Maybe Natural))
-> AutoScalingSettingsDescription
-> f AutoScalingSettingsDescription
autoScalingSettingsDescription_maximumUnits = (AutoScalingSettingsDescription -> Maybe Natural)
-> (AutoScalingSettingsDescription
    -> Maybe Natural -> AutoScalingSettingsDescription)
-> Lens
     AutoScalingSettingsDescription
     AutoScalingSettingsDescription
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingSettingsDescription' {Maybe Natural
maximumUnits :: Maybe Natural
$sel:maximumUnits:AutoScalingSettingsDescription' :: AutoScalingSettingsDescription -> Maybe Natural
maximumUnits} -> Maybe Natural
maximumUnits) (\s :: AutoScalingSettingsDescription
s@AutoScalingSettingsDescription' {} Maybe Natural
a -> AutoScalingSettingsDescription
s {$sel:maximumUnits:AutoScalingSettingsDescription' :: Maybe Natural
maximumUnits = Maybe Natural
a} :: AutoScalingSettingsDescription)

-- | Information about the scaling policies.
autoScalingSettingsDescription_scalingPolicies :: Lens.Lens' AutoScalingSettingsDescription (Prelude.Maybe [AutoScalingPolicyDescription])
autoScalingSettingsDescription_scalingPolicies :: (Maybe [AutoScalingPolicyDescription]
 -> f (Maybe [AutoScalingPolicyDescription]))
-> AutoScalingSettingsDescription
-> f AutoScalingSettingsDescription
autoScalingSettingsDescription_scalingPolicies = (AutoScalingSettingsDescription
 -> Maybe [AutoScalingPolicyDescription])
-> (AutoScalingSettingsDescription
    -> Maybe [AutoScalingPolicyDescription]
    -> AutoScalingSettingsDescription)
-> Lens
     AutoScalingSettingsDescription
     AutoScalingSettingsDescription
     (Maybe [AutoScalingPolicyDescription])
     (Maybe [AutoScalingPolicyDescription])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingSettingsDescription' {Maybe [AutoScalingPolicyDescription]
scalingPolicies :: Maybe [AutoScalingPolicyDescription]
$sel:scalingPolicies:AutoScalingSettingsDescription' :: AutoScalingSettingsDescription
-> Maybe [AutoScalingPolicyDescription]
scalingPolicies} -> Maybe [AutoScalingPolicyDescription]
scalingPolicies) (\s :: AutoScalingSettingsDescription
s@AutoScalingSettingsDescription' {} Maybe [AutoScalingPolicyDescription]
a -> AutoScalingSettingsDescription
s {$sel:scalingPolicies:AutoScalingSettingsDescription' :: Maybe [AutoScalingPolicyDescription]
scalingPolicies = Maybe [AutoScalingPolicyDescription]
a} :: AutoScalingSettingsDescription) ((Maybe [AutoScalingPolicyDescription]
  -> f (Maybe [AutoScalingPolicyDescription]))
 -> AutoScalingSettingsDescription
 -> f AutoScalingSettingsDescription)
-> ((Maybe [AutoScalingPolicyDescription]
     -> f (Maybe [AutoScalingPolicyDescription]))
    -> Maybe [AutoScalingPolicyDescription]
    -> f (Maybe [AutoScalingPolicyDescription]))
-> (Maybe [AutoScalingPolicyDescription]
    -> f (Maybe [AutoScalingPolicyDescription]))
-> AutoScalingSettingsDescription
-> f AutoScalingSettingsDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AutoScalingPolicyDescription]
  [AutoScalingPolicyDescription]
  [AutoScalingPolicyDescription]
  [AutoScalingPolicyDescription]
-> Iso
     (Maybe [AutoScalingPolicyDescription])
     (Maybe [AutoScalingPolicyDescription])
     (Maybe [AutoScalingPolicyDescription])
     (Maybe [AutoScalingPolicyDescription])
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
  [AutoScalingPolicyDescription]
  [AutoScalingPolicyDescription]
  [AutoScalingPolicyDescription]
  [AutoScalingPolicyDescription]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Role ARN used for configuring the auto scaling policy.
autoScalingSettingsDescription_autoScalingRoleArn :: Lens.Lens' AutoScalingSettingsDescription (Prelude.Maybe Prelude.Text)
autoScalingSettingsDescription_autoScalingRoleArn :: (Maybe Text -> f (Maybe Text))
-> AutoScalingSettingsDescription
-> f AutoScalingSettingsDescription
autoScalingSettingsDescription_autoScalingRoleArn = (AutoScalingSettingsDescription -> Maybe Text)
-> (AutoScalingSettingsDescription
    -> Maybe Text -> AutoScalingSettingsDescription)
-> Lens
     AutoScalingSettingsDescription
     AutoScalingSettingsDescription
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingSettingsDescription' {Maybe Text
autoScalingRoleArn :: Maybe Text
$sel:autoScalingRoleArn:AutoScalingSettingsDescription' :: AutoScalingSettingsDescription -> Maybe Text
autoScalingRoleArn} -> Maybe Text
autoScalingRoleArn) (\s :: AutoScalingSettingsDescription
s@AutoScalingSettingsDescription' {} Maybe Text
a -> AutoScalingSettingsDescription
s {$sel:autoScalingRoleArn:AutoScalingSettingsDescription' :: Maybe Text
autoScalingRoleArn = Maybe Text
a} :: AutoScalingSettingsDescription)

instance Core.FromJSON AutoScalingSettingsDescription where
  parseJSON :: Value -> Parser AutoScalingSettingsDescription
parseJSON =
    String
-> (Object -> Parser AutoScalingSettingsDescription)
-> Value
-> Parser AutoScalingSettingsDescription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AutoScalingSettingsDescription"
      ( \Object
x ->
          Maybe Bool
-> Maybe Natural
-> Maybe Natural
-> Maybe [AutoScalingPolicyDescription]
-> Maybe Text
-> AutoScalingSettingsDescription
AutoScalingSettingsDescription'
            (Maybe Bool
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe [AutoScalingPolicyDescription]
 -> Maybe Text
 -> AutoScalingSettingsDescription)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Natural
      -> Maybe Natural
      -> Maybe [AutoScalingPolicyDescription]
      -> Maybe Text
      -> AutoScalingSettingsDescription)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AutoScalingDisabled")
            Parser
  (Maybe Natural
   -> Maybe Natural
   -> Maybe [AutoScalingPolicyDescription]
   -> Maybe Text
   -> AutoScalingSettingsDescription)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural
      -> Maybe [AutoScalingPolicyDescription]
      -> Maybe Text
      -> AutoScalingSettingsDescription)
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
"MinimumUnits")
            Parser
  (Maybe Natural
   -> Maybe [AutoScalingPolicyDescription]
   -> Maybe Text
   -> AutoScalingSettingsDescription)
-> Parser (Maybe Natural)
-> Parser
     (Maybe [AutoScalingPolicyDescription]
      -> Maybe Text -> AutoScalingSettingsDescription)
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
"MaximumUnits")
            Parser
  (Maybe [AutoScalingPolicyDescription]
   -> Maybe Text -> AutoScalingSettingsDescription)
-> Parser (Maybe [AutoScalingPolicyDescription])
-> Parser (Maybe Text -> AutoScalingSettingsDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text -> Parser (Maybe (Maybe [AutoScalingPolicyDescription]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ScalingPolicies"
                            Parser (Maybe (Maybe [AutoScalingPolicyDescription]))
-> Maybe [AutoScalingPolicyDescription]
-> Parser (Maybe [AutoScalingPolicyDescription])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [AutoScalingPolicyDescription]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Text -> AutoScalingSettingsDescription)
-> Parser (Maybe Text) -> Parser AutoScalingSettingsDescription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AutoScalingRoleArn")
      )

instance
  Prelude.Hashable
    AutoScalingSettingsDescription

instance
  Prelude.NFData
    AutoScalingSettingsDescription