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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT.Types.AwsJobExponentialRolloutRate
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
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]
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
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.
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'
    { $sel:exponentialRate:AwsJobExecutionsRolloutConfig' :: Maybe AwsJobExponentialRolloutRate
exponentialRate =
        forall a. Maybe a
Prelude.Nothing,
      $sel:maximumPerMinute:AwsJobExecutionsRolloutConfig' :: Maybe Natural
maximumPerMinute = 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 :: Lens'
  AwsJobExecutionsRolloutConfig (Maybe AwsJobExponentialRolloutRate)
awsJobExecutionsRolloutConfig_exponentialRate = 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 :: Lens' AwsJobExecutionsRolloutConfig (Maybe Natural)
awsJobExecutionsRolloutConfig_maximumPerMinute = 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 Data.FromJSON AwsJobExecutionsRolloutConfig where
  parseJSON :: Value -> Parser AwsJobExecutionsRolloutConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AwsJobExecutionsRolloutConfig"
      ( \Object
x ->
          Maybe AwsJobExponentialRolloutRate
-> Maybe Natural -> AwsJobExecutionsRolloutConfig
AwsJobExecutionsRolloutConfig'
            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
"exponentialRate")
            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
"maximumPerMinute")
      )

instance
  Prelude.Hashable
    AwsJobExecutionsRolloutConfig
  where
  hashWithSalt :: Int -> AwsJobExecutionsRolloutConfig -> Int
hashWithSalt Int
_salt AwsJobExecutionsRolloutConfig' {Maybe Natural
Maybe AwsJobExponentialRolloutRate
maximumPerMinute :: Maybe Natural
exponentialRate :: Maybe AwsJobExponentialRolloutRate
$sel:maximumPerMinute:AwsJobExecutionsRolloutConfig' :: AwsJobExecutionsRolloutConfig -> Maybe Natural
$sel:exponentialRate:AwsJobExecutionsRolloutConfig' :: AwsJobExecutionsRolloutConfig -> Maybe AwsJobExponentialRolloutRate
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AwsJobExponentialRolloutRate
exponentialRate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maximumPerMinute

instance Prelude.NFData AwsJobExecutionsRolloutConfig where
  rnf :: AwsJobExecutionsRolloutConfig -> ()
rnf AwsJobExecutionsRolloutConfig' {Maybe Natural
Maybe AwsJobExponentialRolloutRate
maximumPerMinute :: Maybe Natural
exponentialRate :: Maybe AwsJobExponentialRolloutRate
$sel:maximumPerMinute:AwsJobExecutionsRolloutConfig' :: AwsJobExecutionsRolloutConfig -> Maybe Natural
$sel:exponentialRate:AwsJobExecutionsRolloutConfig' :: AwsJobExecutionsRolloutConfig -> Maybe AwsJobExponentialRolloutRate
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AwsJobExponentialRolloutRate
exponentialRate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maximumPerMinute

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"exponentialRate" 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 AwsJobExponentialRolloutRate
exponentialRate,
            (Key
"maximumPerMinute" 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
maximumPerMinute
          ]
      )