{-# 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.ElasticTranscoder.CancelJob
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- The CancelJob operation cancels an unfinished job.
--
-- You can only cancel a job that has a status of @Submitted@. To prevent a
-- pipeline from starting to process a job while you\'re getting the job
-- identifier, use UpdatePipelineStatus to temporarily pause the pipeline.
module Amazonka.ElasticTranscoder.CancelJob
  ( -- * Creating a Request
    CancelJob (..),
    newCancelJob,

    -- * Request Lenses
    cancelJob_id,

    -- * Destructuring the Response
    CancelJobResponse (..),
    newCancelJobResponse,

    -- * Response Lenses
    cancelJobResponse_httpStatus,
  )
where

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

-- | The @CancelJobRequest@ structure.
--
-- /See:/ 'newCancelJob' smart constructor.
data CancelJob = CancelJob'
  { -- | The identifier of the job that you want to cancel.
    --
    -- To get a list of the jobs (including their @jobId@) that have a status
    -- of @Submitted@, use the ListJobsByStatus API action.
    CancelJob -> Text
id :: Prelude.Text
  }
  deriving (CancelJob -> CancelJob -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelJob -> CancelJob -> Bool
$c/= :: CancelJob -> CancelJob -> Bool
== :: CancelJob -> CancelJob -> Bool
$c== :: CancelJob -> CancelJob -> Bool
Prelude.Eq, ReadPrec [CancelJob]
ReadPrec CancelJob
Int -> ReadS CancelJob
ReadS [CancelJob]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelJob]
$creadListPrec :: ReadPrec [CancelJob]
readPrec :: ReadPrec CancelJob
$creadPrec :: ReadPrec CancelJob
readList :: ReadS [CancelJob]
$creadList :: ReadS [CancelJob]
readsPrec :: Int -> ReadS CancelJob
$creadsPrec :: Int -> ReadS CancelJob
Prelude.Read, Int -> CancelJob -> ShowS
[CancelJob] -> ShowS
CancelJob -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelJob] -> ShowS
$cshowList :: [CancelJob] -> ShowS
show :: CancelJob -> String
$cshow :: CancelJob -> String
showsPrec :: Int -> CancelJob -> ShowS
$cshowsPrec :: Int -> CancelJob -> ShowS
Prelude.Show, forall x. Rep CancelJob x -> CancelJob
forall x. CancelJob -> Rep CancelJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CancelJob x -> CancelJob
$cfrom :: forall x. CancelJob -> Rep CancelJob x
Prelude.Generic)

-- |
-- Create a value of 'CancelJob' 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:
--
-- 'id', 'cancelJob_id' - The identifier of the job that you want to cancel.
--
-- To get a list of the jobs (including their @jobId@) that have a status
-- of @Submitted@, use the ListJobsByStatus API action.
newCancelJob ::
  -- | 'id'
  Prelude.Text ->
  CancelJob
newCancelJob :: Text -> CancelJob
newCancelJob Text
pId_ = CancelJob' {$sel:id:CancelJob' :: Text
id = Text
pId_}

-- | The identifier of the job that you want to cancel.
--
-- To get a list of the jobs (including their @jobId@) that have a status
-- of @Submitted@, use the ListJobsByStatus API action.
cancelJob_id :: Lens.Lens' CancelJob Prelude.Text
cancelJob_id :: Lens' CancelJob Text
cancelJob_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelJob' {Text
id :: Text
$sel:id:CancelJob' :: CancelJob -> Text
id} -> Text
id) (\s :: CancelJob
s@CancelJob' {} Text
a -> CancelJob
s {$sel:id:CancelJob' :: Text
id = Text
a} :: CancelJob)

instance Core.AWSRequest CancelJob where
  type AWSResponse CancelJob = CancelJobResponse
  request :: (Service -> Service) -> CancelJob -> Request CancelJob
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CancelJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CancelJob)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> CancelJobResponse
CancelJobResponse'
            forall (f :: * -> *) a b. Functor 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 CancelJob where
  hashWithSalt :: Int -> CancelJob -> Int
hashWithSalt Int
_salt CancelJob' {Text
id :: Text
$sel:id:CancelJob' :: CancelJob -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

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

instance Data.ToHeaders CancelJob where
  toHeaders :: CancelJob -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath CancelJob where
  toPath :: CancelJob -> ByteString
toPath CancelJob' {Text
id :: Text
$sel:id:CancelJob' :: CancelJob -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/2012-09-25/jobs/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
id]

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

-- | The response body contains a JSON object. If the job is successfully
-- canceled, the value of @Success@ is @true@.
--
-- /See:/ 'newCancelJobResponse' smart constructor.
data CancelJobResponse = CancelJobResponse'
  { -- | The response's http status code.
    CancelJobResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CancelJobResponse -> CancelJobResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelJobResponse -> CancelJobResponse -> Bool
$c/= :: CancelJobResponse -> CancelJobResponse -> Bool
== :: CancelJobResponse -> CancelJobResponse -> Bool
$c== :: CancelJobResponse -> CancelJobResponse -> Bool
Prelude.Eq, ReadPrec [CancelJobResponse]
ReadPrec CancelJobResponse
Int -> ReadS CancelJobResponse
ReadS [CancelJobResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelJobResponse]
$creadListPrec :: ReadPrec [CancelJobResponse]
readPrec :: ReadPrec CancelJobResponse
$creadPrec :: ReadPrec CancelJobResponse
readList :: ReadS [CancelJobResponse]
$creadList :: ReadS [CancelJobResponse]
readsPrec :: Int -> ReadS CancelJobResponse
$creadsPrec :: Int -> ReadS CancelJobResponse
Prelude.Read, Int -> CancelJobResponse -> ShowS
[CancelJobResponse] -> ShowS
CancelJobResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelJobResponse] -> ShowS
$cshowList :: [CancelJobResponse] -> ShowS
show :: CancelJobResponse -> String
$cshow :: CancelJobResponse -> String
showsPrec :: Int -> CancelJobResponse -> ShowS
$cshowsPrec :: Int -> CancelJobResponse -> ShowS
Prelude.Show, forall x. Rep CancelJobResponse x -> CancelJobResponse
forall x. CancelJobResponse -> Rep CancelJobResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CancelJobResponse x -> CancelJobResponse
$cfrom :: forall x. CancelJobResponse -> Rep CancelJobResponse x
Prelude.Generic)

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

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

instance Prelude.NFData CancelJobResponse where
  rnf :: CancelJobResponse -> ()
rnf CancelJobResponse' {Int
httpStatus :: Int
$sel:httpStatus:CancelJobResponse' :: CancelJobResponse -> Int
..} = forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus