{-# 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.IoT.CancelJob
(
CancelJob (..),
newCancelJob,
cancelJob_force,
cancelJob_reasonCode,
cancelJob_comment,
cancelJob_jobId,
CancelJobResponse (..),
newCancelJobResponse,
cancelJobResponse_jobId,
cancelJobResponse_jobArn,
cancelJobResponse_description,
cancelJobResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import Amazonka.IoT.Types
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 CancelJob = CancelJob'
{
CancelJob -> Maybe Bool
force :: Prelude.Maybe Prelude.Bool,
CancelJob -> Maybe Text
reasonCode :: Prelude.Maybe Prelude.Text,
:: Prelude.Maybe Prelude.Text,
CancelJob -> Text
jobId :: Prelude.Text
}
deriving (CancelJob -> CancelJob -> Bool
(CancelJob -> CancelJob -> Bool)
-> (CancelJob -> CancelJob -> Bool) -> Eq CancelJob
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]
(Int -> ReadS CancelJob)
-> ReadS [CancelJob]
-> ReadPrec CancelJob
-> ReadPrec [CancelJob]
-> Read 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
(Int -> CancelJob -> ShowS)
-> (CancelJob -> String)
-> ([CancelJob] -> ShowS)
-> Show CancelJob
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. CancelJob -> Rep CancelJob x)
-> (forall x. Rep CancelJob x -> CancelJob) -> Generic CancelJob
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)
newCancelJob ::
Prelude.Text ->
CancelJob
newCancelJob :: Text -> CancelJob
newCancelJob Text
pJobId_ =
CancelJob' :: Maybe Bool -> Maybe Text -> Maybe Text -> Text -> CancelJob
CancelJob'
{ $sel:force:CancelJob' :: Maybe Bool
force = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
$sel:reasonCode:CancelJob' :: Maybe Text
reasonCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:comment:CancelJob' :: Maybe Text
comment = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:jobId:CancelJob' :: Text
jobId = Text
pJobId_
}
cancelJob_force :: Lens.Lens' CancelJob (Prelude.Maybe Prelude.Bool)
cancelJob_force :: (Maybe Bool -> f (Maybe Bool)) -> CancelJob -> f CancelJob
cancelJob_force = (CancelJob -> Maybe Bool)
-> (CancelJob -> Maybe Bool -> CancelJob)
-> Lens CancelJob CancelJob (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelJob' {Maybe Bool
force :: Maybe Bool
$sel:force:CancelJob' :: CancelJob -> Maybe Bool
force} -> Maybe Bool
force) (\s :: CancelJob
s@CancelJob' {} Maybe Bool
a -> CancelJob
s {$sel:force:CancelJob' :: Maybe Bool
force = Maybe Bool
a} :: CancelJob)
cancelJob_reasonCode :: Lens.Lens' CancelJob (Prelude.Maybe Prelude.Text)
cancelJob_reasonCode :: (Maybe Text -> f (Maybe Text)) -> CancelJob -> f CancelJob
cancelJob_reasonCode = (CancelJob -> Maybe Text)
-> (CancelJob -> Maybe Text -> CancelJob)
-> Lens CancelJob CancelJob (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelJob' {Maybe Text
reasonCode :: Maybe Text
$sel:reasonCode:CancelJob' :: CancelJob -> Maybe Text
reasonCode} -> Maybe Text
reasonCode) (\s :: CancelJob
s@CancelJob' {} Maybe Text
a -> CancelJob
s {$sel:reasonCode:CancelJob' :: Maybe Text
reasonCode = Maybe Text
a} :: CancelJob)
cancelJob_comment :: Lens.Lens' CancelJob (Prelude.Maybe Prelude.Text)
= (CancelJob -> Maybe Text)
-> (CancelJob -> Maybe Text -> CancelJob)
-> Lens CancelJob CancelJob (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelJob' {Maybe Text
comment :: Maybe Text
$sel:comment:CancelJob' :: CancelJob -> Maybe Text
comment} -> Maybe Text
comment) (\s :: CancelJob
s@CancelJob' {} Maybe Text
a -> CancelJob
s {$sel:comment:CancelJob' :: Maybe Text
comment = Maybe Text
a} :: CancelJob)
cancelJob_jobId :: Lens.Lens' CancelJob Prelude.Text
cancelJob_jobId :: (Text -> f Text) -> CancelJob -> f CancelJob
cancelJob_jobId = (CancelJob -> Text)
-> (CancelJob -> Text -> CancelJob)
-> Lens CancelJob CancelJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelJob' {Text
jobId :: Text
$sel:jobId:CancelJob' :: CancelJob -> Text
jobId} -> Text
jobId) (\s :: CancelJob
s@CancelJob' {} Text
a -> CancelJob
s {$sel:jobId:CancelJob' :: Text
jobId = Text
a} :: CancelJob)
instance Core.AWSRequest CancelJob where
type AWSResponse CancelJob = CancelJobResponse
request :: CancelJob -> Request CancelJob
request = Service -> CancelJob -> Request CancelJob
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CancelJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CancelJob)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CancelJob))
-> Logger
-> Service
-> Proxy CancelJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CancelJob)))
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 ->
Maybe Text -> Maybe Text -> Maybe Text -> Int -> CancelJobResponse
CancelJobResponse'
(Maybe Text
-> Maybe Text -> Maybe Text -> Int -> CancelJobResponse)
-> Either String (Maybe Text)
-> Either
String (Maybe Text -> Maybe Text -> Int -> CancelJobResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"jobId")
Either
String (Maybe Text -> Maybe Text -> Int -> CancelJobResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> CancelJobResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"jobArn")
Either String (Maybe Text -> Int -> CancelJobResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CancelJobResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"description")
Either String (Int -> CancelJobResponse)
-> Either String Int -> Either String CancelJobResponse
forall (f :: * -> *) a b. Applicative f => 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 CancelJob
instance Prelude.NFData CancelJob
instance Core.ToHeaders CancelJob where
toHeaders :: CancelJob -> ResponseHeaders
toHeaders = ResponseHeaders -> CancelJob -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToJSON CancelJob where
toJSON :: CancelJob -> Value
toJSON CancelJob' {Maybe Bool
Maybe Text
Text
jobId :: Text
comment :: Maybe Text
reasonCode :: Maybe Text
force :: Maybe Bool
$sel:jobId:CancelJob' :: CancelJob -> Text
$sel:comment:CancelJob' :: CancelJob -> Maybe Text
$sel:reasonCode:CancelJob' :: CancelJob -> Maybe Text
$sel:force:CancelJob' :: CancelJob -> Maybe Bool
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"reasonCode" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
reasonCode,
(Text
"comment" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
comment
]
)
instance Core.ToPath CancelJob where
toPath :: CancelJob -> ByteString
toPath CancelJob' {Maybe Bool
Maybe Text
Text
jobId :: Text
comment :: Maybe Text
reasonCode :: Maybe Text
force :: Maybe Bool
$sel:jobId:CancelJob' :: CancelJob -> Text
$sel:comment:CancelJob' :: CancelJob -> Maybe Text
$sel:reasonCode:CancelJob' :: CancelJob -> Maybe Text
$sel:force:CancelJob' :: CancelJob -> Maybe Bool
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/jobs/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
jobId, ByteString
"/cancel"]
instance Core.ToQuery CancelJob where
toQuery :: CancelJob -> QueryString
toQuery CancelJob' {Maybe Bool
Maybe Text
Text
jobId :: Text
comment :: Maybe Text
reasonCode :: Maybe Text
force :: Maybe Bool
$sel:jobId:CancelJob' :: CancelJob -> Text
$sel:comment:CancelJob' :: CancelJob -> Maybe Text
$sel:reasonCode:CancelJob' :: CancelJob -> Maybe Text
$sel:force:CancelJob' :: CancelJob -> Maybe Bool
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"force" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
force]
data CancelJobResponse = CancelJobResponse'
{
CancelJobResponse -> Maybe Text
jobId :: Prelude.Maybe Prelude.Text,
CancelJobResponse -> Maybe Text
jobArn :: Prelude.Maybe Prelude.Text,
CancelJobResponse -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
CancelJobResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CancelJobResponse -> CancelJobResponse -> Bool
(CancelJobResponse -> CancelJobResponse -> Bool)
-> (CancelJobResponse -> CancelJobResponse -> Bool)
-> Eq CancelJobResponse
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]
(Int -> ReadS CancelJobResponse)
-> ReadS [CancelJobResponse]
-> ReadPrec CancelJobResponse
-> ReadPrec [CancelJobResponse]
-> Read 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
(Int -> CancelJobResponse -> ShowS)
-> (CancelJobResponse -> String)
-> ([CancelJobResponse] -> ShowS)
-> Show CancelJobResponse
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. CancelJobResponse -> Rep CancelJobResponse x)
-> (forall x. Rep CancelJobResponse x -> CancelJobResponse)
-> Generic CancelJobResponse
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)
newCancelJobResponse ::
Prelude.Int ->
CancelJobResponse
newCancelJobResponse :: Int -> CancelJobResponse
newCancelJobResponse Int
pHttpStatus_ =
CancelJobResponse' :: Maybe Text -> Maybe Text -> Maybe Text -> Int -> CancelJobResponse
CancelJobResponse'
{ $sel:jobId:CancelJobResponse' :: Maybe Text
jobId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:jobArn:CancelJobResponse' :: Maybe Text
jobArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:description:CancelJobResponse' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CancelJobResponse' :: Int
httpStatus = Int
pHttpStatus_
}
cancelJobResponse_jobId :: Lens.Lens' CancelJobResponse (Prelude.Maybe Prelude.Text)
cancelJobResponse_jobId :: (Maybe Text -> f (Maybe Text))
-> CancelJobResponse -> f CancelJobResponse
cancelJobResponse_jobId = (CancelJobResponse -> Maybe Text)
-> (CancelJobResponse -> Maybe Text -> CancelJobResponse)
-> Lens
CancelJobResponse CancelJobResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelJobResponse' {Maybe Text
jobId :: Maybe Text
$sel:jobId:CancelJobResponse' :: CancelJobResponse -> Maybe Text
jobId} -> Maybe Text
jobId) (\s :: CancelJobResponse
s@CancelJobResponse' {} Maybe Text
a -> CancelJobResponse
s {$sel:jobId:CancelJobResponse' :: Maybe Text
jobId = Maybe Text
a} :: CancelJobResponse)
cancelJobResponse_jobArn :: Lens.Lens' CancelJobResponse (Prelude.Maybe Prelude.Text)
cancelJobResponse_jobArn :: (Maybe Text -> f (Maybe Text))
-> CancelJobResponse -> f CancelJobResponse
cancelJobResponse_jobArn = (CancelJobResponse -> Maybe Text)
-> (CancelJobResponse -> Maybe Text -> CancelJobResponse)
-> Lens
CancelJobResponse CancelJobResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelJobResponse' {Maybe Text
jobArn :: Maybe Text
$sel:jobArn:CancelJobResponse' :: CancelJobResponse -> Maybe Text
jobArn} -> Maybe Text
jobArn) (\s :: CancelJobResponse
s@CancelJobResponse' {} Maybe Text
a -> CancelJobResponse
s {$sel:jobArn:CancelJobResponse' :: Maybe Text
jobArn = Maybe Text
a} :: CancelJobResponse)
cancelJobResponse_description :: Lens.Lens' CancelJobResponse (Prelude.Maybe Prelude.Text)
cancelJobResponse_description :: (Maybe Text -> f (Maybe Text))
-> CancelJobResponse -> f CancelJobResponse
cancelJobResponse_description = (CancelJobResponse -> Maybe Text)
-> (CancelJobResponse -> Maybe Text -> CancelJobResponse)
-> Lens
CancelJobResponse CancelJobResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelJobResponse' {Maybe Text
description :: Maybe Text
$sel:description:CancelJobResponse' :: CancelJobResponse -> Maybe Text
description} -> Maybe Text
description) (\s :: CancelJobResponse
s@CancelJobResponse' {} Maybe Text
a -> CancelJobResponse
s {$sel:description:CancelJobResponse' :: Maybe Text
description = Maybe Text
a} :: CancelJobResponse)
cancelJobResponse_httpStatus :: Lens.Lens' CancelJobResponse Prelude.Int
cancelJobResponse_httpStatus :: (Int -> f Int) -> CancelJobResponse -> f CancelJobResponse
cancelJobResponse_httpStatus = (CancelJobResponse -> Int)
-> (CancelJobResponse -> Int -> CancelJobResponse)
-> Lens CancelJobResponse CancelJobResponse Int Int
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