{-# 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.Glue.DeleteJob
-- 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 a specified job definition. If the job definition is not found,
-- no exception is thrown.
module Amazonka.Glue.DeleteJob
  ( -- * Creating a Request
    DeleteJob (..),
    newDeleteJob,

    -- * Request Lenses
    deleteJob_jobName,

    -- * Destructuring the Response
    DeleteJobResponse (..),
    newDeleteJobResponse,

    -- * Response Lenses
    deleteJobResponse_jobName,
    deleteJobResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteJob' smart constructor.
data DeleteJob = DeleteJob'
  { -- | The name of the job definition to delete.
    DeleteJob -> Text
jobName :: Prelude.Text
  }
  deriving (DeleteJob -> DeleteJob -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteJob -> DeleteJob -> Bool
$c/= :: DeleteJob -> DeleteJob -> Bool
== :: DeleteJob -> DeleteJob -> Bool
$c== :: DeleteJob -> DeleteJob -> Bool
Prelude.Eq, ReadPrec [DeleteJob]
ReadPrec DeleteJob
Int -> ReadS DeleteJob
ReadS [DeleteJob]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteJob]
$creadListPrec :: ReadPrec [DeleteJob]
readPrec :: ReadPrec DeleteJob
$creadPrec :: ReadPrec DeleteJob
readList :: ReadS [DeleteJob]
$creadList :: ReadS [DeleteJob]
readsPrec :: Int -> ReadS DeleteJob
$creadsPrec :: Int -> ReadS DeleteJob
Prelude.Read, Int -> DeleteJob -> ShowS
[DeleteJob] -> ShowS
DeleteJob -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteJob] -> ShowS
$cshowList :: [DeleteJob] -> ShowS
show :: DeleteJob -> String
$cshow :: DeleteJob -> String
showsPrec :: Int -> DeleteJob -> ShowS
$cshowsPrec :: Int -> DeleteJob -> ShowS
Prelude.Show, forall x. Rep DeleteJob x -> DeleteJob
forall x. DeleteJob -> Rep DeleteJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteJob x -> DeleteJob
$cfrom :: forall x. DeleteJob -> Rep DeleteJob x
Prelude.Generic)

-- |
-- Create a value of 'DeleteJob' 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:
--
-- 'jobName', 'deleteJob_jobName' - The name of the job definition to delete.
newDeleteJob ::
  -- | 'jobName'
  Prelude.Text ->
  DeleteJob
newDeleteJob :: Text -> DeleteJob
newDeleteJob Text
pJobName_ =
  DeleteJob' {$sel:jobName:DeleteJob' :: Text
jobName = Text
pJobName_}

-- | The name of the job definition to delete.
deleteJob_jobName :: Lens.Lens' DeleteJob Prelude.Text
deleteJob_jobName :: Lens' DeleteJob Text
deleteJob_jobName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteJob' {Text
jobName :: Text
$sel:jobName:DeleteJob' :: DeleteJob -> Text
jobName} -> Text
jobName) (\s :: DeleteJob
s@DeleteJob' {} Text
a -> DeleteJob
s {$sel:jobName:DeleteJob' :: Text
jobName = Text
a} :: DeleteJob)

instance Core.AWSRequest DeleteJob where
  type AWSResponse DeleteJob = DeleteJobResponse
  request :: (Service -> Service) -> DeleteJob -> Request DeleteJob
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteJob)))
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 Text -> Int -> DeleteJobResponse
DeleteJobResponse'
            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
"JobName")
            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 DeleteJob where
  hashWithSalt :: Int -> DeleteJob -> Int
hashWithSalt Int
_salt DeleteJob' {Text
jobName :: Text
$sel:jobName:DeleteJob' :: DeleteJob -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
jobName

instance Prelude.NFData DeleteJob where
  rnf :: DeleteJob -> ()
rnf DeleteJob' {Text
jobName :: Text
$sel:jobName:DeleteJob' :: DeleteJob -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
jobName

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

instance Data.ToJSON DeleteJob where
  toJSON :: DeleteJob -> Value
toJSON DeleteJob' {Text
jobName :: Text
$sel:jobName:DeleteJob' :: DeleteJob -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"JobName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
jobName)]
      )

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

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

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

-- |
-- Create a value of 'DeleteJobResponse' 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:
--
-- 'jobName', 'deleteJobResponse_jobName' - The name of the job definition that was deleted.
--
-- 'httpStatus', 'deleteJobResponse_httpStatus' - The response's http status code.
newDeleteJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteJobResponse
newDeleteJobResponse :: Int -> DeleteJobResponse
newDeleteJobResponse Int
pHttpStatus_ =
  DeleteJobResponse'
    { $sel:jobName:DeleteJobResponse' :: Maybe Text
jobName = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteJobResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The name of the job definition that was deleted.
deleteJobResponse_jobName :: Lens.Lens' DeleteJobResponse (Prelude.Maybe Prelude.Text)
deleteJobResponse_jobName :: Lens' DeleteJobResponse (Maybe Text)
deleteJobResponse_jobName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteJobResponse' {Maybe Text
jobName :: Maybe Text
$sel:jobName:DeleteJobResponse' :: DeleteJobResponse -> Maybe Text
jobName} -> Maybe Text
jobName) (\s :: DeleteJobResponse
s@DeleteJobResponse' {} Maybe Text
a -> DeleteJobResponse
s {$sel:jobName:DeleteJobResponse' :: Maybe Text
jobName = Maybe Text
a} :: DeleteJobResponse)

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

instance Prelude.NFData DeleteJobResponse where
  rnf :: DeleteJobResponse -> ()
rnf DeleteJobResponse' {Int
Maybe Text
httpStatus :: Int
jobName :: Maybe Text
$sel:httpStatus:DeleteJobResponse' :: DeleteJobResponse -> Int
$sel:jobName:DeleteJobResponse' :: DeleteJobResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
jobName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus