{-# 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.IoT.Types.BehaviorCriteria
-- 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.IoT.Types.BehaviorCriteria where

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.ComparisonOperator
import Amazonka.IoT.Types.MachineLearningDetectionConfig
import Amazonka.IoT.Types.MetricValue
import Amazonka.IoT.Types.StatisticalThreshold
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The criteria by which the behavior is determined to be normal.
--
-- /See:/ 'newBehaviorCriteria' smart constructor.
data BehaviorCriteria = BehaviorCriteria'
  { -- | The configuration of an ML Detect
    BehaviorCriteria -> Maybe MachineLearningDetectionConfig
mlDetectionConfig :: Prelude.Maybe MachineLearningDetectionConfig,
    -- | The value to be compared with the @metric@.
    BehaviorCriteria -> Maybe MetricValue
value :: Prelude.Maybe MetricValue,
    -- | If a device is in violation of the behavior for the specified number of
    -- consecutive datapoints, an alarm occurs. If not specified, the default
    -- is 1.
    BehaviorCriteria -> Maybe Natural
consecutiveDatapointsToAlarm :: Prelude.Maybe Prelude.Natural,
    -- | The operator that relates the thing measured (@metric@) to the criteria
    -- (containing a @value@ or @statisticalThreshold@). Valid operators
    -- include:
    --
    -- -   @string-list@: @in-set@ and @not-in-set@
    --
    -- -   @number-list@: @in-set@ and @not-in-set@
    --
    -- -   @ip-address-list@: @in-cidr-set@ and @not-in-cidr-set@
    --
    -- -   @number@: @less-than@, @less-than-equals@, @greater-than@, and
    --     @greater-than-equals@
    BehaviorCriteria -> Maybe ComparisonOperator
comparisonOperator :: Prelude.Maybe ComparisonOperator,
    -- | A statistical ranking (percentile)that indicates a threshold value by
    -- which a behavior is determined to be in compliance or in violation of
    -- the behavior.
    BehaviorCriteria -> Maybe StatisticalThreshold
statisticalThreshold :: Prelude.Maybe StatisticalThreshold,
    -- | Use this to specify the time duration over which the behavior is
    -- evaluated, for those criteria that have a time dimension (for example,
    -- @NUM_MESSAGES_SENT@). For a @statisticalThreshhold@ metric comparison,
    -- measurements from all devices are accumulated over this time duration
    -- before being used to calculate percentiles, and later, measurements from
    -- an individual device are also accumulated over this time duration before
    -- being given a percentile rank. Cannot be used with list-based metric
    -- datatypes.
    BehaviorCriteria -> Maybe Int
durationSeconds :: Prelude.Maybe Prelude.Int,
    -- | If an alarm has occurred and the offending device is no longer in
    -- violation of the behavior for the specified number of consecutive
    -- datapoints, the alarm is cleared. If not specified, the default is 1.
    BehaviorCriteria -> Maybe Natural
consecutiveDatapointsToClear :: Prelude.Maybe Prelude.Natural
  }
  deriving (BehaviorCriteria -> BehaviorCriteria -> Bool
(BehaviorCriteria -> BehaviorCriteria -> Bool)
-> (BehaviorCriteria -> BehaviorCriteria -> Bool)
-> Eq BehaviorCriteria
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BehaviorCriteria -> BehaviorCriteria -> Bool
$c/= :: BehaviorCriteria -> BehaviorCriteria -> Bool
== :: BehaviorCriteria -> BehaviorCriteria -> Bool
$c== :: BehaviorCriteria -> BehaviorCriteria -> Bool
Prelude.Eq, ReadPrec [BehaviorCriteria]
ReadPrec BehaviorCriteria
Int -> ReadS BehaviorCriteria
ReadS [BehaviorCriteria]
(Int -> ReadS BehaviorCriteria)
-> ReadS [BehaviorCriteria]
-> ReadPrec BehaviorCriteria
-> ReadPrec [BehaviorCriteria]
-> Read BehaviorCriteria
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BehaviorCriteria]
$creadListPrec :: ReadPrec [BehaviorCriteria]
readPrec :: ReadPrec BehaviorCriteria
$creadPrec :: ReadPrec BehaviorCriteria
readList :: ReadS [BehaviorCriteria]
$creadList :: ReadS [BehaviorCriteria]
readsPrec :: Int -> ReadS BehaviorCriteria
$creadsPrec :: Int -> ReadS BehaviorCriteria
Prelude.Read, Int -> BehaviorCriteria -> ShowS
[BehaviorCriteria] -> ShowS
BehaviorCriteria -> String
(Int -> BehaviorCriteria -> ShowS)
-> (BehaviorCriteria -> String)
-> ([BehaviorCriteria] -> ShowS)
-> Show BehaviorCriteria
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BehaviorCriteria] -> ShowS
$cshowList :: [BehaviorCriteria] -> ShowS
show :: BehaviorCriteria -> String
$cshow :: BehaviorCriteria -> String
showsPrec :: Int -> BehaviorCriteria -> ShowS
$cshowsPrec :: Int -> BehaviorCriteria -> ShowS
Prelude.Show, (forall x. BehaviorCriteria -> Rep BehaviorCriteria x)
-> (forall x. Rep BehaviorCriteria x -> BehaviorCriteria)
-> Generic BehaviorCriteria
forall x. Rep BehaviorCriteria x -> BehaviorCriteria
forall x. BehaviorCriteria -> Rep BehaviorCriteria x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BehaviorCriteria x -> BehaviorCriteria
$cfrom :: forall x. BehaviorCriteria -> Rep BehaviorCriteria x
Prelude.Generic)

-- |
-- Create a value of 'BehaviorCriteria' 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:
--
-- 'mlDetectionConfig', 'behaviorCriteria_mlDetectionConfig' - The configuration of an ML Detect
--
-- 'value', 'behaviorCriteria_value' - The value to be compared with the @metric@.
--
-- 'consecutiveDatapointsToAlarm', 'behaviorCriteria_consecutiveDatapointsToAlarm' - If a device is in violation of the behavior for the specified number of
-- consecutive datapoints, an alarm occurs. If not specified, the default
-- is 1.
--
-- 'comparisonOperator', 'behaviorCriteria_comparisonOperator' - The operator that relates the thing measured (@metric@) to the criteria
-- (containing a @value@ or @statisticalThreshold@). Valid operators
-- include:
--
-- -   @string-list@: @in-set@ and @not-in-set@
--
-- -   @number-list@: @in-set@ and @not-in-set@
--
-- -   @ip-address-list@: @in-cidr-set@ and @not-in-cidr-set@
--
-- -   @number@: @less-than@, @less-than-equals@, @greater-than@, and
--     @greater-than-equals@
--
-- 'statisticalThreshold', 'behaviorCriteria_statisticalThreshold' - A statistical ranking (percentile)that indicates a threshold value by
-- which a behavior is determined to be in compliance or in violation of
-- the behavior.
--
-- 'durationSeconds', 'behaviorCriteria_durationSeconds' - Use this to specify the time duration over which the behavior is
-- evaluated, for those criteria that have a time dimension (for example,
-- @NUM_MESSAGES_SENT@). For a @statisticalThreshhold@ metric comparison,
-- measurements from all devices are accumulated over this time duration
-- before being used to calculate percentiles, and later, measurements from
-- an individual device are also accumulated over this time duration before
-- being given a percentile rank. Cannot be used with list-based metric
-- datatypes.
--
-- 'consecutiveDatapointsToClear', 'behaviorCriteria_consecutiveDatapointsToClear' - If an alarm has occurred and the offending device is no longer in
-- violation of the behavior for the specified number of consecutive
-- datapoints, the alarm is cleared. If not specified, the default is 1.
newBehaviorCriteria ::
  BehaviorCriteria
newBehaviorCriteria :: BehaviorCriteria
newBehaviorCriteria =
  BehaviorCriteria' :: Maybe MachineLearningDetectionConfig
-> Maybe MetricValue
-> Maybe Natural
-> Maybe ComparisonOperator
-> Maybe StatisticalThreshold
-> Maybe Int
-> Maybe Natural
-> BehaviorCriteria
BehaviorCriteria'
    { $sel:mlDetectionConfig:BehaviorCriteria' :: Maybe MachineLearningDetectionConfig
mlDetectionConfig =
        Maybe MachineLearningDetectionConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:value:BehaviorCriteria' :: Maybe MetricValue
value = Maybe MetricValue
forall a. Maybe a
Prelude.Nothing,
      $sel:consecutiveDatapointsToAlarm:BehaviorCriteria' :: Maybe Natural
consecutiveDatapointsToAlarm = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:comparisonOperator:BehaviorCriteria' :: Maybe ComparisonOperator
comparisonOperator = Maybe ComparisonOperator
forall a. Maybe a
Prelude.Nothing,
      $sel:statisticalThreshold:BehaviorCriteria' :: Maybe StatisticalThreshold
statisticalThreshold = Maybe StatisticalThreshold
forall a. Maybe a
Prelude.Nothing,
      $sel:durationSeconds:BehaviorCriteria' :: Maybe Int
durationSeconds = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:consecutiveDatapointsToClear:BehaviorCriteria' :: Maybe Natural
consecutiveDatapointsToClear = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The configuration of an ML Detect
behaviorCriteria_mlDetectionConfig :: Lens.Lens' BehaviorCriteria (Prelude.Maybe MachineLearningDetectionConfig)
behaviorCriteria_mlDetectionConfig :: (Maybe MachineLearningDetectionConfig
 -> f (Maybe MachineLearningDetectionConfig))
-> BehaviorCriteria -> f BehaviorCriteria
behaviorCriteria_mlDetectionConfig = (BehaviorCriteria -> Maybe MachineLearningDetectionConfig)
-> (BehaviorCriteria
    -> Maybe MachineLearningDetectionConfig -> BehaviorCriteria)
-> Lens
     BehaviorCriteria
     BehaviorCriteria
     (Maybe MachineLearningDetectionConfig)
     (Maybe MachineLearningDetectionConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BehaviorCriteria' {Maybe MachineLearningDetectionConfig
mlDetectionConfig :: Maybe MachineLearningDetectionConfig
$sel:mlDetectionConfig:BehaviorCriteria' :: BehaviorCriteria -> Maybe MachineLearningDetectionConfig
mlDetectionConfig} -> Maybe MachineLearningDetectionConfig
mlDetectionConfig) (\s :: BehaviorCriteria
s@BehaviorCriteria' {} Maybe MachineLearningDetectionConfig
a -> BehaviorCriteria
s {$sel:mlDetectionConfig:BehaviorCriteria' :: Maybe MachineLearningDetectionConfig
mlDetectionConfig = Maybe MachineLearningDetectionConfig
a} :: BehaviorCriteria)

-- | The value to be compared with the @metric@.
behaviorCriteria_value :: Lens.Lens' BehaviorCriteria (Prelude.Maybe MetricValue)
behaviorCriteria_value :: (Maybe MetricValue -> f (Maybe MetricValue))
-> BehaviorCriteria -> f BehaviorCriteria
behaviorCriteria_value = (BehaviorCriteria -> Maybe MetricValue)
-> (BehaviorCriteria -> Maybe MetricValue -> BehaviorCriteria)
-> Lens
     BehaviorCriteria
     BehaviorCriteria
     (Maybe MetricValue)
     (Maybe MetricValue)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BehaviorCriteria' {Maybe MetricValue
value :: Maybe MetricValue
$sel:value:BehaviorCriteria' :: BehaviorCriteria -> Maybe MetricValue
value} -> Maybe MetricValue
value) (\s :: BehaviorCriteria
s@BehaviorCriteria' {} Maybe MetricValue
a -> BehaviorCriteria
s {$sel:value:BehaviorCriteria' :: Maybe MetricValue
value = Maybe MetricValue
a} :: BehaviorCriteria)

-- | If a device is in violation of the behavior for the specified number of
-- consecutive datapoints, an alarm occurs. If not specified, the default
-- is 1.
behaviorCriteria_consecutiveDatapointsToAlarm :: Lens.Lens' BehaviorCriteria (Prelude.Maybe Prelude.Natural)
behaviorCriteria_consecutiveDatapointsToAlarm :: (Maybe Natural -> f (Maybe Natural))
-> BehaviorCriteria -> f BehaviorCriteria
behaviorCriteria_consecutiveDatapointsToAlarm = (BehaviorCriteria -> Maybe Natural)
-> (BehaviorCriteria -> Maybe Natural -> BehaviorCriteria)
-> Lens
     BehaviorCriteria BehaviorCriteria (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BehaviorCriteria' {Maybe Natural
consecutiveDatapointsToAlarm :: Maybe Natural
$sel:consecutiveDatapointsToAlarm:BehaviorCriteria' :: BehaviorCriteria -> Maybe Natural
consecutiveDatapointsToAlarm} -> Maybe Natural
consecutiveDatapointsToAlarm) (\s :: BehaviorCriteria
s@BehaviorCriteria' {} Maybe Natural
a -> BehaviorCriteria
s {$sel:consecutiveDatapointsToAlarm:BehaviorCriteria' :: Maybe Natural
consecutiveDatapointsToAlarm = Maybe Natural
a} :: BehaviorCriteria)

-- | The operator that relates the thing measured (@metric@) to the criteria
-- (containing a @value@ or @statisticalThreshold@). Valid operators
-- include:
--
-- -   @string-list@: @in-set@ and @not-in-set@
--
-- -   @number-list@: @in-set@ and @not-in-set@
--
-- -   @ip-address-list@: @in-cidr-set@ and @not-in-cidr-set@
--
-- -   @number@: @less-than@, @less-than-equals@, @greater-than@, and
--     @greater-than-equals@
behaviorCriteria_comparisonOperator :: Lens.Lens' BehaviorCriteria (Prelude.Maybe ComparisonOperator)
behaviorCriteria_comparisonOperator :: (Maybe ComparisonOperator -> f (Maybe ComparisonOperator))
-> BehaviorCriteria -> f BehaviorCriteria
behaviorCriteria_comparisonOperator = (BehaviorCriteria -> Maybe ComparisonOperator)
-> (BehaviorCriteria
    -> Maybe ComparisonOperator -> BehaviorCriteria)
-> Lens
     BehaviorCriteria
     BehaviorCriteria
     (Maybe ComparisonOperator)
     (Maybe ComparisonOperator)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BehaviorCriteria' {Maybe ComparisonOperator
comparisonOperator :: Maybe ComparisonOperator
$sel:comparisonOperator:BehaviorCriteria' :: BehaviorCriteria -> Maybe ComparisonOperator
comparisonOperator} -> Maybe ComparisonOperator
comparisonOperator) (\s :: BehaviorCriteria
s@BehaviorCriteria' {} Maybe ComparisonOperator
a -> BehaviorCriteria
s {$sel:comparisonOperator:BehaviorCriteria' :: Maybe ComparisonOperator
comparisonOperator = Maybe ComparisonOperator
a} :: BehaviorCriteria)

-- | A statistical ranking (percentile)that indicates a threshold value by
-- which a behavior is determined to be in compliance or in violation of
-- the behavior.
behaviorCriteria_statisticalThreshold :: Lens.Lens' BehaviorCriteria (Prelude.Maybe StatisticalThreshold)
behaviorCriteria_statisticalThreshold :: (Maybe StatisticalThreshold -> f (Maybe StatisticalThreshold))
-> BehaviorCriteria -> f BehaviorCriteria
behaviorCriteria_statisticalThreshold = (BehaviorCriteria -> Maybe StatisticalThreshold)
-> (BehaviorCriteria
    -> Maybe StatisticalThreshold -> BehaviorCriteria)
-> Lens
     BehaviorCriteria
     BehaviorCriteria
     (Maybe StatisticalThreshold)
     (Maybe StatisticalThreshold)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BehaviorCriteria' {Maybe StatisticalThreshold
statisticalThreshold :: Maybe StatisticalThreshold
$sel:statisticalThreshold:BehaviorCriteria' :: BehaviorCriteria -> Maybe StatisticalThreshold
statisticalThreshold} -> Maybe StatisticalThreshold
statisticalThreshold) (\s :: BehaviorCriteria
s@BehaviorCriteria' {} Maybe StatisticalThreshold
a -> BehaviorCriteria
s {$sel:statisticalThreshold:BehaviorCriteria' :: Maybe StatisticalThreshold
statisticalThreshold = Maybe StatisticalThreshold
a} :: BehaviorCriteria)

-- | Use this to specify the time duration over which the behavior is
-- evaluated, for those criteria that have a time dimension (for example,
-- @NUM_MESSAGES_SENT@). For a @statisticalThreshhold@ metric comparison,
-- measurements from all devices are accumulated over this time duration
-- before being used to calculate percentiles, and later, measurements from
-- an individual device are also accumulated over this time duration before
-- being given a percentile rank. Cannot be used with list-based metric
-- datatypes.
behaviorCriteria_durationSeconds :: Lens.Lens' BehaviorCriteria (Prelude.Maybe Prelude.Int)
behaviorCriteria_durationSeconds :: (Maybe Int -> f (Maybe Int))
-> BehaviorCriteria -> f BehaviorCriteria
behaviorCriteria_durationSeconds = (BehaviorCriteria -> Maybe Int)
-> (BehaviorCriteria -> Maybe Int -> BehaviorCriteria)
-> Lens BehaviorCriteria BehaviorCriteria (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BehaviorCriteria' {Maybe Int
durationSeconds :: Maybe Int
$sel:durationSeconds:BehaviorCriteria' :: BehaviorCriteria -> Maybe Int
durationSeconds} -> Maybe Int
durationSeconds) (\s :: BehaviorCriteria
s@BehaviorCriteria' {} Maybe Int
a -> BehaviorCriteria
s {$sel:durationSeconds:BehaviorCriteria' :: Maybe Int
durationSeconds = Maybe Int
a} :: BehaviorCriteria)

-- | If an alarm has occurred and the offending device is no longer in
-- violation of the behavior for the specified number of consecutive
-- datapoints, the alarm is cleared. If not specified, the default is 1.
behaviorCriteria_consecutiveDatapointsToClear :: Lens.Lens' BehaviorCriteria (Prelude.Maybe Prelude.Natural)
behaviorCriteria_consecutiveDatapointsToClear :: (Maybe Natural -> f (Maybe Natural))
-> BehaviorCriteria -> f BehaviorCriteria
behaviorCriteria_consecutiveDatapointsToClear = (BehaviorCriteria -> Maybe Natural)
-> (BehaviorCriteria -> Maybe Natural -> BehaviorCriteria)
-> Lens
     BehaviorCriteria BehaviorCriteria (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BehaviorCriteria' {Maybe Natural
consecutiveDatapointsToClear :: Maybe Natural
$sel:consecutiveDatapointsToClear:BehaviorCriteria' :: BehaviorCriteria -> Maybe Natural
consecutiveDatapointsToClear} -> Maybe Natural
consecutiveDatapointsToClear) (\s :: BehaviorCriteria
s@BehaviorCriteria' {} Maybe Natural
a -> BehaviorCriteria
s {$sel:consecutiveDatapointsToClear:BehaviorCriteria' :: Maybe Natural
consecutiveDatapointsToClear = Maybe Natural
a} :: BehaviorCriteria)

instance Core.FromJSON BehaviorCriteria where
  parseJSON :: Value -> Parser BehaviorCriteria
parseJSON =
    String
-> (Object -> Parser BehaviorCriteria)
-> Value
-> Parser BehaviorCriteria
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BehaviorCriteria"
      ( \Object
x ->
          Maybe MachineLearningDetectionConfig
-> Maybe MetricValue
-> Maybe Natural
-> Maybe ComparisonOperator
-> Maybe StatisticalThreshold
-> Maybe Int
-> Maybe Natural
-> BehaviorCriteria
BehaviorCriteria'
            (Maybe MachineLearningDetectionConfig
 -> Maybe MetricValue
 -> Maybe Natural
 -> Maybe ComparisonOperator
 -> Maybe StatisticalThreshold
 -> Maybe Int
 -> Maybe Natural
 -> BehaviorCriteria)
-> Parser (Maybe MachineLearningDetectionConfig)
-> Parser
     (Maybe MetricValue
      -> Maybe Natural
      -> Maybe ComparisonOperator
      -> Maybe StatisticalThreshold
      -> Maybe Int
      -> Maybe Natural
      -> BehaviorCriteria)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe MachineLearningDetectionConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"mlDetectionConfig")
            Parser
  (Maybe MetricValue
   -> Maybe Natural
   -> Maybe ComparisonOperator
   -> Maybe StatisticalThreshold
   -> Maybe Int
   -> Maybe Natural
   -> BehaviorCriteria)
-> Parser (Maybe MetricValue)
-> Parser
     (Maybe Natural
      -> Maybe ComparisonOperator
      -> Maybe StatisticalThreshold
      -> Maybe Int
      -> Maybe Natural
      -> BehaviorCriteria)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe MetricValue)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"value")
            Parser
  (Maybe Natural
   -> Maybe ComparisonOperator
   -> Maybe StatisticalThreshold
   -> Maybe Int
   -> Maybe Natural
   -> BehaviorCriteria)
-> Parser (Maybe Natural)
-> Parser
     (Maybe ComparisonOperator
      -> Maybe StatisticalThreshold
      -> Maybe Int
      -> Maybe Natural
      -> BehaviorCriteria)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"consecutiveDatapointsToAlarm")
            Parser
  (Maybe ComparisonOperator
   -> Maybe StatisticalThreshold
   -> Maybe Int
   -> Maybe Natural
   -> BehaviorCriteria)
-> Parser (Maybe ComparisonOperator)
-> Parser
     (Maybe StatisticalThreshold
      -> Maybe Int -> Maybe Natural -> BehaviorCriteria)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ComparisonOperator)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"comparisonOperator")
            Parser
  (Maybe StatisticalThreshold
   -> Maybe Int -> Maybe Natural -> BehaviorCriteria)
-> Parser (Maybe StatisticalThreshold)
-> Parser (Maybe Int -> Maybe Natural -> BehaviorCriteria)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe StatisticalThreshold)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"statisticalThreshold")
            Parser (Maybe Int -> Maybe Natural -> BehaviorCriteria)
-> Parser (Maybe Int) -> Parser (Maybe Natural -> BehaviorCriteria)
forall (f :: * -> *) a b. Applicative f => 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
"durationSeconds")
            Parser (Maybe Natural -> BehaviorCriteria)
-> Parser (Maybe Natural) -> Parser BehaviorCriteria
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"consecutiveDatapointsToClear")
      )

instance Prelude.Hashable BehaviorCriteria

instance Prelude.NFData BehaviorCriteria

instance Core.ToJSON BehaviorCriteria where
  toJSON :: BehaviorCriteria -> Value
toJSON BehaviorCriteria' {Maybe Int
Maybe Natural
Maybe ComparisonOperator
Maybe MachineLearningDetectionConfig
Maybe MetricValue
Maybe StatisticalThreshold
consecutiveDatapointsToClear :: Maybe Natural
durationSeconds :: Maybe Int
statisticalThreshold :: Maybe StatisticalThreshold
comparisonOperator :: Maybe ComparisonOperator
consecutiveDatapointsToAlarm :: Maybe Natural
value :: Maybe MetricValue
mlDetectionConfig :: Maybe MachineLearningDetectionConfig
$sel:consecutiveDatapointsToClear:BehaviorCriteria' :: BehaviorCriteria -> Maybe Natural
$sel:durationSeconds:BehaviorCriteria' :: BehaviorCriteria -> Maybe Int
$sel:statisticalThreshold:BehaviorCriteria' :: BehaviorCriteria -> Maybe StatisticalThreshold
$sel:comparisonOperator:BehaviorCriteria' :: BehaviorCriteria -> Maybe ComparisonOperator
$sel:consecutiveDatapointsToAlarm:BehaviorCriteria' :: BehaviorCriteria -> Maybe Natural
$sel:value:BehaviorCriteria' :: BehaviorCriteria -> Maybe MetricValue
$sel:mlDetectionConfig:BehaviorCriteria' :: BehaviorCriteria -> Maybe MachineLearningDetectionConfig
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"mlDetectionConfig" Text -> MachineLearningDetectionConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (MachineLearningDetectionConfig -> Pair)
-> Maybe MachineLearningDetectionConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MachineLearningDetectionConfig
mlDetectionConfig,
            (Text
"value" Text -> MetricValue -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (MetricValue -> Pair) -> Maybe MetricValue -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MetricValue
value,
            (Text
"consecutiveDatapointsToAlarm" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
consecutiveDatapointsToAlarm,
            (Text
"comparisonOperator" Text -> ComparisonOperator -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ComparisonOperator -> Pair)
-> Maybe ComparisonOperator -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ComparisonOperator
comparisonOperator,
            (Text
"statisticalThreshold" Text -> StatisticalThreshold -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (StatisticalThreshold -> Pair)
-> Maybe StatisticalThreshold -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StatisticalThreshold
statisticalThreshold,
            (Text
"durationSeconds" 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
durationSeconds,
            (Text
"consecutiveDatapointsToClear" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
consecutiveDatapointsToClear
          ]
      )