{-# 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.AwsJobExponentialRolloutRate
-- 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.AwsJobExponentialRolloutRate 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.AwsJobRateIncreaseCriteria
import qualified Amazonka.Prelude as Prelude

-- | The rate of increase for a job rollout. This parameter allows you to
-- define an exponential rate increase for a job rollout.
--
-- /See:/ 'newAwsJobExponentialRolloutRate' smart constructor.
data AwsJobExponentialRolloutRate = AwsJobExponentialRolloutRate'
  { -- | The minimum number of things that will be notified of a pending job, per
    -- minute, at the start of the job rollout. This is the initial rate of the
    -- rollout.
    AwsJobExponentialRolloutRate -> Natural
baseRatePerMinute :: Prelude.Natural,
    -- | The rate of increase for a job rollout. The number of things notified is
    -- multiplied by this factor.
    AwsJobExponentialRolloutRate -> Double
incrementFactor :: Prelude.Double,
    -- | The criteria to initiate the increase in rate of rollout for a job.
    --
    -- Amazon Web Services IoT Core supports up to one digit after the decimal
    -- (for example, 1.5, but not 1.55).
    AwsJobExponentialRolloutRate -> AwsJobRateIncreaseCriteria
rateIncreaseCriteria :: AwsJobRateIncreaseCriteria
  }
  deriving (AwsJobExponentialRolloutRate
-> AwsJobExponentialRolloutRate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsJobExponentialRolloutRate
-> AwsJobExponentialRolloutRate -> Bool
$c/= :: AwsJobExponentialRolloutRate
-> AwsJobExponentialRolloutRate -> Bool
== :: AwsJobExponentialRolloutRate
-> AwsJobExponentialRolloutRate -> Bool
$c== :: AwsJobExponentialRolloutRate
-> AwsJobExponentialRolloutRate -> Bool
Prelude.Eq, ReadPrec [AwsJobExponentialRolloutRate]
ReadPrec AwsJobExponentialRolloutRate
Int -> ReadS AwsJobExponentialRolloutRate
ReadS [AwsJobExponentialRolloutRate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsJobExponentialRolloutRate]
$creadListPrec :: ReadPrec [AwsJobExponentialRolloutRate]
readPrec :: ReadPrec AwsJobExponentialRolloutRate
$creadPrec :: ReadPrec AwsJobExponentialRolloutRate
readList :: ReadS [AwsJobExponentialRolloutRate]
$creadList :: ReadS [AwsJobExponentialRolloutRate]
readsPrec :: Int -> ReadS AwsJobExponentialRolloutRate
$creadsPrec :: Int -> ReadS AwsJobExponentialRolloutRate
Prelude.Read, Int -> AwsJobExponentialRolloutRate -> ShowS
[AwsJobExponentialRolloutRate] -> ShowS
AwsJobExponentialRolloutRate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsJobExponentialRolloutRate] -> ShowS
$cshowList :: [AwsJobExponentialRolloutRate] -> ShowS
show :: AwsJobExponentialRolloutRate -> String
$cshow :: AwsJobExponentialRolloutRate -> String
showsPrec :: Int -> AwsJobExponentialRolloutRate -> ShowS
$cshowsPrec :: Int -> AwsJobExponentialRolloutRate -> ShowS
Prelude.Show, forall x.
Rep AwsJobExponentialRolloutRate x -> AwsJobExponentialRolloutRate
forall x.
AwsJobExponentialRolloutRate -> Rep AwsJobExponentialRolloutRate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsJobExponentialRolloutRate x -> AwsJobExponentialRolloutRate
$cfrom :: forall x.
AwsJobExponentialRolloutRate -> Rep AwsJobExponentialRolloutRate x
Prelude.Generic)

-- |
-- Create a value of 'AwsJobExponentialRolloutRate' 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:
--
-- 'baseRatePerMinute', 'awsJobExponentialRolloutRate_baseRatePerMinute' - The minimum number of things that will be notified of a pending job, per
-- minute, at the start of the job rollout. This is the initial rate of the
-- rollout.
--
-- 'incrementFactor', 'awsJobExponentialRolloutRate_incrementFactor' - The rate of increase for a job rollout. The number of things notified is
-- multiplied by this factor.
--
-- 'rateIncreaseCriteria', 'awsJobExponentialRolloutRate_rateIncreaseCriteria' - The criteria to initiate the increase in rate of rollout for a job.
--
-- Amazon Web Services IoT Core supports up to one digit after the decimal
-- (for example, 1.5, but not 1.55).
newAwsJobExponentialRolloutRate ::
  -- | 'baseRatePerMinute'
  Prelude.Natural ->
  -- | 'incrementFactor'
  Prelude.Double ->
  -- | 'rateIncreaseCriteria'
  AwsJobRateIncreaseCriteria ->
  AwsJobExponentialRolloutRate
newAwsJobExponentialRolloutRate :: Natural
-> Double
-> AwsJobRateIncreaseCriteria
-> AwsJobExponentialRolloutRate
newAwsJobExponentialRolloutRate
  Natural
pBaseRatePerMinute_
  Double
pIncrementFactor_
  AwsJobRateIncreaseCriteria
pRateIncreaseCriteria_ =
    AwsJobExponentialRolloutRate'
      { $sel:baseRatePerMinute:AwsJobExponentialRolloutRate' :: Natural
baseRatePerMinute =
          Natural
pBaseRatePerMinute_,
        $sel:incrementFactor:AwsJobExponentialRolloutRate' :: Double
incrementFactor = Double
pIncrementFactor_,
        $sel:rateIncreaseCriteria:AwsJobExponentialRolloutRate' :: AwsJobRateIncreaseCriteria
rateIncreaseCriteria = AwsJobRateIncreaseCriteria
pRateIncreaseCriteria_
      }

-- | The minimum number of things that will be notified of a pending job, per
-- minute, at the start of the job rollout. This is the initial rate of the
-- rollout.
awsJobExponentialRolloutRate_baseRatePerMinute :: Lens.Lens' AwsJobExponentialRolloutRate Prelude.Natural
awsJobExponentialRolloutRate_baseRatePerMinute :: Lens' AwsJobExponentialRolloutRate Natural
awsJobExponentialRolloutRate_baseRatePerMinute = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsJobExponentialRolloutRate' {Natural
baseRatePerMinute :: Natural
$sel:baseRatePerMinute:AwsJobExponentialRolloutRate' :: AwsJobExponentialRolloutRate -> Natural
baseRatePerMinute} -> Natural
baseRatePerMinute) (\s :: AwsJobExponentialRolloutRate
s@AwsJobExponentialRolloutRate' {} Natural
a -> AwsJobExponentialRolloutRate
s {$sel:baseRatePerMinute:AwsJobExponentialRolloutRate' :: Natural
baseRatePerMinute = Natural
a} :: AwsJobExponentialRolloutRate)

-- | The rate of increase for a job rollout. The number of things notified is
-- multiplied by this factor.
awsJobExponentialRolloutRate_incrementFactor :: Lens.Lens' AwsJobExponentialRolloutRate Prelude.Double
awsJobExponentialRolloutRate_incrementFactor :: Lens' AwsJobExponentialRolloutRate Double
awsJobExponentialRolloutRate_incrementFactor = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsJobExponentialRolloutRate' {Double
incrementFactor :: Double
$sel:incrementFactor:AwsJobExponentialRolloutRate' :: AwsJobExponentialRolloutRate -> Double
incrementFactor} -> Double
incrementFactor) (\s :: AwsJobExponentialRolloutRate
s@AwsJobExponentialRolloutRate' {} Double
a -> AwsJobExponentialRolloutRate
s {$sel:incrementFactor:AwsJobExponentialRolloutRate' :: Double
incrementFactor = Double
a} :: AwsJobExponentialRolloutRate)

-- | The criteria to initiate the increase in rate of rollout for a job.
--
-- Amazon Web Services IoT Core supports up to one digit after the decimal
-- (for example, 1.5, but not 1.55).
awsJobExponentialRolloutRate_rateIncreaseCriteria :: Lens.Lens' AwsJobExponentialRolloutRate AwsJobRateIncreaseCriteria
awsJobExponentialRolloutRate_rateIncreaseCriteria :: Lens' AwsJobExponentialRolloutRate AwsJobRateIncreaseCriteria
awsJobExponentialRolloutRate_rateIncreaseCriteria = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsJobExponentialRolloutRate' {AwsJobRateIncreaseCriteria
rateIncreaseCriteria :: AwsJobRateIncreaseCriteria
$sel:rateIncreaseCriteria:AwsJobExponentialRolloutRate' :: AwsJobExponentialRolloutRate -> AwsJobRateIncreaseCriteria
rateIncreaseCriteria} -> AwsJobRateIncreaseCriteria
rateIncreaseCriteria) (\s :: AwsJobExponentialRolloutRate
s@AwsJobExponentialRolloutRate' {} AwsJobRateIncreaseCriteria
a -> AwsJobExponentialRolloutRate
s {$sel:rateIncreaseCriteria:AwsJobExponentialRolloutRate' :: AwsJobRateIncreaseCriteria
rateIncreaseCriteria = AwsJobRateIncreaseCriteria
a} :: AwsJobExponentialRolloutRate)

instance Data.FromJSON AwsJobExponentialRolloutRate where
  parseJSON :: Value -> Parser AwsJobExponentialRolloutRate
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AwsJobExponentialRolloutRate"
      ( \Object
x ->
          Natural
-> Double
-> AwsJobRateIncreaseCriteria
-> AwsJobExponentialRolloutRate
AwsJobExponentialRolloutRate'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"baseRatePerMinute")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"incrementFactor")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"rateIncreaseCriteria")
      )

instance
  Prelude.Hashable
    AwsJobExponentialRolloutRate
  where
  hashWithSalt :: Int -> AwsJobExponentialRolloutRate -> Int
hashWithSalt Int
_salt AwsJobExponentialRolloutRate' {Double
Natural
AwsJobRateIncreaseCriteria
rateIncreaseCriteria :: AwsJobRateIncreaseCriteria
incrementFactor :: Double
baseRatePerMinute :: Natural
$sel:rateIncreaseCriteria:AwsJobExponentialRolloutRate' :: AwsJobExponentialRolloutRate -> AwsJobRateIncreaseCriteria
$sel:incrementFactor:AwsJobExponentialRolloutRate' :: AwsJobExponentialRolloutRate -> Double
$sel:baseRatePerMinute:AwsJobExponentialRolloutRate' :: AwsJobExponentialRolloutRate -> Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
baseRatePerMinute
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
incrementFactor
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AwsJobRateIncreaseCriteria
rateIncreaseCriteria

instance Prelude.NFData AwsJobExponentialRolloutRate where
  rnf :: AwsJobExponentialRolloutRate -> ()
rnf AwsJobExponentialRolloutRate' {Double
Natural
AwsJobRateIncreaseCriteria
rateIncreaseCriteria :: AwsJobRateIncreaseCriteria
incrementFactor :: Double
baseRatePerMinute :: Natural
$sel:rateIncreaseCriteria:AwsJobExponentialRolloutRate' :: AwsJobExponentialRolloutRate -> AwsJobRateIncreaseCriteria
$sel:incrementFactor:AwsJobExponentialRolloutRate' :: AwsJobExponentialRolloutRate -> Double
$sel:baseRatePerMinute:AwsJobExponentialRolloutRate' :: AwsJobExponentialRolloutRate -> Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Natural
baseRatePerMinute
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
incrementFactor
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf AwsJobRateIncreaseCriteria
rateIncreaseCriteria

instance Data.ToJSON AwsJobExponentialRolloutRate where
  toJSON :: AwsJobExponentialRolloutRate -> Value
toJSON AwsJobExponentialRolloutRate' {Double
Natural
AwsJobRateIncreaseCriteria
rateIncreaseCriteria :: AwsJobRateIncreaseCriteria
incrementFactor :: Double
baseRatePerMinute :: Natural
$sel:rateIncreaseCriteria:AwsJobExponentialRolloutRate' :: AwsJobExponentialRolloutRate -> AwsJobRateIncreaseCriteria
$sel:incrementFactor:AwsJobExponentialRolloutRate' :: AwsJobExponentialRolloutRate -> Double
$sel:baseRatePerMinute:AwsJobExponentialRolloutRate' :: AwsJobExponentialRolloutRate -> Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"baseRatePerMinute" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
baseRatePerMinute),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"incrementFactor" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Double
incrementFactor),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"rateIncreaseCriteria"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= AwsJobRateIncreaseCriteria
rateIncreaseCriteria
              )
          ]
      )