{-# 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.DeregisterTaskDefinition
-- 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)
--
-- Deregisters the specified task definition by family and revision. Upon
-- deregistration, the task definition is marked as @INACTIVE@. Existing
-- tasks and services that reference an @INACTIVE@ task definition continue
-- to run without disruption. Existing services that reference an
-- @INACTIVE@ task definition can still scale up or down by modifying the
-- service\'s desired count.
--
-- You cannot use an @INACTIVE@ task definition to run new tasks or create
-- new services, and you cannot update an existing service to reference an
-- @INACTIVE@ task definition. However, there may be up to a 10-minute
-- window following deregistration where these restrictions have not yet
-- taken effect.
--
-- At this time, @INACTIVE@ task definitions remain discoverable in your
-- account indefinitely. However, this behavior is subject to change in the
-- future, so you should not rely on @INACTIVE@ task definitions persisting
-- beyond the lifecycle of any associated tasks and services.
module Amazonka.ECS.DeregisterTaskDefinition
  ( -- * Creating a Request
    DeregisterTaskDefinition (..),
    newDeregisterTaskDefinition,

    -- * Request Lenses
    deregisterTaskDefinition_taskDefinition,

    -- * Destructuring the Response
    DeregisterTaskDefinitionResponse (..),
    newDeregisterTaskDefinitionResponse,

    -- * Response Lenses
    deregisterTaskDefinitionResponse_taskDefinition,
    deregisterTaskDefinitionResponse_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:/ 'newDeregisterTaskDefinition' smart constructor.
data DeregisterTaskDefinition = DeregisterTaskDefinition'
  { -- | The @family@ and @revision@ (@family:revision@) or full Amazon Resource
    -- Name (ARN) of the task definition to deregister. You must specify a
    -- @revision@.
    DeregisterTaskDefinition -> Text
taskDefinition :: Prelude.Text
  }
  deriving (DeregisterTaskDefinition -> DeregisterTaskDefinition -> Bool
(DeregisterTaskDefinition -> DeregisterTaskDefinition -> Bool)
-> (DeregisterTaskDefinition -> DeregisterTaskDefinition -> Bool)
-> Eq DeregisterTaskDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeregisterTaskDefinition -> DeregisterTaskDefinition -> Bool
$c/= :: DeregisterTaskDefinition -> DeregisterTaskDefinition -> Bool
== :: DeregisterTaskDefinition -> DeregisterTaskDefinition -> Bool
$c== :: DeregisterTaskDefinition -> DeregisterTaskDefinition -> Bool
Prelude.Eq, ReadPrec [DeregisterTaskDefinition]
ReadPrec DeregisterTaskDefinition
Int -> ReadS DeregisterTaskDefinition
ReadS [DeregisterTaskDefinition]
(Int -> ReadS DeregisterTaskDefinition)
-> ReadS [DeregisterTaskDefinition]
-> ReadPrec DeregisterTaskDefinition
-> ReadPrec [DeregisterTaskDefinition]
-> Read DeregisterTaskDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeregisterTaskDefinition]
$creadListPrec :: ReadPrec [DeregisterTaskDefinition]
readPrec :: ReadPrec DeregisterTaskDefinition
$creadPrec :: ReadPrec DeregisterTaskDefinition
readList :: ReadS [DeregisterTaskDefinition]
$creadList :: ReadS [DeregisterTaskDefinition]
readsPrec :: Int -> ReadS DeregisterTaskDefinition
$creadsPrec :: Int -> ReadS DeregisterTaskDefinition
Prelude.Read, Int -> DeregisterTaskDefinition -> ShowS
[DeregisterTaskDefinition] -> ShowS
DeregisterTaskDefinition -> String
(Int -> DeregisterTaskDefinition -> ShowS)
-> (DeregisterTaskDefinition -> String)
-> ([DeregisterTaskDefinition] -> ShowS)
-> Show DeregisterTaskDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeregisterTaskDefinition] -> ShowS
$cshowList :: [DeregisterTaskDefinition] -> ShowS
show :: DeregisterTaskDefinition -> String
$cshow :: DeregisterTaskDefinition -> String
showsPrec :: Int -> DeregisterTaskDefinition -> ShowS
$cshowsPrec :: Int -> DeregisterTaskDefinition -> ShowS
Prelude.Show, (forall x.
 DeregisterTaskDefinition -> Rep DeregisterTaskDefinition x)
-> (forall x.
    Rep DeregisterTaskDefinition x -> DeregisterTaskDefinition)
-> Generic DeregisterTaskDefinition
forall x.
Rep DeregisterTaskDefinition x -> DeregisterTaskDefinition
forall x.
DeregisterTaskDefinition -> Rep DeregisterTaskDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeregisterTaskDefinition x -> DeregisterTaskDefinition
$cfrom :: forall x.
DeregisterTaskDefinition -> Rep DeregisterTaskDefinition x
Prelude.Generic)

-- |
-- Create a value of 'DeregisterTaskDefinition' 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:
--
-- 'taskDefinition', 'deregisterTaskDefinition_taskDefinition' - The @family@ and @revision@ (@family:revision@) or full Amazon Resource
-- Name (ARN) of the task definition to deregister. You must specify a
-- @revision@.
newDeregisterTaskDefinition ::
  -- | 'taskDefinition'
  Prelude.Text ->
  DeregisterTaskDefinition
newDeregisterTaskDefinition :: Text -> DeregisterTaskDefinition
newDeregisterTaskDefinition Text
pTaskDefinition_ =
  DeregisterTaskDefinition' :: Text -> DeregisterTaskDefinition
DeregisterTaskDefinition'
    { $sel:taskDefinition:DeregisterTaskDefinition' :: Text
taskDefinition =
        Text
pTaskDefinition_
    }

-- | The @family@ and @revision@ (@family:revision@) or full Amazon Resource
-- Name (ARN) of the task definition to deregister. You must specify a
-- @revision@.
deregisterTaskDefinition_taskDefinition :: Lens.Lens' DeregisterTaskDefinition Prelude.Text
deregisterTaskDefinition_taskDefinition :: (Text -> f Text)
-> DeregisterTaskDefinition -> f DeregisterTaskDefinition
deregisterTaskDefinition_taskDefinition = (DeregisterTaskDefinition -> Text)
-> (DeregisterTaskDefinition -> Text -> DeregisterTaskDefinition)
-> Lens DeregisterTaskDefinition DeregisterTaskDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterTaskDefinition' {Text
taskDefinition :: Text
$sel:taskDefinition:DeregisterTaskDefinition' :: DeregisterTaskDefinition -> Text
taskDefinition} -> Text
taskDefinition) (\s :: DeregisterTaskDefinition
s@DeregisterTaskDefinition' {} Text
a -> DeregisterTaskDefinition
s {$sel:taskDefinition:DeregisterTaskDefinition' :: Text
taskDefinition = Text
a} :: DeregisterTaskDefinition)

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

instance Prelude.NFData DeregisterTaskDefinition

instance Core.ToHeaders DeregisterTaskDefinition where
  toHeaders :: DeregisterTaskDefinition -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeregisterTaskDefinition -> 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.DeregisterTaskDefinition" ::
                          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 DeregisterTaskDefinition where
  toJSON :: DeregisterTaskDefinition -> Value
toJSON DeregisterTaskDefinition' {Text
taskDefinition :: Text
$sel:taskDefinition:DeregisterTaskDefinition' :: DeregisterTaskDefinition -> 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
"taskDefinition" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
taskDefinition)
          ]
      )

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

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

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

-- |
-- Create a value of 'DeregisterTaskDefinitionResponse' 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:
--
-- 'taskDefinition', 'deregisterTaskDefinitionResponse_taskDefinition' - The full description of the deregistered task.
--
-- 'httpStatus', 'deregisterTaskDefinitionResponse_httpStatus' - The response's http status code.
newDeregisterTaskDefinitionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeregisterTaskDefinitionResponse
newDeregisterTaskDefinitionResponse :: Int -> DeregisterTaskDefinitionResponse
newDeregisterTaskDefinitionResponse Int
pHttpStatus_ =
  DeregisterTaskDefinitionResponse' :: Maybe TaskDefinition -> Int -> DeregisterTaskDefinitionResponse
DeregisterTaskDefinitionResponse'
    { $sel:taskDefinition:DeregisterTaskDefinitionResponse' :: Maybe TaskDefinition
taskDefinition =
        Maybe TaskDefinition
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeregisterTaskDefinitionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The full description of the deregistered task.
deregisterTaskDefinitionResponse_taskDefinition :: Lens.Lens' DeregisterTaskDefinitionResponse (Prelude.Maybe TaskDefinition)
deregisterTaskDefinitionResponse_taskDefinition :: (Maybe TaskDefinition -> f (Maybe TaskDefinition))
-> DeregisterTaskDefinitionResponse
-> f DeregisterTaskDefinitionResponse
deregisterTaskDefinitionResponse_taskDefinition = (DeregisterTaskDefinitionResponse -> Maybe TaskDefinition)
-> (DeregisterTaskDefinitionResponse
    -> Maybe TaskDefinition -> DeregisterTaskDefinitionResponse)
-> Lens
     DeregisterTaskDefinitionResponse
     DeregisterTaskDefinitionResponse
     (Maybe TaskDefinition)
     (Maybe TaskDefinition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterTaskDefinitionResponse' {Maybe TaskDefinition
taskDefinition :: Maybe TaskDefinition
$sel:taskDefinition:DeregisterTaskDefinitionResponse' :: DeregisterTaskDefinitionResponse -> Maybe TaskDefinition
taskDefinition} -> Maybe TaskDefinition
taskDefinition) (\s :: DeregisterTaskDefinitionResponse
s@DeregisterTaskDefinitionResponse' {} Maybe TaskDefinition
a -> DeregisterTaskDefinitionResponse
s {$sel:taskDefinition:DeregisterTaskDefinitionResponse' :: Maybe TaskDefinition
taskDefinition = Maybe TaskDefinition
a} :: DeregisterTaskDefinitionResponse)

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

instance
  Prelude.NFData
    DeregisterTaskDefinitionResponse