{-# 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.ECS.DeleteCapacityProvider
-- 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 the specified capacity provider.
--
-- The @FARGATE@ and @FARGATE_SPOT@ capacity providers are reserved and
-- cannot be deleted. You can disassociate them from a cluster using either
-- the PutClusterCapacityProviders API or by deleting the cluster.
--
-- Prior to a capacity provider being deleted, the capacity provider must
-- be removed from the capacity provider strategy from all services. The
-- UpdateService API can be used to remove a capacity provider from a
-- service\'s capacity provider strategy. When updating a service, the
-- @forceNewDeployment@ option can be used to ensure that any tasks using
-- the Amazon EC2 instance capacity provided by the capacity provider are
-- transitioned to use the capacity from the remaining capacity providers.
-- Only capacity providers that are not associated with a cluster can be
-- deleted. To remove a capacity provider from a cluster, you can either
-- use PutClusterCapacityProviders or delete the cluster.
module Amazonka.ECS.DeleteCapacityProvider
  ( -- * Creating a Request
    DeleteCapacityProvider (..),
    newDeleteCapacityProvider,

    -- * Request Lenses
    deleteCapacityProvider_capacityProvider,

    -- * Destructuring the Response
    DeleteCapacityProviderResponse (..),
    newDeleteCapacityProviderResponse,

    -- * Response Lenses
    deleteCapacityProviderResponse_capacityProvider,
    deleteCapacityProviderResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.ECS.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:/ 'newDeleteCapacityProvider' smart constructor.
data DeleteCapacityProvider = DeleteCapacityProvider'
  { -- | The short name or full Amazon Resource Name (ARN) of the capacity
    -- provider to delete.
    DeleteCapacityProvider -> Text
capacityProvider :: Prelude.Text
  }
  deriving (DeleteCapacityProvider -> DeleteCapacityProvider -> Bool
(DeleteCapacityProvider -> DeleteCapacityProvider -> Bool)
-> (DeleteCapacityProvider -> DeleteCapacityProvider -> Bool)
-> Eq DeleteCapacityProvider
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteCapacityProvider -> DeleteCapacityProvider -> Bool
$c/= :: DeleteCapacityProvider -> DeleteCapacityProvider -> Bool
== :: DeleteCapacityProvider -> DeleteCapacityProvider -> Bool
$c== :: DeleteCapacityProvider -> DeleteCapacityProvider -> Bool
Prelude.Eq, ReadPrec [DeleteCapacityProvider]
ReadPrec DeleteCapacityProvider
Int -> ReadS DeleteCapacityProvider
ReadS [DeleteCapacityProvider]
(Int -> ReadS DeleteCapacityProvider)
-> ReadS [DeleteCapacityProvider]
-> ReadPrec DeleteCapacityProvider
-> ReadPrec [DeleteCapacityProvider]
-> Read DeleteCapacityProvider
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteCapacityProvider]
$creadListPrec :: ReadPrec [DeleteCapacityProvider]
readPrec :: ReadPrec DeleteCapacityProvider
$creadPrec :: ReadPrec DeleteCapacityProvider
readList :: ReadS [DeleteCapacityProvider]
$creadList :: ReadS [DeleteCapacityProvider]
readsPrec :: Int -> ReadS DeleteCapacityProvider
$creadsPrec :: Int -> ReadS DeleteCapacityProvider
Prelude.Read, Int -> DeleteCapacityProvider -> ShowS
[DeleteCapacityProvider] -> ShowS
DeleteCapacityProvider -> String
(Int -> DeleteCapacityProvider -> ShowS)
-> (DeleteCapacityProvider -> String)
-> ([DeleteCapacityProvider] -> ShowS)
-> Show DeleteCapacityProvider
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteCapacityProvider] -> ShowS
$cshowList :: [DeleteCapacityProvider] -> ShowS
show :: DeleteCapacityProvider -> String
$cshow :: DeleteCapacityProvider -> String
showsPrec :: Int -> DeleteCapacityProvider -> ShowS
$cshowsPrec :: Int -> DeleteCapacityProvider -> ShowS
Prelude.Show, (forall x. DeleteCapacityProvider -> Rep DeleteCapacityProvider x)
-> (forall x.
    Rep DeleteCapacityProvider x -> DeleteCapacityProvider)
-> Generic DeleteCapacityProvider
forall x. Rep DeleteCapacityProvider x -> DeleteCapacityProvider
forall x. DeleteCapacityProvider -> Rep DeleteCapacityProvider x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteCapacityProvider x -> DeleteCapacityProvider
$cfrom :: forall x. DeleteCapacityProvider -> Rep DeleteCapacityProvider x
Prelude.Generic)

-- |
-- Create a value of 'DeleteCapacityProvider' 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:
--
-- 'capacityProvider', 'deleteCapacityProvider_capacityProvider' - The short name or full Amazon Resource Name (ARN) of the capacity
-- provider to delete.
newDeleteCapacityProvider ::
  -- | 'capacityProvider'
  Prelude.Text ->
  DeleteCapacityProvider
newDeleteCapacityProvider :: Text -> DeleteCapacityProvider
newDeleteCapacityProvider Text
pCapacityProvider_ =
  DeleteCapacityProvider' :: Text -> DeleteCapacityProvider
DeleteCapacityProvider'
    { $sel:capacityProvider:DeleteCapacityProvider' :: Text
capacityProvider =
        Text
pCapacityProvider_
    }

-- | The short name or full Amazon Resource Name (ARN) of the capacity
-- provider to delete.
deleteCapacityProvider_capacityProvider :: Lens.Lens' DeleteCapacityProvider Prelude.Text
deleteCapacityProvider_capacityProvider :: (Text -> f Text)
-> DeleteCapacityProvider -> f DeleteCapacityProvider
deleteCapacityProvider_capacityProvider = (DeleteCapacityProvider -> Text)
-> (DeleteCapacityProvider -> Text -> DeleteCapacityProvider)
-> Lens DeleteCapacityProvider DeleteCapacityProvider Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCapacityProvider' {Text
capacityProvider :: Text
$sel:capacityProvider:DeleteCapacityProvider' :: DeleteCapacityProvider -> Text
capacityProvider} -> Text
capacityProvider) (\s :: DeleteCapacityProvider
s@DeleteCapacityProvider' {} Text
a -> DeleteCapacityProvider
s {$sel:capacityProvider:DeleteCapacityProvider' :: Text
capacityProvider = Text
a} :: DeleteCapacityProvider)

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

instance Prelude.NFData DeleteCapacityProvider

instance Core.ToHeaders DeleteCapacityProvider where
  toHeaders :: DeleteCapacityProvider -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteCapacityProvider -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AmazonEC2ContainerServiceV20141113.DeleteCapacityProvider" ::
                          Prelude.ByteString
                      ),
            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 DeleteCapacityProvider where
  toJSON :: DeleteCapacityProvider -> Value
toJSON DeleteCapacityProvider' {Text
capacityProvider :: Text
$sel:capacityProvider:DeleteCapacityProvider' :: DeleteCapacityProvider -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"capacityProvider" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
capacityProvider)
          ]
      )

instance Core.ToPath DeleteCapacityProvider where
  toPath :: DeleteCapacityProvider -> ByteString
toPath = ByteString -> DeleteCapacityProvider -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'DeleteCapacityProviderResponse' 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:
--
-- 'capacityProvider', 'deleteCapacityProviderResponse_capacityProvider' - The details of the capacity provider.
--
-- 'httpStatus', 'deleteCapacityProviderResponse_httpStatus' - The response's http status code.
newDeleteCapacityProviderResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteCapacityProviderResponse
newDeleteCapacityProviderResponse :: Int -> DeleteCapacityProviderResponse
newDeleteCapacityProviderResponse Int
pHttpStatus_ =
  DeleteCapacityProviderResponse' :: Maybe CapacityProvider -> Int -> DeleteCapacityProviderResponse
DeleteCapacityProviderResponse'
    { $sel:capacityProvider:DeleteCapacityProviderResponse' :: Maybe CapacityProvider
capacityProvider =
        Maybe CapacityProvider
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteCapacityProviderResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The details of the capacity provider.
deleteCapacityProviderResponse_capacityProvider :: Lens.Lens' DeleteCapacityProviderResponse (Prelude.Maybe CapacityProvider)
deleteCapacityProviderResponse_capacityProvider :: (Maybe CapacityProvider -> f (Maybe CapacityProvider))
-> DeleteCapacityProviderResponse
-> f DeleteCapacityProviderResponse
deleteCapacityProviderResponse_capacityProvider = (DeleteCapacityProviderResponse -> Maybe CapacityProvider)
-> (DeleteCapacityProviderResponse
    -> Maybe CapacityProvider -> DeleteCapacityProviderResponse)
-> Lens
     DeleteCapacityProviderResponse
     DeleteCapacityProviderResponse
     (Maybe CapacityProvider)
     (Maybe CapacityProvider)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCapacityProviderResponse' {Maybe CapacityProvider
capacityProvider :: Maybe CapacityProvider
$sel:capacityProvider:DeleteCapacityProviderResponse' :: DeleteCapacityProviderResponse -> Maybe CapacityProvider
capacityProvider} -> Maybe CapacityProvider
capacityProvider) (\s :: DeleteCapacityProviderResponse
s@DeleteCapacityProviderResponse' {} Maybe CapacityProvider
a -> DeleteCapacityProviderResponse
s {$sel:capacityProvider:DeleteCapacityProviderResponse' :: Maybe CapacityProvider
capacityProvider = Maybe CapacityProvider
a} :: DeleteCapacityProviderResponse)

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

instance
  Prelude.NFData
    DeleteCapacityProviderResponse