{-# 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.GameLift.Types.ScalingPolicy
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.GameLift.Types.ScalingPolicy where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GameLift.Types.ComparisonOperatorType
import Amazonka.GameLift.Types.LocationUpdateStatus
import Amazonka.GameLift.Types.MetricName
import Amazonka.GameLift.Types.PolicyType
import Amazonka.GameLift.Types.ScalingAdjustmentType
import Amazonka.GameLift.Types.ScalingStatusType
import Amazonka.GameLift.Types.TargetConfiguration
import qualified Amazonka.Prelude as Prelude

-- | Rule that controls how a fleet is scaled. Scaling policies are uniquely
-- identified by the combination of name and fleet ID.
--
-- /See:/ 'newScalingPolicy' smart constructor.
data ScalingPolicy = ScalingPolicy'
  { -- | Comparison operator to use when measuring a metric against the threshold
    -- value.
    ScalingPolicy -> Maybe ComparisonOperatorType
comparisonOperator :: Prelude.Maybe ComparisonOperatorType,
    -- | Length of time (in minutes) the metric must be at or beyond the
    -- threshold before a scaling event is triggered.
    ScalingPolicy -> Maybe Natural
evaluationPeriods :: Prelude.Maybe Prelude.Natural,
    -- | The Amazon Resource Name
    -- (<https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html ARN>)
    -- that is assigned to a GameLift fleet resource and uniquely identifies
    -- it. ARNs are unique across all Regions. Format is
    -- @arn:aws:gamelift:\<region>::fleet\/fleet-a1234567-b8c9-0d1e-2fa3-b45c6d7e8912@.
    ScalingPolicy -> Maybe Text
fleetArn :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for the fleet that is associated with this scaling
    -- policy.
    ScalingPolicy -> Maybe Text
fleetId :: Prelude.Maybe Prelude.Text,
    -- | The fleet location.
    ScalingPolicy -> Maybe Text
location :: Prelude.Maybe Prelude.Text,
    -- | Name of the Amazon GameLift-defined metric that is used to trigger a
    -- scaling adjustment. For detailed descriptions of fleet metrics, see
    -- <https://docs.aws.amazon.com/gamelift/latest/developerguide/monitoring-cloudwatch.html Monitor Amazon GameLift with Amazon CloudWatch>.
    --
    -- -   __ActivatingGameSessions__ -- Game sessions in the process of being
    --     created.
    --
    -- -   __ActiveGameSessions__ -- Game sessions that are currently running.
    --
    -- -   __ActiveInstances__ -- Fleet instances that are currently running at
    --     least one game session.
    --
    -- -   __AvailableGameSessions__ -- Additional game sessions that fleet
    --     could host simultaneously, given current capacity.
    --
    -- -   __AvailablePlayerSessions__ -- Empty player slots in currently
    --     active game sessions. This includes game sessions that are not
    --     currently accepting players. Reserved player slots are not included.
    --
    -- -   __CurrentPlayerSessions__ -- Player slots in active game sessions
    --     that are being used by a player or are reserved for a player.
    --
    -- -   __IdleInstances__ -- Active instances that are currently hosting
    --     zero game sessions.
    --
    -- -   __PercentAvailableGameSessions__ -- Unused percentage of the total
    --     number of game sessions that a fleet could host simultaneously,
    --     given current capacity. Use this metric for a target-based scaling
    --     policy.
    --
    -- -   __PercentIdleInstances__ -- Percentage of the total number of active
    --     instances that are hosting zero game sessions.
    --
    -- -   __QueueDepth__ -- Pending game session placement requests, in any
    --     queue, where the current fleet is the top-priority destination.
    --
    -- -   __WaitTime__ -- Current wait time for pending game session placement
    --     requests, in any queue, where the current fleet is the top-priority
    --     destination.
    ScalingPolicy -> Maybe MetricName
metricName :: Prelude.Maybe MetricName,
    -- | A descriptive label that is associated with a fleet\'s scaling policy.
    -- Policy names do not need to be unique.
    ScalingPolicy -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The type of scaling policy to create. For a target-based policy, set the
    -- parameter /MetricName/ to \'PercentAvailableGameSessions\' and specify a
    -- /TargetConfiguration/. For a rule-based policy set the following
    -- parameters: /MetricName/, /ComparisonOperator/, /Threshold/,
    -- /EvaluationPeriods/, /ScalingAdjustmentType/, and /ScalingAdjustment/.
    ScalingPolicy -> Maybe PolicyType
policyType :: Prelude.Maybe PolicyType,
    -- | Amount of adjustment to make, based on the scaling adjustment type.
    ScalingPolicy -> Maybe Int
scalingAdjustment :: Prelude.Maybe Prelude.Int,
    -- | The type of adjustment to make to a fleet\'s instance count.
    --
    -- -   __ChangeInCapacity__ -- add (or subtract) the scaling adjustment
    --     value from the current instance count. Positive values scale up
    --     while negative values scale down.
    --
    -- -   __ExactCapacity__ -- set the instance count to the scaling
    --     adjustment value.
    --
    -- -   __PercentChangeInCapacity__ -- increase or reduce the current
    --     instance count by the scaling adjustment, read as a percentage.
    --     Positive values scale up while negative values scale down.
    ScalingPolicy -> Maybe ScalingAdjustmentType
scalingAdjustmentType :: Prelude.Maybe ScalingAdjustmentType,
    -- | Current status of the scaling policy. The scaling policy can be in force
    -- only when in an @ACTIVE@ status. Scaling policies can be suspended for
    -- individual fleets. If the policy is suspended for a fleet, the policy
    -- status does not change.
    --
    -- -   __ACTIVE__ -- The scaling policy can be used for auto-scaling a
    --     fleet.
    --
    -- -   __UPDATE_REQUESTED__ -- A request to update the scaling policy has
    --     been received.
    --
    -- -   __UPDATING__ -- A change is being made to the scaling policy.
    --
    -- -   __DELETE_REQUESTED__ -- A request to delete the scaling policy has
    --     been received.
    --
    -- -   __DELETING__ -- The scaling policy is being deleted.
    --
    -- -   __DELETED__ -- The scaling policy has been deleted.
    --
    -- -   __ERROR__ -- An error occurred in creating the policy. It should be
    --     removed and recreated.
    ScalingPolicy -> Maybe ScalingStatusType
status :: Prelude.Maybe ScalingStatusType,
    -- | An object that contains settings for a target-based scaling policy.
    ScalingPolicy -> Maybe TargetConfiguration
targetConfiguration :: Prelude.Maybe TargetConfiguration,
    -- | Metric value used to trigger a scaling event.
    ScalingPolicy -> Maybe Double
threshold :: Prelude.Maybe Prelude.Double,
    -- | The current status of the fleet\'s scaling policies in a requested fleet
    -- location. The status @PENDING_UPDATE@ indicates that an update was
    -- requested for the fleet but has not yet been completed for the location.
    ScalingPolicy -> Maybe LocationUpdateStatus
updateStatus :: Prelude.Maybe LocationUpdateStatus
  }
  deriving (ScalingPolicy -> ScalingPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScalingPolicy -> ScalingPolicy -> Bool
$c/= :: ScalingPolicy -> ScalingPolicy -> Bool
== :: ScalingPolicy -> ScalingPolicy -> Bool
$c== :: ScalingPolicy -> ScalingPolicy -> Bool
Prelude.Eq, ReadPrec [ScalingPolicy]
ReadPrec ScalingPolicy
Int -> ReadS ScalingPolicy
ReadS [ScalingPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScalingPolicy]
$creadListPrec :: ReadPrec [ScalingPolicy]
readPrec :: ReadPrec ScalingPolicy
$creadPrec :: ReadPrec ScalingPolicy
readList :: ReadS [ScalingPolicy]
$creadList :: ReadS [ScalingPolicy]
readsPrec :: Int -> ReadS ScalingPolicy
$creadsPrec :: Int -> ReadS ScalingPolicy
Prelude.Read, Int -> ScalingPolicy -> ShowS
[ScalingPolicy] -> ShowS
ScalingPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScalingPolicy] -> ShowS
$cshowList :: [ScalingPolicy] -> ShowS
show :: ScalingPolicy -> String
$cshow :: ScalingPolicy -> String
showsPrec :: Int -> ScalingPolicy -> ShowS
$cshowsPrec :: Int -> ScalingPolicy -> ShowS
Prelude.Show, forall x. Rep ScalingPolicy x -> ScalingPolicy
forall x. ScalingPolicy -> Rep ScalingPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ScalingPolicy x -> ScalingPolicy
$cfrom :: forall x. ScalingPolicy -> Rep ScalingPolicy x
Prelude.Generic)

-- |
-- Create a value of 'ScalingPolicy' 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:
--
-- 'comparisonOperator', 'scalingPolicy_comparisonOperator' - Comparison operator to use when measuring a metric against the threshold
-- value.
--
-- 'evaluationPeriods', 'scalingPolicy_evaluationPeriods' - Length of time (in minutes) the metric must be at or beyond the
-- threshold before a scaling event is triggered.
--
-- 'fleetArn', 'scalingPolicy_fleetArn' - The Amazon Resource Name
-- (<https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html ARN>)
-- that is assigned to a GameLift fleet resource and uniquely identifies
-- it. ARNs are unique across all Regions. Format is
-- @arn:aws:gamelift:\<region>::fleet\/fleet-a1234567-b8c9-0d1e-2fa3-b45c6d7e8912@.
--
-- 'fleetId', 'scalingPolicy_fleetId' - A unique identifier for the fleet that is associated with this scaling
-- policy.
--
-- 'location', 'scalingPolicy_location' - The fleet location.
--
-- 'metricName', 'scalingPolicy_metricName' - Name of the Amazon GameLift-defined metric that is used to trigger a
-- scaling adjustment. For detailed descriptions of fleet metrics, see
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/monitoring-cloudwatch.html Monitor Amazon GameLift with Amazon CloudWatch>.
--
-- -   __ActivatingGameSessions__ -- Game sessions in the process of being
--     created.
--
-- -   __ActiveGameSessions__ -- Game sessions that are currently running.
--
-- -   __ActiveInstances__ -- Fleet instances that are currently running at
--     least one game session.
--
-- -   __AvailableGameSessions__ -- Additional game sessions that fleet
--     could host simultaneously, given current capacity.
--
-- -   __AvailablePlayerSessions__ -- Empty player slots in currently
--     active game sessions. This includes game sessions that are not
--     currently accepting players. Reserved player slots are not included.
--
-- -   __CurrentPlayerSessions__ -- Player slots in active game sessions
--     that are being used by a player or are reserved for a player.
--
-- -   __IdleInstances__ -- Active instances that are currently hosting
--     zero game sessions.
--
-- -   __PercentAvailableGameSessions__ -- Unused percentage of the total
--     number of game sessions that a fleet could host simultaneously,
--     given current capacity. Use this metric for a target-based scaling
--     policy.
--
-- -   __PercentIdleInstances__ -- Percentage of the total number of active
--     instances that are hosting zero game sessions.
--
-- -   __QueueDepth__ -- Pending game session placement requests, in any
--     queue, where the current fleet is the top-priority destination.
--
-- -   __WaitTime__ -- Current wait time for pending game session placement
--     requests, in any queue, where the current fleet is the top-priority
--     destination.
--
-- 'name', 'scalingPolicy_name' - A descriptive label that is associated with a fleet\'s scaling policy.
-- Policy names do not need to be unique.
--
-- 'policyType', 'scalingPolicy_policyType' - The type of scaling policy to create. For a target-based policy, set the
-- parameter /MetricName/ to \'PercentAvailableGameSessions\' and specify a
-- /TargetConfiguration/. For a rule-based policy set the following
-- parameters: /MetricName/, /ComparisonOperator/, /Threshold/,
-- /EvaluationPeriods/, /ScalingAdjustmentType/, and /ScalingAdjustment/.
--
-- 'scalingAdjustment', 'scalingPolicy_scalingAdjustment' - Amount of adjustment to make, based on the scaling adjustment type.
--
-- 'scalingAdjustmentType', 'scalingPolicy_scalingAdjustmentType' - The type of adjustment to make to a fleet\'s instance count.
--
-- -   __ChangeInCapacity__ -- add (or subtract) the scaling adjustment
--     value from the current instance count. Positive values scale up
--     while negative values scale down.
--
-- -   __ExactCapacity__ -- set the instance count to the scaling
--     adjustment value.
--
-- -   __PercentChangeInCapacity__ -- increase or reduce the current
--     instance count by the scaling adjustment, read as a percentage.
--     Positive values scale up while negative values scale down.
--
-- 'status', 'scalingPolicy_status' - Current status of the scaling policy. The scaling policy can be in force
-- only when in an @ACTIVE@ status. Scaling policies can be suspended for
-- individual fleets. If the policy is suspended for a fleet, the policy
-- status does not change.
--
-- -   __ACTIVE__ -- The scaling policy can be used for auto-scaling a
--     fleet.
--
-- -   __UPDATE_REQUESTED__ -- A request to update the scaling policy has
--     been received.
--
-- -   __UPDATING__ -- A change is being made to the scaling policy.
--
-- -   __DELETE_REQUESTED__ -- A request to delete the scaling policy has
--     been received.
--
-- -   __DELETING__ -- The scaling policy is being deleted.
--
-- -   __DELETED__ -- The scaling policy has been deleted.
--
-- -   __ERROR__ -- An error occurred in creating the policy. It should be
--     removed and recreated.
--
-- 'targetConfiguration', 'scalingPolicy_targetConfiguration' - An object that contains settings for a target-based scaling policy.
--
-- 'threshold', 'scalingPolicy_threshold' - Metric value used to trigger a scaling event.
--
-- 'updateStatus', 'scalingPolicy_updateStatus' - The current status of the fleet\'s scaling policies in a requested fleet
-- location. The status @PENDING_UPDATE@ indicates that an update was
-- requested for the fleet but has not yet been completed for the location.
newScalingPolicy ::
  ScalingPolicy
newScalingPolicy :: ScalingPolicy
newScalingPolicy =
  ScalingPolicy'
    { $sel:comparisonOperator:ScalingPolicy' :: Maybe ComparisonOperatorType
comparisonOperator =
        forall a. Maybe a
Prelude.Nothing,
      $sel:evaluationPeriods:ScalingPolicy' :: Maybe Natural
evaluationPeriods = forall a. Maybe a
Prelude.Nothing,
      $sel:fleetArn:ScalingPolicy' :: Maybe Text
fleetArn = forall a. Maybe a
Prelude.Nothing,
      $sel:fleetId:ScalingPolicy' :: Maybe Text
fleetId = forall a. Maybe a
Prelude.Nothing,
      $sel:location:ScalingPolicy' :: Maybe Text
location = forall a. Maybe a
Prelude.Nothing,
      $sel:metricName:ScalingPolicy' :: Maybe MetricName
metricName = forall a. Maybe a
Prelude.Nothing,
      $sel:name:ScalingPolicy' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:policyType:ScalingPolicy' :: Maybe PolicyType
policyType = forall a. Maybe a
Prelude.Nothing,
      $sel:scalingAdjustment:ScalingPolicy' :: Maybe Int
scalingAdjustment = forall a. Maybe a
Prelude.Nothing,
      $sel:scalingAdjustmentType:ScalingPolicy' :: Maybe ScalingAdjustmentType
scalingAdjustmentType = forall a. Maybe a
Prelude.Nothing,
      $sel:status:ScalingPolicy' :: Maybe ScalingStatusType
status = forall a. Maybe a
Prelude.Nothing,
      $sel:targetConfiguration:ScalingPolicy' :: Maybe TargetConfiguration
targetConfiguration = forall a. Maybe a
Prelude.Nothing,
      $sel:threshold:ScalingPolicy' :: Maybe Double
threshold = forall a. Maybe a
Prelude.Nothing,
      $sel:updateStatus:ScalingPolicy' :: Maybe LocationUpdateStatus
updateStatus = forall a. Maybe a
Prelude.Nothing
    }

-- | Comparison operator to use when measuring a metric against the threshold
-- value.
scalingPolicy_comparisonOperator :: Lens.Lens' ScalingPolicy (Prelude.Maybe ComparisonOperatorType)
scalingPolicy_comparisonOperator :: Lens' ScalingPolicy (Maybe ComparisonOperatorType)
scalingPolicy_comparisonOperator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPolicy' {Maybe ComparisonOperatorType
comparisonOperator :: Maybe ComparisonOperatorType
$sel:comparisonOperator:ScalingPolicy' :: ScalingPolicy -> Maybe ComparisonOperatorType
comparisonOperator} -> Maybe ComparisonOperatorType
comparisonOperator) (\s :: ScalingPolicy
s@ScalingPolicy' {} Maybe ComparisonOperatorType
a -> ScalingPolicy
s {$sel:comparisonOperator:ScalingPolicy' :: Maybe ComparisonOperatorType
comparisonOperator = Maybe ComparisonOperatorType
a} :: ScalingPolicy)

-- | Length of time (in minutes) the metric must be at or beyond the
-- threshold before a scaling event is triggered.
scalingPolicy_evaluationPeriods :: Lens.Lens' ScalingPolicy (Prelude.Maybe Prelude.Natural)
scalingPolicy_evaluationPeriods :: Lens' ScalingPolicy (Maybe Natural)
scalingPolicy_evaluationPeriods = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPolicy' {Maybe Natural
evaluationPeriods :: Maybe Natural
$sel:evaluationPeriods:ScalingPolicy' :: ScalingPolicy -> Maybe Natural
evaluationPeriods} -> Maybe Natural
evaluationPeriods) (\s :: ScalingPolicy
s@ScalingPolicy' {} Maybe Natural
a -> ScalingPolicy
s {$sel:evaluationPeriods:ScalingPolicy' :: Maybe Natural
evaluationPeriods = Maybe Natural
a} :: ScalingPolicy)

-- | The Amazon Resource Name
-- (<https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html ARN>)
-- that is assigned to a GameLift fleet resource and uniquely identifies
-- it. ARNs are unique across all Regions. Format is
-- @arn:aws:gamelift:\<region>::fleet\/fleet-a1234567-b8c9-0d1e-2fa3-b45c6d7e8912@.
scalingPolicy_fleetArn :: Lens.Lens' ScalingPolicy (Prelude.Maybe Prelude.Text)
scalingPolicy_fleetArn :: Lens' ScalingPolicy (Maybe Text)
scalingPolicy_fleetArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPolicy' {Maybe Text
fleetArn :: Maybe Text
$sel:fleetArn:ScalingPolicy' :: ScalingPolicy -> Maybe Text
fleetArn} -> Maybe Text
fleetArn) (\s :: ScalingPolicy
s@ScalingPolicy' {} Maybe Text
a -> ScalingPolicy
s {$sel:fleetArn:ScalingPolicy' :: Maybe Text
fleetArn = Maybe Text
a} :: ScalingPolicy)

-- | A unique identifier for the fleet that is associated with this scaling
-- policy.
scalingPolicy_fleetId :: Lens.Lens' ScalingPolicy (Prelude.Maybe Prelude.Text)
scalingPolicy_fleetId :: Lens' ScalingPolicy (Maybe Text)
scalingPolicy_fleetId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPolicy' {Maybe Text
fleetId :: Maybe Text
$sel:fleetId:ScalingPolicy' :: ScalingPolicy -> Maybe Text
fleetId} -> Maybe Text
fleetId) (\s :: ScalingPolicy
s@ScalingPolicy' {} Maybe Text
a -> ScalingPolicy
s {$sel:fleetId:ScalingPolicy' :: Maybe Text
fleetId = Maybe Text
a} :: ScalingPolicy)

-- | The fleet location.
scalingPolicy_location :: Lens.Lens' ScalingPolicy (Prelude.Maybe Prelude.Text)
scalingPolicy_location :: Lens' ScalingPolicy (Maybe Text)
scalingPolicy_location = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPolicy' {Maybe Text
location :: Maybe Text
$sel:location:ScalingPolicy' :: ScalingPolicy -> Maybe Text
location} -> Maybe Text
location) (\s :: ScalingPolicy
s@ScalingPolicy' {} Maybe Text
a -> ScalingPolicy
s {$sel:location:ScalingPolicy' :: Maybe Text
location = Maybe Text
a} :: ScalingPolicy)

-- | Name of the Amazon GameLift-defined metric that is used to trigger a
-- scaling adjustment. For detailed descriptions of fleet metrics, see
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/monitoring-cloudwatch.html Monitor Amazon GameLift with Amazon CloudWatch>.
--
-- -   __ActivatingGameSessions__ -- Game sessions in the process of being
--     created.
--
-- -   __ActiveGameSessions__ -- Game sessions that are currently running.
--
-- -   __ActiveInstances__ -- Fleet instances that are currently running at
--     least one game session.
--
-- -   __AvailableGameSessions__ -- Additional game sessions that fleet
--     could host simultaneously, given current capacity.
--
-- -   __AvailablePlayerSessions__ -- Empty player slots in currently
--     active game sessions. This includes game sessions that are not
--     currently accepting players. Reserved player slots are not included.
--
-- -   __CurrentPlayerSessions__ -- Player slots in active game sessions
--     that are being used by a player or are reserved for a player.
--
-- -   __IdleInstances__ -- Active instances that are currently hosting
--     zero game sessions.
--
-- -   __PercentAvailableGameSessions__ -- Unused percentage of the total
--     number of game sessions that a fleet could host simultaneously,
--     given current capacity. Use this metric for a target-based scaling
--     policy.
--
-- -   __PercentIdleInstances__ -- Percentage of the total number of active
--     instances that are hosting zero game sessions.
--
-- -   __QueueDepth__ -- Pending game session placement requests, in any
--     queue, where the current fleet is the top-priority destination.
--
-- -   __WaitTime__ -- Current wait time for pending game session placement
--     requests, in any queue, where the current fleet is the top-priority
--     destination.
scalingPolicy_metricName :: Lens.Lens' ScalingPolicy (Prelude.Maybe MetricName)
scalingPolicy_metricName :: Lens' ScalingPolicy (Maybe MetricName)
scalingPolicy_metricName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPolicy' {Maybe MetricName
metricName :: Maybe MetricName
$sel:metricName:ScalingPolicy' :: ScalingPolicy -> Maybe MetricName
metricName} -> Maybe MetricName
metricName) (\s :: ScalingPolicy
s@ScalingPolicy' {} Maybe MetricName
a -> ScalingPolicy
s {$sel:metricName:ScalingPolicy' :: Maybe MetricName
metricName = Maybe MetricName
a} :: ScalingPolicy)

-- | A descriptive label that is associated with a fleet\'s scaling policy.
-- Policy names do not need to be unique.
scalingPolicy_name :: Lens.Lens' ScalingPolicy (Prelude.Maybe Prelude.Text)
scalingPolicy_name :: Lens' ScalingPolicy (Maybe Text)
scalingPolicy_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPolicy' {Maybe Text
name :: Maybe Text
$sel:name:ScalingPolicy' :: ScalingPolicy -> Maybe Text
name} -> Maybe Text
name) (\s :: ScalingPolicy
s@ScalingPolicy' {} Maybe Text
a -> ScalingPolicy
s {$sel:name:ScalingPolicy' :: Maybe Text
name = Maybe Text
a} :: ScalingPolicy)

-- | The type of scaling policy to create. For a target-based policy, set the
-- parameter /MetricName/ to \'PercentAvailableGameSessions\' and specify a
-- /TargetConfiguration/. For a rule-based policy set the following
-- parameters: /MetricName/, /ComparisonOperator/, /Threshold/,
-- /EvaluationPeriods/, /ScalingAdjustmentType/, and /ScalingAdjustment/.
scalingPolicy_policyType :: Lens.Lens' ScalingPolicy (Prelude.Maybe PolicyType)
scalingPolicy_policyType :: Lens' ScalingPolicy (Maybe PolicyType)
scalingPolicy_policyType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPolicy' {Maybe PolicyType
policyType :: Maybe PolicyType
$sel:policyType:ScalingPolicy' :: ScalingPolicy -> Maybe PolicyType
policyType} -> Maybe PolicyType
policyType) (\s :: ScalingPolicy
s@ScalingPolicy' {} Maybe PolicyType
a -> ScalingPolicy
s {$sel:policyType:ScalingPolicy' :: Maybe PolicyType
policyType = Maybe PolicyType
a} :: ScalingPolicy)

-- | Amount of adjustment to make, based on the scaling adjustment type.
scalingPolicy_scalingAdjustment :: Lens.Lens' ScalingPolicy (Prelude.Maybe Prelude.Int)
scalingPolicy_scalingAdjustment :: Lens' ScalingPolicy (Maybe Int)
scalingPolicy_scalingAdjustment = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPolicy' {Maybe Int
scalingAdjustment :: Maybe Int
$sel:scalingAdjustment:ScalingPolicy' :: ScalingPolicy -> Maybe Int
scalingAdjustment} -> Maybe Int
scalingAdjustment) (\s :: ScalingPolicy
s@ScalingPolicy' {} Maybe Int
a -> ScalingPolicy
s {$sel:scalingAdjustment:ScalingPolicy' :: Maybe Int
scalingAdjustment = Maybe Int
a} :: ScalingPolicy)

-- | The type of adjustment to make to a fleet\'s instance count.
--
-- -   __ChangeInCapacity__ -- add (or subtract) the scaling adjustment
--     value from the current instance count. Positive values scale up
--     while negative values scale down.
--
-- -   __ExactCapacity__ -- set the instance count to the scaling
--     adjustment value.
--
-- -   __PercentChangeInCapacity__ -- increase or reduce the current
--     instance count by the scaling adjustment, read as a percentage.
--     Positive values scale up while negative values scale down.
scalingPolicy_scalingAdjustmentType :: Lens.Lens' ScalingPolicy (Prelude.Maybe ScalingAdjustmentType)
scalingPolicy_scalingAdjustmentType :: Lens' ScalingPolicy (Maybe ScalingAdjustmentType)
scalingPolicy_scalingAdjustmentType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPolicy' {Maybe ScalingAdjustmentType
scalingAdjustmentType :: Maybe ScalingAdjustmentType
$sel:scalingAdjustmentType:ScalingPolicy' :: ScalingPolicy -> Maybe ScalingAdjustmentType
scalingAdjustmentType} -> Maybe ScalingAdjustmentType
scalingAdjustmentType) (\s :: ScalingPolicy
s@ScalingPolicy' {} Maybe ScalingAdjustmentType
a -> ScalingPolicy
s {$sel:scalingAdjustmentType:ScalingPolicy' :: Maybe ScalingAdjustmentType
scalingAdjustmentType = Maybe ScalingAdjustmentType
a} :: ScalingPolicy)

-- | Current status of the scaling policy. The scaling policy can be in force
-- only when in an @ACTIVE@ status. Scaling policies can be suspended for
-- individual fleets. If the policy is suspended for a fleet, the policy
-- status does not change.
--
-- -   __ACTIVE__ -- The scaling policy can be used for auto-scaling a
--     fleet.
--
-- -   __UPDATE_REQUESTED__ -- A request to update the scaling policy has
--     been received.
--
-- -   __UPDATING__ -- A change is being made to the scaling policy.
--
-- -   __DELETE_REQUESTED__ -- A request to delete the scaling policy has
--     been received.
--
-- -   __DELETING__ -- The scaling policy is being deleted.
--
-- -   __DELETED__ -- The scaling policy has been deleted.
--
-- -   __ERROR__ -- An error occurred in creating the policy. It should be
--     removed and recreated.
scalingPolicy_status :: Lens.Lens' ScalingPolicy (Prelude.Maybe ScalingStatusType)
scalingPolicy_status :: Lens' ScalingPolicy (Maybe ScalingStatusType)
scalingPolicy_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPolicy' {Maybe ScalingStatusType
status :: Maybe ScalingStatusType
$sel:status:ScalingPolicy' :: ScalingPolicy -> Maybe ScalingStatusType
status} -> Maybe ScalingStatusType
status) (\s :: ScalingPolicy
s@ScalingPolicy' {} Maybe ScalingStatusType
a -> ScalingPolicy
s {$sel:status:ScalingPolicy' :: Maybe ScalingStatusType
status = Maybe ScalingStatusType
a} :: ScalingPolicy)

-- | An object that contains settings for a target-based scaling policy.
scalingPolicy_targetConfiguration :: Lens.Lens' ScalingPolicy (Prelude.Maybe TargetConfiguration)
scalingPolicy_targetConfiguration :: Lens' ScalingPolicy (Maybe TargetConfiguration)
scalingPolicy_targetConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPolicy' {Maybe TargetConfiguration
targetConfiguration :: Maybe TargetConfiguration
$sel:targetConfiguration:ScalingPolicy' :: ScalingPolicy -> Maybe TargetConfiguration
targetConfiguration} -> Maybe TargetConfiguration
targetConfiguration) (\s :: ScalingPolicy
s@ScalingPolicy' {} Maybe TargetConfiguration
a -> ScalingPolicy
s {$sel:targetConfiguration:ScalingPolicy' :: Maybe TargetConfiguration
targetConfiguration = Maybe TargetConfiguration
a} :: ScalingPolicy)

-- | Metric value used to trigger a scaling event.
scalingPolicy_threshold :: Lens.Lens' ScalingPolicy (Prelude.Maybe Prelude.Double)
scalingPolicy_threshold :: Lens' ScalingPolicy (Maybe Double)
scalingPolicy_threshold = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPolicy' {Maybe Double
threshold :: Maybe Double
$sel:threshold:ScalingPolicy' :: ScalingPolicy -> Maybe Double
threshold} -> Maybe Double
threshold) (\s :: ScalingPolicy
s@ScalingPolicy' {} Maybe Double
a -> ScalingPolicy
s {$sel:threshold:ScalingPolicy' :: Maybe Double
threshold = Maybe Double
a} :: ScalingPolicy)

-- | The current status of the fleet\'s scaling policies in a requested fleet
-- location. The status @PENDING_UPDATE@ indicates that an update was
-- requested for the fleet but has not yet been completed for the location.
scalingPolicy_updateStatus :: Lens.Lens' ScalingPolicy (Prelude.Maybe LocationUpdateStatus)
scalingPolicy_updateStatus :: Lens' ScalingPolicy (Maybe LocationUpdateStatus)
scalingPolicy_updateStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPolicy' {Maybe LocationUpdateStatus
updateStatus :: Maybe LocationUpdateStatus
$sel:updateStatus:ScalingPolicy' :: ScalingPolicy -> Maybe LocationUpdateStatus
updateStatus} -> Maybe LocationUpdateStatus
updateStatus) (\s :: ScalingPolicy
s@ScalingPolicy' {} Maybe LocationUpdateStatus
a -> ScalingPolicy
s {$sel:updateStatus:ScalingPolicy' :: Maybe LocationUpdateStatus
updateStatus = Maybe LocationUpdateStatus
a} :: ScalingPolicy)

instance Data.FromJSON ScalingPolicy where
  parseJSON :: Value -> Parser ScalingPolicy
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ScalingPolicy"
      ( \Object
x ->
          Maybe ComparisonOperatorType
-> Maybe Natural
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe MetricName
-> Maybe Text
-> Maybe PolicyType
-> Maybe Int
-> Maybe ScalingAdjustmentType
-> Maybe ScalingStatusType
-> Maybe TargetConfiguration
-> Maybe Double
-> Maybe LocationUpdateStatus
-> ScalingPolicy
ScalingPolicy'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ComparisonOperator")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"EvaluationPeriods")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"FleetArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"FleetId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Location")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"MetricName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"PolicyType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ScalingAdjustment")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ScalingAdjustmentType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Status")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"TargetConfiguration")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Threshold")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"UpdateStatus")
      )

instance Prelude.Hashable ScalingPolicy where
  hashWithSalt :: Int -> ScalingPolicy -> Int
hashWithSalt Int
_salt ScalingPolicy' {Maybe Double
Maybe Int
Maybe Natural
Maybe Text
Maybe ComparisonOperatorType
Maybe LocationUpdateStatus
Maybe MetricName
Maybe PolicyType
Maybe ScalingAdjustmentType
Maybe ScalingStatusType
Maybe TargetConfiguration
updateStatus :: Maybe LocationUpdateStatus
threshold :: Maybe Double
targetConfiguration :: Maybe TargetConfiguration
status :: Maybe ScalingStatusType
scalingAdjustmentType :: Maybe ScalingAdjustmentType
scalingAdjustment :: Maybe Int
policyType :: Maybe PolicyType
name :: Maybe Text
metricName :: Maybe MetricName
location :: Maybe Text
fleetId :: Maybe Text
fleetArn :: Maybe Text
evaluationPeriods :: Maybe Natural
comparisonOperator :: Maybe ComparisonOperatorType
$sel:updateStatus:ScalingPolicy' :: ScalingPolicy -> Maybe LocationUpdateStatus
$sel:threshold:ScalingPolicy' :: ScalingPolicy -> Maybe Double
$sel:targetConfiguration:ScalingPolicy' :: ScalingPolicy -> Maybe TargetConfiguration
$sel:status:ScalingPolicy' :: ScalingPolicy -> Maybe ScalingStatusType
$sel:scalingAdjustmentType:ScalingPolicy' :: ScalingPolicy -> Maybe ScalingAdjustmentType
$sel:scalingAdjustment:ScalingPolicy' :: ScalingPolicy -> Maybe Int
$sel:policyType:ScalingPolicy' :: ScalingPolicy -> Maybe PolicyType
$sel:name:ScalingPolicy' :: ScalingPolicy -> Maybe Text
$sel:metricName:ScalingPolicy' :: ScalingPolicy -> Maybe MetricName
$sel:location:ScalingPolicy' :: ScalingPolicy -> Maybe Text
$sel:fleetId:ScalingPolicy' :: ScalingPolicy -> Maybe Text
$sel:fleetArn:ScalingPolicy' :: ScalingPolicy -> Maybe Text
$sel:evaluationPeriods:ScalingPolicy' :: ScalingPolicy -> Maybe Natural
$sel:comparisonOperator:ScalingPolicy' :: ScalingPolicy -> Maybe ComparisonOperatorType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ComparisonOperatorType
comparisonOperator
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
evaluationPeriods
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
fleetArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
fleetId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
location
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MetricName
metricName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PolicyType
policyType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
scalingAdjustment
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ScalingAdjustmentType
scalingAdjustmentType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ScalingStatusType
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TargetConfiguration
targetConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
threshold
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe LocationUpdateStatus
updateStatus

instance Prelude.NFData ScalingPolicy where
  rnf :: ScalingPolicy -> ()
rnf ScalingPolicy' {Maybe Double
Maybe Int
Maybe Natural
Maybe Text
Maybe ComparisonOperatorType
Maybe LocationUpdateStatus
Maybe MetricName
Maybe PolicyType
Maybe ScalingAdjustmentType
Maybe ScalingStatusType
Maybe TargetConfiguration
updateStatus :: Maybe LocationUpdateStatus
threshold :: Maybe Double
targetConfiguration :: Maybe TargetConfiguration
status :: Maybe ScalingStatusType
scalingAdjustmentType :: Maybe ScalingAdjustmentType
scalingAdjustment :: Maybe Int
policyType :: Maybe PolicyType
name :: Maybe Text
metricName :: Maybe MetricName
location :: Maybe Text
fleetId :: Maybe Text
fleetArn :: Maybe Text
evaluationPeriods :: Maybe Natural
comparisonOperator :: Maybe ComparisonOperatorType
$sel:updateStatus:ScalingPolicy' :: ScalingPolicy -> Maybe LocationUpdateStatus
$sel:threshold:ScalingPolicy' :: ScalingPolicy -> Maybe Double
$sel:targetConfiguration:ScalingPolicy' :: ScalingPolicy -> Maybe TargetConfiguration
$sel:status:ScalingPolicy' :: ScalingPolicy -> Maybe ScalingStatusType
$sel:scalingAdjustmentType:ScalingPolicy' :: ScalingPolicy -> Maybe ScalingAdjustmentType
$sel:scalingAdjustment:ScalingPolicy' :: ScalingPolicy -> Maybe Int
$sel:policyType:ScalingPolicy' :: ScalingPolicy -> Maybe PolicyType
$sel:name:ScalingPolicy' :: ScalingPolicy -> Maybe Text
$sel:metricName:ScalingPolicy' :: ScalingPolicy -> Maybe MetricName
$sel:location:ScalingPolicy' :: ScalingPolicy -> Maybe Text
$sel:fleetId:ScalingPolicy' :: ScalingPolicy -> Maybe Text
$sel:fleetArn:ScalingPolicy' :: ScalingPolicy -> Maybe Text
$sel:evaluationPeriods:ScalingPolicy' :: ScalingPolicy -> Maybe Natural
$sel:comparisonOperator:ScalingPolicy' :: ScalingPolicy -> Maybe ComparisonOperatorType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ComparisonOperatorType
comparisonOperator
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
evaluationPeriods
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
fleetArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
fleetId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
location
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe MetricName
metricName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PolicyType
policyType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
scalingAdjustment
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ScalingAdjustmentType
scalingAdjustmentType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ScalingStatusType
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TargetConfiguration
targetConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
threshold
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe LocationUpdateStatus
updateStatus