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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT.Types.AwsJobAbortCriteriaAbortAction
import Amazonka.IoT.Types.AwsJobAbortCriteriaFailureType
import qualified Amazonka.Prelude as Prelude

-- | The criteria that determine when and how a job abort takes place.
--
-- /See:/ 'newAwsJobAbortCriteria' smart constructor.
data AwsJobAbortCriteria = AwsJobAbortCriteria'
  { -- | The type of job execution failures that can initiate a job abort.
    AwsJobAbortCriteria -> AwsJobAbortCriteriaFailureType
failureType :: AwsJobAbortCriteriaFailureType,
    -- | The type of job action to take to initiate the job abort.
    AwsJobAbortCriteria -> AwsJobAbortCriteriaAbortAction
action :: AwsJobAbortCriteriaAbortAction,
    -- | The minimum percentage of job execution failures that must occur to
    -- initiate the job abort.
    --
    -- Amazon Web Services IoT Core supports up to two digits after the decimal
    -- (for example, 10.9 and 10.99, but not 10.999).
    AwsJobAbortCriteria -> Double
thresholdPercentage :: Prelude.Double,
    -- | The minimum number of things which must receive job execution
    -- notifications before the job can be aborted.
    AwsJobAbortCriteria -> Natural
minNumberOfExecutedThings :: Prelude.Natural
  }
  deriving (AwsJobAbortCriteria -> AwsJobAbortCriteria -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsJobAbortCriteria -> AwsJobAbortCriteria -> Bool
$c/= :: AwsJobAbortCriteria -> AwsJobAbortCriteria -> Bool
== :: AwsJobAbortCriteria -> AwsJobAbortCriteria -> Bool
$c== :: AwsJobAbortCriteria -> AwsJobAbortCriteria -> Bool
Prelude.Eq, ReadPrec [AwsJobAbortCriteria]
ReadPrec AwsJobAbortCriteria
Int -> ReadS AwsJobAbortCriteria
ReadS [AwsJobAbortCriteria]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsJobAbortCriteria]
$creadListPrec :: ReadPrec [AwsJobAbortCriteria]
readPrec :: ReadPrec AwsJobAbortCriteria
$creadPrec :: ReadPrec AwsJobAbortCriteria
readList :: ReadS [AwsJobAbortCriteria]
$creadList :: ReadS [AwsJobAbortCriteria]
readsPrec :: Int -> ReadS AwsJobAbortCriteria
$creadsPrec :: Int -> ReadS AwsJobAbortCriteria
Prelude.Read, Int -> AwsJobAbortCriteria -> ShowS
[AwsJobAbortCriteria] -> ShowS
AwsJobAbortCriteria -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsJobAbortCriteria] -> ShowS
$cshowList :: [AwsJobAbortCriteria] -> ShowS
show :: AwsJobAbortCriteria -> String
$cshow :: AwsJobAbortCriteria -> String
showsPrec :: Int -> AwsJobAbortCriteria -> ShowS
$cshowsPrec :: Int -> AwsJobAbortCriteria -> ShowS
Prelude.Show, forall x. Rep AwsJobAbortCriteria x -> AwsJobAbortCriteria
forall x. AwsJobAbortCriteria -> Rep AwsJobAbortCriteria x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AwsJobAbortCriteria x -> AwsJobAbortCriteria
$cfrom :: forall x. AwsJobAbortCriteria -> Rep AwsJobAbortCriteria x
Prelude.Generic)

-- |
-- Create a value of 'AwsJobAbortCriteria' 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:
--
-- 'failureType', 'awsJobAbortCriteria_failureType' - The type of job execution failures that can initiate a job abort.
--
-- 'action', 'awsJobAbortCriteria_action' - The type of job action to take to initiate the job abort.
--
-- 'thresholdPercentage', 'awsJobAbortCriteria_thresholdPercentage' - The minimum percentage of job execution failures that must occur to
-- initiate the job abort.
--
-- Amazon Web Services IoT Core supports up to two digits after the decimal
-- (for example, 10.9 and 10.99, but not 10.999).
--
-- 'minNumberOfExecutedThings', 'awsJobAbortCriteria_minNumberOfExecutedThings' - The minimum number of things which must receive job execution
-- notifications before the job can be aborted.
newAwsJobAbortCriteria ::
  -- | 'failureType'
  AwsJobAbortCriteriaFailureType ->
  -- | 'action'
  AwsJobAbortCriteriaAbortAction ->
  -- | 'thresholdPercentage'
  Prelude.Double ->
  -- | 'minNumberOfExecutedThings'
  Prelude.Natural ->
  AwsJobAbortCriteria
newAwsJobAbortCriteria :: AwsJobAbortCriteriaFailureType
-> AwsJobAbortCriteriaAbortAction
-> Double
-> Natural
-> AwsJobAbortCriteria
newAwsJobAbortCriteria
  AwsJobAbortCriteriaFailureType
pFailureType_
  AwsJobAbortCriteriaAbortAction
pAction_
  Double
pThresholdPercentage_
  Natural
pMinNumberOfExecutedThings_ =
    AwsJobAbortCriteria'
      { $sel:failureType:AwsJobAbortCriteria' :: AwsJobAbortCriteriaFailureType
failureType = AwsJobAbortCriteriaFailureType
pFailureType_,
        $sel:action:AwsJobAbortCriteria' :: AwsJobAbortCriteriaAbortAction
action = AwsJobAbortCriteriaAbortAction
pAction_,
        $sel:thresholdPercentage:AwsJobAbortCriteria' :: Double
thresholdPercentage = Double
pThresholdPercentage_,
        $sel:minNumberOfExecutedThings:AwsJobAbortCriteria' :: Natural
minNumberOfExecutedThings =
          Natural
pMinNumberOfExecutedThings_
      }

-- | The type of job execution failures that can initiate a job abort.
awsJobAbortCriteria_failureType :: Lens.Lens' AwsJobAbortCriteria AwsJobAbortCriteriaFailureType
awsJobAbortCriteria_failureType :: Lens' AwsJobAbortCriteria AwsJobAbortCriteriaFailureType
awsJobAbortCriteria_failureType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsJobAbortCriteria' {AwsJobAbortCriteriaFailureType
failureType :: AwsJobAbortCriteriaFailureType
$sel:failureType:AwsJobAbortCriteria' :: AwsJobAbortCriteria -> AwsJobAbortCriteriaFailureType
failureType} -> AwsJobAbortCriteriaFailureType
failureType) (\s :: AwsJobAbortCriteria
s@AwsJobAbortCriteria' {} AwsJobAbortCriteriaFailureType
a -> AwsJobAbortCriteria
s {$sel:failureType:AwsJobAbortCriteria' :: AwsJobAbortCriteriaFailureType
failureType = AwsJobAbortCriteriaFailureType
a} :: AwsJobAbortCriteria)

-- | The type of job action to take to initiate the job abort.
awsJobAbortCriteria_action :: Lens.Lens' AwsJobAbortCriteria AwsJobAbortCriteriaAbortAction
awsJobAbortCriteria_action :: Lens' AwsJobAbortCriteria AwsJobAbortCriteriaAbortAction
awsJobAbortCriteria_action = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsJobAbortCriteria' {AwsJobAbortCriteriaAbortAction
action :: AwsJobAbortCriteriaAbortAction
$sel:action:AwsJobAbortCriteria' :: AwsJobAbortCriteria -> AwsJobAbortCriteriaAbortAction
action} -> AwsJobAbortCriteriaAbortAction
action) (\s :: AwsJobAbortCriteria
s@AwsJobAbortCriteria' {} AwsJobAbortCriteriaAbortAction
a -> AwsJobAbortCriteria
s {$sel:action:AwsJobAbortCriteria' :: AwsJobAbortCriteriaAbortAction
action = AwsJobAbortCriteriaAbortAction
a} :: AwsJobAbortCriteria)

-- | The minimum percentage of job execution failures that must occur to
-- initiate the job abort.
--
-- Amazon Web Services IoT Core supports up to two digits after the decimal
-- (for example, 10.9 and 10.99, but not 10.999).
awsJobAbortCriteria_thresholdPercentage :: Lens.Lens' AwsJobAbortCriteria Prelude.Double
awsJobAbortCriteria_thresholdPercentage :: Lens' AwsJobAbortCriteria Double
awsJobAbortCriteria_thresholdPercentage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsJobAbortCriteria' {Double
thresholdPercentage :: Double
$sel:thresholdPercentage:AwsJobAbortCriteria' :: AwsJobAbortCriteria -> Double
thresholdPercentage} -> Double
thresholdPercentage) (\s :: AwsJobAbortCriteria
s@AwsJobAbortCriteria' {} Double
a -> AwsJobAbortCriteria
s {$sel:thresholdPercentage:AwsJobAbortCriteria' :: Double
thresholdPercentage = Double
a} :: AwsJobAbortCriteria)

-- | The minimum number of things which must receive job execution
-- notifications before the job can be aborted.
awsJobAbortCriteria_minNumberOfExecutedThings :: Lens.Lens' AwsJobAbortCriteria Prelude.Natural
awsJobAbortCriteria_minNumberOfExecutedThings :: Lens' AwsJobAbortCriteria Natural
awsJobAbortCriteria_minNumberOfExecutedThings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsJobAbortCriteria' {Natural
minNumberOfExecutedThings :: Natural
$sel:minNumberOfExecutedThings:AwsJobAbortCriteria' :: AwsJobAbortCriteria -> Natural
minNumberOfExecutedThings} -> Natural
minNumberOfExecutedThings) (\s :: AwsJobAbortCriteria
s@AwsJobAbortCriteria' {} Natural
a -> AwsJobAbortCriteria
s {$sel:minNumberOfExecutedThings:AwsJobAbortCriteria' :: Natural
minNumberOfExecutedThings = Natural
a} :: AwsJobAbortCriteria)

instance Prelude.Hashable AwsJobAbortCriteria where
  hashWithSalt :: Int -> AwsJobAbortCriteria -> Int
hashWithSalt Int
_salt AwsJobAbortCriteria' {Double
Natural
AwsJobAbortCriteriaAbortAction
AwsJobAbortCriteriaFailureType
minNumberOfExecutedThings :: Natural
thresholdPercentage :: Double
action :: AwsJobAbortCriteriaAbortAction
failureType :: AwsJobAbortCriteriaFailureType
$sel:minNumberOfExecutedThings:AwsJobAbortCriteria' :: AwsJobAbortCriteria -> Natural
$sel:thresholdPercentage:AwsJobAbortCriteria' :: AwsJobAbortCriteria -> Double
$sel:action:AwsJobAbortCriteria' :: AwsJobAbortCriteria -> AwsJobAbortCriteriaAbortAction
$sel:failureType:AwsJobAbortCriteria' :: AwsJobAbortCriteria -> AwsJobAbortCriteriaFailureType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AwsJobAbortCriteriaFailureType
failureType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AwsJobAbortCriteriaAbortAction
action
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
thresholdPercentage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
minNumberOfExecutedThings

instance Prelude.NFData AwsJobAbortCriteria where
  rnf :: AwsJobAbortCriteria -> ()
rnf AwsJobAbortCriteria' {Double
Natural
AwsJobAbortCriteriaAbortAction
AwsJobAbortCriteriaFailureType
minNumberOfExecutedThings :: Natural
thresholdPercentage :: Double
action :: AwsJobAbortCriteriaAbortAction
failureType :: AwsJobAbortCriteriaFailureType
$sel:minNumberOfExecutedThings:AwsJobAbortCriteria' :: AwsJobAbortCriteria -> Natural
$sel:thresholdPercentage:AwsJobAbortCriteria' :: AwsJobAbortCriteria -> Double
$sel:action:AwsJobAbortCriteria' :: AwsJobAbortCriteria -> AwsJobAbortCriteriaAbortAction
$sel:failureType:AwsJobAbortCriteria' :: AwsJobAbortCriteria -> AwsJobAbortCriteriaFailureType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf AwsJobAbortCriteriaFailureType
failureType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf AwsJobAbortCriteriaAbortAction
action
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
thresholdPercentage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
minNumberOfExecutedThings

instance Data.ToJSON AwsJobAbortCriteria where
  toJSON :: AwsJobAbortCriteria -> Value
toJSON AwsJobAbortCriteria' {Double
Natural
AwsJobAbortCriteriaAbortAction
AwsJobAbortCriteriaFailureType
minNumberOfExecutedThings :: Natural
thresholdPercentage :: Double
action :: AwsJobAbortCriteriaAbortAction
failureType :: AwsJobAbortCriteriaFailureType
$sel:minNumberOfExecutedThings:AwsJobAbortCriteria' :: AwsJobAbortCriteria -> Natural
$sel:thresholdPercentage:AwsJobAbortCriteria' :: AwsJobAbortCriteria -> Double
$sel:action:AwsJobAbortCriteria' :: AwsJobAbortCriteria -> AwsJobAbortCriteriaAbortAction
$sel:failureType:AwsJobAbortCriteria' :: AwsJobAbortCriteria -> AwsJobAbortCriteriaFailureType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"failureType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= AwsJobAbortCriteriaFailureType
failureType),
            forall a. a -> Maybe a
Prelude.Just (Key
"action" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= AwsJobAbortCriteriaAbortAction
action),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"thresholdPercentage" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Double
thresholdPercentage),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"minNumberOfExecutedThings"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
minNumberOfExecutedThings
              )
          ]
      )