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

import qualified Amazonka.Core as Core
import Amazonka.GreengrassV2.Types.IoTJobExponentialRolloutRate
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the rollout configuration for a job. This
-- configuration defines the rate at which the job deploys a configuration
-- to a fleet of target devices.
--
-- /See:/ 'newIoTJobExecutionsRolloutConfig' smart constructor.
data IoTJobExecutionsRolloutConfig = IoTJobExecutionsRolloutConfig'
  { -- | The exponential rate to increase the job rollout rate.
    IoTJobExecutionsRolloutConfig -> Maybe IoTJobExponentialRolloutRate
exponentialRate :: Prelude.Maybe IoTJobExponentialRolloutRate,
    -- | The maximum number of devices that receive a pending job notification,
    -- per minute.
    IoTJobExecutionsRolloutConfig -> Maybe Natural
maximumPerMinute :: Prelude.Maybe Prelude.Natural
  }
  deriving (IoTJobExecutionsRolloutConfig
-> IoTJobExecutionsRolloutConfig -> Bool
(IoTJobExecutionsRolloutConfig
 -> IoTJobExecutionsRolloutConfig -> Bool)
-> (IoTJobExecutionsRolloutConfig
    -> IoTJobExecutionsRolloutConfig -> Bool)
-> Eq IoTJobExecutionsRolloutConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IoTJobExecutionsRolloutConfig
-> IoTJobExecutionsRolloutConfig -> Bool
$c/= :: IoTJobExecutionsRolloutConfig
-> IoTJobExecutionsRolloutConfig -> Bool
== :: IoTJobExecutionsRolloutConfig
-> IoTJobExecutionsRolloutConfig -> Bool
$c== :: IoTJobExecutionsRolloutConfig
-> IoTJobExecutionsRolloutConfig -> Bool
Prelude.Eq, ReadPrec [IoTJobExecutionsRolloutConfig]
ReadPrec IoTJobExecutionsRolloutConfig
Int -> ReadS IoTJobExecutionsRolloutConfig
ReadS [IoTJobExecutionsRolloutConfig]
(Int -> ReadS IoTJobExecutionsRolloutConfig)
-> ReadS [IoTJobExecutionsRolloutConfig]
-> ReadPrec IoTJobExecutionsRolloutConfig
-> ReadPrec [IoTJobExecutionsRolloutConfig]
-> Read IoTJobExecutionsRolloutConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IoTJobExecutionsRolloutConfig]
$creadListPrec :: ReadPrec [IoTJobExecutionsRolloutConfig]
readPrec :: ReadPrec IoTJobExecutionsRolloutConfig
$creadPrec :: ReadPrec IoTJobExecutionsRolloutConfig
readList :: ReadS [IoTJobExecutionsRolloutConfig]
$creadList :: ReadS [IoTJobExecutionsRolloutConfig]
readsPrec :: Int -> ReadS IoTJobExecutionsRolloutConfig
$creadsPrec :: Int -> ReadS IoTJobExecutionsRolloutConfig
Prelude.Read, Int -> IoTJobExecutionsRolloutConfig -> ShowS
[IoTJobExecutionsRolloutConfig] -> ShowS
IoTJobExecutionsRolloutConfig -> String
(Int -> IoTJobExecutionsRolloutConfig -> ShowS)
-> (IoTJobExecutionsRolloutConfig -> String)
-> ([IoTJobExecutionsRolloutConfig] -> ShowS)
-> Show IoTJobExecutionsRolloutConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IoTJobExecutionsRolloutConfig] -> ShowS
$cshowList :: [IoTJobExecutionsRolloutConfig] -> ShowS
show :: IoTJobExecutionsRolloutConfig -> String
$cshow :: IoTJobExecutionsRolloutConfig -> String
showsPrec :: Int -> IoTJobExecutionsRolloutConfig -> ShowS
$cshowsPrec :: Int -> IoTJobExecutionsRolloutConfig -> ShowS
Prelude.Show, (forall x.
 IoTJobExecutionsRolloutConfig
 -> Rep IoTJobExecutionsRolloutConfig x)
-> (forall x.
    Rep IoTJobExecutionsRolloutConfig x
    -> IoTJobExecutionsRolloutConfig)
-> Generic IoTJobExecutionsRolloutConfig
forall x.
Rep IoTJobExecutionsRolloutConfig x
-> IoTJobExecutionsRolloutConfig
forall x.
IoTJobExecutionsRolloutConfig
-> Rep IoTJobExecutionsRolloutConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep IoTJobExecutionsRolloutConfig x
-> IoTJobExecutionsRolloutConfig
$cfrom :: forall x.
IoTJobExecutionsRolloutConfig
-> Rep IoTJobExecutionsRolloutConfig x
Prelude.Generic)

-- |
-- Create a value of 'IoTJobExecutionsRolloutConfig' 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:
--
-- 'exponentialRate', 'ioTJobExecutionsRolloutConfig_exponentialRate' - The exponential rate to increase the job rollout rate.
--
-- 'maximumPerMinute', 'ioTJobExecutionsRolloutConfig_maximumPerMinute' - The maximum number of devices that receive a pending job notification,
-- per minute.
newIoTJobExecutionsRolloutConfig ::
  IoTJobExecutionsRolloutConfig
newIoTJobExecutionsRolloutConfig :: IoTJobExecutionsRolloutConfig
newIoTJobExecutionsRolloutConfig =
  IoTJobExecutionsRolloutConfig' :: Maybe IoTJobExponentialRolloutRate
-> Maybe Natural -> IoTJobExecutionsRolloutConfig
IoTJobExecutionsRolloutConfig'
    { $sel:exponentialRate:IoTJobExecutionsRolloutConfig' :: Maybe IoTJobExponentialRolloutRate
exponentialRate =
        Maybe IoTJobExponentialRolloutRate
forall a. Maybe a
Prelude.Nothing,
      $sel:maximumPerMinute:IoTJobExecutionsRolloutConfig' :: Maybe Natural
maximumPerMinute = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The exponential rate to increase the job rollout rate.
ioTJobExecutionsRolloutConfig_exponentialRate :: Lens.Lens' IoTJobExecutionsRolloutConfig (Prelude.Maybe IoTJobExponentialRolloutRate)
ioTJobExecutionsRolloutConfig_exponentialRate :: (Maybe IoTJobExponentialRolloutRate
 -> f (Maybe IoTJobExponentialRolloutRate))
-> IoTJobExecutionsRolloutConfig -> f IoTJobExecutionsRolloutConfig
ioTJobExecutionsRolloutConfig_exponentialRate = (IoTJobExecutionsRolloutConfig
 -> Maybe IoTJobExponentialRolloutRate)
-> (IoTJobExecutionsRolloutConfig
    -> Maybe IoTJobExponentialRolloutRate
    -> IoTJobExecutionsRolloutConfig)
-> Lens
     IoTJobExecutionsRolloutConfig
     IoTJobExecutionsRolloutConfig
     (Maybe IoTJobExponentialRolloutRate)
     (Maybe IoTJobExponentialRolloutRate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IoTJobExecutionsRolloutConfig' {Maybe IoTJobExponentialRolloutRate
exponentialRate :: Maybe IoTJobExponentialRolloutRate
$sel:exponentialRate:IoTJobExecutionsRolloutConfig' :: IoTJobExecutionsRolloutConfig -> Maybe IoTJobExponentialRolloutRate
exponentialRate} -> Maybe IoTJobExponentialRolloutRate
exponentialRate) (\s :: IoTJobExecutionsRolloutConfig
s@IoTJobExecutionsRolloutConfig' {} Maybe IoTJobExponentialRolloutRate
a -> IoTJobExecutionsRolloutConfig
s {$sel:exponentialRate:IoTJobExecutionsRolloutConfig' :: Maybe IoTJobExponentialRolloutRate
exponentialRate = Maybe IoTJobExponentialRolloutRate
a} :: IoTJobExecutionsRolloutConfig)

-- | The maximum number of devices that receive a pending job notification,
-- per minute.
ioTJobExecutionsRolloutConfig_maximumPerMinute :: Lens.Lens' IoTJobExecutionsRolloutConfig (Prelude.Maybe Prelude.Natural)
ioTJobExecutionsRolloutConfig_maximumPerMinute :: (Maybe Natural -> f (Maybe Natural))
-> IoTJobExecutionsRolloutConfig -> f IoTJobExecutionsRolloutConfig
ioTJobExecutionsRolloutConfig_maximumPerMinute = (IoTJobExecutionsRolloutConfig -> Maybe Natural)
-> (IoTJobExecutionsRolloutConfig
    -> Maybe Natural -> IoTJobExecutionsRolloutConfig)
-> Lens
     IoTJobExecutionsRolloutConfig
     IoTJobExecutionsRolloutConfig
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IoTJobExecutionsRolloutConfig' {Maybe Natural
maximumPerMinute :: Maybe Natural
$sel:maximumPerMinute:IoTJobExecutionsRolloutConfig' :: IoTJobExecutionsRolloutConfig -> Maybe Natural
maximumPerMinute} -> Maybe Natural
maximumPerMinute) (\s :: IoTJobExecutionsRolloutConfig
s@IoTJobExecutionsRolloutConfig' {} Maybe Natural
a -> IoTJobExecutionsRolloutConfig
s {$sel:maximumPerMinute:IoTJobExecutionsRolloutConfig' :: Maybe Natural
maximumPerMinute = Maybe Natural
a} :: IoTJobExecutionsRolloutConfig)

instance Core.FromJSON IoTJobExecutionsRolloutConfig where
  parseJSON :: Value -> Parser IoTJobExecutionsRolloutConfig
parseJSON =
    String
-> (Object -> Parser IoTJobExecutionsRolloutConfig)
-> Value
-> Parser IoTJobExecutionsRolloutConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"IoTJobExecutionsRolloutConfig"
      ( \Object
x ->
          Maybe IoTJobExponentialRolloutRate
-> Maybe Natural -> IoTJobExecutionsRolloutConfig
IoTJobExecutionsRolloutConfig'
            (Maybe IoTJobExponentialRolloutRate
 -> Maybe Natural -> IoTJobExecutionsRolloutConfig)
-> Parser (Maybe IoTJobExponentialRolloutRate)
-> Parser (Maybe Natural -> IoTJobExecutionsRolloutConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe IoTJobExponentialRolloutRate)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"exponentialRate")
            Parser (Maybe Natural -> IoTJobExecutionsRolloutConfig)
-> Parser (Maybe Natural) -> Parser IoTJobExecutionsRolloutConfig
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
"maximumPerMinute")
      )

instance
  Prelude.Hashable
    IoTJobExecutionsRolloutConfig

instance Prelude.NFData IoTJobExecutionsRolloutConfig

instance Core.ToJSON IoTJobExecutionsRolloutConfig where
  toJSON :: IoTJobExecutionsRolloutConfig -> Value
toJSON IoTJobExecutionsRolloutConfig' {Maybe Natural
Maybe IoTJobExponentialRolloutRate
maximumPerMinute :: Maybe Natural
exponentialRate :: Maybe IoTJobExponentialRolloutRate
$sel:maximumPerMinute:IoTJobExecutionsRolloutConfig' :: IoTJobExecutionsRolloutConfig -> Maybe Natural
$sel:exponentialRate:IoTJobExecutionsRolloutConfig' :: IoTJobExecutionsRolloutConfig -> Maybe IoTJobExponentialRolloutRate
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"exponentialRate" Text -> IoTJobExponentialRolloutRate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (IoTJobExponentialRolloutRate -> Pair)
-> Maybe IoTJobExponentialRolloutRate -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe IoTJobExponentialRolloutRate
exponentialRate,
            (Text
"maximumPerMinute" 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
maximumPerMinute
          ]
      )