{-# 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.NodegroupUpdateConfig
-- 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.NodegroupUpdateConfig 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

-- | The node group update configuration.
--
-- /See:/ 'newNodegroupUpdateConfig' smart constructor.
data NodegroupUpdateConfig = NodegroupUpdateConfig'
  { -- | The maximum number of nodes unavailable at once during a version update.
    -- Nodes will be updated in parallel. This value or
    -- @maxUnavailablePercentage@ is required to have a value.The maximum
    -- number is 100.
    NodegroupUpdateConfig -> Maybe Natural
maxUnavailable :: Prelude.Maybe Prelude.Natural,
    -- | The maximum percentage of nodes unavailable during a version update.
    -- This percentage of nodes will be updated in parallel, up to 100 nodes at
    -- once. This value or @maxUnavailable@ is required to have a value.
    NodegroupUpdateConfig -> Maybe Natural
maxUnavailablePercentage :: Prelude.Maybe Prelude.Natural
  }
  deriving (NodegroupUpdateConfig -> NodegroupUpdateConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NodegroupUpdateConfig -> NodegroupUpdateConfig -> Bool
$c/= :: NodegroupUpdateConfig -> NodegroupUpdateConfig -> Bool
== :: NodegroupUpdateConfig -> NodegroupUpdateConfig -> Bool
$c== :: NodegroupUpdateConfig -> NodegroupUpdateConfig -> Bool
Prelude.Eq, ReadPrec [NodegroupUpdateConfig]
ReadPrec NodegroupUpdateConfig
Int -> ReadS NodegroupUpdateConfig
ReadS [NodegroupUpdateConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NodegroupUpdateConfig]
$creadListPrec :: ReadPrec [NodegroupUpdateConfig]
readPrec :: ReadPrec NodegroupUpdateConfig
$creadPrec :: ReadPrec NodegroupUpdateConfig
readList :: ReadS [NodegroupUpdateConfig]
$creadList :: ReadS [NodegroupUpdateConfig]
readsPrec :: Int -> ReadS NodegroupUpdateConfig
$creadsPrec :: Int -> ReadS NodegroupUpdateConfig
Prelude.Read, Int -> NodegroupUpdateConfig -> ShowS
[NodegroupUpdateConfig] -> ShowS
NodegroupUpdateConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NodegroupUpdateConfig] -> ShowS
$cshowList :: [NodegroupUpdateConfig] -> ShowS
show :: NodegroupUpdateConfig -> String
$cshow :: NodegroupUpdateConfig -> String
showsPrec :: Int -> NodegroupUpdateConfig -> ShowS
$cshowsPrec :: Int -> NodegroupUpdateConfig -> ShowS
Prelude.Show, forall x. Rep NodegroupUpdateConfig x -> NodegroupUpdateConfig
forall x. NodegroupUpdateConfig -> Rep NodegroupUpdateConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NodegroupUpdateConfig x -> NodegroupUpdateConfig
$cfrom :: forall x. NodegroupUpdateConfig -> Rep NodegroupUpdateConfig x
Prelude.Generic)

-- |
-- Create a value of 'NodegroupUpdateConfig' 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:
--
-- 'maxUnavailable', 'nodegroupUpdateConfig_maxUnavailable' - The maximum number of nodes unavailable at once during a version update.
-- Nodes will be updated in parallel. This value or
-- @maxUnavailablePercentage@ is required to have a value.The maximum
-- number is 100.
--
-- 'maxUnavailablePercentage', 'nodegroupUpdateConfig_maxUnavailablePercentage' - The maximum percentage of nodes unavailable during a version update.
-- This percentage of nodes will be updated in parallel, up to 100 nodes at
-- once. This value or @maxUnavailable@ is required to have a value.
newNodegroupUpdateConfig ::
  NodegroupUpdateConfig
newNodegroupUpdateConfig :: NodegroupUpdateConfig
newNodegroupUpdateConfig =
  NodegroupUpdateConfig'
    { $sel:maxUnavailable:NodegroupUpdateConfig' :: Maybe Natural
maxUnavailable =
        forall a. Maybe a
Prelude.Nothing,
      $sel:maxUnavailablePercentage:NodegroupUpdateConfig' :: Maybe Natural
maxUnavailablePercentage = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of nodes unavailable at once during a version update.
-- Nodes will be updated in parallel. This value or
-- @maxUnavailablePercentage@ is required to have a value.The maximum
-- number is 100.
nodegroupUpdateConfig_maxUnavailable :: Lens.Lens' NodegroupUpdateConfig (Prelude.Maybe Prelude.Natural)
nodegroupUpdateConfig_maxUnavailable :: Lens' NodegroupUpdateConfig (Maybe Natural)
nodegroupUpdateConfig_maxUnavailable = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodegroupUpdateConfig' {Maybe Natural
maxUnavailable :: Maybe Natural
$sel:maxUnavailable:NodegroupUpdateConfig' :: NodegroupUpdateConfig -> Maybe Natural
maxUnavailable} -> Maybe Natural
maxUnavailable) (\s :: NodegroupUpdateConfig
s@NodegroupUpdateConfig' {} Maybe Natural
a -> NodegroupUpdateConfig
s {$sel:maxUnavailable:NodegroupUpdateConfig' :: Maybe Natural
maxUnavailable = Maybe Natural
a} :: NodegroupUpdateConfig)

-- | The maximum percentage of nodes unavailable during a version update.
-- This percentage of nodes will be updated in parallel, up to 100 nodes at
-- once. This value or @maxUnavailable@ is required to have a value.
nodegroupUpdateConfig_maxUnavailablePercentage :: Lens.Lens' NodegroupUpdateConfig (Prelude.Maybe Prelude.Natural)
nodegroupUpdateConfig_maxUnavailablePercentage :: Lens' NodegroupUpdateConfig (Maybe Natural)
nodegroupUpdateConfig_maxUnavailablePercentage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodegroupUpdateConfig' {Maybe Natural
maxUnavailablePercentage :: Maybe Natural
$sel:maxUnavailablePercentage:NodegroupUpdateConfig' :: NodegroupUpdateConfig -> Maybe Natural
maxUnavailablePercentage} -> Maybe Natural
maxUnavailablePercentage) (\s :: NodegroupUpdateConfig
s@NodegroupUpdateConfig' {} Maybe Natural
a -> NodegroupUpdateConfig
s {$sel:maxUnavailablePercentage:NodegroupUpdateConfig' :: Maybe Natural
maxUnavailablePercentage = Maybe Natural
a} :: NodegroupUpdateConfig)

instance Data.FromJSON NodegroupUpdateConfig where
  parseJSON :: Value -> Parser NodegroupUpdateConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NodegroupUpdateConfig"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> NodegroupUpdateConfig
NodegroupUpdateConfig'
            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
"maxUnavailable")
            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
"maxUnavailablePercentage")
      )

instance Prelude.Hashable NodegroupUpdateConfig where
  hashWithSalt :: Int -> NodegroupUpdateConfig -> Int
hashWithSalt Int
_salt NodegroupUpdateConfig' {Maybe Natural
maxUnavailablePercentage :: Maybe Natural
maxUnavailable :: Maybe Natural
$sel:maxUnavailablePercentage:NodegroupUpdateConfig' :: NodegroupUpdateConfig -> Maybe Natural
$sel:maxUnavailable:NodegroupUpdateConfig' :: NodegroupUpdateConfig -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxUnavailable
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxUnavailablePercentage

instance Prelude.NFData NodegroupUpdateConfig where
  rnf :: NodegroupUpdateConfig -> ()
rnf NodegroupUpdateConfig' {Maybe Natural
maxUnavailablePercentage :: Maybe Natural
maxUnavailable :: Maybe Natural
$sel:maxUnavailablePercentage:NodegroupUpdateConfig' :: NodegroupUpdateConfig -> Maybe Natural
$sel:maxUnavailable:NodegroupUpdateConfig' :: NodegroupUpdateConfig -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxUnavailable
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxUnavailablePercentage

instance Data.ToJSON NodegroupUpdateConfig where
  toJSON :: NodegroupUpdateConfig -> Value
toJSON NodegroupUpdateConfig' {Maybe Natural
maxUnavailablePercentage :: Maybe Natural
maxUnavailable :: Maybe Natural
$sel:maxUnavailablePercentage:NodegroupUpdateConfig' :: NodegroupUpdateConfig -> Maybe Natural
$sel:maxUnavailable:NodegroupUpdateConfig' :: NodegroupUpdateConfig -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"maxUnavailable" 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
maxUnavailable,
            (Key
"maxUnavailablePercentage" 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
maxUnavailablePercentage
          ]
      )