{-# 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.AutoScalingPlans.Types.PredefinedLoadMetricSpecification
-- 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.AutoScalingPlans.Types.PredefinedLoadMetricSpecification where

import Amazonka.AutoScalingPlans.Types.LoadMetricType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents a predefined metric that can be used for predictive scaling.
--
-- After creating your scaling plan, you can use the AWS Auto Scaling
-- console to visualize forecasts for the specified metric. For more
-- information, see
-- <https://docs.aws.amazon.com/autoscaling/plans/userguide/gs-create-scaling-plan.html#gs-view-resource View Scaling Information for a Resource>
-- in the /AWS Auto Scaling User Guide/.
--
-- /See:/ 'newPredefinedLoadMetricSpecification' smart constructor.
data PredefinedLoadMetricSpecification = PredefinedLoadMetricSpecification'
  { -- | Identifies the resource associated with the metric type. You can\'t
    -- specify a resource label unless the metric type is
    -- @ALBTargetGroupRequestCount@ and there is a target group for an
    -- Application Load Balancer 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 is
    -- app\/\<load-balancer-name>\/\<load-balancer-id>\/targetgroup\/\<target-group-name>\/\<target-group-id>,
    -- 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.
    --
    -- This is an example:
    -- app\/EC2Co-EcsEl-1TKLTMITMM0EO\/f37c06a68c1748aa\/targetgroup\/EC2Co-Defau-LDNM7Q3ZH1ZN\/6d4ea56ca2d6a18d.
    --
    -- 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.
    PredefinedLoadMetricSpecification -> Maybe Text
resourceLabel :: Prelude.Maybe Prelude.Text,
    -- | The metric type.
    PredefinedLoadMetricSpecification -> LoadMetricType
predefinedLoadMetricType :: LoadMetricType
  }
  deriving (PredefinedLoadMetricSpecification
-> PredefinedLoadMetricSpecification -> Bool
(PredefinedLoadMetricSpecification
 -> PredefinedLoadMetricSpecification -> Bool)
-> (PredefinedLoadMetricSpecification
    -> PredefinedLoadMetricSpecification -> Bool)
-> Eq PredefinedLoadMetricSpecification
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PredefinedLoadMetricSpecification
-> PredefinedLoadMetricSpecification -> Bool
$c/= :: PredefinedLoadMetricSpecification
-> PredefinedLoadMetricSpecification -> Bool
== :: PredefinedLoadMetricSpecification
-> PredefinedLoadMetricSpecification -> Bool
$c== :: PredefinedLoadMetricSpecification
-> PredefinedLoadMetricSpecification -> Bool
Prelude.Eq, ReadPrec [PredefinedLoadMetricSpecification]
ReadPrec PredefinedLoadMetricSpecification
Int -> ReadS PredefinedLoadMetricSpecification
ReadS [PredefinedLoadMetricSpecification]
(Int -> ReadS PredefinedLoadMetricSpecification)
-> ReadS [PredefinedLoadMetricSpecification]
-> ReadPrec PredefinedLoadMetricSpecification
-> ReadPrec [PredefinedLoadMetricSpecification]
-> Read PredefinedLoadMetricSpecification
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PredefinedLoadMetricSpecification]
$creadListPrec :: ReadPrec [PredefinedLoadMetricSpecification]
readPrec :: ReadPrec PredefinedLoadMetricSpecification
$creadPrec :: ReadPrec PredefinedLoadMetricSpecification
readList :: ReadS [PredefinedLoadMetricSpecification]
$creadList :: ReadS [PredefinedLoadMetricSpecification]
readsPrec :: Int -> ReadS PredefinedLoadMetricSpecification
$creadsPrec :: Int -> ReadS PredefinedLoadMetricSpecification
Prelude.Read, Int -> PredefinedLoadMetricSpecification -> ShowS
[PredefinedLoadMetricSpecification] -> ShowS
PredefinedLoadMetricSpecification -> String
(Int -> PredefinedLoadMetricSpecification -> ShowS)
-> (PredefinedLoadMetricSpecification -> String)
-> ([PredefinedLoadMetricSpecification] -> ShowS)
-> Show PredefinedLoadMetricSpecification
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PredefinedLoadMetricSpecification] -> ShowS
$cshowList :: [PredefinedLoadMetricSpecification] -> ShowS
show :: PredefinedLoadMetricSpecification -> String
$cshow :: PredefinedLoadMetricSpecification -> String
showsPrec :: Int -> PredefinedLoadMetricSpecification -> ShowS
$cshowsPrec :: Int -> PredefinedLoadMetricSpecification -> ShowS
Prelude.Show, (forall x.
 PredefinedLoadMetricSpecification
 -> Rep PredefinedLoadMetricSpecification x)
-> (forall x.
    Rep PredefinedLoadMetricSpecification x
    -> PredefinedLoadMetricSpecification)
-> Generic PredefinedLoadMetricSpecification
forall x.
Rep PredefinedLoadMetricSpecification x
-> PredefinedLoadMetricSpecification
forall x.
PredefinedLoadMetricSpecification
-> Rep PredefinedLoadMetricSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PredefinedLoadMetricSpecification x
-> PredefinedLoadMetricSpecification
$cfrom :: forall x.
PredefinedLoadMetricSpecification
-> Rep PredefinedLoadMetricSpecification x
Prelude.Generic)

-- |
-- Create a value of 'PredefinedLoadMetricSpecification' 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', 'predefinedLoadMetricSpecification_resourceLabel' - Identifies the resource associated with the metric type. You can\'t
-- specify a resource label unless the metric type is
-- @ALBTargetGroupRequestCount@ and there is a target group for an
-- Application Load Balancer 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 is
-- app\/\<load-balancer-name>\/\<load-balancer-id>\/targetgroup\/\<target-group-name>\/\<target-group-id>,
-- 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.
--
-- This is an example:
-- app\/EC2Co-EcsEl-1TKLTMITMM0EO\/f37c06a68c1748aa\/targetgroup\/EC2Co-Defau-LDNM7Q3ZH1ZN\/6d4ea56ca2d6a18d.
--
-- 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.
--
-- 'predefinedLoadMetricType', 'predefinedLoadMetricSpecification_predefinedLoadMetricType' - The metric type.
newPredefinedLoadMetricSpecification ::
  -- | 'predefinedLoadMetricType'
  LoadMetricType ->
  PredefinedLoadMetricSpecification
newPredefinedLoadMetricSpecification :: LoadMetricType -> PredefinedLoadMetricSpecification
newPredefinedLoadMetricSpecification
  LoadMetricType
pPredefinedLoadMetricType_ =
    PredefinedLoadMetricSpecification' :: Maybe Text -> LoadMetricType -> PredefinedLoadMetricSpecification
PredefinedLoadMetricSpecification'
      { $sel:resourceLabel:PredefinedLoadMetricSpecification' :: Maybe Text
resourceLabel =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:predefinedLoadMetricType:PredefinedLoadMetricSpecification' :: LoadMetricType
predefinedLoadMetricType =
          LoadMetricType
pPredefinedLoadMetricType_
      }

-- | Identifies the resource associated with the metric type. You can\'t
-- specify a resource label unless the metric type is
-- @ALBTargetGroupRequestCount@ and there is a target group for an
-- Application Load Balancer 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 is
-- app\/\<load-balancer-name>\/\<load-balancer-id>\/targetgroup\/\<target-group-name>\/\<target-group-id>,
-- 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.
--
-- This is an example:
-- app\/EC2Co-EcsEl-1TKLTMITMM0EO\/f37c06a68c1748aa\/targetgroup\/EC2Co-Defau-LDNM7Q3ZH1ZN\/6d4ea56ca2d6a18d.
--
-- 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.
predefinedLoadMetricSpecification_resourceLabel :: Lens.Lens' PredefinedLoadMetricSpecification (Prelude.Maybe Prelude.Text)
predefinedLoadMetricSpecification_resourceLabel :: (Maybe Text -> f (Maybe Text))
-> PredefinedLoadMetricSpecification
-> f PredefinedLoadMetricSpecification
predefinedLoadMetricSpecification_resourceLabel = (PredefinedLoadMetricSpecification -> Maybe Text)
-> (PredefinedLoadMetricSpecification
    -> Maybe Text -> PredefinedLoadMetricSpecification)
-> Lens
     PredefinedLoadMetricSpecification
     PredefinedLoadMetricSpecification
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredefinedLoadMetricSpecification' {Maybe Text
resourceLabel :: Maybe Text
$sel:resourceLabel:PredefinedLoadMetricSpecification' :: PredefinedLoadMetricSpecification -> Maybe Text
resourceLabel} -> Maybe Text
resourceLabel) (\s :: PredefinedLoadMetricSpecification
s@PredefinedLoadMetricSpecification' {} Maybe Text
a -> PredefinedLoadMetricSpecification
s {$sel:resourceLabel:PredefinedLoadMetricSpecification' :: Maybe Text
resourceLabel = Maybe Text
a} :: PredefinedLoadMetricSpecification)

-- | The metric type.
predefinedLoadMetricSpecification_predefinedLoadMetricType :: Lens.Lens' PredefinedLoadMetricSpecification LoadMetricType
predefinedLoadMetricSpecification_predefinedLoadMetricType :: (LoadMetricType -> f LoadMetricType)
-> PredefinedLoadMetricSpecification
-> f PredefinedLoadMetricSpecification
predefinedLoadMetricSpecification_predefinedLoadMetricType = (PredefinedLoadMetricSpecification -> LoadMetricType)
-> (PredefinedLoadMetricSpecification
    -> LoadMetricType -> PredefinedLoadMetricSpecification)
-> Lens
     PredefinedLoadMetricSpecification
     PredefinedLoadMetricSpecification
     LoadMetricType
     LoadMetricType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredefinedLoadMetricSpecification' {LoadMetricType
predefinedLoadMetricType :: LoadMetricType
$sel:predefinedLoadMetricType:PredefinedLoadMetricSpecification' :: PredefinedLoadMetricSpecification -> LoadMetricType
predefinedLoadMetricType} -> LoadMetricType
predefinedLoadMetricType) (\s :: PredefinedLoadMetricSpecification
s@PredefinedLoadMetricSpecification' {} LoadMetricType
a -> PredefinedLoadMetricSpecification
s {$sel:predefinedLoadMetricType:PredefinedLoadMetricSpecification' :: LoadMetricType
predefinedLoadMetricType = LoadMetricType
a} :: PredefinedLoadMetricSpecification)

instance
  Core.FromJSON
    PredefinedLoadMetricSpecification
  where
  parseJSON :: Value -> Parser PredefinedLoadMetricSpecification
parseJSON =
    String
-> (Object -> Parser PredefinedLoadMetricSpecification)
-> Value
-> Parser PredefinedLoadMetricSpecification
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PredefinedLoadMetricSpecification"
      ( \Object
x ->
          Maybe Text -> LoadMetricType -> PredefinedLoadMetricSpecification
PredefinedLoadMetricSpecification'
            (Maybe Text -> LoadMetricType -> PredefinedLoadMetricSpecification)
-> Parser (Maybe Text)
-> Parser (LoadMetricType -> PredefinedLoadMetricSpecification)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResourceLabel")
            Parser (LoadMetricType -> PredefinedLoadMetricSpecification)
-> Parser LoadMetricType
-> Parser PredefinedLoadMetricSpecification
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser LoadMetricType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"PredefinedLoadMetricType")
      )

instance
  Prelude.Hashable
    PredefinedLoadMetricSpecification

instance
  Prelude.NFData
    PredefinedLoadMetricSpecification

instance
  Core.ToJSON
    PredefinedLoadMetricSpecification
  where
  toJSON :: PredefinedLoadMetricSpecification -> Value
toJSON PredefinedLoadMetricSpecification' {Maybe Text
LoadMetricType
predefinedLoadMetricType :: LoadMetricType
resourceLabel :: Maybe Text
$sel:predefinedLoadMetricType:PredefinedLoadMetricSpecification' :: PredefinedLoadMetricSpecification -> LoadMetricType
$sel:resourceLabel:PredefinedLoadMetricSpecification' :: PredefinedLoadMetricSpecification -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ResourceLabel" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
resourceLabel,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"PredefinedLoadMetricType"
                  Text -> LoadMetricType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= LoadMetricType
predefinedLoadMetricType
              )
          ]
      )