{-# 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.ApplicationAutoScaling.Types.StepScalingPolicyConfiguration
-- 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.ApplicationAutoScaling.Types.StepScalingPolicyConfiguration where

import Amazonka.ApplicationAutoScaling.Types.AdjustmentType
import Amazonka.ApplicationAutoScaling.Types.MetricAggregationType
import Amazonka.ApplicationAutoScaling.Types.StepAdjustment
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents a step scaling policy configuration to use with Application
-- Auto Scaling.
--
-- /See:/ 'newStepScalingPolicyConfiguration' smart constructor.
data StepScalingPolicyConfiguration = StepScalingPolicyConfiguration'
  { -- | A set of adjustments that enable you to scale based on the size of the
    -- alarm breach.
    --
    -- At least one step adjustment is required if you are adding a new step
    -- scaling policy configuration.
    StepScalingPolicyConfiguration -> Maybe [StepAdjustment]
stepAdjustments :: Prelude.Maybe [StepAdjustment],
    -- | Specifies how the @ScalingAdjustment@ value in a
    -- <https://docs.aws.amazon.com/autoscaling/application/APIReference/API_StepAdjustment.html StepAdjustment>
    -- is interpreted (for example, an absolute number or a percentage). The
    -- valid values are @ChangeInCapacity@, @ExactCapacity@, and
    -- @PercentChangeInCapacity@.
    --
    -- @AdjustmentType@ is required if you are adding a new step scaling policy
    -- configuration.
    StepScalingPolicyConfiguration -> Maybe AdjustmentType
adjustmentType :: Prelude.Maybe AdjustmentType,
    -- | The amount of time, in seconds, to wait for a previous scaling activity
    -- to take effect.
    --
    -- With scale-out policies, the intention is to continuously (but not
    -- excessively) scale out. After Application Auto Scaling successfully
    -- scales out using a step scaling policy, it starts to calculate the
    -- cooldown time. The scaling policy won\'t increase the desired capacity
    -- again unless either a larger scale out is triggered or the cooldown
    -- period ends. While the cooldown period is in effect, capacity added by
    -- the initiating scale-out activity is calculated as part of the desired
    -- capacity for the next scale-out activity. For example, when an alarm
    -- triggers a step scaling policy to increase the capacity by 2, the
    -- scaling activity completes successfully, and a cooldown period starts.
    -- If the alarm triggers again during the cooldown period but at a more
    -- aggressive step adjustment of 3, the previous increase of 2 is
    -- considered part of the current capacity. Therefore, only 1 is added to
    -- the capacity.
    --
    -- With scale-in policies, the intention is to scale in conservatively to
    -- protect your application’s availability, so scale-in activities are
    -- blocked until the cooldown period has expired. However, if another alarm
    -- triggers a scale-out activity during the cooldown period after a
    -- scale-in activity, Application Auto Scaling scales out the target
    -- immediately. In this case, the cooldown period for the scale-in activity
    -- stops and doesn\'t complete.
    --
    -- Application Auto Scaling provides a default value of 600 for Amazon
    -- ElastiCache replication groups and a default value of 300 for the
    -- following scalable targets:
    --
    -- -   AppStream 2.0 fleets
    --
    -- -   Aurora DB clusters
    --
    -- -   ECS services
    --
    -- -   EMR clusters
    --
    -- -   Neptune clusters
    --
    -- -   SageMaker endpoint variants
    --
    -- -   Spot Fleets
    --
    -- -   Custom resources
    --
    -- For all other scalable targets, the default value is 0:
    --
    -- -   Amazon Comprehend document classification and entity recognizer
    --     endpoints
    --
    -- -   DynamoDB tables and global secondary indexes
    --
    -- -   Amazon Keyspaces tables
    --
    -- -   Lambda provisioned concurrency
    --
    -- -   Amazon MSK broker storage
    StepScalingPolicyConfiguration -> Maybe Int
cooldown :: Prelude.Maybe Prelude.Int,
    -- | The aggregation type for the CloudWatch metrics. Valid values are
    -- @Minimum@, @Maximum@, and @Average@. If the aggregation type is null,
    -- the value is treated as @Average@.
    StepScalingPolicyConfiguration -> Maybe MetricAggregationType
metricAggregationType :: Prelude.Maybe MetricAggregationType,
    -- | The minimum value to scale by when the adjustment type is
    -- @PercentChangeInCapacity@. For example, suppose that you create a step
    -- scaling policy to scale out an Amazon ECS service by 25 percent and you
    -- specify a @MinAdjustmentMagnitude@ of 2. If the service has 4 tasks and
    -- the scaling policy is performed, 25 percent of 4 is 1. However, because
    -- you specified a @MinAdjustmentMagnitude@ of 2, Application Auto Scaling
    -- scales out the service by 2 tasks.
    StepScalingPolicyConfiguration -> Maybe Int
minAdjustmentMagnitude :: Prelude.Maybe Prelude.Int
  }
  deriving (StepScalingPolicyConfiguration
-> StepScalingPolicyConfiguration -> Bool
(StepScalingPolicyConfiguration
 -> StepScalingPolicyConfiguration -> Bool)
-> (StepScalingPolicyConfiguration
    -> StepScalingPolicyConfiguration -> Bool)
-> Eq StepScalingPolicyConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StepScalingPolicyConfiguration
-> StepScalingPolicyConfiguration -> Bool
$c/= :: StepScalingPolicyConfiguration
-> StepScalingPolicyConfiguration -> Bool
== :: StepScalingPolicyConfiguration
-> StepScalingPolicyConfiguration -> Bool
$c== :: StepScalingPolicyConfiguration
-> StepScalingPolicyConfiguration -> Bool
Prelude.Eq, ReadPrec [StepScalingPolicyConfiguration]
ReadPrec StepScalingPolicyConfiguration
Int -> ReadS StepScalingPolicyConfiguration
ReadS [StepScalingPolicyConfiguration]
(Int -> ReadS StepScalingPolicyConfiguration)
-> ReadS [StepScalingPolicyConfiguration]
-> ReadPrec StepScalingPolicyConfiguration
-> ReadPrec [StepScalingPolicyConfiguration]
-> Read StepScalingPolicyConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StepScalingPolicyConfiguration]
$creadListPrec :: ReadPrec [StepScalingPolicyConfiguration]
readPrec :: ReadPrec StepScalingPolicyConfiguration
$creadPrec :: ReadPrec StepScalingPolicyConfiguration
readList :: ReadS [StepScalingPolicyConfiguration]
$creadList :: ReadS [StepScalingPolicyConfiguration]
readsPrec :: Int -> ReadS StepScalingPolicyConfiguration
$creadsPrec :: Int -> ReadS StepScalingPolicyConfiguration
Prelude.Read, Int -> StepScalingPolicyConfiguration -> ShowS
[StepScalingPolicyConfiguration] -> ShowS
StepScalingPolicyConfiguration -> String
(Int -> StepScalingPolicyConfiguration -> ShowS)
-> (StepScalingPolicyConfiguration -> String)
-> ([StepScalingPolicyConfiguration] -> ShowS)
-> Show StepScalingPolicyConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StepScalingPolicyConfiguration] -> ShowS
$cshowList :: [StepScalingPolicyConfiguration] -> ShowS
show :: StepScalingPolicyConfiguration -> String
$cshow :: StepScalingPolicyConfiguration -> String
showsPrec :: Int -> StepScalingPolicyConfiguration -> ShowS
$cshowsPrec :: Int -> StepScalingPolicyConfiguration -> ShowS
Prelude.Show, (forall x.
 StepScalingPolicyConfiguration
 -> Rep StepScalingPolicyConfiguration x)
-> (forall x.
    Rep StepScalingPolicyConfiguration x
    -> StepScalingPolicyConfiguration)
-> Generic StepScalingPolicyConfiguration
forall x.
Rep StepScalingPolicyConfiguration x
-> StepScalingPolicyConfiguration
forall x.
StepScalingPolicyConfiguration
-> Rep StepScalingPolicyConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StepScalingPolicyConfiguration x
-> StepScalingPolicyConfiguration
$cfrom :: forall x.
StepScalingPolicyConfiguration
-> Rep StepScalingPolicyConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'StepScalingPolicyConfiguration' 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:
--
-- 'stepAdjustments', 'stepScalingPolicyConfiguration_stepAdjustments' - A set of adjustments that enable you to scale based on the size of the
-- alarm breach.
--
-- At least one step adjustment is required if you are adding a new step
-- scaling policy configuration.
--
-- 'adjustmentType', 'stepScalingPolicyConfiguration_adjustmentType' - Specifies how the @ScalingAdjustment@ value in a
-- <https://docs.aws.amazon.com/autoscaling/application/APIReference/API_StepAdjustment.html StepAdjustment>
-- is interpreted (for example, an absolute number or a percentage). The
-- valid values are @ChangeInCapacity@, @ExactCapacity@, and
-- @PercentChangeInCapacity@.
--
-- @AdjustmentType@ is required if you are adding a new step scaling policy
-- configuration.
--
-- 'cooldown', 'stepScalingPolicyConfiguration_cooldown' - The amount of time, in seconds, to wait for a previous scaling activity
-- to take effect.
--
-- With scale-out policies, the intention is to continuously (but not
-- excessively) scale out. After Application Auto Scaling successfully
-- scales out using a step scaling policy, it starts to calculate the
-- cooldown time. The scaling policy won\'t increase the desired capacity
-- again unless either a larger scale out is triggered or the cooldown
-- period ends. While the cooldown period is in effect, capacity added by
-- the initiating scale-out activity is calculated as part of the desired
-- capacity for the next scale-out activity. For example, when an alarm
-- triggers a step scaling policy to increase the capacity by 2, the
-- scaling activity completes successfully, and a cooldown period starts.
-- If the alarm triggers again during the cooldown period but at a more
-- aggressive step adjustment of 3, the previous increase of 2 is
-- considered part of the current capacity. Therefore, only 1 is added to
-- the capacity.
--
-- With scale-in policies, the intention is to scale in conservatively to
-- protect your application’s availability, so scale-in activities are
-- blocked until the cooldown period has expired. However, if another alarm
-- triggers a scale-out activity during the cooldown period after a
-- scale-in activity, Application Auto Scaling scales out the target
-- immediately. In this case, the cooldown period for the scale-in activity
-- stops and doesn\'t complete.
--
-- Application Auto Scaling provides a default value of 600 for Amazon
-- ElastiCache replication groups and a default value of 300 for the
-- following scalable targets:
--
-- -   AppStream 2.0 fleets
--
-- -   Aurora DB clusters
--
-- -   ECS services
--
-- -   EMR clusters
--
-- -   Neptune clusters
--
-- -   SageMaker endpoint variants
--
-- -   Spot Fleets
--
-- -   Custom resources
--
-- For all other scalable targets, the default value is 0:
--
-- -   Amazon Comprehend document classification and entity recognizer
--     endpoints
--
-- -   DynamoDB tables and global secondary indexes
--
-- -   Amazon Keyspaces tables
--
-- -   Lambda provisioned concurrency
--
-- -   Amazon MSK broker storage
--
-- 'metricAggregationType', 'stepScalingPolicyConfiguration_metricAggregationType' - The aggregation type for the CloudWatch metrics. Valid values are
-- @Minimum@, @Maximum@, and @Average@. If the aggregation type is null,
-- the value is treated as @Average@.
--
-- 'minAdjustmentMagnitude', 'stepScalingPolicyConfiguration_minAdjustmentMagnitude' - The minimum value to scale by when the adjustment type is
-- @PercentChangeInCapacity@. For example, suppose that you create a step
-- scaling policy to scale out an Amazon ECS service by 25 percent and you
-- specify a @MinAdjustmentMagnitude@ of 2. If the service has 4 tasks and
-- the scaling policy is performed, 25 percent of 4 is 1. However, because
-- you specified a @MinAdjustmentMagnitude@ of 2, Application Auto Scaling
-- scales out the service by 2 tasks.
newStepScalingPolicyConfiguration ::
  StepScalingPolicyConfiguration
newStepScalingPolicyConfiguration :: StepScalingPolicyConfiguration
newStepScalingPolicyConfiguration =
  StepScalingPolicyConfiguration' :: Maybe [StepAdjustment]
-> Maybe AdjustmentType
-> Maybe Int
-> Maybe MetricAggregationType
-> Maybe Int
-> StepScalingPolicyConfiguration
StepScalingPolicyConfiguration'
    { $sel:stepAdjustments:StepScalingPolicyConfiguration' :: Maybe [StepAdjustment]
stepAdjustments =
        Maybe [StepAdjustment]
forall a. Maybe a
Prelude.Nothing,
      $sel:adjustmentType:StepScalingPolicyConfiguration' :: Maybe AdjustmentType
adjustmentType = Maybe AdjustmentType
forall a. Maybe a
Prelude.Nothing,
      $sel:cooldown:StepScalingPolicyConfiguration' :: Maybe Int
cooldown = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:metricAggregationType:StepScalingPolicyConfiguration' :: Maybe MetricAggregationType
metricAggregationType = Maybe MetricAggregationType
forall a. Maybe a
Prelude.Nothing,
      $sel:minAdjustmentMagnitude:StepScalingPolicyConfiguration' :: Maybe Int
minAdjustmentMagnitude = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | A set of adjustments that enable you to scale based on the size of the
-- alarm breach.
--
-- At least one step adjustment is required if you are adding a new step
-- scaling policy configuration.
stepScalingPolicyConfiguration_stepAdjustments :: Lens.Lens' StepScalingPolicyConfiguration (Prelude.Maybe [StepAdjustment])
stepScalingPolicyConfiguration_stepAdjustments :: (Maybe [StepAdjustment] -> f (Maybe [StepAdjustment]))
-> StepScalingPolicyConfiguration
-> f StepScalingPolicyConfiguration
stepScalingPolicyConfiguration_stepAdjustments = (StepScalingPolicyConfiguration -> Maybe [StepAdjustment])
-> (StepScalingPolicyConfiguration
    -> Maybe [StepAdjustment] -> StepScalingPolicyConfiguration)
-> Lens
     StepScalingPolicyConfiguration
     StepScalingPolicyConfiguration
     (Maybe [StepAdjustment])
     (Maybe [StepAdjustment])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StepScalingPolicyConfiguration' {Maybe [StepAdjustment]
stepAdjustments :: Maybe [StepAdjustment]
$sel:stepAdjustments:StepScalingPolicyConfiguration' :: StepScalingPolicyConfiguration -> Maybe [StepAdjustment]
stepAdjustments} -> Maybe [StepAdjustment]
stepAdjustments) (\s :: StepScalingPolicyConfiguration
s@StepScalingPolicyConfiguration' {} Maybe [StepAdjustment]
a -> StepScalingPolicyConfiguration
s {$sel:stepAdjustments:StepScalingPolicyConfiguration' :: Maybe [StepAdjustment]
stepAdjustments = Maybe [StepAdjustment]
a} :: StepScalingPolicyConfiguration) ((Maybe [StepAdjustment] -> f (Maybe [StepAdjustment]))
 -> StepScalingPolicyConfiguration
 -> f StepScalingPolicyConfiguration)
-> ((Maybe [StepAdjustment] -> f (Maybe [StepAdjustment]))
    -> Maybe [StepAdjustment] -> f (Maybe [StepAdjustment]))
-> (Maybe [StepAdjustment] -> f (Maybe [StepAdjustment]))
-> StepScalingPolicyConfiguration
-> f StepScalingPolicyConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [StepAdjustment] [StepAdjustment] [StepAdjustment] [StepAdjustment]
-> Iso
     (Maybe [StepAdjustment])
     (Maybe [StepAdjustment])
     (Maybe [StepAdjustment])
     (Maybe [StepAdjustment])
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
  [StepAdjustment] [StepAdjustment] [StepAdjustment] [StepAdjustment]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies how the @ScalingAdjustment@ value in a
-- <https://docs.aws.amazon.com/autoscaling/application/APIReference/API_StepAdjustment.html StepAdjustment>
-- is interpreted (for example, an absolute number or a percentage). The
-- valid values are @ChangeInCapacity@, @ExactCapacity@, and
-- @PercentChangeInCapacity@.
--
-- @AdjustmentType@ is required if you are adding a new step scaling policy
-- configuration.
stepScalingPolicyConfiguration_adjustmentType :: Lens.Lens' StepScalingPolicyConfiguration (Prelude.Maybe AdjustmentType)
stepScalingPolicyConfiguration_adjustmentType :: (Maybe AdjustmentType -> f (Maybe AdjustmentType))
-> StepScalingPolicyConfiguration
-> f StepScalingPolicyConfiguration
stepScalingPolicyConfiguration_adjustmentType = (StepScalingPolicyConfiguration -> Maybe AdjustmentType)
-> (StepScalingPolicyConfiguration
    -> Maybe AdjustmentType -> StepScalingPolicyConfiguration)
-> Lens
     StepScalingPolicyConfiguration
     StepScalingPolicyConfiguration
     (Maybe AdjustmentType)
     (Maybe AdjustmentType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StepScalingPolicyConfiguration' {Maybe AdjustmentType
adjustmentType :: Maybe AdjustmentType
$sel:adjustmentType:StepScalingPolicyConfiguration' :: StepScalingPolicyConfiguration -> Maybe AdjustmentType
adjustmentType} -> Maybe AdjustmentType
adjustmentType) (\s :: StepScalingPolicyConfiguration
s@StepScalingPolicyConfiguration' {} Maybe AdjustmentType
a -> StepScalingPolicyConfiguration
s {$sel:adjustmentType:StepScalingPolicyConfiguration' :: Maybe AdjustmentType
adjustmentType = Maybe AdjustmentType
a} :: StepScalingPolicyConfiguration)

-- | The amount of time, in seconds, to wait for a previous scaling activity
-- to take effect.
--
-- With scale-out policies, the intention is to continuously (but not
-- excessively) scale out. After Application Auto Scaling successfully
-- scales out using a step scaling policy, it starts to calculate the
-- cooldown time. The scaling policy won\'t increase the desired capacity
-- again unless either a larger scale out is triggered or the cooldown
-- period ends. While the cooldown period is in effect, capacity added by
-- the initiating scale-out activity is calculated as part of the desired
-- capacity for the next scale-out activity. For example, when an alarm
-- triggers a step scaling policy to increase the capacity by 2, the
-- scaling activity completes successfully, and a cooldown period starts.
-- If the alarm triggers again during the cooldown period but at a more
-- aggressive step adjustment of 3, the previous increase of 2 is
-- considered part of the current capacity. Therefore, only 1 is added to
-- the capacity.
--
-- With scale-in policies, the intention is to scale in conservatively to
-- protect your application’s availability, so scale-in activities are
-- blocked until the cooldown period has expired. However, if another alarm
-- triggers a scale-out activity during the cooldown period after a
-- scale-in activity, Application Auto Scaling scales out the target
-- immediately. In this case, the cooldown period for the scale-in activity
-- stops and doesn\'t complete.
--
-- Application Auto Scaling provides a default value of 600 for Amazon
-- ElastiCache replication groups and a default value of 300 for the
-- following scalable targets:
--
-- -   AppStream 2.0 fleets
--
-- -   Aurora DB clusters
--
-- -   ECS services
--
-- -   EMR clusters
--
-- -   Neptune clusters
--
-- -   SageMaker endpoint variants
--
-- -   Spot Fleets
--
-- -   Custom resources
--
-- For all other scalable targets, the default value is 0:
--
-- -   Amazon Comprehend document classification and entity recognizer
--     endpoints
--
-- -   DynamoDB tables and global secondary indexes
--
-- -   Amazon Keyspaces tables
--
-- -   Lambda provisioned concurrency
--
-- -   Amazon MSK broker storage
stepScalingPolicyConfiguration_cooldown :: Lens.Lens' StepScalingPolicyConfiguration (Prelude.Maybe Prelude.Int)
stepScalingPolicyConfiguration_cooldown :: (Maybe Int -> f (Maybe Int))
-> StepScalingPolicyConfiguration
-> f StepScalingPolicyConfiguration
stepScalingPolicyConfiguration_cooldown = (StepScalingPolicyConfiguration -> Maybe Int)
-> (StepScalingPolicyConfiguration
    -> Maybe Int -> StepScalingPolicyConfiguration)
-> Lens
     StepScalingPolicyConfiguration
     StepScalingPolicyConfiguration
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StepScalingPolicyConfiguration' {Maybe Int
cooldown :: Maybe Int
$sel:cooldown:StepScalingPolicyConfiguration' :: StepScalingPolicyConfiguration -> Maybe Int
cooldown} -> Maybe Int
cooldown) (\s :: StepScalingPolicyConfiguration
s@StepScalingPolicyConfiguration' {} Maybe Int
a -> StepScalingPolicyConfiguration
s {$sel:cooldown:StepScalingPolicyConfiguration' :: Maybe Int
cooldown = Maybe Int
a} :: StepScalingPolicyConfiguration)

-- | The aggregation type for the CloudWatch metrics. Valid values are
-- @Minimum@, @Maximum@, and @Average@. If the aggregation type is null,
-- the value is treated as @Average@.
stepScalingPolicyConfiguration_metricAggregationType :: Lens.Lens' StepScalingPolicyConfiguration (Prelude.Maybe MetricAggregationType)
stepScalingPolicyConfiguration_metricAggregationType :: (Maybe MetricAggregationType -> f (Maybe MetricAggregationType))
-> StepScalingPolicyConfiguration
-> f StepScalingPolicyConfiguration
stepScalingPolicyConfiguration_metricAggregationType = (StepScalingPolicyConfiguration -> Maybe MetricAggregationType)
-> (StepScalingPolicyConfiguration
    -> Maybe MetricAggregationType -> StepScalingPolicyConfiguration)
-> Lens
     StepScalingPolicyConfiguration
     StepScalingPolicyConfiguration
     (Maybe MetricAggregationType)
     (Maybe MetricAggregationType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StepScalingPolicyConfiguration' {Maybe MetricAggregationType
metricAggregationType :: Maybe MetricAggregationType
$sel:metricAggregationType:StepScalingPolicyConfiguration' :: StepScalingPolicyConfiguration -> Maybe MetricAggregationType
metricAggregationType} -> Maybe MetricAggregationType
metricAggregationType) (\s :: StepScalingPolicyConfiguration
s@StepScalingPolicyConfiguration' {} Maybe MetricAggregationType
a -> StepScalingPolicyConfiguration
s {$sel:metricAggregationType:StepScalingPolicyConfiguration' :: Maybe MetricAggregationType
metricAggregationType = Maybe MetricAggregationType
a} :: StepScalingPolicyConfiguration)

-- | The minimum value to scale by when the adjustment type is
-- @PercentChangeInCapacity@. For example, suppose that you create a step
-- scaling policy to scale out an Amazon ECS service by 25 percent and you
-- specify a @MinAdjustmentMagnitude@ of 2. If the service has 4 tasks and
-- the scaling policy is performed, 25 percent of 4 is 1. However, because
-- you specified a @MinAdjustmentMagnitude@ of 2, Application Auto Scaling
-- scales out the service by 2 tasks.
stepScalingPolicyConfiguration_minAdjustmentMagnitude :: Lens.Lens' StepScalingPolicyConfiguration (Prelude.Maybe Prelude.Int)
stepScalingPolicyConfiguration_minAdjustmentMagnitude :: (Maybe Int -> f (Maybe Int))
-> StepScalingPolicyConfiguration
-> f StepScalingPolicyConfiguration
stepScalingPolicyConfiguration_minAdjustmentMagnitude = (StepScalingPolicyConfiguration -> Maybe Int)
-> (StepScalingPolicyConfiguration
    -> Maybe Int -> StepScalingPolicyConfiguration)
-> Lens
     StepScalingPolicyConfiguration
     StepScalingPolicyConfiguration
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StepScalingPolicyConfiguration' {Maybe Int
minAdjustmentMagnitude :: Maybe Int
$sel:minAdjustmentMagnitude:StepScalingPolicyConfiguration' :: StepScalingPolicyConfiguration -> Maybe Int
minAdjustmentMagnitude} -> Maybe Int
minAdjustmentMagnitude) (\s :: StepScalingPolicyConfiguration
s@StepScalingPolicyConfiguration' {} Maybe Int
a -> StepScalingPolicyConfiguration
s {$sel:minAdjustmentMagnitude:StepScalingPolicyConfiguration' :: Maybe Int
minAdjustmentMagnitude = Maybe Int
a} :: StepScalingPolicyConfiguration)

instance Core.FromJSON StepScalingPolicyConfiguration where
  parseJSON :: Value -> Parser StepScalingPolicyConfiguration
parseJSON =
    String
-> (Object -> Parser StepScalingPolicyConfiguration)
-> Value
-> Parser StepScalingPolicyConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StepScalingPolicyConfiguration"
      ( \Object
x ->
          Maybe [StepAdjustment]
-> Maybe AdjustmentType
-> Maybe Int
-> Maybe MetricAggregationType
-> Maybe Int
-> StepScalingPolicyConfiguration
StepScalingPolicyConfiguration'
            (Maybe [StepAdjustment]
 -> Maybe AdjustmentType
 -> Maybe Int
 -> Maybe MetricAggregationType
 -> Maybe Int
 -> StepScalingPolicyConfiguration)
-> Parser (Maybe [StepAdjustment])
-> Parser
     (Maybe AdjustmentType
      -> Maybe Int
      -> Maybe MetricAggregationType
      -> Maybe Int
      -> StepScalingPolicyConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [StepAdjustment]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StepAdjustments"
                            Parser (Maybe (Maybe [StepAdjustment]))
-> Maybe [StepAdjustment] -> Parser (Maybe [StepAdjustment])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [StepAdjustment]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe AdjustmentType
   -> Maybe Int
   -> Maybe MetricAggregationType
   -> Maybe Int
   -> StepScalingPolicyConfiguration)
-> Parser (Maybe AdjustmentType)
-> Parser
     (Maybe Int
      -> Maybe MetricAggregationType
      -> Maybe Int
      -> StepScalingPolicyConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AdjustmentType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AdjustmentType")
            Parser
  (Maybe Int
   -> Maybe MetricAggregationType
   -> Maybe Int
   -> StepScalingPolicyConfiguration)
-> Parser (Maybe Int)
-> Parser
     (Maybe MetricAggregationType
      -> Maybe Int -> StepScalingPolicyConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Cooldown")
            Parser
  (Maybe MetricAggregationType
   -> Maybe Int -> StepScalingPolicyConfiguration)
-> Parser (Maybe MetricAggregationType)
-> Parser (Maybe Int -> StepScalingPolicyConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe MetricAggregationType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MetricAggregationType")
            Parser (Maybe Int -> StepScalingPolicyConfiguration)
-> Parser (Maybe Int) -> Parser StepScalingPolicyConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MinAdjustmentMagnitude")
      )

instance
  Prelude.Hashable
    StepScalingPolicyConfiguration

instance
  Prelude.NFData
    StepScalingPolicyConfiguration

instance Core.ToJSON StepScalingPolicyConfiguration where
  toJSON :: StepScalingPolicyConfiguration -> Value
toJSON StepScalingPolicyConfiguration' {Maybe Int
Maybe [StepAdjustment]
Maybe AdjustmentType
Maybe MetricAggregationType
minAdjustmentMagnitude :: Maybe Int
metricAggregationType :: Maybe MetricAggregationType
cooldown :: Maybe Int
adjustmentType :: Maybe AdjustmentType
stepAdjustments :: Maybe [StepAdjustment]
$sel:minAdjustmentMagnitude:StepScalingPolicyConfiguration' :: StepScalingPolicyConfiguration -> Maybe Int
$sel:metricAggregationType:StepScalingPolicyConfiguration' :: StepScalingPolicyConfiguration -> Maybe MetricAggregationType
$sel:cooldown:StepScalingPolicyConfiguration' :: StepScalingPolicyConfiguration -> Maybe Int
$sel:adjustmentType:StepScalingPolicyConfiguration' :: StepScalingPolicyConfiguration -> Maybe AdjustmentType
$sel:stepAdjustments:StepScalingPolicyConfiguration' :: StepScalingPolicyConfiguration -> Maybe [StepAdjustment]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"StepAdjustments" Text -> [StepAdjustment] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([StepAdjustment] -> Pair) -> Maybe [StepAdjustment] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [StepAdjustment]
stepAdjustments,
            (Text
"AdjustmentType" Text -> AdjustmentType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AdjustmentType -> Pair) -> Maybe AdjustmentType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AdjustmentType
adjustmentType,
            (Text
"Cooldown" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
cooldown,
            (Text
"MetricAggregationType" Text -> MetricAggregationType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (MetricAggregationType -> Pair)
-> Maybe MetricAggregationType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MetricAggregationType
metricAggregationType,
            (Text
"MinAdjustmentMagnitude" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
minAdjustmentMagnitude
          ]
      )