{-# 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.Batch.DeregisterJobDefinition
-- 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 an Batch job definition. Job definitions are permanently
-- deleted after 180 days.
module Amazonka.Batch.DeregisterJobDefinition
  ( -- * Creating a Request
    DeregisterJobDefinition (..),
    newDeregisterJobDefinition,

    -- * Request Lenses
    deregisterJobDefinition_jobDefinition,

    -- * Destructuring the Response
    DeregisterJobDefinitionResponse (..),
    newDeregisterJobDefinitionResponse,

    -- * Response Lenses
    deregisterJobDefinitionResponse_httpStatus,
  )
where

import Amazonka.Batch.Types
import qualified Amazonka.Core as Core
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:/ 'newDeregisterJobDefinition' smart constructor.
data DeregisterJobDefinition = DeregisterJobDefinition'
  { -- | The name and revision (@name:revision@) or full Amazon Resource Name
    -- (ARN) of the job definition to deregister.
    DeregisterJobDefinition -> Text
jobDefinition :: Prelude.Text
  }
  deriving (DeregisterJobDefinition -> DeregisterJobDefinition -> Bool
(DeregisterJobDefinition -> DeregisterJobDefinition -> Bool)
-> (DeregisterJobDefinition -> DeregisterJobDefinition -> Bool)
-> Eq DeregisterJobDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeregisterJobDefinition -> DeregisterJobDefinition -> Bool
$c/= :: DeregisterJobDefinition -> DeregisterJobDefinition -> Bool
== :: DeregisterJobDefinition -> DeregisterJobDefinition -> Bool
$c== :: DeregisterJobDefinition -> DeregisterJobDefinition -> Bool
Prelude.Eq, ReadPrec [DeregisterJobDefinition]
ReadPrec DeregisterJobDefinition
Int -> ReadS DeregisterJobDefinition
ReadS [DeregisterJobDefinition]
(Int -> ReadS DeregisterJobDefinition)
-> ReadS [DeregisterJobDefinition]
-> ReadPrec DeregisterJobDefinition
-> ReadPrec [DeregisterJobDefinition]
-> Read DeregisterJobDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeregisterJobDefinition]
$creadListPrec :: ReadPrec [DeregisterJobDefinition]
readPrec :: ReadPrec DeregisterJobDefinition
$creadPrec :: ReadPrec DeregisterJobDefinition
readList :: ReadS [DeregisterJobDefinition]
$creadList :: ReadS [DeregisterJobDefinition]
readsPrec :: Int -> ReadS DeregisterJobDefinition
$creadsPrec :: Int -> ReadS DeregisterJobDefinition
Prelude.Read, Int -> DeregisterJobDefinition -> ShowS
[DeregisterJobDefinition] -> ShowS
DeregisterJobDefinition -> String
(Int -> DeregisterJobDefinition -> ShowS)
-> (DeregisterJobDefinition -> String)
-> ([DeregisterJobDefinition] -> ShowS)
-> Show DeregisterJobDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeregisterJobDefinition] -> ShowS
$cshowList :: [DeregisterJobDefinition] -> ShowS
show :: DeregisterJobDefinition -> String
$cshow :: DeregisterJobDefinition -> String
showsPrec :: Int -> DeregisterJobDefinition -> ShowS
$cshowsPrec :: Int -> DeregisterJobDefinition -> ShowS
Prelude.Show, (forall x.
 DeregisterJobDefinition -> Rep DeregisterJobDefinition x)
-> (forall x.
    Rep DeregisterJobDefinition x -> DeregisterJobDefinition)
-> Generic DeregisterJobDefinition
forall x. Rep DeregisterJobDefinition x -> DeregisterJobDefinition
forall x. DeregisterJobDefinition -> Rep DeregisterJobDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeregisterJobDefinition x -> DeregisterJobDefinition
$cfrom :: forall x. DeregisterJobDefinition -> Rep DeregisterJobDefinition x
Prelude.Generic)

-- |
-- Create a value of 'DeregisterJobDefinition' 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:
--
-- 'jobDefinition', 'deregisterJobDefinition_jobDefinition' - The name and revision (@name:revision@) or full Amazon Resource Name
-- (ARN) of the job definition to deregister.
newDeregisterJobDefinition ::
  -- | 'jobDefinition'
  Prelude.Text ->
  DeregisterJobDefinition
newDeregisterJobDefinition :: Text -> DeregisterJobDefinition
newDeregisterJobDefinition Text
pJobDefinition_ =
  DeregisterJobDefinition' :: Text -> DeregisterJobDefinition
DeregisterJobDefinition'
    { $sel:jobDefinition:DeregisterJobDefinition' :: Text
jobDefinition =
        Text
pJobDefinition_
    }

-- | The name and revision (@name:revision@) or full Amazon Resource Name
-- (ARN) of the job definition to deregister.
deregisterJobDefinition_jobDefinition :: Lens.Lens' DeregisterJobDefinition Prelude.Text
deregisterJobDefinition_jobDefinition :: (Text -> f Text)
-> DeregisterJobDefinition -> f DeregisterJobDefinition
deregisterJobDefinition_jobDefinition = (DeregisterJobDefinition -> Text)
-> (DeregisterJobDefinition -> Text -> DeregisterJobDefinition)
-> Lens DeregisterJobDefinition DeregisterJobDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterJobDefinition' {Text
jobDefinition :: Text
$sel:jobDefinition:DeregisterJobDefinition' :: DeregisterJobDefinition -> Text
jobDefinition} -> Text
jobDefinition) (\s :: DeregisterJobDefinition
s@DeregisterJobDefinition' {} Text
a -> DeregisterJobDefinition
s {$sel:jobDefinition:DeregisterJobDefinition' :: Text
jobDefinition = Text
a} :: DeregisterJobDefinition)

instance Core.AWSRequest DeregisterJobDefinition where
  type
    AWSResponse DeregisterJobDefinition =
      DeregisterJobDefinitionResponse
  request :: DeregisterJobDefinition -> Request DeregisterJobDefinition
request = Service
-> DeregisterJobDefinition -> Request DeregisterJobDefinition
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeregisterJobDefinition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeregisterJobDefinition)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeregisterJobDefinition))
-> Logger
-> Service
-> Proxy DeregisterJobDefinition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeregisterJobDefinition)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeregisterJobDefinitionResponse
DeregisterJobDefinitionResponse'
            (Int -> DeregisterJobDefinitionResponse)
-> Either String Int
-> Either String DeregisterJobDefinitionResponse
forall (f :: * -> *) a b. Functor 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 DeregisterJobDefinition

instance Prelude.NFData DeregisterJobDefinition

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

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

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

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

-- |
-- Create a value of 'DeregisterJobDefinitionResponse' 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:
--
-- 'httpStatus', 'deregisterJobDefinitionResponse_httpStatus' - The response's http status code.
newDeregisterJobDefinitionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeregisterJobDefinitionResponse
newDeregisterJobDefinitionResponse :: Int -> DeregisterJobDefinitionResponse
newDeregisterJobDefinitionResponse Int
pHttpStatus_ =
  DeregisterJobDefinitionResponse' :: Int -> DeregisterJobDefinitionResponse
DeregisterJobDefinitionResponse'
    { $sel:httpStatus:DeregisterJobDefinitionResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance
  Prelude.NFData
    DeregisterJobDefinitionResponse