{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AutoScaling.Types.WarmPoolConfiguration where

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

-- | Describes a warm pool configuration.
--
-- /See:/ 'newWarmPoolConfiguration' smart constructor.
data WarmPoolConfiguration = WarmPoolConfiguration'
  { -- | The instance reuse policy.
    WarmPoolConfiguration -> Maybe InstanceReusePolicy
instanceReusePolicy :: Prelude.Maybe InstanceReusePolicy,
    -- | 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 minimum number of instances to maintain in the warm pool.
    WarmPoolConfiguration -> Maybe Natural
minSize :: Prelude.Maybe Prelude.Natural,
    -- | The instance state to transition to after the lifecycle actions are
    -- complete.
    WarmPoolConfiguration -> Maybe WarmPoolState
poolState :: Prelude.Maybe WarmPoolState,
    -- | The status of a warm pool that is marked for deletion.
    WarmPoolConfiguration -> Maybe WarmPoolStatus
status :: Prelude.Maybe WarmPoolStatus
  }
  deriving (WarmPoolConfiguration -> WarmPoolConfiguration -> Bool
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]
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
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. 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:
--
-- 'instanceReusePolicy', 'warmPoolConfiguration_instanceReusePolicy' - The instance reuse policy.
--
-- '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.
--
-- 'minSize', 'warmPoolConfiguration_minSize' - The minimum number of instances to maintain in the warm pool.
--
-- 'poolState', 'warmPoolConfiguration_poolState' - The instance state to transition to after the lifecycle actions are
-- complete.
--
-- 'status', 'warmPoolConfiguration_status' - The status of a warm pool that is marked for deletion.
newWarmPoolConfiguration ::
  WarmPoolConfiguration
newWarmPoolConfiguration :: WarmPoolConfiguration
newWarmPoolConfiguration =
  WarmPoolConfiguration'
    { $sel:instanceReusePolicy:WarmPoolConfiguration' :: Maybe InstanceReusePolicy
instanceReusePolicy =
        forall a. Maybe a
Prelude.Nothing,
      $sel:maxGroupPreparedCapacity:WarmPoolConfiguration' :: Maybe Int
maxGroupPreparedCapacity = forall a. Maybe a
Prelude.Nothing,
      $sel:minSize:WarmPoolConfiguration' :: Maybe Natural
minSize = forall a. Maybe a
Prelude.Nothing,
      $sel:poolState:WarmPoolConfiguration' :: Maybe WarmPoolState
poolState = forall a. Maybe a
Prelude.Nothing,
      $sel:status:WarmPoolConfiguration' :: Maybe WarmPoolStatus
status = forall a. Maybe a
Prelude.Nothing
    }

-- | The instance reuse policy.
warmPoolConfiguration_instanceReusePolicy :: Lens.Lens' WarmPoolConfiguration (Prelude.Maybe InstanceReusePolicy)
warmPoolConfiguration_instanceReusePolicy :: Lens' WarmPoolConfiguration (Maybe InstanceReusePolicy)
warmPoolConfiguration_instanceReusePolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WarmPoolConfiguration' {Maybe InstanceReusePolicy
instanceReusePolicy :: Maybe InstanceReusePolicy
$sel:instanceReusePolicy:WarmPoolConfiguration' :: WarmPoolConfiguration -> Maybe InstanceReusePolicy
instanceReusePolicy} -> Maybe InstanceReusePolicy
instanceReusePolicy) (\s :: WarmPoolConfiguration
s@WarmPoolConfiguration' {} Maybe InstanceReusePolicy
a -> WarmPoolConfiguration
s {$sel:instanceReusePolicy:WarmPoolConfiguration' :: Maybe InstanceReusePolicy
instanceReusePolicy = Maybe InstanceReusePolicy
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 :: Lens' WarmPoolConfiguration (Maybe Int)
warmPoolConfiguration_maxGroupPreparedCapacity = 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 minimum number of instances to maintain in the warm pool.
warmPoolConfiguration_minSize :: Lens.Lens' WarmPoolConfiguration (Prelude.Maybe Prelude.Natural)
warmPoolConfiguration_minSize :: Lens' WarmPoolConfiguration (Maybe Natural)
warmPoolConfiguration_minSize = 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 instance state to transition to after the lifecycle actions are
-- complete.
warmPoolConfiguration_poolState :: Lens.Lens' WarmPoolConfiguration (Prelude.Maybe WarmPoolState)
warmPoolConfiguration_poolState :: Lens' WarmPoolConfiguration (Maybe WarmPoolState)
warmPoolConfiguration_poolState = 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)

-- | The status of a warm pool that is marked for deletion.
warmPoolConfiguration_status :: Lens.Lens' WarmPoolConfiguration (Prelude.Maybe WarmPoolStatus)
warmPoolConfiguration_status :: Lens' WarmPoolConfiguration (Maybe WarmPoolStatus)
warmPoolConfiguration_status = 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)

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

instance Prelude.Hashable WarmPoolConfiguration where
  hashWithSalt :: Int -> WarmPoolConfiguration -> Int
hashWithSalt Int
_salt WarmPoolConfiguration' {Maybe Int
Maybe Natural
Maybe InstanceReusePolicy
Maybe WarmPoolState
Maybe WarmPoolStatus
status :: Maybe WarmPoolStatus
poolState :: Maybe WarmPoolState
minSize :: Maybe Natural
maxGroupPreparedCapacity :: Maybe Int
instanceReusePolicy :: Maybe InstanceReusePolicy
$sel:status:WarmPoolConfiguration' :: WarmPoolConfiguration -> Maybe WarmPoolStatus
$sel:poolState:WarmPoolConfiguration' :: WarmPoolConfiguration -> Maybe WarmPoolState
$sel:minSize:WarmPoolConfiguration' :: WarmPoolConfiguration -> Maybe Natural
$sel:maxGroupPreparedCapacity:WarmPoolConfiguration' :: WarmPoolConfiguration -> Maybe Int
$sel:instanceReusePolicy:WarmPoolConfiguration' :: WarmPoolConfiguration -> Maybe InstanceReusePolicy
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InstanceReusePolicy
instanceReusePolicy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
maxGroupPreparedCapacity
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
minSize
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe WarmPoolState
poolState
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe WarmPoolStatus
status

instance Prelude.NFData WarmPoolConfiguration where
  rnf :: WarmPoolConfiguration -> ()
rnf WarmPoolConfiguration' {Maybe Int
Maybe Natural
Maybe InstanceReusePolicy
Maybe WarmPoolState
Maybe WarmPoolStatus
status :: Maybe WarmPoolStatus
poolState :: Maybe WarmPoolState
minSize :: Maybe Natural
maxGroupPreparedCapacity :: Maybe Int
instanceReusePolicy :: Maybe InstanceReusePolicy
$sel:status:WarmPoolConfiguration' :: WarmPoolConfiguration -> Maybe WarmPoolStatus
$sel:poolState:WarmPoolConfiguration' :: WarmPoolConfiguration -> Maybe WarmPoolState
$sel:minSize:WarmPoolConfiguration' :: WarmPoolConfiguration -> Maybe Natural
$sel:maxGroupPreparedCapacity:WarmPoolConfiguration' :: WarmPoolConfiguration -> Maybe Int
$sel:instanceReusePolicy:WarmPoolConfiguration' :: WarmPoolConfiguration -> Maybe InstanceReusePolicy
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe InstanceReusePolicy
instanceReusePolicy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
maxGroupPreparedCapacity
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
minSize
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe WarmPoolState
poolState
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe WarmPoolStatus
status