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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(NodegroupUpdateConfig -> NodegroupUpdateConfig -> Bool)
-> (NodegroupUpdateConfig -> NodegroupUpdateConfig -> Bool)
-> Eq NodegroupUpdateConfig
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]
(Int -> ReadS NodegroupUpdateConfig)
-> ReadS [NodegroupUpdateConfig]
-> ReadPrec NodegroupUpdateConfig
-> ReadPrec [NodegroupUpdateConfig]
-> Read 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
(Int -> NodegroupUpdateConfig -> ShowS)
-> (NodegroupUpdateConfig -> String)
-> ([NodegroupUpdateConfig] -> ShowS)
-> Show NodegroupUpdateConfig
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. NodegroupUpdateConfig -> Rep NodegroupUpdateConfig x)
-> (forall x. Rep NodegroupUpdateConfig x -> NodegroupUpdateConfig)
-> Generic NodegroupUpdateConfig
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' :: Maybe Natural -> Maybe Natural -> NodegroupUpdateConfig
NodegroupUpdateConfig'
    { $sel:maxUnavailable:NodegroupUpdateConfig' :: Maybe Natural
maxUnavailable =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:maxUnavailablePercentage:NodegroupUpdateConfig' :: Maybe Natural
maxUnavailablePercentage = Maybe Natural
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 :: (Maybe Natural -> f (Maybe Natural))
-> NodegroupUpdateConfig -> f NodegroupUpdateConfig
nodegroupUpdateConfig_maxUnavailable = (NodegroupUpdateConfig -> Maybe Natural)
-> (NodegroupUpdateConfig
    -> Maybe Natural -> NodegroupUpdateConfig)
-> Lens
     NodegroupUpdateConfig
     NodegroupUpdateConfig
     (Maybe Natural)
     (Maybe Natural)
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 :: (Maybe Natural -> f (Maybe Natural))
-> NodegroupUpdateConfig -> f NodegroupUpdateConfig
nodegroupUpdateConfig_maxUnavailablePercentage = (NodegroupUpdateConfig -> Maybe Natural)
-> (NodegroupUpdateConfig
    -> Maybe Natural -> NodegroupUpdateConfig)
-> Lens
     NodegroupUpdateConfig
     NodegroupUpdateConfig
     (Maybe Natural)
     (Maybe Natural)
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 Core.FromJSON NodegroupUpdateConfig where
  parseJSON :: Value -> Parser NodegroupUpdateConfig
parseJSON =
    String
-> (Object -> Parser NodegroupUpdateConfig)
-> Value
-> Parser NodegroupUpdateConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"NodegroupUpdateConfig"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> NodegroupUpdateConfig
NodegroupUpdateConfig'
            (Maybe Natural -> Maybe Natural -> NodegroupUpdateConfig)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> NodegroupUpdateConfig)
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
"maxUnavailable")
            Parser (Maybe Natural -> NodegroupUpdateConfig)
-> Parser (Maybe Natural) -> Parser NodegroupUpdateConfig
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
"maxUnavailablePercentage")
      )

instance Prelude.Hashable NodegroupUpdateConfig

instance Prelude.NFData NodegroupUpdateConfig

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