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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes an enabled metric.
--
-- /See:/ 'newEnabledMetric' smart constructor.
data EnabledMetric = EnabledMetric'
  { -- | The granularity of the metric. The only valid value is @1Minute@.
    EnabledMetric -> Maybe Text
granularity :: Prelude.Maybe Prelude.Text,
    -- | One of the following metrics:
    --
    -- -   @GroupMinSize@
    --
    -- -   @GroupMaxSize@
    --
    -- -   @GroupDesiredCapacity@
    --
    -- -   @GroupInServiceInstances@
    --
    -- -   @GroupPendingInstances@
    --
    -- -   @GroupStandbyInstances@
    --
    -- -   @GroupTerminatingInstances@
    --
    -- -   @GroupTotalInstances@
    --
    -- -   @GroupInServiceCapacity@
    --
    -- -   @GroupPendingCapacity@
    --
    -- -   @GroupStandbyCapacity@
    --
    -- -   @GroupTerminatingCapacity@
    --
    -- -   @GroupTotalCapacity@
    --
    -- -   @WarmPoolDesiredCapacity@
    --
    -- -   @WarmPoolWarmedCapacity@
    --
    -- -   @WarmPoolPendingCapacity@
    --
    -- -   @WarmPoolTerminatingCapacity@
    --
    -- -   @WarmPoolTotalCapacity@
    --
    -- -   @GroupAndWarmPoolDesiredCapacity@
    --
    -- -   @GroupAndWarmPoolTotalCapacity@
    EnabledMetric -> Maybe Text
metric :: Prelude.Maybe Prelude.Text
  }
  deriving (EnabledMetric -> EnabledMetric -> Bool
(EnabledMetric -> EnabledMetric -> Bool)
-> (EnabledMetric -> EnabledMetric -> Bool) -> Eq EnabledMetric
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnabledMetric -> EnabledMetric -> Bool
$c/= :: EnabledMetric -> EnabledMetric -> Bool
== :: EnabledMetric -> EnabledMetric -> Bool
$c== :: EnabledMetric -> EnabledMetric -> Bool
Prelude.Eq, ReadPrec [EnabledMetric]
ReadPrec EnabledMetric
Int -> ReadS EnabledMetric
ReadS [EnabledMetric]
(Int -> ReadS EnabledMetric)
-> ReadS [EnabledMetric]
-> ReadPrec EnabledMetric
-> ReadPrec [EnabledMetric]
-> Read EnabledMetric
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnabledMetric]
$creadListPrec :: ReadPrec [EnabledMetric]
readPrec :: ReadPrec EnabledMetric
$creadPrec :: ReadPrec EnabledMetric
readList :: ReadS [EnabledMetric]
$creadList :: ReadS [EnabledMetric]
readsPrec :: Int -> ReadS EnabledMetric
$creadsPrec :: Int -> ReadS EnabledMetric
Prelude.Read, Int -> EnabledMetric -> ShowS
[EnabledMetric] -> ShowS
EnabledMetric -> String
(Int -> EnabledMetric -> ShowS)
-> (EnabledMetric -> String)
-> ([EnabledMetric] -> ShowS)
-> Show EnabledMetric
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnabledMetric] -> ShowS
$cshowList :: [EnabledMetric] -> ShowS
show :: EnabledMetric -> String
$cshow :: EnabledMetric -> String
showsPrec :: Int -> EnabledMetric -> ShowS
$cshowsPrec :: Int -> EnabledMetric -> ShowS
Prelude.Show, (forall x. EnabledMetric -> Rep EnabledMetric x)
-> (forall x. Rep EnabledMetric x -> EnabledMetric)
-> Generic EnabledMetric
forall x. Rep EnabledMetric x -> EnabledMetric
forall x. EnabledMetric -> Rep EnabledMetric x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnabledMetric x -> EnabledMetric
$cfrom :: forall x. EnabledMetric -> Rep EnabledMetric x
Prelude.Generic)

-- |
-- Create a value of 'EnabledMetric' 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:
--
-- 'granularity', 'enabledMetric_granularity' - The granularity of the metric. The only valid value is @1Minute@.
--
-- 'metric', 'enabledMetric_metric' - One of the following metrics:
--
-- -   @GroupMinSize@
--
-- -   @GroupMaxSize@
--
-- -   @GroupDesiredCapacity@
--
-- -   @GroupInServiceInstances@
--
-- -   @GroupPendingInstances@
--
-- -   @GroupStandbyInstances@
--
-- -   @GroupTerminatingInstances@
--
-- -   @GroupTotalInstances@
--
-- -   @GroupInServiceCapacity@
--
-- -   @GroupPendingCapacity@
--
-- -   @GroupStandbyCapacity@
--
-- -   @GroupTerminatingCapacity@
--
-- -   @GroupTotalCapacity@
--
-- -   @WarmPoolDesiredCapacity@
--
-- -   @WarmPoolWarmedCapacity@
--
-- -   @WarmPoolPendingCapacity@
--
-- -   @WarmPoolTerminatingCapacity@
--
-- -   @WarmPoolTotalCapacity@
--
-- -   @GroupAndWarmPoolDesiredCapacity@
--
-- -   @GroupAndWarmPoolTotalCapacity@
newEnabledMetric ::
  EnabledMetric
newEnabledMetric :: EnabledMetric
newEnabledMetric =
  EnabledMetric' :: Maybe Text -> Maybe Text -> EnabledMetric
EnabledMetric'
    { $sel:granularity:EnabledMetric' :: Maybe Text
granularity = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:metric:EnabledMetric' :: Maybe Text
metric = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The granularity of the metric. The only valid value is @1Minute@.
enabledMetric_granularity :: Lens.Lens' EnabledMetric (Prelude.Maybe Prelude.Text)
enabledMetric_granularity :: (Maybe Text -> f (Maybe Text)) -> EnabledMetric -> f EnabledMetric
enabledMetric_granularity = (EnabledMetric -> Maybe Text)
-> (EnabledMetric -> Maybe Text -> EnabledMetric)
-> Lens EnabledMetric EnabledMetric (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnabledMetric' {Maybe Text
granularity :: Maybe Text
$sel:granularity:EnabledMetric' :: EnabledMetric -> Maybe Text
granularity} -> Maybe Text
granularity) (\s :: EnabledMetric
s@EnabledMetric' {} Maybe Text
a -> EnabledMetric
s {$sel:granularity:EnabledMetric' :: Maybe Text
granularity = Maybe Text
a} :: EnabledMetric)

-- | One of the following metrics:
--
-- -   @GroupMinSize@
--
-- -   @GroupMaxSize@
--
-- -   @GroupDesiredCapacity@
--
-- -   @GroupInServiceInstances@
--
-- -   @GroupPendingInstances@
--
-- -   @GroupStandbyInstances@
--
-- -   @GroupTerminatingInstances@
--
-- -   @GroupTotalInstances@
--
-- -   @GroupInServiceCapacity@
--
-- -   @GroupPendingCapacity@
--
-- -   @GroupStandbyCapacity@
--
-- -   @GroupTerminatingCapacity@
--
-- -   @GroupTotalCapacity@
--
-- -   @WarmPoolDesiredCapacity@
--
-- -   @WarmPoolWarmedCapacity@
--
-- -   @WarmPoolPendingCapacity@
--
-- -   @WarmPoolTerminatingCapacity@
--
-- -   @WarmPoolTotalCapacity@
--
-- -   @GroupAndWarmPoolDesiredCapacity@
--
-- -   @GroupAndWarmPoolTotalCapacity@
enabledMetric_metric :: Lens.Lens' EnabledMetric (Prelude.Maybe Prelude.Text)
enabledMetric_metric :: (Maybe Text -> f (Maybe Text)) -> EnabledMetric -> f EnabledMetric
enabledMetric_metric = (EnabledMetric -> Maybe Text)
-> (EnabledMetric -> Maybe Text -> EnabledMetric)
-> Lens EnabledMetric EnabledMetric (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnabledMetric' {Maybe Text
metric :: Maybe Text
$sel:metric:EnabledMetric' :: EnabledMetric -> Maybe Text
metric} -> Maybe Text
metric) (\s :: EnabledMetric
s@EnabledMetric' {} Maybe Text
a -> EnabledMetric
s {$sel:metric:EnabledMetric' :: Maybe Text
metric = Maybe Text
a} :: EnabledMetric)

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

instance Prelude.Hashable EnabledMetric

instance Prelude.NFData EnabledMetric