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

-- | Allows you to create an exponential rate of rollout for a job.
--
-- /See:/ 'newExponentialRolloutRate' smart constructor.
data ExponentialRolloutRate = ExponentialRolloutRate'
  { -- | The minimum number of things that will be notified of a pending job, per
    -- minute at the start of job rollout. This parameter allows you to define
    -- the initial rate of rollout.
    ExponentialRolloutRate -> Natural
baseRatePerMinute :: Prelude.Natural,
    -- | The exponential factor to increase the 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).
    ExponentialRolloutRate -> Double
incrementFactor :: Prelude.Double,
    -- | The criteria to initiate the increase in rate of rollout for a job.
    ExponentialRolloutRate -> RateIncreaseCriteria
rateIncreaseCriteria :: RateIncreaseCriteria
  }
  deriving (ExponentialRolloutRate -> ExponentialRolloutRate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExponentialRolloutRate -> ExponentialRolloutRate -> Bool
$c/= :: ExponentialRolloutRate -> ExponentialRolloutRate -> Bool
== :: ExponentialRolloutRate -> ExponentialRolloutRate -> Bool
$c== :: ExponentialRolloutRate -> ExponentialRolloutRate -> Bool
Prelude.Eq, ReadPrec [ExponentialRolloutRate]
ReadPrec ExponentialRolloutRate
Int -> ReadS ExponentialRolloutRate
ReadS [ExponentialRolloutRate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExponentialRolloutRate]
$creadListPrec :: ReadPrec [ExponentialRolloutRate]
readPrec :: ReadPrec ExponentialRolloutRate
$creadPrec :: ReadPrec ExponentialRolloutRate
readList :: ReadS [ExponentialRolloutRate]
$creadList :: ReadS [ExponentialRolloutRate]
readsPrec :: Int -> ReadS ExponentialRolloutRate
$creadsPrec :: Int -> ReadS ExponentialRolloutRate
Prelude.Read, Int -> ExponentialRolloutRate -> ShowS
[ExponentialRolloutRate] -> ShowS
ExponentialRolloutRate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExponentialRolloutRate] -> ShowS
$cshowList :: [ExponentialRolloutRate] -> ShowS
show :: ExponentialRolloutRate -> String
$cshow :: ExponentialRolloutRate -> String
showsPrec :: Int -> ExponentialRolloutRate -> ShowS
$cshowsPrec :: Int -> ExponentialRolloutRate -> ShowS
Prelude.Show, forall x. Rep ExponentialRolloutRate x -> ExponentialRolloutRate
forall x. ExponentialRolloutRate -> Rep ExponentialRolloutRate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExponentialRolloutRate x -> ExponentialRolloutRate
$cfrom :: forall x. ExponentialRolloutRate -> Rep ExponentialRolloutRate x
Prelude.Generic)

-- |
-- Create a value of 'ExponentialRolloutRate' 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', 'exponentialRolloutRate_baseRatePerMinute' - The minimum number of things that will be notified of a pending job, per
-- minute at the start of job rollout. This parameter allows you to define
-- the initial rate of rollout.
--
-- 'incrementFactor', 'exponentialRolloutRate_incrementFactor' - The exponential factor to increase the 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).
--
-- 'rateIncreaseCriteria', 'exponentialRolloutRate_rateIncreaseCriteria' - The criteria to initiate the increase in rate of rollout for a job.
newExponentialRolloutRate ::
  -- | 'baseRatePerMinute'
  Prelude.Natural ->
  -- | 'incrementFactor'
  Prelude.Double ->
  -- | 'rateIncreaseCriteria'
  RateIncreaseCriteria ->
  ExponentialRolloutRate
newExponentialRolloutRate :: Natural -> Double -> RateIncreaseCriteria -> ExponentialRolloutRate
newExponentialRolloutRate
  Natural
pBaseRatePerMinute_
  Double
pIncrementFactor_
  RateIncreaseCriteria
pRateIncreaseCriteria_ =
    ExponentialRolloutRate'
      { $sel:baseRatePerMinute:ExponentialRolloutRate' :: Natural
baseRatePerMinute =
          Natural
pBaseRatePerMinute_,
        $sel:incrementFactor:ExponentialRolloutRate' :: Double
incrementFactor = Double
pIncrementFactor_,
        $sel:rateIncreaseCriteria:ExponentialRolloutRate' :: RateIncreaseCriteria
rateIncreaseCriteria = RateIncreaseCriteria
pRateIncreaseCriteria_
      }

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

-- | The exponential factor to increase the 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).
exponentialRolloutRate_incrementFactor :: Lens.Lens' ExponentialRolloutRate Prelude.Double
exponentialRolloutRate_incrementFactor :: Lens' ExponentialRolloutRate Double
exponentialRolloutRate_incrementFactor = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExponentialRolloutRate' {Double
incrementFactor :: Double
$sel:incrementFactor:ExponentialRolloutRate' :: ExponentialRolloutRate -> Double
incrementFactor} -> Double
incrementFactor) (\s :: ExponentialRolloutRate
s@ExponentialRolloutRate' {} Double
a -> ExponentialRolloutRate
s {$sel:incrementFactor:ExponentialRolloutRate' :: Double
incrementFactor = Double
a} :: ExponentialRolloutRate)

-- | The criteria to initiate the increase in rate of rollout for a job.
exponentialRolloutRate_rateIncreaseCriteria :: Lens.Lens' ExponentialRolloutRate RateIncreaseCriteria
exponentialRolloutRate_rateIncreaseCriteria :: Lens' ExponentialRolloutRate RateIncreaseCriteria
exponentialRolloutRate_rateIncreaseCriteria = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExponentialRolloutRate' {RateIncreaseCriteria
rateIncreaseCriteria :: RateIncreaseCriteria
$sel:rateIncreaseCriteria:ExponentialRolloutRate' :: ExponentialRolloutRate -> RateIncreaseCriteria
rateIncreaseCriteria} -> RateIncreaseCriteria
rateIncreaseCriteria) (\s :: ExponentialRolloutRate
s@ExponentialRolloutRate' {} RateIncreaseCriteria
a -> ExponentialRolloutRate
s {$sel:rateIncreaseCriteria:ExponentialRolloutRate' :: RateIncreaseCriteria
rateIncreaseCriteria = RateIncreaseCriteria
a} :: ExponentialRolloutRate)

instance Data.FromJSON ExponentialRolloutRate where
  parseJSON :: Value -> Parser ExponentialRolloutRate
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ExponentialRolloutRate"
      ( \Object
x ->
          Natural -> Double -> RateIncreaseCriteria -> ExponentialRolloutRate
ExponentialRolloutRate'
            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 ExponentialRolloutRate where
  hashWithSalt :: Int -> ExponentialRolloutRate -> Int
hashWithSalt Int
_salt ExponentialRolloutRate' {Double
Natural
RateIncreaseCriteria
rateIncreaseCriteria :: RateIncreaseCriteria
incrementFactor :: Double
baseRatePerMinute :: Natural
$sel:rateIncreaseCriteria:ExponentialRolloutRate' :: ExponentialRolloutRate -> RateIncreaseCriteria
$sel:incrementFactor:ExponentialRolloutRate' :: ExponentialRolloutRate -> Double
$sel:baseRatePerMinute:ExponentialRolloutRate' :: ExponentialRolloutRate -> 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` RateIncreaseCriteria
rateIncreaseCriteria

instance Prelude.NFData ExponentialRolloutRate where
  rnf :: ExponentialRolloutRate -> ()
rnf ExponentialRolloutRate' {Double
Natural
RateIncreaseCriteria
rateIncreaseCriteria :: RateIncreaseCriteria
incrementFactor :: Double
baseRatePerMinute :: Natural
$sel:rateIncreaseCriteria:ExponentialRolloutRate' :: ExponentialRolloutRate -> RateIncreaseCriteria
$sel:incrementFactor:ExponentialRolloutRate' :: ExponentialRolloutRate -> Double
$sel:baseRatePerMinute:ExponentialRolloutRate' :: ExponentialRolloutRate -> 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 RateIncreaseCriteria
rateIncreaseCriteria

instance Data.ToJSON ExponentialRolloutRate where
  toJSON :: ExponentialRolloutRate -> Value
toJSON ExponentialRolloutRate' {Double
Natural
RateIncreaseCriteria
rateIncreaseCriteria :: RateIncreaseCriteria
incrementFactor :: Double
baseRatePerMinute :: Natural
$sel:rateIncreaseCriteria:ExponentialRolloutRate' :: ExponentialRolloutRate -> RateIncreaseCriteria
$sel:incrementFactor:ExponentialRolloutRate' :: ExponentialRolloutRate -> Double
$sel:baseRatePerMinute:ExponentialRolloutRate' :: ExponentialRolloutRate -> 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..= RateIncreaseCriteria
rateIncreaseCriteria
              )
          ]
      )