{-# 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.EMR.Types.CloudWatchAlarmDefinition
-- 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.EMR.Types.CloudWatchAlarmDefinition where

import qualified Amazonka.Core as Core
import Amazonka.EMR.Types.ComparisonOperator
import Amazonka.EMR.Types.MetricDimension
import Amazonka.EMR.Types.Statistic
import Amazonka.EMR.Types.Unit
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The definition of a CloudWatch metric alarm, which determines when an
-- automatic scaling activity is triggered. When the defined alarm
-- conditions are satisfied, scaling activity begins.
--
-- /See:/ 'newCloudWatchAlarmDefinition' smart constructor.
data CloudWatchAlarmDefinition = CloudWatchAlarmDefinition'
  { -- | The number of periods, in five-minute increments, during which the alarm
    -- condition must exist before the alarm triggers automatic scaling
    -- activity. The default value is @1@.
    CloudWatchAlarmDefinition -> Maybe Int
evaluationPeriods :: Prelude.Maybe Prelude.Int,
    -- | The namespace for the CloudWatch metric. The default is
    -- @AWS\/ElasticMapReduce@.
    CloudWatchAlarmDefinition -> Maybe Text
namespace :: Prelude.Maybe Prelude.Text,
    -- | A CloudWatch metric dimension.
    CloudWatchAlarmDefinition -> Maybe [MetricDimension]
dimensions :: Prelude.Maybe [MetricDimension],
    -- | The unit of measure associated with the CloudWatch metric being watched.
    -- The value specified for @Unit@ must correspond to the units specified in
    -- the CloudWatch metric.
    CloudWatchAlarmDefinition -> Maybe Unit
unit :: Prelude.Maybe Unit,
    -- | The statistic to apply to the metric associated with the alarm. The
    -- default is @AVERAGE@.
    CloudWatchAlarmDefinition -> Maybe Statistic
statistic :: Prelude.Maybe Statistic,
    -- | Determines how the metric specified by @MetricName@ is compared to the
    -- value specified by @Threshold@.
    CloudWatchAlarmDefinition -> ComparisonOperator
comparisonOperator :: ComparisonOperator,
    -- | The name of the CloudWatch metric that is watched to determine an alarm
    -- condition.
    CloudWatchAlarmDefinition -> Text
metricName :: Prelude.Text,
    -- | The period, in seconds, over which the statistic is applied. EMR
    -- CloudWatch metrics are emitted every five minutes (300 seconds), so if
    -- an EMR CloudWatch metric is specified, specify @300@.
    CloudWatchAlarmDefinition -> Int
period :: Prelude.Int,
    -- | The value against which the specified statistic is compared.
    CloudWatchAlarmDefinition -> Double
threshold :: Prelude.Double
  }
  deriving (CloudWatchAlarmDefinition -> CloudWatchAlarmDefinition -> Bool
(CloudWatchAlarmDefinition -> CloudWatchAlarmDefinition -> Bool)
-> (CloudWatchAlarmDefinition -> CloudWatchAlarmDefinition -> Bool)
-> Eq CloudWatchAlarmDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CloudWatchAlarmDefinition -> CloudWatchAlarmDefinition -> Bool
$c/= :: CloudWatchAlarmDefinition -> CloudWatchAlarmDefinition -> Bool
== :: CloudWatchAlarmDefinition -> CloudWatchAlarmDefinition -> Bool
$c== :: CloudWatchAlarmDefinition -> CloudWatchAlarmDefinition -> Bool
Prelude.Eq, ReadPrec [CloudWatchAlarmDefinition]
ReadPrec CloudWatchAlarmDefinition
Int -> ReadS CloudWatchAlarmDefinition
ReadS [CloudWatchAlarmDefinition]
(Int -> ReadS CloudWatchAlarmDefinition)
-> ReadS [CloudWatchAlarmDefinition]
-> ReadPrec CloudWatchAlarmDefinition
-> ReadPrec [CloudWatchAlarmDefinition]
-> Read CloudWatchAlarmDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CloudWatchAlarmDefinition]
$creadListPrec :: ReadPrec [CloudWatchAlarmDefinition]
readPrec :: ReadPrec CloudWatchAlarmDefinition
$creadPrec :: ReadPrec CloudWatchAlarmDefinition
readList :: ReadS [CloudWatchAlarmDefinition]
$creadList :: ReadS [CloudWatchAlarmDefinition]
readsPrec :: Int -> ReadS CloudWatchAlarmDefinition
$creadsPrec :: Int -> ReadS CloudWatchAlarmDefinition
Prelude.Read, Int -> CloudWatchAlarmDefinition -> ShowS
[CloudWatchAlarmDefinition] -> ShowS
CloudWatchAlarmDefinition -> String
(Int -> CloudWatchAlarmDefinition -> ShowS)
-> (CloudWatchAlarmDefinition -> String)
-> ([CloudWatchAlarmDefinition] -> ShowS)
-> Show CloudWatchAlarmDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CloudWatchAlarmDefinition] -> ShowS
$cshowList :: [CloudWatchAlarmDefinition] -> ShowS
show :: CloudWatchAlarmDefinition -> String
$cshow :: CloudWatchAlarmDefinition -> String
showsPrec :: Int -> CloudWatchAlarmDefinition -> ShowS
$cshowsPrec :: Int -> CloudWatchAlarmDefinition -> ShowS
Prelude.Show, (forall x.
 CloudWatchAlarmDefinition -> Rep CloudWatchAlarmDefinition x)
-> (forall x.
    Rep CloudWatchAlarmDefinition x -> CloudWatchAlarmDefinition)
-> Generic CloudWatchAlarmDefinition
forall x.
Rep CloudWatchAlarmDefinition x -> CloudWatchAlarmDefinition
forall x.
CloudWatchAlarmDefinition -> Rep CloudWatchAlarmDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CloudWatchAlarmDefinition x -> CloudWatchAlarmDefinition
$cfrom :: forall x.
CloudWatchAlarmDefinition -> Rep CloudWatchAlarmDefinition x
Prelude.Generic)

-- |
-- Create a value of 'CloudWatchAlarmDefinition' 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:
--
-- 'evaluationPeriods', 'cloudWatchAlarmDefinition_evaluationPeriods' - The number of periods, in five-minute increments, during which the alarm
-- condition must exist before the alarm triggers automatic scaling
-- activity. The default value is @1@.
--
-- 'namespace', 'cloudWatchAlarmDefinition_namespace' - The namespace for the CloudWatch metric. The default is
-- @AWS\/ElasticMapReduce@.
--
-- 'dimensions', 'cloudWatchAlarmDefinition_dimensions' - A CloudWatch metric dimension.
--
-- 'unit', 'cloudWatchAlarmDefinition_unit' - The unit of measure associated with the CloudWatch metric being watched.
-- The value specified for @Unit@ must correspond to the units specified in
-- the CloudWatch metric.
--
-- 'statistic', 'cloudWatchAlarmDefinition_statistic' - The statistic to apply to the metric associated with the alarm. The
-- default is @AVERAGE@.
--
-- 'comparisonOperator', 'cloudWatchAlarmDefinition_comparisonOperator' - Determines how the metric specified by @MetricName@ is compared to the
-- value specified by @Threshold@.
--
-- 'metricName', 'cloudWatchAlarmDefinition_metricName' - The name of the CloudWatch metric that is watched to determine an alarm
-- condition.
--
-- 'period', 'cloudWatchAlarmDefinition_period' - The period, in seconds, over which the statistic is applied. EMR
-- CloudWatch metrics are emitted every five minutes (300 seconds), so if
-- an EMR CloudWatch metric is specified, specify @300@.
--
-- 'threshold', 'cloudWatchAlarmDefinition_threshold' - The value against which the specified statistic is compared.
newCloudWatchAlarmDefinition ::
  -- | 'comparisonOperator'
  ComparisonOperator ->
  -- | 'metricName'
  Prelude.Text ->
  -- | 'period'
  Prelude.Int ->
  -- | 'threshold'
  Prelude.Double ->
  CloudWatchAlarmDefinition
newCloudWatchAlarmDefinition :: ComparisonOperator
-> Text -> Int -> Double -> CloudWatchAlarmDefinition
newCloudWatchAlarmDefinition
  ComparisonOperator
pComparisonOperator_
  Text
pMetricName_
  Int
pPeriod_
  Double
pThreshold_ =
    CloudWatchAlarmDefinition' :: Maybe Int
-> Maybe Text
-> Maybe [MetricDimension]
-> Maybe Unit
-> Maybe Statistic
-> ComparisonOperator
-> Text
-> Int
-> Double
-> CloudWatchAlarmDefinition
CloudWatchAlarmDefinition'
      { $sel:evaluationPeriods:CloudWatchAlarmDefinition' :: Maybe Int
evaluationPeriods =
          Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:namespace:CloudWatchAlarmDefinition' :: Maybe Text
namespace = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:dimensions:CloudWatchAlarmDefinition' :: Maybe [MetricDimension]
dimensions = Maybe [MetricDimension]
forall a. Maybe a
Prelude.Nothing,
        $sel:unit:CloudWatchAlarmDefinition' :: Maybe Unit
unit = Maybe Unit
forall a. Maybe a
Prelude.Nothing,
        $sel:statistic:CloudWatchAlarmDefinition' :: Maybe Statistic
statistic = Maybe Statistic
forall a. Maybe a
Prelude.Nothing,
        $sel:comparisonOperator:CloudWatchAlarmDefinition' :: ComparisonOperator
comparisonOperator = ComparisonOperator
pComparisonOperator_,
        $sel:metricName:CloudWatchAlarmDefinition' :: Text
metricName = Text
pMetricName_,
        $sel:period:CloudWatchAlarmDefinition' :: Int
period = Int
pPeriod_,
        $sel:threshold:CloudWatchAlarmDefinition' :: Double
threshold = Double
pThreshold_
      }

-- | The number of periods, in five-minute increments, during which the alarm
-- condition must exist before the alarm triggers automatic scaling
-- activity. The default value is @1@.
cloudWatchAlarmDefinition_evaluationPeriods :: Lens.Lens' CloudWatchAlarmDefinition (Prelude.Maybe Prelude.Int)
cloudWatchAlarmDefinition_evaluationPeriods :: (Maybe Int -> f (Maybe Int))
-> CloudWatchAlarmDefinition -> f CloudWatchAlarmDefinition
cloudWatchAlarmDefinition_evaluationPeriods = (CloudWatchAlarmDefinition -> Maybe Int)
-> (CloudWatchAlarmDefinition
    -> Maybe Int -> CloudWatchAlarmDefinition)
-> Lens
     CloudWatchAlarmDefinition
     CloudWatchAlarmDefinition
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchAlarmDefinition' {Maybe Int
evaluationPeriods :: Maybe Int
$sel:evaluationPeriods:CloudWatchAlarmDefinition' :: CloudWatchAlarmDefinition -> Maybe Int
evaluationPeriods} -> Maybe Int
evaluationPeriods) (\s :: CloudWatchAlarmDefinition
s@CloudWatchAlarmDefinition' {} Maybe Int
a -> CloudWatchAlarmDefinition
s {$sel:evaluationPeriods:CloudWatchAlarmDefinition' :: Maybe Int
evaluationPeriods = Maybe Int
a} :: CloudWatchAlarmDefinition)

-- | The namespace for the CloudWatch metric. The default is
-- @AWS\/ElasticMapReduce@.
cloudWatchAlarmDefinition_namespace :: Lens.Lens' CloudWatchAlarmDefinition (Prelude.Maybe Prelude.Text)
cloudWatchAlarmDefinition_namespace :: (Maybe Text -> f (Maybe Text))
-> CloudWatchAlarmDefinition -> f CloudWatchAlarmDefinition
cloudWatchAlarmDefinition_namespace = (CloudWatchAlarmDefinition -> Maybe Text)
-> (CloudWatchAlarmDefinition
    -> Maybe Text -> CloudWatchAlarmDefinition)
-> Lens
     CloudWatchAlarmDefinition
     CloudWatchAlarmDefinition
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchAlarmDefinition' {Maybe Text
namespace :: Maybe Text
$sel:namespace:CloudWatchAlarmDefinition' :: CloudWatchAlarmDefinition -> Maybe Text
namespace} -> Maybe Text
namespace) (\s :: CloudWatchAlarmDefinition
s@CloudWatchAlarmDefinition' {} Maybe Text
a -> CloudWatchAlarmDefinition
s {$sel:namespace:CloudWatchAlarmDefinition' :: Maybe Text
namespace = Maybe Text
a} :: CloudWatchAlarmDefinition)

-- | A CloudWatch metric dimension.
cloudWatchAlarmDefinition_dimensions :: Lens.Lens' CloudWatchAlarmDefinition (Prelude.Maybe [MetricDimension])
cloudWatchAlarmDefinition_dimensions :: (Maybe [MetricDimension] -> f (Maybe [MetricDimension]))
-> CloudWatchAlarmDefinition -> f CloudWatchAlarmDefinition
cloudWatchAlarmDefinition_dimensions = (CloudWatchAlarmDefinition -> Maybe [MetricDimension])
-> (CloudWatchAlarmDefinition
    -> Maybe [MetricDimension] -> CloudWatchAlarmDefinition)
-> Lens
     CloudWatchAlarmDefinition
     CloudWatchAlarmDefinition
     (Maybe [MetricDimension])
     (Maybe [MetricDimension])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchAlarmDefinition' {Maybe [MetricDimension]
dimensions :: Maybe [MetricDimension]
$sel:dimensions:CloudWatchAlarmDefinition' :: CloudWatchAlarmDefinition -> Maybe [MetricDimension]
dimensions} -> Maybe [MetricDimension]
dimensions) (\s :: CloudWatchAlarmDefinition
s@CloudWatchAlarmDefinition' {} Maybe [MetricDimension]
a -> CloudWatchAlarmDefinition
s {$sel:dimensions:CloudWatchAlarmDefinition' :: Maybe [MetricDimension]
dimensions = Maybe [MetricDimension]
a} :: CloudWatchAlarmDefinition) ((Maybe [MetricDimension] -> f (Maybe [MetricDimension]))
 -> CloudWatchAlarmDefinition -> f CloudWatchAlarmDefinition)
-> ((Maybe [MetricDimension] -> f (Maybe [MetricDimension]))
    -> Maybe [MetricDimension] -> f (Maybe [MetricDimension]))
-> (Maybe [MetricDimension] -> f (Maybe [MetricDimension]))
-> CloudWatchAlarmDefinition
-> f CloudWatchAlarmDefinition
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [MetricDimension]
  [MetricDimension]
  [MetricDimension]
  [MetricDimension]
-> Iso
     (Maybe [MetricDimension])
     (Maybe [MetricDimension])
     (Maybe [MetricDimension])
     (Maybe [MetricDimension])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [MetricDimension]
  [MetricDimension]
  [MetricDimension]
  [MetricDimension]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The unit of measure associated with the CloudWatch metric being watched.
-- The value specified for @Unit@ must correspond to the units specified in
-- the CloudWatch metric.
cloudWatchAlarmDefinition_unit :: Lens.Lens' CloudWatchAlarmDefinition (Prelude.Maybe Unit)
cloudWatchAlarmDefinition_unit :: (Maybe Unit -> f (Maybe Unit))
-> CloudWatchAlarmDefinition -> f CloudWatchAlarmDefinition
cloudWatchAlarmDefinition_unit = (CloudWatchAlarmDefinition -> Maybe Unit)
-> (CloudWatchAlarmDefinition
    -> Maybe Unit -> CloudWatchAlarmDefinition)
-> Lens
     CloudWatchAlarmDefinition
     CloudWatchAlarmDefinition
     (Maybe Unit)
     (Maybe Unit)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchAlarmDefinition' {Maybe Unit
unit :: Maybe Unit
$sel:unit:CloudWatchAlarmDefinition' :: CloudWatchAlarmDefinition -> Maybe Unit
unit} -> Maybe Unit
unit) (\s :: CloudWatchAlarmDefinition
s@CloudWatchAlarmDefinition' {} Maybe Unit
a -> CloudWatchAlarmDefinition
s {$sel:unit:CloudWatchAlarmDefinition' :: Maybe Unit
unit = Maybe Unit
a} :: CloudWatchAlarmDefinition)

-- | The statistic to apply to the metric associated with the alarm. The
-- default is @AVERAGE@.
cloudWatchAlarmDefinition_statistic :: Lens.Lens' CloudWatchAlarmDefinition (Prelude.Maybe Statistic)
cloudWatchAlarmDefinition_statistic :: (Maybe Statistic -> f (Maybe Statistic))
-> CloudWatchAlarmDefinition -> f CloudWatchAlarmDefinition
cloudWatchAlarmDefinition_statistic = (CloudWatchAlarmDefinition -> Maybe Statistic)
-> (CloudWatchAlarmDefinition
    -> Maybe Statistic -> CloudWatchAlarmDefinition)
-> Lens
     CloudWatchAlarmDefinition
     CloudWatchAlarmDefinition
     (Maybe Statistic)
     (Maybe Statistic)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchAlarmDefinition' {Maybe Statistic
statistic :: Maybe Statistic
$sel:statistic:CloudWatchAlarmDefinition' :: CloudWatchAlarmDefinition -> Maybe Statistic
statistic} -> Maybe Statistic
statistic) (\s :: CloudWatchAlarmDefinition
s@CloudWatchAlarmDefinition' {} Maybe Statistic
a -> CloudWatchAlarmDefinition
s {$sel:statistic:CloudWatchAlarmDefinition' :: Maybe Statistic
statistic = Maybe Statistic
a} :: CloudWatchAlarmDefinition)

-- | Determines how the metric specified by @MetricName@ is compared to the
-- value specified by @Threshold@.
cloudWatchAlarmDefinition_comparisonOperator :: Lens.Lens' CloudWatchAlarmDefinition ComparisonOperator
cloudWatchAlarmDefinition_comparisonOperator :: (ComparisonOperator -> f ComparisonOperator)
-> CloudWatchAlarmDefinition -> f CloudWatchAlarmDefinition
cloudWatchAlarmDefinition_comparisonOperator = (CloudWatchAlarmDefinition -> ComparisonOperator)
-> (CloudWatchAlarmDefinition
    -> ComparisonOperator -> CloudWatchAlarmDefinition)
-> Lens
     CloudWatchAlarmDefinition
     CloudWatchAlarmDefinition
     ComparisonOperator
     ComparisonOperator
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchAlarmDefinition' {ComparisonOperator
comparisonOperator :: ComparisonOperator
$sel:comparisonOperator:CloudWatchAlarmDefinition' :: CloudWatchAlarmDefinition -> ComparisonOperator
comparisonOperator} -> ComparisonOperator
comparisonOperator) (\s :: CloudWatchAlarmDefinition
s@CloudWatchAlarmDefinition' {} ComparisonOperator
a -> CloudWatchAlarmDefinition
s {$sel:comparisonOperator:CloudWatchAlarmDefinition' :: ComparisonOperator
comparisonOperator = ComparisonOperator
a} :: CloudWatchAlarmDefinition)

-- | The name of the CloudWatch metric that is watched to determine an alarm
-- condition.
cloudWatchAlarmDefinition_metricName :: Lens.Lens' CloudWatchAlarmDefinition Prelude.Text
cloudWatchAlarmDefinition_metricName :: (Text -> f Text)
-> CloudWatchAlarmDefinition -> f CloudWatchAlarmDefinition
cloudWatchAlarmDefinition_metricName = (CloudWatchAlarmDefinition -> Text)
-> (CloudWatchAlarmDefinition -> Text -> CloudWatchAlarmDefinition)
-> Lens
     CloudWatchAlarmDefinition CloudWatchAlarmDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchAlarmDefinition' {Text
metricName :: Text
$sel:metricName:CloudWatchAlarmDefinition' :: CloudWatchAlarmDefinition -> Text
metricName} -> Text
metricName) (\s :: CloudWatchAlarmDefinition
s@CloudWatchAlarmDefinition' {} Text
a -> CloudWatchAlarmDefinition
s {$sel:metricName:CloudWatchAlarmDefinition' :: Text
metricName = Text
a} :: CloudWatchAlarmDefinition)

-- | The period, in seconds, over which the statistic is applied. EMR
-- CloudWatch metrics are emitted every five minutes (300 seconds), so if
-- an EMR CloudWatch metric is specified, specify @300@.
cloudWatchAlarmDefinition_period :: Lens.Lens' CloudWatchAlarmDefinition Prelude.Int
cloudWatchAlarmDefinition_period :: (Int -> f Int)
-> CloudWatchAlarmDefinition -> f CloudWatchAlarmDefinition
cloudWatchAlarmDefinition_period = (CloudWatchAlarmDefinition -> Int)
-> (CloudWatchAlarmDefinition -> Int -> CloudWatchAlarmDefinition)
-> Lens CloudWatchAlarmDefinition CloudWatchAlarmDefinition Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchAlarmDefinition' {Int
period :: Int
$sel:period:CloudWatchAlarmDefinition' :: CloudWatchAlarmDefinition -> Int
period} -> Int
period) (\s :: CloudWatchAlarmDefinition
s@CloudWatchAlarmDefinition' {} Int
a -> CloudWatchAlarmDefinition
s {$sel:period:CloudWatchAlarmDefinition' :: Int
period = Int
a} :: CloudWatchAlarmDefinition)

-- | The value against which the specified statistic is compared.
cloudWatchAlarmDefinition_threshold :: Lens.Lens' CloudWatchAlarmDefinition Prelude.Double
cloudWatchAlarmDefinition_threshold :: (Double -> f Double)
-> CloudWatchAlarmDefinition -> f CloudWatchAlarmDefinition
cloudWatchAlarmDefinition_threshold = (CloudWatchAlarmDefinition -> Double)
-> (CloudWatchAlarmDefinition
    -> Double -> CloudWatchAlarmDefinition)
-> Lens
     CloudWatchAlarmDefinition CloudWatchAlarmDefinition Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchAlarmDefinition' {Double
threshold :: Double
$sel:threshold:CloudWatchAlarmDefinition' :: CloudWatchAlarmDefinition -> Double
threshold} -> Double
threshold) (\s :: CloudWatchAlarmDefinition
s@CloudWatchAlarmDefinition' {} Double
a -> CloudWatchAlarmDefinition
s {$sel:threshold:CloudWatchAlarmDefinition' :: Double
threshold = Double
a} :: CloudWatchAlarmDefinition)

instance Core.FromJSON CloudWatchAlarmDefinition where
  parseJSON :: Value -> Parser CloudWatchAlarmDefinition
parseJSON =
    String
-> (Object -> Parser CloudWatchAlarmDefinition)
-> Value
-> Parser CloudWatchAlarmDefinition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CloudWatchAlarmDefinition"
      ( \Object
x ->
          Maybe Int
-> Maybe Text
-> Maybe [MetricDimension]
-> Maybe Unit
-> Maybe Statistic
-> ComparisonOperator
-> Text
-> Int
-> Double
-> CloudWatchAlarmDefinition
CloudWatchAlarmDefinition'
            (Maybe Int
 -> Maybe Text
 -> Maybe [MetricDimension]
 -> Maybe Unit
 -> Maybe Statistic
 -> ComparisonOperator
 -> Text
 -> Int
 -> Double
 -> CloudWatchAlarmDefinition)
-> Parser (Maybe Int)
-> Parser
     (Maybe Text
      -> Maybe [MetricDimension]
      -> Maybe Unit
      -> Maybe Statistic
      -> ComparisonOperator
      -> Text
      -> Int
      -> Double
      -> CloudWatchAlarmDefinition)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EvaluationPeriods")
            Parser
  (Maybe Text
   -> Maybe [MetricDimension]
   -> Maybe Unit
   -> Maybe Statistic
   -> ComparisonOperator
   -> Text
   -> Int
   -> Double
   -> CloudWatchAlarmDefinition)
-> Parser (Maybe Text)
-> Parser
     (Maybe [MetricDimension]
      -> Maybe Unit
      -> Maybe Statistic
      -> ComparisonOperator
      -> Text
      -> Int
      -> Double
      -> CloudWatchAlarmDefinition)
forall (f :: * -> *) a b. Applicative f => 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
"Namespace")
            Parser
  (Maybe [MetricDimension]
   -> Maybe Unit
   -> Maybe Statistic
   -> ComparisonOperator
   -> Text
   -> Int
   -> Double
   -> CloudWatchAlarmDefinition)
-> Parser (Maybe [MetricDimension])
-> Parser
     (Maybe Unit
      -> Maybe Statistic
      -> ComparisonOperator
      -> Text
      -> Int
      -> Double
      -> CloudWatchAlarmDefinition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [MetricDimension]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Dimensions" Parser (Maybe (Maybe [MetricDimension]))
-> Maybe [MetricDimension] -> Parser (Maybe [MetricDimension])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [MetricDimension]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Unit
   -> Maybe Statistic
   -> ComparisonOperator
   -> Text
   -> Int
   -> Double
   -> CloudWatchAlarmDefinition)
-> Parser (Maybe Unit)
-> Parser
     (Maybe Statistic
      -> ComparisonOperator
      -> Text
      -> Int
      -> Double
      -> CloudWatchAlarmDefinition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Unit)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Unit")
            Parser
  (Maybe Statistic
   -> ComparisonOperator
   -> Text
   -> Int
   -> Double
   -> CloudWatchAlarmDefinition)
-> Parser (Maybe Statistic)
-> Parser
     (ComparisonOperator
      -> Text -> Int -> Double -> CloudWatchAlarmDefinition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Statistic)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Statistic")
            Parser
  (ComparisonOperator
   -> Text -> Int -> Double -> CloudWatchAlarmDefinition)
-> Parser ComparisonOperator
-> Parser (Text -> Int -> Double -> CloudWatchAlarmDefinition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ComparisonOperator
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ComparisonOperator")
            Parser (Text -> Int -> Double -> CloudWatchAlarmDefinition)
-> Parser Text
-> Parser (Int -> Double -> CloudWatchAlarmDefinition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MetricName")
            Parser (Int -> Double -> CloudWatchAlarmDefinition)
-> Parser Int -> Parser (Double -> CloudWatchAlarmDefinition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Period")
            Parser (Double -> CloudWatchAlarmDefinition)
-> Parser Double -> Parser CloudWatchAlarmDefinition
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Threshold")
      )

instance Prelude.Hashable CloudWatchAlarmDefinition

instance Prelude.NFData CloudWatchAlarmDefinition

instance Core.ToJSON CloudWatchAlarmDefinition where
  toJSON :: CloudWatchAlarmDefinition -> Value
toJSON CloudWatchAlarmDefinition' {Double
Int
Maybe Int
Maybe [MetricDimension]
Maybe Text
Maybe Statistic
Maybe Unit
Text
ComparisonOperator
threshold :: Double
period :: Int
metricName :: Text
comparisonOperator :: ComparisonOperator
statistic :: Maybe Statistic
unit :: Maybe Unit
dimensions :: Maybe [MetricDimension]
namespace :: Maybe Text
evaluationPeriods :: Maybe Int
$sel:threshold:CloudWatchAlarmDefinition' :: CloudWatchAlarmDefinition -> Double
$sel:period:CloudWatchAlarmDefinition' :: CloudWatchAlarmDefinition -> Int
$sel:metricName:CloudWatchAlarmDefinition' :: CloudWatchAlarmDefinition -> Text
$sel:comparisonOperator:CloudWatchAlarmDefinition' :: CloudWatchAlarmDefinition -> ComparisonOperator
$sel:statistic:CloudWatchAlarmDefinition' :: CloudWatchAlarmDefinition -> Maybe Statistic
$sel:unit:CloudWatchAlarmDefinition' :: CloudWatchAlarmDefinition -> Maybe Unit
$sel:dimensions:CloudWatchAlarmDefinition' :: CloudWatchAlarmDefinition -> Maybe [MetricDimension]
$sel:namespace:CloudWatchAlarmDefinition' :: CloudWatchAlarmDefinition -> Maybe Text
$sel:evaluationPeriods:CloudWatchAlarmDefinition' :: CloudWatchAlarmDefinition -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EvaluationPeriods" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
evaluationPeriods,
            (Text
"Namespace" 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
namespace,
            (Text
"Dimensions" Text -> [MetricDimension] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([MetricDimension] -> Pair)
-> Maybe [MetricDimension] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [MetricDimension]
dimensions,
            (Text
"Unit" Text -> Unit -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Unit -> Pair) -> Maybe Unit -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Unit
unit,
            (Text
"Statistic" Text -> Statistic -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Statistic -> Pair) -> Maybe Statistic -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Statistic
statistic,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ComparisonOperator" Text -> ComparisonOperator -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ComparisonOperator
comparisonOperator),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"MetricName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
metricName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Period" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Int
period),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Threshold" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
threshold)
          ]
      )