{-# 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.EKS.Types.NodegroupScalingConfig
-- 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.EKS.Types.NodegroupScalingConfig where

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

-- | An object representing the scaling configuration details for the Auto
-- Scaling group that is associated with your node group. When creating a
-- node group, you must specify all or none of the properties. When
-- updating a node group, you can specify any or none of the properties.
--
-- /See:/ 'newNodegroupScalingConfig' smart constructor.
data NodegroupScalingConfig = NodegroupScalingConfig'
  { -- | The current number of nodes that the managed node group should maintain.
    --
    -- If you use Cluster Autoscaler, you shouldn\'t change the desiredSize
    -- value directly, as this can cause the Cluster Autoscaler to suddenly
    -- scale up or scale down.
    --
    -- Whenever this parameter changes, the number of worker nodes in the node
    -- group is updated to the specified size. If this parameter is given a
    -- value that is smaller than the current number of running worker nodes,
    -- the necessary number of worker nodes are terminated to match the given
    -- value. When using CloudFormation, no action occurs if you remove this
    -- parameter from your CFN template.
    --
    -- This parameter can be different from minSize in some cases, such as when
    -- starting with extra hosts for testing. This parameter can also be
    -- different when you want to start with an estimated number of needed
    -- hosts, but let Cluster Autoscaler reduce the number if there are too
    -- many. When Cluster Autoscaler is used, the desiredSize parameter is
    -- altered by Cluster Autoscaler (but can be out-of-date for short periods
    -- of time). Cluster Autoscaler doesn\'t scale a managed node group lower
    -- than minSize or higher than maxSize.
    NodegroupScalingConfig -> Maybe Natural
desiredSize :: Prelude.Maybe Prelude.Natural,
    -- | The maximum number of nodes that the managed node group can scale out
    -- to. For information about the maximum number that you can specify, see
    -- <https://docs.aws.amazon.com/eks/latest/userguide/service-quotas.html Amazon EKS service quotas>
    -- in the /Amazon EKS User Guide/.
    NodegroupScalingConfig -> Maybe Natural
maxSize :: Prelude.Maybe Prelude.Natural,
    -- | The minimum number of nodes that the managed node group can scale in to.
    NodegroupScalingConfig -> Maybe Natural
minSize :: Prelude.Maybe Prelude.Natural
  }
  deriving (NodegroupScalingConfig -> NodegroupScalingConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NodegroupScalingConfig -> NodegroupScalingConfig -> Bool
$c/= :: NodegroupScalingConfig -> NodegroupScalingConfig -> Bool
== :: NodegroupScalingConfig -> NodegroupScalingConfig -> Bool
$c== :: NodegroupScalingConfig -> NodegroupScalingConfig -> Bool
Prelude.Eq, ReadPrec [NodegroupScalingConfig]
ReadPrec NodegroupScalingConfig
Int -> ReadS NodegroupScalingConfig
ReadS [NodegroupScalingConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NodegroupScalingConfig]
$creadListPrec :: ReadPrec [NodegroupScalingConfig]
readPrec :: ReadPrec NodegroupScalingConfig
$creadPrec :: ReadPrec NodegroupScalingConfig
readList :: ReadS [NodegroupScalingConfig]
$creadList :: ReadS [NodegroupScalingConfig]
readsPrec :: Int -> ReadS NodegroupScalingConfig
$creadsPrec :: Int -> ReadS NodegroupScalingConfig
Prelude.Read, Int -> NodegroupScalingConfig -> ShowS
[NodegroupScalingConfig] -> ShowS
NodegroupScalingConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NodegroupScalingConfig] -> ShowS
$cshowList :: [NodegroupScalingConfig] -> ShowS
show :: NodegroupScalingConfig -> String
$cshow :: NodegroupScalingConfig -> String
showsPrec :: Int -> NodegroupScalingConfig -> ShowS
$cshowsPrec :: Int -> NodegroupScalingConfig -> ShowS
Prelude.Show, forall x. Rep NodegroupScalingConfig x -> NodegroupScalingConfig
forall x. NodegroupScalingConfig -> Rep NodegroupScalingConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NodegroupScalingConfig x -> NodegroupScalingConfig
$cfrom :: forall x. NodegroupScalingConfig -> Rep NodegroupScalingConfig x
Prelude.Generic)

-- |
-- Create a value of 'NodegroupScalingConfig' 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:
--
-- 'desiredSize', 'nodegroupScalingConfig_desiredSize' - The current number of nodes that the managed node group should maintain.
--
-- If you use Cluster Autoscaler, you shouldn\'t change the desiredSize
-- value directly, as this can cause the Cluster Autoscaler to suddenly
-- scale up or scale down.
--
-- Whenever this parameter changes, the number of worker nodes in the node
-- group is updated to the specified size. If this parameter is given a
-- value that is smaller than the current number of running worker nodes,
-- the necessary number of worker nodes are terminated to match the given
-- value. When using CloudFormation, no action occurs if you remove this
-- parameter from your CFN template.
--
-- This parameter can be different from minSize in some cases, such as when
-- starting with extra hosts for testing. This parameter can also be
-- different when you want to start with an estimated number of needed
-- hosts, but let Cluster Autoscaler reduce the number if there are too
-- many. When Cluster Autoscaler is used, the desiredSize parameter is
-- altered by Cluster Autoscaler (but can be out-of-date for short periods
-- of time). Cluster Autoscaler doesn\'t scale a managed node group lower
-- than minSize or higher than maxSize.
--
-- 'maxSize', 'nodegroupScalingConfig_maxSize' - The maximum number of nodes that the managed node group can scale out
-- to. For information about the maximum number that you can specify, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/service-quotas.html Amazon EKS service quotas>
-- in the /Amazon EKS User Guide/.
--
-- 'minSize', 'nodegroupScalingConfig_minSize' - The minimum number of nodes that the managed node group can scale in to.
newNodegroupScalingConfig ::
  NodegroupScalingConfig
newNodegroupScalingConfig :: NodegroupScalingConfig
newNodegroupScalingConfig =
  NodegroupScalingConfig'
    { $sel:desiredSize:NodegroupScalingConfig' :: Maybe Natural
desiredSize =
        forall a. Maybe a
Prelude.Nothing,
      $sel:maxSize:NodegroupScalingConfig' :: Maybe Natural
maxSize = forall a. Maybe a
Prelude.Nothing,
      $sel:minSize:NodegroupScalingConfig' :: Maybe Natural
minSize = forall a. Maybe a
Prelude.Nothing
    }

-- | The current number of nodes that the managed node group should maintain.
--
-- If you use Cluster Autoscaler, you shouldn\'t change the desiredSize
-- value directly, as this can cause the Cluster Autoscaler to suddenly
-- scale up or scale down.
--
-- Whenever this parameter changes, the number of worker nodes in the node
-- group is updated to the specified size. If this parameter is given a
-- value that is smaller than the current number of running worker nodes,
-- the necessary number of worker nodes are terminated to match the given
-- value. When using CloudFormation, no action occurs if you remove this
-- parameter from your CFN template.
--
-- This parameter can be different from minSize in some cases, such as when
-- starting with extra hosts for testing. This parameter can also be
-- different when you want to start with an estimated number of needed
-- hosts, but let Cluster Autoscaler reduce the number if there are too
-- many. When Cluster Autoscaler is used, the desiredSize parameter is
-- altered by Cluster Autoscaler (but can be out-of-date for short periods
-- of time). Cluster Autoscaler doesn\'t scale a managed node group lower
-- than minSize or higher than maxSize.
nodegroupScalingConfig_desiredSize :: Lens.Lens' NodegroupScalingConfig (Prelude.Maybe Prelude.Natural)
nodegroupScalingConfig_desiredSize :: Lens' NodegroupScalingConfig (Maybe Natural)
nodegroupScalingConfig_desiredSize = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodegroupScalingConfig' {Maybe Natural
desiredSize :: Maybe Natural
$sel:desiredSize:NodegroupScalingConfig' :: NodegroupScalingConfig -> Maybe Natural
desiredSize} -> Maybe Natural
desiredSize) (\s :: NodegroupScalingConfig
s@NodegroupScalingConfig' {} Maybe Natural
a -> NodegroupScalingConfig
s {$sel:desiredSize:NodegroupScalingConfig' :: Maybe Natural
desiredSize = Maybe Natural
a} :: NodegroupScalingConfig)

-- | The maximum number of nodes that the managed node group can scale out
-- to. For information about the maximum number that you can specify, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/service-quotas.html Amazon EKS service quotas>
-- in the /Amazon EKS User Guide/.
nodegroupScalingConfig_maxSize :: Lens.Lens' NodegroupScalingConfig (Prelude.Maybe Prelude.Natural)
nodegroupScalingConfig_maxSize :: Lens' NodegroupScalingConfig (Maybe Natural)
nodegroupScalingConfig_maxSize = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodegroupScalingConfig' {Maybe Natural
maxSize :: Maybe Natural
$sel:maxSize:NodegroupScalingConfig' :: NodegroupScalingConfig -> Maybe Natural
maxSize} -> Maybe Natural
maxSize) (\s :: NodegroupScalingConfig
s@NodegroupScalingConfig' {} Maybe Natural
a -> NodegroupScalingConfig
s {$sel:maxSize:NodegroupScalingConfig' :: Maybe Natural
maxSize = Maybe Natural
a} :: NodegroupScalingConfig)

-- | The minimum number of nodes that the managed node group can scale in to.
nodegroupScalingConfig_minSize :: Lens.Lens' NodegroupScalingConfig (Prelude.Maybe Prelude.Natural)
nodegroupScalingConfig_minSize :: Lens' NodegroupScalingConfig (Maybe Natural)
nodegroupScalingConfig_minSize = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodegroupScalingConfig' {Maybe Natural
minSize :: Maybe Natural
$sel:minSize:NodegroupScalingConfig' :: NodegroupScalingConfig -> Maybe Natural
minSize} -> Maybe Natural
minSize) (\s :: NodegroupScalingConfig
s@NodegroupScalingConfig' {} Maybe Natural
a -> NodegroupScalingConfig
s {$sel:minSize:NodegroupScalingConfig' :: Maybe Natural
minSize = Maybe Natural
a} :: NodegroupScalingConfig)

instance Data.FromJSON NodegroupScalingConfig where
  parseJSON :: Value -> Parser NodegroupScalingConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NodegroupScalingConfig"
      ( \Object
x ->
          Maybe Natural
-> Maybe Natural -> Maybe Natural -> NodegroupScalingConfig
NodegroupScalingConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"desiredSize")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"maxSize")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"minSize")
      )

instance Prelude.Hashable NodegroupScalingConfig where
  hashWithSalt :: Int -> NodegroupScalingConfig -> Int
hashWithSalt Int
_salt NodegroupScalingConfig' {Maybe Natural
minSize :: Maybe Natural
maxSize :: Maybe Natural
desiredSize :: Maybe Natural
$sel:minSize:NodegroupScalingConfig' :: NodegroupScalingConfig -> Maybe Natural
$sel:maxSize:NodegroupScalingConfig' :: NodegroupScalingConfig -> Maybe Natural
$sel:desiredSize:NodegroupScalingConfig' :: NodegroupScalingConfig -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
desiredSize
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxSize
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
minSize

instance Prelude.NFData NodegroupScalingConfig where
  rnf :: NodegroupScalingConfig -> ()
rnf NodegroupScalingConfig' {Maybe Natural
minSize :: Maybe Natural
maxSize :: Maybe Natural
desiredSize :: Maybe Natural
$sel:minSize:NodegroupScalingConfig' :: NodegroupScalingConfig -> Maybe Natural
$sel:maxSize:NodegroupScalingConfig' :: NodegroupScalingConfig -> Maybe Natural
$sel:desiredSize:NodegroupScalingConfig' :: NodegroupScalingConfig -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
desiredSize
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxSize
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
minSize

instance Data.ToJSON NodegroupScalingConfig where
  toJSON :: NodegroupScalingConfig -> Value
toJSON NodegroupScalingConfig' {Maybe Natural
minSize :: Maybe Natural
maxSize :: Maybe Natural
desiredSize :: Maybe Natural
$sel:minSize:NodegroupScalingConfig' :: NodegroupScalingConfig -> Maybe Natural
$sel:maxSize:NodegroupScalingConfig' :: NodegroupScalingConfig -> Maybe Natural
$sel:desiredSize:NodegroupScalingConfig' :: NodegroupScalingConfig -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"desiredSize" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
desiredSize,
            (Key
"maxSize" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxSize,
            (Key
"minSize" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
minSize
          ]
      )