{-# 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.GreengrassV2.Types.IoTJobExponentialRolloutRate
-- 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.GreengrassV2.Types.IoTJobExponentialRolloutRate where

import qualified Amazonka.Core as Core
import Amazonka.GreengrassV2.Types.IoTJobRateIncreaseCriteria
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about an exponential rollout rate for a
-- configuration deployment job.
--
-- /See:/ 'newIoTJobExponentialRolloutRate' smart constructor.
data IoTJobExponentialRolloutRate = IoTJobExponentialRolloutRate'
  { -- | The minimum number of devices that receive a pending job notification,
    -- per minute, when the job starts. This parameter defines the initial
    -- rollout rate of the job.
    IoTJobExponentialRolloutRate -> Natural
baseRatePerMinute :: Prelude.Natural,
    -- | The exponential factor to increase the rollout rate for the job.
    --
    -- This parameter supports up to one digit after the decimal (for example,
    -- you can specify @1.5@, but not @1.55@).
    IoTJobExponentialRolloutRate -> Double
incrementFactor :: Prelude.Double,
    -- | The criteria to increase the rollout rate for the job.
    IoTJobExponentialRolloutRate -> IoTJobRateIncreaseCriteria
rateIncreaseCriteria :: IoTJobRateIncreaseCriteria
  }
  deriving (IoTJobExponentialRolloutRate
-> IoTJobExponentialRolloutRate -> Bool
(IoTJobExponentialRolloutRate
 -> IoTJobExponentialRolloutRate -> Bool)
-> (IoTJobExponentialRolloutRate
    -> IoTJobExponentialRolloutRate -> Bool)
-> Eq IoTJobExponentialRolloutRate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IoTJobExponentialRolloutRate
-> IoTJobExponentialRolloutRate -> Bool
$c/= :: IoTJobExponentialRolloutRate
-> IoTJobExponentialRolloutRate -> Bool
== :: IoTJobExponentialRolloutRate
-> IoTJobExponentialRolloutRate -> Bool
$c== :: IoTJobExponentialRolloutRate
-> IoTJobExponentialRolloutRate -> Bool
Prelude.Eq, ReadPrec [IoTJobExponentialRolloutRate]
ReadPrec IoTJobExponentialRolloutRate
Int -> ReadS IoTJobExponentialRolloutRate
ReadS [IoTJobExponentialRolloutRate]
(Int -> ReadS IoTJobExponentialRolloutRate)
-> ReadS [IoTJobExponentialRolloutRate]
-> ReadPrec IoTJobExponentialRolloutRate
-> ReadPrec [IoTJobExponentialRolloutRate]
-> Read IoTJobExponentialRolloutRate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IoTJobExponentialRolloutRate]
$creadListPrec :: ReadPrec [IoTJobExponentialRolloutRate]
readPrec :: ReadPrec IoTJobExponentialRolloutRate
$creadPrec :: ReadPrec IoTJobExponentialRolloutRate
readList :: ReadS [IoTJobExponentialRolloutRate]
$creadList :: ReadS [IoTJobExponentialRolloutRate]
readsPrec :: Int -> ReadS IoTJobExponentialRolloutRate
$creadsPrec :: Int -> ReadS IoTJobExponentialRolloutRate
Prelude.Read, Int -> IoTJobExponentialRolloutRate -> ShowS
[IoTJobExponentialRolloutRate] -> ShowS
IoTJobExponentialRolloutRate -> String
(Int -> IoTJobExponentialRolloutRate -> ShowS)
-> (IoTJobExponentialRolloutRate -> String)
-> ([IoTJobExponentialRolloutRate] -> ShowS)
-> Show IoTJobExponentialRolloutRate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IoTJobExponentialRolloutRate] -> ShowS
$cshowList :: [IoTJobExponentialRolloutRate] -> ShowS
show :: IoTJobExponentialRolloutRate -> String
$cshow :: IoTJobExponentialRolloutRate -> String
showsPrec :: Int -> IoTJobExponentialRolloutRate -> ShowS
$cshowsPrec :: Int -> IoTJobExponentialRolloutRate -> ShowS
Prelude.Show, (forall x.
 IoTJobExponentialRolloutRate -> Rep IoTJobExponentialRolloutRate x)
-> (forall x.
    Rep IoTJobExponentialRolloutRate x -> IoTJobExponentialRolloutRate)
-> Generic IoTJobExponentialRolloutRate
forall x.
Rep IoTJobExponentialRolloutRate x -> IoTJobExponentialRolloutRate
forall x.
IoTJobExponentialRolloutRate -> Rep IoTJobExponentialRolloutRate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep IoTJobExponentialRolloutRate x -> IoTJobExponentialRolloutRate
$cfrom :: forall x.
IoTJobExponentialRolloutRate -> Rep IoTJobExponentialRolloutRate x
Prelude.Generic)

-- |
-- Create a value of 'IoTJobExponentialRolloutRate' 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', 'ioTJobExponentialRolloutRate_baseRatePerMinute' - The minimum number of devices that receive a pending job notification,
-- per minute, when the job starts. This parameter defines the initial
-- rollout rate of the job.
--
-- 'incrementFactor', 'ioTJobExponentialRolloutRate_incrementFactor' - The exponential factor to increase the rollout rate for the job.
--
-- This parameter supports up to one digit after the decimal (for example,
-- you can specify @1.5@, but not @1.55@).
--
-- 'rateIncreaseCriteria', 'ioTJobExponentialRolloutRate_rateIncreaseCriteria' - The criteria to increase the rollout rate for the job.
newIoTJobExponentialRolloutRate ::
  -- | 'baseRatePerMinute'
  Prelude.Natural ->
  -- | 'incrementFactor'
  Prelude.Double ->
  -- | 'rateIncreaseCriteria'
  IoTJobRateIncreaseCriteria ->
  IoTJobExponentialRolloutRate
newIoTJobExponentialRolloutRate :: Natural
-> Double
-> IoTJobRateIncreaseCriteria
-> IoTJobExponentialRolloutRate
newIoTJobExponentialRolloutRate
  Natural
pBaseRatePerMinute_
  Double
pIncrementFactor_
  IoTJobRateIncreaseCriteria
pRateIncreaseCriteria_ =
    IoTJobExponentialRolloutRate' :: Natural
-> Double
-> IoTJobRateIncreaseCriteria
-> IoTJobExponentialRolloutRate
IoTJobExponentialRolloutRate'
      { $sel:baseRatePerMinute:IoTJobExponentialRolloutRate' :: Natural
baseRatePerMinute =
          Natural
pBaseRatePerMinute_,
        $sel:incrementFactor:IoTJobExponentialRolloutRate' :: Double
incrementFactor = Double
pIncrementFactor_,
        $sel:rateIncreaseCriteria:IoTJobExponentialRolloutRate' :: IoTJobRateIncreaseCriteria
rateIncreaseCriteria = IoTJobRateIncreaseCriteria
pRateIncreaseCriteria_
      }

-- | The minimum number of devices that receive a pending job notification,
-- per minute, when the job starts. This parameter defines the initial
-- rollout rate of the job.
ioTJobExponentialRolloutRate_baseRatePerMinute :: Lens.Lens' IoTJobExponentialRolloutRate Prelude.Natural
ioTJobExponentialRolloutRate_baseRatePerMinute :: (Natural -> f Natural)
-> IoTJobExponentialRolloutRate -> f IoTJobExponentialRolloutRate
ioTJobExponentialRolloutRate_baseRatePerMinute = (IoTJobExponentialRolloutRate -> Natural)
-> (IoTJobExponentialRolloutRate
    -> Natural -> IoTJobExponentialRolloutRate)
-> Lens
     IoTJobExponentialRolloutRate
     IoTJobExponentialRolloutRate
     Natural
     Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IoTJobExponentialRolloutRate' {Natural
baseRatePerMinute :: Natural
$sel:baseRatePerMinute:IoTJobExponentialRolloutRate' :: IoTJobExponentialRolloutRate -> Natural
baseRatePerMinute} -> Natural
baseRatePerMinute) (\s :: IoTJobExponentialRolloutRate
s@IoTJobExponentialRolloutRate' {} Natural
a -> IoTJobExponentialRolloutRate
s {$sel:baseRatePerMinute:IoTJobExponentialRolloutRate' :: Natural
baseRatePerMinute = Natural
a} :: IoTJobExponentialRolloutRate)

-- | The exponential factor to increase the rollout rate for the job.
--
-- This parameter supports up to one digit after the decimal (for example,
-- you can specify @1.5@, but not @1.55@).
ioTJobExponentialRolloutRate_incrementFactor :: Lens.Lens' IoTJobExponentialRolloutRate Prelude.Double
ioTJobExponentialRolloutRate_incrementFactor :: (Double -> f Double)
-> IoTJobExponentialRolloutRate -> f IoTJobExponentialRolloutRate
ioTJobExponentialRolloutRate_incrementFactor = (IoTJobExponentialRolloutRate -> Double)
-> (IoTJobExponentialRolloutRate
    -> Double -> IoTJobExponentialRolloutRate)
-> Lens
     IoTJobExponentialRolloutRate
     IoTJobExponentialRolloutRate
     Double
     Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IoTJobExponentialRolloutRate' {Double
incrementFactor :: Double
$sel:incrementFactor:IoTJobExponentialRolloutRate' :: IoTJobExponentialRolloutRate -> Double
incrementFactor} -> Double
incrementFactor) (\s :: IoTJobExponentialRolloutRate
s@IoTJobExponentialRolloutRate' {} Double
a -> IoTJobExponentialRolloutRate
s {$sel:incrementFactor:IoTJobExponentialRolloutRate' :: Double
incrementFactor = Double
a} :: IoTJobExponentialRolloutRate)

-- | The criteria to increase the rollout rate for the job.
ioTJobExponentialRolloutRate_rateIncreaseCriteria :: Lens.Lens' IoTJobExponentialRolloutRate IoTJobRateIncreaseCriteria
ioTJobExponentialRolloutRate_rateIncreaseCriteria :: (IoTJobRateIncreaseCriteria -> f IoTJobRateIncreaseCriteria)
-> IoTJobExponentialRolloutRate -> f IoTJobExponentialRolloutRate
ioTJobExponentialRolloutRate_rateIncreaseCriteria = (IoTJobExponentialRolloutRate -> IoTJobRateIncreaseCriteria)
-> (IoTJobExponentialRolloutRate
    -> IoTJobRateIncreaseCriteria -> IoTJobExponentialRolloutRate)
-> Lens
     IoTJobExponentialRolloutRate
     IoTJobExponentialRolloutRate
     IoTJobRateIncreaseCriteria
     IoTJobRateIncreaseCriteria
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IoTJobExponentialRolloutRate' {IoTJobRateIncreaseCriteria
rateIncreaseCriteria :: IoTJobRateIncreaseCriteria
$sel:rateIncreaseCriteria:IoTJobExponentialRolloutRate' :: IoTJobExponentialRolloutRate -> IoTJobRateIncreaseCriteria
rateIncreaseCriteria} -> IoTJobRateIncreaseCriteria
rateIncreaseCriteria) (\s :: IoTJobExponentialRolloutRate
s@IoTJobExponentialRolloutRate' {} IoTJobRateIncreaseCriteria
a -> IoTJobExponentialRolloutRate
s {$sel:rateIncreaseCriteria:IoTJobExponentialRolloutRate' :: IoTJobRateIncreaseCriteria
rateIncreaseCriteria = IoTJobRateIncreaseCriteria
a} :: IoTJobExponentialRolloutRate)

instance Core.FromJSON IoTJobExponentialRolloutRate where
  parseJSON :: Value -> Parser IoTJobExponentialRolloutRate
parseJSON =
    String
-> (Object -> Parser IoTJobExponentialRolloutRate)
-> Value
-> Parser IoTJobExponentialRolloutRate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"IoTJobExponentialRolloutRate"
      ( \Object
x ->
          Natural
-> Double
-> IoTJobRateIncreaseCriteria
-> IoTJobExponentialRolloutRate
IoTJobExponentialRolloutRate'
            (Natural
 -> Double
 -> IoTJobRateIncreaseCriteria
 -> IoTJobExponentialRolloutRate)
-> Parser Natural
-> Parser
     (Double
      -> IoTJobRateIncreaseCriteria -> IoTJobExponentialRolloutRate)
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
   -> IoTJobRateIncreaseCriteria -> IoTJobExponentialRolloutRate)
-> Parser Double
-> Parser
     (IoTJobRateIncreaseCriteria -> IoTJobExponentialRolloutRate)
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 (IoTJobRateIncreaseCriteria -> IoTJobExponentialRolloutRate)
-> Parser IoTJobRateIncreaseCriteria
-> Parser IoTJobExponentialRolloutRate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser IoTJobRateIncreaseCriteria
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"rateIncreaseCriteria")
      )

instance
  Prelude.Hashable
    IoTJobExponentialRolloutRate

instance Prelude.NFData IoTJobExponentialRolloutRate

instance Core.ToJSON IoTJobExponentialRolloutRate where
  toJSON :: IoTJobExponentialRolloutRate -> Value
toJSON IoTJobExponentialRolloutRate' {Double
Natural
IoTJobRateIncreaseCriteria
rateIncreaseCriteria :: IoTJobRateIncreaseCriteria
incrementFactor :: Double
baseRatePerMinute :: Natural
$sel:rateIncreaseCriteria:IoTJobExponentialRolloutRate' :: IoTJobExponentialRolloutRate -> IoTJobRateIncreaseCriteria
$sel:incrementFactor:IoTJobExponentialRolloutRate' :: IoTJobExponentialRolloutRate -> Double
$sel:baseRatePerMinute:IoTJobExponentialRolloutRate' :: IoTJobExponentialRolloutRate -> 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 -> IoTJobRateIncreaseCriteria -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= IoTJobRateIncreaseCriteria
rateIncreaseCriteria
              )
          ]
      )