{-# 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.ListWorkerBlocks
(
ListWorkerBlocks (..),
newListWorkerBlocks,
listWorkerBlocks_maxResults,
listWorkerBlocks_nextToken,
ListWorkerBlocksResponse (..),
newListWorkerBlocksResponse,
listWorkerBlocksResponse_nextToken,
listWorkerBlocksResponse_numResults,
listWorkerBlocksResponse_workerBlocks,
listWorkerBlocksResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MechanicalTurk.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data ListWorkerBlocks = ListWorkerBlocks'
{ ListWorkerBlocks -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
ListWorkerBlocks -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
}
deriving (ListWorkerBlocks -> ListWorkerBlocks -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListWorkerBlocks -> ListWorkerBlocks -> Bool
$c/= :: ListWorkerBlocks -> ListWorkerBlocks -> Bool
== :: ListWorkerBlocks -> ListWorkerBlocks -> Bool
$c== :: ListWorkerBlocks -> ListWorkerBlocks -> Bool
Prelude.Eq, ReadPrec [ListWorkerBlocks]
ReadPrec ListWorkerBlocks
Int -> ReadS ListWorkerBlocks
ReadS [ListWorkerBlocks]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListWorkerBlocks]
$creadListPrec :: ReadPrec [ListWorkerBlocks]
readPrec :: ReadPrec ListWorkerBlocks
$creadPrec :: ReadPrec ListWorkerBlocks
readList :: ReadS [ListWorkerBlocks]
$creadList :: ReadS [ListWorkerBlocks]
readsPrec :: Int -> ReadS ListWorkerBlocks
$creadsPrec :: Int -> ReadS ListWorkerBlocks
Prelude.Read, Int -> ListWorkerBlocks -> ShowS
[ListWorkerBlocks] -> ShowS
ListWorkerBlocks -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListWorkerBlocks] -> ShowS
$cshowList :: [ListWorkerBlocks] -> ShowS
show :: ListWorkerBlocks -> String
$cshow :: ListWorkerBlocks -> String
showsPrec :: Int -> ListWorkerBlocks -> ShowS
$cshowsPrec :: Int -> ListWorkerBlocks -> ShowS
Prelude.Show, forall x. Rep ListWorkerBlocks x -> ListWorkerBlocks
forall x. ListWorkerBlocks -> Rep ListWorkerBlocks x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListWorkerBlocks x -> ListWorkerBlocks
$cfrom :: forall x. ListWorkerBlocks -> Rep ListWorkerBlocks x
Prelude.Generic)
newListWorkerBlocks ::
ListWorkerBlocks
newListWorkerBlocks :: ListWorkerBlocks
newListWorkerBlocks =
ListWorkerBlocks'
{ $sel:maxResults:ListWorkerBlocks' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
$sel:nextToken:ListWorkerBlocks' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
}
listWorkerBlocks_maxResults :: Lens.Lens' ListWorkerBlocks (Prelude.Maybe Prelude.Natural)
listWorkerBlocks_maxResults :: Lens' ListWorkerBlocks (Maybe Natural)
listWorkerBlocks_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWorkerBlocks' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListWorkerBlocks' :: ListWorkerBlocks -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListWorkerBlocks
s@ListWorkerBlocks' {} Maybe Natural
a -> ListWorkerBlocks
s {$sel:maxResults:ListWorkerBlocks' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListWorkerBlocks)
listWorkerBlocks_nextToken :: Lens.Lens' ListWorkerBlocks (Prelude.Maybe Prelude.Text)
listWorkerBlocks_nextToken :: Lens' ListWorkerBlocks (Maybe Text)
listWorkerBlocks_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWorkerBlocks' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListWorkerBlocks' :: ListWorkerBlocks -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListWorkerBlocks
s@ListWorkerBlocks' {} Maybe Text
a -> ListWorkerBlocks
s {$sel:nextToken:ListWorkerBlocks' :: Maybe Text
nextToken = Maybe Text
a} :: ListWorkerBlocks)
instance Core.AWSPager ListWorkerBlocks where
page :: ListWorkerBlocks
-> AWSResponse ListWorkerBlocks -> Maybe ListWorkerBlocks
page ListWorkerBlocks
rq AWSResponse ListWorkerBlocks
rs
| forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListWorkerBlocks
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListWorkerBlocksResponse (Maybe Text)
listWorkerBlocksResponse_nextToken
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
forall a. Maybe a
Prelude.Nothing
| forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListWorkerBlocks
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListWorkerBlocksResponse (Maybe [WorkerBlock])
listWorkerBlocksResponse_workerBlocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
forall a. a -> Maybe a
Prelude.Just
forall a b. (a -> b) -> a -> b
Prelude.$ ListWorkerBlocks
rq
forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListWorkerBlocks (Maybe Text)
listWorkerBlocks_nextToken
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListWorkerBlocks
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListWorkerBlocksResponse (Maybe Text)
listWorkerBlocksResponse_nextToken
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
instance Core.AWSRequest ListWorkerBlocks where
type
AWSResponse ListWorkerBlocks =
ListWorkerBlocksResponse
request :: (Service -> Service)
-> ListWorkerBlocks -> Request ListWorkerBlocks
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 ListWorkerBlocks
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListWorkerBlocks)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Text
-> Maybe Int
-> Maybe [WorkerBlock]
-> Int
-> ListWorkerBlocksResponse
ListWorkerBlocksResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"NextToken")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"NumResults")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"WorkerBlocks" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
forall (f :: * -> *) a b. Applicative f => 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 ListWorkerBlocks where
hashWithSalt :: Int -> ListWorkerBlocks -> Int
hashWithSalt Int
_salt ListWorkerBlocks' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListWorkerBlocks' :: ListWorkerBlocks -> Maybe Text
$sel:maxResults:ListWorkerBlocks' :: ListWorkerBlocks -> Maybe Natural
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
instance Prelude.NFData ListWorkerBlocks where
rnf :: ListWorkerBlocks -> ()
rnf ListWorkerBlocks' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListWorkerBlocks' :: ListWorkerBlocks -> Maybe Text
$sel:maxResults:ListWorkerBlocks' :: ListWorkerBlocks -> Maybe Natural
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
instance Data.ToHeaders ListWorkerBlocks where
toHeaders :: ListWorkerBlocks -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"MTurkRequesterServiceV20170117.ListWorkerBlocks" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON ListWorkerBlocks where
toJSON :: ListWorkerBlocks -> Value
toJSON ListWorkerBlocks' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListWorkerBlocks' :: ListWorkerBlocks -> Maybe Text
$sel:maxResults:ListWorkerBlocks' :: ListWorkerBlocks -> Maybe Natural
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"MaxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
(Key
"NextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken
]
)
instance Data.ToPath ListWorkerBlocks where
toPath :: ListWorkerBlocks -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery ListWorkerBlocks where
toQuery :: ListWorkerBlocks -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data ListWorkerBlocksResponse = ListWorkerBlocksResponse'
{ ListWorkerBlocksResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListWorkerBlocksResponse -> Maybe Int
numResults :: Prelude.Maybe Prelude.Int,
ListWorkerBlocksResponse -> Maybe [WorkerBlock]
workerBlocks :: Prelude.Maybe [WorkerBlock],
ListWorkerBlocksResponse -> Int
httpStatus :: Prelude.Int
}
deriving (ListWorkerBlocksResponse -> ListWorkerBlocksResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListWorkerBlocksResponse -> ListWorkerBlocksResponse -> Bool
$c/= :: ListWorkerBlocksResponse -> ListWorkerBlocksResponse -> Bool
== :: ListWorkerBlocksResponse -> ListWorkerBlocksResponse -> Bool
$c== :: ListWorkerBlocksResponse -> ListWorkerBlocksResponse -> Bool
Prelude.Eq, ReadPrec [ListWorkerBlocksResponse]
ReadPrec ListWorkerBlocksResponse
Int -> ReadS ListWorkerBlocksResponse
ReadS [ListWorkerBlocksResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListWorkerBlocksResponse]
$creadListPrec :: ReadPrec [ListWorkerBlocksResponse]
readPrec :: ReadPrec ListWorkerBlocksResponse
$creadPrec :: ReadPrec ListWorkerBlocksResponse
readList :: ReadS [ListWorkerBlocksResponse]
$creadList :: ReadS [ListWorkerBlocksResponse]
readsPrec :: Int -> ReadS ListWorkerBlocksResponse
$creadsPrec :: Int -> ReadS ListWorkerBlocksResponse
Prelude.Read, Int -> ListWorkerBlocksResponse -> ShowS
[ListWorkerBlocksResponse] -> ShowS
ListWorkerBlocksResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListWorkerBlocksResponse] -> ShowS
$cshowList :: [ListWorkerBlocksResponse] -> ShowS
show :: ListWorkerBlocksResponse -> String
$cshow :: ListWorkerBlocksResponse -> String
showsPrec :: Int -> ListWorkerBlocksResponse -> ShowS
$cshowsPrec :: Int -> ListWorkerBlocksResponse -> ShowS
Prelude.Show, forall x.
Rep ListWorkerBlocksResponse x -> ListWorkerBlocksResponse
forall x.
ListWorkerBlocksResponse -> Rep ListWorkerBlocksResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListWorkerBlocksResponse x -> ListWorkerBlocksResponse
$cfrom :: forall x.
ListWorkerBlocksResponse -> Rep ListWorkerBlocksResponse x
Prelude.Generic)
newListWorkerBlocksResponse ::
Prelude.Int ->
ListWorkerBlocksResponse
newListWorkerBlocksResponse :: Int -> ListWorkerBlocksResponse
newListWorkerBlocksResponse Int
pHttpStatus_ =
ListWorkerBlocksResponse'
{ $sel:nextToken:ListWorkerBlocksResponse' :: Maybe Text
nextToken =
forall a. Maybe a
Prelude.Nothing,
$sel:numResults:ListWorkerBlocksResponse' :: Maybe Int
numResults = forall a. Maybe a
Prelude.Nothing,
$sel:workerBlocks:ListWorkerBlocksResponse' :: Maybe [WorkerBlock]
workerBlocks = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:ListWorkerBlocksResponse' :: Int
httpStatus = Int
pHttpStatus_
}
listWorkerBlocksResponse_nextToken :: Lens.Lens' ListWorkerBlocksResponse (Prelude.Maybe Prelude.Text)
listWorkerBlocksResponse_nextToken :: Lens' ListWorkerBlocksResponse (Maybe Text)
listWorkerBlocksResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWorkerBlocksResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListWorkerBlocksResponse' :: ListWorkerBlocksResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListWorkerBlocksResponse
s@ListWorkerBlocksResponse' {} Maybe Text
a -> ListWorkerBlocksResponse
s {$sel:nextToken:ListWorkerBlocksResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListWorkerBlocksResponse)
listWorkerBlocksResponse_numResults :: Lens.Lens' ListWorkerBlocksResponse (Prelude.Maybe Prelude.Int)
listWorkerBlocksResponse_numResults :: Lens' ListWorkerBlocksResponse (Maybe Int)
listWorkerBlocksResponse_numResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWorkerBlocksResponse' {Maybe Int
numResults :: Maybe Int
$sel:numResults:ListWorkerBlocksResponse' :: ListWorkerBlocksResponse -> Maybe Int
numResults} -> Maybe Int
numResults) (\s :: ListWorkerBlocksResponse
s@ListWorkerBlocksResponse' {} Maybe Int
a -> ListWorkerBlocksResponse
s {$sel:numResults:ListWorkerBlocksResponse' :: Maybe Int
numResults = Maybe Int
a} :: ListWorkerBlocksResponse)
listWorkerBlocksResponse_workerBlocks :: Lens.Lens' ListWorkerBlocksResponse (Prelude.Maybe [WorkerBlock])
listWorkerBlocksResponse_workerBlocks :: Lens' ListWorkerBlocksResponse (Maybe [WorkerBlock])
listWorkerBlocksResponse_workerBlocks = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWorkerBlocksResponse' {Maybe [WorkerBlock]
workerBlocks :: Maybe [WorkerBlock]
$sel:workerBlocks:ListWorkerBlocksResponse' :: ListWorkerBlocksResponse -> Maybe [WorkerBlock]
workerBlocks} -> Maybe [WorkerBlock]
workerBlocks) (\s :: ListWorkerBlocksResponse
s@ListWorkerBlocksResponse' {} Maybe [WorkerBlock]
a -> ListWorkerBlocksResponse
s {$sel:workerBlocks:ListWorkerBlocksResponse' :: Maybe [WorkerBlock]
workerBlocks = Maybe [WorkerBlock]
a} :: ListWorkerBlocksResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
listWorkerBlocksResponse_httpStatus :: Lens.Lens' ListWorkerBlocksResponse Prelude.Int
listWorkerBlocksResponse_httpStatus :: Lens' ListWorkerBlocksResponse Int
listWorkerBlocksResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWorkerBlocksResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListWorkerBlocksResponse' :: ListWorkerBlocksResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListWorkerBlocksResponse
s@ListWorkerBlocksResponse' {} Int
a -> ListWorkerBlocksResponse
s {$sel:httpStatus:ListWorkerBlocksResponse' :: Int
httpStatus = Int
a} :: ListWorkerBlocksResponse)
instance Prelude.NFData ListWorkerBlocksResponse where
rnf :: ListWorkerBlocksResponse -> ()
rnf ListWorkerBlocksResponse' {Int
Maybe Int
Maybe [WorkerBlock]
Maybe Text
httpStatus :: Int
workerBlocks :: Maybe [WorkerBlock]
numResults :: Maybe Int
nextToken :: Maybe Text
$sel:httpStatus:ListWorkerBlocksResponse' :: ListWorkerBlocksResponse -> Int
$sel:workerBlocks:ListWorkerBlocksResponse' :: ListWorkerBlocksResponse -> Maybe [WorkerBlock]
$sel:numResults:ListWorkerBlocksResponse' :: ListWorkerBlocksResponse -> Maybe Int
$sel:nextToken:ListWorkerBlocksResponse' :: ListWorkerBlocksResponse -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
numResults
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [WorkerBlock]
workerBlocks
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus