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

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

-- | Represents a predefined metric for a target tracking scaling policy to
-- use with Amazon EC2 Auto Scaling.
--
-- /See:/ 'newPredefinedMetricSpecification' smart constructor.
data PredefinedMetricSpecification = PredefinedMetricSpecification'
  { -- | 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.
    PredefinedMetricSpecification -> Maybe Text
resourceLabel :: Prelude.Maybe Prelude.Text,
    -- | The metric type. The following predefined metrics are available:
    --
    -- -   @ASGAverageCPUUtilization@ - Average CPU utilization of the Auto
    --     Scaling group.
    --
    -- -   @ASGAverageNetworkIn@ - Average number of bytes received on all
    --     network interfaces by the Auto Scaling group.
    --
    -- -   @ASGAverageNetworkOut@ - Average number of bytes sent out on all
    --     network interfaces by the Auto Scaling group.
    --
    -- -   @ALBRequestCountPerTarget@ - Number of requests completed per target
    --     in an Application Load Balancer target group.
    PredefinedMetricSpecification -> MetricType
predefinedMetricType :: MetricType
  }
  deriving (PredefinedMetricSpecification
-> PredefinedMetricSpecification -> Bool
(PredefinedMetricSpecification
 -> PredefinedMetricSpecification -> Bool)
-> (PredefinedMetricSpecification
    -> PredefinedMetricSpecification -> Bool)
-> Eq PredefinedMetricSpecification
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PredefinedMetricSpecification
-> PredefinedMetricSpecification -> Bool
$c/= :: PredefinedMetricSpecification
-> PredefinedMetricSpecification -> Bool
== :: PredefinedMetricSpecification
-> PredefinedMetricSpecification -> Bool
$c== :: PredefinedMetricSpecification
-> PredefinedMetricSpecification -> Bool
Prelude.Eq, ReadPrec [PredefinedMetricSpecification]
ReadPrec PredefinedMetricSpecification
Int -> ReadS PredefinedMetricSpecification
ReadS [PredefinedMetricSpecification]
(Int -> ReadS PredefinedMetricSpecification)
-> ReadS [PredefinedMetricSpecification]
-> ReadPrec PredefinedMetricSpecification
-> ReadPrec [PredefinedMetricSpecification]
-> Read PredefinedMetricSpecification
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PredefinedMetricSpecification]
$creadListPrec :: ReadPrec [PredefinedMetricSpecification]
readPrec :: ReadPrec PredefinedMetricSpecification
$creadPrec :: ReadPrec PredefinedMetricSpecification
readList :: ReadS [PredefinedMetricSpecification]
$creadList :: ReadS [PredefinedMetricSpecification]
readsPrec :: Int -> ReadS PredefinedMetricSpecification
$creadsPrec :: Int -> ReadS PredefinedMetricSpecification
Prelude.Read, Int -> PredefinedMetricSpecification -> ShowS
[PredefinedMetricSpecification] -> ShowS
PredefinedMetricSpecification -> String
(Int -> PredefinedMetricSpecification -> ShowS)
-> (PredefinedMetricSpecification -> String)
-> ([PredefinedMetricSpecification] -> ShowS)
-> Show PredefinedMetricSpecification
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PredefinedMetricSpecification] -> ShowS
$cshowList :: [PredefinedMetricSpecification] -> ShowS
show :: PredefinedMetricSpecification -> String
$cshow :: PredefinedMetricSpecification -> String
showsPrec :: Int -> PredefinedMetricSpecification -> ShowS
$cshowsPrec :: Int -> PredefinedMetricSpecification -> ShowS
Prelude.Show, (forall x.
 PredefinedMetricSpecification
 -> Rep PredefinedMetricSpecification x)
-> (forall x.
    Rep PredefinedMetricSpecification x
    -> PredefinedMetricSpecification)
-> Generic PredefinedMetricSpecification
forall x.
Rep PredefinedMetricSpecification x
-> PredefinedMetricSpecification
forall x.
PredefinedMetricSpecification
-> Rep PredefinedMetricSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PredefinedMetricSpecification x
-> PredefinedMetricSpecification
$cfrom :: forall x.
PredefinedMetricSpecification
-> Rep PredefinedMetricSpecification x
Prelude.Generic)

-- |
-- Create a value of 'PredefinedMetricSpecification' 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', 'predefinedMetricSpecification_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', 'predefinedMetricSpecification_predefinedMetricType' - The metric type. The following predefined metrics are available:
--
-- -   @ASGAverageCPUUtilization@ - Average CPU utilization of the Auto
--     Scaling group.
--
-- -   @ASGAverageNetworkIn@ - Average number of bytes received on all
--     network interfaces by the Auto Scaling group.
--
-- -   @ASGAverageNetworkOut@ - Average number of bytes sent out on all
--     network interfaces by the Auto Scaling group.
--
-- -   @ALBRequestCountPerTarget@ - Number of requests completed per target
--     in an Application Load Balancer target group.
newPredefinedMetricSpecification ::
  -- | 'predefinedMetricType'
  MetricType ->
  PredefinedMetricSpecification
newPredefinedMetricSpecification :: MetricType -> PredefinedMetricSpecification
newPredefinedMetricSpecification
  MetricType
pPredefinedMetricType_ =
    PredefinedMetricSpecification' :: Maybe Text -> MetricType -> PredefinedMetricSpecification
PredefinedMetricSpecification'
      { $sel:resourceLabel:PredefinedMetricSpecification' :: Maybe Text
resourceLabel =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:predefinedMetricType:PredefinedMetricSpecification' :: MetricType
predefinedMetricType =
          MetricType
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.
predefinedMetricSpecification_resourceLabel :: Lens.Lens' PredefinedMetricSpecification (Prelude.Maybe Prelude.Text)
predefinedMetricSpecification_resourceLabel :: (Maybe Text -> f (Maybe Text))
-> PredefinedMetricSpecification -> f PredefinedMetricSpecification
predefinedMetricSpecification_resourceLabel = (PredefinedMetricSpecification -> Maybe Text)
-> (PredefinedMetricSpecification
    -> Maybe Text -> PredefinedMetricSpecification)
-> Lens
     PredefinedMetricSpecification
     PredefinedMetricSpecification
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredefinedMetricSpecification' {Maybe Text
resourceLabel :: Maybe Text
$sel:resourceLabel:PredefinedMetricSpecification' :: PredefinedMetricSpecification -> Maybe Text
resourceLabel} -> Maybe Text
resourceLabel) (\s :: PredefinedMetricSpecification
s@PredefinedMetricSpecification' {} Maybe Text
a -> PredefinedMetricSpecification
s {$sel:resourceLabel:PredefinedMetricSpecification' :: Maybe Text
resourceLabel = Maybe Text
a} :: PredefinedMetricSpecification)

-- | The metric type. The following predefined metrics are available:
--
-- -   @ASGAverageCPUUtilization@ - Average CPU utilization of the Auto
--     Scaling group.
--
-- -   @ASGAverageNetworkIn@ - Average number of bytes received on all
--     network interfaces by the Auto Scaling group.
--
-- -   @ASGAverageNetworkOut@ - Average number of bytes sent out on all
--     network interfaces by the Auto Scaling group.
--
-- -   @ALBRequestCountPerTarget@ - Number of requests completed per target
--     in an Application Load Balancer target group.
predefinedMetricSpecification_predefinedMetricType :: Lens.Lens' PredefinedMetricSpecification MetricType
predefinedMetricSpecification_predefinedMetricType :: (MetricType -> f MetricType)
-> PredefinedMetricSpecification -> f PredefinedMetricSpecification
predefinedMetricSpecification_predefinedMetricType = (PredefinedMetricSpecification -> MetricType)
-> (PredefinedMetricSpecification
    -> MetricType -> PredefinedMetricSpecification)
-> Lens
     PredefinedMetricSpecification
     PredefinedMetricSpecification
     MetricType
     MetricType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredefinedMetricSpecification' {MetricType
predefinedMetricType :: MetricType
$sel:predefinedMetricType:PredefinedMetricSpecification' :: PredefinedMetricSpecification -> MetricType
predefinedMetricType} -> MetricType
predefinedMetricType) (\s :: PredefinedMetricSpecification
s@PredefinedMetricSpecification' {} MetricType
a -> PredefinedMetricSpecification
s {$sel:predefinedMetricType:PredefinedMetricSpecification' :: MetricType
predefinedMetricType = MetricType
a} :: PredefinedMetricSpecification)

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

instance
  Prelude.Hashable
    PredefinedMetricSpecification

instance Prelude.NFData PredefinedMetricSpecification

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