{-# 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 #-}
module Amazonka.IoT.Types.AbortCriteria where
import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.AbortAction
import Amazonka.IoT.Types.JobExecutionFailureType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data AbortCriteria = AbortCriteria'
{
AbortCriteria -> JobExecutionFailureType
failureType :: JobExecutionFailureType,
AbortCriteria -> AbortAction
action :: AbortAction,
AbortCriteria -> Double
thresholdPercentage :: Prelude.Double,
AbortCriteria -> Natural
minNumberOfExecutedThings :: Prelude.Natural
}
deriving (AbortCriteria -> AbortCriteria -> Bool
(AbortCriteria -> AbortCriteria -> Bool)
-> (AbortCriteria -> AbortCriteria -> Bool) -> Eq AbortCriteria
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AbortCriteria -> AbortCriteria -> Bool
$c/= :: AbortCriteria -> AbortCriteria -> Bool
== :: AbortCriteria -> AbortCriteria -> Bool
$c== :: AbortCriteria -> AbortCriteria -> Bool
Prelude.Eq, ReadPrec [AbortCriteria]
ReadPrec AbortCriteria
Int -> ReadS AbortCriteria
ReadS [AbortCriteria]
(Int -> ReadS AbortCriteria)
-> ReadS [AbortCriteria]
-> ReadPrec AbortCriteria
-> ReadPrec [AbortCriteria]
-> Read AbortCriteria
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AbortCriteria]
$creadListPrec :: ReadPrec [AbortCriteria]
readPrec :: ReadPrec AbortCriteria
$creadPrec :: ReadPrec AbortCriteria
readList :: ReadS [AbortCriteria]
$creadList :: ReadS [AbortCriteria]
readsPrec :: Int -> ReadS AbortCriteria
$creadsPrec :: Int -> ReadS AbortCriteria
Prelude.Read, Int -> AbortCriteria -> ShowS
[AbortCriteria] -> ShowS
AbortCriteria -> String
(Int -> AbortCriteria -> ShowS)
-> (AbortCriteria -> String)
-> ([AbortCriteria] -> ShowS)
-> Show AbortCriteria
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AbortCriteria] -> ShowS
$cshowList :: [AbortCriteria] -> ShowS
show :: AbortCriteria -> String
$cshow :: AbortCriteria -> String
showsPrec :: Int -> AbortCriteria -> ShowS
$cshowsPrec :: Int -> AbortCriteria -> ShowS
Prelude.Show, (forall x. AbortCriteria -> Rep AbortCriteria x)
-> (forall x. Rep AbortCriteria x -> AbortCriteria)
-> Generic AbortCriteria
forall x. Rep AbortCriteria x -> AbortCriteria
forall x. AbortCriteria -> Rep AbortCriteria x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AbortCriteria x -> AbortCriteria
$cfrom :: forall x. AbortCriteria -> Rep AbortCriteria x
Prelude.Generic)
newAbortCriteria ::
JobExecutionFailureType ->
AbortAction ->
Prelude.Double ->
Prelude.Natural ->
AbortCriteria
newAbortCriteria :: JobExecutionFailureType
-> AbortAction -> Double -> Natural -> AbortCriteria
newAbortCriteria
JobExecutionFailureType
pFailureType_
AbortAction
pAction_
Double
pThresholdPercentage_
Natural
pMinNumberOfExecutedThings_ =
AbortCriteria' :: JobExecutionFailureType
-> AbortAction -> Double -> Natural -> AbortCriteria
AbortCriteria'
{ $sel:failureType:AbortCriteria' :: JobExecutionFailureType
failureType = JobExecutionFailureType
pFailureType_,
$sel:action:AbortCriteria' :: AbortAction
action = AbortAction
pAction_,
$sel:thresholdPercentage:AbortCriteria' :: Double
thresholdPercentage = Double
pThresholdPercentage_,
$sel:minNumberOfExecutedThings:AbortCriteria' :: Natural
minNumberOfExecutedThings =
Natural
pMinNumberOfExecutedThings_
}
abortCriteria_failureType :: Lens.Lens' AbortCriteria JobExecutionFailureType
abortCriteria_failureType :: (JobExecutionFailureType -> f JobExecutionFailureType)
-> AbortCriteria -> f AbortCriteria
abortCriteria_failureType = (AbortCriteria -> JobExecutionFailureType)
-> (AbortCriteria -> JobExecutionFailureType -> AbortCriteria)
-> Lens
AbortCriteria
AbortCriteria
JobExecutionFailureType
JobExecutionFailureType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AbortCriteria' {JobExecutionFailureType
failureType :: JobExecutionFailureType
$sel:failureType:AbortCriteria' :: AbortCriteria -> JobExecutionFailureType
failureType} -> JobExecutionFailureType
failureType) (\s :: AbortCriteria
s@AbortCriteria' {} JobExecutionFailureType
a -> AbortCriteria
s {$sel:failureType:AbortCriteria' :: JobExecutionFailureType
failureType = JobExecutionFailureType
a} :: AbortCriteria)
abortCriteria_action :: Lens.Lens' AbortCriteria AbortAction
abortCriteria_action :: (AbortAction -> f AbortAction) -> AbortCriteria -> f AbortCriteria
abortCriteria_action = (AbortCriteria -> AbortAction)
-> (AbortCriteria -> AbortAction -> AbortCriteria)
-> Lens AbortCriteria AbortCriteria AbortAction AbortAction
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AbortCriteria' {AbortAction
action :: AbortAction
$sel:action:AbortCriteria' :: AbortCriteria -> AbortAction
action} -> AbortAction
action) (\s :: AbortCriteria
s@AbortCriteria' {} AbortAction
a -> AbortCriteria
s {$sel:action:AbortCriteria' :: AbortAction
action = AbortAction
a} :: AbortCriteria)
abortCriteria_thresholdPercentage :: Lens.Lens' AbortCriteria Prelude.Double
abortCriteria_thresholdPercentage :: (Double -> f Double) -> AbortCriteria -> f AbortCriteria
abortCriteria_thresholdPercentage = (AbortCriteria -> Double)
-> (AbortCriteria -> Double -> AbortCriteria)
-> Lens AbortCriteria AbortCriteria Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AbortCriteria' {Double
thresholdPercentage :: Double
$sel:thresholdPercentage:AbortCriteria' :: AbortCriteria -> Double
thresholdPercentage} -> Double
thresholdPercentage) (\s :: AbortCriteria
s@AbortCriteria' {} Double
a -> AbortCriteria
s {$sel:thresholdPercentage:AbortCriteria' :: Double
thresholdPercentage = Double
a} :: AbortCriteria)
abortCriteria_minNumberOfExecutedThings :: Lens.Lens' AbortCriteria Prelude.Natural
abortCriteria_minNumberOfExecutedThings :: (Natural -> f Natural) -> AbortCriteria -> f AbortCriteria
abortCriteria_minNumberOfExecutedThings = (AbortCriteria -> Natural)
-> (AbortCriteria -> Natural -> AbortCriteria)
-> Lens AbortCriteria AbortCriteria Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AbortCriteria' {Natural
minNumberOfExecutedThings :: Natural
$sel:minNumberOfExecutedThings:AbortCriteria' :: AbortCriteria -> Natural
minNumberOfExecutedThings} -> Natural
minNumberOfExecutedThings) (\s :: AbortCriteria
s@AbortCriteria' {} Natural
a -> AbortCriteria
s {$sel:minNumberOfExecutedThings:AbortCriteria' :: Natural
minNumberOfExecutedThings = Natural
a} :: AbortCriteria)
instance Core.FromJSON AbortCriteria where
parseJSON :: Value -> Parser AbortCriteria
parseJSON =
String
-> (Object -> Parser AbortCriteria)
-> Value
-> Parser AbortCriteria
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"AbortCriteria"
( \Object
x ->
JobExecutionFailureType
-> AbortAction -> Double -> Natural -> AbortCriteria
AbortCriteria'
(JobExecutionFailureType
-> AbortAction -> Double -> Natural -> AbortCriteria)
-> Parser JobExecutionFailureType
-> Parser (AbortAction -> Double -> Natural -> AbortCriteria)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser JobExecutionFailureType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"failureType")
Parser (AbortAction -> Double -> Natural -> AbortCriteria)
-> Parser AbortAction
-> Parser (Double -> Natural -> AbortCriteria)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser AbortAction
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"action")
Parser (Double -> Natural -> AbortCriteria)
-> Parser Double -> Parser (Natural -> AbortCriteria)
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
"thresholdPercentage")
Parser (Natural -> AbortCriteria)
-> Parser Natural -> Parser AbortCriteria
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"minNumberOfExecutedThings")
)
instance Prelude.Hashable AbortCriteria
instance Prelude.NFData AbortCriteria
instance Core.ToJSON AbortCriteria where
toJSON :: AbortCriteria -> Value
toJSON AbortCriteria' {Double
Natural
AbortAction
JobExecutionFailureType
minNumberOfExecutedThings :: Natural
thresholdPercentage :: Double
action :: AbortAction
failureType :: JobExecutionFailureType
$sel:minNumberOfExecutedThings:AbortCriteria' :: AbortCriteria -> Natural
$sel:thresholdPercentage:AbortCriteria' :: AbortCriteria -> Double
$sel:action:AbortCriteria' :: AbortCriteria -> AbortAction
$sel:failureType:AbortCriteria' :: AbortCriteria -> JobExecutionFailureType
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"failureType" Text -> JobExecutionFailureType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= JobExecutionFailureType
failureType),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"action" Text -> AbortAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AbortAction
action),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"thresholdPercentage" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
thresholdPercentage),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
( Text
"minNumberOfExecutedThings"
Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
minNumberOfExecutedThings
)
]
)