{-# 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.RDS.Types.ScalingConfigurationInfo
-- 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.RDS.Types.ScalingConfigurationInfo where

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

-- | Shows the scaling configuration for an Aurora DB cluster in @serverless@
-- DB engine mode.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless.html Using Amazon Aurora Serverless>
-- in the /Amazon Aurora User Guide/.
--
-- /See:/ 'newScalingConfigurationInfo' smart constructor.
data ScalingConfigurationInfo = ScalingConfigurationInfo'
  { -- | The remaining amount of time, in seconds, before the Aurora DB cluster
    -- in @serverless@ mode is paused. A DB cluster can be paused only when
    -- it\'s idle (it has no connections).
    ScalingConfigurationInfo -> Maybe Int
secondsUntilAutoPause :: Prelude.Maybe Prelude.Int,
    -- | The action that occurs when Aurora times out while attempting to change
    -- the capacity of an Aurora Serverless cluster. The value is either
    -- @ForceApplyCapacityChange@ or @RollbackCapacityChange@.
    --
    -- @ForceApplyCapacityChange@, the default, sets the capacity to the
    -- specified value as soon as possible.
    --
    -- @RollbackCapacityChange@ ignores the capacity change if a scaling point
    -- isn\'t found in the timeout period.
    ScalingConfigurationInfo -> Maybe Text
timeoutAction :: Prelude.Maybe Prelude.Text,
    -- | A value that indicates whether automatic pause is allowed for the Aurora
    -- DB cluster in @serverless@ DB engine mode.
    --
    -- When the value is set to false for an Aurora Serverless DB cluster, the
    -- DB cluster automatically resumes.
    ScalingConfigurationInfo -> Maybe Bool
autoPause :: Prelude.Maybe Prelude.Bool,
    -- | The maximum capacity for an Aurora DB cluster in @serverless@ DB engine
    -- mode.
    ScalingConfigurationInfo -> Maybe Int
maxCapacity :: Prelude.Maybe Prelude.Int,
    -- | The maximum capacity for the Aurora DB cluster in @serverless@ DB engine
    -- mode.
    ScalingConfigurationInfo -> Maybe Int
minCapacity :: Prelude.Maybe Prelude.Int,
    -- | The number of seconds before scaling times out. What happens when an
    -- attempted scaling action times out is determined by the @TimeoutAction@
    -- setting.
    ScalingConfigurationInfo -> Maybe Int
secondsBeforeTimeout :: Prelude.Maybe Prelude.Int
  }
  deriving (ScalingConfigurationInfo -> ScalingConfigurationInfo -> Bool
(ScalingConfigurationInfo -> ScalingConfigurationInfo -> Bool)
-> (ScalingConfigurationInfo -> ScalingConfigurationInfo -> Bool)
-> Eq ScalingConfigurationInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScalingConfigurationInfo -> ScalingConfigurationInfo -> Bool
$c/= :: ScalingConfigurationInfo -> ScalingConfigurationInfo -> Bool
== :: ScalingConfigurationInfo -> ScalingConfigurationInfo -> Bool
$c== :: ScalingConfigurationInfo -> ScalingConfigurationInfo -> Bool
Prelude.Eq, ReadPrec [ScalingConfigurationInfo]
ReadPrec ScalingConfigurationInfo
Int -> ReadS ScalingConfigurationInfo
ReadS [ScalingConfigurationInfo]
(Int -> ReadS ScalingConfigurationInfo)
-> ReadS [ScalingConfigurationInfo]
-> ReadPrec ScalingConfigurationInfo
-> ReadPrec [ScalingConfigurationInfo]
-> Read ScalingConfigurationInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScalingConfigurationInfo]
$creadListPrec :: ReadPrec [ScalingConfigurationInfo]
readPrec :: ReadPrec ScalingConfigurationInfo
$creadPrec :: ReadPrec ScalingConfigurationInfo
readList :: ReadS [ScalingConfigurationInfo]
$creadList :: ReadS [ScalingConfigurationInfo]
readsPrec :: Int -> ReadS ScalingConfigurationInfo
$creadsPrec :: Int -> ReadS ScalingConfigurationInfo
Prelude.Read, Int -> ScalingConfigurationInfo -> ShowS
[ScalingConfigurationInfo] -> ShowS
ScalingConfigurationInfo -> String
(Int -> ScalingConfigurationInfo -> ShowS)
-> (ScalingConfigurationInfo -> String)
-> ([ScalingConfigurationInfo] -> ShowS)
-> Show ScalingConfigurationInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScalingConfigurationInfo] -> ShowS
$cshowList :: [ScalingConfigurationInfo] -> ShowS
show :: ScalingConfigurationInfo -> String
$cshow :: ScalingConfigurationInfo -> String
showsPrec :: Int -> ScalingConfigurationInfo -> ShowS
$cshowsPrec :: Int -> ScalingConfigurationInfo -> ShowS
Prelude.Show, (forall x.
 ScalingConfigurationInfo -> Rep ScalingConfigurationInfo x)
-> (forall x.
    Rep ScalingConfigurationInfo x -> ScalingConfigurationInfo)
-> Generic ScalingConfigurationInfo
forall x.
Rep ScalingConfigurationInfo x -> ScalingConfigurationInfo
forall x.
ScalingConfigurationInfo -> Rep ScalingConfigurationInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ScalingConfigurationInfo x -> ScalingConfigurationInfo
$cfrom :: forall x.
ScalingConfigurationInfo -> Rep ScalingConfigurationInfo x
Prelude.Generic)

-- |
-- Create a value of 'ScalingConfigurationInfo' 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:
--
-- 'secondsUntilAutoPause', 'scalingConfigurationInfo_secondsUntilAutoPause' - The remaining amount of time, in seconds, before the Aurora DB cluster
-- in @serverless@ mode is paused. A DB cluster can be paused only when
-- it\'s idle (it has no connections).
--
-- 'timeoutAction', 'scalingConfigurationInfo_timeoutAction' - The action that occurs when Aurora times out while attempting to change
-- the capacity of an Aurora Serverless cluster. The value is either
-- @ForceApplyCapacityChange@ or @RollbackCapacityChange@.
--
-- @ForceApplyCapacityChange@, the default, sets the capacity to the
-- specified value as soon as possible.
--
-- @RollbackCapacityChange@ ignores the capacity change if a scaling point
-- isn\'t found in the timeout period.
--
-- 'autoPause', 'scalingConfigurationInfo_autoPause' - A value that indicates whether automatic pause is allowed for the Aurora
-- DB cluster in @serverless@ DB engine mode.
--
-- When the value is set to false for an Aurora Serverless DB cluster, the
-- DB cluster automatically resumes.
--
-- 'maxCapacity', 'scalingConfigurationInfo_maxCapacity' - The maximum capacity for an Aurora DB cluster in @serverless@ DB engine
-- mode.
--
-- 'minCapacity', 'scalingConfigurationInfo_minCapacity' - The maximum capacity for the Aurora DB cluster in @serverless@ DB engine
-- mode.
--
-- 'secondsBeforeTimeout', 'scalingConfigurationInfo_secondsBeforeTimeout' - The number of seconds before scaling times out. What happens when an
-- attempted scaling action times out is determined by the @TimeoutAction@
-- setting.
newScalingConfigurationInfo ::
  ScalingConfigurationInfo
newScalingConfigurationInfo :: ScalingConfigurationInfo
newScalingConfigurationInfo =
  ScalingConfigurationInfo' :: Maybe Int
-> Maybe Text
-> Maybe Bool
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> ScalingConfigurationInfo
ScalingConfigurationInfo'
    { $sel:secondsUntilAutoPause:ScalingConfigurationInfo' :: Maybe Int
secondsUntilAutoPause =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:timeoutAction:ScalingConfigurationInfo' :: Maybe Text
timeoutAction = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:autoPause:ScalingConfigurationInfo' :: Maybe Bool
autoPause = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:maxCapacity:ScalingConfigurationInfo' :: Maybe Int
maxCapacity = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:minCapacity:ScalingConfigurationInfo' :: Maybe Int
minCapacity = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:secondsBeforeTimeout:ScalingConfigurationInfo' :: Maybe Int
secondsBeforeTimeout = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The remaining amount of time, in seconds, before the Aurora DB cluster
-- in @serverless@ mode is paused. A DB cluster can be paused only when
-- it\'s idle (it has no connections).
scalingConfigurationInfo_secondsUntilAutoPause :: Lens.Lens' ScalingConfigurationInfo (Prelude.Maybe Prelude.Int)
scalingConfigurationInfo_secondsUntilAutoPause :: (Maybe Int -> f (Maybe Int))
-> ScalingConfigurationInfo -> f ScalingConfigurationInfo
scalingConfigurationInfo_secondsUntilAutoPause = (ScalingConfigurationInfo -> Maybe Int)
-> (ScalingConfigurationInfo
    -> Maybe Int -> ScalingConfigurationInfo)
-> Lens
     ScalingConfigurationInfo
     ScalingConfigurationInfo
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingConfigurationInfo' {Maybe Int
secondsUntilAutoPause :: Maybe Int
$sel:secondsUntilAutoPause:ScalingConfigurationInfo' :: ScalingConfigurationInfo -> Maybe Int
secondsUntilAutoPause} -> Maybe Int
secondsUntilAutoPause) (\s :: ScalingConfigurationInfo
s@ScalingConfigurationInfo' {} Maybe Int
a -> ScalingConfigurationInfo
s {$sel:secondsUntilAutoPause:ScalingConfigurationInfo' :: Maybe Int
secondsUntilAutoPause = Maybe Int
a} :: ScalingConfigurationInfo)

-- | The action that occurs when Aurora times out while attempting to change
-- the capacity of an Aurora Serverless cluster. The value is either
-- @ForceApplyCapacityChange@ or @RollbackCapacityChange@.
--
-- @ForceApplyCapacityChange@, the default, sets the capacity to the
-- specified value as soon as possible.
--
-- @RollbackCapacityChange@ ignores the capacity change if a scaling point
-- isn\'t found in the timeout period.
scalingConfigurationInfo_timeoutAction :: Lens.Lens' ScalingConfigurationInfo (Prelude.Maybe Prelude.Text)
scalingConfigurationInfo_timeoutAction :: (Maybe Text -> f (Maybe Text))
-> ScalingConfigurationInfo -> f ScalingConfigurationInfo
scalingConfigurationInfo_timeoutAction = (ScalingConfigurationInfo -> Maybe Text)
-> (ScalingConfigurationInfo
    -> Maybe Text -> ScalingConfigurationInfo)
-> Lens
     ScalingConfigurationInfo
     ScalingConfigurationInfo
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingConfigurationInfo' {Maybe Text
timeoutAction :: Maybe Text
$sel:timeoutAction:ScalingConfigurationInfo' :: ScalingConfigurationInfo -> Maybe Text
timeoutAction} -> Maybe Text
timeoutAction) (\s :: ScalingConfigurationInfo
s@ScalingConfigurationInfo' {} Maybe Text
a -> ScalingConfigurationInfo
s {$sel:timeoutAction:ScalingConfigurationInfo' :: Maybe Text
timeoutAction = Maybe Text
a} :: ScalingConfigurationInfo)

-- | A value that indicates whether automatic pause is allowed for the Aurora
-- DB cluster in @serverless@ DB engine mode.
--
-- When the value is set to false for an Aurora Serverless DB cluster, the
-- DB cluster automatically resumes.
scalingConfigurationInfo_autoPause :: Lens.Lens' ScalingConfigurationInfo (Prelude.Maybe Prelude.Bool)
scalingConfigurationInfo_autoPause :: (Maybe Bool -> f (Maybe Bool))
-> ScalingConfigurationInfo -> f ScalingConfigurationInfo
scalingConfigurationInfo_autoPause = (ScalingConfigurationInfo -> Maybe Bool)
-> (ScalingConfigurationInfo
    -> Maybe Bool -> ScalingConfigurationInfo)
-> Lens
     ScalingConfigurationInfo
     ScalingConfigurationInfo
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingConfigurationInfo' {Maybe Bool
autoPause :: Maybe Bool
$sel:autoPause:ScalingConfigurationInfo' :: ScalingConfigurationInfo -> Maybe Bool
autoPause} -> Maybe Bool
autoPause) (\s :: ScalingConfigurationInfo
s@ScalingConfigurationInfo' {} Maybe Bool
a -> ScalingConfigurationInfo
s {$sel:autoPause:ScalingConfigurationInfo' :: Maybe Bool
autoPause = Maybe Bool
a} :: ScalingConfigurationInfo)

-- | The maximum capacity for an Aurora DB cluster in @serverless@ DB engine
-- mode.
scalingConfigurationInfo_maxCapacity :: Lens.Lens' ScalingConfigurationInfo (Prelude.Maybe Prelude.Int)
scalingConfigurationInfo_maxCapacity :: (Maybe Int -> f (Maybe Int))
-> ScalingConfigurationInfo -> f ScalingConfigurationInfo
scalingConfigurationInfo_maxCapacity = (ScalingConfigurationInfo -> Maybe Int)
-> (ScalingConfigurationInfo
    -> Maybe Int -> ScalingConfigurationInfo)
-> Lens
     ScalingConfigurationInfo
     ScalingConfigurationInfo
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingConfigurationInfo' {Maybe Int
maxCapacity :: Maybe Int
$sel:maxCapacity:ScalingConfigurationInfo' :: ScalingConfigurationInfo -> Maybe Int
maxCapacity} -> Maybe Int
maxCapacity) (\s :: ScalingConfigurationInfo
s@ScalingConfigurationInfo' {} Maybe Int
a -> ScalingConfigurationInfo
s {$sel:maxCapacity:ScalingConfigurationInfo' :: Maybe Int
maxCapacity = Maybe Int
a} :: ScalingConfigurationInfo)

-- | The maximum capacity for the Aurora DB cluster in @serverless@ DB engine
-- mode.
scalingConfigurationInfo_minCapacity :: Lens.Lens' ScalingConfigurationInfo (Prelude.Maybe Prelude.Int)
scalingConfigurationInfo_minCapacity :: (Maybe Int -> f (Maybe Int))
-> ScalingConfigurationInfo -> f ScalingConfigurationInfo
scalingConfigurationInfo_minCapacity = (ScalingConfigurationInfo -> Maybe Int)
-> (ScalingConfigurationInfo
    -> Maybe Int -> ScalingConfigurationInfo)
-> Lens
     ScalingConfigurationInfo
     ScalingConfigurationInfo
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingConfigurationInfo' {Maybe Int
minCapacity :: Maybe Int
$sel:minCapacity:ScalingConfigurationInfo' :: ScalingConfigurationInfo -> Maybe Int
minCapacity} -> Maybe Int
minCapacity) (\s :: ScalingConfigurationInfo
s@ScalingConfigurationInfo' {} Maybe Int
a -> ScalingConfigurationInfo
s {$sel:minCapacity:ScalingConfigurationInfo' :: Maybe Int
minCapacity = Maybe Int
a} :: ScalingConfigurationInfo)

-- | The number of seconds before scaling times out. What happens when an
-- attempted scaling action times out is determined by the @TimeoutAction@
-- setting.
scalingConfigurationInfo_secondsBeforeTimeout :: Lens.Lens' ScalingConfigurationInfo (Prelude.Maybe Prelude.Int)
scalingConfigurationInfo_secondsBeforeTimeout :: (Maybe Int -> f (Maybe Int))
-> ScalingConfigurationInfo -> f ScalingConfigurationInfo
scalingConfigurationInfo_secondsBeforeTimeout = (ScalingConfigurationInfo -> Maybe Int)
-> (ScalingConfigurationInfo
    -> Maybe Int -> ScalingConfigurationInfo)
-> Lens
     ScalingConfigurationInfo
     ScalingConfigurationInfo
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingConfigurationInfo' {Maybe Int
secondsBeforeTimeout :: Maybe Int
$sel:secondsBeforeTimeout:ScalingConfigurationInfo' :: ScalingConfigurationInfo -> Maybe Int
secondsBeforeTimeout} -> Maybe Int
secondsBeforeTimeout) (\s :: ScalingConfigurationInfo
s@ScalingConfigurationInfo' {} Maybe Int
a -> ScalingConfigurationInfo
s {$sel:secondsBeforeTimeout:ScalingConfigurationInfo' :: Maybe Int
secondsBeforeTimeout = Maybe Int
a} :: ScalingConfigurationInfo)

instance Core.FromXML ScalingConfigurationInfo where
  parseXML :: [Node] -> Either String ScalingConfigurationInfo
parseXML [Node]
x =
    Maybe Int
-> Maybe Text
-> Maybe Bool
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> ScalingConfigurationInfo
ScalingConfigurationInfo'
      (Maybe Int
 -> Maybe Text
 -> Maybe Bool
 -> Maybe Int
 -> Maybe Int
 -> Maybe Int
 -> ScalingConfigurationInfo)
-> Either String (Maybe Int)
-> Either
     String
     (Maybe Text
      -> Maybe Bool
      -> Maybe Int
      -> Maybe Int
      -> Maybe Int
      -> ScalingConfigurationInfo)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SecondsUntilAutoPause")
      Either
  String
  (Maybe Text
   -> Maybe Bool
   -> Maybe Int
   -> Maybe Int
   -> Maybe Int
   -> ScalingConfigurationInfo)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Bool
      -> Maybe Int -> Maybe Int -> Maybe Int -> ScalingConfigurationInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"TimeoutAction")
      Either
  String
  (Maybe Bool
   -> Maybe Int -> Maybe Int -> Maybe Int -> ScalingConfigurationInfo)
-> Either String (Maybe Bool)
-> Either
     String
     (Maybe Int -> Maybe Int -> Maybe Int -> ScalingConfigurationInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Bool)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"AutoPause")
      Either
  String
  (Maybe Int -> Maybe Int -> Maybe Int -> ScalingConfigurationInfo)
-> Either String (Maybe Int)
-> Either
     String (Maybe Int -> Maybe Int -> ScalingConfigurationInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"MaxCapacity")
      Either String (Maybe Int -> Maybe Int -> ScalingConfigurationInfo)
-> Either String (Maybe Int)
-> Either String (Maybe Int -> ScalingConfigurationInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"MinCapacity")
      Either String (Maybe Int -> ScalingConfigurationInfo)
-> Either String (Maybe Int)
-> Either String ScalingConfigurationInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SecondsBeforeTimeout")

instance Prelude.Hashable ScalingConfigurationInfo

instance Prelude.NFData ScalingConfigurationInfo