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

import Amazonka.AutoScaling.Types.Metric
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

-- | This structure defines the CloudWatch metric to return, along with the
-- statistic, period, and unit.
--
-- For more information about the CloudWatch terminology below, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html Amazon CloudWatch concepts>
-- in the /Amazon CloudWatch User Guide/.
--
-- /See:/ 'newTargetTrackingMetricStat' smart constructor.
data TargetTrackingMetricStat = TargetTrackingMetricStat'
  { -- | The unit to use for the returned data points. For a complete list of the
    -- units that CloudWatch supports, see the
    -- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html MetricDatum>
    -- data type in the /Amazon CloudWatch API Reference/.
    TargetTrackingMetricStat -> Maybe Text
unit :: Prelude.Maybe Prelude.Text,
    TargetTrackingMetricStat -> Metric
metric :: Metric,
    -- | The statistic to return. It can include any CloudWatch statistic or
    -- extended statistic. For a list of valid values, see the table in
    -- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Statistic Statistics>
    -- in the /Amazon CloudWatch User Guide/.
    --
    -- The most commonly used metrics for scaling is @Average@
    TargetTrackingMetricStat -> Text
stat :: Prelude.Text
  }
  deriving (TargetTrackingMetricStat -> TargetTrackingMetricStat -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TargetTrackingMetricStat -> TargetTrackingMetricStat -> Bool
$c/= :: TargetTrackingMetricStat -> TargetTrackingMetricStat -> Bool
== :: TargetTrackingMetricStat -> TargetTrackingMetricStat -> Bool
$c== :: TargetTrackingMetricStat -> TargetTrackingMetricStat -> Bool
Prelude.Eq, ReadPrec [TargetTrackingMetricStat]
ReadPrec TargetTrackingMetricStat
Int -> ReadS TargetTrackingMetricStat
ReadS [TargetTrackingMetricStat]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TargetTrackingMetricStat]
$creadListPrec :: ReadPrec [TargetTrackingMetricStat]
readPrec :: ReadPrec TargetTrackingMetricStat
$creadPrec :: ReadPrec TargetTrackingMetricStat
readList :: ReadS [TargetTrackingMetricStat]
$creadList :: ReadS [TargetTrackingMetricStat]
readsPrec :: Int -> ReadS TargetTrackingMetricStat
$creadsPrec :: Int -> ReadS TargetTrackingMetricStat
Prelude.Read, Int -> TargetTrackingMetricStat -> ShowS
[TargetTrackingMetricStat] -> ShowS
TargetTrackingMetricStat -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TargetTrackingMetricStat] -> ShowS
$cshowList :: [TargetTrackingMetricStat] -> ShowS
show :: TargetTrackingMetricStat -> String
$cshow :: TargetTrackingMetricStat -> String
showsPrec :: Int -> TargetTrackingMetricStat -> ShowS
$cshowsPrec :: Int -> TargetTrackingMetricStat -> ShowS
Prelude.Show, forall x.
Rep TargetTrackingMetricStat x -> TargetTrackingMetricStat
forall x.
TargetTrackingMetricStat -> Rep TargetTrackingMetricStat x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TargetTrackingMetricStat x -> TargetTrackingMetricStat
$cfrom :: forall x.
TargetTrackingMetricStat -> Rep TargetTrackingMetricStat x
Prelude.Generic)

-- |
-- Create a value of 'TargetTrackingMetricStat' 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:
--
-- 'unit', 'targetTrackingMetricStat_unit' - The unit to use for the returned data points. For a complete list of the
-- units that CloudWatch supports, see the
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html MetricDatum>
-- data type in the /Amazon CloudWatch API Reference/.
--
-- 'metric', 'targetTrackingMetricStat_metric' - Undocumented member.
--
-- 'stat', 'targetTrackingMetricStat_stat' - The statistic to return. It can include any CloudWatch statistic or
-- extended statistic. For a list of valid values, see the table in
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Statistic Statistics>
-- in the /Amazon CloudWatch User Guide/.
--
-- The most commonly used metrics for scaling is @Average@
newTargetTrackingMetricStat ::
  -- | 'metric'
  Metric ->
  -- | 'stat'
  Prelude.Text ->
  TargetTrackingMetricStat
newTargetTrackingMetricStat :: Metric -> Text -> TargetTrackingMetricStat
newTargetTrackingMetricStat Metric
pMetric_ Text
pStat_ =
  TargetTrackingMetricStat'
    { $sel:unit:TargetTrackingMetricStat' :: Maybe Text
unit = forall a. Maybe a
Prelude.Nothing,
      $sel:metric:TargetTrackingMetricStat' :: Metric
metric = Metric
pMetric_,
      $sel:stat:TargetTrackingMetricStat' :: Text
stat = Text
pStat_
    }

-- | The unit to use for the returned data points. For a complete list of the
-- units that CloudWatch supports, see the
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html MetricDatum>
-- data type in the /Amazon CloudWatch API Reference/.
targetTrackingMetricStat_unit :: Lens.Lens' TargetTrackingMetricStat (Prelude.Maybe Prelude.Text)
targetTrackingMetricStat_unit :: Lens' TargetTrackingMetricStat (Maybe Text)
targetTrackingMetricStat_unit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetTrackingMetricStat' {Maybe Text
unit :: Maybe Text
$sel:unit:TargetTrackingMetricStat' :: TargetTrackingMetricStat -> Maybe Text
unit} -> Maybe Text
unit) (\s :: TargetTrackingMetricStat
s@TargetTrackingMetricStat' {} Maybe Text
a -> TargetTrackingMetricStat
s {$sel:unit:TargetTrackingMetricStat' :: Maybe Text
unit = Maybe Text
a} :: TargetTrackingMetricStat)

-- | Undocumented member.
targetTrackingMetricStat_metric :: Lens.Lens' TargetTrackingMetricStat Metric
targetTrackingMetricStat_metric :: Lens' TargetTrackingMetricStat Metric
targetTrackingMetricStat_metric = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetTrackingMetricStat' {Metric
metric :: Metric
$sel:metric:TargetTrackingMetricStat' :: TargetTrackingMetricStat -> Metric
metric} -> Metric
metric) (\s :: TargetTrackingMetricStat
s@TargetTrackingMetricStat' {} Metric
a -> TargetTrackingMetricStat
s {$sel:metric:TargetTrackingMetricStat' :: Metric
metric = Metric
a} :: TargetTrackingMetricStat)

-- | The statistic to return. It can include any CloudWatch statistic or
-- extended statistic. For a list of valid values, see the table in
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Statistic Statistics>
-- in the /Amazon CloudWatch User Guide/.
--
-- The most commonly used metrics for scaling is @Average@
targetTrackingMetricStat_stat :: Lens.Lens' TargetTrackingMetricStat Prelude.Text
targetTrackingMetricStat_stat :: Lens' TargetTrackingMetricStat Text
targetTrackingMetricStat_stat = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetTrackingMetricStat' {Text
stat :: Text
$sel:stat:TargetTrackingMetricStat' :: TargetTrackingMetricStat -> Text
stat} -> Text
stat) (\s :: TargetTrackingMetricStat
s@TargetTrackingMetricStat' {} Text
a -> TargetTrackingMetricStat
s {$sel:stat:TargetTrackingMetricStat' :: Text
stat = Text
a} :: TargetTrackingMetricStat)

instance Data.FromXML TargetTrackingMetricStat where
  parseXML :: [Node] -> Either String TargetTrackingMetricStat
parseXML [Node]
x =
    Maybe Text -> Metric -> Text -> TargetTrackingMetricStat
TargetTrackingMetricStat'
      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
"Unit")
      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
"Metric")
      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
"Stat")

instance Prelude.Hashable TargetTrackingMetricStat where
  hashWithSalt :: Int -> TargetTrackingMetricStat -> Int
hashWithSalt Int
_salt TargetTrackingMetricStat' {Maybe Text
Text
Metric
stat :: Text
metric :: Metric
unit :: Maybe Text
$sel:stat:TargetTrackingMetricStat' :: TargetTrackingMetricStat -> Text
$sel:metric:TargetTrackingMetricStat' :: TargetTrackingMetricStat -> Metric
$sel:unit:TargetTrackingMetricStat' :: TargetTrackingMetricStat -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
unit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Metric
metric
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
stat

instance Prelude.NFData TargetTrackingMetricStat where
  rnf :: TargetTrackingMetricStat -> ()
rnf TargetTrackingMetricStat' {Maybe Text
Text
Metric
stat :: Text
metric :: Metric
unit :: Maybe Text
$sel:stat:TargetTrackingMetricStat' :: TargetTrackingMetricStat -> Text
$sel:metric:TargetTrackingMetricStat' :: TargetTrackingMetricStat -> Metric
$sel:unit:TargetTrackingMetricStat' :: TargetTrackingMetricStat -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
unit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Metric
metric
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
stat

instance Data.ToQuery TargetTrackingMetricStat where
  toQuery :: TargetTrackingMetricStat -> QueryString
toQuery TargetTrackingMetricStat' {Maybe Text
Text
Metric
stat :: Text
metric :: Metric
unit :: Maybe Text
$sel:stat:TargetTrackingMetricStat' :: TargetTrackingMetricStat -> Text
$sel:metric:TargetTrackingMetricStat' :: TargetTrackingMetricStat -> Metric
$sel:unit:TargetTrackingMetricStat' :: TargetTrackingMetricStat -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Unit" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
unit,
        ByteString
"Metric" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Metric
metric,
        ByteString
"Stat" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
stat
      ]