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

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.AwsJobRateIncreaseCriteria
import qualified Amazonka.Lens as Lens
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
(AwsJobExponentialRolloutRate
 -> AwsJobExponentialRolloutRate -> Bool)
-> (AwsJobExponentialRolloutRate
    -> AwsJobExponentialRolloutRate -> Bool)
-> Eq AwsJobExponentialRolloutRate
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]
(Int -> ReadS AwsJobExponentialRolloutRate)
-> ReadS [AwsJobExponentialRolloutRate]
-> ReadPrec AwsJobExponentialRolloutRate
-> ReadPrec [AwsJobExponentialRolloutRate]
-> Read 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
(Int -> AwsJobExponentialRolloutRate -> ShowS)
-> (AwsJobExponentialRolloutRate -> String)
-> ([AwsJobExponentialRolloutRate] -> ShowS)
-> Show AwsJobExponentialRolloutRate
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.
 AwsJobExponentialRolloutRate -> Rep AwsJobExponentialRolloutRate x)
-> (forall x.
    Rep AwsJobExponentialRolloutRate x -> AwsJobExponentialRolloutRate)
-> Generic AwsJobExponentialRolloutRate
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' :: Natural
-> Double
-> AwsJobRateIncreaseCriteria
-> AwsJobExponentialRolloutRate
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 :: (Natural -> f Natural)
-> AwsJobExponentialRolloutRate -> f AwsJobExponentialRolloutRate
awsJobExponentialRolloutRate_baseRatePerMinute = (AwsJobExponentialRolloutRate -> Natural)
-> (AwsJobExponentialRolloutRate
    -> Natural -> AwsJobExponentialRolloutRate)
-> Lens
     AwsJobExponentialRolloutRate
     AwsJobExponentialRolloutRate
     Natural
     Natural
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 :: (Double -> f Double)
-> AwsJobExponentialRolloutRate -> f AwsJobExponentialRolloutRate
awsJobExponentialRolloutRate_incrementFactor = (AwsJobExponentialRolloutRate -> Double)
-> (AwsJobExponentialRolloutRate
    -> Double -> AwsJobExponentialRolloutRate)
-> Lens
     AwsJobExponentialRolloutRate
     AwsJobExponentialRolloutRate
     Double
     Double
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 :: (AwsJobRateIncreaseCriteria -> f AwsJobRateIncreaseCriteria)
-> AwsJobExponentialRolloutRate -> f AwsJobExponentialRolloutRate
awsJobExponentialRolloutRate_rateIncreaseCriteria = (AwsJobExponentialRolloutRate -> AwsJobRateIncreaseCriteria)
-> (AwsJobExponentialRolloutRate
    -> AwsJobRateIncreaseCriteria -> AwsJobExponentialRolloutRate)
-> Lens
     AwsJobExponentialRolloutRate
     AwsJobExponentialRolloutRate
     AwsJobRateIncreaseCriteria
     AwsJobRateIncreaseCriteria
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 Core.FromJSON AwsJobExponentialRolloutRate where
  parseJSON :: Value -> Parser AwsJobExponentialRolloutRate
parseJSON =
    String
-> (Object -> Parser AwsJobExponentialRolloutRate)
-> Value
-> Parser AwsJobExponentialRolloutRate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsJobExponentialRolloutRate"
      ( \Object
x ->
          Natural
-> Double
-> AwsJobRateIncreaseCriteria
-> AwsJobExponentialRolloutRate
AwsJobExponentialRolloutRate'
            (Natural
 -> Double
 -> AwsJobRateIncreaseCriteria
 -> AwsJobExponentialRolloutRate)
-> Parser Natural
-> Parser
     (Double
      -> AwsJobRateIncreaseCriteria -> AwsJobExponentialRolloutRate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"baseRatePerMinute")
            Parser
  (Double
   -> AwsJobRateIncreaseCriteria -> AwsJobExponentialRolloutRate)
-> Parser Double
-> Parser
     (AwsJobRateIncreaseCriteria -> AwsJobExponentialRolloutRate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"incrementFactor")
            Parser (AwsJobRateIncreaseCriteria -> AwsJobExponentialRolloutRate)
-> Parser AwsJobRateIncreaseCriteria
-> Parser AwsJobExponentialRolloutRate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser AwsJobRateIncreaseCriteria
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"rateIncreaseCriteria")
      )

instance
  Prelude.Hashable
    AwsJobExponentialRolloutRate

instance Prelude.NFData AwsJobExponentialRolloutRate

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"baseRatePerMinute" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
baseRatePerMinute),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"incrementFactor" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
incrementFactor),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"rateIncreaseCriteria"
                  Text -> AwsJobRateIncreaseCriteria -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AwsJobRateIncreaseCriteria
rateIncreaseCriteria
              )
          ]
      )