{-# 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.DeleteNodegroup
-- 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)
--
-- Deletes an Amazon EKS node group for a cluster.
module Amazonka.EKS.DeleteNodegroup
  ( -- * Creating a Request
    DeleteNodegroup (..),
    newDeleteNodegroup,

    -- * Request Lenses
    deleteNodegroup_clusterName,
    deleteNodegroup_nodegroupName,

    -- * Destructuring the Response
    DeleteNodegroupResponse (..),
    newDeleteNodegroupResponse,

    -- * Response Lenses
    deleteNodegroupResponse_nodegroup,
    deleteNodegroupResponse_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:/ 'newDeleteNodegroup' smart constructor.
data DeleteNodegroup = DeleteNodegroup'
  { -- | The name of the Amazon EKS cluster that is associated with your node
    -- group.
    DeleteNodegroup -> Text
clusterName :: Prelude.Text,
    -- | The name of the node group to delete.
    DeleteNodegroup -> Text
nodegroupName :: Prelude.Text
  }
  deriving (DeleteNodegroup -> DeleteNodegroup -> Bool
(DeleteNodegroup -> DeleteNodegroup -> Bool)
-> (DeleteNodegroup -> DeleteNodegroup -> Bool)
-> Eq DeleteNodegroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteNodegroup -> DeleteNodegroup -> Bool
$c/= :: DeleteNodegroup -> DeleteNodegroup -> Bool
== :: DeleteNodegroup -> DeleteNodegroup -> Bool
$c== :: DeleteNodegroup -> DeleteNodegroup -> Bool
Prelude.Eq, ReadPrec [DeleteNodegroup]
ReadPrec DeleteNodegroup
Int -> ReadS DeleteNodegroup
ReadS [DeleteNodegroup]
(Int -> ReadS DeleteNodegroup)
-> ReadS [DeleteNodegroup]
-> ReadPrec DeleteNodegroup
-> ReadPrec [DeleteNodegroup]
-> Read DeleteNodegroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteNodegroup]
$creadListPrec :: ReadPrec [DeleteNodegroup]
readPrec :: ReadPrec DeleteNodegroup
$creadPrec :: ReadPrec DeleteNodegroup
readList :: ReadS [DeleteNodegroup]
$creadList :: ReadS [DeleteNodegroup]
readsPrec :: Int -> ReadS DeleteNodegroup
$creadsPrec :: Int -> ReadS DeleteNodegroup
Prelude.Read, Int -> DeleteNodegroup -> ShowS
[DeleteNodegroup] -> ShowS
DeleteNodegroup -> String
(Int -> DeleteNodegroup -> ShowS)
-> (DeleteNodegroup -> String)
-> ([DeleteNodegroup] -> ShowS)
-> Show DeleteNodegroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteNodegroup] -> ShowS
$cshowList :: [DeleteNodegroup] -> ShowS
show :: DeleteNodegroup -> String
$cshow :: DeleteNodegroup -> String
showsPrec :: Int -> DeleteNodegroup -> ShowS
$cshowsPrec :: Int -> DeleteNodegroup -> ShowS
Prelude.Show, (forall x. DeleteNodegroup -> Rep DeleteNodegroup x)
-> (forall x. Rep DeleteNodegroup x -> DeleteNodegroup)
-> Generic DeleteNodegroup
forall x. Rep DeleteNodegroup x -> DeleteNodegroup
forall x. DeleteNodegroup -> Rep DeleteNodegroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteNodegroup x -> DeleteNodegroup
$cfrom :: forall x. DeleteNodegroup -> Rep DeleteNodegroup x
Prelude.Generic)

-- |
-- Create a value of 'DeleteNodegroup' 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:
--
-- 'clusterName', 'deleteNodegroup_clusterName' - The name of the Amazon EKS cluster that is associated with your node
-- group.
--
-- 'nodegroupName', 'deleteNodegroup_nodegroupName' - The name of the node group to delete.
newDeleteNodegroup ::
  -- | 'clusterName'
  Prelude.Text ->
  -- | 'nodegroupName'
  Prelude.Text ->
  DeleteNodegroup
newDeleteNodegroup :: Text -> Text -> DeleteNodegroup
newDeleteNodegroup Text
pClusterName_ Text
pNodegroupName_ =
  DeleteNodegroup' :: Text -> Text -> DeleteNodegroup
DeleteNodegroup'
    { $sel:clusterName:DeleteNodegroup' :: Text
clusterName = Text
pClusterName_,
      $sel:nodegroupName:DeleteNodegroup' :: Text
nodegroupName = Text
pNodegroupName_
    }

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

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

instance Core.AWSRequest DeleteNodegroup where
  type
    AWSResponse DeleteNodegroup =
      DeleteNodegroupResponse
  request :: DeleteNodegroup -> Request DeleteNodegroup
request = Service -> DeleteNodegroup -> Request DeleteNodegroup
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteNodegroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteNodegroup)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteNodegroup))
-> Logger
-> Service
-> Proxy DeleteNodegroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteNodegroup)))
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 Nodegroup -> Int -> DeleteNodegroupResponse
DeleteNodegroupResponse'
            (Maybe Nodegroup -> Int -> DeleteNodegroupResponse)
-> Either String (Maybe Nodegroup)
-> Either String (Int -> DeleteNodegroupResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Nodegroup)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"nodegroup")
            Either String (Int -> DeleteNodegroupResponse)
-> Either String Int -> Either String DeleteNodegroupResponse
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 DeleteNodegroup

instance Prelude.NFData DeleteNodegroup

instance Core.ToHeaders DeleteNodegroup where
  toHeaders :: DeleteNodegroup -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteNodegroup -> 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.ToPath DeleteNodegroup where
  toPath :: DeleteNodegroup -> ByteString
toPath DeleteNodegroup' {Text
nodegroupName :: Text
clusterName :: Text
$sel:nodegroupName:DeleteNodegroup' :: DeleteNodegroup -> Text
$sel:clusterName:DeleteNodegroup' :: DeleteNodegroup -> Text
..} =
    [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
      ]

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

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

-- |
-- Create a value of 'DeleteNodegroupResponse' 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:
--
-- 'nodegroup', 'deleteNodegroupResponse_nodegroup' - The full description of your deleted node group.
--
-- 'httpStatus', 'deleteNodegroupResponse_httpStatus' - The response's http status code.
newDeleteNodegroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteNodegroupResponse
newDeleteNodegroupResponse :: Int -> DeleteNodegroupResponse
newDeleteNodegroupResponse Int
pHttpStatus_ =
  DeleteNodegroupResponse' :: Maybe Nodegroup -> Int -> DeleteNodegroupResponse
DeleteNodegroupResponse'
    { $sel:nodegroup:DeleteNodegroupResponse' :: Maybe Nodegroup
nodegroup =
        Maybe Nodegroup
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteNodegroupResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The full description of your deleted node group.
deleteNodegroupResponse_nodegroup :: Lens.Lens' DeleteNodegroupResponse (Prelude.Maybe Nodegroup)
deleteNodegroupResponse_nodegroup :: (Maybe Nodegroup -> f (Maybe Nodegroup))
-> DeleteNodegroupResponse -> f DeleteNodegroupResponse
deleteNodegroupResponse_nodegroup = (DeleteNodegroupResponse -> Maybe Nodegroup)
-> (DeleteNodegroupResponse
    -> Maybe Nodegroup -> DeleteNodegroupResponse)
-> Lens
     DeleteNodegroupResponse
     DeleteNodegroupResponse
     (Maybe Nodegroup)
     (Maybe Nodegroup)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteNodegroupResponse' {Maybe Nodegroup
nodegroup :: Maybe Nodegroup
$sel:nodegroup:DeleteNodegroupResponse' :: DeleteNodegroupResponse -> Maybe Nodegroup
nodegroup} -> Maybe Nodegroup
nodegroup) (\s :: DeleteNodegroupResponse
s@DeleteNodegroupResponse' {} Maybe Nodegroup
a -> DeleteNodegroupResponse
s {$sel:nodegroup:DeleteNodegroupResponse' :: Maybe Nodegroup
nodegroup = Maybe Nodegroup
a} :: DeleteNodegroupResponse)

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

instance Prelude.NFData DeleteNodegroupResponse