{-# 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.AutoScaling.Types.PredictiveScalingPredefinedMetricPair
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AutoScaling.Types.PredictiveScalingPredefinedMetricPair where

import Amazonka.AutoScaling.Types.PredefinedMetricPairType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents a metric pair for a predictive scaling policy.
--
-- /See:/ 'newPredictiveScalingPredefinedMetricPair' smart constructor.
data PredictiveScalingPredefinedMetricPair = PredictiveScalingPredefinedMetricPair'
  { -- | A label that uniquely identifies a specific Application Load Balancer
    -- target group from which to determine the total and average request count
    -- served by your Auto Scaling group. You can\'t specify a resource label
    -- unless the target group is attached to the Auto Scaling group.
    --
    -- You create the resource label by appending the final portion of the load
    -- balancer ARN and the final portion of the target group ARN into a single
    -- value, separated by a forward slash (\/). The format of the resource
    -- label is:
    --
    -- @app\/my-alb\/778d41231b141a0f\/targetgroup\/my-alb-target-group\/943f017f100becff@.
    --
    -- Where:
    --
    -- -   app\/\<load-balancer-name>\/\<load-balancer-id> is the final portion
    --     of the load balancer ARN
    --
    -- -   targetgroup\/\<target-group-name>\/\<target-group-id> is the final
    --     portion of the target group ARN.
    --
    -- To find the ARN for an Application Load Balancer, use the
    -- <https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_DescribeLoadBalancers.html DescribeLoadBalancers>
    -- API operation. To find the ARN for the target group, use the
    -- <https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_DescribeTargetGroups.html DescribeTargetGroups>
    -- API operation.
    PredictiveScalingPredefinedMetricPair -> Maybe Text
resourceLabel :: Prelude.Maybe Prelude.Text,
    -- | Indicates which metrics to use. There are two different types of metrics
    -- for each metric type: one is a load metric and one is a scaling metric.
    -- For example, if the metric type is @ASGCPUUtilization@, the Auto Scaling
    -- group\'s total CPU metric is used as the load metric, and the average
    -- CPU metric is used for the scaling metric.
    PredictiveScalingPredefinedMetricPair -> PredefinedMetricPairType
predefinedMetricType :: PredefinedMetricPairType
  }
  deriving (PredictiveScalingPredefinedMetricPair
-> PredictiveScalingPredefinedMetricPair -> Bool
(PredictiveScalingPredefinedMetricPair
 -> PredictiveScalingPredefinedMetricPair -> Bool)
-> (PredictiveScalingPredefinedMetricPair
    -> PredictiveScalingPredefinedMetricPair -> Bool)
-> Eq PredictiveScalingPredefinedMetricPair
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PredictiveScalingPredefinedMetricPair
-> PredictiveScalingPredefinedMetricPair -> Bool
$c/= :: PredictiveScalingPredefinedMetricPair
-> PredictiveScalingPredefinedMetricPair -> Bool
== :: PredictiveScalingPredefinedMetricPair
-> PredictiveScalingPredefinedMetricPair -> Bool
$c== :: PredictiveScalingPredefinedMetricPair
-> PredictiveScalingPredefinedMetricPair -> Bool
Prelude.Eq, ReadPrec [PredictiveScalingPredefinedMetricPair]
ReadPrec PredictiveScalingPredefinedMetricPair
Int -> ReadS PredictiveScalingPredefinedMetricPair
ReadS [PredictiveScalingPredefinedMetricPair]
(Int -> ReadS PredictiveScalingPredefinedMetricPair)
-> ReadS [PredictiveScalingPredefinedMetricPair]
-> ReadPrec PredictiveScalingPredefinedMetricPair
-> ReadPrec [PredictiveScalingPredefinedMetricPair]
-> Read PredictiveScalingPredefinedMetricPair
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PredictiveScalingPredefinedMetricPair]
$creadListPrec :: ReadPrec [PredictiveScalingPredefinedMetricPair]
readPrec :: ReadPrec PredictiveScalingPredefinedMetricPair
$creadPrec :: ReadPrec PredictiveScalingPredefinedMetricPair
readList :: ReadS [PredictiveScalingPredefinedMetricPair]
$creadList :: ReadS [PredictiveScalingPredefinedMetricPair]
readsPrec :: Int -> ReadS PredictiveScalingPredefinedMetricPair
$creadsPrec :: Int -> ReadS PredictiveScalingPredefinedMetricPair
Prelude.Read, Int -> PredictiveScalingPredefinedMetricPair -> ShowS
[PredictiveScalingPredefinedMetricPair] -> ShowS
PredictiveScalingPredefinedMetricPair -> String
(Int -> PredictiveScalingPredefinedMetricPair -> ShowS)
-> (PredictiveScalingPredefinedMetricPair -> String)
-> ([PredictiveScalingPredefinedMetricPair] -> ShowS)
-> Show PredictiveScalingPredefinedMetricPair
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PredictiveScalingPredefinedMetricPair] -> ShowS
$cshowList :: [PredictiveScalingPredefinedMetricPair] -> ShowS
show :: PredictiveScalingPredefinedMetricPair -> String
$cshow :: PredictiveScalingPredefinedMetricPair -> String
showsPrec :: Int -> PredictiveScalingPredefinedMetricPair -> ShowS
$cshowsPrec :: Int -> PredictiveScalingPredefinedMetricPair -> ShowS
Prelude.Show, (forall x.
 PredictiveScalingPredefinedMetricPair
 -> Rep PredictiveScalingPredefinedMetricPair x)
-> (forall x.
    Rep PredictiveScalingPredefinedMetricPair x
    -> PredictiveScalingPredefinedMetricPair)
-> Generic PredictiveScalingPredefinedMetricPair
forall x.
Rep PredictiveScalingPredefinedMetricPair x
-> PredictiveScalingPredefinedMetricPair
forall x.
PredictiveScalingPredefinedMetricPair
-> Rep PredictiveScalingPredefinedMetricPair x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PredictiveScalingPredefinedMetricPair x
-> PredictiveScalingPredefinedMetricPair
$cfrom :: forall x.
PredictiveScalingPredefinedMetricPair
-> Rep PredictiveScalingPredefinedMetricPair x
Prelude.Generic)

-- |
-- Create a value of 'PredictiveScalingPredefinedMetricPair' 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:
--
-- 'resourceLabel', 'predictiveScalingPredefinedMetricPair_resourceLabel' - A label that uniquely identifies a specific Application Load Balancer
-- target group from which to determine the total and average request count
-- served by your Auto Scaling group. You can\'t specify a resource label
-- unless the target group is attached to the Auto Scaling group.
--
-- You create the resource label by appending the final portion of the load
-- balancer ARN and the final portion of the target group ARN into a single
-- value, separated by a forward slash (\/). The format of the resource
-- label is:
--
-- @app\/my-alb\/778d41231b141a0f\/targetgroup\/my-alb-target-group\/943f017f100becff@.
--
-- Where:
--
-- -   app\/\<load-balancer-name>\/\<load-balancer-id> is the final portion
--     of the load balancer ARN
--
-- -   targetgroup\/\<target-group-name>\/\<target-group-id> is the final
--     portion of the target group ARN.
--
-- To find the ARN for an Application Load Balancer, use the
-- <https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_DescribeLoadBalancers.html DescribeLoadBalancers>
-- API operation. To find the ARN for the target group, use the
-- <https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_DescribeTargetGroups.html DescribeTargetGroups>
-- API operation.
--
-- 'predefinedMetricType', 'predictiveScalingPredefinedMetricPair_predefinedMetricType' - Indicates which metrics to use. There are two different types of metrics
-- for each metric type: one is a load metric and one is a scaling metric.
-- For example, if the metric type is @ASGCPUUtilization@, the Auto Scaling
-- group\'s total CPU metric is used as the load metric, and the average
-- CPU metric is used for the scaling metric.
newPredictiveScalingPredefinedMetricPair ::
  -- | 'predefinedMetricType'
  PredefinedMetricPairType ->
  PredictiveScalingPredefinedMetricPair
newPredictiveScalingPredefinedMetricPair :: PredefinedMetricPairType -> PredictiveScalingPredefinedMetricPair
newPredictiveScalingPredefinedMetricPair
  PredefinedMetricPairType
pPredefinedMetricType_ =
    PredictiveScalingPredefinedMetricPair' :: Maybe Text
-> PredefinedMetricPairType
-> PredictiveScalingPredefinedMetricPair
PredictiveScalingPredefinedMetricPair'
      { $sel:resourceLabel:PredictiveScalingPredefinedMetricPair' :: Maybe Text
resourceLabel =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:predefinedMetricType:PredictiveScalingPredefinedMetricPair' :: PredefinedMetricPairType
predefinedMetricType =
          PredefinedMetricPairType
pPredefinedMetricType_
      }

-- | A label that uniquely identifies a specific Application Load Balancer
-- target group from which to determine the total and average request count
-- served by your Auto Scaling group. You can\'t specify a resource label
-- unless the target group is attached to the Auto Scaling group.
--
-- You create the resource label by appending the final portion of the load
-- balancer ARN and the final portion of the target group ARN into a single
-- value, separated by a forward slash (\/). The format of the resource
-- label is:
--
-- @app\/my-alb\/778d41231b141a0f\/targetgroup\/my-alb-target-group\/943f017f100becff@.
--
-- Where:
--
-- -   app\/\<load-balancer-name>\/\<load-balancer-id> is the final portion
--     of the load balancer ARN
--
-- -   targetgroup\/\<target-group-name>\/\<target-group-id> is the final
--     portion of the target group ARN.
--
-- To find the ARN for an Application Load Balancer, use the
-- <https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_DescribeLoadBalancers.html DescribeLoadBalancers>
-- API operation. To find the ARN for the target group, use the
-- <https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_DescribeTargetGroups.html DescribeTargetGroups>
-- API operation.
predictiveScalingPredefinedMetricPair_resourceLabel :: Lens.Lens' PredictiveScalingPredefinedMetricPair (Prelude.Maybe Prelude.Text)
predictiveScalingPredefinedMetricPair_resourceLabel :: (Maybe Text -> f (Maybe Text))
-> PredictiveScalingPredefinedMetricPair
-> f PredictiveScalingPredefinedMetricPair
predictiveScalingPredefinedMetricPair_resourceLabel = (PredictiveScalingPredefinedMetricPair -> Maybe Text)
-> (PredictiveScalingPredefinedMetricPair
    -> Maybe Text -> PredictiveScalingPredefinedMetricPair)
-> Lens
     PredictiveScalingPredefinedMetricPair
     PredictiveScalingPredefinedMetricPair
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictiveScalingPredefinedMetricPair' {Maybe Text
resourceLabel :: Maybe Text
$sel:resourceLabel:PredictiveScalingPredefinedMetricPair' :: PredictiveScalingPredefinedMetricPair -> Maybe Text
resourceLabel} -> Maybe Text
resourceLabel) (\s :: PredictiveScalingPredefinedMetricPair
s@PredictiveScalingPredefinedMetricPair' {} Maybe Text
a -> PredictiveScalingPredefinedMetricPair
s {$sel:resourceLabel:PredictiveScalingPredefinedMetricPair' :: Maybe Text
resourceLabel = Maybe Text
a} :: PredictiveScalingPredefinedMetricPair)

-- | Indicates which metrics to use. There are two different types of metrics
-- for each metric type: one is a load metric and one is a scaling metric.
-- For example, if the metric type is @ASGCPUUtilization@, the Auto Scaling
-- group\'s total CPU metric is used as the load metric, and the average
-- CPU metric is used for the scaling metric.
predictiveScalingPredefinedMetricPair_predefinedMetricType :: Lens.Lens' PredictiveScalingPredefinedMetricPair PredefinedMetricPairType
predictiveScalingPredefinedMetricPair_predefinedMetricType :: (PredefinedMetricPairType -> f PredefinedMetricPairType)
-> PredictiveScalingPredefinedMetricPair
-> f PredictiveScalingPredefinedMetricPair
predictiveScalingPredefinedMetricPair_predefinedMetricType = (PredictiveScalingPredefinedMetricPair -> PredefinedMetricPairType)
-> (PredictiveScalingPredefinedMetricPair
    -> PredefinedMetricPairType
    -> PredictiveScalingPredefinedMetricPair)
-> Lens
     PredictiveScalingPredefinedMetricPair
     PredictiveScalingPredefinedMetricPair
     PredefinedMetricPairType
     PredefinedMetricPairType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictiveScalingPredefinedMetricPair' {PredefinedMetricPairType
predefinedMetricType :: PredefinedMetricPairType
$sel:predefinedMetricType:PredictiveScalingPredefinedMetricPair' :: PredictiveScalingPredefinedMetricPair -> PredefinedMetricPairType
predefinedMetricType} -> PredefinedMetricPairType
predefinedMetricType) (\s :: PredictiveScalingPredefinedMetricPair
s@PredictiveScalingPredefinedMetricPair' {} PredefinedMetricPairType
a -> PredictiveScalingPredefinedMetricPair
s {$sel:predefinedMetricType:PredictiveScalingPredefinedMetricPair' :: PredefinedMetricPairType
predefinedMetricType = PredefinedMetricPairType
a} :: PredictiveScalingPredefinedMetricPair)

instance
  Core.FromXML
    PredictiveScalingPredefinedMetricPair
  where
  parseXML :: [Node] -> Either String PredictiveScalingPredefinedMetricPair
parseXML [Node]
x =
    Maybe Text
-> PredefinedMetricPairType
-> PredictiveScalingPredefinedMetricPair
PredictiveScalingPredefinedMetricPair'
      (Maybe Text
 -> PredefinedMetricPairType
 -> PredictiveScalingPredefinedMetricPair)
-> Either String (Maybe Text)
-> Either
     String
     (PredefinedMetricPairType -> PredictiveScalingPredefinedMetricPair)
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
"ResourceLabel")
      Either
  String
  (PredefinedMetricPairType -> PredictiveScalingPredefinedMetricPair)
-> Either String PredefinedMetricPairType
-> Either String PredictiveScalingPredefinedMetricPair
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String PredefinedMetricPairType
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"PredefinedMetricType")

instance
  Prelude.Hashable
    PredictiveScalingPredefinedMetricPair

instance
  Prelude.NFData
    PredictiveScalingPredefinedMetricPair

instance
  Core.ToQuery
    PredictiveScalingPredefinedMetricPair
  where
  toQuery :: PredictiveScalingPredefinedMetricPair -> QueryString
toQuery PredictiveScalingPredefinedMetricPair' {Maybe Text
PredefinedMetricPairType
predefinedMetricType :: PredefinedMetricPairType
resourceLabel :: Maybe Text
$sel:predefinedMetricType:PredictiveScalingPredefinedMetricPair' :: PredictiveScalingPredefinedMetricPair -> PredefinedMetricPairType
$sel:resourceLabel:PredictiveScalingPredefinedMetricPair' :: PredictiveScalingPredefinedMetricPair -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"ResourceLabel" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
resourceLabel,
        ByteString
"PredefinedMetricType" ByteString -> PredefinedMetricPairType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: PredefinedMetricPairType
predefinedMetricType
      ]