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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpsWorks.Types.AutoScalingThresholds
import qualified Amazonka.Prelude as Prelude

-- | Describes a layer\'s load-based auto scaling configuration.
--
-- /See:/ 'newLoadBasedAutoScalingConfiguration' smart constructor.
data LoadBasedAutoScalingConfiguration = LoadBasedAutoScalingConfiguration'
  { -- | An @AutoScalingThresholds@ object that describes the upscaling
    -- configuration, which defines how and when AWS OpsWorks Stacks increases
    -- the number of instances.
    LoadBasedAutoScalingConfiguration -> Maybe AutoScalingThresholds
upScaling :: Prelude.Maybe AutoScalingThresholds,
    -- | Whether load-based auto scaling is enabled for the layer.
    LoadBasedAutoScalingConfiguration -> Maybe Bool
enable :: Prelude.Maybe Prelude.Bool,
    -- | An @AutoScalingThresholds@ object that describes the downscaling
    -- configuration, which defines how and when AWS OpsWorks Stacks reduces
    -- the number of instances.
    LoadBasedAutoScalingConfiguration -> Maybe AutoScalingThresholds
downScaling :: Prelude.Maybe AutoScalingThresholds,
    -- | The layer ID.
    LoadBasedAutoScalingConfiguration -> Maybe Text
layerId :: Prelude.Maybe Prelude.Text
  }
  deriving (LoadBasedAutoScalingConfiguration
-> LoadBasedAutoScalingConfiguration -> Bool
(LoadBasedAutoScalingConfiguration
 -> LoadBasedAutoScalingConfiguration -> Bool)
-> (LoadBasedAutoScalingConfiguration
    -> LoadBasedAutoScalingConfiguration -> Bool)
-> Eq LoadBasedAutoScalingConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LoadBasedAutoScalingConfiguration
-> LoadBasedAutoScalingConfiguration -> Bool
$c/= :: LoadBasedAutoScalingConfiguration
-> LoadBasedAutoScalingConfiguration -> Bool
== :: LoadBasedAutoScalingConfiguration
-> LoadBasedAutoScalingConfiguration -> Bool
$c== :: LoadBasedAutoScalingConfiguration
-> LoadBasedAutoScalingConfiguration -> Bool
Prelude.Eq, ReadPrec [LoadBasedAutoScalingConfiguration]
ReadPrec LoadBasedAutoScalingConfiguration
Int -> ReadS LoadBasedAutoScalingConfiguration
ReadS [LoadBasedAutoScalingConfiguration]
(Int -> ReadS LoadBasedAutoScalingConfiguration)
-> ReadS [LoadBasedAutoScalingConfiguration]
-> ReadPrec LoadBasedAutoScalingConfiguration
-> ReadPrec [LoadBasedAutoScalingConfiguration]
-> Read LoadBasedAutoScalingConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LoadBasedAutoScalingConfiguration]
$creadListPrec :: ReadPrec [LoadBasedAutoScalingConfiguration]
readPrec :: ReadPrec LoadBasedAutoScalingConfiguration
$creadPrec :: ReadPrec LoadBasedAutoScalingConfiguration
readList :: ReadS [LoadBasedAutoScalingConfiguration]
$creadList :: ReadS [LoadBasedAutoScalingConfiguration]
readsPrec :: Int -> ReadS LoadBasedAutoScalingConfiguration
$creadsPrec :: Int -> ReadS LoadBasedAutoScalingConfiguration
Prelude.Read, Int -> LoadBasedAutoScalingConfiguration -> ShowS
[LoadBasedAutoScalingConfiguration] -> ShowS
LoadBasedAutoScalingConfiguration -> String
(Int -> LoadBasedAutoScalingConfiguration -> ShowS)
-> (LoadBasedAutoScalingConfiguration -> String)
-> ([LoadBasedAutoScalingConfiguration] -> ShowS)
-> Show LoadBasedAutoScalingConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LoadBasedAutoScalingConfiguration] -> ShowS
$cshowList :: [LoadBasedAutoScalingConfiguration] -> ShowS
show :: LoadBasedAutoScalingConfiguration -> String
$cshow :: LoadBasedAutoScalingConfiguration -> String
showsPrec :: Int -> LoadBasedAutoScalingConfiguration -> ShowS
$cshowsPrec :: Int -> LoadBasedAutoScalingConfiguration -> ShowS
Prelude.Show, (forall x.
 LoadBasedAutoScalingConfiguration
 -> Rep LoadBasedAutoScalingConfiguration x)
-> (forall x.
    Rep LoadBasedAutoScalingConfiguration x
    -> LoadBasedAutoScalingConfiguration)
-> Generic LoadBasedAutoScalingConfiguration
forall x.
Rep LoadBasedAutoScalingConfiguration x
-> LoadBasedAutoScalingConfiguration
forall x.
LoadBasedAutoScalingConfiguration
-> Rep LoadBasedAutoScalingConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep LoadBasedAutoScalingConfiguration x
-> LoadBasedAutoScalingConfiguration
$cfrom :: forall x.
LoadBasedAutoScalingConfiguration
-> Rep LoadBasedAutoScalingConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'LoadBasedAutoScalingConfiguration' 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:
--
-- 'upScaling', 'loadBasedAutoScalingConfiguration_upScaling' - An @AutoScalingThresholds@ object that describes the upscaling
-- configuration, which defines how and when AWS OpsWorks Stacks increases
-- the number of instances.
--
-- 'enable', 'loadBasedAutoScalingConfiguration_enable' - Whether load-based auto scaling is enabled for the layer.
--
-- 'downScaling', 'loadBasedAutoScalingConfiguration_downScaling' - An @AutoScalingThresholds@ object that describes the downscaling
-- configuration, which defines how and when AWS OpsWorks Stacks reduces
-- the number of instances.
--
-- 'layerId', 'loadBasedAutoScalingConfiguration_layerId' - The layer ID.
newLoadBasedAutoScalingConfiguration ::
  LoadBasedAutoScalingConfiguration
newLoadBasedAutoScalingConfiguration :: LoadBasedAutoScalingConfiguration
newLoadBasedAutoScalingConfiguration =
  LoadBasedAutoScalingConfiguration' :: Maybe AutoScalingThresholds
-> Maybe Bool
-> Maybe AutoScalingThresholds
-> Maybe Text
-> LoadBasedAutoScalingConfiguration
LoadBasedAutoScalingConfiguration'
    { $sel:upScaling:LoadBasedAutoScalingConfiguration' :: Maybe AutoScalingThresholds
upScaling =
        Maybe AutoScalingThresholds
forall a. Maybe a
Prelude.Nothing,
      $sel:enable:LoadBasedAutoScalingConfiguration' :: Maybe Bool
enable = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:downScaling:LoadBasedAutoScalingConfiguration' :: Maybe AutoScalingThresholds
downScaling = Maybe AutoScalingThresholds
forall a. Maybe a
Prelude.Nothing,
      $sel:layerId:LoadBasedAutoScalingConfiguration' :: Maybe Text
layerId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | An @AutoScalingThresholds@ object that describes the upscaling
-- configuration, which defines how and when AWS OpsWorks Stacks increases
-- the number of instances.
loadBasedAutoScalingConfiguration_upScaling :: Lens.Lens' LoadBasedAutoScalingConfiguration (Prelude.Maybe AutoScalingThresholds)
loadBasedAutoScalingConfiguration_upScaling :: (Maybe AutoScalingThresholds -> f (Maybe AutoScalingThresholds))
-> LoadBasedAutoScalingConfiguration
-> f LoadBasedAutoScalingConfiguration
loadBasedAutoScalingConfiguration_upScaling = (LoadBasedAutoScalingConfiguration -> Maybe AutoScalingThresholds)
-> (LoadBasedAutoScalingConfiguration
    -> Maybe AutoScalingThresholds
    -> LoadBasedAutoScalingConfiguration)
-> Lens
     LoadBasedAutoScalingConfiguration
     LoadBasedAutoScalingConfiguration
     (Maybe AutoScalingThresholds)
     (Maybe AutoScalingThresholds)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoadBasedAutoScalingConfiguration' {Maybe AutoScalingThresholds
upScaling :: Maybe AutoScalingThresholds
$sel:upScaling:LoadBasedAutoScalingConfiguration' :: LoadBasedAutoScalingConfiguration -> Maybe AutoScalingThresholds
upScaling} -> Maybe AutoScalingThresholds
upScaling) (\s :: LoadBasedAutoScalingConfiguration
s@LoadBasedAutoScalingConfiguration' {} Maybe AutoScalingThresholds
a -> LoadBasedAutoScalingConfiguration
s {$sel:upScaling:LoadBasedAutoScalingConfiguration' :: Maybe AutoScalingThresholds
upScaling = Maybe AutoScalingThresholds
a} :: LoadBasedAutoScalingConfiguration)

-- | Whether load-based auto scaling is enabled for the layer.
loadBasedAutoScalingConfiguration_enable :: Lens.Lens' LoadBasedAutoScalingConfiguration (Prelude.Maybe Prelude.Bool)
loadBasedAutoScalingConfiguration_enable :: (Maybe Bool -> f (Maybe Bool))
-> LoadBasedAutoScalingConfiguration
-> f LoadBasedAutoScalingConfiguration
loadBasedAutoScalingConfiguration_enable = (LoadBasedAutoScalingConfiguration -> Maybe Bool)
-> (LoadBasedAutoScalingConfiguration
    -> Maybe Bool -> LoadBasedAutoScalingConfiguration)
-> Lens
     LoadBasedAutoScalingConfiguration
     LoadBasedAutoScalingConfiguration
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoadBasedAutoScalingConfiguration' {Maybe Bool
enable :: Maybe Bool
$sel:enable:LoadBasedAutoScalingConfiguration' :: LoadBasedAutoScalingConfiguration -> Maybe Bool
enable} -> Maybe Bool
enable) (\s :: LoadBasedAutoScalingConfiguration
s@LoadBasedAutoScalingConfiguration' {} Maybe Bool
a -> LoadBasedAutoScalingConfiguration
s {$sel:enable:LoadBasedAutoScalingConfiguration' :: Maybe Bool
enable = Maybe Bool
a} :: LoadBasedAutoScalingConfiguration)

-- | An @AutoScalingThresholds@ object that describes the downscaling
-- configuration, which defines how and when AWS OpsWorks Stacks reduces
-- the number of instances.
loadBasedAutoScalingConfiguration_downScaling :: Lens.Lens' LoadBasedAutoScalingConfiguration (Prelude.Maybe AutoScalingThresholds)
loadBasedAutoScalingConfiguration_downScaling :: (Maybe AutoScalingThresholds -> f (Maybe AutoScalingThresholds))
-> LoadBasedAutoScalingConfiguration
-> f LoadBasedAutoScalingConfiguration
loadBasedAutoScalingConfiguration_downScaling = (LoadBasedAutoScalingConfiguration -> Maybe AutoScalingThresholds)
-> (LoadBasedAutoScalingConfiguration
    -> Maybe AutoScalingThresholds
    -> LoadBasedAutoScalingConfiguration)
-> Lens
     LoadBasedAutoScalingConfiguration
     LoadBasedAutoScalingConfiguration
     (Maybe AutoScalingThresholds)
     (Maybe AutoScalingThresholds)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoadBasedAutoScalingConfiguration' {Maybe AutoScalingThresholds
downScaling :: Maybe AutoScalingThresholds
$sel:downScaling:LoadBasedAutoScalingConfiguration' :: LoadBasedAutoScalingConfiguration -> Maybe AutoScalingThresholds
downScaling} -> Maybe AutoScalingThresholds
downScaling) (\s :: LoadBasedAutoScalingConfiguration
s@LoadBasedAutoScalingConfiguration' {} Maybe AutoScalingThresholds
a -> LoadBasedAutoScalingConfiguration
s {$sel:downScaling:LoadBasedAutoScalingConfiguration' :: Maybe AutoScalingThresholds
downScaling = Maybe AutoScalingThresholds
a} :: LoadBasedAutoScalingConfiguration)

-- | The layer ID.
loadBasedAutoScalingConfiguration_layerId :: Lens.Lens' LoadBasedAutoScalingConfiguration (Prelude.Maybe Prelude.Text)
loadBasedAutoScalingConfiguration_layerId :: (Maybe Text -> f (Maybe Text))
-> LoadBasedAutoScalingConfiguration
-> f LoadBasedAutoScalingConfiguration
loadBasedAutoScalingConfiguration_layerId = (LoadBasedAutoScalingConfiguration -> Maybe Text)
-> (LoadBasedAutoScalingConfiguration
    -> Maybe Text -> LoadBasedAutoScalingConfiguration)
-> Lens
     LoadBasedAutoScalingConfiguration
     LoadBasedAutoScalingConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoadBasedAutoScalingConfiguration' {Maybe Text
layerId :: Maybe Text
$sel:layerId:LoadBasedAutoScalingConfiguration' :: LoadBasedAutoScalingConfiguration -> Maybe Text
layerId} -> Maybe Text
layerId) (\s :: LoadBasedAutoScalingConfiguration
s@LoadBasedAutoScalingConfiguration' {} Maybe Text
a -> LoadBasedAutoScalingConfiguration
s {$sel:layerId:LoadBasedAutoScalingConfiguration' :: Maybe Text
layerId = Maybe Text
a} :: LoadBasedAutoScalingConfiguration)

instance
  Core.FromJSON
    LoadBasedAutoScalingConfiguration
  where
  parseJSON :: Value -> Parser LoadBasedAutoScalingConfiguration
parseJSON =
    String
-> (Object -> Parser LoadBasedAutoScalingConfiguration)
-> Value
-> Parser LoadBasedAutoScalingConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LoadBasedAutoScalingConfiguration"
      ( \Object
x ->
          Maybe AutoScalingThresholds
-> Maybe Bool
-> Maybe AutoScalingThresholds
-> Maybe Text
-> LoadBasedAutoScalingConfiguration
LoadBasedAutoScalingConfiguration'
            (Maybe AutoScalingThresholds
 -> Maybe Bool
 -> Maybe AutoScalingThresholds
 -> Maybe Text
 -> LoadBasedAutoScalingConfiguration)
-> Parser (Maybe AutoScalingThresholds)
-> Parser
     (Maybe Bool
      -> Maybe AutoScalingThresholds
      -> Maybe Text
      -> LoadBasedAutoScalingConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AutoScalingThresholds)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"UpScaling")
            Parser
  (Maybe Bool
   -> Maybe AutoScalingThresholds
   -> Maybe Text
   -> LoadBasedAutoScalingConfiguration)
-> Parser (Maybe Bool)
-> Parser
     (Maybe AutoScalingThresholds
      -> Maybe Text -> LoadBasedAutoScalingConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Enable")
            Parser
  (Maybe AutoScalingThresholds
   -> Maybe Text -> LoadBasedAutoScalingConfiguration)
-> Parser (Maybe AutoScalingThresholds)
-> Parser (Maybe Text -> LoadBasedAutoScalingConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AutoScalingThresholds)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DownScaling")
            Parser (Maybe Text -> LoadBasedAutoScalingConfiguration)
-> Parser (Maybe Text) -> Parser LoadBasedAutoScalingConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LayerId")
      )

instance
  Prelude.Hashable
    LoadBasedAutoScalingConfiguration

instance
  Prelude.NFData
    LoadBasedAutoScalingConfiguration