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

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

-- | Contains the scaling configuration of an Aurora Serverless DB cluster.
--
-- 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:/ 'newScalingConfiguration' smart constructor.
data ScalingConfiguration = ScalingConfiguration'
  { -- | The time, in seconds, before an Aurora DB cluster in @serverless@ mode
    -- is paused.
    --
    -- Specify a value between 300 and 86,400 seconds.
    ScalingConfiguration -> Maybe Int
secondsUntilAutoPause :: Prelude.Maybe Prelude.Int,
    -- | The action to take when the timeout is reached, either
    -- @ForceApplyCapacityChange@ or @RollbackCapacityChange@.
    --
    -- @ForceApplyCapacityChange@ sets the capacity to the specified value as
    -- soon as possible.
    --
    -- @RollbackCapacityChange@, the default, ignores the capacity change if a
    -- scaling point isn\'t found in the timeout period.
    --
    -- If you specify @ForceApplyCapacityChange@, connections that prevent
    -- Aurora Serverless from finding a scaling point might be dropped.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless.how-it-works.html#aurora-serverless.how-it-works.auto-scaling Autoscaling for Aurora Serverless>
    -- in the /Amazon Aurora User Guide/.
    ScalingConfiguration -> Maybe Text
timeoutAction :: Prelude.Maybe Prelude.Text,
    -- | A value that indicates whether to allow or disallow automatic pause for
    -- an Aurora DB cluster in @serverless@ DB engine mode. A DB cluster can be
    -- paused only when it\'s idle (it has no connections).
    --
    -- If a DB cluster is paused for more than seven days, the DB cluster might
    -- be backed up with a snapshot. In this case, the DB cluster is restored
    -- when there is a request to connect to it.
    ScalingConfiguration -> Maybe Bool
autoPause :: Prelude.Maybe Prelude.Bool,
    -- | The maximum capacity for an Aurora DB cluster in @serverless@ DB engine
    -- mode.
    --
    -- For Aurora MySQL, valid capacity values are @1@, @2@, @4@, @8@, @16@,
    -- @32@, @64@, @128@, and @256@.
    --
    -- For Aurora PostgreSQL, valid capacity values are @2@, @4@, @8@, @16@,
    -- @32@, @64@, @192@, and @384@.
    --
    -- The maximum capacity must be greater than or equal to the minimum
    -- capacity.
    ScalingConfiguration -> Maybe Int
maxCapacity :: Prelude.Maybe Prelude.Int,
    -- | The minimum capacity for an Aurora DB cluster in @serverless@ DB engine
    -- mode.
    --
    -- For Aurora MySQL, valid capacity values are @1@, @2@, @4@, @8@, @16@,
    -- @32@, @64@, @128@, and @256@.
    --
    -- For Aurora PostgreSQL, valid capacity values are @2@, @4@, @8@, @16@,
    -- @32@, @64@, @192@, and @384@.
    --
    -- The minimum capacity must be less than or equal to the maximum capacity.
    ScalingConfiguration -> Maybe Int
minCapacity :: Prelude.Maybe Prelude.Int,
    -- | The amount of time, in seconds, that Aurora Serverless tries to find a
    -- scaling point to perform seamless scaling before enforcing the timeout
    -- action. The default is 300.
    --
    -- Specify a value between 60 and 600 seconds.
    ScalingConfiguration -> Maybe Int
secondsBeforeTimeout :: Prelude.Maybe Prelude.Int
  }
  deriving (ScalingConfiguration -> ScalingConfiguration -> Bool
(ScalingConfiguration -> ScalingConfiguration -> Bool)
-> (ScalingConfiguration -> ScalingConfiguration -> Bool)
-> Eq ScalingConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScalingConfiguration -> ScalingConfiguration -> Bool
$c/= :: ScalingConfiguration -> ScalingConfiguration -> Bool
== :: ScalingConfiguration -> ScalingConfiguration -> Bool
$c== :: ScalingConfiguration -> ScalingConfiguration -> Bool
Prelude.Eq, ReadPrec [ScalingConfiguration]
ReadPrec ScalingConfiguration
Int -> ReadS ScalingConfiguration
ReadS [ScalingConfiguration]
(Int -> ReadS ScalingConfiguration)
-> ReadS [ScalingConfiguration]
-> ReadPrec ScalingConfiguration
-> ReadPrec [ScalingConfiguration]
-> Read ScalingConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScalingConfiguration]
$creadListPrec :: ReadPrec [ScalingConfiguration]
readPrec :: ReadPrec ScalingConfiguration
$creadPrec :: ReadPrec ScalingConfiguration
readList :: ReadS [ScalingConfiguration]
$creadList :: ReadS [ScalingConfiguration]
readsPrec :: Int -> ReadS ScalingConfiguration
$creadsPrec :: Int -> ReadS ScalingConfiguration
Prelude.Read, Int -> ScalingConfiguration -> ShowS
[ScalingConfiguration] -> ShowS
ScalingConfiguration -> String
(Int -> ScalingConfiguration -> ShowS)
-> (ScalingConfiguration -> String)
-> ([ScalingConfiguration] -> ShowS)
-> Show ScalingConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScalingConfiguration] -> ShowS
$cshowList :: [ScalingConfiguration] -> ShowS
show :: ScalingConfiguration -> String
$cshow :: ScalingConfiguration -> String
showsPrec :: Int -> ScalingConfiguration -> ShowS
$cshowsPrec :: Int -> ScalingConfiguration -> ShowS
Prelude.Show, (forall x. ScalingConfiguration -> Rep ScalingConfiguration x)
-> (forall x. Rep ScalingConfiguration x -> ScalingConfiguration)
-> Generic ScalingConfiguration
forall x. Rep ScalingConfiguration x -> ScalingConfiguration
forall x. ScalingConfiguration -> Rep ScalingConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ScalingConfiguration x -> ScalingConfiguration
$cfrom :: forall x. ScalingConfiguration -> Rep ScalingConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ScalingConfiguration' 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', 'scalingConfiguration_secondsUntilAutoPause' - The time, in seconds, before an Aurora DB cluster in @serverless@ mode
-- is paused.
--
-- Specify a value between 300 and 86,400 seconds.
--
-- 'timeoutAction', 'scalingConfiguration_timeoutAction' - The action to take when the timeout is reached, either
-- @ForceApplyCapacityChange@ or @RollbackCapacityChange@.
--
-- @ForceApplyCapacityChange@ sets the capacity to the specified value as
-- soon as possible.
--
-- @RollbackCapacityChange@, the default, ignores the capacity change if a
-- scaling point isn\'t found in the timeout period.
--
-- If you specify @ForceApplyCapacityChange@, connections that prevent
-- Aurora Serverless from finding a scaling point might be dropped.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless.how-it-works.html#aurora-serverless.how-it-works.auto-scaling Autoscaling for Aurora Serverless>
-- in the /Amazon Aurora User Guide/.
--
-- 'autoPause', 'scalingConfiguration_autoPause' - A value that indicates whether to allow or disallow automatic pause for
-- an Aurora DB cluster in @serverless@ DB engine mode. A DB cluster can be
-- paused only when it\'s idle (it has no connections).
--
-- If a DB cluster is paused for more than seven days, the DB cluster might
-- be backed up with a snapshot. In this case, the DB cluster is restored
-- when there is a request to connect to it.
--
-- 'maxCapacity', 'scalingConfiguration_maxCapacity' - The maximum capacity for an Aurora DB cluster in @serverless@ DB engine
-- mode.
--
-- For Aurora MySQL, valid capacity values are @1@, @2@, @4@, @8@, @16@,
-- @32@, @64@, @128@, and @256@.
--
-- For Aurora PostgreSQL, valid capacity values are @2@, @4@, @8@, @16@,
-- @32@, @64@, @192@, and @384@.
--
-- The maximum capacity must be greater than or equal to the minimum
-- capacity.
--
-- 'minCapacity', 'scalingConfiguration_minCapacity' - The minimum capacity for an Aurora DB cluster in @serverless@ DB engine
-- mode.
--
-- For Aurora MySQL, valid capacity values are @1@, @2@, @4@, @8@, @16@,
-- @32@, @64@, @128@, and @256@.
--
-- For Aurora PostgreSQL, valid capacity values are @2@, @4@, @8@, @16@,
-- @32@, @64@, @192@, and @384@.
--
-- The minimum capacity must be less than or equal to the maximum capacity.
--
-- 'secondsBeforeTimeout', 'scalingConfiguration_secondsBeforeTimeout' - The amount of time, in seconds, that Aurora Serverless tries to find a
-- scaling point to perform seamless scaling before enforcing the timeout
-- action. The default is 300.
--
-- Specify a value between 60 and 600 seconds.
newScalingConfiguration ::
  ScalingConfiguration
newScalingConfiguration :: ScalingConfiguration
newScalingConfiguration =
  ScalingConfiguration' :: Maybe Int
-> Maybe Text
-> Maybe Bool
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> ScalingConfiguration
ScalingConfiguration'
    { $sel:secondsUntilAutoPause:ScalingConfiguration' :: Maybe Int
secondsUntilAutoPause =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:timeoutAction:ScalingConfiguration' :: Maybe Text
timeoutAction = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:autoPause:ScalingConfiguration' :: Maybe Bool
autoPause = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:maxCapacity:ScalingConfiguration' :: Maybe Int
maxCapacity = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:minCapacity:ScalingConfiguration' :: Maybe Int
minCapacity = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:secondsBeforeTimeout:ScalingConfiguration' :: Maybe Int
secondsBeforeTimeout = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The time, in seconds, before an Aurora DB cluster in @serverless@ mode
-- is paused.
--
-- Specify a value between 300 and 86,400 seconds.
scalingConfiguration_secondsUntilAutoPause :: Lens.Lens' ScalingConfiguration (Prelude.Maybe Prelude.Int)
scalingConfiguration_secondsUntilAutoPause :: (Maybe Int -> f (Maybe Int))
-> ScalingConfiguration -> f ScalingConfiguration
scalingConfiguration_secondsUntilAutoPause = (ScalingConfiguration -> Maybe Int)
-> (ScalingConfiguration -> Maybe Int -> ScalingConfiguration)
-> Lens
     ScalingConfiguration ScalingConfiguration (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingConfiguration' {Maybe Int
secondsUntilAutoPause :: Maybe Int
$sel:secondsUntilAutoPause:ScalingConfiguration' :: ScalingConfiguration -> Maybe Int
secondsUntilAutoPause} -> Maybe Int
secondsUntilAutoPause) (\s :: ScalingConfiguration
s@ScalingConfiguration' {} Maybe Int
a -> ScalingConfiguration
s {$sel:secondsUntilAutoPause:ScalingConfiguration' :: Maybe Int
secondsUntilAutoPause = Maybe Int
a} :: ScalingConfiguration)

-- | The action to take when the timeout is reached, either
-- @ForceApplyCapacityChange@ or @RollbackCapacityChange@.
--
-- @ForceApplyCapacityChange@ sets the capacity to the specified value as
-- soon as possible.
--
-- @RollbackCapacityChange@, the default, ignores the capacity change if a
-- scaling point isn\'t found in the timeout period.
--
-- If you specify @ForceApplyCapacityChange@, connections that prevent
-- Aurora Serverless from finding a scaling point might be dropped.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless.how-it-works.html#aurora-serverless.how-it-works.auto-scaling Autoscaling for Aurora Serverless>
-- in the /Amazon Aurora User Guide/.
scalingConfiguration_timeoutAction :: Lens.Lens' ScalingConfiguration (Prelude.Maybe Prelude.Text)
scalingConfiguration_timeoutAction :: (Maybe Text -> f (Maybe Text))
-> ScalingConfiguration -> f ScalingConfiguration
scalingConfiguration_timeoutAction = (ScalingConfiguration -> Maybe Text)
-> (ScalingConfiguration -> Maybe Text -> ScalingConfiguration)
-> Lens
     ScalingConfiguration ScalingConfiguration (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingConfiguration' {Maybe Text
timeoutAction :: Maybe Text
$sel:timeoutAction:ScalingConfiguration' :: ScalingConfiguration -> Maybe Text
timeoutAction} -> Maybe Text
timeoutAction) (\s :: ScalingConfiguration
s@ScalingConfiguration' {} Maybe Text
a -> ScalingConfiguration
s {$sel:timeoutAction:ScalingConfiguration' :: Maybe Text
timeoutAction = Maybe Text
a} :: ScalingConfiguration)

-- | A value that indicates whether to allow or disallow automatic pause for
-- an Aurora DB cluster in @serverless@ DB engine mode. A DB cluster can be
-- paused only when it\'s idle (it has no connections).
--
-- If a DB cluster is paused for more than seven days, the DB cluster might
-- be backed up with a snapshot. In this case, the DB cluster is restored
-- when there is a request to connect to it.
scalingConfiguration_autoPause :: Lens.Lens' ScalingConfiguration (Prelude.Maybe Prelude.Bool)
scalingConfiguration_autoPause :: (Maybe Bool -> f (Maybe Bool))
-> ScalingConfiguration -> f ScalingConfiguration
scalingConfiguration_autoPause = (ScalingConfiguration -> Maybe Bool)
-> (ScalingConfiguration -> Maybe Bool -> ScalingConfiguration)
-> Lens
     ScalingConfiguration ScalingConfiguration (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingConfiguration' {Maybe Bool
autoPause :: Maybe Bool
$sel:autoPause:ScalingConfiguration' :: ScalingConfiguration -> Maybe Bool
autoPause} -> Maybe Bool
autoPause) (\s :: ScalingConfiguration
s@ScalingConfiguration' {} Maybe Bool
a -> ScalingConfiguration
s {$sel:autoPause:ScalingConfiguration' :: Maybe Bool
autoPause = Maybe Bool
a} :: ScalingConfiguration)

-- | The maximum capacity for an Aurora DB cluster in @serverless@ DB engine
-- mode.
--
-- For Aurora MySQL, valid capacity values are @1@, @2@, @4@, @8@, @16@,
-- @32@, @64@, @128@, and @256@.
--
-- For Aurora PostgreSQL, valid capacity values are @2@, @4@, @8@, @16@,
-- @32@, @64@, @192@, and @384@.
--
-- The maximum capacity must be greater than or equal to the minimum
-- capacity.
scalingConfiguration_maxCapacity :: Lens.Lens' ScalingConfiguration (Prelude.Maybe Prelude.Int)
scalingConfiguration_maxCapacity :: (Maybe Int -> f (Maybe Int))
-> ScalingConfiguration -> f ScalingConfiguration
scalingConfiguration_maxCapacity = (ScalingConfiguration -> Maybe Int)
-> (ScalingConfiguration -> Maybe Int -> ScalingConfiguration)
-> Lens
     ScalingConfiguration ScalingConfiguration (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingConfiguration' {Maybe Int
maxCapacity :: Maybe Int
$sel:maxCapacity:ScalingConfiguration' :: ScalingConfiguration -> Maybe Int
maxCapacity} -> Maybe Int
maxCapacity) (\s :: ScalingConfiguration
s@ScalingConfiguration' {} Maybe Int
a -> ScalingConfiguration
s {$sel:maxCapacity:ScalingConfiguration' :: Maybe Int
maxCapacity = Maybe Int
a} :: ScalingConfiguration)

-- | The minimum capacity for an Aurora DB cluster in @serverless@ DB engine
-- mode.
--
-- For Aurora MySQL, valid capacity values are @1@, @2@, @4@, @8@, @16@,
-- @32@, @64@, @128@, and @256@.
--
-- For Aurora PostgreSQL, valid capacity values are @2@, @4@, @8@, @16@,
-- @32@, @64@, @192@, and @384@.
--
-- The minimum capacity must be less than or equal to the maximum capacity.
scalingConfiguration_minCapacity :: Lens.Lens' ScalingConfiguration (Prelude.Maybe Prelude.Int)
scalingConfiguration_minCapacity :: (Maybe Int -> f (Maybe Int))
-> ScalingConfiguration -> f ScalingConfiguration
scalingConfiguration_minCapacity = (ScalingConfiguration -> Maybe Int)
-> (ScalingConfiguration -> Maybe Int -> ScalingConfiguration)
-> Lens
     ScalingConfiguration ScalingConfiguration (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingConfiguration' {Maybe Int
minCapacity :: Maybe Int
$sel:minCapacity:ScalingConfiguration' :: ScalingConfiguration -> Maybe Int
minCapacity} -> Maybe Int
minCapacity) (\s :: ScalingConfiguration
s@ScalingConfiguration' {} Maybe Int
a -> ScalingConfiguration
s {$sel:minCapacity:ScalingConfiguration' :: Maybe Int
minCapacity = Maybe Int
a} :: ScalingConfiguration)

-- | The amount of time, in seconds, that Aurora Serverless tries to find a
-- scaling point to perform seamless scaling before enforcing the timeout
-- action. The default is 300.
--
-- Specify a value between 60 and 600 seconds.
scalingConfiguration_secondsBeforeTimeout :: Lens.Lens' ScalingConfiguration (Prelude.Maybe Prelude.Int)
scalingConfiguration_secondsBeforeTimeout :: (Maybe Int -> f (Maybe Int))
-> ScalingConfiguration -> f ScalingConfiguration
scalingConfiguration_secondsBeforeTimeout = (ScalingConfiguration -> Maybe Int)
-> (ScalingConfiguration -> Maybe Int -> ScalingConfiguration)
-> Lens
     ScalingConfiguration ScalingConfiguration (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingConfiguration' {Maybe Int
secondsBeforeTimeout :: Maybe Int
$sel:secondsBeforeTimeout:ScalingConfiguration' :: ScalingConfiguration -> Maybe Int
secondsBeforeTimeout} -> Maybe Int
secondsBeforeTimeout) (\s :: ScalingConfiguration
s@ScalingConfiguration' {} Maybe Int
a -> ScalingConfiguration
s {$sel:secondsBeforeTimeout:ScalingConfiguration' :: Maybe Int
secondsBeforeTimeout = Maybe Int
a} :: ScalingConfiguration)

instance Prelude.Hashable ScalingConfiguration

instance Prelude.NFData ScalingConfiguration

instance Core.ToQuery ScalingConfiguration where
  toQuery :: ScalingConfiguration -> QueryString
toQuery ScalingConfiguration' {Maybe Bool
Maybe Int
Maybe Text
secondsBeforeTimeout :: Maybe Int
minCapacity :: Maybe Int
maxCapacity :: Maybe Int
autoPause :: Maybe Bool
timeoutAction :: Maybe Text
secondsUntilAutoPause :: Maybe Int
$sel:secondsBeforeTimeout:ScalingConfiguration' :: ScalingConfiguration -> Maybe Int
$sel:minCapacity:ScalingConfiguration' :: ScalingConfiguration -> Maybe Int
$sel:maxCapacity:ScalingConfiguration' :: ScalingConfiguration -> Maybe Int
$sel:autoPause:ScalingConfiguration' :: ScalingConfiguration -> Maybe Bool
$sel:timeoutAction:ScalingConfiguration' :: ScalingConfiguration -> Maybe Text
$sel:secondsUntilAutoPause:ScalingConfiguration' :: ScalingConfiguration -> Maybe Int
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"SecondsUntilAutoPause"
          ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
secondsUntilAutoPause,
        ByteString
"TimeoutAction" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
timeoutAction,
        ByteString
"AutoPause" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
autoPause,
        ByteString
"MaxCapacity" ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
maxCapacity,
        ByteString
"MinCapacity" ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
minCapacity,
        ByteString
"SecondsBeforeTimeout" ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
secondsBeforeTimeout
      ]