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

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

-- | Describes a scaling metric for a predictive scaling policy.
--
-- When returned in the output of @DescribePolicies@, it indicates that a
-- predictive scaling policy uses individually specified load and scaling
-- metrics instead of a metric pair.
--
-- /See:/ 'newPredictiveScalingPredefinedScalingMetric' smart constructor.
data PredictiveScalingPredefinedScalingMetric = PredictiveScalingPredefinedScalingMetric'
  { -- | A label that uniquely identifies a specific Application Load Balancer
    -- target group from which to determine the 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.
    PredictiveScalingPredefinedScalingMetric -> Maybe Text
resourceLabel :: Prelude.Maybe Prelude.Text,
    -- | The metric type.
    PredictiveScalingPredefinedScalingMetric
-> PredefinedScalingMetricType
predefinedMetricType :: PredefinedScalingMetricType
  }
  deriving (PredictiveScalingPredefinedScalingMetric
-> PredictiveScalingPredefinedScalingMetric -> Bool
(PredictiveScalingPredefinedScalingMetric
 -> PredictiveScalingPredefinedScalingMetric -> Bool)
-> (PredictiveScalingPredefinedScalingMetric
    -> PredictiveScalingPredefinedScalingMetric -> Bool)
-> Eq PredictiveScalingPredefinedScalingMetric
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PredictiveScalingPredefinedScalingMetric
-> PredictiveScalingPredefinedScalingMetric -> Bool
$c/= :: PredictiveScalingPredefinedScalingMetric
-> PredictiveScalingPredefinedScalingMetric -> Bool
== :: PredictiveScalingPredefinedScalingMetric
-> PredictiveScalingPredefinedScalingMetric -> Bool
$c== :: PredictiveScalingPredefinedScalingMetric
-> PredictiveScalingPredefinedScalingMetric -> Bool
Prelude.Eq, ReadPrec [PredictiveScalingPredefinedScalingMetric]
ReadPrec PredictiveScalingPredefinedScalingMetric
Int -> ReadS PredictiveScalingPredefinedScalingMetric
ReadS [PredictiveScalingPredefinedScalingMetric]
(Int -> ReadS PredictiveScalingPredefinedScalingMetric)
-> ReadS [PredictiveScalingPredefinedScalingMetric]
-> ReadPrec PredictiveScalingPredefinedScalingMetric
-> ReadPrec [PredictiveScalingPredefinedScalingMetric]
-> Read PredictiveScalingPredefinedScalingMetric
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PredictiveScalingPredefinedScalingMetric]
$creadListPrec :: ReadPrec [PredictiveScalingPredefinedScalingMetric]
readPrec :: ReadPrec PredictiveScalingPredefinedScalingMetric
$creadPrec :: ReadPrec PredictiveScalingPredefinedScalingMetric
readList :: ReadS [PredictiveScalingPredefinedScalingMetric]
$creadList :: ReadS [PredictiveScalingPredefinedScalingMetric]
readsPrec :: Int -> ReadS PredictiveScalingPredefinedScalingMetric
$creadsPrec :: Int -> ReadS PredictiveScalingPredefinedScalingMetric
Prelude.Read, Int -> PredictiveScalingPredefinedScalingMetric -> ShowS
[PredictiveScalingPredefinedScalingMetric] -> ShowS
PredictiveScalingPredefinedScalingMetric -> String
(Int -> PredictiveScalingPredefinedScalingMetric -> ShowS)
-> (PredictiveScalingPredefinedScalingMetric -> String)
-> ([PredictiveScalingPredefinedScalingMetric] -> ShowS)
-> Show PredictiveScalingPredefinedScalingMetric
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PredictiveScalingPredefinedScalingMetric] -> ShowS
$cshowList :: [PredictiveScalingPredefinedScalingMetric] -> ShowS
show :: PredictiveScalingPredefinedScalingMetric -> String
$cshow :: PredictiveScalingPredefinedScalingMetric -> String
showsPrec :: Int -> PredictiveScalingPredefinedScalingMetric -> ShowS
$cshowsPrec :: Int -> PredictiveScalingPredefinedScalingMetric -> ShowS
Prelude.Show, (forall x.
 PredictiveScalingPredefinedScalingMetric
 -> Rep PredictiveScalingPredefinedScalingMetric x)
-> (forall x.
    Rep PredictiveScalingPredefinedScalingMetric x
    -> PredictiveScalingPredefinedScalingMetric)
-> Generic PredictiveScalingPredefinedScalingMetric
forall x.
Rep PredictiveScalingPredefinedScalingMetric x
-> PredictiveScalingPredefinedScalingMetric
forall x.
PredictiveScalingPredefinedScalingMetric
-> Rep PredictiveScalingPredefinedScalingMetric x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PredictiveScalingPredefinedScalingMetric x
-> PredictiveScalingPredefinedScalingMetric
$cfrom :: forall x.
PredictiveScalingPredefinedScalingMetric
-> Rep PredictiveScalingPredefinedScalingMetric x
Prelude.Generic)

-- |
-- Create a value of 'PredictiveScalingPredefinedScalingMetric' 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', 'predictiveScalingPredefinedScalingMetric_resourceLabel' - A label that uniquely identifies a specific Application Load Balancer
-- target group from which to determine the 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', 'predictiveScalingPredefinedScalingMetric_predefinedMetricType' - The metric type.
newPredictiveScalingPredefinedScalingMetric ::
  -- | 'predefinedMetricType'
  PredefinedScalingMetricType ->
  PredictiveScalingPredefinedScalingMetric
newPredictiveScalingPredefinedScalingMetric :: PredefinedScalingMetricType
-> PredictiveScalingPredefinedScalingMetric
newPredictiveScalingPredefinedScalingMetric
  PredefinedScalingMetricType
pPredefinedMetricType_ =
    PredictiveScalingPredefinedScalingMetric' :: Maybe Text
-> PredefinedScalingMetricType
-> PredictiveScalingPredefinedScalingMetric
PredictiveScalingPredefinedScalingMetric'
      { $sel:resourceLabel:PredictiveScalingPredefinedScalingMetric' :: Maybe Text
resourceLabel =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:predefinedMetricType:PredictiveScalingPredefinedScalingMetric' :: PredefinedScalingMetricType
predefinedMetricType =
          PredefinedScalingMetricType
pPredefinedMetricType_
      }

-- | A label that uniquely identifies a specific Application Load Balancer
-- target group from which to determine the 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.
predictiveScalingPredefinedScalingMetric_resourceLabel :: Lens.Lens' PredictiveScalingPredefinedScalingMetric (Prelude.Maybe Prelude.Text)
predictiveScalingPredefinedScalingMetric_resourceLabel :: (Maybe Text -> f (Maybe Text))
-> PredictiveScalingPredefinedScalingMetric
-> f PredictiveScalingPredefinedScalingMetric
predictiveScalingPredefinedScalingMetric_resourceLabel = (PredictiveScalingPredefinedScalingMetric -> Maybe Text)
-> (PredictiveScalingPredefinedScalingMetric
    -> Maybe Text -> PredictiveScalingPredefinedScalingMetric)
-> Lens
     PredictiveScalingPredefinedScalingMetric
     PredictiveScalingPredefinedScalingMetric
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictiveScalingPredefinedScalingMetric' {Maybe Text
resourceLabel :: Maybe Text
$sel:resourceLabel:PredictiveScalingPredefinedScalingMetric' :: PredictiveScalingPredefinedScalingMetric -> Maybe Text
resourceLabel} -> Maybe Text
resourceLabel) (\s :: PredictiveScalingPredefinedScalingMetric
s@PredictiveScalingPredefinedScalingMetric' {} Maybe Text
a -> PredictiveScalingPredefinedScalingMetric
s {$sel:resourceLabel:PredictiveScalingPredefinedScalingMetric' :: Maybe Text
resourceLabel = Maybe Text
a} :: PredictiveScalingPredefinedScalingMetric)

-- | The metric type.
predictiveScalingPredefinedScalingMetric_predefinedMetricType :: Lens.Lens' PredictiveScalingPredefinedScalingMetric PredefinedScalingMetricType
predictiveScalingPredefinedScalingMetric_predefinedMetricType :: (PredefinedScalingMetricType -> f PredefinedScalingMetricType)
-> PredictiveScalingPredefinedScalingMetric
-> f PredictiveScalingPredefinedScalingMetric
predictiveScalingPredefinedScalingMetric_predefinedMetricType = (PredictiveScalingPredefinedScalingMetric
 -> PredefinedScalingMetricType)
-> (PredictiveScalingPredefinedScalingMetric
    -> PredefinedScalingMetricType
    -> PredictiveScalingPredefinedScalingMetric)
-> Lens
     PredictiveScalingPredefinedScalingMetric
     PredictiveScalingPredefinedScalingMetric
     PredefinedScalingMetricType
     PredefinedScalingMetricType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictiveScalingPredefinedScalingMetric' {PredefinedScalingMetricType
predefinedMetricType :: PredefinedScalingMetricType
$sel:predefinedMetricType:PredictiveScalingPredefinedScalingMetric' :: PredictiveScalingPredefinedScalingMetric
-> PredefinedScalingMetricType
predefinedMetricType} -> PredefinedScalingMetricType
predefinedMetricType) (\s :: PredictiveScalingPredefinedScalingMetric
s@PredictiveScalingPredefinedScalingMetric' {} PredefinedScalingMetricType
a -> PredictiveScalingPredefinedScalingMetric
s {$sel:predefinedMetricType:PredictiveScalingPredefinedScalingMetric' :: PredefinedScalingMetricType
predefinedMetricType = PredefinedScalingMetricType
a} :: PredictiveScalingPredefinedScalingMetric)

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

instance
  Prelude.Hashable
    PredictiveScalingPredefinedScalingMetric

instance
  Prelude.NFData
    PredictiveScalingPredefinedScalingMetric

instance
  Core.ToQuery
    PredictiveScalingPredefinedScalingMetric
  where
  toQuery :: PredictiveScalingPredefinedScalingMetric -> QueryString
toQuery PredictiveScalingPredefinedScalingMetric' {Maybe Text
PredefinedScalingMetricType
predefinedMetricType :: PredefinedScalingMetricType
resourceLabel :: Maybe Text
$sel:predefinedMetricType:PredictiveScalingPredefinedScalingMetric' :: PredictiveScalingPredefinedScalingMetric
-> PredefinedScalingMetricType
$sel:resourceLabel:PredictiveScalingPredefinedScalingMetric' :: PredictiveScalingPredefinedScalingMetric -> 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 -> PredefinedScalingMetricType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: PredefinedScalingMetricType
predefinedMetricType
      ]