{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EKS.Types
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
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]
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
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. 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'
      { $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 :: Lens' DeleteFargateProfile Text
deleteFargateProfile_clusterName = 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 :: Lens' DeleteFargateProfile Text
deleteFargateProfile_fargateProfileName = 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 :: (Service -> Service)
-> DeleteFargateProfile -> Request DeleteFargateProfile
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteFargateProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteFargateProfile)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe FargateProfile -> Int -> DeleteFargateProfileResponse
DeleteFargateProfileResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"fargateProfile")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteFargateProfile where
  hashWithSalt :: Int -> DeleteFargateProfile -> Int
hashWithSalt Int
_salt DeleteFargateProfile' {Text
fargateProfileName :: Text
clusterName :: Text
$sel:fargateProfileName:DeleteFargateProfile' :: DeleteFargateProfile -> Text
$sel:clusterName:DeleteFargateProfile' :: DeleteFargateProfile -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
clusterName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
fargateProfileName

instance Prelude.NFData DeleteFargateProfile where
  rnf :: DeleteFargateProfile -> ()
rnf DeleteFargateProfile' {Text
fargateProfileName :: Text
clusterName :: Text
$sel:fargateProfileName:DeleteFargateProfile' :: DeleteFargateProfile -> Text
$sel:clusterName:DeleteFargateProfile' :: DeleteFargateProfile -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
clusterName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
fargateProfileName

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

instance Data.ToPath DeleteFargateProfile where
  toPath :: DeleteFargateProfile -> ByteString
toPath DeleteFargateProfile' {Text
fargateProfileName :: Text
clusterName :: Text
$sel:fargateProfileName:DeleteFargateProfile' :: DeleteFargateProfile -> Text
$sel:clusterName:DeleteFargateProfile' :: DeleteFargateProfile -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/clusters/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
clusterName,
        ByteString
"/fargate-profiles/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
fargateProfileName
      ]

instance Data.ToQuery DeleteFargateProfile where
  toQuery :: DeleteFargateProfile -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:fargateProfile:DeleteFargateProfileResponse' :: Maybe FargateProfile
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 :: Lens' DeleteFargateProfileResponse (Maybe FargateProfile)
deleteFargateProfileResponse_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 :: Lens' DeleteFargateProfileResponse Int
deleteFargateProfileResponse_httpStatus = 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 where
  rnf :: DeleteFargateProfileResponse -> ()
rnf DeleteFargateProfileResponse' {Int
Maybe FargateProfile
httpStatus :: Int
fargateProfile :: Maybe FargateProfile
$sel:httpStatus:DeleteFargateProfileResponse' :: DeleteFargateProfileResponse -> Int
$sel:fargateProfile:DeleteFargateProfileResponse' :: DeleteFargateProfileResponse -> Maybe FargateProfile
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe FargateProfile
fargateProfile
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus