{-# 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.Amplify.DeleteJob
-- 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 a job for a branch of an Amplify app.
module Amazonka.Amplify.DeleteJob
  ( -- * Creating a Request
    DeleteJob (..),
    newDeleteJob,

    -- * Request Lenses
    deleteJob_appId,
    deleteJob_branchName,
    deleteJob_jobId,

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

    -- * Response Lenses
    deleteJobResponse_httpStatus,
    deleteJobResponse_jobSummary,
  )
where

import Amazonka.Amplify.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

-- | The request structure for the delete job request.
--
-- /See:/ 'newDeleteJob' smart constructor.
data DeleteJob = DeleteJob'
  { -- | The unique ID for an Amplify app.
    DeleteJob -> Text
appId :: Prelude.Text,
    -- | The name for the branch, for the job.
    DeleteJob -> Text
branchName :: Prelude.Text,
    -- | The unique ID for the job.
    DeleteJob -> Text
jobId :: Prelude.Text
  }
  deriving (DeleteJob -> DeleteJob -> Bool
(DeleteJob -> DeleteJob -> Bool)
-> (DeleteJob -> DeleteJob -> Bool) -> Eq DeleteJob
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]
(Int -> ReadS DeleteJob)
-> ReadS [DeleteJob]
-> ReadPrec DeleteJob
-> ReadPrec [DeleteJob]
-> Read 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
(Int -> DeleteJob -> ShowS)
-> (DeleteJob -> String)
-> ([DeleteJob] -> ShowS)
-> Show DeleteJob
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. DeleteJob -> Rep DeleteJob x)
-> (forall x. Rep DeleteJob x -> DeleteJob) -> Generic DeleteJob
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:
--
-- 'appId', 'deleteJob_appId' - The unique ID for an Amplify app.
--
-- 'branchName', 'deleteJob_branchName' - The name for the branch, for the job.
--
-- 'jobId', 'deleteJob_jobId' - The unique ID for the job.
newDeleteJob ::
  -- | 'appId'
  Prelude.Text ->
  -- | 'branchName'
  Prelude.Text ->
  -- | 'jobId'
  Prelude.Text ->
  DeleteJob
newDeleteJob :: Text -> Text -> Text -> DeleteJob
newDeleteJob Text
pAppId_ Text
pBranchName_ Text
pJobId_ =
  DeleteJob' :: Text -> Text -> Text -> DeleteJob
DeleteJob'
    { $sel:appId:DeleteJob' :: Text
appId = Text
pAppId_,
      $sel:branchName:DeleteJob' :: Text
branchName = Text
pBranchName_,
      $sel:jobId:DeleteJob' :: Text
jobId = Text
pJobId_
    }

-- | The unique ID for an Amplify app.
deleteJob_appId :: Lens.Lens' DeleteJob Prelude.Text
deleteJob_appId :: (Text -> f Text) -> DeleteJob -> f DeleteJob
deleteJob_appId = (DeleteJob -> Text)
-> (DeleteJob -> Text -> DeleteJob)
-> Lens DeleteJob DeleteJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteJob' {Text
appId :: Text
$sel:appId:DeleteJob' :: DeleteJob -> Text
appId} -> Text
appId) (\s :: DeleteJob
s@DeleteJob' {} Text
a -> DeleteJob
s {$sel:appId:DeleteJob' :: Text
appId = Text
a} :: DeleteJob)

-- | The name for the branch, for the job.
deleteJob_branchName :: Lens.Lens' DeleteJob Prelude.Text
deleteJob_branchName :: (Text -> f Text) -> DeleteJob -> f DeleteJob
deleteJob_branchName = (DeleteJob -> Text)
-> (DeleteJob -> Text -> DeleteJob)
-> Lens DeleteJob DeleteJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteJob' {Text
branchName :: Text
$sel:branchName:DeleteJob' :: DeleteJob -> Text
branchName} -> Text
branchName) (\s :: DeleteJob
s@DeleteJob' {} Text
a -> DeleteJob
s {$sel:branchName:DeleteJob' :: Text
branchName = Text
a} :: DeleteJob)

-- | The unique ID for the job.
deleteJob_jobId :: Lens.Lens' DeleteJob Prelude.Text
deleteJob_jobId :: (Text -> f Text) -> DeleteJob -> f DeleteJob
deleteJob_jobId = (DeleteJob -> Text)
-> (DeleteJob -> Text -> DeleteJob)
-> Lens DeleteJob DeleteJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteJob' {Text
jobId :: Text
$sel:jobId:DeleteJob' :: DeleteJob -> Text
jobId} -> Text
jobId) (\s :: DeleteJob
s@DeleteJob' {} Text
a -> DeleteJob
s {$sel:jobId:DeleteJob' :: Text
jobId = Text
a} :: DeleteJob)

instance Core.AWSRequest DeleteJob where
  type AWSResponse DeleteJob = DeleteJobResponse
  request :: DeleteJob -> Request DeleteJob
request = Service -> DeleteJob -> Request DeleteJob
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteJob)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteJob))
-> Logger
-> Service
-> Proxy DeleteJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteJob)))
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 ->
          Int -> JobSummary -> DeleteJobResponse
DeleteJobResponse'
            (Int -> JobSummary -> DeleteJobResponse)
-> Either String Int
-> Either String (JobSummary -> DeleteJobResponse)
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))
            Either String (JobSummary -> DeleteJobResponse)
-> Either String JobSummary -> Either String DeleteJobResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String JobSummary
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"jobSummary")
      )

instance Prelude.Hashable DeleteJob

instance Prelude.NFData DeleteJob

instance Core.ToHeaders DeleteJob where
  toHeaders :: DeleteJob -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteJob -> 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.ToPath DeleteJob where
  toPath :: DeleteJob -> ByteString
toPath DeleteJob' {Text
jobId :: Text
branchName :: Text
appId :: Text
$sel:jobId:DeleteJob' :: DeleteJob -> Text
$sel:branchName:DeleteJob' :: DeleteJob -> Text
$sel:appId:DeleteJob' :: DeleteJob -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/apps/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
appId,
        ByteString
"/branches/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
branchName,
        ByteString
"/jobs/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
jobId
      ]

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

-- | The result structure for the delete job request.
--
-- /See:/ 'newDeleteJobResponse' smart constructor.
data DeleteJobResponse = DeleteJobResponse'
  { -- | The response's http status code.
    DeleteJobResponse -> Int
httpStatus :: Prelude.Int,
    DeleteJobResponse -> JobSummary
jobSummary :: JobSummary
  }
  deriving (DeleteJobResponse -> DeleteJobResponse -> Bool
(DeleteJobResponse -> DeleteJobResponse -> Bool)
-> (DeleteJobResponse -> DeleteJobResponse -> Bool)
-> Eq DeleteJobResponse
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]
(Int -> ReadS DeleteJobResponse)
-> ReadS [DeleteJobResponse]
-> ReadPrec DeleteJobResponse
-> ReadPrec [DeleteJobResponse]
-> Read 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
(Int -> DeleteJobResponse -> ShowS)
-> (DeleteJobResponse -> String)
-> ([DeleteJobResponse] -> ShowS)
-> Show DeleteJobResponse
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. DeleteJobResponse -> Rep DeleteJobResponse x)
-> (forall x. Rep DeleteJobResponse x -> DeleteJobResponse)
-> Generic DeleteJobResponse
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:
--
-- 'httpStatus', 'deleteJobResponse_httpStatus' - The response's http status code.
--
-- 'jobSummary', 'deleteJobResponse_jobSummary' - Undocumented member.
newDeleteJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'jobSummary'
  JobSummary ->
  DeleteJobResponse
newDeleteJobResponse :: Int -> JobSummary -> DeleteJobResponse
newDeleteJobResponse Int
pHttpStatus_ JobSummary
pJobSummary_ =
  DeleteJobResponse' :: Int -> JobSummary -> DeleteJobResponse
DeleteJobResponse'
    { $sel:httpStatus:DeleteJobResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:jobSummary:DeleteJobResponse' :: JobSummary
jobSummary = JobSummary
pJobSummary_
    }

-- | The response's http status code.
deleteJobResponse_httpStatus :: Lens.Lens' DeleteJobResponse Prelude.Int
deleteJobResponse_httpStatus :: (Int -> f Int) -> DeleteJobResponse -> f DeleteJobResponse
deleteJobResponse_httpStatus = (DeleteJobResponse -> Int)
-> (DeleteJobResponse -> Int -> DeleteJobResponse)
-> Lens DeleteJobResponse DeleteJobResponse Int Int
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)

-- | Undocumented member.
deleteJobResponse_jobSummary :: Lens.Lens' DeleteJobResponse JobSummary
deleteJobResponse_jobSummary :: (JobSummary -> f JobSummary)
-> DeleteJobResponse -> f DeleteJobResponse
deleteJobResponse_jobSummary = (DeleteJobResponse -> JobSummary)
-> (DeleteJobResponse -> JobSummary -> DeleteJobResponse)
-> Lens DeleteJobResponse DeleteJobResponse JobSummary JobSummary
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteJobResponse' {JobSummary
jobSummary :: JobSummary
$sel:jobSummary:DeleteJobResponse' :: DeleteJobResponse -> JobSummary
jobSummary} -> JobSummary
jobSummary) (\s :: DeleteJobResponse
s@DeleteJobResponse' {} JobSummary
a -> DeleteJobResponse
s {$sel:jobSummary:DeleteJobResponse' :: JobSummary
jobSummary = JobSummary
a} :: DeleteJobResponse)

instance Prelude.NFData DeleteJobResponse