{-# 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.M2.CancelBatchJobExecution
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Cancels the running of a specific batch job execution.
module Amazonka.M2.CancelBatchJobExecution
  ( -- * Creating a Request
    CancelBatchJobExecution (..),
    newCancelBatchJobExecution,

    -- * Request Lenses
    cancelBatchJobExecution_applicationId,
    cancelBatchJobExecution_executionId,

    -- * Destructuring the Response
    CancelBatchJobExecutionResponse (..),
    newCancelBatchJobExecutionResponse,

    -- * Response Lenses
    cancelBatchJobExecutionResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCancelBatchJobExecution' smart constructor.
data CancelBatchJobExecution = CancelBatchJobExecution'
  { -- | The unique identifier of the application.
    CancelBatchJobExecution -> Text
applicationId :: Prelude.Text,
    -- | The unique identifier of the batch job execution.
    CancelBatchJobExecution -> Text
executionId :: Prelude.Text
  }
  deriving (CancelBatchJobExecution -> CancelBatchJobExecution -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelBatchJobExecution -> CancelBatchJobExecution -> Bool
$c/= :: CancelBatchJobExecution -> CancelBatchJobExecution -> Bool
== :: CancelBatchJobExecution -> CancelBatchJobExecution -> Bool
$c== :: CancelBatchJobExecution -> CancelBatchJobExecution -> Bool
Prelude.Eq, ReadPrec [CancelBatchJobExecution]
ReadPrec CancelBatchJobExecution
Int -> ReadS CancelBatchJobExecution
ReadS [CancelBatchJobExecution]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelBatchJobExecution]
$creadListPrec :: ReadPrec [CancelBatchJobExecution]
readPrec :: ReadPrec CancelBatchJobExecution
$creadPrec :: ReadPrec CancelBatchJobExecution
readList :: ReadS [CancelBatchJobExecution]
$creadList :: ReadS [CancelBatchJobExecution]
readsPrec :: Int -> ReadS CancelBatchJobExecution
$creadsPrec :: Int -> ReadS CancelBatchJobExecution
Prelude.Read, Int -> CancelBatchJobExecution -> ShowS
[CancelBatchJobExecution] -> ShowS
CancelBatchJobExecution -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelBatchJobExecution] -> ShowS
$cshowList :: [CancelBatchJobExecution] -> ShowS
show :: CancelBatchJobExecution -> String
$cshow :: CancelBatchJobExecution -> String
showsPrec :: Int -> CancelBatchJobExecution -> ShowS
$cshowsPrec :: Int -> CancelBatchJobExecution -> ShowS
Prelude.Show, forall x. Rep CancelBatchJobExecution x -> CancelBatchJobExecution
forall x. CancelBatchJobExecution -> Rep CancelBatchJobExecution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CancelBatchJobExecution x -> CancelBatchJobExecution
$cfrom :: forall x. CancelBatchJobExecution -> Rep CancelBatchJobExecution x
Prelude.Generic)

-- |
-- Create a value of 'CancelBatchJobExecution' 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:
--
-- 'applicationId', 'cancelBatchJobExecution_applicationId' - The unique identifier of the application.
--
-- 'executionId', 'cancelBatchJobExecution_executionId' - The unique identifier of the batch job execution.
newCancelBatchJobExecution ::
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'executionId'
  Prelude.Text ->
  CancelBatchJobExecution
newCancelBatchJobExecution :: Text -> Text -> CancelBatchJobExecution
newCancelBatchJobExecution
  Text
pApplicationId_
  Text
pExecutionId_ =
    CancelBatchJobExecution'
      { $sel:applicationId:CancelBatchJobExecution' :: Text
applicationId =
          Text
pApplicationId_,
        $sel:executionId:CancelBatchJobExecution' :: Text
executionId = Text
pExecutionId_
      }

-- | The unique identifier of the application.
cancelBatchJobExecution_applicationId :: Lens.Lens' CancelBatchJobExecution Prelude.Text
cancelBatchJobExecution_applicationId :: Lens' CancelBatchJobExecution Text
cancelBatchJobExecution_applicationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelBatchJobExecution' {Text
applicationId :: Text
$sel:applicationId:CancelBatchJobExecution' :: CancelBatchJobExecution -> Text
applicationId} -> Text
applicationId) (\s :: CancelBatchJobExecution
s@CancelBatchJobExecution' {} Text
a -> CancelBatchJobExecution
s {$sel:applicationId:CancelBatchJobExecution' :: Text
applicationId = Text
a} :: CancelBatchJobExecution)

-- | The unique identifier of the batch job execution.
cancelBatchJobExecution_executionId :: Lens.Lens' CancelBatchJobExecution Prelude.Text
cancelBatchJobExecution_executionId :: Lens' CancelBatchJobExecution Text
cancelBatchJobExecution_executionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelBatchJobExecution' {Text
executionId :: Text
$sel:executionId:CancelBatchJobExecution' :: CancelBatchJobExecution -> Text
executionId} -> Text
executionId) (\s :: CancelBatchJobExecution
s@CancelBatchJobExecution' {} Text
a -> CancelBatchJobExecution
s {$sel:executionId:CancelBatchJobExecution' :: Text
executionId = Text
a} :: CancelBatchJobExecution)

instance Core.AWSRequest CancelBatchJobExecution where
  type
    AWSResponse CancelBatchJobExecution =
      CancelBatchJobExecutionResponse
  request :: (Service -> Service)
-> CancelBatchJobExecution -> Request CancelBatchJobExecution
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 CancelBatchJobExecution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CancelBatchJobExecution)))
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 -> CancelBatchJobExecutionResponse
CancelBatchJobExecutionResponse'
            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 CancelBatchJobExecution where
  hashWithSalt :: Int -> CancelBatchJobExecution -> Int
hashWithSalt Int
_salt CancelBatchJobExecution' {Text
executionId :: Text
applicationId :: Text
$sel:executionId:CancelBatchJobExecution' :: CancelBatchJobExecution -> Text
$sel:applicationId:CancelBatchJobExecution' :: CancelBatchJobExecution -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
applicationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
executionId

instance Prelude.NFData CancelBatchJobExecution where
  rnf :: CancelBatchJobExecution -> ()
rnf CancelBatchJobExecution' {Text
executionId :: Text
applicationId :: Text
$sel:executionId:CancelBatchJobExecution' :: CancelBatchJobExecution -> Text
$sel:applicationId:CancelBatchJobExecution' :: CancelBatchJobExecution -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
applicationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
executionId

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

instance Data.ToJSON CancelBatchJobExecution where
  toJSON :: CancelBatchJobExecution -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

instance Data.ToPath CancelBatchJobExecution where
  toPath :: CancelBatchJobExecution -> ByteString
toPath CancelBatchJobExecution' {Text
executionId :: Text
applicationId :: Text
$sel:executionId:CancelBatchJobExecution' :: CancelBatchJobExecution -> Text
$sel:applicationId:CancelBatchJobExecution' :: CancelBatchJobExecution -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/applications/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
applicationId,
        ByteString
"/batch-job-executions/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
executionId,
        ByteString
"/cancel"
      ]

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

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

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

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

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