{-# 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.DeleteFargateProfile
-- 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 Fargate profile.
--
-- When you delete a Fargate profile, any pods running on Fargate that were
-- created with the profile are deleted. If those pods match another
-- Fargate profile, then they are scheduled on Fargate with that profile.
-- If they no longer match any Fargate profiles, then they are not
-- scheduled on Fargate and they may remain in a pending state.
--
-- Only one Fargate profile in a cluster can be in the @DELETING@ status at
-- a time. You must wait for a Fargate profile to finish deleting before
-- you can delete any other profiles in that cluster.
module Amazonka.EKS.DeleteFargateProfile
  ( -- * Creating a Request
    DeleteFargateProfile (..),
    newDeleteFargateProfile,

    -- * Request Lenses
    deleteFargateProfile_clusterName,
    deleteFargateProfile_fargateProfileName,

    -- * Destructuring the Response
    DeleteFargateProfileResponse (..),
    newDeleteFargateProfileResponse,

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

-- |
-- Create a value of 'DeleteFargateProfile' 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', 'deleteFargateProfile_clusterName' - The name of the Amazon EKS cluster associated with the Fargate profile
-- to delete.
--
-- 'fargateProfileName', 'deleteFargateProfile_fargateProfileName' - The name of the Fargate profile to delete.
newDeleteFargateProfile ::
  -- | 'clusterName'
  Prelude.Text ->
  -- | 'fargateProfileName'
  Prelude.Text ->
  DeleteFargateProfile
newDeleteFargateProfile :: Text -> Text -> DeleteFargateProfile
newDeleteFargateProfile
  Text
pClusterName_
  Text
pFargateProfileName_ =
    DeleteFargateProfile' :: Text -> Text -> DeleteFargateProfile
DeleteFargateProfile'
      { $sel:clusterName:DeleteFargateProfile' :: Text
clusterName = Text
pClusterName_,
        $sel:fargateProfileName:DeleteFargateProfile' :: Text
fargateProfileName = Text
pFargateProfileName_
      }

-- | The name of the Amazon EKS cluster associated with the Fargate profile
-- to delete.
deleteFargateProfile_clusterName :: Lens.Lens' DeleteFargateProfile Prelude.Text
deleteFargateProfile_clusterName :: (Text -> f Text) -> DeleteFargateProfile -> f DeleteFargateProfile
deleteFargateProfile_clusterName = (DeleteFargateProfile -> Text)
-> (DeleteFargateProfile -> Text -> DeleteFargateProfile)
-> Lens DeleteFargateProfile DeleteFargateProfile Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFargateProfile' {Text
clusterName :: Text
$sel:clusterName:DeleteFargateProfile' :: DeleteFargateProfile -> Text
clusterName} -> Text
clusterName) (\s :: DeleteFargateProfile
s@DeleteFargateProfile' {} Text
a -> DeleteFargateProfile
s {$sel:clusterName:DeleteFargateProfile' :: Text
clusterName = Text
a} :: DeleteFargateProfile)

-- | The name of the Fargate profile to delete.
deleteFargateProfile_fargateProfileName :: Lens.Lens' DeleteFargateProfile Prelude.Text
deleteFargateProfile_fargateProfileName :: (Text -> f Text) -> DeleteFargateProfile -> f DeleteFargateProfile
deleteFargateProfile_fargateProfileName = (DeleteFargateProfile -> Text)
-> (DeleteFargateProfile -> Text -> DeleteFargateProfile)
-> Lens DeleteFargateProfile DeleteFargateProfile Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFargateProfile' {Text
fargateProfileName :: Text
$sel:fargateProfileName:DeleteFargateProfile' :: DeleteFargateProfile -> Text
fargateProfileName} -> Text
fargateProfileName) (\s :: DeleteFargateProfile
s@DeleteFargateProfile' {} Text
a -> DeleteFargateProfile
s {$sel:fargateProfileName:DeleteFargateProfile' :: Text
fargateProfileName = Text
a} :: DeleteFargateProfile)

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

instance Prelude.NFData DeleteFargateProfile

instance Core.ToHeaders DeleteFargateProfile where
  toHeaders :: DeleteFargateProfile -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteFargateProfile -> 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 DeleteFargateProfile where
  toPath :: DeleteFargateProfile -> ByteString
toPath DeleteFargateProfile' {Text
fargateProfileName :: Text
clusterName :: Text
$sel:fargateProfileName:DeleteFargateProfile' :: DeleteFargateProfile -> Text
$sel:clusterName:DeleteFargateProfile' :: DeleteFargateProfile -> 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
"/fargate-profiles/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
fargateProfileName
      ]

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

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

-- |
-- Create a value of 'DeleteFargateProfileResponse' 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:
--
-- 'fargateProfile', 'deleteFargateProfileResponse_fargateProfile' - The deleted Fargate profile.
--
-- 'httpStatus', 'deleteFargateProfileResponse_httpStatus' - The response's http status code.
newDeleteFargateProfileResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteFargateProfileResponse
newDeleteFargateProfileResponse :: Int -> DeleteFargateProfileResponse
newDeleteFargateProfileResponse Int
pHttpStatus_ =
  DeleteFargateProfileResponse' :: Maybe FargateProfile -> Int -> DeleteFargateProfileResponse
DeleteFargateProfileResponse'
    { $sel:fargateProfile:DeleteFargateProfileResponse' :: Maybe FargateProfile
fargateProfile =
        Maybe FargateProfile
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteFargateProfileResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The deleted Fargate profile.
deleteFargateProfileResponse_fargateProfile :: Lens.Lens' DeleteFargateProfileResponse (Prelude.Maybe FargateProfile)
deleteFargateProfileResponse_fargateProfile :: (Maybe FargateProfile -> f (Maybe FargateProfile))
-> DeleteFargateProfileResponse -> f DeleteFargateProfileResponse
deleteFargateProfileResponse_fargateProfile = (DeleteFargateProfileResponse -> Maybe FargateProfile)
-> (DeleteFargateProfileResponse
    -> Maybe FargateProfile -> DeleteFargateProfileResponse)
-> Lens
     DeleteFargateProfileResponse
     DeleteFargateProfileResponse
     (Maybe FargateProfile)
     (Maybe FargateProfile)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFargateProfileResponse' {Maybe FargateProfile
fargateProfile :: Maybe FargateProfile
$sel:fargateProfile:DeleteFargateProfileResponse' :: DeleteFargateProfileResponse -> Maybe FargateProfile
fargateProfile} -> Maybe FargateProfile
fargateProfile) (\s :: DeleteFargateProfileResponse
s@DeleteFargateProfileResponse' {} Maybe FargateProfile
a -> DeleteFargateProfileResponse
s {$sel:fargateProfile:DeleteFargateProfileResponse' :: Maybe FargateProfile
fargateProfile = Maybe FargateProfile
a} :: DeleteFargateProfileResponse)

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

instance Prelude.NFData DeleteFargateProfileResponse