{-# 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.DeleteAddon
-- 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)
--
-- Delete an Amazon EKS add-on.
--
-- When you remove the add-on, it will also be deleted from the cluster.
-- You can always manually start an add-on on the cluster using the
-- Kubernetes API.
module Amazonka.EKS.DeleteAddon
  ( -- * Creating a Request
    DeleteAddon (..),
    newDeleteAddon,

    -- * Request Lenses
    deleteAddon_preserve,
    deleteAddon_clusterName,
    deleteAddon_addonName,

    -- * Destructuring the Response
    DeleteAddonResponse (..),
    newDeleteAddonResponse,

    -- * Response Lenses
    deleteAddonResponse_addon,
    deleteAddonResponse_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:/ 'newDeleteAddon' smart constructor.
data DeleteAddon = DeleteAddon'
  { -- | Specifying this option preserves the add-on software on your cluster but
    -- Amazon EKS stops managing any settings for the add-on. If an IAM account
    -- is associated with the add-on, it is not removed.
    DeleteAddon -> Maybe Bool
preserve :: Prelude.Maybe Prelude.Bool,
    -- | The name of the cluster to delete the add-on from.
    DeleteAddon -> Text
clusterName :: Prelude.Text,
    -- | The name of the add-on. The name must match one of the names returned by
    -- <https://docs.aws.amazon.com/eks/latest/APIReference/API_ListAddons.html ListAddons>
    -- .
    DeleteAddon -> Text
addonName :: Prelude.Text
  }
  deriving (DeleteAddon -> DeleteAddon -> Bool
(DeleteAddon -> DeleteAddon -> Bool)
-> (DeleteAddon -> DeleteAddon -> Bool) -> Eq DeleteAddon
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteAddon -> DeleteAddon -> Bool
$c/= :: DeleteAddon -> DeleteAddon -> Bool
== :: DeleteAddon -> DeleteAddon -> Bool
$c== :: DeleteAddon -> DeleteAddon -> Bool
Prelude.Eq, ReadPrec [DeleteAddon]
ReadPrec DeleteAddon
Int -> ReadS DeleteAddon
ReadS [DeleteAddon]
(Int -> ReadS DeleteAddon)
-> ReadS [DeleteAddon]
-> ReadPrec DeleteAddon
-> ReadPrec [DeleteAddon]
-> Read DeleteAddon
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteAddon]
$creadListPrec :: ReadPrec [DeleteAddon]
readPrec :: ReadPrec DeleteAddon
$creadPrec :: ReadPrec DeleteAddon
readList :: ReadS [DeleteAddon]
$creadList :: ReadS [DeleteAddon]
readsPrec :: Int -> ReadS DeleteAddon
$creadsPrec :: Int -> ReadS DeleteAddon
Prelude.Read, Int -> DeleteAddon -> ShowS
[DeleteAddon] -> ShowS
DeleteAddon -> String
(Int -> DeleteAddon -> ShowS)
-> (DeleteAddon -> String)
-> ([DeleteAddon] -> ShowS)
-> Show DeleteAddon
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteAddon] -> ShowS
$cshowList :: [DeleteAddon] -> ShowS
show :: DeleteAddon -> String
$cshow :: DeleteAddon -> String
showsPrec :: Int -> DeleteAddon -> ShowS
$cshowsPrec :: Int -> DeleteAddon -> ShowS
Prelude.Show, (forall x. DeleteAddon -> Rep DeleteAddon x)
-> (forall x. Rep DeleteAddon x -> DeleteAddon)
-> Generic DeleteAddon
forall x. Rep DeleteAddon x -> DeleteAddon
forall x. DeleteAddon -> Rep DeleteAddon x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteAddon x -> DeleteAddon
$cfrom :: forall x. DeleteAddon -> Rep DeleteAddon x
Prelude.Generic)

-- |
-- Create a value of 'DeleteAddon' 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:
--
-- 'preserve', 'deleteAddon_preserve' - Specifying this option preserves the add-on software on your cluster but
-- Amazon EKS stops managing any settings for the add-on. If an IAM account
-- is associated with the add-on, it is not removed.
--
-- 'clusterName', 'deleteAddon_clusterName' - The name of the cluster to delete the add-on from.
--
-- 'addonName', 'deleteAddon_addonName' - The name of the add-on. The name must match one of the names returned by
-- <https://docs.aws.amazon.com/eks/latest/APIReference/API_ListAddons.html ListAddons>
-- .
newDeleteAddon ::
  -- | 'clusterName'
  Prelude.Text ->
  -- | 'addonName'
  Prelude.Text ->
  DeleteAddon
newDeleteAddon :: Text -> Text -> DeleteAddon
newDeleteAddon Text
pClusterName_ Text
pAddonName_ =
  DeleteAddon' :: Maybe Bool -> Text -> Text -> DeleteAddon
DeleteAddon'
    { $sel:preserve:DeleteAddon' :: Maybe Bool
preserve = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:clusterName:DeleteAddon' :: Text
clusterName = Text
pClusterName_,
      $sel:addonName:DeleteAddon' :: Text
addonName = Text
pAddonName_
    }

-- | Specifying this option preserves the add-on software on your cluster but
-- Amazon EKS stops managing any settings for the add-on. If an IAM account
-- is associated with the add-on, it is not removed.
deleteAddon_preserve :: Lens.Lens' DeleteAddon (Prelude.Maybe Prelude.Bool)
deleteAddon_preserve :: (Maybe Bool -> f (Maybe Bool)) -> DeleteAddon -> f DeleteAddon
deleteAddon_preserve = (DeleteAddon -> Maybe Bool)
-> (DeleteAddon -> Maybe Bool -> DeleteAddon)
-> Lens DeleteAddon DeleteAddon (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAddon' {Maybe Bool
preserve :: Maybe Bool
$sel:preserve:DeleteAddon' :: DeleteAddon -> Maybe Bool
preserve} -> Maybe Bool
preserve) (\s :: DeleteAddon
s@DeleteAddon' {} Maybe Bool
a -> DeleteAddon
s {$sel:preserve:DeleteAddon' :: Maybe Bool
preserve = Maybe Bool
a} :: DeleteAddon)

-- | The name of the cluster to delete the add-on from.
deleteAddon_clusterName :: Lens.Lens' DeleteAddon Prelude.Text
deleteAddon_clusterName :: (Text -> f Text) -> DeleteAddon -> f DeleteAddon
deleteAddon_clusterName = (DeleteAddon -> Text)
-> (DeleteAddon -> Text -> DeleteAddon)
-> Lens DeleteAddon DeleteAddon Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAddon' {Text
clusterName :: Text
$sel:clusterName:DeleteAddon' :: DeleteAddon -> Text
clusterName} -> Text
clusterName) (\s :: DeleteAddon
s@DeleteAddon' {} Text
a -> DeleteAddon
s {$sel:clusterName:DeleteAddon' :: Text
clusterName = Text
a} :: DeleteAddon)

-- | The name of the add-on. The name must match one of the names returned by
-- <https://docs.aws.amazon.com/eks/latest/APIReference/API_ListAddons.html ListAddons>
-- .
deleteAddon_addonName :: Lens.Lens' DeleteAddon Prelude.Text
deleteAddon_addonName :: (Text -> f Text) -> DeleteAddon -> f DeleteAddon
deleteAddon_addonName = (DeleteAddon -> Text)
-> (DeleteAddon -> Text -> DeleteAddon)
-> Lens DeleteAddon DeleteAddon Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAddon' {Text
addonName :: Text
$sel:addonName:DeleteAddon' :: DeleteAddon -> Text
addonName} -> Text
addonName) (\s :: DeleteAddon
s@DeleteAddon' {} Text
a -> DeleteAddon
s {$sel:addonName:DeleteAddon' :: Text
addonName = Text
a} :: DeleteAddon)

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

instance Prelude.NFData DeleteAddon

instance Core.ToHeaders DeleteAddon where
  toHeaders :: DeleteAddon -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteAddon -> 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 DeleteAddon where
  toPath :: DeleteAddon -> ByteString
toPath DeleteAddon' {Maybe Bool
Text
addonName :: Text
clusterName :: Text
preserve :: Maybe Bool
$sel:addonName:DeleteAddon' :: DeleteAddon -> Text
$sel:clusterName:DeleteAddon' :: DeleteAddon -> Text
$sel:preserve:DeleteAddon' :: DeleteAddon -> 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
"/addons/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
addonName
      ]

instance Core.ToQuery DeleteAddon where
  toQuery :: DeleteAddon -> QueryString
toQuery DeleteAddon' {Maybe Bool
Text
addonName :: Text
clusterName :: Text
preserve :: Maybe Bool
$sel:addonName:DeleteAddon' :: DeleteAddon -> Text
$sel:clusterName:DeleteAddon' :: DeleteAddon -> Text
$sel:preserve:DeleteAddon' :: DeleteAddon -> Maybe Bool
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"preserve" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
preserve]

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

-- |
-- Create a value of 'DeleteAddonResponse' 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:
--
-- 'addon', 'deleteAddonResponse_addon' - Undocumented member.
--
-- 'httpStatus', 'deleteAddonResponse_httpStatus' - The response's http status code.
newDeleteAddonResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteAddonResponse
newDeleteAddonResponse :: Int -> DeleteAddonResponse
newDeleteAddonResponse Int
pHttpStatus_ =
  DeleteAddonResponse' :: Maybe Addon -> Int -> DeleteAddonResponse
DeleteAddonResponse'
    { $sel:addon:DeleteAddonResponse' :: Maybe Addon
addon = Maybe Addon
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteAddonResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
deleteAddonResponse_addon :: Lens.Lens' DeleteAddonResponse (Prelude.Maybe Addon)
deleteAddonResponse_addon :: (Maybe Addon -> f (Maybe Addon))
-> DeleteAddonResponse -> f DeleteAddonResponse
deleteAddonResponse_addon = (DeleteAddonResponse -> Maybe Addon)
-> (DeleteAddonResponse -> Maybe Addon -> DeleteAddonResponse)
-> Lens
     DeleteAddonResponse DeleteAddonResponse (Maybe Addon) (Maybe Addon)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAddonResponse' {Maybe Addon
addon :: Maybe Addon
$sel:addon:DeleteAddonResponse' :: DeleteAddonResponse -> Maybe Addon
addon} -> Maybe Addon
addon) (\s :: DeleteAddonResponse
s@DeleteAddonResponse' {} Maybe Addon
a -> DeleteAddonResponse
s {$sel:addon:DeleteAddonResponse' :: Maybe Addon
addon = Maybe Addon
a} :: DeleteAddonResponse)

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

instance Prelude.NFData DeleteAddonResponse