{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.AutoScaling.PutScalingPolicy
-- 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)
--
-- Creates or updates a scaling policy for an Auto Scaling group. Scaling
-- policies are used to scale an Auto Scaling group based on configurable
-- metrics. If no policies are defined, the dynamic scaling and predictive
-- scaling features are not used.
--
-- For more information about using dynamic scaling, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-target-tracking.html Target tracking scaling policies>
-- and
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-simple-step.html Step and simple scaling policies>
-- in the /Amazon EC2 Auto Scaling User Guide/.
--
-- For more information about using predictive scaling, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-predictive-scaling.html Predictive scaling for Amazon EC2 Auto Scaling>
-- in the /Amazon EC2 Auto Scaling User Guide/.
--
-- You can view the scaling policies for an Auto Scaling group using the
-- DescribePolicies API call. If you are no longer using a scaling policy,
-- you can delete it by calling the DeletePolicy API.
module Amazonka.AutoScaling.PutScalingPolicy
  ( -- * Creating a Request
    PutScalingPolicy (..),
    newPutScalingPolicy,

    -- * Request Lenses
    putScalingPolicy_minAdjustmentStep,
    putScalingPolicy_estimatedInstanceWarmup,
    putScalingPolicy_enabled,
    putScalingPolicy_policyType,
    putScalingPolicy_stepAdjustments,
    putScalingPolicy_targetTrackingConfiguration,
    putScalingPolicy_adjustmentType,
    putScalingPolicy_predictiveScalingConfiguration,
    putScalingPolicy_scalingAdjustment,
    putScalingPolicy_cooldown,
    putScalingPolicy_metricAggregationType,
    putScalingPolicy_minAdjustmentMagnitude,
    putScalingPolicy_autoScalingGroupName,
    putScalingPolicy_policyName,

    -- * Destructuring the Response
    PutScalingPolicyResponse (..),
    newPutScalingPolicyResponse,

    -- * Response Lenses
    putScalingPolicyResponse_policyARN,
    putScalingPolicyResponse_alarms,
    putScalingPolicyResponse_httpStatus,
  )
where

import Amazonka.AutoScaling.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newPutScalingPolicy' smart constructor.
data PutScalingPolicy = PutScalingPolicy'
  { -- | Available for backward compatibility. Use @MinAdjustmentMagnitude@
    -- instead.
    PutScalingPolicy -> Maybe Int
minAdjustmentStep :: Prelude.Maybe Prelude.Int,
    -- | The estimated time, in seconds, until a newly launched instance can
    -- contribute to the CloudWatch metrics. If not provided, the default is to
    -- use the value from the default cooldown period for the Auto Scaling
    -- group.
    --
    -- Valid only if the policy type is @TargetTrackingScaling@ or
    -- @StepScaling@.
    PutScalingPolicy -> Maybe Int
estimatedInstanceWarmup :: Prelude.Maybe Prelude.Int,
    -- | Indicates whether the scaling policy is enabled or disabled. The default
    -- is enabled. For more information, see
    -- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-enable-disable-scaling-policy.html Disabling a scaling policy for an Auto Scaling group>
    -- in the /Amazon EC2 Auto Scaling User Guide/.
    PutScalingPolicy -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | One of the following policy types:
    --
    -- -   @TargetTrackingScaling@
    --
    -- -   @StepScaling@
    --
    -- -   @SimpleScaling@ (default)
    --
    -- -   @PredictiveScaling@
    PutScalingPolicy -> Maybe Text
policyType :: Prelude.Maybe Prelude.Text,
    -- | A set of adjustments that enable you to scale based on the size of the
    -- alarm breach.
    --
    -- Required if the policy type is @StepScaling@. (Not used with any other
    -- policy type.)
    PutScalingPolicy -> Maybe [StepAdjustment]
stepAdjustments :: Prelude.Maybe [StepAdjustment],
    -- | A target tracking scaling policy. Provides support for predefined or
    -- customized metrics.
    --
    -- The following predefined metrics are available:
    --
    -- -   @ASGAverageCPUUtilization@
    --
    -- -   @ASGAverageNetworkIn@
    --
    -- -   @ASGAverageNetworkOut@
    --
    -- -   @ALBRequestCountPerTarget@
    --
    -- If you specify @ALBRequestCountPerTarget@ for the metric, you must
    -- specify the @ResourceLabel@ parameter with the
    -- @PredefinedMetricSpecification@.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_TargetTrackingConfiguration.html TargetTrackingConfiguration>
    -- in the /Amazon EC2 Auto Scaling API Reference/.
    --
    -- Required if the policy type is @TargetTrackingScaling@.
    PutScalingPolicy -> Maybe TargetTrackingConfiguration
targetTrackingConfiguration :: Prelude.Maybe TargetTrackingConfiguration,
    -- | Specifies how the scaling adjustment is interpreted (for example, an
    -- absolute number or a percentage). The valid values are
    -- @ChangeInCapacity@, @ExactCapacity@, and @PercentChangeInCapacity@.
    --
    -- Required if the policy type is @StepScaling@ or @SimpleScaling@. For
    -- more information, see
    -- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-simple-step.html#as-scaling-adjustment Scaling adjustment types>
    -- in the /Amazon EC2 Auto Scaling User Guide/.
    PutScalingPolicy -> Maybe Text
adjustmentType :: Prelude.Maybe Prelude.Text,
    -- | A predictive scaling policy. Provides support for only predefined
    -- metrics.
    --
    -- Predictive scaling works with CPU utilization, network in\/out, and the
    -- Application Load Balancer request count.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_PredictiveScalingConfiguration.html PredictiveScalingConfiguration>
    -- in the /Amazon EC2 Auto Scaling API Reference/.
    --
    -- Required if the policy type is @PredictiveScaling@.
    PutScalingPolicy -> Maybe PredictiveScalingConfiguration
predictiveScalingConfiguration :: Prelude.Maybe PredictiveScalingConfiguration,
    -- | The amount by which to scale, based on the specified adjustment type. A
    -- positive value adds to the current capacity while a negative number
    -- removes from the current capacity. For exact capacity, you must specify
    -- a positive value.
    --
    -- Required if the policy type is @SimpleScaling@. (Not used with any other
    -- policy type.)
    PutScalingPolicy -> Maybe Int
scalingAdjustment :: Prelude.Maybe Prelude.Int,
    -- | The duration of the policy\'s cooldown period, in seconds. When a
    -- cooldown period is specified here, it overrides the default cooldown
    -- period defined for the Auto Scaling group.
    --
    -- Valid only if the policy type is @SimpleScaling@. For more information,
    -- see
    -- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/Cooldown.html Scaling cooldowns for Amazon EC2 Auto Scaling>
    -- in the /Amazon EC2 Auto Scaling User Guide/.
    PutScalingPolicy -> Maybe Int
cooldown :: Prelude.Maybe Prelude.Int,
    -- | The aggregation type for the CloudWatch metrics. The valid values are
    -- @Minimum@, @Maximum@, and @Average@. If the aggregation type is null,
    -- the value is treated as @Average@.
    --
    -- Valid only if the policy type is @StepScaling@.
    PutScalingPolicy -> Maybe Text
metricAggregationType :: Prelude.Maybe Prelude.Text,
    -- | 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 Auto Scaling group by 25 percent and you
    -- specify a @MinAdjustmentMagnitude@ of 2. If the group has 4 instances
    -- and the scaling policy is performed, 25 percent of 4 is 1. However,
    -- because you specified a @MinAdjustmentMagnitude@ of 2, Amazon EC2 Auto
    -- Scaling scales out the group by 2 instances.
    --
    -- Valid only if the policy type is @StepScaling@ or @SimpleScaling@. For
    -- more information, see
    -- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-simple-step.html#as-scaling-adjustment Scaling adjustment types>
    -- in the /Amazon EC2 Auto Scaling User Guide/.
    --
    -- Some Auto Scaling groups use instance weights. In this case, set the
    -- @MinAdjustmentMagnitude@ to a value that is at least as large as your
    -- largest instance weight.
    PutScalingPolicy -> Maybe Int
minAdjustmentMagnitude :: Prelude.Maybe Prelude.Int,
    -- | The name of the Auto Scaling group.
    PutScalingPolicy -> Text
autoScalingGroupName :: Prelude.Text,
    -- | The name of the policy.
    PutScalingPolicy -> Text
policyName :: Prelude.Text
  }
  deriving (PutScalingPolicy -> PutScalingPolicy -> Bool
(PutScalingPolicy -> PutScalingPolicy -> Bool)
-> (PutScalingPolicy -> PutScalingPolicy -> Bool)
-> Eq PutScalingPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutScalingPolicy -> PutScalingPolicy -> Bool
$c/= :: PutScalingPolicy -> PutScalingPolicy -> Bool
== :: PutScalingPolicy -> PutScalingPolicy -> Bool
$c== :: PutScalingPolicy -> PutScalingPolicy -> Bool
Prelude.Eq, ReadPrec [PutScalingPolicy]
ReadPrec PutScalingPolicy
Int -> ReadS PutScalingPolicy
ReadS [PutScalingPolicy]
(Int -> ReadS PutScalingPolicy)
-> ReadS [PutScalingPolicy]
-> ReadPrec PutScalingPolicy
-> ReadPrec [PutScalingPolicy]
-> Read PutScalingPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutScalingPolicy]
$creadListPrec :: ReadPrec [PutScalingPolicy]
readPrec :: ReadPrec PutScalingPolicy
$creadPrec :: ReadPrec PutScalingPolicy
readList :: ReadS [PutScalingPolicy]
$creadList :: ReadS [PutScalingPolicy]
readsPrec :: Int -> ReadS PutScalingPolicy
$creadsPrec :: Int -> ReadS PutScalingPolicy
Prelude.Read, Int -> PutScalingPolicy -> ShowS
[PutScalingPolicy] -> ShowS
PutScalingPolicy -> String
(Int -> PutScalingPolicy -> ShowS)
-> (PutScalingPolicy -> String)
-> ([PutScalingPolicy] -> ShowS)
-> Show PutScalingPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutScalingPolicy] -> ShowS
$cshowList :: [PutScalingPolicy] -> ShowS
show :: PutScalingPolicy -> String
$cshow :: PutScalingPolicy -> String
showsPrec :: Int -> PutScalingPolicy -> ShowS
$cshowsPrec :: Int -> PutScalingPolicy -> ShowS
Prelude.Show, (forall x. PutScalingPolicy -> Rep PutScalingPolicy x)
-> (forall x. Rep PutScalingPolicy x -> PutScalingPolicy)
-> Generic PutScalingPolicy
forall x. Rep PutScalingPolicy x -> PutScalingPolicy
forall x. PutScalingPolicy -> Rep PutScalingPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutScalingPolicy x -> PutScalingPolicy
$cfrom :: forall x. PutScalingPolicy -> Rep PutScalingPolicy x
Prelude.Generic)

-- |
-- Create a value of 'PutScalingPolicy' 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:
--
-- 'minAdjustmentStep', 'putScalingPolicy_minAdjustmentStep' - Available for backward compatibility. Use @MinAdjustmentMagnitude@
-- instead.
--
-- 'estimatedInstanceWarmup', 'putScalingPolicy_estimatedInstanceWarmup' - The estimated time, in seconds, until a newly launched instance can
-- contribute to the CloudWatch metrics. If not provided, the default is to
-- use the value from the default cooldown period for the Auto Scaling
-- group.
--
-- Valid only if the policy type is @TargetTrackingScaling@ or
-- @StepScaling@.
--
-- 'enabled', 'putScalingPolicy_enabled' - Indicates whether the scaling policy is enabled or disabled. The default
-- is enabled. For more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-enable-disable-scaling-policy.html Disabling a scaling policy for an Auto Scaling group>
-- in the /Amazon EC2 Auto Scaling User Guide/.
--
-- 'policyType', 'putScalingPolicy_policyType' - One of the following policy types:
--
-- -   @TargetTrackingScaling@
--
-- -   @StepScaling@
--
-- -   @SimpleScaling@ (default)
--
-- -   @PredictiveScaling@
--
-- 'stepAdjustments', 'putScalingPolicy_stepAdjustments' - A set of adjustments that enable you to scale based on the size of the
-- alarm breach.
--
-- Required if the policy type is @StepScaling@. (Not used with any other
-- policy type.)
--
-- 'targetTrackingConfiguration', 'putScalingPolicy_targetTrackingConfiguration' - A target tracking scaling policy. Provides support for predefined or
-- customized metrics.
--
-- The following predefined metrics are available:
--
-- -   @ASGAverageCPUUtilization@
--
-- -   @ASGAverageNetworkIn@
--
-- -   @ASGAverageNetworkOut@
--
-- -   @ALBRequestCountPerTarget@
--
-- If you specify @ALBRequestCountPerTarget@ for the metric, you must
-- specify the @ResourceLabel@ parameter with the
-- @PredefinedMetricSpecification@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_TargetTrackingConfiguration.html TargetTrackingConfiguration>
-- in the /Amazon EC2 Auto Scaling API Reference/.
--
-- Required if the policy type is @TargetTrackingScaling@.
--
-- 'adjustmentType', 'putScalingPolicy_adjustmentType' - Specifies how the scaling adjustment is interpreted (for example, an
-- absolute number or a percentage). The valid values are
-- @ChangeInCapacity@, @ExactCapacity@, and @PercentChangeInCapacity@.
--
-- Required if the policy type is @StepScaling@ or @SimpleScaling@. For
-- more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-simple-step.html#as-scaling-adjustment Scaling adjustment types>
-- in the /Amazon EC2 Auto Scaling User Guide/.
--
-- 'predictiveScalingConfiguration', 'putScalingPolicy_predictiveScalingConfiguration' - A predictive scaling policy. Provides support for only predefined
-- metrics.
--
-- Predictive scaling works with CPU utilization, network in\/out, and the
-- Application Load Balancer request count.
--
-- For more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_PredictiveScalingConfiguration.html PredictiveScalingConfiguration>
-- in the /Amazon EC2 Auto Scaling API Reference/.
--
-- Required if the policy type is @PredictiveScaling@.
--
-- 'scalingAdjustment', 'putScalingPolicy_scalingAdjustment' - The amount by which to scale, based on the specified adjustment type. A
-- positive value adds to the current capacity while a negative number
-- removes from the current capacity. For exact capacity, you must specify
-- a positive value.
--
-- Required if the policy type is @SimpleScaling@. (Not used with any other
-- policy type.)
--
-- 'cooldown', 'putScalingPolicy_cooldown' - The duration of the policy\'s cooldown period, in seconds. When a
-- cooldown period is specified here, it overrides the default cooldown
-- period defined for the Auto Scaling group.
--
-- Valid only if the policy type is @SimpleScaling@. For more information,
-- see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/Cooldown.html Scaling cooldowns for Amazon EC2 Auto Scaling>
-- in the /Amazon EC2 Auto Scaling User Guide/.
--
-- 'metricAggregationType', 'putScalingPolicy_metricAggregationType' - The aggregation type for the CloudWatch metrics. The valid values are
-- @Minimum@, @Maximum@, and @Average@. If the aggregation type is null,
-- the value is treated as @Average@.
--
-- Valid only if the policy type is @StepScaling@.
--
-- 'minAdjustmentMagnitude', 'putScalingPolicy_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 Auto Scaling group by 25 percent and you
-- specify a @MinAdjustmentMagnitude@ of 2. If the group has 4 instances
-- and the scaling policy is performed, 25 percent of 4 is 1. However,
-- because you specified a @MinAdjustmentMagnitude@ of 2, Amazon EC2 Auto
-- Scaling scales out the group by 2 instances.
--
-- Valid only if the policy type is @StepScaling@ or @SimpleScaling@. For
-- more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-simple-step.html#as-scaling-adjustment Scaling adjustment types>
-- in the /Amazon EC2 Auto Scaling User Guide/.
--
-- Some Auto Scaling groups use instance weights. In this case, set the
-- @MinAdjustmentMagnitude@ to a value that is at least as large as your
-- largest instance weight.
--
-- 'autoScalingGroupName', 'putScalingPolicy_autoScalingGroupName' - The name of the Auto Scaling group.
--
-- 'policyName', 'putScalingPolicy_policyName' - The name of the policy.
newPutScalingPolicy ::
  -- | 'autoScalingGroupName'
  Prelude.Text ->
  -- | 'policyName'
  Prelude.Text ->
  PutScalingPolicy
newPutScalingPolicy :: Text -> Text -> PutScalingPolicy
newPutScalingPolicy
  Text
pAutoScalingGroupName_
  Text
pPolicyName_ =
    PutScalingPolicy' :: Maybe Int
-> Maybe Int
-> Maybe Bool
-> Maybe Text
-> Maybe [StepAdjustment]
-> Maybe TargetTrackingConfiguration
-> Maybe Text
-> Maybe PredictiveScalingConfiguration
-> Maybe Int
-> Maybe Int
-> Maybe Text
-> Maybe Int
-> Text
-> Text
-> PutScalingPolicy
PutScalingPolicy'
      { $sel:minAdjustmentStep:PutScalingPolicy' :: Maybe Int
minAdjustmentStep =
          Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:estimatedInstanceWarmup:PutScalingPolicy' :: Maybe Int
estimatedInstanceWarmup = Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:enabled:PutScalingPolicy' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
        $sel:policyType:PutScalingPolicy' :: Maybe Text
policyType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:stepAdjustments:PutScalingPolicy' :: Maybe [StepAdjustment]
stepAdjustments = Maybe [StepAdjustment]
forall a. Maybe a
Prelude.Nothing,
        $sel:targetTrackingConfiguration:PutScalingPolicy' :: Maybe TargetTrackingConfiguration
targetTrackingConfiguration = Maybe TargetTrackingConfiguration
forall a. Maybe a
Prelude.Nothing,
        $sel:adjustmentType:PutScalingPolicy' :: Maybe Text
adjustmentType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:predictiveScalingConfiguration:PutScalingPolicy' :: Maybe PredictiveScalingConfiguration
predictiveScalingConfiguration = Maybe PredictiveScalingConfiguration
forall a. Maybe a
Prelude.Nothing,
        $sel:scalingAdjustment:PutScalingPolicy' :: Maybe Int
scalingAdjustment = Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:cooldown:PutScalingPolicy' :: Maybe Int
cooldown = Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:metricAggregationType:PutScalingPolicy' :: Maybe Text
metricAggregationType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:minAdjustmentMagnitude:PutScalingPolicy' :: Maybe Int
minAdjustmentMagnitude = Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:autoScalingGroupName:PutScalingPolicy' :: Text
autoScalingGroupName = Text
pAutoScalingGroupName_,
        $sel:policyName:PutScalingPolicy' :: Text
policyName = Text
pPolicyName_
      }

-- | Available for backward compatibility. Use @MinAdjustmentMagnitude@
-- instead.
putScalingPolicy_minAdjustmentStep :: Lens.Lens' PutScalingPolicy (Prelude.Maybe Prelude.Int)
putScalingPolicy_minAdjustmentStep :: (Maybe Int -> f (Maybe Int))
-> PutScalingPolicy -> f PutScalingPolicy
putScalingPolicy_minAdjustmentStep = (PutScalingPolicy -> Maybe Int)
-> (PutScalingPolicy -> Maybe Int -> PutScalingPolicy)
-> Lens PutScalingPolicy PutScalingPolicy (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutScalingPolicy' {Maybe Int
minAdjustmentStep :: Maybe Int
$sel:minAdjustmentStep:PutScalingPolicy' :: PutScalingPolicy -> Maybe Int
minAdjustmentStep} -> Maybe Int
minAdjustmentStep) (\s :: PutScalingPolicy
s@PutScalingPolicy' {} Maybe Int
a -> PutScalingPolicy
s {$sel:minAdjustmentStep:PutScalingPolicy' :: Maybe Int
minAdjustmentStep = Maybe Int
a} :: PutScalingPolicy)

-- | The estimated time, in seconds, until a newly launched instance can
-- contribute to the CloudWatch metrics. If not provided, the default is to
-- use the value from the default cooldown period for the Auto Scaling
-- group.
--
-- Valid only if the policy type is @TargetTrackingScaling@ or
-- @StepScaling@.
putScalingPolicy_estimatedInstanceWarmup :: Lens.Lens' PutScalingPolicy (Prelude.Maybe Prelude.Int)
putScalingPolicy_estimatedInstanceWarmup :: (Maybe Int -> f (Maybe Int))
-> PutScalingPolicy -> f PutScalingPolicy
putScalingPolicy_estimatedInstanceWarmup = (PutScalingPolicy -> Maybe Int)
-> (PutScalingPolicy -> Maybe Int -> PutScalingPolicy)
-> Lens PutScalingPolicy PutScalingPolicy (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutScalingPolicy' {Maybe Int
estimatedInstanceWarmup :: Maybe Int
$sel:estimatedInstanceWarmup:PutScalingPolicy' :: PutScalingPolicy -> Maybe Int
estimatedInstanceWarmup} -> Maybe Int
estimatedInstanceWarmup) (\s :: PutScalingPolicy
s@PutScalingPolicy' {} Maybe Int
a -> PutScalingPolicy
s {$sel:estimatedInstanceWarmup:PutScalingPolicy' :: Maybe Int
estimatedInstanceWarmup = Maybe Int
a} :: PutScalingPolicy)

-- | Indicates whether the scaling policy is enabled or disabled. The default
-- is enabled. For more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-enable-disable-scaling-policy.html Disabling a scaling policy for an Auto Scaling group>
-- in the /Amazon EC2 Auto Scaling User Guide/.
putScalingPolicy_enabled :: Lens.Lens' PutScalingPolicy (Prelude.Maybe Prelude.Bool)
putScalingPolicy_enabled :: (Maybe Bool -> f (Maybe Bool))
-> PutScalingPolicy -> f PutScalingPolicy
putScalingPolicy_enabled = (PutScalingPolicy -> Maybe Bool)
-> (PutScalingPolicy -> Maybe Bool -> PutScalingPolicy)
-> Lens PutScalingPolicy PutScalingPolicy (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutScalingPolicy' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:PutScalingPolicy' :: PutScalingPolicy -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: PutScalingPolicy
s@PutScalingPolicy' {} Maybe Bool
a -> PutScalingPolicy
s {$sel:enabled:PutScalingPolicy' :: Maybe Bool
enabled = Maybe Bool
a} :: PutScalingPolicy)

-- | One of the following policy types:
--
-- -   @TargetTrackingScaling@
--
-- -   @StepScaling@
--
-- -   @SimpleScaling@ (default)
--
-- -   @PredictiveScaling@
putScalingPolicy_policyType :: Lens.Lens' PutScalingPolicy (Prelude.Maybe Prelude.Text)
putScalingPolicy_policyType :: (Maybe Text -> f (Maybe Text))
-> PutScalingPolicy -> f PutScalingPolicy
putScalingPolicy_policyType = (PutScalingPolicy -> Maybe Text)
-> (PutScalingPolicy -> Maybe Text -> PutScalingPolicy)
-> Lens PutScalingPolicy PutScalingPolicy (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutScalingPolicy' {Maybe Text
policyType :: Maybe Text
$sel:policyType:PutScalingPolicy' :: PutScalingPolicy -> Maybe Text
policyType} -> Maybe Text
policyType) (\s :: PutScalingPolicy
s@PutScalingPolicy' {} Maybe Text
a -> PutScalingPolicy
s {$sel:policyType:PutScalingPolicy' :: Maybe Text
policyType = Maybe Text
a} :: PutScalingPolicy)

-- | A set of adjustments that enable you to scale based on the size of the
-- alarm breach.
--
-- Required if the policy type is @StepScaling@. (Not used with any other
-- policy type.)
putScalingPolicy_stepAdjustments :: Lens.Lens' PutScalingPolicy (Prelude.Maybe [StepAdjustment])
putScalingPolicy_stepAdjustments :: (Maybe [StepAdjustment] -> f (Maybe [StepAdjustment]))
-> PutScalingPolicy -> f PutScalingPolicy
putScalingPolicy_stepAdjustments = (PutScalingPolicy -> Maybe [StepAdjustment])
-> (PutScalingPolicy -> Maybe [StepAdjustment] -> PutScalingPolicy)
-> Lens
     PutScalingPolicy
     PutScalingPolicy
     (Maybe [StepAdjustment])
     (Maybe [StepAdjustment])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutScalingPolicy' {Maybe [StepAdjustment]
stepAdjustments :: Maybe [StepAdjustment]
$sel:stepAdjustments:PutScalingPolicy' :: PutScalingPolicy -> Maybe [StepAdjustment]
stepAdjustments} -> Maybe [StepAdjustment]
stepAdjustments) (\s :: PutScalingPolicy
s@PutScalingPolicy' {} Maybe [StepAdjustment]
a -> PutScalingPolicy
s {$sel:stepAdjustments:PutScalingPolicy' :: Maybe [StepAdjustment]
stepAdjustments = Maybe [StepAdjustment]
a} :: PutScalingPolicy) ((Maybe [StepAdjustment] -> f (Maybe [StepAdjustment]))
 -> PutScalingPolicy -> f PutScalingPolicy)
-> ((Maybe [StepAdjustment] -> f (Maybe [StepAdjustment]))
    -> Maybe [StepAdjustment] -> f (Maybe [StepAdjustment]))
-> (Maybe [StepAdjustment] -> f (Maybe [StepAdjustment]))
-> PutScalingPolicy
-> f PutScalingPolicy
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

-- | A target tracking scaling policy. Provides support for predefined or
-- customized metrics.
--
-- The following predefined metrics are available:
--
-- -   @ASGAverageCPUUtilization@
--
-- -   @ASGAverageNetworkIn@
--
-- -   @ASGAverageNetworkOut@
--
-- -   @ALBRequestCountPerTarget@
--
-- If you specify @ALBRequestCountPerTarget@ for the metric, you must
-- specify the @ResourceLabel@ parameter with the
-- @PredefinedMetricSpecification@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_TargetTrackingConfiguration.html TargetTrackingConfiguration>
-- in the /Amazon EC2 Auto Scaling API Reference/.
--
-- Required if the policy type is @TargetTrackingScaling@.
putScalingPolicy_targetTrackingConfiguration :: Lens.Lens' PutScalingPolicy (Prelude.Maybe TargetTrackingConfiguration)
putScalingPolicy_targetTrackingConfiguration :: (Maybe TargetTrackingConfiguration
 -> f (Maybe TargetTrackingConfiguration))
-> PutScalingPolicy -> f PutScalingPolicy
putScalingPolicy_targetTrackingConfiguration = (PutScalingPolicy -> Maybe TargetTrackingConfiguration)
-> (PutScalingPolicy
    -> Maybe TargetTrackingConfiguration -> PutScalingPolicy)
-> Lens
     PutScalingPolicy
     PutScalingPolicy
     (Maybe TargetTrackingConfiguration)
     (Maybe TargetTrackingConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutScalingPolicy' {Maybe TargetTrackingConfiguration
targetTrackingConfiguration :: Maybe TargetTrackingConfiguration
$sel:targetTrackingConfiguration:PutScalingPolicy' :: PutScalingPolicy -> Maybe TargetTrackingConfiguration
targetTrackingConfiguration} -> Maybe TargetTrackingConfiguration
targetTrackingConfiguration) (\s :: PutScalingPolicy
s@PutScalingPolicy' {} Maybe TargetTrackingConfiguration
a -> PutScalingPolicy
s {$sel:targetTrackingConfiguration:PutScalingPolicy' :: Maybe TargetTrackingConfiguration
targetTrackingConfiguration = Maybe TargetTrackingConfiguration
a} :: PutScalingPolicy)

-- | Specifies how the scaling adjustment is interpreted (for example, an
-- absolute number or a percentage). The valid values are
-- @ChangeInCapacity@, @ExactCapacity@, and @PercentChangeInCapacity@.
--
-- Required if the policy type is @StepScaling@ or @SimpleScaling@. For
-- more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-simple-step.html#as-scaling-adjustment Scaling adjustment types>
-- in the /Amazon EC2 Auto Scaling User Guide/.
putScalingPolicy_adjustmentType :: Lens.Lens' PutScalingPolicy (Prelude.Maybe Prelude.Text)
putScalingPolicy_adjustmentType :: (Maybe Text -> f (Maybe Text))
-> PutScalingPolicy -> f PutScalingPolicy
putScalingPolicy_adjustmentType = (PutScalingPolicy -> Maybe Text)
-> (PutScalingPolicy -> Maybe Text -> PutScalingPolicy)
-> Lens PutScalingPolicy PutScalingPolicy (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutScalingPolicy' {Maybe Text
adjustmentType :: Maybe Text
$sel:adjustmentType:PutScalingPolicy' :: PutScalingPolicy -> Maybe Text
adjustmentType} -> Maybe Text
adjustmentType) (\s :: PutScalingPolicy
s@PutScalingPolicy' {} Maybe Text
a -> PutScalingPolicy
s {$sel:adjustmentType:PutScalingPolicy' :: Maybe Text
adjustmentType = Maybe Text
a} :: PutScalingPolicy)

-- | A predictive scaling policy. Provides support for only predefined
-- metrics.
--
-- Predictive scaling works with CPU utilization, network in\/out, and the
-- Application Load Balancer request count.
--
-- For more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_PredictiveScalingConfiguration.html PredictiveScalingConfiguration>
-- in the /Amazon EC2 Auto Scaling API Reference/.
--
-- Required if the policy type is @PredictiveScaling@.
putScalingPolicy_predictiveScalingConfiguration :: Lens.Lens' PutScalingPolicy (Prelude.Maybe PredictiveScalingConfiguration)
putScalingPolicy_predictiveScalingConfiguration :: (Maybe PredictiveScalingConfiguration
 -> f (Maybe PredictiveScalingConfiguration))
-> PutScalingPolicy -> f PutScalingPolicy
putScalingPolicy_predictiveScalingConfiguration = (PutScalingPolicy -> Maybe PredictiveScalingConfiguration)
-> (PutScalingPolicy
    -> Maybe PredictiveScalingConfiguration -> PutScalingPolicy)
-> Lens
     PutScalingPolicy
     PutScalingPolicy
     (Maybe PredictiveScalingConfiguration)
     (Maybe PredictiveScalingConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutScalingPolicy' {Maybe PredictiveScalingConfiguration
predictiveScalingConfiguration :: Maybe PredictiveScalingConfiguration
$sel:predictiveScalingConfiguration:PutScalingPolicy' :: PutScalingPolicy -> Maybe PredictiveScalingConfiguration
predictiveScalingConfiguration} -> Maybe PredictiveScalingConfiguration
predictiveScalingConfiguration) (\s :: PutScalingPolicy
s@PutScalingPolicy' {} Maybe PredictiveScalingConfiguration
a -> PutScalingPolicy
s {$sel:predictiveScalingConfiguration:PutScalingPolicy' :: Maybe PredictiveScalingConfiguration
predictiveScalingConfiguration = Maybe PredictiveScalingConfiguration
a} :: PutScalingPolicy)

-- | The amount by which to scale, based on the specified adjustment type. A
-- positive value adds to the current capacity while a negative number
-- removes from the current capacity. For exact capacity, you must specify
-- a positive value.
--
-- Required if the policy type is @SimpleScaling@. (Not used with any other
-- policy type.)
putScalingPolicy_scalingAdjustment :: Lens.Lens' PutScalingPolicy (Prelude.Maybe Prelude.Int)
putScalingPolicy_scalingAdjustment :: (Maybe Int -> f (Maybe Int))
-> PutScalingPolicy -> f PutScalingPolicy
putScalingPolicy_scalingAdjustment = (PutScalingPolicy -> Maybe Int)
-> (PutScalingPolicy -> Maybe Int -> PutScalingPolicy)
-> Lens PutScalingPolicy PutScalingPolicy (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutScalingPolicy' {Maybe Int
scalingAdjustment :: Maybe Int
$sel:scalingAdjustment:PutScalingPolicy' :: PutScalingPolicy -> Maybe Int
scalingAdjustment} -> Maybe Int
scalingAdjustment) (\s :: PutScalingPolicy
s@PutScalingPolicy' {} Maybe Int
a -> PutScalingPolicy
s {$sel:scalingAdjustment:PutScalingPolicy' :: Maybe Int
scalingAdjustment = Maybe Int
a} :: PutScalingPolicy)

-- | The duration of the policy\'s cooldown period, in seconds. When a
-- cooldown period is specified here, it overrides the default cooldown
-- period defined for the Auto Scaling group.
--
-- Valid only if the policy type is @SimpleScaling@. For more information,
-- see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/Cooldown.html Scaling cooldowns for Amazon EC2 Auto Scaling>
-- in the /Amazon EC2 Auto Scaling User Guide/.
putScalingPolicy_cooldown :: Lens.Lens' PutScalingPolicy (Prelude.Maybe Prelude.Int)
putScalingPolicy_cooldown :: (Maybe Int -> f (Maybe Int))
-> PutScalingPolicy -> f PutScalingPolicy
putScalingPolicy_cooldown = (PutScalingPolicy -> Maybe Int)
-> (PutScalingPolicy -> Maybe Int -> PutScalingPolicy)
-> Lens PutScalingPolicy PutScalingPolicy (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutScalingPolicy' {Maybe Int
cooldown :: Maybe Int
$sel:cooldown:PutScalingPolicy' :: PutScalingPolicy -> Maybe Int
cooldown} -> Maybe Int
cooldown) (\s :: PutScalingPolicy
s@PutScalingPolicy' {} Maybe Int
a -> PutScalingPolicy
s {$sel:cooldown:PutScalingPolicy' :: Maybe Int
cooldown = Maybe Int
a} :: PutScalingPolicy)

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

-- | 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 Auto Scaling group by 25 percent and you
-- specify a @MinAdjustmentMagnitude@ of 2. If the group has 4 instances
-- and the scaling policy is performed, 25 percent of 4 is 1. However,
-- because you specified a @MinAdjustmentMagnitude@ of 2, Amazon EC2 Auto
-- Scaling scales out the group by 2 instances.
--
-- Valid only if the policy type is @StepScaling@ or @SimpleScaling@. For
-- more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-simple-step.html#as-scaling-adjustment Scaling adjustment types>
-- in the /Amazon EC2 Auto Scaling User Guide/.
--
-- Some Auto Scaling groups use instance weights. In this case, set the
-- @MinAdjustmentMagnitude@ to a value that is at least as large as your
-- largest instance weight.
putScalingPolicy_minAdjustmentMagnitude :: Lens.Lens' PutScalingPolicy (Prelude.Maybe Prelude.Int)
putScalingPolicy_minAdjustmentMagnitude :: (Maybe Int -> f (Maybe Int))
-> PutScalingPolicy -> f PutScalingPolicy
putScalingPolicy_minAdjustmentMagnitude = (PutScalingPolicy -> Maybe Int)
-> (PutScalingPolicy -> Maybe Int -> PutScalingPolicy)
-> Lens PutScalingPolicy PutScalingPolicy (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutScalingPolicy' {Maybe Int
minAdjustmentMagnitude :: Maybe Int
$sel:minAdjustmentMagnitude:PutScalingPolicy' :: PutScalingPolicy -> Maybe Int
minAdjustmentMagnitude} -> Maybe Int
minAdjustmentMagnitude) (\s :: PutScalingPolicy
s@PutScalingPolicy' {} Maybe Int
a -> PutScalingPolicy
s {$sel:minAdjustmentMagnitude:PutScalingPolicy' :: Maybe Int
minAdjustmentMagnitude = Maybe Int
a} :: PutScalingPolicy)

-- | The name of the Auto Scaling group.
putScalingPolicy_autoScalingGroupName :: Lens.Lens' PutScalingPolicy Prelude.Text
putScalingPolicy_autoScalingGroupName :: (Text -> f Text) -> PutScalingPolicy -> f PutScalingPolicy
putScalingPolicy_autoScalingGroupName = (PutScalingPolicy -> Text)
-> (PutScalingPolicy -> Text -> PutScalingPolicy)
-> Lens PutScalingPolicy PutScalingPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutScalingPolicy' {Text
autoScalingGroupName :: Text
$sel:autoScalingGroupName:PutScalingPolicy' :: PutScalingPolicy -> Text
autoScalingGroupName} -> Text
autoScalingGroupName) (\s :: PutScalingPolicy
s@PutScalingPolicy' {} Text
a -> PutScalingPolicy
s {$sel:autoScalingGroupName:PutScalingPolicy' :: Text
autoScalingGroupName = Text
a} :: PutScalingPolicy)

-- | The name of the policy.
putScalingPolicy_policyName :: Lens.Lens' PutScalingPolicy Prelude.Text
putScalingPolicy_policyName :: (Text -> f Text) -> PutScalingPolicy -> f PutScalingPolicy
putScalingPolicy_policyName = (PutScalingPolicy -> Text)
-> (PutScalingPolicy -> Text -> PutScalingPolicy)
-> Lens PutScalingPolicy PutScalingPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutScalingPolicy' {Text
policyName :: Text
$sel:policyName:PutScalingPolicy' :: PutScalingPolicy -> Text
policyName} -> Text
policyName) (\s :: PutScalingPolicy
s@PutScalingPolicy' {} Text
a -> PutScalingPolicy
s {$sel:policyName:PutScalingPolicy' :: Text
policyName = Text
a} :: PutScalingPolicy)

instance Core.AWSRequest PutScalingPolicy where
  type
    AWSResponse PutScalingPolicy =
      PutScalingPolicyResponse
  request :: PutScalingPolicy -> Request PutScalingPolicy
request = Service -> PutScalingPolicy -> Request PutScalingPolicy
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy PutScalingPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutScalingPolicy)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse PutScalingPolicy))
-> Logger
-> Service
-> Proxy PutScalingPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutScalingPolicy)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"PutScalingPolicyResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text -> Maybe [Alarm] -> Int -> PutScalingPolicyResponse
PutScalingPolicyResponse'
            (Maybe Text -> Maybe [Alarm] -> Int -> PutScalingPolicyResponse)
-> Either String (Maybe Text)
-> Either String (Maybe [Alarm] -> Int -> PutScalingPolicyResponse)
forall (f :: * -> *) a b. Functor 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
"PolicyARN")
            Either String (Maybe [Alarm] -> Int -> PutScalingPolicyResponse)
-> Either String (Maybe [Alarm])
-> Either String (Int -> PutScalingPolicyResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Alarms" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String (Maybe [Alarm]))
-> Either String (Maybe [Alarm])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Alarm])
-> [Node] -> Either String (Maybe [Alarm])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Alarm]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                        )
            Either String (Int -> PutScalingPolicyResponse)
-> Either String Int -> Either String PutScalingPolicyResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable PutScalingPolicy

instance Prelude.NFData PutScalingPolicy

instance Core.ToHeaders PutScalingPolicy where
  toHeaders :: PutScalingPolicy -> ResponseHeaders
toHeaders = ResponseHeaders -> PutScalingPolicy -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath PutScalingPolicy where
  toPath :: PutScalingPolicy -> ByteString
toPath = ByteString -> PutScalingPolicy -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery PutScalingPolicy where
  toQuery :: PutScalingPolicy -> QueryString
toQuery PutScalingPolicy' {Maybe Bool
Maybe Int
Maybe [StepAdjustment]
Maybe Text
Maybe PredictiveScalingConfiguration
Maybe TargetTrackingConfiguration
Text
policyName :: Text
autoScalingGroupName :: Text
minAdjustmentMagnitude :: Maybe Int
metricAggregationType :: Maybe Text
cooldown :: Maybe Int
scalingAdjustment :: Maybe Int
predictiveScalingConfiguration :: Maybe PredictiveScalingConfiguration
adjustmentType :: Maybe Text
targetTrackingConfiguration :: Maybe TargetTrackingConfiguration
stepAdjustments :: Maybe [StepAdjustment]
policyType :: Maybe Text
enabled :: Maybe Bool
estimatedInstanceWarmup :: Maybe Int
minAdjustmentStep :: Maybe Int
$sel:policyName:PutScalingPolicy' :: PutScalingPolicy -> Text
$sel:autoScalingGroupName:PutScalingPolicy' :: PutScalingPolicy -> Text
$sel:minAdjustmentMagnitude:PutScalingPolicy' :: PutScalingPolicy -> Maybe Int
$sel:metricAggregationType:PutScalingPolicy' :: PutScalingPolicy -> Maybe Text
$sel:cooldown:PutScalingPolicy' :: PutScalingPolicy -> Maybe Int
$sel:scalingAdjustment:PutScalingPolicy' :: PutScalingPolicy -> Maybe Int
$sel:predictiveScalingConfiguration:PutScalingPolicy' :: PutScalingPolicy -> Maybe PredictiveScalingConfiguration
$sel:adjustmentType:PutScalingPolicy' :: PutScalingPolicy -> Maybe Text
$sel:targetTrackingConfiguration:PutScalingPolicy' :: PutScalingPolicy -> Maybe TargetTrackingConfiguration
$sel:stepAdjustments:PutScalingPolicy' :: PutScalingPolicy -> Maybe [StepAdjustment]
$sel:policyType:PutScalingPolicy' :: PutScalingPolicy -> Maybe Text
$sel:enabled:PutScalingPolicy' :: PutScalingPolicy -> Maybe Bool
$sel:estimatedInstanceWarmup:PutScalingPolicy' :: PutScalingPolicy -> Maybe Int
$sel:minAdjustmentStep:PutScalingPolicy' :: PutScalingPolicy -> Maybe Int
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"PutScalingPolicy" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2011-01-01" :: Prelude.ByteString),
        ByteString
"MinAdjustmentStep" ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
minAdjustmentStep,
        ByteString
"EstimatedInstanceWarmup"
          ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
estimatedInstanceWarmup,
        ByteString
"Enabled" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
enabled,
        ByteString
"PolicyType" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
policyType,
        ByteString
"StepAdjustments"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            ( ByteString -> [StepAdjustment] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member"
                ([StepAdjustment] -> QueryString)
-> Maybe [StepAdjustment] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [StepAdjustment]
stepAdjustments
            ),
        ByteString
"TargetTrackingConfiguration"
          ByteString -> Maybe TargetTrackingConfiguration -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe TargetTrackingConfiguration
targetTrackingConfiguration,
        ByteString
"AdjustmentType" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
adjustmentType,
        ByteString
"PredictiveScalingConfiguration"
          ByteString -> Maybe PredictiveScalingConfiguration -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe PredictiveScalingConfiguration
predictiveScalingConfiguration,
        ByteString
"ScalingAdjustment" ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
scalingAdjustment,
        ByteString
"Cooldown" ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
cooldown,
        ByteString
"MetricAggregationType"
          ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
metricAggregationType,
        ByteString
"MinAdjustmentMagnitude"
          ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
minAdjustmentMagnitude,
        ByteString
"AutoScalingGroupName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
autoScalingGroupName,
        ByteString
"PolicyName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
policyName
      ]

-- | Contains the output of PutScalingPolicy.
--
-- /See:/ 'newPutScalingPolicyResponse' smart constructor.
data PutScalingPolicyResponse = PutScalingPolicyResponse'
  { -- | The Amazon Resource Name (ARN) of the policy.
    PutScalingPolicyResponse -> Maybe Text
policyARN :: Prelude.Maybe Prelude.Text,
    -- | The CloudWatch alarms created for the target tracking scaling policy.
    PutScalingPolicyResponse -> Maybe [Alarm]
alarms :: Prelude.Maybe [Alarm],
    -- | The response's http status code.
    PutScalingPolicyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutScalingPolicyResponse -> PutScalingPolicyResponse -> Bool
(PutScalingPolicyResponse -> PutScalingPolicyResponse -> Bool)
-> (PutScalingPolicyResponse -> PutScalingPolicyResponse -> Bool)
-> Eq PutScalingPolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutScalingPolicyResponse -> PutScalingPolicyResponse -> Bool
$c/= :: PutScalingPolicyResponse -> PutScalingPolicyResponse -> Bool
== :: PutScalingPolicyResponse -> PutScalingPolicyResponse -> Bool
$c== :: PutScalingPolicyResponse -> PutScalingPolicyResponse -> Bool
Prelude.Eq, ReadPrec [PutScalingPolicyResponse]
ReadPrec PutScalingPolicyResponse
Int -> ReadS PutScalingPolicyResponse
ReadS [PutScalingPolicyResponse]
(Int -> ReadS PutScalingPolicyResponse)
-> ReadS [PutScalingPolicyResponse]
-> ReadPrec PutScalingPolicyResponse
-> ReadPrec [PutScalingPolicyResponse]
-> Read PutScalingPolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutScalingPolicyResponse]
$creadListPrec :: ReadPrec [PutScalingPolicyResponse]
readPrec :: ReadPrec PutScalingPolicyResponse
$creadPrec :: ReadPrec PutScalingPolicyResponse
readList :: ReadS [PutScalingPolicyResponse]
$creadList :: ReadS [PutScalingPolicyResponse]
readsPrec :: Int -> ReadS PutScalingPolicyResponse
$creadsPrec :: Int -> ReadS PutScalingPolicyResponse
Prelude.Read, Int -> PutScalingPolicyResponse -> ShowS
[PutScalingPolicyResponse] -> ShowS
PutScalingPolicyResponse -> String
(Int -> PutScalingPolicyResponse -> ShowS)
-> (PutScalingPolicyResponse -> String)
-> ([PutScalingPolicyResponse] -> ShowS)
-> Show PutScalingPolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutScalingPolicyResponse] -> ShowS
$cshowList :: [PutScalingPolicyResponse] -> ShowS
show :: PutScalingPolicyResponse -> String
$cshow :: PutScalingPolicyResponse -> String
showsPrec :: Int -> PutScalingPolicyResponse -> ShowS
$cshowsPrec :: Int -> PutScalingPolicyResponse -> ShowS
Prelude.Show, (forall x.
 PutScalingPolicyResponse -> Rep PutScalingPolicyResponse x)
-> (forall x.
    Rep PutScalingPolicyResponse x -> PutScalingPolicyResponse)
-> Generic PutScalingPolicyResponse
forall x.
Rep PutScalingPolicyResponse x -> PutScalingPolicyResponse
forall x.
PutScalingPolicyResponse -> Rep PutScalingPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutScalingPolicyResponse x -> PutScalingPolicyResponse
$cfrom :: forall x.
PutScalingPolicyResponse -> Rep PutScalingPolicyResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutScalingPolicyResponse' 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:
--
-- 'policyARN', 'putScalingPolicyResponse_policyARN' - The Amazon Resource Name (ARN) of the policy.
--
-- 'alarms', 'putScalingPolicyResponse_alarms' - The CloudWatch alarms created for the target tracking scaling policy.
--
-- 'httpStatus', 'putScalingPolicyResponse_httpStatus' - The response's http status code.
newPutScalingPolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutScalingPolicyResponse
newPutScalingPolicyResponse :: Int -> PutScalingPolicyResponse
newPutScalingPolicyResponse Int
pHttpStatus_ =
  PutScalingPolicyResponse' :: Maybe Text -> Maybe [Alarm] -> Int -> PutScalingPolicyResponse
PutScalingPolicyResponse'
    { $sel:policyARN:PutScalingPolicyResponse' :: Maybe Text
policyARN =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:alarms:PutScalingPolicyResponse' :: Maybe [Alarm]
alarms = Maybe [Alarm]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PutScalingPolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the policy.
putScalingPolicyResponse_policyARN :: Lens.Lens' PutScalingPolicyResponse (Prelude.Maybe Prelude.Text)
putScalingPolicyResponse_policyARN :: (Maybe Text -> f (Maybe Text))
-> PutScalingPolicyResponse -> f PutScalingPolicyResponse
putScalingPolicyResponse_policyARN = (PutScalingPolicyResponse -> Maybe Text)
-> (PutScalingPolicyResponse
    -> Maybe Text -> PutScalingPolicyResponse)
-> Lens
     PutScalingPolicyResponse
     PutScalingPolicyResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutScalingPolicyResponse' {Maybe Text
policyARN :: Maybe Text
$sel:policyARN:PutScalingPolicyResponse' :: PutScalingPolicyResponse -> Maybe Text
policyARN} -> Maybe Text
policyARN) (\s :: PutScalingPolicyResponse
s@PutScalingPolicyResponse' {} Maybe Text
a -> PutScalingPolicyResponse
s {$sel:policyARN:PutScalingPolicyResponse' :: Maybe Text
policyARN = Maybe Text
a} :: PutScalingPolicyResponse)

-- | The CloudWatch alarms created for the target tracking scaling policy.
putScalingPolicyResponse_alarms :: Lens.Lens' PutScalingPolicyResponse (Prelude.Maybe [Alarm])
putScalingPolicyResponse_alarms :: (Maybe [Alarm] -> f (Maybe [Alarm]))
-> PutScalingPolicyResponse -> f PutScalingPolicyResponse
putScalingPolicyResponse_alarms = (PutScalingPolicyResponse -> Maybe [Alarm])
-> (PutScalingPolicyResponse
    -> Maybe [Alarm] -> PutScalingPolicyResponse)
-> Lens
     PutScalingPolicyResponse
     PutScalingPolicyResponse
     (Maybe [Alarm])
     (Maybe [Alarm])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutScalingPolicyResponse' {Maybe [Alarm]
alarms :: Maybe [Alarm]
$sel:alarms:PutScalingPolicyResponse' :: PutScalingPolicyResponse -> Maybe [Alarm]
alarms} -> Maybe [Alarm]
alarms) (\s :: PutScalingPolicyResponse
s@PutScalingPolicyResponse' {} Maybe [Alarm]
a -> PutScalingPolicyResponse
s {$sel:alarms:PutScalingPolicyResponse' :: Maybe [Alarm]
alarms = Maybe [Alarm]
a} :: PutScalingPolicyResponse) ((Maybe [Alarm] -> f (Maybe [Alarm]))
 -> PutScalingPolicyResponse -> f PutScalingPolicyResponse)
-> ((Maybe [Alarm] -> f (Maybe [Alarm]))
    -> Maybe [Alarm] -> f (Maybe [Alarm]))
-> (Maybe [Alarm] -> f (Maybe [Alarm]))
-> PutScalingPolicyResponse
-> f PutScalingPolicyResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Alarm] [Alarm] [Alarm] [Alarm]
-> Iso
     (Maybe [Alarm]) (Maybe [Alarm]) (Maybe [Alarm]) (Maybe [Alarm])
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 [Alarm] [Alarm] [Alarm] [Alarm]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
putScalingPolicyResponse_httpStatus :: Lens.Lens' PutScalingPolicyResponse Prelude.Int
putScalingPolicyResponse_httpStatus :: (Int -> f Int)
-> PutScalingPolicyResponse -> f PutScalingPolicyResponse
putScalingPolicyResponse_httpStatus = (PutScalingPolicyResponse -> Int)
-> (PutScalingPolicyResponse -> Int -> PutScalingPolicyResponse)
-> Lens PutScalingPolicyResponse PutScalingPolicyResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutScalingPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutScalingPolicyResponse' :: PutScalingPolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutScalingPolicyResponse
s@PutScalingPolicyResponse' {} Int
a -> PutScalingPolicyResponse
s {$sel:httpStatus:PutScalingPolicyResponse' :: Int
httpStatus = Int
a} :: PutScalingPolicyResponse)

instance Prelude.NFData PutScalingPolicyResponse