{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.UpdateNodegroupVersion
-- 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)
--
-- Updates the Kubernetes version or AMI version of an Amazon EKS managed
-- node group.
--
-- You can update a node group using a launch template only if the node
-- group was originally deployed with a launch template. If you need to
-- update a custom AMI in a node group that was deployed with a launch
-- template, then update your custom AMI, specify the new ID in a new
-- version of the launch template, and then update the node group to the
-- new version of the launch template.
--
-- If you update without a launch template, then you can update to the
-- latest available AMI version of a node group\'s current Kubernetes
-- version by not specifying a Kubernetes version in the request. You can
-- update to the latest AMI version of your cluster\'s current Kubernetes
-- version by specifying your cluster\'s Kubernetes version in the request.
-- For more information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/eks-linux-ami-versions.html Amazon EKS optimized Amazon Linux 2 AMI versions>
-- in the /Amazon EKS User Guide/.
--
-- You cannot roll back a node group to an earlier Kubernetes version or
-- AMI version.
--
-- When a node in a managed node group is terminated due to a scaling
-- action or update, the pods in that node are drained first. Amazon EKS
-- attempts to drain the nodes gracefully and will fail if it is unable to
-- do so. You can @force@ the update if Amazon EKS is unable to drain the
-- nodes as a result of a pod disruption budget issue.
module Amazonka.EKS.UpdateNodegroupVersion
  ( -- * Creating a Request
    UpdateNodegroupVersion (..),
    newUpdateNodegroupVersion,

    -- * Request Lenses
    updateNodegroupVersion_force,
    updateNodegroupVersion_releaseVersion,
    updateNodegroupVersion_version,
    updateNodegroupVersion_launchTemplate,
    updateNodegroupVersion_clientRequestToken,
    updateNodegroupVersion_clusterName,
    updateNodegroupVersion_nodegroupName,

    -- * Destructuring the Response
    UpdateNodegroupVersionResponse (..),
    newUpdateNodegroupVersionResponse,

    -- * Response Lenses
    updateNodegroupVersionResponse_update,
    updateNodegroupVersionResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.EKS.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateNodegroupVersion' smart constructor.
data UpdateNodegroupVersion = UpdateNodegroupVersion'
  { -- | Force the update if the existing node group\'s pods are unable to be
    -- drained due to a pod disruption budget issue. If an update fails because
    -- pods could not be drained, you can force the update after it fails to
    -- terminate the old node whether or not any pods are running on the node.
    UpdateNodegroupVersion -> Maybe Bool
force :: Prelude.Maybe Prelude.Bool,
    -- | The AMI version of the Amazon EKS optimized AMI to use for the update.
    -- By default, the latest available AMI version for the node group\'s
    -- Kubernetes version is used. For more information, see
    -- <https://docs.aws.amazon.com/eks/latest/userguide/eks-linux-ami-versions.html Amazon EKS optimized Amazon Linux 2 AMI versions>
    -- in the /Amazon EKS User Guide/. If you specify @launchTemplate@, and
    -- your launch template uses a custom AMI, then don\'t specify
    -- @releaseVersion@, or the node group update will fail. For more
    -- information about using launch templates with Amazon EKS, see
    -- <https://docs.aws.amazon.com/eks/latest/userguide/launch-templates.html Launch template support>
    -- in the Amazon EKS User Guide.
    UpdateNodegroupVersion -> Maybe Text
releaseVersion :: Prelude.Maybe Prelude.Text,
    -- | The Kubernetes version to update to. If no version is specified, then
    -- the Kubernetes version of the node group does not change. You can
    -- specify the Kubernetes version of the cluster to update the node group
    -- to the latest AMI version of the cluster\'s Kubernetes version. If you
    -- specify @launchTemplate@, and your launch template uses a custom AMI,
    -- then don\'t specify @version@, or the node group update will fail. For
    -- more information about using launch templates with Amazon EKS, see
    -- <https://docs.aws.amazon.com/eks/latest/userguide/launch-templates.html Launch template support>
    -- in the Amazon EKS User Guide.
    UpdateNodegroupVersion -> Maybe Text
version :: Prelude.Maybe Prelude.Text,
    -- | An object representing a node group\'s launch template specification.
    -- You can only update a node group using a launch template if the node
    -- group was originally deployed with a launch template.
    UpdateNodegroupVersion -> Maybe LaunchTemplateSpecification
launchTemplate :: Prelude.Maybe LaunchTemplateSpecification,
    -- | Unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request.
    UpdateNodegroupVersion -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the Amazon EKS cluster that is associated with the managed
    -- node group to update.
    UpdateNodegroupVersion -> Text
clusterName :: Prelude.Text,
    -- | The name of the managed node group to update.
    UpdateNodegroupVersion -> Text
nodegroupName :: Prelude.Text
  }
  deriving (UpdateNodegroupVersion -> UpdateNodegroupVersion -> Bool
(UpdateNodegroupVersion -> UpdateNodegroupVersion -> Bool)
-> (UpdateNodegroupVersion -> UpdateNodegroupVersion -> Bool)
-> Eq UpdateNodegroupVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateNodegroupVersion -> UpdateNodegroupVersion -> Bool
$c/= :: UpdateNodegroupVersion -> UpdateNodegroupVersion -> Bool
== :: UpdateNodegroupVersion -> UpdateNodegroupVersion -> Bool
$c== :: UpdateNodegroupVersion -> UpdateNodegroupVersion -> Bool
Prelude.Eq, ReadPrec [UpdateNodegroupVersion]
ReadPrec UpdateNodegroupVersion
Int -> ReadS UpdateNodegroupVersion
ReadS [UpdateNodegroupVersion]
(Int -> ReadS UpdateNodegroupVersion)
-> ReadS [UpdateNodegroupVersion]
-> ReadPrec UpdateNodegroupVersion
-> ReadPrec [UpdateNodegroupVersion]
-> Read UpdateNodegroupVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateNodegroupVersion]
$creadListPrec :: ReadPrec [UpdateNodegroupVersion]
readPrec :: ReadPrec UpdateNodegroupVersion
$creadPrec :: ReadPrec UpdateNodegroupVersion
readList :: ReadS [UpdateNodegroupVersion]
$creadList :: ReadS [UpdateNodegroupVersion]
readsPrec :: Int -> ReadS UpdateNodegroupVersion
$creadsPrec :: Int -> ReadS UpdateNodegroupVersion
Prelude.Read, Int -> UpdateNodegroupVersion -> ShowS
[UpdateNodegroupVersion] -> ShowS
UpdateNodegroupVersion -> String
(Int -> UpdateNodegroupVersion -> ShowS)
-> (UpdateNodegroupVersion -> String)
-> ([UpdateNodegroupVersion] -> ShowS)
-> Show UpdateNodegroupVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateNodegroupVersion] -> ShowS
$cshowList :: [UpdateNodegroupVersion] -> ShowS
show :: UpdateNodegroupVersion -> String
$cshow :: UpdateNodegroupVersion -> String
showsPrec :: Int -> UpdateNodegroupVersion -> ShowS
$cshowsPrec :: Int -> UpdateNodegroupVersion -> ShowS
Prelude.Show, (forall x. UpdateNodegroupVersion -> Rep UpdateNodegroupVersion x)
-> (forall x.
    Rep UpdateNodegroupVersion x -> UpdateNodegroupVersion)
-> Generic UpdateNodegroupVersion
forall x. Rep UpdateNodegroupVersion x -> UpdateNodegroupVersion
forall x. UpdateNodegroupVersion -> Rep UpdateNodegroupVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateNodegroupVersion x -> UpdateNodegroupVersion
$cfrom :: forall x. UpdateNodegroupVersion -> Rep UpdateNodegroupVersion x
Prelude.Generic)

-- |
-- Create a value of 'UpdateNodegroupVersion' 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:
--
-- 'force', 'updateNodegroupVersion_force' - Force the update if the existing node group\'s pods are unable to be
-- drained due to a pod disruption budget issue. If an update fails because
-- pods could not be drained, you can force the update after it fails to
-- terminate the old node whether or not any pods are running on the node.
--
-- 'releaseVersion', 'updateNodegroupVersion_releaseVersion' - The AMI version of the Amazon EKS optimized AMI to use for the update.
-- By default, the latest available AMI version for the node group\'s
-- Kubernetes version is used. For more information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/eks-linux-ami-versions.html Amazon EKS optimized Amazon Linux 2 AMI versions>
-- in the /Amazon EKS User Guide/. If you specify @launchTemplate@, and
-- your launch template uses a custom AMI, then don\'t specify
-- @releaseVersion@, or the node group update will fail. For more
-- information about using launch templates with Amazon EKS, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/launch-templates.html Launch template support>
-- in the Amazon EKS User Guide.
--
-- 'version', 'updateNodegroupVersion_version' - The Kubernetes version to update to. If no version is specified, then
-- the Kubernetes version of the node group does not change. You can
-- specify the Kubernetes version of the cluster to update the node group
-- to the latest AMI version of the cluster\'s Kubernetes version. If you
-- specify @launchTemplate@, and your launch template uses a custom AMI,
-- then don\'t specify @version@, or the node group update will fail. For
-- more information about using launch templates with Amazon EKS, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/launch-templates.html Launch template support>
-- in the Amazon EKS User Guide.
--
-- 'launchTemplate', 'updateNodegroupVersion_launchTemplate' - An object representing a node group\'s launch template specification.
-- You can only update a node group using a launch template if the node
-- group was originally deployed with a launch template.
--
-- 'clientRequestToken', 'updateNodegroupVersion_clientRequestToken' - Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
--
-- 'clusterName', 'updateNodegroupVersion_clusterName' - The name of the Amazon EKS cluster that is associated with the managed
-- node group to update.
--
-- 'nodegroupName', 'updateNodegroupVersion_nodegroupName' - The name of the managed node group to update.
newUpdateNodegroupVersion ::
  -- | 'clusterName'
  Prelude.Text ->
  -- | 'nodegroupName'
  Prelude.Text ->
  UpdateNodegroupVersion
newUpdateNodegroupVersion :: Text -> Text -> UpdateNodegroupVersion
newUpdateNodegroupVersion
  Text
pClusterName_
  Text
pNodegroupName_ =
    UpdateNodegroupVersion' :: Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe LaunchTemplateSpecification
-> Maybe Text
-> Text
-> Text
-> UpdateNodegroupVersion
UpdateNodegroupVersion'
      { $sel:force:UpdateNodegroupVersion' :: Maybe Bool
force = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
        $sel:releaseVersion:UpdateNodegroupVersion' :: Maybe Text
releaseVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:version:UpdateNodegroupVersion' :: Maybe Text
version = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:launchTemplate:UpdateNodegroupVersion' :: Maybe LaunchTemplateSpecification
launchTemplate = Maybe LaunchTemplateSpecification
forall a. Maybe a
Prelude.Nothing,
        $sel:clientRequestToken:UpdateNodegroupVersion' :: Maybe Text
clientRequestToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:clusterName:UpdateNodegroupVersion' :: Text
clusterName = Text
pClusterName_,
        $sel:nodegroupName:UpdateNodegroupVersion' :: Text
nodegroupName = Text
pNodegroupName_
      }

-- | Force the update if the existing node group\'s pods are unable to be
-- drained due to a pod disruption budget issue. If an update fails because
-- pods could not be drained, you can force the update after it fails to
-- terminate the old node whether or not any pods are running on the node.
updateNodegroupVersion_force :: Lens.Lens' UpdateNodegroupVersion (Prelude.Maybe Prelude.Bool)
updateNodegroupVersion_force :: (Maybe Bool -> f (Maybe Bool))
-> UpdateNodegroupVersion -> f UpdateNodegroupVersion
updateNodegroupVersion_force = (UpdateNodegroupVersion -> Maybe Bool)
-> (UpdateNodegroupVersion -> Maybe Bool -> UpdateNodegroupVersion)
-> Lens
     UpdateNodegroupVersion
     UpdateNodegroupVersion
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateNodegroupVersion' {Maybe Bool
force :: Maybe Bool
$sel:force:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Maybe Bool
force} -> Maybe Bool
force) (\s :: UpdateNodegroupVersion
s@UpdateNodegroupVersion' {} Maybe Bool
a -> UpdateNodegroupVersion
s {$sel:force:UpdateNodegroupVersion' :: Maybe Bool
force = Maybe Bool
a} :: UpdateNodegroupVersion)

-- | The AMI version of the Amazon EKS optimized AMI to use for the update.
-- By default, the latest available AMI version for the node group\'s
-- Kubernetes version is used. For more information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/eks-linux-ami-versions.html Amazon EKS optimized Amazon Linux 2 AMI versions>
-- in the /Amazon EKS User Guide/. If you specify @launchTemplate@, and
-- your launch template uses a custom AMI, then don\'t specify
-- @releaseVersion@, or the node group update will fail. For more
-- information about using launch templates with Amazon EKS, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/launch-templates.html Launch template support>
-- in the Amazon EKS User Guide.
updateNodegroupVersion_releaseVersion :: Lens.Lens' UpdateNodegroupVersion (Prelude.Maybe Prelude.Text)
updateNodegroupVersion_releaseVersion :: (Maybe Text -> f (Maybe Text))
-> UpdateNodegroupVersion -> f UpdateNodegroupVersion
updateNodegroupVersion_releaseVersion = (UpdateNodegroupVersion -> Maybe Text)
-> (UpdateNodegroupVersion -> Maybe Text -> UpdateNodegroupVersion)
-> Lens
     UpdateNodegroupVersion
     UpdateNodegroupVersion
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateNodegroupVersion' {Maybe Text
releaseVersion :: Maybe Text
$sel:releaseVersion:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Maybe Text
releaseVersion} -> Maybe Text
releaseVersion) (\s :: UpdateNodegroupVersion
s@UpdateNodegroupVersion' {} Maybe Text
a -> UpdateNodegroupVersion
s {$sel:releaseVersion:UpdateNodegroupVersion' :: Maybe Text
releaseVersion = Maybe Text
a} :: UpdateNodegroupVersion)

-- | The Kubernetes version to update to. If no version is specified, then
-- the Kubernetes version of the node group does not change. You can
-- specify the Kubernetes version of the cluster to update the node group
-- to the latest AMI version of the cluster\'s Kubernetes version. If you
-- specify @launchTemplate@, and your launch template uses a custom AMI,
-- then don\'t specify @version@, or the node group update will fail. For
-- more information about using launch templates with Amazon EKS, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/launch-templates.html Launch template support>
-- in the Amazon EKS User Guide.
updateNodegroupVersion_version :: Lens.Lens' UpdateNodegroupVersion (Prelude.Maybe Prelude.Text)
updateNodegroupVersion_version :: (Maybe Text -> f (Maybe Text))
-> UpdateNodegroupVersion -> f UpdateNodegroupVersion
updateNodegroupVersion_version = (UpdateNodegroupVersion -> Maybe Text)
-> (UpdateNodegroupVersion -> Maybe Text -> UpdateNodegroupVersion)
-> Lens
     UpdateNodegroupVersion
     UpdateNodegroupVersion
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateNodegroupVersion' {Maybe Text
version :: Maybe Text
$sel:version:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Maybe Text
version} -> Maybe Text
version) (\s :: UpdateNodegroupVersion
s@UpdateNodegroupVersion' {} Maybe Text
a -> UpdateNodegroupVersion
s {$sel:version:UpdateNodegroupVersion' :: Maybe Text
version = Maybe Text
a} :: UpdateNodegroupVersion)

-- | An object representing a node group\'s launch template specification.
-- You can only update a node group using a launch template if the node
-- group was originally deployed with a launch template.
updateNodegroupVersion_launchTemplate :: Lens.Lens' UpdateNodegroupVersion (Prelude.Maybe LaunchTemplateSpecification)
updateNodegroupVersion_launchTemplate :: (Maybe LaunchTemplateSpecification
 -> f (Maybe LaunchTemplateSpecification))
-> UpdateNodegroupVersion -> f UpdateNodegroupVersion
updateNodegroupVersion_launchTemplate = (UpdateNodegroupVersion -> Maybe LaunchTemplateSpecification)
-> (UpdateNodegroupVersion
    -> Maybe LaunchTemplateSpecification -> UpdateNodegroupVersion)
-> Lens
     UpdateNodegroupVersion
     UpdateNodegroupVersion
     (Maybe LaunchTemplateSpecification)
     (Maybe LaunchTemplateSpecification)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateNodegroupVersion' {Maybe LaunchTemplateSpecification
launchTemplate :: Maybe LaunchTemplateSpecification
$sel:launchTemplate:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Maybe LaunchTemplateSpecification
launchTemplate} -> Maybe LaunchTemplateSpecification
launchTemplate) (\s :: UpdateNodegroupVersion
s@UpdateNodegroupVersion' {} Maybe LaunchTemplateSpecification
a -> UpdateNodegroupVersion
s {$sel:launchTemplate:UpdateNodegroupVersion' :: Maybe LaunchTemplateSpecification
launchTemplate = Maybe LaunchTemplateSpecification
a} :: UpdateNodegroupVersion)

-- | Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
updateNodegroupVersion_clientRequestToken :: Lens.Lens' UpdateNodegroupVersion (Prelude.Maybe Prelude.Text)
updateNodegroupVersion_clientRequestToken :: (Maybe Text -> f (Maybe Text))
-> UpdateNodegroupVersion -> f UpdateNodegroupVersion
updateNodegroupVersion_clientRequestToken = (UpdateNodegroupVersion -> Maybe Text)
-> (UpdateNodegroupVersion -> Maybe Text -> UpdateNodegroupVersion)
-> Lens
     UpdateNodegroupVersion
     UpdateNodegroupVersion
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateNodegroupVersion' {Maybe Text
clientRequestToken :: Maybe Text
$sel:clientRequestToken:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Maybe Text
clientRequestToken} -> Maybe Text
clientRequestToken) (\s :: UpdateNodegroupVersion
s@UpdateNodegroupVersion' {} Maybe Text
a -> UpdateNodegroupVersion
s {$sel:clientRequestToken:UpdateNodegroupVersion' :: Maybe Text
clientRequestToken = Maybe Text
a} :: UpdateNodegroupVersion)

-- | The name of the Amazon EKS cluster that is associated with the managed
-- node group to update.
updateNodegroupVersion_clusterName :: Lens.Lens' UpdateNodegroupVersion Prelude.Text
updateNodegroupVersion_clusterName :: (Text -> f Text)
-> UpdateNodegroupVersion -> f UpdateNodegroupVersion
updateNodegroupVersion_clusterName = (UpdateNodegroupVersion -> Text)
-> (UpdateNodegroupVersion -> Text -> UpdateNodegroupVersion)
-> Lens UpdateNodegroupVersion UpdateNodegroupVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateNodegroupVersion' {Text
clusterName :: Text
$sel:clusterName:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Text
clusterName} -> Text
clusterName) (\s :: UpdateNodegroupVersion
s@UpdateNodegroupVersion' {} Text
a -> UpdateNodegroupVersion
s {$sel:clusterName:UpdateNodegroupVersion' :: Text
clusterName = Text
a} :: UpdateNodegroupVersion)

-- | The name of the managed node group to update.
updateNodegroupVersion_nodegroupName :: Lens.Lens' UpdateNodegroupVersion Prelude.Text
updateNodegroupVersion_nodegroupName :: (Text -> f Text)
-> UpdateNodegroupVersion -> f UpdateNodegroupVersion
updateNodegroupVersion_nodegroupName = (UpdateNodegroupVersion -> Text)
-> (UpdateNodegroupVersion -> Text -> UpdateNodegroupVersion)
-> Lens UpdateNodegroupVersion UpdateNodegroupVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateNodegroupVersion' {Text
nodegroupName :: Text
$sel:nodegroupName:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Text
nodegroupName} -> Text
nodegroupName) (\s :: UpdateNodegroupVersion
s@UpdateNodegroupVersion' {} Text
a -> UpdateNodegroupVersion
s {$sel:nodegroupName:UpdateNodegroupVersion' :: Text
nodegroupName = Text
a} :: UpdateNodegroupVersion)

instance Core.AWSRequest UpdateNodegroupVersion where
  type
    AWSResponse UpdateNodegroupVersion =
      UpdateNodegroupVersionResponse
  request :: UpdateNodegroupVersion -> Request UpdateNodegroupVersion
request = Service -> UpdateNodegroupVersion -> Request UpdateNodegroupVersion
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateNodegroupVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateNodegroupVersion)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateNodegroupVersion))
-> Logger
-> Service
-> Proxy UpdateNodegroupVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateNodegroupVersion)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Update -> Int -> UpdateNodegroupVersionResponse
UpdateNodegroupVersionResponse'
            (Maybe Update -> Int -> UpdateNodegroupVersionResponse)
-> Either String (Maybe Update)
-> Either String (Int -> UpdateNodegroupVersionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Update)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"update")
            Either String (Int -> UpdateNodegroupVersionResponse)
-> Either String Int
-> Either String UpdateNodegroupVersionResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdateNodegroupVersion

instance Prelude.NFData UpdateNodegroupVersion

instance Core.ToHeaders UpdateNodegroupVersion where
  toHeaders :: UpdateNodegroupVersion -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateNodegroupVersion -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON UpdateNodegroupVersion where
  toJSON :: UpdateNodegroupVersion -> Value
toJSON UpdateNodegroupVersion' {Maybe Bool
Maybe Text
Maybe LaunchTemplateSpecification
Text
nodegroupName :: Text
clusterName :: Text
clientRequestToken :: Maybe Text
launchTemplate :: Maybe LaunchTemplateSpecification
version :: Maybe Text
releaseVersion :: Maybe Text
force :: Maybe Bool
$sel:nodegroupName:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Text
$sel:clusterName:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Text
$sel:clientRequestToken:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Maybe Text
$sel:launchTemplate:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Maybe LaunchTemplateSpecification
$sel:version:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Maybe Text
$sel:releaseVersion:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Maybe Text
$sel:force:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"force" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
force,
            (Text
"releaseVersion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
releaseVersion,
            (Text
"version" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
version,
            (Text
"launchTemplate" Text -> LaunchTemplateSpecification -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (LaunchTemplateSpecification -> Pair)
-> Maybe LaunchTemplateSpecification -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LaunchTemplateSpecification
launchTemplate,
            (Text
"clientRequestToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientRequestToken
          ]
      )

instance Core.ToPath UpdateNodegroupVersion where
  toPath :: UpdateNodegroupVersion -> ByteString
toPath UpdateNodegroupVersion' {Maybe Bool
Maybe Text
Maybe LaunchTemplateSpecification
Text
nodegroupName :: Text
clusterName :: Text
clientRequestToken :: Maybe Text
launchTemplate :: Maybe LaunchTemplateSpecification
version :: Maybe Text
releaseVersion :: Maybe Text
force :: Maybe Bool
$sel:nodegroupName:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Text
$sel:clusterName:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Text
$sel:clientRequestToken:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Maybe Text
$sel:launchTemplate:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Maybe LaunchTemplateSpecification
$sel:version:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Maybe Text
$sel:releaseVersion:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Maybe Text
$sel:force:UpdateNodegroupVersion' :: UpdateNodegroupVersion -> Maybe Bool
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/clusters/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
clusterName,
        ByteString
"/node-groups/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
nodegroupName,
        ByteString
"/update-version"
      ]

instance Core.ToQuery UpdateNodegroupVersion where
  toQuery :: UpdateNodegroupVersion -> QueryString
toQuery = QueryString -> UpdateNodegroupVersion -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newUpdateNodegroupVersionResponse' smart constructor.
data UpdateNodegroupVersionResponse = UpdateNodegroupVersionResponse'
  { UpdateNodegroupVersionResponse -> Maybe Update
update :: Prelude.Maybe Update,
    -- | The response's http status code.
    UpdateNodegroupVersionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateNodegroupVersionResponse
-> UpdateNodegroupVersionResponse -> Bool
(UpdateNodegroupVersionResponse
 -> UpdateNodegroupVersionResponse -> Bool)
-> (UpdateNodegroupVersionResponse
    -> UpdateNodegroupVersionResponse -> Bool)
-> Eq UpdateNodegroupVersionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateNodegroupVersionResponse
-> UpdateNodegroupVersionResponse -> Bool
$c/= :: UpdateNodegroupVersionResponse
-> UpdateNodegroupVersionResponse -> Bool
== :: UpdateNodegroupVersionResponse
-> UpdateNodegroupVersionResponse -> Bool
$c== :: UpdateNodegroupVersionResponse
-> UpdateNodegroupVersionResponse -> Bool
Prelude.Eq, ReadPrec [UpdateNodegroupVersionResponse]
ReadPrec UpdateNodegroupVersionResponse
Int -> ReadS UpdateNodegroupVersionResponse
ReadS [UpdateNodegroupVersionResponse]
(Int -> ReadS UpdateNodegroupVersionResponse)
-> ReadS [UpdateNodegroupVersionResponse]
-> ReadPrec UpdateNodegroupVersionResponse
-> ReadPrec [UpdateNodegroupVersionResponse]
-> Read UpdateNodegroupVersionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateNodegroupVersionResponse]
$creadListPrec :: ReadPrec [UpdateNodegroupVersionResponse]
readPrec :: ReadPrec UpdateNodegroupVersionResponse
$creadPrec :: ReadPrec UpdateNodegroupVersionResponse
readList :: ReadS [UpdateNodegroupVersionResponse]
$creadList :: ReadS [UpdateNodegroupVersionResponse]
readsPrec :: Int -> ReadS UpdateNodegroupVersionResponse
$creadsPrec :: Int -> ReadS UpdateNodegroupVersionResponse
Prelude.Read, Int -> UpdateNodegroupVersionResponse -> ShowS
[UpdateNodegroupVersionResponse] -> ShowS
UpdateNodegroupVersionResponse -> String
(Int -> UpdateNodegroupVersionResponse -> ShowS)
-> (UpdateNodegroupVersionResponse -> String)
-> ([UpdateNodegroupVersionResponse] -> ShowS)
-> Show UpdateNodegroupVersionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateNodegroupVersionResponse] -> ShowS
$cshowList :: [UpdateNodegroupVersionResponse] -> ShowS
show :: UpdateNodegroupVersionResponse -> String
$cshow :: UpdateNodegroupVersionResponse -> String
showsPrec :: Int -> UpdateNodegroupVersionResponse -> ShowS
$cshowsPrec :: Int -> UpdateNodegroupVersionResponse -> ShowS
Prelude.Show, (forall x.
 UpdateNodegroupVersionResponse
 -> Rep UpdateNodegroupVersionResponse x)
-> (forall x.
    Rep UpdateNodegroupVersionResponse x
    -> UpdateNodegroupVersionResponse)
-> Generic UpdateNodegroupVersionResponse
forall x.
Rep UpdateNodegroupVersionResponse x
-> UpdateNodegroupVersionResponse
forall x.
UpdateNodegroupVersionResponse
-> Rep UpdateNodegroupVersionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateNodegroupVersionResponse x
-> UpdateNodegroupVersionResponse
$cfrom :: forall x.
UpdateNodegroupVersionResponse
-> Rep UpdateNodegroupVersionResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateNodegroupVersionResponse' 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:
--
-- 'update', 'updateNodegroupVersionResponse_update' - Undocumented member.
--
-- 'httpStatus', 'updateNodegroupVersionResponse_httpStatus' - The response's http status code.
newUpdateNodegroupVersionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateNodegroupVersionResponse
newUpdateNodegroupVersionResponse :: Int -> UpdateNodegroupVersionResponse
newUpdateNodegroupVersionResponse Int
pHttpStatus_ =
  UpdateNodegroupVersionResponse' :: Maybe Update -> Int -> UpdateNodegroupVersionResponse
UpdateNodegroupVersionResponse'
    { $sel:update:UpdateNodegroupVersionResponse' :: Maybe Update
update =
        Maybe Update
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateNodegroupVersionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
updateNodegroupVersionResponse_update :: Lens.Lens' UpdateNodegroupVersionResponse (Prelude.Maybe Update)
updateNodegroupVersionResponse_update :: (Maybe Update -> f (Maybe Update))
-> UpdateNodegroupVersionResponse
-> f UpdateNodegroupVersionResponse
updateNodegroupVersionResponse_update = (UpdateNodegroupVersionResponse -> Maybe Update)
-> (UpdateNodegroupVersionResponse
    -> Maybe Update -> UpdateNodegroupVersionResponse)
-> Lens
     UpdateNodegroupVersionResponse
     UpdateNodegroupVersionResponse
     (Maybe Update)
     (Maybe Update)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateNodegroupVersionResponse' {Maybe Update
update :: Maybe Update
$sel:update:UpdateNodegroupVersionResponse' :: UpdateNodegroupVersionResponse -> Maybe Update
update} -> Maybe Update
update) (\s :: UpdateNodegroupVersionResponse
s@UpdateNodegroupVersionResponse' {} Maybe Update
a -> UpdateNodegroupVersionResponse
s {$sel:update:UpdateNodegroupVersionResponse' :: Maybe Update
update = Maybe Update
a} :: UpdateNodegroupVersionResponse)

-- | The response's http status code.
updateNodegroupVersionResponse_httpStatus :: Lens.Lens' UpdateNodegroupVersionResponse Prelude.Int
updateNodegroupVersionResponse_httpStatus :: (Int -> f Int)
-> UpdateNodegroupVersionResponse
-> f UpdateNodegroupVersionResponse
updateNodegroupVersionResponse_httpStatus = (UpdateNodegroupVersionResponse -> Int)
-> (UpdateNodegroupVersionResponse
    -> Int -> UpdateNodegroupVersionResponse)
-> Lens
     UpdateNodegroupVersionResponse
     UpdateNodegroupVersionResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateNodegroupVersionResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateNodegroupVersionResponse' :: UpdateNodegroupVersionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateNodegroupVersionResponse
s@UpdateNodegroupVersionResponse' {} Int
a -> UpdateNodegroupVersionResponse
s {$sel:httpStatus:UpdateNodegroupVersionResponse' :: Int
httpStatus = Int
a} :: UpdateNodegroupVersionResponse)

instance
  Prelude.NFData
    UpdateNodegroupVersionResponse