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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(AwsJobRateIncreaseCriteria -> AwsJobRateIncreaseCriteria -> Bool)
-> (AwsJobRateIncreaseCriteria
    -> AwsJobRateIncreaseCriteria -> Bool)
-> Eq AwsJobRateIncreaseCriteria
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]
(Int -> ReadS AwsJobRateIncreaseCriteria)
-> ReadS [AwsJobRateIncreaseCriteria]
-> ReadPrec AwsJobRateIncreaseCriteria
-> ReadPrec [AwsJobRateIncreaseCriteria]
-> Read 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
(Int -> AwsJobRateIncreaseCriteria -> ShowS)
-> (AwsJobRateIncreaseCriteria -> String)
-> ([AwsJobRateIncreaseCriteria] -> ShowS)
-> Show AwsJobRateIncreaseCriteria
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.
 AwsJobRateIncreaseCriteria -> Rep AwsJobRateIncreaseCriteria x)
-> (forall x.
    Rep AwsJobRateIncreaseCriteria x -> AwsJobRateIncreaseCriteria)
-> Generic AwsJobRateIncreaseCriteria
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' :: Maybe Natural -> Maybe Natural -> AwsJobRateIncreaseCriteria
AwsJobRateIncreaseCriteria'
    { $sel:numberOfNotifiedThings:AwsJobRateIncreaseCriteria' :: Maybe Natural
numberOfNotifiedThings =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:numberOfSucceededThings:AwsJobRateIncreaseCriteria' :: Maybe Natural
numberOfSucceededThings = Maybe Natural
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 :: (Maybe Natural -> f (Maybe Natural))
-> AwsJobRateIncreaseCriteria -> f AwsJobRateIncreaseCriteria
awsJobRateIncreaseCriteria_numberOfNotifiedThings = (AwsJobRateIncreaseCriteria -> Maybe Natural)
-> (AwsJobRateIncreaseCriteria
    -> Maybe Natural -> AwsJobRateIncreaseCriteria)
-> Lens
     AwsJobRateIncreaseCriteria
     AwsJobRateIncreaseCriteria
     (Maybe Natural)
     (Maybe Natural)
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 :: (Maybe Natural -> f (Maybe Natural))
-> AwsJobRateIncreaseCriteria -> f AwsJobRateIncreaseCriteria
awsJobRateIncreaseCriteria_numberOfSucceededThings = (AwsJobRateIncreaseCriteria -> Maybe Natural)
-> (AwsJobRateIncreaseCriteria
    -> Maybe Natural -> AwsJobRateIncreaseCriteria)
-> Lens
     AwsJobRateIncreaseCriteria
     AwsJobRateIncreaseCriteria
     (Maybe Natural)
     (Maybe Natural)
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 Core.FromJSON AwsJobRateIncreaseCriteria where
  parseJSON :: Value -> Parser AwsJobRateIncreaseCriteria
parseJSON =
    String
-> (Object -> Parser AwsJobRateIncreaseCriteria)
-> Value
-> Parser AwsJobRateIncreaseCriteria
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsJobRateIncreaseCriteria"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> AwsJobRateIncreaseCriteria
AwsJobRateIncreaseCriteria'
            (Maybe Natural -> Maybe Natural -> AwsJobRateIncreaseCriteria)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> AwsJobRateIncreaseCriteria)
forall (f :: * -> *) a b. Functor 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
"numberOfNotifiedThings")
            Parser (Maybe Natural -> AwsJobRateIncreaseCriteria)
-> Parser (Maybe Natural) -> Parser AwsJobRateIncreaseCriteria
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
"numberOfSucceededThings")
      )

instance Prelude.Hashable AwsJobRateIncreaseCriteria

instance Prelude.NFData AwsJobRateIncreaseCriteria

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"numberOfNotifiedThings" 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
numberOfNotifiedThings,
            (Text
"numberOfSucceededThings" 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
numberOfSucceededThings
          ]
      )