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

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

-- | 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.
--
-- /See:/ 'newStatisticalThreshold' smart constructor.
data StatisticalThreshold = StatisticalThreshold'
  { -- | The percentile that resolves to a threshold value by which compliance
    -- with a behavior is determined. Metrics are collected over the specified
    -- period (@durationSeconds@) from all reporting devices in your account
    -- and statistical ranks are calculated. Then, the measurements from a
    -- device are collected over the same period. If the accumulated
    -- measurements from the device fall above or below (@comparisonOperator@)
    -- the value associated with the percentile specified, then the device is
    -- considered to be in compliance with the behavior, otherwise a violation
    -- occurs.
    StatisticalThreshold -> Maybe Text
statistic :: Prelude.Maybe Prelude.Text
  }
  deriving (StatisticalThreshold -> StatisticalThreshold -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StatisticalThreshold -> StatisticalThreshold -> Bool
$c/= :: StatisticalThreshold -> StatisticalThreshold -> Bool
== :: StatisticalThreshold -> StatisticalThreshold -> Bool
$c== :: StatisticalThreshold -> StatisticalThreshold -> Bool
Prelude.Eq, ReadPrec [StatisticalThreshold]
ReadPrec StatisticalThreshold
Int -> ReadS StatisticalThreshold
ReadS [StatisticalThreshold]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StatisticalThreshold]
$creadListPrec :: ReadPrec [StatisticalThreshold]
readPrec :: ReadPrec StatisticalThreshold
$creadPrec :: ReadPrec StatisticalThreshold
readList :: ReadS [StatisticalThreshold]
$creadList :: ReadS [StatisticalThreshold]
readsPrec :: Int -> ReadS StatisticalThreshold
$creadsPrec :: Int -> ReadS StatisticalThreshold
Prelude.Read, Int -> StatisticalThreshold -> ShowS
[StatisticalThreshold] -> ShowS
StatisticalThreshold -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StatisticalThreshold] -> ShowS
$cshowList :: [StatisticalThreshold] -> ShowS
show :: StatisticalThreshold -> String
$cshow :: StatisticalThreshold -> String
showsPrec :: Int -> StatisticalThreshold -> ShowS
$cshowsPrec :: Int -> StatisticalThreshold -> ShowS
Prelude.Show, forall x. Rep StatisticalThreshold x -> StatisticalThreshold
forall x. StatisticalThreshold -> Rep StatisticalThreshold x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StatisticalThreshold x -> StatisticalThreshold
$cfrom :: forall x. StatisticalThreshold -> Rep StatisticalThreshold x
Prelude.Generic)

-- |
-- Create a value of 'StatisticalThreshold' 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:
--
-- 'statistic', 'statisticalThreshold_statistic' - The percentile that resolves to a threshold value by which compliance
-- with a behavior is determined. Metrics are collected over the specified
-- period (@durationSeconds@) from all reporting devices in your account
-- and statistical ranks are calculated. Then, the measurements from a
-- device are collected over the same period. If the accumulated
-- measurements from the device fall above or below (@comparisonOperator@)
-- the value associated with the percentile specified, then the device is
-- considered to be in compliance with the behavior, otherwise a violation
-- occurs.
newStatisticalThreshold ::
  StatisticalThreshold
newStatisticalThreshold :: StatisticalThreshold
newStatisticalThreshold =
  StatisticalThreshold' {$sel:statistic:StatisticalThreshold' :: Maybe Text
statistic = forall a. Maybe a
Prelude.Nothing}

-- | The percentile that resolves to a threshold value by which compliance
-- with a behavior is determined. Metrics are collected over the specified
-- period (@durationSeconds@) from all reporting devices in your account
-- and statistical ranks are calculated. Then, the measurements from a
-- device are collected over the same period. If the accumulated
-- measurements from the device fall above or below (@comparisonOperator@)
-- the value associated with the percentile specified, then the device is
-- considered to be in compliance with the behavior, otherwise a violation
-- occurs.
statisticalThreshold_statistic :: Lens.Lens' StatisticalThreshold (Prelude.Maybe Prelude.Text)
statisticalThreshold_statistic :: Lens' StatisticalThreshold (Maybe Text)
statisticalThreshold_statistic = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatisticalThreshold' {Maybe Text
statistic :: Maybe Text
$sel:statistic:StatisticalThreshold' :: StatisticalThreshold -> Maybe Text
statistic} -> Maybe Text
statistic) (\s :: StatisticalThreshold
s@StatisticalThreshold' {} Maybe Text
a -> StatisticalThreshold
s {$sel:statistic:StatisticalThreshold' :: Maybe Text
statistic = Maybe Text
a} :: StatisticalThreshold)

instance Data.FromJSON StatisticalThreshold where
  parseJSON :: Value -> Parser StatisticalThreshold
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"StatisticalThreshold"
      ( \Object
x ->
          Maybe Text -> StatisticalThreshold
StatisticalThreshold'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"statistic")
      )

instance Prelude.Hashable StatisticalThreshold where
  hashWithSalt :: Int -> StatisticalThreshold -> Int
hashWithSalt Int
_salt StatisticalThreshold' {Maybe Text
statistic :: Maybe Text
$sel:statistic:StatisticalThreshold' :: StatisticalThreshold -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
statistic

instance Prelude.NFData StatisticalThreshold where
  rnf :: StatisticalThreshold -> ()
rnf StatisticalThreshold' {Maybe Text
statistic :: Maybe Text
$sel:statistic:StatisticalThreshold' :: StatisticalThreshold -> Maybe Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
statistic

instance Data.ToJSON StatisticalThreshold where
  toJSON :: StatisticalThreshold -> Value
toJSON StatisticalThreshold' {Maybe Text
statistic :: Maybe Text
$sel:statistic:StatisticalThreshold' :: StatisticalThreshold -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"statistic" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
statistic]
      )