{-# 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.GreengrassV2.Types.IoTJobRateIncreaseCriteria
-- 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.GreengrassV2.Types.IoTJobRateIncreaseCriteria where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about criteria to meet before a job increases its
-- rollout rate. Specify either @numberOfNotifiedThings@ or
-- @numberOfSucceededThings@.
--
-- /See:/ 'newIoTJobRateIncreaseCriteria' smart constructor.
data IoTJobRateIncreaseCriteria = IoTJobRateIncreaseCriteria'
  { -- | The number of devices to receive the job notification before the rollout
    -- rate increases.
    IoTJobRateIncreaseCriteria -> Maybe Natural
numberOfNotifiedThings :: Prelude.Maybe Prelude.Natural,
    -- | The number of devices to successfully run the configuration job before
    -- the rollout rate increases.
    IoTJobRateIncreaseCriteria -> Maybe Natural
numberOfSucceededThings :: Prelude.Maybe Prelude.Natural
  }
  deriving (IoTJobRateIncreaseCriteria -> IoTJobRateIncreaseCriteria -> Bool
(IoTJobRateIncreaseCriteria -> IoTJobRateIncreaseCriteria -> Bool)
-> (IoTJobRateIncreaseCriteria
    -> IoTJobRateIncreaseCriteria -> Bool)
-> Eq IoTJobRateIncreaseCriteria
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IoTJobRateIncreaseCriteria -> IoTJobRateIncreaseCriteria -> Bool
$c/= :: IoTJobRateIncreaseCriteria -> IoTJobRateIncreaseCriteria -> Bool
== :: IoTJobRateIncreaseCriteria -> IoTJobRateIncreaseCriteria -> Bool
$c== :: IoTJobRateIncreaseCriteria -> IoTJobRateIncreaseCriteria -> Bool
Prelude.Eq, ReadPrec [IoTJobRateIncreaseCriteria]
ReadPrec IoTJobRateIncreaseCriteria
Int -> ReadS IoTJobRateIncreaseCriteria
ReadS [IoTJobRateIncreaseCriteria]
(Int -> ReadS IoTJobRateIncreaseCriteria)
-> ReadS [IoTJobRateIncreaseCriteria]
-> ReadPrec IoTJobRateIncreaseCriteria
-> ReadPrec [IoTJobRateIncreaseCriteria]
-> Read IoTJobRateIncreaseCriteria
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IoTJobRateIncreaseCriteria]
$creadListPrec :: ReadPrec [IoTJobRateIncreaseCriteria]
readPrec :: ReadPrec IoTJobRateIncreaseCriteria
$creadPrec :: ReadPrec IoTJobRateIncreaseCriteria
readList :: ReadS [IoTJobRateIncreaseCriteria]
$creadList :: ReadS [IoTJobRateIncreaseCriteria]
readsPrec :: Int -> ReadS IoTJobRateIncreaseCriteria
$creadsPrec :: Int -> ReadS IoTJobRateIncreaseCriteria
Prelude.Read, Int -> IoTJobRateIncreaseCriteria -> ShowS
[IoTJobRateIncreaseCriteria] -> ShowS
IoTJobRateIncreaseCriteria -> String
(Int -> IoTJobRateIncreaseCriteria -> ShowS)
-> (IoTJobRateIncreaseCriteria -> String)
-> ([IoTJobRateIncreaseCriteria] -> ShowS)
-> Show IoTJobRateIncreaseCriteria
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IoTJobRateIncreaseCriteria] -> ShowS
$cshowList :: [IoTJobRateIncreaseCriteria] -> ShowS
show :: IoTJobRateIncreaseCriteria -> String
$cshow :: IoTJobRateIncreaseCriteria -> String
showsPrec :: Int -> IoTJobRateIncreaseCriteria -> ShowS
$cshowsPrec :: Int -> IoTJobRateIncreaseCriteria -> ShowS
Prelude.Show, (forall x.
 IoTJobRateIncreaseCriteria -> Rep IoTJobRateIncreaseCriteria x)
-> (forall x.
    Rep IoTJobRateIncreaseCriteria x -> IoTJobRateIncreaseCriteria)
-> Generic IoTJobRateIncreaseCriteria
forall x.
Rep IoTJobRateIncreaseCriteria x -> IoTJobRateIncreaseCriteria
forall x.
IoTJobRateIncreaseCriteria -> Rep IoTJobRateIncreaseCriteria x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep IoTJobRateIncreaseCriteria x -> IoTJobRateIncreaseCriteria
$cfrom :: forall x.
IoTJobRateIncreaseCriteria -> Rep IoTJobRateIncreaseCriteria x
Prelude.Generic)

-- |
-- Create a value of 'IoTJobRateIncreaseCriteria' 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', 'ioTJobRateIncreaseCriteria_numberOfNotifiedThings' - The number of devices to receive the job notification before the rollout
-- rate increases.
--
-- 'numberOfSucceededThings', 'ioTJobRateIncreaseCriteria_numberOfSucceededThings' - The number of devices to successfully run the configuration job before
-- the rollout rate increases.
newIoTJobRateIncreaseCriteria ::
  IoTJobRateIncreaseCriteria
newIoTJobRateIncreaseCriteria :: IoTJobRateIncreaseCriteria
newIoTJobRateIncreaseCriteria =
  IoTJobRateIncreaseCriteria' :: Maybe Natural -> Maybe Natural -> IoTJobRateIncreaseCriteria
IoTJobRateIncreaseCriteria'
    { $sel:numberOfNotifiedThings:IoTJobRateIncreaseCriteria' :: Maybe Natural
numberOfNotifiedThings =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:numberOfSucceededThings:IoTJobRateIncreaseCriteria' :: Maybe Natural
numberOfSucceededThings = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The number of devices to receive the job notification before the rollout
-- rate increases.
ioTJobRateIncreaseCriteria_numberOfNotifiedThings :: Lens.Lens' IoTJobRateIncreaseCriteria (Prelude.Maybe Prelude.Natural)
ioTJobRateIncreaseCriteria_numberOfNotifiedThings :: (Maybe Natural -> f (Maybe Natural))
-> IoTJobRateIncreaseCriteria -> f IoTJobRateIncreaseCriteria
ioTJobRateIncreaseCriteria_numberOfNotifiedThings = (IoTJobRateIncreaseCriteria -> Maybe Natural)
-> (IoTJobRateIncreaseCriteria
    -> Maybe Natural -> IoTJobRateIncreaseCriteria)
-> Lens
     IoTJobRateIncreaseCriteria
     IoTJobRateIncreaseCriteria
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IoTJobRateIncreaseCriteria' {Maybe Natural
numberOfNotifiedThings :: Maybe Natural
$sel:numberOfNotifiedThings:IoTJobRateIncreaseCriteria' :: IoTJobRateIncreaseCriteria -> Maybe Natural
numberOfNotifiedThings} -> Maybe Natural
numberOfNotifiedThings) (\s :: IoTJobRateIncreaseCriteria
s@IoTJobRateIncreaseCriteria' {} Maybe Natural
a -> IoTJobRateIncreaseCriteria
s {$sel:numberOfNotifiedThings:IoTJobRateIncreaseCriteria' :: Maybe Natural
numberOfNotifiedThings = Maybe Natural
a} :: IoTJobRateIncreaseCriteria)

-- | The number of devices to successfully run the configuration job before
-- the rollout rate increases.
ioTJobRateIncreaseCriteria_numberOfSucceededThings :: Lens.Lens' IoTJobRateIncreaseCriteria (Prelude.Maybe Prelude.Natural)
ioTJobRateIncreaseCriteria_numberOfSucceededThings :: (Maybe Natural -> f (Maybe Natural))
-> IoTJobRateIncreaseCriteria -> f IoTJobRateIncreaseCriteria
ioTJobRateIncreaseCriteria_numberOfSucceededThings = (IoTJobRateIncreaseCriteria -> Maybe Natural)
-> (IoTJobRateIncreaseCriteria
    -> Maybe Natural -> IoTJobRateIncreaseCriteria)
-> Lens
     IoTJobRateIncreaseCriteria
     IoTJobRateIncreaseCriteria
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IoTJobRateIncreaseCriteria' {Maybe Natural
numberOfSucceededThings :: Maybe Natural
$sel:numberOfSucceededThings:IoTJobRateIncreaseCriteria' :: IoTJobRateIncreaseCriteria -> Maybe Natural
numberOfSucceededThings} -> Maybe Natural
numberOfSucceededThings) (\s :: IoTJobRateIncreaseCriteria
s@IoTJobRateIncreaseCriteria' {} Maybe Natural
a -> IoTJobRateIncreaseCriteria
s {$sel:numberOfSucceededThings:IoTJobRateIncreaseCriteria' :: Maybe Natural
numberOfSucceededThings = Maybe Natural
a} :: IoTJobRateIncreaseCriteria)

instance Core.FromJSON IoTJobRateIncreaseCriteria where
  parseJSON :: Value -> Parser IoTJobRateIncreaseCriteria
parseJSON =
    String
-> (Object -> Parser IoTJobRateIncreaseCriteria)
-> Value
-> Parser IoTJobRateIncreaseCriteria
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"IoTJobRateIncreaseCriteria"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> IoTJobRateIncreaseCriteria
IoTJobRateIncreaseCriteria'
            (Maybe Natural -> Maybe Natural -> IoTJobRateIncreaseCriteria)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> IoTJobRateIncreaseCriteria)
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 -> IoTJobRateIncreaseCriteria)
-> Parser (Maybe Natural) -> Parser IoTJobRateIncreaseCriteria
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 IoTJobRateIncreaseCriteria

instance Prelude.NFData IoTJobRateIncreaseCriteria

instance Core.ToJSON IoTJobRateIncreaseCriteria where
  toJSON :: IoTJobRateIncreaseCriteria -> Value
toJSON IoTJobRateIncreaseCriteria' {Maybe Natural
numberOfSucceededThings :: Maybe Natural
numberOfNotifiedThings :: Maybe Natural
$sel:numberOfSucceededThings:IoTJobRateIncreaseCriteria' :: IoTJobRateIncreaseCriteria -> Maybe Natural
$sel:numberOfNotifiedThings:IoTJobRateIncreaseCriteria' :: IoTJobRateIncreaseCriteria -> 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
          ]
      )