{-# 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.MechanicalTurk.CreateWorkerBlock
(
CreateWorkerBlock (..),
newCreateWorkerBlock,
createWorkerBlock_workerId,
createWorkerBlock_reason,
CreateWorkerBlockResponse (..),
newCreateWorkerBlockResponse,
createWorkerBlockResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MechanicalTurk.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateWorkerBlock = CreateWorkerBlock'
{
CreateWorkerBlock -> Text
workerId :: Prelude.Text,
CreateWorkerBlock -> Text
reason :: Prelude.Text
}
deriving (CreateWorkerBlock -> CreateWorkerBlock -> Bool
(CreateWorkerBlock -> CreateWorkerBlock -> Bool)
-> (CreateWorkerBlock -> CreateWorkerBlock -> Bool)
-> Eq CreateWorkerBlock
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateWorkerBlock -> CreateWorkerBlock -> Bool
$c/= :: CreateWorkerBlock -> CreateWorkerBlock -> Bool
== :: CreateWorkerBlock -> CreateWorkerBlock -> Bool
$c== :: CreateWorkerBlock -> CreateWorkerBlock -> Bool
Prelude.Eq, ReadPrec [CreateWorkerBlock]
ReadPrec CreateWorkerBlock
Int -> ReadS CreateWorkerBlock
ReadS [CreateWorkerBlock]
(Int -> ReadS CreateWorkerBlock)
-> ReadS [CreateWorkerBlock]
-> ReadPrec CreateWorkerBlock
-> ReadPrec [CreateWorkerBlock]
-> Read CreateWorkerBlock
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateWorkerBlock]
$creadListPrec :: ReadPrec [CreateWorkerBlock]
readPrec :: ReadPrec CreateWorkerBlock
$creadPrec :: ReadPrec CreateWorkerBlock
readList :: ReadS [CreateWorkerBlock]
$creadList :: ReadS [CreateWorkerBlock]
readsPrec :: Int -> ReadS CreateWorkerBlock
$creadsPrec :: Int -> ReadS CreateWorkerBlock
Prelude.Read, Int -> CreateWorkerBlock -> ShowS
[CreateWorkerBlock] -> ShowS
CreateWorkerBlock -> String
(Int -> CreateWorkerBlock -> ShowS)
-> (CreateWorkerBlock -> String)
-> ([CreateWorkerBlock] -> ShowS)
-> Show CreateWorkerBlock
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateWorkerBlock] -> ShowS
$cshowList :: [CreateWorkerBlock] -> ShowS
show :: CreateWorkerBlock -> String
$cshow :: CreateWorkerBlock -> String
showsPrec :: Int -> CreateWorkerBlock -> ShowS
$cshowsPrec :: Int -> CreateWorkerBlock -> ShowS
Prelude.Show, (forall x. CreateWorkerBlock -> Rep CreateWorkerBlock x)
-> (forall x. Rep CreateWorkerBlock x -> CreateWorkerBlock)
-> Generic CreateWorkerBlock
forall x. Rep CreateWorkerBlock x -> CreateWorkerBlock
forall x. CreateWorkerBlock -> Rep CreateWorkerBlock x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateWorkerBlock x -> CreateWorkerBlock
$cfrom :: forall x. CreateWorkerBlock -> Rep CreateWorkerBlock x
Prelude.Generic)
newCreateWorkerBlock ::
Prelude.Text ->
Prelude.Text ->
CreateWorkerBlock
newCreateWorkerBlock :: Text -> Text -> CreateWorkerBlock
newCreateWorkerBlock Text
pWorkerId_ Text
pReason_ =
CreateWorkerBlock' :: Text -> Text -> CreateWorkerBlock
CreateWorkerBlock'
{ $sel:workerId:CreateWorkerBlock' :: Text
workerId = Text
pWorkerId_,
$sel:reason:CreateWorkerBlock' :: Text
reason = Text
pReason_
}
createWorkerBlock_workerId :: Lens.Lens' CreateWorkerBlock Prelude.Text
createWorkerBlock_workerId :: (Text -> f Text) -> CreateWorkerBlock -> f CreateWorkerBlock
createWorkerBlock_workerId = (CreateWorkerBlock -> Text)
-> (CreateWorkerBlock -> Text -> CreateWorkerBlock)
-> Lens CreateWorkerBlock CreateWorkerBlock Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateWorkerBlock' {Text
workerId :: Text
$sel:workerId:CreateWorkerBlock' :: CreateWorkerBlock -> Text
workerId} -> Text
workerId) (\s :: CreateWorkerBlock
s@CreateWorkerBlock' {} Text
a -> CreateWorkerBlock
s {$sel:workerId:CreateWorkerBlock' :: Text
workerId = Text
a} :: CreateWorkerBlock)
createWorkerBlock_reason :: Lens.Lens' CreateWorkerBlock Prelude.Text
createWorkerBlock_reason :: (Text -> f Text) -> CreateWorkerBlock -> f CreateWorkerBlock
createWorkerBlock_reason = (CreateWorkerBlock -> Text)
-> (CreateWorkerBlock -> Text -> CreateWorkerBlock)
-> Lens CreateWorkerBlock CreateWorkerBlock Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateWorkerBlock' {Text
reason :: Text
$sel:reason:CreateWorkerBlock' :: CreateWorkerBlock -> Text
reason} -> Text
reason) (\s :: CreateWorkerBlock
s@CreateWorkerBlock' {} Text
a -> CreateWorkerBlock
s {$sel:reason:CreateWorkerBlock' :: Text
reason = Text
a} :: CreateWorkerBlock)
instance Core.AWSRequest CreateWorkerBlock where
type
AWSResponse CreateWorkerBlock =
CreateWorkerBlockResponse
request :: CreateWorkerBlock -> Request CreateWorkerBlock
request = Service -> CreateWorkerBlock -> Request CreateWorkerBlock
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateWorkerBlock
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateWorkerBlock)))
response =
(Int
-> ResponseHeaders
-> ()
-> Either String (AWSResponse CreateWorkerBlock))
-> Logger
-> Service
-> Proxy CreateWorkerBlock
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateWorkerBlock)))
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 -> CreateWorkerBlockResponse
CreateWorkerBlockResponse'
(Int -> CreateWorkerBlockResponse)
-> Either String Int -> Either String CreateWorkerBlockResponse
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 CreateWorkerBlock
instance Prelude.NFData CreateWorkerBlock
instance Core.ToHeaders CreateWorkerBlock where
toHeaders :: CreateWorkerBlock -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateWorkerBlock -> 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
"MTurkRequesterServiceV20170117.CreateWorkerBlock" ::
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 CreateWorkerBlock where
toJSON :: CreateWorkerBlock -> Value
toJSON CreateWorkerBlock' {Text
reason :: Text
workerId :: Text
$sel:reason:CreateWorkerBlock' :: CreateWorkerBlock -> Text
$sel:workerId:CreateWorkerBlock' :: CreateWorkerBlock -> 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
"WorkerId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
workerId),
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 CreateWorkerBlock where
toPath :: CreateWorkerBlock -> ByteString
toPath = ByteString -> CreateWorkerBlock -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateWorkerBlock where
toQuery :: CreateWorkerBlock -> QueryString
toQuery = QueryString -> CreateWorkerBlock -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateWorkerBlockResponse = CreateWorkerBlockResponse'
{
CreateWorkerBlockResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateWorkerBlockResponse -> CreateWorkerBlockResponse -> Bool
(CreateWorkerBlockResponse -> CreateWorkerBlockResponse -> Bool)
-> (CreateWorkerBlockResponse -> CreateWorkerBlockResponse -> Bool)
-> Eq CreateWorkerBlockResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateWorkerBlockResponse -> CreateWorkerBlockResponse -> Bool
$c/= :: CreateWorkerBlockResponse -> CreateWorkerBlockResponse -> Bool
== :: CreateWorkerBlockResponse -> CreateWorkerBlockResponse -> Bool
$c== :: CreateWorkerBlockResponse -> CreateWorkerBlockResponse -> Bool
Prelude.Eq, ReadPrec [CreateWorkerBlockResponse]
ReadPrec CreateWorkerBlockResponse
Int -> ReadS CreateWorkerBlockResponse
ReadS [CreateWorkerBlockResponse]
(Int -> ReadS CreateWorkerBlockResponse)
-> ReadS [CreateWorkerBlockResponse]
-> ReadPrec CreateWorkerBlockResponse
-> ReadPrec [CreateWorkerBlockResponse]
-> Read CreateWorkerBlockResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateWorkerBlockResponse]
$creadListPrec :: ReadPrec [CreateWorkerBlockResponse]
readPrec :: ReadPrec CreateWorkerBlockResponse
$creadPrec :: ReadPrec CreateWorkerBlockResponse
readList :: ReadS [CreateWorkerBlockResponse]
$creadList :: ReadS [CreateWorkerBlockResponse]
readsPrec :: Int -> ReadS CreateWorkerBlockResponse
$creadsPrec :: Int -> ReadS CreateWorkerBlockResponse
Prelude.Read, Int -> CreateWorkerBlockResponse -> ShowS
[CreateWorkerBlockResponse] -> ShowS
CreateWorkerBlockResponse -> String
(Int -> CreateWorkerBlockResponse -> ShowS)
-> (CreateWorkerBlockResponse -> String)
-> ([CreateWorkerBlockResponse] -> ShowS)
-> Show CreateWorkerBlockResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateWorkerBlockResponse] -> ShowS
$cshowList :: [CreateWorkerBlockResponse] -> ShowS
show :: CreateWorkerBlockResponse -> String
$cshow :: CreateWorkerBlockResponse -> String
showsPrec :: Int -> CreateWorkerBlockResponse -> ShowS
$cshowsPrec :: Int -> CreateWorkerBlockResponse -> ShowS
Prelude.Show, (forall x.
CreateWorkerBlockResponse -> Rep CreateWorkerBlockResponse x)
-> (forall x.
Rep CreateWorkerBlockResponse x -> CreateWorkerBlockResponse)
-> Generic CreateWorkerBlockResponse
forall x.
Rep CreateWorkerBlockResponse x -> CreateWorkerBlockResponse
forall x.
CreateWorkerBlockResponse -> Rep CreateWorkerBlockResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateWorkerBlockResponse x -> CreateWorkerBlockResponse
$cfrom :: forall x.
CreateWorkerBlockResponse -> Rep CreateWorkerBlockResponse x
Prelude.Generic)
newCreateWorkerBlockResponse ::
Prelude.Int ->
CreateWorkerBlockResponse
newCreateWorkerBlockResponse :: Int -> CreateWorkerBlockResponse
newCreateWorkerBlockResponse Int
pHttpStatus_ =
CreateWorkerBlockResponse' :: Int -> CreateWorkerBlockResponse
CreateWorkerBlockResponse'
{ $sel:httpStatus:CreateWorkerBlockResponse' :: Int
httpStatus =
Int
pHttpStatus_
}
createWorkerBlockResponse_httpStatus :: Lens.Lens' CreateWorkerBlockResponse Prelude.Int
createWorkerBlockResponse_httpStatus :: (Int -> f Int)
-> CreateWorkerBlockResponse -> f CreateWorkerBlockResponse
createWorkerBlockResponse_httpStatus = (CreateWorkerBlockResponse -> Int)
-> (CreateWorkerBlockResponse -> Int -> CreateWorkerBlockResponse)
-> Lens CreateWorkerBlockResponse CreateWorkerBlockResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateWorkerBlockResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateWorkerBlockResponse' :: CreateWorkerBlockResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateWorkerBlockResponse
s@CreateWorkerBlockResponse' {} Int
a -> CreateWorkerBlockResponse
s {$sel:httpStatus:CreateWorkerBlockResponse' :: Int
httpStatus = Int
a} :: CreateWorkerBlockResponse)
instance Prelude.NFData CreateWorkerBlockResponse