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

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.ExponentialRolloutRate
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Allows you to create a staged rollout of a job.
--
-- /See:/ 'newJobExecutionsRolloutConfig' smart constructor.
data JobExecutionsRolloutConfig = JobExecutionsRolloutConfig'
  { -- | The rate of increase for a job rollout. This parameter allows you to
    -- define an exponential rate for a job rollout.
    JobExecutionsRolloutConfig -> Maybe ExponentialRolloutRate
exponentialRate :: Prelude.Maybe ExponentialRolloutRate,
    -- | The maximum number of things that will be notified of a pending job, per
    -- minute. This parameter allows you to create a staged rollout.
    JobExecutionsRolloutConfig -> Maybe Natural
maximumPerMinute :: Prelude.Maybe Prelude.Natural
  }
  deriving (JobExecutionsRolloutConfig -> JobExecutionsRolloutConfig -> Bool
(JobExecutionsRolloutConfig -> JobExecutionsRolloutConfig -> Bool)
-> (JobExecutionsRolloutConfig
    -> JobExecutionsRolloutConfig -> Bool)
-> Eq JobExecutionsRolloutConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JobExecutionsRolloutConfig -> JobExecutionsRolloutConfig -> Bool
$c/= :: JobExecutionsRolloutConfig -> JobExecutionsRolloutConfig -> Bool
== :: JobExecutionsRolloutConfig -> JobExecutionsRolloutConfig -> Bool
$c== :: JobExecutionsRolloutConfig -> JobExecutionsRolloutConfig -> Bool
Prelude.Eq, ReadPrec [JobExecutionsRolloutConfig]
ReadPrec JobExecutionsRolloutConfig
Int -> ReadS JobExecutionsRolloutConfig
ReadS [JobExecutionsRolloutConfig]
(Int -> ReadS JobExecutionsRolloutConfig)
-> ReadS [JobExecutionsRolloutConfig]
-> ReadPrec JobExecutionsRolloutConfig
-> ReadPrec [JobExecutionsRolloutConfig]
-> Read JobExecutionsRolloutConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JobExecutionsRolloutConfig]
$creadListPrec :: ReadPrec [JobExecutionsRolloutConfig]
readPrec :: ReadPrec JobExecutionsRolloutConfig
$creadPrec :: ReadPrec JobExecutionsRolloutConfig
readList :: ReadS [JobExecutionsRolloutConfig]
$creadList :: ReadS [JobExecutionsRolloutConfig]
readsPrec :: Int -> ReadS JobExecutionsRolloutConfig
$creadsPrec :: Int -> ReadS JobExecutionsRolloutConfig
Prelude.Read, Int -> JobExecutionsRolloutConfig -> ShowS
[JobExecutionsRolloutConfig] -> ShowS
JobExecutionsRolloutConfig -> String
(Int -> JobExecutionsRolloutConfig -> ShowS)
-> (JobExecutionsRolloutConfig -> String)
-> ([JobExecutionsRolloutConfig] -> ShowS)
-> Show JobExecutionsRolloutConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JobExecutionsRolloutConfig] -> ShowS
$cshowList :: [JobExecutionsRolloutConfig] -> ShowS
show :: JobExecutionsRolloutConfig -> String
$cshow :: JobExecutionsRolloutConfig -> String
showsPrec :: Int -> JobExecutionsRolloutConfig -> ShowS
$cshowsPrec :: Int -> JobExecutionsRolloutConfig -> ShowS
Prelude.Show, (forall x.
 JobExecutionsRolloutConfig -> Rep JobExecutionsRolloutConfig x)
-> (forall x.
    Rep JobExecutionsRolloutConfig x -> JobExecutionsRolloutConfig)
-> Generic JobExecutionsRolloutConfig
forall x.
Rep JobExecutionsRolloutConfig x -> JobExecutionsRolloutConfig
forall x.
JobExecutionsRolloutConfig -> Rep JobExecutionsRolloutConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep JobExecutionsRolloutConfig x -> JobExecutionsRolloutConfig
$cfrom :: forall x.
JobExecutionsRolloutConfig -> Rep JobExecutionsRolloutConfig x
Prelude.Generic)

-- |
-- Create a value of 'JobExecutionsRolloutConfig' 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', 'jobExecutionsRolloutConfig_exponentialRate' - The rate of increase for a job rollout. This parameter allows you to
-- define an exponential rate for a job rollout.
--
-- 'maximumPerMinute', 'jobExecutionsRolloutConfig_maximumPerMinute' - The maximum number of things that will be notified of a pending job, per
-- minute. This parameter allows you to create a staged rollout.
newJobExecutionsRolloutConfig ::
  JobExecutionsRolloutConfig
newJobExecutionsRolloutConfig :: JobExecutionsRolloutConfig
newJobExecutionsRolloutConfig =
  JobExecutionsRolloutConfig' :: Maybe ExponentialRolloutRate
-> Maybe Natural -> JobExecutionsRolloutConfig
JobExecutionsRolloutConfig'
    { $sel:exponentialRate:JobExecutionsRolloutConfig' :: Maybe ExponentialRolloutRate
exponentialRate =
        Maybe ExponentialRolloutRate
forall a. Maybe a
Prelude.Nothing,
      $sel:maximumPerMinute:JobExecutionsRolloutConfig' :: Maybe Natural
maximumPerMinute = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The rate of increase for a job rollout. This parameter allows you to
-- define an exponential rate for a job rollout.
jobExecutionsRolloutConfig_exponentialRate :: Lens.Lens' JobExecutionsRolloutConfig (Prelude.Maybe ExponentialRolloutRate)
jobExecutionsRolloutConfig_exponentialRate :: (Maybe ExponentialRolloutRate -> f (Maybe ExponentialRolloutRate))
-> JobExecutionsRolloutConfig -> f JobExecutionsRolloutConfig
jobExecutionsRolloutConfig_exponentialRate = (JobExecutionsRolloutConfig -> Maybe ExponentialRolloutRate)
-> (JobExecutionsRolloutConfig
    -> Maybe ExponentialRolloutRate -> JobExecutionsRolloutConfig)
-> Lens
     JobExecutionsRolloutConfig
     JobExecutionsRolloutConfig
     (Maybe ExponentialRolloutRate)
     (Maybe ExponentialRolloutRate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobExecutionsRolloutConfig' {Maybe ExponentialRolloutRate
exponentialRate :: Maybe ExponentialRolloutRate
$sel:exponentialRate:JobExecutionsRolloutConfig' :: JobExecutionsRolloutConfig -> Maybe ExponentialRolloutRate
exponentialRate} -> Maybe ExponentialRolloutRate
exponentialRate) (\s :: JobExecutionsRolloutConfig
s@JobExecutionsRolloutConfig' {} Maybe ExponentialRolloutRate
a -> JobExecutionsRolloutConfig
s {$sel:exponentialRate:JobExecutionsRolloutConfig' :: Maybe ExponentialRolloutRate
exponentialRate = Maybe ExponentialRolloutRate
a} :: JobExecutionsRolloutConfig)

-- | The maximum number of things that will be notified of a pending job, per
-- minute. This parameter allows you to create a staged rollout.
jobExecutionsRolloutConfig_maximumPerMinute :: Lens.Lens' JobExecutionsRolloutConfig (Prelude.Maybe Prelude.Natural)
jobExecutionsRolloutConfig_maximumPerMinute :: (Maybe Natural -> f (Maybe Natural))
-> JobExecutionsRolloutConfig -> f JobExecutionsRolloutConfig
jobExecutionsRolloutConfig_maximumPerMinute = (JobExecutionsRolloutConfig -> Maybe Natural)
-> (JobExecutionsRolloutConfig
    -> Maybe Natural -> JobExecutionsRolloutConfig)
-> Lens
     JobExecutionsRolloutConfig
     JobExecutionsRolloutConfig
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobExecutionsRolloutConfig' {Maybe Natural
maximumPerMinute :: Maybe Natural
$sel:maximumPerMinute:JobExecutionsRolloutConfig' :: JobExecutionsRolloutConfig -> Maybe Natural
maximumPerMinute} -> Maybe Natural
maximumPerMinute) (\s :: JobExecutionsRolloutConfig
s@JobExecutionsRolloutConfig' {} Maybe Natural
a -> JobExecutionsRolloutConfig
s {$sel:maximumPerMinute:JobExecutionsRolloutConfig' :: Maybe Natural
maximumPerMinute = Maybe Natural
a} :: JobExecutionsRolloutConfig)

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

instance Prelude.NFData JobExecutionsRolloutConfig

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