{-# 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.DataPipeline.PollForTask
(
PollForTask (..),
newPollForTask,
pollForTask_hostname,
pollForTask_instanceIdentity,
pollForTask_workerGroup,
PollForTaskResponse (..),
newPollForTaskResponse,
pollForTaskResponse_taskObject,
pollForTaskResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import Amazonka.DataPipeline.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 PollForTask = PollForTask'
{
PollForTask -> Maybe Text
hostname :: Prelude.Maybe Prelude.Text,
PollForTask -> Maybe InstanceIdentity
instanceIdentity :: Prelude.Maybe InstanceIdentity,
PollForTask -> Text
workerGroup :: Prelude.Text
}
deriving (PollForTask -> PollForTask -> Bool
(PollForTask -> PollForTask -> Bool)
-> (PollForTask -> PollForTask -> Bool) -> Eq PollForTask
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PollForTask -> PollForTask -> Bool
$c/= :: PollForTask -> PollForTask -> Bool
== :: PollForTask -> PollForTask -> Bool
$c== :: PollForTask -> PollForTask -> Bool
Prelude.Eq, ReadPrec [PollForTask]
ReadPrec PollForTask
Int -> ReadS PollForTask
ReadS [PollForTask]
(Int -> ReadS PollForTask)
-> ReadS [PollForTask]
-> ReadPrec PollForTask
-> ReadPrec [PollForTask]
-> Read PollForTask
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PollForTask]
$creadListPrec :: ReadPrec [PollForTask]
readPrec :: ReadPrec PollForTask
$creadPrec :: ReadPrec PollForTask
readList :: ReadS [PollForTask]
$creadList :: ReadS [PollForTask]
readsPrec :: Int -> ReadS PollForTask
$creadsPrec :: Int -> ReadS PollForTask
Prelude.Read, Int -> PollForTask -> ShowS
[PollForTask] -> ShowS
PollForTask -> String
(Int -> PollForTask -> ShowS)
-> (PollForTask -> String)
-> ([PollForTask] -> ShowS)
-> Show PollForTask
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PollForTask] -> ShowS
$cshowList :: [PollForTask] -> ShowS
show :: PollForTask -> String
$cshow :: PollForTask -> String
showsPrec :: Int -> PollForTask -> ShowS
$cshowsPrec :: Int -> PollForTask -> ShowS
Prelude.Show, (forall x. PollForTask -> Rep PollForTask x)
-> (forall x. Rep PollForTask x -> PollForTask)
-> Generic PollForTask
forall x. Rep PollForTask x -> PollForTask
forall x. PollForTask -> Rep PollForTask x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PollForTask x -> PollForTask
$cfrom :: forall x. PollForTask -> Rep PollForTask x
Prelude.Generic)
newPollForTask ::
Prelude.Text ->
PollForTask
newPollForTask :: Text -> PollForTask
newPollForTask Text
pWorkerGroup_ =
PollForTask' :: Maybe Text -> Maybe InstanceIdentity -> Text -> PollForTask
PollForTask'
{ $sel:hostname:PollForTask' :: Maybe Text
hostname = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:instanceIdentity:PollForTask' :: Maybe InstanceIdentity
instanceIdentity = Maybe InstanceIdentity
forall a. Maybe a
Prelude.Nothing,
$sel:workerGroup:PollForTask' :: Text
workerGroup = Text
pWorkerGroup_
}
pollForTask_hostname :: Lens.Lens' PollForTask (Prelude.Maybe Prelude.Text)
pollForTask_hostname :: (Maybe Text -> f (Maybe Text)) -> PollForTask -> f PollForTask
pollForTask_hostname = (PollForTask -> Maybe Text)
-> (PollForTask -> Maybe Text -> PollForTask)
-> Lens PollForTask PollForTask (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PollForTask' {Maybe Text
hostname :: Maybe Text
$sel:hostname:PollForTask' :: PollForTask -> Maybe Text
hostname} -> Maybe Text
hostname) (\s :: PollForTask
s@PollForTask' {} Maybe Text
a -> PollForTask
s {$sel:hostname:PollForTask' :: Maybe Text
hostname = Maybe Text
a} :: PollForTask)
pollForTask_instanceIdentity :: Lens.Lens' PollForTask (Prelude.Maybe InstanceIdentity)
pollForTask_instanceIdentity :: (Maybe InstanceIdentity -> f (Maybe InstanceIdentity))
-> PollForTask -> f PollForTask
pollForTask_instanceIdentity = (PollForTask -> Maybe InstanceIdentity)
-> (PollForTask -> Maybe InstanceIdentity -> PollForTask)
-> Lens
PollForTask
PollForTask
(Maybe InstanceIdentity)
(Maybe InstanceIdentity)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PollForTask' {Maybe InstanceIdentity
instanceIdentity :: Maybe InstanceIdentity
$sel:instanceIdentity:PollForTask' :: PollForTask -> Maybe InstanceIdentity
instanceIdentity} -> Maybe InstanceIdentity
instanceIdentity) (\s :: PollForTask
s@PollForTask' {} Maybe InstanceIdentity
a -> PollForTask
s {$sel:instanceIdentity:PollForTask' :: Maybe InstanceIdentity
instanceIdentity = Maybe InstanceIdentity
a} :: PollForTask)
pollForTask_workerGroup :: Lens.Lens' PollForTask Prelude.Text
pollForTask_workerGroup :: (Text -> f Text) -> PollForTask -> f PollForTask
pollForTask_workerGroup = (PollForTask -> Text)
-> (PollForTask -> Text -> PollForTask)
-> Lens PollForTask PollForTask Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PollForTask' {Text
workerGroup :: Text
$sel:workerGroup:PollForTask' :: PollForTask -> Text
workerGroup} -> Text
workerGroup) (\s :: PollForTask
s@PollForTask' {} Text
a -> PollForTask
s {$sel:workerGroup:PollForTask' :: Text
workerGroup = Text
a} :: PollForTask)
instance Core.AWSRequest PollForTask where
type AWSResponse PollForTask = PollForTaskResponse
request :: PollForTask -> Request PollForTask
request = Service -> PollForTask -> Request PollForTask
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy PollForTask
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PollForTask)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse PollForTask))
-> Logger
-> Service
-> Proxy PollForTask
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PollForTask)))
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 TaskObject -> Int -> PollForTaskResponse
PollForTaskResponse'
(Maybe TaskObject -> Int -> PollForTaskResponse)
-> Either String (Maybe TaskObject)
-> Either String (Int -> PollForTaskResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe TaskObject)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"taskObject")
Either String (Int -> PollForTaskResponse)
-> Either String Int -> Either String PollForTaskResponse
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 PollForTask
instance Prelude.NFData PollForTask
instance Core.ToHeaders PollForTask where
toHeaders :: PollForTask -> ResponseHeaders
toHeaders =
ResponseHeaders -> PollForTask -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"DataPipeline.PollForTask" :: Prelude.ByteString),
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 PollForTask where
toJSON :: PollForTask -> Value
toJSON PollForTask' {Maybe Text
Maybe InstanceIdentity
Text
workerGroup :: Text
instanceIdentity :: Maybe InstanceIdentity
hostname :: Maybe Text
$sel:workerGroup:PollForTask' :: PollForTask -> Text
$sel:instanceIdentity:PollForTask' :: PollForTask -> Maybe InstanceIdentity
$sel:hostname:PollForTask' :: PollForTask -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"hostname" 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
hostname,
(Text
"instanceIdentity" Text -> InstanceIdentity -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(InstanceIdentity -> Pair) -> Maybe InstanceIdentity -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InstanceIdentity
instanceIdentity,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"workerGroup" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
workerGroup)
]
)
instance Core.ToPath PollForTask where
toPath :: PollForTask -> ByteString
toPath = ByteString -> PollForTask -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery PollForTask where
toQuery :: PollForTask -> QueryString
toQuery = QueryString -> PollForTask -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data PollForTaskResponse = PollForTaskResponse'
{
PollForTaskResponse -> Maybe TaskObject
taskObject :: Prelude.Maybe TaskObject,
PollForTaskResponse -> Int
httpStatus :: Prelude.Int
}
deriving (PollForTaskResponse -> PollForTaskResponse -> Bool
(PollForTaskResponse -> PollForTaskResponse -> Bool)
-> (PollForTaskResponse -> PollForTaskResponse -> Bool)
-> Eq PollForTaskResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PollForTaskResponse -> PollForTaskResponse -> Bool
$c/= :: PollForTaskResponse -> PollForTaskResponse -> Bool
== :: PollForTaskResponse -> PollForTaskResponse -> Bool
$c== :: PollForTaskResponse -> PollForTaskResponse -> Bool
Prelude.Eq, ReadPrec [PollForTaskResponse]
ReadPrec PollForTaskResponse
Int -> ReadS PollForTaskResponse
ReadS [PollForTaskResponse]
(Int -> ReadS PollForTaskResponse)
-> ReadS [PollForTaskResponse]
-> ReadPrec PollForTaskResponse
-> ReadPrec [PollForTaskResponse]
-> Read PollForTaskResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PollForTaskResponse]
$creadListPrec :: ReadPrec [PollForTaskResponse]
readPrec :: ReadPrec PollForTaskResponse
$creadPrec :: ReadPrec PollForTaskResponse
readList :: ReadS [PollForTaskResponse]
$creadList :: ReadS [PollForTaskResponse]
readsPrec :: Int -> ReadS PollForTaskResponse
$creadsPrec :: Int -> ReadS PollForTaskResponse
Prelude.Read, Int -> PollForTaskResponse -> ShowS
[PollForTaskResponse] -> ShowS
PollForTaskResponse -> String
(Int -> PollForTaskResponse -> ShowS)
-> (PollForTaskResponse -> String)
-> ([PollForTaskResponse] -> ShowS)
-> Show PollForTaskResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PollForTaskResponse] -> ShowS
$cshowList :: [PollForTaskResponse] -> ShowS
show :: PollForTaskResponse -> String
$cshow :: PollForTaskResponse -> String
showsPrec :: Int -> PollForTaskResponse -> ShowS
$cshowsPrec :: Int -> PollForTaskResponse -> ShowS
Prelude.Show, (forall x. PollForTaskResponse -> Rep PollForTaskResponse x)
-> (forall x. Rep PollForTaskResponse x -> PollForTaskResponse)
-> Generic PollForTaskResponse
forall x. Rep PollForTaskResponse x -> PollForTaskResponse
forall x. PollForTaskResponse -> Rep PollForTaskResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PollForTaskResponse x -> PollForTaskResponse
$cfrom :: forall x. PollForTaskResponse -> Rep PollForTaskResponse x
Prelude.Generic)
newPollForTaskResponse ::
Prelude.Int ->
PollForTaskResponse
newPollForTaskResponse :: Int -> PollForTaskResponse
newPollForTaskResponse Int
pHttpStatus_ =
PollForTaskResponse' :: Maybe TaskObject -> Int -> PollForTaskResponse
PollForTaskResponse'
{ $sel:taskObject:PollForTaskResponse' :: Maybe TaskObject
taskObject = Maybe TaskObject
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:PollForTaskResponse' :: Int
httpStatus = Int
pHttpStatus_
}
pollForTaskResponse_taskObject :: Lens.Lens' PollForTaskResponse (Prelude.Maybe TaskObject)
pollForTaskResponse_taskObject :: (Maybe TaskObject -> f (Maybe TaskObject))
-> PollForTaskResponse -> f PollForTaskResponse
pollForTaskResponse_taskObject = (PollForTaskResponse -> Maybe TaskObject)
-> (PollForTaskResponse -> Maybe TaskObject -> PollForTaskResponse)
-> Lens
PollForTaskResponse
PollForTaskResponse
(Maybe TaskObject)
(Maybe TaskObject)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PollForTaskResponse' {Maybe TaskObject
taskObject :: Maybe TaskObject
$sel:taskObject:PollForTaskResponse' :: PollForTaskResponse -> Maybe TaskObject
taskObject} -> Maybe TaskObject
taskObject) (\s :: PollForTaskResponse
s@PollForTaskResponse' {} Maybe TaskObject
a -> PollForTaskResponse
s {$sel:taskObject:PollForTaskResponse' :: Maybe TaskObject
taskObject = Maybe TaskObject
a} :: PollForTaskResponse)
pollForTaskResponse_httpStatus :: Lens.Lens' PollForTaskResponse Prelude.Int
pollForTaskResponse_httpStatus :: (Int -> f Int) -> PollForTaskResponse -> f PollForTaskResponse
pollForTaskResponse_httpStatus = (PollForTaskResponse -> Int)
-> (PollForTaskResponse -> Int -> PollForTaskResponse)
-> Lens PollForTaskResponse PollForTaskResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PollForTaskResponse' {Int
httpStatus :: Int
$sel:httpStatus:PollForTaskResponse' :: PollForTaskResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PollForTaskResponse
s@PollForTaskResponse' {} Int
a -> PollForTaskResponse
s {$sel:httpStatus:PollForTaskResponse' :: Int
httpStatus = Int
a} :: PollForTaskResponse)
instance Prelude.NFData PollForTaskResponse