{-# 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.AutoScaling.Types.WarmPoolConfiguration
-- 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.AutoScaling.Types.WarmPoolConfiguration where

import Amazonka.AutoScaling.Types.WarmPoolState
import Amazonka.AutoScaling.Types.WarmPoolStatus
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a warm pool configuration.
--
-- /See:/ 'newWarmPoolConfiguration' smart constructor.
data WarmPoolConfiguration = WarmPoolConfiguration'
  { -- | The status of a warm pool that is marked for deletion.
    WarmPoolConfiguration -> Maybe WarmPoolStatus
status :: Prelude.Maybe WarmPoolStatus,
    -- | The minimum number of instances to maintain in the warm pool.
    WarmPoolConfiguration -> Maybe Natural
minSize :: Prelude.Maybe Prelude.Natural,
    -- | The maximum number of instances that are allowed to be in the warm pool
    -- or in any state except @Terminated@ for the Auto Scaling group.
    WarmPoolConfiguration -> Maybe Int
maxGroupPreparedCapacity :: Prelude.Maybe Prelude.Int,
    -- | The instance state to transition to after the lifecycle actions are
    -- complete.
    WarmPoolConfiguration -> Maybe WarmPoolState
poolState :: Prelude.Maybe WarmPoolState
  }
  deriving (WarmPoolConfiguration -> WarmPoolConfiguration -> Bool
(WarmPoolConfiguration -> WarmPoolConfiguration -> Bool)
-> (WarmPoolConfiguration -> WarmPoolConfiguration -> Bool)
-> Eq WarmPoolConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WarmPoolConfiguration -> WarmPoolConfiguration -> Bool
$c/= :: WarmPoolConfiguration -> WarmPoolConfiguration -> Bool
== :: WarmPoolConfiguration -> WarmPoolConfiguration -> Bool
$c== :: WarmPoolConfiguration -> WarmPoolConfiguration -> Bool
Prelude.Eq, ReadPrec [WarmPoolConfiguration]
ReadPrec WarmPoolConfiguration
Int -> ReadS WarmPoolConfiguration
ReadS [WarmPoolConfiguration]
(Int -> ReadS WarmPoolConfiguration)
-> ReadS [WarmPoolConfiguration]
-> ReadPrec WarmPoolConfiguration
-> ReadPrec [WarmPoolConfiguration]
-> Read WarmPoolConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WarmPoolConfiguration]
$creadListPrec :: ReadPrec [WarmPoolConfiguration]
readPrec :: ReadPrec WarmPoolConfiguration
$creadPrec :: ReadPrec WarmPoolConfiguration
readList :: ReadS [WarmPoolConfiguration]
$creadList :: ReadS [WarmPoolConfiguration]
readsPrec :: Int -> ReadS WarmPoolConfiguration
$creadsPrec :: Int -> ReadS WarmPoolConfiguration
Prelude.Read, Int -> WarmPoolConfiguration -> ShowS
[WarmPoolConfiguration] -> ShowS
WarmPoolConfiguration -> String
(Int -> WarmPoolConfiguration -> ShowS)
-> (WarmPoolConfiguration -> String)
-> ([WarmPoolConfiguration] -> ShowS)
-> Show WarmPoolConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WarmPoolConfiguration] -> ShowS
$cshowList :: [WarmPoolConfiguration] -> ShowS
show :: WarmPoolConfiguration -> String
$cshow :: WarmPoolConfiguration -> String
showsPrec :: Int -> WarmPoolConfiguration -> ShowS
$cshowsPrec :: Int -> WarmPoolConfiguration -> ShowS
Prelude.Show, (forall x. WarmPoolConfiguration -> Rep WarmPoolConfiguration x)
-> (forall x. Rep WarmPoolConfiguration x -> WarmPoolConfiguration)
-> Generic WarmPoolConfiguration
forall x. Rep WarmPoolConfiguration x -> WarmPoolConfiguration
forall x. WarmPoolConfiguration -> Rep WarmPoolConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WarmPoolConfiguration x -> WarmPoolConfiguration
$cfrom :: forall x. WarmPoolConfiguration -> Rep WarmPoolConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'WarmPoolConfiguration' 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:
--
-- 'status', 'warmPoolConfiguration_status' - The status of a warm pool that is marked for deletion.
--
-- 'minSize', 'warmPoolConfiguration_minSize' - The minimum number of instances to maintain in the warm pool.
--
-- 'maxGroupPreparedCapacity', 'warmPoolConfiguration_maxGroupPreparedCapacity' - The maximum number of instances that are allowed to be in the warm pool
-- or in any state except @Terminated@ for the Auto Scaling group.
--
-- 'poolState', 'warmPoolConfiguration_poolState' - The instance state to transition to after the lifecycle actions are
-- complete.
newWarmPoolConfiguration ::
  WarmPoolConfiguration
newWarmPoolConfiguration :: WarmPoolConfiguration
newWarmPoolConfiguration =
  WarmPoolConfiguration' :: Maybe WarmPoolStatus
-> Maybe Natural
-> Maybe Int
-> Maybe WarmPoolState
-> WarmPoolConfiguration
WarmPoolConfiguration'
    { $sel:status:WarmPoolConfiguration' :: Maybe WarmPoolStatus
status = Maybe WarmPoolStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:minSize:WarmPoolConfiguration' :: Maybe Natural
minSize = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:maxGroupPreparedCapacity:WarmPoolConfiguration' :: Maybe Int
maxGroupPreparedCapacity = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:poolState:WarmPoolConfiguration' :: Maybe WarmPoolState
poolState = Maybe WarmPoolState
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of a warm pool that is marked for deletion.
warmPoolConfiguration_status :: Lens.Lens' WarmPoolConfiguration (Prelude.Maybe WarmPoolStatus)
warmPoolConfiguration_status :: (Maybe WarmPoolStatus -> f (Maybe WarmPoolStatus))
-> WarmPoolConfiguration -> f WarmPoolConfiguration
warmPoolConfiguration_status = (WarmPoolConfiguration -> Maybe WarmPoolStatus)
-> (WarmPoolConfiguration
    -> Maybe WarmPoolStatus -> WarmPoolConfiguration)
-> Lens
     WarmPoolConfiguration
     WarmPoolConfiguration
     (Maybe WarmPoolStatus)
     (Maybe WarmPoolStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WarmPoolConfiguration' {Maybe WarmPoolStatus
status :: Maybe WarmPoolStatus
$sel:status:WarmPoolConfiguration' :: WarmPoolConfiguration -> Maybe WarmPoolStatus
status} -> Maybe WarmPoolStatus
status) (\s :: WarmPoolConfiguration
s@WarmPoolConfiguration' {} Maybe WarmPoolStatus
a -> WarmPoolConfiguration
s {$sel:status:WarmPoolConfiguration' :: Maybe WarmPoolStatus
status = Maybe WarmPoolStatus
a} :: WarmPoolConfiguration)

-- | The minimum number of instances to maintain in the warm pool.
warmPoolConfiguration_minSize :: Lens.Lens' WarmPoolConfiguration (Prelude.Maybe Prelude.Natural)
warmPoolConfiguration_minSize :: (Maybe Natural -> f (Maybe Natural))
-> WarmPoolConfiguration -> f WarmPoolConfiguration
warmPoolConfiguration_minSize = (WarmPoolConfiguration -> Maybe Natural)
-> (WarmPoolConfiguration
    -> Maybe Natural -> WarmPoolConfiguration)
-> Lens
     WarmPoolConfiguration
     WarmPoolConfiguration
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WarmPoolConfiguration' {Maybe Natural
minSize :: Maybe Natural
$sel:minSize:WarmPoolConfiguration' :: WarmPoolConfiguration -> Maybe Natural
minSize} -> Maybe Natural
minSize) (\s :: WarmPoolConfiguration
s@WarmPoolConfiguration' {} Maybe Natural
a -> WarmPoolConfiguration
s {$sel:minSize:WarmPoolConfiguration' :: Maybe Natural
minSize = Maybe Natural
a} :: WarmPoolConfiguration)

-- | The maximum number of instances that are allowed to be in the warm pool
-- or in any state except @Terminated@ for the Auto Scaling group.
warmPoolConfiguration_maxGroupPreparedCapacity :: Lens.Lens' WarmPoolConfiguration (Prelude.Maybe Prelude.Int)
warmPoolConfiguration_maxGroupPreparedCapacity :: (Maybe Int -> f (Maybe Int))
-> WarmPoolConfiguration -> f WarmPoolConfiguration
warmPoolConfiguration_maxGroupPreparedCapacity = (WarmPoolConfiguration -> Maybe Int)
-> (WarmPoolConfiguration -> Maybe Int -> WarmPoolConfiguration)
-> Lens
     WarmPoolConfiguration WarmPoolConfiguration (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WarmPoolConfiguration' {Maybe Int
maxGroupPreparedCapacity :: Maybe Int
$sel:maxGroupPreparedCapacity:WarmPoolConfiguration' :: WarmPoolConfiguration -> Maybe Int
maxGroupPreparedCapacity} -> Maybe Int
maxGroupPreparedCapacity) (\s :: WarmPoolConfiguration
s@WarmPoolConfiguration' {} Maybe Int
a -> WarmPoolConfiguration
s {$sel:maxGroupPreparedCapacity:WarmPoolConfiguration' :: Maybe Int
maxGroupPreparedCapacity = Maybe Int
a} :: WarmPoolConfiguration)

-- | The instance state to transition to after the lifecycle actions are
-- complete.
warmPoolConfiguration_poolState :: Lens.Lens' WarmPoolConfiguration (Prelude.Maybe WarmPoolState)
warmPoolConfiguration_poolState :: (Maybe WarmPoolState -> f (Maybe WarmPoolState))
-> WarmPoolConfiguration -> f WarmPoolConfiguration
warmPoolConfiguration_poolState = (WarmPoolConfiguration -> Maybe WarmPoolState)
-> (WarmPoolConfiguration
    -> Maybe WarmPoolState -> WarmPoolConfiguration)
-> Lens
     WarmPoolConfiguration
     WarmPoolConfiguration
     (Maybe WarmPoolState)
     (Maybe WarmPoolState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WarmPoolConfiguration' {Maybe WarmPoolState
poolState :: Maybe WarmPoolState
$sel:poolState:WarmPoolConfiguration' :: WarmPoolConfiguration -> Maybe WarmPoolState
poolState} -> Maybe WarmPoolState
poolState) (\s :: WarmPoolConfiguration
s@WarmPoolConfiguration' {} Maybe WarmPoolState
a -> WarmPoolConfiguration
s {$sel:poolState:WarmPoolConfiguration' :: Maybe WarmPoolState
poolState = Maybe WarmPoolState
a} :: WarmPoolConfiguration)

instance Core.FromXML WarmPoolConfiguration where
  parseXML :: [Node] -> Either String WarmPoolConfiguration
parseXML [Node]
x =
    Maybe WarmPoolStatus
-> Maybe Natural
-> Maybe Int
-> Maybe WarmPoolState
-> WarmPoolConfiguration
WarmPoolConfiguration'
      (Maybe WarmPoolStatus
 -> Maybe Natural
 -> Maybe Int
 -> Maybe WarmPoolState
 -> WarmPoolConfiguration)
-> Either String (Maybe WarmPoolStatus)
-> Either
     String
     (Maybe Natural
      -> Maybe Int -> Maybe WarmPoolState -> WarmPoolConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe WarmPoolStatus)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Status")
      Either
  String
  (Maybe Natural
   -> Maybe Int -> Maybe WarmPoolState -> WarmPoolConfiguration)
-> Either String (Maybe Natural)
-> Either
     String (Maybe Int -> Maybe WarmPoolState -> WarmPoolConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Natural)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"MinSize")
      Either
  String (Maybe Int -> Maybe WarmPoolState -> WarmPoolConfiguration)
-> Either String (Maybe Int)
-> Either String (Maybe WarmPoolState -> WarmPoolConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"MaxGroupPreparedCapacity")
      Either String (Maybe WarmPoolState -> WarmPoolConfiguration)
-> Either String (Maybe WarmPoolState)
-> Either String WarmPoolConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe WarmPoolState)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"PoolState")

instance Prelude.Hashable WarmPoolConfiguration

instance Prelude.NFData WarmPoolConfiguration