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

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

-- | Configuration for the rollout of OTA updates.
--
-- /See:/ 'newAwsJobExecutionsRolloutConfig' smart constructor.
data AwsJobExecutionsRolloutConfig = AwsJobExecutionsRolloutConfig'
  { -- | The rate of increase for a job rollout. This parameter allows you to
    -- define an exponential rate increase for a job rollout.
    AwsJobExecutionsRolloutConfig -> Maybe AwsJobExponentialRolloutRate
exponentialRate :: Prelude.Maybe AwsJobExponentialRolloutRate,
    -- | The maximum number of OTA update job executions started per minute.
    AwsJobExecutionsRolloutConfig -> Maybe Natural
maximumPerMinute :: Prelude.Maybe Prelude.Natural
  }
  deriving (AwsJobExecutionsRolloutConfig
-> AwsJobExecutionsRolloutConfig -> Bool
(AwsJobExecutionsRolloutConfig
 -> AwsJobExecutionsRolloutConfig -> Bool)
-> (AwsJobExecutionsRolloutConfig
    -> AwsJobExecutionsRolloutConfig -> Bool)
-> Eq AwsJobExecutionsRolloutConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsJobExecutionsRolloutConfig
-> AwsJobExecutionsRolloutConfig -> Bool
$c/= :: AwsJobExecutionsRolloutConfig
-> AwsJobExecutionsRolloutConfig -> Bool
== :: AwsJobExecutionsRolloutConfig
-> AwsJobExecutionsRolloutConfig -> Bool
$c== :: AwsJobExecutionsRolloutConfig
-> AwsJobExecutionsRolloutConfig -> Bool
Prelude.Eq, ReadPrec [AwsJobExecutionsRolloutConfig]
ReadPrec AwsJobExecutionsRolloutConfig
Int -> ReadS AwsJobExecutionsRolloutConfig
ReadS [AwsJobExecutionsRolloutConfig]
(Int -> ReadS AwsJobExecutionsRolloutConfig)
-> ReadS [AwsJobExecutionsRolloutConfig]
-> ReadPrec AwsJobExecutionsRolloutConfig
-> ReadPrec [AwsJobExecutionsRolloutConfig]
-> Read AwsJobExecutionsRolloutConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsJobExecutionsRolloutConfig]
$creadListPrec :: ReadPrec [AwsJobExecutionsRolloutConfig]
readPrec :: ReadPrec AwsJobExecutionsRolloutConfig
$creadPrec :: ReadPrec AwsJobExecutionsRolloutConfig
readList :: ReadS [AwsJobExecutionsRolloutConfig]
$creadList :: ReadS [AwsJobExecutionsRolloutConfig]
readsPrec :: Int -> ReadS AwsJobExecutionsRolloutConfig
$creadsPrec :: Int -> ReadS AwsJobExecutionsRolloutConfig
Prelude.Read, Int -> AwsJobExecutionsRolloutConfig -> ShowS
[AwsJobExecutionsRolloutConfig] -> ShowS
AwsJobExecutionsRolloutConfig -> String
(Int -> AwsJobExecutionsRolloutConfig -> ShowS)
-> (AwsJobExecutionsRolloutConfig -> String)
-> ([AwsJobExecutionsRolloutConfig] -> ShowS)
-> Show AwsJobExecutionsRolloutConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsJobExecutionsRolloutConfig] -> ShowS
$cshowList :: [AwsJobExecutionsRolloutConfig] -> ShowS
show :: AwsJobExecutionsRolloutConfig -> String
$cshow :: AwsJobExecutionsRolloutConfig -> String
showsPrec :: Int -> AwsJobExecutionsRolloutConfig -> ShowS
$cshowsPrec :: Int -> AwsJobExecutionsRolloutConfig -> ShowS
Prelude.Show, (forall x.
 AwsJobExecutionsRolloutConfig
 -> Rep AwsJobExecutionsRolloutConfig x)
-> (forall x.
    Rep AwsJobExecutionsRolloutConfig x
    -> AwsJobExecutionsRolloutConfig)
-> Generic AwsJobExecutionsRolloutConfig
forall x.
Rep AwsJobExecutionsRolloutConfig x
-> AwsJobExecutionsRolloutConfig
forall x.
AwsJobExecutionsRolloutConfig
-> Rep AwsJobExecutionsRolloutConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsJobExecutionsRolloutConfig x
-> AwsJobExecutionsRolloutConfig
$cfrom :: forall x.
AwsJobExecutionsRolloutConfig
-> Rep AwsJobExecutionsRolloutConfig x
Prelude.Generic)

-- |
-- Create a value of 'AwsJobExecutionsRolloutConfig' 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', 'awsJobExecutionsRolloutConfig_exponentialRate' - The rate of increase for a job rollout. This parameter allows you to
-- define an exponential rate increase for a job rollout.
--
-- 'maximumPerMinute', 'awsJobExecutionsRolloutConfig_maximumPerMinute' - The maximum number of OTA update job executions started per minute.
newAwsJobExecutionsRolloutConfig ::
  AwsJobExecutionsRolloutConfig
newAwsJobExecutionsRolloutConfig :: AwsJobExecutionsRolloutConfig
newAwsJobExecutionsRolloutConfig =
  AwsJobExecutionsRolloutConfig' :: Maybe AwsJobExponentialRolloutRate
-> Maybe Natural -> AwsJobExecutionsRolloutConfig
AwsJobExecutionsRolloutConfig'
    { $sel:exponentialRate:AwsJobExecutionsRolloutConfig' :: Maybe AwsJobExponentialRolloutRate
exponentialRate =
        Maybe AwsJobExponentialRolloutRate
forall a. Maybe a
Prelude.Nothing,
      $sel:maximumPerMinute:AwsJobExecutionsRolloutConfig' :: 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 increase for a job rollout.
awsJobExecutionsRolloutConfig_exponentialRate :: Lens.Lens' AwsJobExecutionsRolloutConfig (Prelude.Maybe AwsJobExponentialRolloutRate)
awsJobExecutionsRolloutConfig_exponentialRate :: (Maybe AwsJobExponentialRolloutRate
 -> f (Maybe AwsJobExponentialRolloutRate))
-> AwsJobExecutionsRolloutConfig -> f AwsJobExecutionsRolloutConfig
awsJobExecutionsRolloutConfig_exponentialRate = (AwsJobExecutionsRolloutConfig
 -> Maybe AwsJobExponentialRolloutRate)
-> (AwsJobExecutionsRolloutConfig
    -> Maybe AwsJobExponentialRolloutRate
    -> AwsJobExecutionsRolloutConfig)
-> Lens
     AwsJobExecutionsRolloutConfig
     AwsJobExecutionsRolloutConfig
     (Maybe AwsJobExponentialRolloutRate)
     (Maybe AwsJobExponentialRolloutRate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsJobExecutionsRolloutConfig' {Maybe AwsJobExponentialRolloutRate
exponentialRate :: Maybe AwsJobExponentialRolloutRate
$sel:exponentialRate:AwsJobExecutionsRolloutConfig' :: AwsJobExecutionsRolloutConfig -> Maybe AwsJobExponentialRolloutRate
exponentialRate} -> Maybe AwsJobExponentialRolloutRate
exponentialRate) (\s :: AwsJobExecutionsRolloutConfig
s@AwsJobExecutionsRolloutConfig' {} Maybe AwsJobExponentialRolloutRate
a -> AwsJobExecutionsRolloutConfig
s {$sel:exponentialRate:AwsJobExecutionsRolloutConfig' :: Maybe AwsJobExponentialRolloutRate
exponentialRate = Maybe AwsJobExponentialRolloutRate
a} :: AwsJobExecutionsRolloutConfig)

-- | The maximum number of OTA update job executions started per minute.
awsJobExecutionsRolloutConfig_maximumPerMinute :: Lens.Lens' AwsJobExecutionsRolloutConfig (Prelude.Maybe Prelude.Natural)
awsJobExecutionsRolloutConfig_maximumPerMinute :: (Maybe Natural -> f (Maybe Natural))
-> AwsJobExecutionsRolloutConfig -> f AwsJobExecutionsRolloutConfig
awsJobExecutionsRolloutConfig_maximumPerMinute = (AwsJobExecutionsRolloutConfig -> Maybe Natural)
-> (AwsJobExecutionsRolloutConfig
    -> Maybe Natural -> AwsJobExecutionsRolloutConfig)
-> Lens
     AwsJobExecutionsRolloutConfig
     AwsJobExecutionsRolloutConfig
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsJobExecutionsRolloutConfig' {Maybe Natural
maximumPerMinute :: Maybe Natural
$sel:maximumPerMinute:AwsJobExecutionsRolloutConfig' :: AwsJobExecutionsRolloutConfig -> Maybe Natural
maximumPerMinute} -> Maybe Natural
maximumPerMinute) (\s :: AwsJobExecutionsRolloutConfig
s@AwsJobExecutionsRolloutConfig' {} Maybe Natural
a -> AwsJobExecutionsRolloutConfig
s {$sel:maximumPerMinute:AwsJobExecutionsRolloutConfig' :: Maybe Natural
maximumPerMinute = Maybe Natural
a} :: AwsJobExecutionsRolloutConfig)

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

instance Prelude.NFData AwsJobExecutionsRolloutConfig

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