{-# 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.PredictiveScalingPredefinedLoadMetric
-- 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.AutoScaling.Types.PredictiveScalingPredefinedLoadMetric where

import Amazonka.AutoScaling.Types.PredefinedLoadMetricType
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Describes a load 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:/ 'newPredictiveScalingPredefinedLoadMetric' smart constructor.
data PredictiveScalingPredefinedLoadMetric = PredictiveScalingPredefinedLoadMetric'
  { -- | A label that uniquely identifies a specific Application Load Balancer
    -- target group from which to determine the 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.
    PredictiveScalingPredefinedLoadMetric -> Maybe Text
resourceLabel :: Prelude.Maybe Prelude.Text,
    -- | The metric type.
    PredictiveScalingPredefinedLoadMetric -> PredefinedLoadMetricType
predefinedMetricType :: PredefinedLoadMetricType
  }
  deriving (PredictiveScalingPredefinedLoadMetric
-> PredictiveScalingPredefinedLoadMetric -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PredictiveScalingPredefinedLoadMetric
-> PredictiveScalingPredefinedLoadMetric -> Bool
$c/= :: PredictiveScalingPredefinedLoadMetric
-> PredictiveScalingPredefinedLoadMetric -> Bool
== :: PredictiveScalingPredefinedLoadMetric
-> PredictiveScalingPredefinedLoadMetric -> Bool
$c== :: PredictiveScalingPredefinedLoadMetric
-> PredictiveScalingPredefinedLoadMetric -> Bool
Prelude.Eq, ReadPrec [PredictiveScalingPredefinedLoadMetric]
ReadPrec PredictiveScalingPredefinedLoadMetric
Int -> ReadS PredictiveScalingPredefinedLoadMetric
ReadS [PredictiveScalingPredefinedLoadMetric]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PredictiveScalingPredefinedLoadMetric]
$creadListPrec :: ReadPrec [PredictiveScalingPredefinedLoadMetric]
readPrec :: ReadPrec PredictiveScalingPredefinedLoadMetric
$creadPrec :: ReadPrec PredictiveScalingPredefinedLoadMetric
readList :: ReadS [PredictiveScalingPredefinedLoadMetric]
$creadList :: ReadS [PredictiveScalingPredefinedLoadMetric]
readsPrec :: Int -> ReadS PredictiveScalingPredefinedLoadMetric
$creadsPrec :: Int -> ReadS PredictiveScalingPredefinedLoadMetric
Prelude.Read, Int -> PredictiveScalingPredefinedLoadMetric -> ShowS
[PredictiveScalingPredefinedLoadMetric] -> ShowS
PredictiveScalingPredefinedLoadMetric -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PredictiveScalingPredefinedLoadMetric] -> ShowS
$cshowList :: [PredictiveScalingPredefinedLoadMetric] -> ShowS
show :: PredictiveScalingPredefinedLoadMetric -> String
$cshow :: PredictiveScalingPredefinedLoadMetric -> String
showsPrec :: Int -> PredictiveScalingPredefinedLoadMetric -> ShowS
$cshowsPrec :: Int -> PredictiveScalingPredefinedLoadMetric -> ShowS
Prelude.Show, forall x.
Rep PredictiveScalingPredefinedLoadMetric x
-> PredictiveScalingPredefinedLoadMetric
forall x.
PredictiveScalingPredefinedLoadMetric
-> Rep PredictiveScalingPredefinedLoadMetric x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PredictiveScalingPredefinedLoadMetric x
-> PredictiveScalingPredefinedLoadMetric
$cfrom :: forall x.
PredictiveScalingPredefinedLoadMetric
-> Rep PredictiveScalingPredefinedLoadMetric x
Prelude.Generic)

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

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

-- | The metric type.
predictiveScalingPredefinedLoadMetric_predefinedMetricType :: Lens.Lens' PredictiveScalingPredefinedLoadMetric PredefinedLoadMetricType
predictiveScalingPredefinedLoadMetric_predefinedMetricType :: Lens'
  PredictiveScalingPredefinedLoadMetric PredefinedLoadMetricType
predictiveScalingPredefinedLoadMetric_predefinedMetricType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictiveScalingPredefinedLoadMetric' {PredefinedLoadMetricType
predefinedMetricType :: PredefinedLoadMetricType
$sel:predefinedMetricType:PredictiveScalingPredefinedLoadMetric' :: PredictiveScalingPredefinedLoadMetric -> PredefinedLoadMetricType
predefinedMetricType} -> PredefinedLoadMetricType
predefinedMetricType) (\s :: PredictiveScalingPredefinedLoadMetric
s@PredictiveScalingPredefinedLoadMetric' {} PredefinedLoadMetricType
a -> PredictiveScalingPredefinedLoadMetric
s {$sel:predefinedMetricType:PredictiveScalingPredefinedLoadMetric' :: PredefinedLoadMetricType
predefinedMetricType = PredefinedLoadMetricType
a} :: PredictiveScalingPredefinedLoadMetric)

instance
  Data.FromXML
    PredictiveScalingPredefinedLoadMetric
  where
  parseXML :: [Node] -> Either String PredictiveScalingPredefinedLoadMetric
parseXML [Node]
x =
    Maybe Text
-> PredefinedLoadMetricType
-> PredictiveScalingPredefinedLoadMetric
PredictiveScalingPredefinedLoadMetric'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ResourceLabel")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"PredefinedMetricType")

instance
  Prelude.Hashable
    PredictiveScalingPredefinedLoadMetric
  where
  hashWithSalt :: Int -> PredictiveScalingPredefinedLoadMetric -> Int
hashWithSalt
    Int
_salt
    PredictiveScalingPredefinedLoadMetric' {Maybe Text
PredefinedLoadMetricType
predefinedMetricType :: PredefinedLoadMetricType
resourceLabel :: Maybe Text
$sel:predefinedMetricType:PredictiveScalingPredefinedLoadMetric' :: PredictiveScalingPredefinedLoadMetric -> PredefinedLoadMetricType
$sel:resourceLabel:PredictiveScalingPredefinedLoadMetric' :: PredictiveScalingPredefinedLoadMetric -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceLabel
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` PredefinedLoadMetricType
predefinedMetricType

instance
  Prelude.NFData
    PredictiveScalingPredefinedLoadMetric
  where
  rnf :: PredictiveScalingPredefinedLoadMetric -> ()
rnf PredictiveScalingPredefinedLoadMetric' {Maybe Text
PredefinedLoadMetricType
predefinedMetricType :: PredefinedLoadMetricType
resourceLabel :: Maybe Text
$sel:predefinedMetricType:PredictiveScalingPredefinedLoadMetric' :: PredictiveScalingPredefinedLoadMetric -> PredefinedLoadMetricType
$sel:resourceLabel:PredictiveScalingPredefinedLoadMetric' :: PredictiveScalingPredefinedLoadMetric -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceLabel
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf PredefinedLoadMetricType
predefinedMetricType

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