{-# 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.AwsJobRateIncreaseCriteria
-- 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.AwsJobRateIncreaseCriteria 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

-- | The criteria to initiate the increase in rate of rollout for a job.
--
-- /See:/ 'newAwsJobRateIncreaseCriteria' smart constructor.
data AwsJobRateIncreaseCriteria = AwsJobRateIncreaseCriteria'
  { -- | When this number of things have been notified, it will initiate an
    -- increase in the rollout rate.
    AwsJobRateIncreaseCriteria -> Maybe Natural
numberOfNotifiedThings :: Prelude.Maybe Prelude.Natural,
    -- | When this number of things have succeeded in their job execution, it
    -- will initiate an increase in the rollout rate.
    AwsJobRateIncreaseCriteria -> Maybe Natural
numberOfSucceededThings :: Prelude.Maybe Prelude.Natural
  }
  deriving (AwsJobRateIncreaseCriteria -> AwsJobRateIncreaseCriteria -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsJobRateIncreaseCriteria -> AwsJobRateIncreaseCriteria -> Bool
$c/= :: AwsJobRateIncreaseCriteria -> AwsJobRateIncreaseCriteria -> Bool
== :: AwsJobRateIncreaseCriteria -> AwsJobRateIncreaseCriteria -> Bool
$c== :: AwsJobRateIncreaseCriteria -> AwsJobRateIncreaseCriteria -> Bool
Prelude.Eq, ReadPrec [AwsJobRateIncreaseCriteria]
ReadPrec AwsJobRateIncreaseCriteria
Int -> ReadS AwsJobRateIncreaseCriteria
ReadS [AwsJobRateIncreaseCriteria]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsJobRateIncreaseCriteria]
$creadListPrec :: ReadPrec [AwsJobRateIncreaseCriteria]
readPrec :: ReadPrec AwsJobRateIncreaseCriteria
$creadPrec :: ReadPrec AwsJobRateIncreaseCriteria
readList :: ReadS [AwsJobRateIncreaseCriteria]
$creadList :: ReadS [AwsJobRateIncreaseCriteria]
readsPrec :: Int -> ReadS AwsJobRateIncreaseCriteria
$creadsPrec :: Int -> ReadS AwsJobRateIncreaseCriteria
Prelude.Read, Int -> AwsJobRateIncreaseCriteria -> ShowS
[AwsJobRateIncreaseCriteria] -> ShowS
AwsJobRateIncreaseCriteria -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsJobRateIncreaseCriteria] -> ShowS
$cshowList :: [AwsJobRateIncreaseCriteria] -> ShowS
show :: AwsJobRateIncreaseCriteria -> String
$cshow :: AwsJobRateIncreaseCriteria -> String
showsPrec :: Int -> AwsJobRateIncreaseCriteria -> ShowS
$cshowsPrec :: Int -> AwsJobRateIncreaseCriteria -> ShowS
Prelude.Show, forall x.
Rep AwsJobRateIncreaseCriteria x -> AwsJobRateIncreaseCriteria
forall x.
AwsJobRateIncreaseCriteria -> Rep AwsJobRateIncreaseCriteria x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsJobRateIncreaseCriteria x -> AwsJobRateIncreaseCriteria
$cfrom :: forall x.
AwsJobRateIncreaseCriteria -> Rep AwsJobRateIncreaseCriteria x
Prelude.Generic)

-- |
-- Create a value of 'AwsJobRateIncreaseCriteria' 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:
--
-- 'numberOfNotifiedThings', 'awsJobRateIncreaseCriteria_numberOfNotifiedThings' - When this number of things have been notified, it will initiate an
-- increase in the rollout rate.
--
-- 'numberOfSucceededThings', 'awsJobRateIncreaseCriteria_numberOfSucceededThings' - When this number of things have succeeded in their job execution, it
-- will initiate an increase in the rollout rate.
newAwsJobRateIncreaseCriteria ::
  AwsJobRateIncreaseCriteria
newAwsJobRateIncreaseCriteria :: AwsJobRateIncreaseCriteria
newAwsJobRateIncreaseCriteria =
  AwsJobRateIncreaseCriteria'
    { $sel:numberOfNotifiedThings:AwsJobRateIncreaseCriteria' :: Maybe Natural
numberOfNotifiedThings =
        forall a. Maybe a
Prelude.Nothing,
      $sel:numberOfSucceededThings:AwsJobRateIncreaseCriteria' :: Maybe Natural
numberOfSucceededThings = forall a. Maybe a
Prelude.Nothing
    }

-- | When this number of things have been notified, it will initiate an
-- increase in the rollout rate.
awsJobRateIncreaseCriteria_numberOfNotifiedThings :: Lens.Lens' AwsJobRateIncreaseCriteria (Prelude.Maybe Prelude.Natural)
awsJobRateIncreaseCriteria_numberOfNotifiedThings :: Lens' AwsJobRateIncreaseCriteria (Maybe Natural)
awsJobRateIncreaseCriteria_numberOfNotifiedThings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsJobRateIncreaseCriteria' {Maybe Natural
numberOfNotifiedThings :: Maybe Natural
$sel:numberOfNotifiedThings:AwsJobRateIncreaseCriteria' :: AwsJobRateIncreaseCriteria -> Maybe Natural
numberOfNotifiedThings} -> Maybe Natural
numberOfNotifiedThings) (\s :: AwsJobRateIncreaseCriteria
s@AwsJobRateIncreaseCriteria' {} Maybe Natural
a -> AwsJobRateIncreaseCriteria
s {$sel:numberOfNotifiedThings:AwsJobRateIncreaseCriteria' :: Maybe Natural
numberOfNotifiedThings = Maybe Natural
a} :: AwsJobRateIncreaseCriteria)

-- | When this number of things have succeeded in their job execution, it
-- will initiate an increase in the rollout rate.
awsJobRateIncreaseCriteria_numberOfSucceededThings :: Lens.Lens' AwsJobRateIncreaseCriteria (Prelude.Maybe Prelude.Natural)
awsJobRateIncreaseCriteria_numberOfSucceededThings :: Lens' AwsJobRateIncreaseCriteria (Maybe Natural)
awsJobRateIncreaseCriteria_numberOfSucceededThings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsJobRateIncreaseCriteria' {Maybe Natural
numberOfSucceededThings :: Maybe Natural
$sel:numberOfSucceededThings:AwsJobRateIncreaseCriteria' :: AwsJobRateIncreaseCriteria -> Maybe Natural
numberOfSucceededThings} -> Maybe Natural
numberOfSucceededThings) (\s :: AwsJobRateIncreaseCriteria
s@AwsJobRateIncreaseCriteria' {} Maybe Natural
a -> AwsJobRateIncreaseCriteria
s {$sel:numberOfSucceededThings:AwsJobRateIncreaseCriteria' :: Maybe Natural
numberOfSucceededThings = Maybe Natural
a} :: AwsJobRateIncreaseCriteria)

instance Data.FromJSON AwsJobRateIncreaseCriteria where
  parseJSON :: Value -> Parser AwsJobRateIncreaseCriteria
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AwsJobRateIncreaseCriteria"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> AwsJobRateIncreaseCriteria
AwsJobRateIncreaseCriteria'
            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
"numberOfNotifiedThings")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"numberOfSucceededThings")
      )

instance Prelude.Hashable AwsJobRateIncreaseCriteria where
  hashWithSalt :: Int -> AwsJobRateIncreaseCriteria -> Int
hashWithSalt Int
_salt AwsJobRateIncreaseCriteria' {Maybe Natural
numberOfSucceededThings :: Maybe Natural
numberOfNotifiedThings :: Maybe Natural
$sel:numberOfSucceededThings:AwsJobRateIncreaseCriteria' :: AwsJobRateIncreaseCriteria -> Maybe Natural
$sel:numberOfNotifiedThings:AwsJobRateIncreaseCriteria' :: AwsJobRateIncreaseCriteria -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
numberOfNotifiedThings
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
numberOfSucceededThings

instance Prelude.NFData AwsJobRateIncreaseCriteria where
  rnf :: AwsJobRateIncreaseCriteria -> ()
rnf AwsJobRateIncreaseCriteria' {Maybe Natural
numberOfSucceededThings :: Maybe Natural
numberOfNotifiedThings :: Maybe Natural
$sel:numberOfSucceededThings:AwsJobRateIncreaseCriteria' :: AwsJobRateIncreaseCriteria -> Maybe Natural
$sel:numberOfNotifiedThings:AwsJobRateIncreaseCriteria' :: AwsJobRateIncreaseCriteria -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
numberOfNotifiedThings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
numberOfSucceededThings

instance Data.ToJSON AwsJobRateIncreaseCriteria where
  toJSON :: AwsJobRateIncreaseCriteria -> Value
toJSON AwsJobRateIncreaseCriteria' {Maybe Natural
numberOfSucceededThings :: Maybe Natural
numberOfNotifiedThings :: Maybe Natural
$sel:numberOfSucceededThings:AwsJobRateIncreaseCriteria' :: AwsJobRateIncreaseCriteria -> Maybe Natural
$sel:numberOfNotifiedThings:AwsJobRateIncreaseCriteria' :: AwsJobRateIncreaseCriteria -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"numberOfNotifiedThings" 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 Natural
numberOfNotifiedThings,
            (Key
"numberOfSucceededThings" 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 Natural
numberOfSucceededThings
          ]
      )