{-# 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.OpsWorks.Types.AutoScalingThresholds
-- 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.OpsWorks.Types.AutoScalingThresholds where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a load-based auto scaling upscaling or downscaling threshold
-- configuration, which specifies when AWS OpsWorks Stacks starts or stops
-- load-based instances.
--
-- /See:/ 'newAutoScalingThresholds' smart constructor.
data AutoScalingThresholds = AutoScalingThresholds'
  { -- | The number of instances to add or remove when the load exceeds a
    -- threshold.
    AutoScalingThresholds -> Maybe Int
instanceCount :: Prelude.Maybe Prelude.Int,
    -- | The amount of time (in minutes) after a scaling event occurs that AWS
    -- OpsWorks Stacks should ignore metrics and suppress additional scaling
    -- events. For example, AWS OpsWorks Stacks adds new instances following an
    -- upscaling event but the instances won\'t start reducing the load until
    -- they have been booted and configured. There is no point in raising
    -- additional scaling events during that operation, which typically takes
    -- several minutes. @IgnoreMetricsTime@ allows you to direct AWS OpsWorks
    -- Stacks to suppress scaling events long enough to get the new instances
    -- online.
    AutoScalingThresholds -> Maybe Natural
ignoreMetricsTime :: Prelude.Maybe Prelude.Natural,
    -- | The load threshold. A value of -1 disables the threshold. For more
    -- information about how load is computed, see
    -- <http://en.wikipedia.org/wiki/Load_%28computing%29 Load (computing)>.
    AutoScalingThresholds -> Maybe Double
loadThreshold :: Prelude.Maybe Prelude.Double,
    -- | The amount of time, in minutes, that the load must exceed a threshold
    -- before more instances are added or removed.
    AutoScalingThresholds -> Maybe Natural
thresholdsWaitTime :: Prelude.Maybe Prelude.Natural,
    -- | Custom Cloudwatch auto scaling alarms, to be used as thresholds. This
    -- parameter takes a list of up to five alarm names, which are case
    -- sensitive and must be in the same region as the stack.
    --
    -- To use custom alarms, you must update your service role to allow
    -- @cloudwatch:DescribeAlarms@. You can either have AWS OpsWorks Stacks
    -- update the role for you when you first use this feature or you can edit
    -- the role manually. For more information, see
    -- <https://docs.aws.amazon.com/opsworks/latest/userguide/opsworks-security-servicerole.html Allowing AWS OpsWorks Stacks to Act on Your Behalf>.
    AutoScalingThresholds -> Maybe [Text]
alarms :: Prelude.Maybe [Prelude.Text],
    -- | The memory utilization threshold, as a percent of the available memory.
    -- A value of -1 disables the threshold.
    AutoScalingThresholds -> Maybe Double
memoryThreshold :: Prelude.Maybe Prelude.Double,
    -- | The CPU utilization threshold, as a percent of the available CPU. A
    -- value of -1 disables the threshold.
    AutoScalingThresholds -> Maybe Double
cpuThreshold :: Prelude.Maybe Prelude.Double
  }
  deriving (AutoScalingThresholds -> AutoScalingThresholds -> Bool
(AutoScalingThresholds -> AutoScalingThresholds -> Bool)
-> (AutoScalingThresholds -> AutoScalingThresholds -> Bool)
-> Eq AutoScalingThresholds
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoScalingThresholds -> AutoScalingThresholds -> Bool
$c/= :: AutoScalingThresholds -> AutoScalingThresholds -> Bool
== :: AutoScalingThresholds -> AutoScalingThresholds -> Bool
$c== :: AutoScalingThresholds -> AutoScalingThresholds -> Bool
Prelude.Eq, ReadPrec [AutoScalingThresholds]
ReadPrec AutoScalingThresholds
Int -> ReadS AutoScalingThresholds
ReadS [AutoScalingThresholds]
(Int -> ReadS AutoScalingThresholds)
-> ReadS [AutoScalingThresholds]
-> ReadPrec AutoScalingThresholds
-> ReadPrec [AutoScalingThresholds]
-> Read AutoScalingThresholds
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutoScalingThresholds]
$creadListPrec :: ReadPrec [AutoScalingThresholds]
readPrec :: ReadPrec AutoScalingThresholds
$creadPrec :: ReadPrec AutoScalingThresholds
readList :: ReadS [AutoScalingThresholds]
$creadList :: ReadS [AutoScalingThresholds]
readsPrec :: Int -> ReadS AutoScalingThresholds
$creadsPrec :: Int -> ReadS AutoScalingThresholds
Prelude.Read, Int -> AutoScalingThresholds -> ShowS
[AutoScalingThresholds] -> ShowS
AutoScalingThresholds -> String
(Int -> AutoScalingThresholds -> ShowS)
-> (AutoScalingThresholds -> String)
-> ([AutoScalingThresholds] -> ShowS)
-> Show AutoScalingThresholds
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoScalingThresholds] -> ShowS
$cshowList :: [AutoScalingThresholds] -> ShowS
show :: AutoScalingThresholds -> String
$cshow :: AutoScalingThresholds -> String
showsPrec :: Int -> AutoScalingThresholds -> ShowS
$cshowsPrec :: Int -> AutoScalingThresholds -> ShowS
Prelude.Show, (forall x. AutoScalingThresholds -> Rep AutoScalingThresholds x)
-> (forall x. Rep AutoScalingThresholds x -> AutoScalingThresholds)
-> Generic AutoScalingThresholds
forall x. Rep AutoScalingThresholds x -> AutoScalingThresholds
forall x. AutoScalingThresholds -> Rep AutoScalingThresholds x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AutoScalingThresholds x -> AutoScalingThresholds
$cfrom :: forall x. AutoScalingThresholds -> Rep AutoScalingThresholds x
Prelude.Generic)

-- |
-- Create a value of 'AutoScalingThresholds' 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:
--
-- 'instanceCount', 'autoScalingThresholds_instanceCount' - The number of instances to add or remove when the load exceeds a
-- threshold.
--
-- 'ignoreMetricsTime', 'autoScalingThresholds_ignoreMetricsTime' - The amount of time (in minutes) after a scaling event occurs that AWS
-- OpsWorks Stacks should ignore metrics and suppress additional scaling
-- events. For example, AWS OpsWorks Stacks adds new instances following an
-- upscaling event but the instances won\'t start reducing the load until
-- they have been booted and configured. There is no point in raising
-- additional scaling events during that operation, which typically takes
-- several minutes. @IgnoreMetricsTime@ allows you to direct AWS OpsWorks
-- Stacks to suppress scaling events long enough to get the new instances
-- online.
--
-- 'loadThreshold', 'autoScalingThresholds_loadThreshold' - The load threshold. A value of -1 disables the threshold. For more
-- information about how load is computed, see
-- <http://en.wikipedia.org/wiki/Load_%28computing%29 Load (computing)>.
--
-- 'thresholdsWaitTime', 'autoScalingThresholds_thresholdsWaitTime' - The amount of time, in minutes, that the load must exceed a threshold
-- before more instances are added or removed.
--
-- 'alarms', 'autoScalingThresholds_alarms' - Custom Cloudwatch auto scaling alarms, to be used as thresholds. This
-- parameter takes a list of up to five alarm names, which are case
-- sensitive and must be in the same region as the stack.
--
-- To use custom alarms, you must update your service role to allow
-- @cloudwatch:DescribeAlarms@. You can either have AWS OpsWorks Stacks
-- update the role for you when you first use this feature or you can edit
-- the role manually. For more information, see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/opsworks-security-servicerole.html Allowing AWS OpsWorks Stacks to Act on Your Behalf>.
--
-- 'memoryThreshold', 'autoScalingThresholds_memoryThreshold' - The memory utilization threshold, as a percent of the available memory.
-- A value of -1 disables the threshold.
--
-- 'cpuThreshold', 'autoScalingThresholds_cpuThreshold' - The CPU utilization threshold, as a percent of the available CPU. A
-- value of -1 disables the threshold.
newAutoScalingThresholds ::
  AutoScalingThresholds
newAutoScalingThresholds :: AutoScalingThresholds
newAutoScalingThresholds =
  AutoScalingThresholds' :: Maybe Int
-> Maybe Natural
-> Maybe Double
-> Maybe Natural
-> Maybe [Text]
-> Maybe Double
-> Maybe Double
-> AutoScalingThresholds
AutoScalingThresholds'
    { $sel:instanceCount:AutoScalingThresholds' :: Maybe Int
instanceCount =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:ignoreMetricsTime:AutoScalingThresholds' :: Maybe Natural
ignoreMetricsTime = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:loadThreshold:AutoScalingThresholds' :: Maybe Double
loadThreshold = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:thresholdsWaitTime:AutoScalingThresholds' :: Maybe Natural
thresholdsWaitTime = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:alarms:AutoScalingThresholds' :: Maybe [Text]
alarms = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:memoryThreshold:AutoScalingThresholds' :: Maybe Double
memoryThreshold = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:cpuThreshold:AutoScalingThresholds' :: Maybe Double
cpuThreshold = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | The number of instances to add or remove when the load exceeds a
-- threshold.
autoScalingThresholds_instanceCount :: Lens.Lens' AutoScalingThresholds (Prelude.Maybe Prelude.Int)
autoScalingThresholds_instanceCount :: (Maybe Int -> f (Maybe Int))
-> AutoScalingThresholds -> f AutoScalingThresholds
autoScalingThresholds_instanceCount = (AutoScalingThresholds -> Maybe Int)
-> (AutoScalingThresholds -> Maybe Int -> AutoScalingThresholds)
-> Lens
     AutoScalingThresholds AutoScalingThresholds (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingThresholds' {Maybe Int
instanceCount :: Maybe Int
$sel:instanceCount:AutoScalingThresholds' :: AutoScalingThresholds -> Maybe Int
instanceCount} -> Maybe Int
instanceCount) (\s :: AutoScalingThresholds
s@AutoScalingThresholds' {} Maybe Int
a -> AutoScalingThresholds
s {$sel:instanceCount:AutoScalingThresholds' :: Maybe Int
instanceCount = Maybe Int
a} :: AutoScalingThresholds)

-- | The amount of time (in minutes) after a scaling event occurs that AWS
-- OpsWorks Stacks should ignore metrics and suppress additional scaling
-- events. For example, AWS OpsWorks Stacks adds new instances following an
-- upscaling event but the instances won\'t start reducing the load until
-- they have been booted and configured. There is no point in raising
-- additional scaling events during that operation, which typically takes
-- several minutes. @IgnoreMetricsTime@ allows you to direct AWS OpsWorks
-- Stacks to suppress scaling events long enough to get the new instances
-- online.
autoScalingThresholds_ignoreMetricsTime :: Lens.Lens' AutoScalingThresholds (Prelude.Maybe Prelude.Natural)
autoScalingThresholds_ignoreMetricsTime :: (Maybe Natural -> f (Maybe Natural))
-> AutoScalingThresholds -> f AutoScalingThresholds
autoScalingThresholds_ignoreMetricsTime = (AutoScalingThresholds -> Maybe Natural)
-> (AutoScalingThresholds
    -> Maybe Natural -> AutoScalingThresholds)
-> Lens
     AutoScalingThresholds
     AutoScalingThresholds
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingThresholds' {Maybe Natural
ignoreMetricsTime :: Maybe Natural
$sel:ignoreMetricsTime:AutoScalingThresholds' :: AutoScalingThresholds -> Maybe Natural
ignoreMetricsTime} -> Maybe Natural
ignoreMetricsTime) (\s :: AutoScalingThresholds
s@AutoScalingThresholds' {} Maybe Natural
a -> AutoScalingThresholds
s {$sel:ignoreMetricsTime:AutoScalingThresholds' :: Maybe Natural
ignoreMetricsTime = Maybe Natural
a} :: AutoScalingThresholds)

-- | The load threshold. A value of -1 disables the threshold. For more
-- information about how load is computed, see
-- <http://en.wikipedia.org/wiki/Load_%28computing%29 Load (computing)>.
autoScalingThresholds_loadThreshold :: Lens.Lens' AutoScalingThresholds (Prelude.Maybe Prelude.Double)
autoScalingThresholds_loadThreshold :: (Maybe Double -> f (Maybe Double))
-> AutoScalingThresholds -> f AutoScalingThresholds
autoScalingThresholds_loadThreshold = (AutoScalingThresholds -> Maybe Double)
-> (AutoScalingThresholds -> Maybe Double -> AutoScalingThresholds)
-> Lens
     AutoScalingThresholds
     AutoScalingThresholds
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingThresholds' {Maybe Double
loadThreshold :: Maybe Double
$sel:loadThreshold:AutoScalingThresholds' :: AutoScalingThresholds -> Maybe Double
loadThreshold} -> Maybe Double
loadThreshold) (\s :: AutoScalingThresholds
s@AutoScalingThresholds' {} Maybe Double
a -> AutoScalingThresholds
s {$sel:loadThreshold:AutoScalingThresholds' :: Maybe Double
loadThreshold = Maybe Double
a} :: AutoScalingThresholds)

-- | The amount of time, in minutes, that the load must exceed a threshold
-- before more instances are added or removed.
autoScalingThresholds_thresholdsWaitTime :: Lens.Lens' AutoScalingThresholds (Prelude.Maybe Prelude.Natural)
autoScalingThresholds_thresholdsWaitTime :: (Maybe Natural -> f (Maybe Natural))
-> AutoScalingThresholds -> f AutoScalingThresholds
autoScalingThresholds_thresholdsWaitTime = (AutoScalingThresholds -> Maybe Natural)
-> (AutoScalingThresholds
    -> Maybe Natural -> AutoScalingThresholds)
-> Lens
     AutoScalingThresholds
     AutoScalingThresholds
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingThresholds' {Maybe Natural
thresholdsWaitTime :: Maybe Natural
$sel:thresholdsWaitTime:AutoScalingThresholds' :: AutoScalingThresholds -> Maybe Natural
thresholdsWaitTime} -> Maybe Natural
thresholdsWaitTime) (\s :: AutoScalingThresholds
s@AutoScalingThresholds' {} Maybe Natural
a -> AutoScalingThresholds
s {$sel:thresholdsWaitTime:AutoScalingThresholds' :: Maybe Natural
thresholdsWaitTime = Maybe Natural
a} :: AutoScalingThresholds)

-- | Custom Cloudwatch auto scaling alarms, to be used as thresholds. This
-- parameter takes a list of up to five alarm names, which are case
-- sensitive and must be in the same region as the stack.
--
-- To use custom alarms, you must update your service role to allow
-- @cloudwatch:DescribeAlarms@. You can either have AWS OpsWorks Stacks
-- update the role for you when you first use this feature or you can edit
-- the role manually. For more information, see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/opsworks-security-servicerole.html Allowing AWS OpsWorks Stacks to Act on Your Behalf>.
autoScalingThresholds_alarms :: Lens.Lens' AutoScalingThresholds (Prelude.Maybe [Prelude.Text])
autoScalingThresholds_alarms :: (Maybe [Text] -> f (Maybe [Text]))
-> AutoScalingThresholds -> f AutoScalingThresholds
autoScalingThresholds_alarms = (AutoScalingThresholds -> Maybe [Text])
-> (AutoScalingThresholds -> Maybe [Text] -> AutoScalingThresholds)
-> Lens
     AutoScalingThresholds
     AutoScalingThresholds
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingThresholds' {Maybe [Text]
alarms :: Maybe [Text]
$sel:alarms:AutoScalingThresholds' :: AutoScalingThresholds -> Maybe [Text]
alarms} -> Maybe [Text]
alarms) (\s :: AutoScalingThresholds
s@AutoScalingThresholds' {} Maybe [Text]
a -> AutoScalingThresholds
s {$sel:alarms:AutoScalingThresholds' :: Maybe [Text]
alarms = Maybe [Text]
a} :: AutoScalingThresholds) ((Maybe [Text] -> f (Maybe [Text]))
 -> AutoScalingThresholds -> f AutoScalingThresholds)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> AutoScalingThresholds
-> f AutoScalingThresholds
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The memory utilization threshold, as a percent of the available memory.
-- A value of -1 disables the threshold.
autoScalingThresholds_memoryThreshold :: Lens.Lens' AutoScalingThresholds (Prelude.Maybe Prelude.Double)
autoScalingThresholds_memoryThreshold :: (Maybe Double -> f (Maybe Double))
-> AutoScalingThresholds -> f AutoScalingThresholds
autoScalingThresholds_memoryThreshold = (AutoScalingThresholds -> Maybe Double)
-> (AutoScalingThresholds -> Maybe Double -> AutoScalingThresholds)
-> Lens
     AutoScalingThresholds
     AutoScalingThresholds
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingThresholds' {Maybe Double
memoryThreshold :: Maybe Double
$sel:memoryThreshold:AutoScalingThresholds' :: AutoScalingThresholds -> Maybe Double
memoryThreshold} -> Maybe Double
memoryThreshold) (\s :: AutoScalingThresholds
s@AutoScalingThresholds' {} Maybe Double
a -> AutoScalingThresholds
s {$sel:memoryThreshold:AutoScalingThresholds' :: Maybe Double
memoryThreshold = Maybe Double
a} :: AutoScalingThresholds)

-- | The CPU utilization threshold, as a percent of the available CPU. A
-- value of -1 disables the threshold.
autoScalingThresholds_cpuThreshold :: Lens.Lens' AutoScalingThresholds (Prelude.Maybe Prelude.Double)
autoScalingThresholds_cpuThreshold :: (Maybe Double -> f (Maybe Double))
-> AutoScalingThresholds -> f AutoScalingThresholds
autoScalingThresholds_cpuThreshold = (AutoScalingThresholds -> Maybe Double)
-> (AutoScalingThresholds -> Maybe Double -> AutoScalingThresholds)
-> Lens
     AutoScalingThresholds
     AutoScalingThresholds
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingThresholds' {Maybe Double
cpuThreshold :: Maybe Double
$sel:cpuThreshold:AutoScalingThresholds' :: AutoScalingThresholds -> Maybe Double
cpuThreshold} -> Maybe Double
cpuThreshold) (\s :: AutoScalingThresholds
s@AutoScalingThresholds' {} Maybe Double
a -> AutoScalingThresholds
s {$sel:cpuThreshold:AutoScalingThresholds' :: Maybe Double
cpuThreshold = Maybe Double
a} :: AutoScalingThresholds)

instance Core.FromJSON AutoScalingThresholds where
  parseJSON :: Value -> Parser AutoScalingThresholds
parseJSON =
    String
-> (Object -> Parser AutoScalingThresholds)
-> Value
-> Parser AutoScalingThresholds
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AutoScalingThresholds"
      ( \Object
x ->
          Maybe Int
-> Maybe Natural
-> Maybe Double
-> Maybe Natural
-> Maybe [Text]
-> Maybe Double
-> Maybe Double
-> AutoScalingThresholds
AutoScalingThresholds'
            (Maybe Int
 -> Maybe Natural
 -> Maybe Double
 -> Maybe Natural
 -> Maybe [Text]
 -> Maybe Double
 -> Maybe Double
 -> AutoScalingThresholds)
-> Parser (Maybe Int)
-> Parser
     (Maybe Natural
      -> Maybe Double
      -> Maybe Natural
      -> Maybe [Text]
      -> Maybe Double
      -> Maybe Double
      -> AutoScalingThresholds)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"InstanceCount")
            Parser
  (Maybe Natural
   -> Maybe Double
   -> Maybe Natural
   -> Maybe [Text]
   -> Maybe Double
   -> Maybe Double
   -> AutoScalingThresholds)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Double
      -> Maybe Natural
      -> Maybe [Text]
      -> Maybe Double
      -> Maybe Double
      -> AutoScalingThresholds)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IgnoreMetricsTime")
            Parser
  (Maybe Double
   -> Maybe Natural
   -> Maybe [Text]
   -> Maybe Double
   -> Maybe Double
   -> AutoScalingThresholds)
-> Parser (Maybe Double)
-> Parser
     (Maybe Natural
      -> Maybe [Text]
      -> Maybe Double
      -> Maybe Double
      -> AutoScalingThresholds)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LoadThreshold")
            Parser
  (Maybe Natural
   -> Maybe [Text]
   -> Maybe Double
   -> Maybe Double
   -> AutoScalingThresholds)
-> Parser (Maybe Natural)
-> Parser
     (Maybe [Text]
      -> Maybe Double -> Maybe Double -> AutoScalingThresholds)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ThresholdsWaitTime")
            Parser
  (Maybe [Text]
   -> Maybe Double -> Maybe Double -> AutoScalingThresholds)
-> Parser (Maybe [Text])
-> Parser (Maybe Double -> Maybe Double -> AutoScalingThresholds)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Alarms" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Double -> Maybe Double -> AutoScalingThresholds)
-> Parser (Maybe Double)
-> Parser (Maybe Double -> AutoScalingThresholds)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MemoryThreshold")
            Parser (Maybe Double -> AutoScalingThresholds)
-> Parser (Maybe Double) -> Parser AutoScalingThresholds
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CpuThreshold")
      )

instance Prelude.Hashable AutoScalingThresholds

instance Prelude.NFData AutoScalingThresholds

instance Core.ToJSON AutoScalingThresholds where
  toJSON :: AutoScalingThresholds -> Value
toJSON AutoScalingThresholds' {Maybe Double
Maybe Int
Maybe Natural
Maybe [Text]
cpuThreshold :: Maybe Double
memoryThreshold :: Maybe Double
alarms :: Maybe [Text]
thresholdsWaitTime :: Maybe Natural
loadThreshold :: Maybe Double
ignoreMetricsTime :: Maybe Natural
instanceCount :: Maybe Int
$sel:cpuThreshold:AutoScalingThresholds' :: AutoScalingThresholds -> Maybe Double
$sel:memoryThreshold:AutoScalingThresholds' :: AutoScalingThresholds -> Maybe Double
$sel:alarms:AutoScalingThresholds' :: AutoScalingThresholds -> Maybe [Text]
$sel:thresholdsWaitTime:AutoScalingThresholds' :: AutoScalingThresholds -> Maybe Natural
$sel:loadThreshold:AutoScalingThresholds' :: AutoScalingThresholds -> Maybe Double
$sel:ignoreMetricsTime:AutoScalingThresholds' :: AutoScalingThresholds -> Maybe Natural
$sel:instanceCount:AutoScalingThresholds' :: AutoScalingThresholds -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"InstanceCount" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
instanceCount,
            (Text
"IgnoreMetricsTime" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
ignoreMetricsTime,
            (Text
"LoadThreshold" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
loadThreshold,
            (Text
"ThresholdsWaitTime" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
thresholdsWaitTime,
            (Text
"Alarms" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
alarms,
            (Text
"MemoryThreshold" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
memoryThreshold,
            (Text
"CpuThreshold" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
cpuThreshold
          ]
      )