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

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

-- |
-- Create a value of 'RateIncreaseCriteria' 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', 'rateIncreaseCriteria_numberOfNotifiedThings' - The threshold for number of notified things that will initiate the
-- increase in rate of rollout.
--
-- 'numberOfSucceededThings', 'rateIncreaseCriteria_numberOfSucceededThings' - The threshold for number of succeeded things that will initiate the
-- increase in rate of rollout.
newRateIncreaseCriteria ::
  RateIncreaseCriteria
newRateIncreaseCriteria :: RateIncreaseCriteria
newRateIncreaseCriteria =
  RateIncreaseCriteria'
    { $sel:numberOfNotifiedThings:RateIncreaseCriteria' :: Maybe Natural
numberOfNotifiedThings =
        forall a. Maybe a
Prelude.Nothing,
      $sel:numberOfSucceededThings:RateIncreaseCriteria' :: Maybe Natural
numberOfSucceededThings = forall a. Maybe a
Prelude.Nothing
    }

-- | The threshold for number of notified things that will initiate the
-- increase in rate of rollout.
rateIncreaseCriteria_numberOfNotifiedThings :: Lens.Lens' RateIncreaseCriteria (Prelude.Maybe Prelude.Natural)
rateIncreaseCriteria_numberOfNotifiedThings :: Lens' RateIncreaseCriteria (Maybe Natural)
rateIncreaseCriteria_numberOfNotifiedThings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RateIncreaseCriteria' {Maybe Natural
numberOfNotifiedThings :: Maybe Natural
$sel:numberOfNotifiedThings:RateIncreaseCriteria' :: RateIncreaseCriteria -> Maybe Natural
numberOfNotifiedThings} -> Maybe Natural
numberOfNotifiedThings) (\s :: RateIncreaseCriteria
s@RateIncreaseCriteria' {} Maybe Natural
a -> RateIncreaseCriteria
s {$sel:numberOfNotifiedThings:RateIncreaseCriteria' :: Maybe Natural
numberOfNotifiedThings = Maybe Natural
a} :: RateIncreaseCriteria)

-- | The threshold for number of succeeded things that will initiate the
-- increase in rate of rollout.
rateIncreaseCriteria_numberOfSucceededThings :: Lens.Lens' RateIncreaseCriteria (Prelude.Maybe Prelude.Natural)
rateIncreaseCriteria_numberOfSucceededThings :: Lens' RateIncreaseCriteria (Maybe Natural)
rateIncreaseCriteria_numberOfSucceededThings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RateIncreaseCriteria' {Maybe Natural
numberOfSucceededThings :: Maybe Natural
$sel:numberOfSucceededThings:RateIncreaseCriteria' :: RateIncreaseCriteria -> Maybe Natural
numberOfSucceededThings} -> Maybe Natural
numberOfSucceededThings) (\s :: RateIncreaseCriteria
s@RateIncreaseCriteria' {} Maybe Natural
a -> RateIncreaseCriteria
s {$sel:numberOfSucceededThings:RateIncreaseCriteria' :: Maybe Natural
numberOfSucceededThings = Maybe Natural
a} :: RateIncreaseCriteria)

instance Data.FromJSON RateIncreaseCriteria where
  parseJSON :: Value -> Parser RateIncreaseCriteria
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RateIncreaseCriteria"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> RateIncreaseCriteria
RateIncreaseCriteria'
            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 RateIncreaseCriteria where
  hashWithSalt :: Int -> RateIncreaseCriteria -> Int
hashWithSalt Int
_salt RateIncreaseCriteria' {Maybe Natural
numberOfSucceededThings :: Maybe Natural
numberOfNotifiedThings :: Maybe Natural
$sel:numberOfSucceededThings:RateIncreaseCriteria' :: RateIncreaseCriteria -> Maybe Natural
$sel:numberOfNotifiedThings:RateIncreaseCriteria' :: RateIncreaseCriteria -> 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 RateIncreaseCriteria where
  rnf :: RateIncreaseCriteria -> ()
rnf RateIncreaseCriteria' {Maybe Natural
numberOfSucceededThings :: Maybe Natural
numberOfNotifiedThings :: Maybe Natural
$sel:numberOfSucceededThings:RateIncreaseCriteria' :: RateIncreaseCriteria -> Maybe Natural
$sel:numberOfNotifiedThings:RateIncreaseCriteria' :: RateIncreaseCriteria -> 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 RateIncreaseCriteria where
  toJSON :: RateIncreaseCriteria -> Value
toJSON RateIncreaseCriteria' {Maybe Natural
numberOfSucceededThings :: Maybe Natural
numberOfNotifiedThings :: Maybe Natural
$sel:numberOfSucceededThings:RateIncreaseCriteria' :: RateIncreaseCriteria -> Maybe Natural
$sel:numberOfNotifiedThings:RateIncreaseCriteria' :: RateIncreaseCriteria -> 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
          ]
      )