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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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.
    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
(NodegroupScalingConfig -> NodegroupScalingConfig -> Bool)
-> (NodegroupScalingConfig -> NodegroupScalingConfig -> Bool)
-> Eq NodegroupScalingConfig
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]
(Int -> ReadS NodegroupScalingConfig)
-> ReadS [NodegroupScalingConfig]
-> ReadPrec NodegroupScalingConfig
-> ReadPrec [NodegroupScalingConfig]
-> Read 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
(Int -> NodegroupScalingConfig -> ShowS)
-> (NodegroupScalingConfig -> String)
-> ([NodegroupScalingConfig] -> ShowS)
-> Show NodegroupScalingConfig
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. NodegroupScalingConfig -> Rep NodegroupScalingConfig x)
-> (forall x.
    Rep NodegroupScalingConfig x -> NodegroupScalingConfig)
-> Generic NodegroupScalingConfig
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.
--
-- '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' :: Maybe Natural
-> Maybe Natural -> Maybe Natural -> NodegroupScalingConfig
NodegroupScalingConfig'
    { $sel:desiredSize:NodegroupScalingConfig' :: Maybe Natural
desiredSize =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:maxSize:NodegroupScalingConfig' :: Maybe Natural
maxSize = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:minSize:NodegroupScalingConfig' :: Maybe Natural
minSize = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The current number of nodes that the managed node group should maintain.
nodegroupScalingConfig_desiredSize :: Lens.Lens' NodegroupScalingConfig (Prelude.Maybe Prelude.Natural)
nodegroupScalingConfig_desiredSize :: (Maybe Natural -> f (Maybe Natural))
-> NodegroupScalingConfig -> f NodegroupScalingConfig
nodegroupScalingConfig_desiredSize = (NodegroupScalingConfig -> Maybe Natural)
-> (NodegroupScalingConfig
    -> Maybe Natural -> NodegroupScalingConfig)
-> Lens
     NodegroupScalingConfig
     NodegroupScalingConfig
     (Maybe Natural)
     (Maybe Natural)
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 :: (Maybe Natural -> f (Maybe Natural))
-> NodegroupScalingConfig -> f NodegroupScalingConfig
nodegroupScalingConfig_maxSize = (NodegroupScalingConfig -> Maybe Natural)
-> (NodegroupScalingConfig
    -> Maybe Natural -> NodegroupScalingConfig)
-> Lens
     NodegroupScalingConfig
     NodegroupScalingConfig
     (Maybe Natural)
     (Maybe Natural)
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 :: (Maybe Natural -> f (Maybe Natural))
-> NodegroupScalingConfig -> f NodegroupScalingConfig
nodegroupScalingConfig_minSize = (NodegroupScalingConfig -> Maybe Natural)
-> (NodegroupScalingConfig
    -> Maybe Natural -> NodegroupScalingConfig)
-> Lens
     NodegroupScalingConfig
     NodegroupScalingConfig
     (Maybe Natural)
     (Maybe Natural)
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 Core.FromJSON NodegroupScalingConfig where
  parseJSON :: Value -> Parser NodegroupScalingConfig
parseJSON =
    String
-> (Object -> Parser NodegroupScalingConfig)
-> Value
-> Parser NodegroupScalingConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"NodegroupScalingConfig"
      ( \Object
x ->
          Maybe Natural
-> Maybe Natural -> Maybe Natural -> NodegroupScalingConfig
NodegroupScalingConfig'
            (Maybe Natural
 -> Maybe Natural -> Maybe Natural -> NodegroupScalingConfig)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural -> Maybe Natural -> NodegroupScalingConfig)
forall (f :: * -> *) a b. Functor 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
"desiredSize")
            Parser (Maybe Natural -> Maybe Natural -> NodegroupScalingConfig)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> NodegroupScalingConfig)
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
"maxSize")
            Parser (Maybe Natural -> NodegroupScalingConfig)
-> Parser (Maybe Natural) -> Parser NodegroupScalingConfig
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
"minSize")
      )

instance Prelude.Hashable NodegroupScalingConfig

instance Prelude.NFData NodegroupScalingConfig

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"desiredSize" 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
desiredSize,
            (Text
"maxSize" 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
maxSize,
            (Text
"minSize" 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
minSize
          ]
      )