{-# 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 #-}
module Amazonka.Batch.TerminateJob
(
TerminateJob (..),
newTerminateJob,
terminateJob_jobId,
terminateJob_reason,
TerminateJobResponse (..),
newTerminateJobResponse,
terminateJobResponse_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
data TerminateJob = TerminateJob'
{
TerminateJob -> Text
jobId :: Prelude.Text,
TerminateJob -> Text
reason :: Prelude.Text
}
deriving (TerminateJob -> TerminateJob -> Bool
(TerminateJob -> TerminateJob -> Bool)
-> (TerminateJob -> TerminateJob -> Bool) -> Eq TerminateJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TerminateJob -> TerminateJob -> Bool
$c/= :: TerminateJob -> TerminateJob -> Bool
== :: TerminateJob -> TerminateJob -> Bool
$c== :: TerminateJob -> TerminateJob -> Bool
Prelude.Eq, ReadPrec [TerminateJob]
ReadPrec TerminateJob
Int -> ReadS TerminateJob
ReadS [TerminateJob]
(Int -> ReadS TerminateJob)
-> ReadS [TerminateJob]
-> ReadPrec TerminateJob
-> ReadPrec [TerminateJob]
-> Read TerminateJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TerminateJob]
$creadListPrec :: ReadPrec [TerminateJob]
readPrec :: ReadPrec TerminateJob
$creadPrec :: ReadPrec TerminateJob
readList :: ReadS [TerminateJob]
$creadList :: ReadS [TerminateJob]
readsPrec :: Int -> ReadS TerminateJob
$creadsPrec :: Int -> ReadS TerminateJob
Prelude.Read, Int -> TerminateJob -> ShowS
[TerminateJob] -> ShowS
TerminateJob -> String
(Int -> TerminateJob -> ShowS)
-> (TerminateJob -> String)
-> ([TerminateJob] -> ShowS)
-> Show TerminateJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TerminateJob] -> ShowS
$cshowList :: [TerminateJob] -> ShowS
show :: TerminateJob -> String
$cshow :: TerminateJob -> String
showsPrec :: Int -> TerminateJob -> ShowS
$cshowsPrec :: Int -> TerminateJob -> ShowS
Prelude.Show, (forall x. TerminateJob -> Rep TerminateJob x)
-> (forall x. Rep TerminateJob x -> TerminateJob)
-> Generic TerminateJob
forall x. Rep TerminateJob x -> TerminateJob
forall x. TerminateJob -> Rep TerminateJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TerminateJob x -> TerminateJob
$cfrom :: forall x. TerminateJob -> Rep TerminateJob x
Prelude.Generic)
newTerminateJob ::
Prelude.Text ->
Prelude.Text ->
TerminateJob
newTerminateJob :: Text -> Text -> TerminateJob
newTerminateJob Text
pJobId_ Text
pReason_ =
TerminateJob' :: Text -> Text -> TerminateJob
TerminateJob' {$sel:jobId:TerminateJob' :: Text
jobId = Text
pJobId_, $sel:reason:TerminateJob' :: Text
reason = Text
pReason_}
terminateJob_jobId :: Lens.Lens' TerminateJob Prelude.Text
terminateJob_jobId :: (Text -> f Text) -> TerminateJob -> f TerminateJob
terminateJob_jobId = (TerminateJob -> Text)
-> (TerminateJob -> Text -> TerminateJob)
-> Lens TerminateJob TerminateJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TerminateJob' {Text
jobId :: Text
$sel:jobId:TerminateJob' :: TerminateJob -> Text
jobId} -> Text
jobId) (\s :: TerminateJob
s@TerminateJob' {} Text
a -> TerminateJob
s {$sel:jobId:TerminateJob' :: Text
jobId = Text
a} :: TerminateJob)
terminateJob_reason :: Lens.Lens' TerminateJob Prelude.Text
terminateJob_reason :: (Text -> f Text) -> TerminateJob -> f TerminateJob
terminateJob_reason = (TerminateJob -> Text)
-> (TerminateJob -> Text -> TerminateJob)
-> Lens TerminateJob TerminateJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TerminateJob' {Text
reason :: Text
$sel:reason:TerminateJob' :: TerminateJob -> Text
reason} -> Text
reason) (\s :: TerminateJob
s@TerminateJob' {} Text
a -> TerminateJob
s {$sel:reason:TerminateJob' :: Text
reason = Text
a} :: TerminateJob)
instance Core.AWSRequest TerminateJob where
type AWSResponse TerminateJob = TerminateJobResponse
request :: TerminateJob -> Request TerminateJob
request = Service -> TerminateJob -> Request TerminateJob
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy TerminateJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse TerminateJob)))
response =
(Int
-> ResponseHeaders
-> ()
-> Either String (AWSResponse TerminateJob))
-> Logger
-> Service
-> Proxy TerminateJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse TerminateJob)))
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 -> TerminateJobResponse
TerminateJobResponse'
(Int -> TerminateJobResponse)
-> Either String Int -> Either String TerminateJobResponse
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 TerminateJob
instance Prelude.NFData TerminateJob
instance Core.ToHeaders TerminateJob where
toHeaders :: TerminateJob -> ResponseHeaders
toHeaders =
ResponseHeaders -> TerminateJob -> 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 TerminateJob where
toJSON :: TerminateJob -> Value
toJSON TerminateJob' {Text
reason :: Text
jobId :: Text
$sel:reason:TerminateJob' :: TerminateJob -> Text
$sel:jobId:TerminateJob' :: TerminateJob -> 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
"jobId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
jobId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"reason" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
reason)
]
)
instance Core.ToPath TerminateJob where
toPath :: TerminateJob -> ByteString
toPath = ByteString -> TerminateJob -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/v1/terminatejob"
instance Core.ToQuery TerminateJob where
toQuery :: TerminateJob -> QueryString
toQuery = QueryString -> TerminateJob -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data TerminateJobResponse = TerminateJobResponse'
{
TerminateJobResponse -> Int
httpStatus :: Prelude.Int
}
deriving (TerminateJobResponse -> TerminateJobResponse -> Bool
(TerminateJobResponse -> TerminateJobResponse -> Bool)
-> (TerminateJobResponse -> TerminateJobResponse -> Bool)
-> Eq TerminateJobResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TerminateJobResponse -> TerminateJobResponse -> Bool
$c/= :: TerminateJobResponse -> TerminateJobResponse -> Bool
== :: TerminateJobResponse -> TerminateJobResponse -> Bool
$c== :: TerminateJobResponse -> TerminateJobResponse -> Bool
Prelude.Eq, ReadPrec [TerminateJobResponse]
ReadPrec TerminateJobResponse
Int -> ReadS TerminateJobResponse
ReadS [TerminateJobResponse]
(Int -> ReadS TerminateJobResponse)
-> ReadS [TerminateJobResponse]
-> ReadPrec TerminateJobResponse
-> ReadPrec [TerminateJobResponse]
-> Read TerminateJobResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TerminateJobResponse]
$creadListPrec :: ReadPrec [TerminateJobResponse]
readPrec :: ReadPrec TerminateJobResponse
$creadPrec :: ReadPrec TerminateJobResponse
readList :: ReadS [TerminateJobResponse]
$creadList :: ReadS [TerminateJobResponse]
readsPrec :: Int -> ReadS TerminateJobResponse
$creadsPrec :: Int -> ReadS TerminateJobResponse
Prelude.Read, Int -> TerminateJobResponse -> ShowS
[TerminateJobResponse] -> ShowS
TerminateJobResponse -> String
(Int -> TerminateJobResponse -> ShowS)
-> (TerminateJobResponse -> String)
-> ([TerminateJobResponse] -> ShowS)
-> Show TerminateJobResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TerminateJobResponse] -> ShowS
$cshowList :: [TerminateJobResponse] -> ShowS
show :: TerminateJobResponse -> String
$cshow :: TerminateJobResponse -> String
showsPrec :: Int -> TerminateJobResponse -> ShowS
$cshowsPrec :: Int -> TerminateJobResponse -> ShowS
Prelude.Show, (forall x. TerminateJobResponse -> Rep TerminateJobResponse x)
-> (forall x. Rep TerminateJobResponse x -> TerminateJobResponse)
-> Generic TerminateJobResponse
forall x. Rep TerminateJobResponse x -> TerminateJobResponse
forall x. TerminateJobResponse -> Rep TerminateJobResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TerminateJobResponse x -> TerminateJobResponse
$cfrom :: forall x. TerminateJobResponse -> Rep TerminateJobResponse x
Prelude.Generic)
newTerminateJobResponse ::
Prelude.Int ->
TerminateJobResponse
newTerminateJobResponse :: Int -> TerminateJobResponse
newTerminateJobResponse Int
pHttpStatus_ =
TerminateJobResponse' :: Int -> TerminateJobResponse
TerminateJobResponse' {$sel:httpStatus:TerminateJobResponse' :: Int
httpStatus = Int
pHttpStatus_}
terminateJobResponse_httpStatus :: Lens.Lens' TerminateJobResponse Prelude.Int
terminateJobResponse_httpStatus :: (Int -> f Int) -> TerminateJobResponse -> f TerminateJobResponse
terminateJobResponse_httpStatus = (TerminateJobResponse -> Int)
-> (TerminateJobResponse -> Int -> TerminateJobResponse)
-> Lens TerminateJobResponse TerminateJobResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TerminateJobResponse' {Int
httpStatus :: Int
$sel:httpStatus:TerminateJobResponse' :: TerminateJobResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: TerminateJobResponse
s@TerminateJobResponse' {} Int
a -> TerminateJobResponse
s {$sel:httpStatus:TerminateJobResponse' :: Int
httpStatus = Int
a} :: TerminateJobResponse)
instance Prelude.NFData TerminateJobResponse