{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.MechanicalTurk.ListAssignmentsForHIT
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- The @ListAssignmentsForHIT@ operation retrieves completed assignments
-- for a HIT. You can use this operation to retrieve the results for a HIT.
--
-- You can get assignments for a HIT at any time, even if the HIT is not
-- yet Reviewable. If a HIT requested multiple assignments, and has
-- received some results but has not yet become Reviewable, you can still
-- retrieve the partial results with this operation.
--
-- Use the AssignmentStatus parameter to control which set of assignments
-- for a HIT are returned. The ListAssignmentsForHIT operation can return
-- submitted assignments awaiting approval, or it can return assignments
-- that have already been approved or rejected. You can set
-- AssignmentStatus=Approved,Rejected to get assignments that have already
-- been approved and rejected together in one result set.
--
-- Only the Requester who created the HIT can retrieve the assignments for
-- that HIT.
--
-- Results are sorted and divided into numbered pages and the operation
-- returns a single page of results. You can use the parameters of the
-- operation to control sorting and pagination.
--
-- This operation returns paginated results.
module Amazonka.MechanicalTurk.ListAssignmentsForHIT
  ( -- * Creating a Request
    ListAssignmentsForHIT (..),
    newListAssignmentsForHIT,

    -- * Request Lenses
    listAssignmentsForHIT_assignmentStatuses,
    listAssignmentsForHIT_nextToken,
    listAssignmentsForHIT_maxResults,
    listAssignmentsForHIT_hITId,

    -- * Destructuring the Response
    ListAssignmentsForHITResponse (..),
    newListAssignmentsForHITResponse,

    -- * Response Lenses
    listAssignmentsForHITResponse_nextToken,
    listAssignmentsForHITResponse_numResults,
    listAssignmentsForHITResponse_assignments,
    listAssignmentsForHITResponse_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

-- | /See:/ 'newListAssignmentsForHIT' smart constructor.
data ListAssignmentsForHIT = ListAssignmentsForHIT'
  { -- | The status of the assignments to return: Submitted | Approved | Rejected
    ListAssignmentsForHIT -> Maybe [AssignmentStatus]
assignmentStatuses :: Prelude.Maybe [AssignmentStatus],
    -- | Pagination token
    ListAssignmentsForHIT -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    ListAssignmentsForHIT -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The ID of the HIT.
    ListAssignmentsForHIT -> Text
hITId :: Prelude.Text
  }
  deriving (ListAssignmentsForHIT -> ListAssignmentsForHIT -> Bool
(ListAssignmentsForHIT -> ListAssignmentsForHIT -> Bool)
-> (ListAssignmentsForHIT -> ListAssignmentsForHIT -> Bool)
-> Eq ListAssignmentsForHIT
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAssignmentsForHIT -> ListAssignmentsForHIT -> Bool
$c/= :: ListAssignmentsForHIT -> ListAssignmentsForHIT -> Bool
== :: ListAssignmentsForHIT -> ListAssignmentsForHIT -> Bool
$c== :: ListAssignmentsForHIT -> ListAssignmentsForHIT -> Bool
Prelude.Eq, ReadPrec [ListAssignmentsForHIT]
ReadPrec ListAssignmentsForHIT
Int -> ReadS ListAssignmentsForHIT
ReadS [ListAssignmentsForHIT]
(Int -> ReadS ListAssignmentsForHIT)
-> ReadS [ListAssignmentsForHIT]
-> ReadPrec ListAssignmentsForHIT
-> ReadPrec [ListAssignmentsForHIT]
-> Read ListAssignmentsForHIT
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAssignmentsForHIT]
$creadListPrec :: ReadPrec [ListAssignmentsForHIT]
readPrec :: ReadPrec ListAssignmentsForHIT
$creadPrec :: ReadPrec ListAssignmentsForHIT
readList :: ReadS [ListAssignmentsForHIT]
$creadList :: ReadS [ListAssignmentsForHIT]
readsPrec :: Int -> ReadS ListAssignmentsForHIT
$creadsPrec :: Int -> ReadS ListAssignmentsForHIT
Prelude.Read, Int -> ListAssignmentsForHIT -> ShowS
[ListAssignmentsForHIT] -> ShowS
ListAssignmentsForHIT -> String
(Int -> ListAssignmentsForHIT -> ShowS)
-> (ListAssignmentsForHIT -> String)
-> ([ListAssignmentsForHIT] -> ShowS)
-> Show ListAssignmentsForHIT
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAssignmentsForHIT] -> ShowS
$cshowList :: [ListAssignmentsForHIT] -> ShowS
show :: ListAssignmentsForHIT -> String
$cshow :: ListAssignmentsForHIT -> String
showsPrec :: Int -> ListAssignmentsForHIT -> ShowS
$cshowsPrec :: Int -> ListAssignmentsForHIT -> ShowS
Prelude.Show, (forall x. ListAssignmentsForHIT -> Rep ListAssignmentsForHIT x)
-> (forall x. Rep ListAssignmentsForHIT x -> ListAssignmentsForHIT)
-> Generic ListAssignmentsForHIT
forall x. Rep ListAssignmentsForHIT x -> ListAssignmentsForHIT
forall x. ListAssignmentsForHIT -> Rep ListAssignmentsForHIT x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAssignmentsForHIT x -> ListAssignmentsForHIT
$cfrom :: forall x. ListAssignmentsForHIT -> Rep ListAssignmentsForHIT x
Prelude.Generic)

-- |
-- Create a value of 'ListAssignmentsForHIT' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'assignmentStatuses', 'listAssignmentsForHIT_assignmentStatuses' - The status of the assignments to return: Submitted | Approved | Rejected
--
-- 'nextToken', 'listAssignmentsForHIT_nextToken' - Pagination token
--
-- 'maxResults', 'listAssignmentsForHIT_maxResults' - Undocumented member.
--
-- 'hITId', 'listAssignmentsForHIT_hITId' - The ID of the HIT.
newListAssignmentsForHIT ::
  -- | 'hITId'
  Prelude.Text ->
  ListAssignmentsForHIT
newListAssignmentsForHIT :: Text -> ListAssignmentsForHIT
newListAssignmentsForHIT Text
pHITId_ =
  ListAssignmentsForHIT' :: Maybe [AssignmentStatus]
-> Maybe Text -> Maybe Natural -> Text -> ListAssignmentsForHIT
ListAssignmentsForHIT'
    { $sel:assignmentStatuses:ListAssignmentsForHIT' :: Maybe [AssignmentStatus]
assignmentStatuses =
        Maybe [AssignmentStatus]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAssignmentsForHIT' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListAssignmentsForHIT' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:hITId:ListAssignmentsForHIT' :: Text
hITId = Text
pHITId_
    }

-- | The status of the assignments to return: Submitted | Approved | Rejected
listAssignmentsForHIT_assignmentStatuses :: Lens.Lens' ListAssignmentsForHIT (Prelude.Maybe [AssignmentStatus])
listAssignmentsForHIT_assignmentStatuses :: (Maybe [AssignmentStatus] -> f (Maybe [AssignmentStatus]))
-> ListAssignmentsForHIT -> f ListAssignmentsForHIT
listAssignmentsForHIT_assignmentStatuses = (ListAssignmentsForHIT -> Maybe [AssignmentStatus])
-> (ListAssignmentsForHIT
    -> Maybe [AssignmentStatus] -> ListAssignmentsForHIT)
-> Lens
     ListAssignmentsForHIT
     ListAssignmentsForHIT
     (Maybe [AssignmentStatus])
     (Maybe [AssignmentStatus])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssignmentsForHIT' {Maybe [AssignmentStatus]
assignmentStatuses :: Maybe [AssignmentStatus]
$sel:assignmentStatuses:ListAssignmentsForHIT' :: ListAssignmentsForHIT -> Maybe [AssignmentStatus]
assignmentStatuses} -> Maybe [AssignmentStatus]
assignmentStatuses) (\s :: ListAssignmentsForHIT
s@ListAssignmentsForHIT' {} Maybe [AssignmentStatus]
a -> ListAssignmentsForHIT
s {$sel:assignmentStatuses:ListAssignmentsForHIT' :: Maybe [AssignmentStatus]
assignmentStatuses = Maybe [AssignmentStatus]
a} :: ListAssignmentsForHIT) ((Maybe [AssignmentStatus] -> f (Maybe [AssignmentStatus]))
 -> ListAssignmentsForHIT -> f ListAssignmentsForHIT)
-> ((Maybe [AssignmentStatus] -> f (Maybe [AssignmentStatus]))
    -> Maybe [AssignmentStatus] -> f (Maybe [AssignmentStatus]))
-> (Maybe [AssignmentStatus] -> f (Maybe [AssignmentStatus]))
-> ListAssignmentsForHIT
-> f ListAssignmentsForHIT
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AssignmentStatus]
  [AssignmentStatus]
  [AssignmentStatus]
  [AssignmentStatus]
-> Iso
     (Maybe [AssignmentStatus])
     (Maybe [AssignmentStatus])
     (Maybe [AssignmentStatus])
     (Maybe [AssignmentStatus])
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 AnIso
  [AssignmentStatus]
  [AssignmentStatus]
  [AssignmentStatus]
  [AssignmentStatus]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Pagination token
listAssignmentsForHIT_nextToken :: Lens.Lens' ListAssignmentsForHIT (Prelude.Maybe Prelude.Text)
listAssignmentsForHIT_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAssignmentsForHIT -> f ListAssignmentsForHIT
listAssignmentsForHIT_nextToken = (ListAssignmentsForHIT -> Maybe Text)
-> (ListAssignmentsForHIT -> Maybe Text -> ListAssignmentsForHIT)
-> Lens
     ListAssignmentsForHIT
     ListAssignmentsForHIT
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssignmentsForHIT' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAssignmentsForHIT' :: ListAssignmentsForHIT -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAssignmentsForHIT
s@ListAssignmentsForHIT' {} Maybe Text
a -> ListAssignmentsForHIT
s {$sel:nextToken:ListAssignmentsForHIT' :: Maybe Text
nextToken = Maybe Text
a} :: ListAssignmentsForHIT)

-- | Undocumented member.
listAssignmentsForHIT_maxResults :: Lens.Lens' ListAssignmentsForHIT (Prelude.Maybe Prelude.Natural)
listAssignmentsForHIT_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListAssignmentsForHIT -> f ListAssignmentsForHIT
listAssignmentsForHIT_maxResults = (ListAssignmentsForHIT -> Maybe Natural)
-> (ListAssignmentsForHIT
    -> Maybe Natural -> ListAssignmentsForHIT)
-> Lens
     ListAssignmentsForHIT
     ListAssignmentsForHIT
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssignmentsForHIT' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListAssignmentsForHIT' :: ListAssignmentsForHIT -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListAssignmentsForHIT
s@ListAssignmentsForHIT' {} Maybe Natural
a -> ListAssignmentsForHIT
s {$sel:maxResults:ListAssignmentsForHIT' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListAssignmentsForHIT)

-- | The ID of the HIT.
listAssignmentsForHIT_hITId :: Lens.Lens' ListAssignmentsForHIT Prelude.Text
listAssignmentsForHIT_hITId :: (Text -> f Text)
-> ListAssignmentsForHIT -> f ListAssignmentsForHIT
listAssignmentsForHIT_hITId = (ListAssignmentsForHIT -> Text)
-> (ListAssignmentsForHIT -> Text -> ListAssignmentsForHIT)
-> Lens ListAssignmentsForHIT ListAssignmentsForHIT Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssignmentsForHIT' {Text
hITId :: Text
$sel:hITId:ListAssignmentsForHIT' :: ListAssignmentsForHIT -> Text
hITId} -> Text
hITId) (\s :: ListAssignmentsForHIT
s@ListAssignmentsForHIT' {} Text
a -> ListAssignmentsForHIT
s {$sel:hITId:ListAssignmentsForHIT' :: Text
hITId = Text
a} :: ListAssignmentsForHIT)

instance Core.AWSPager ListAssignmentsForHIT where
  page :: ListAssignmentsForHIT
-> AWSResponse ListAssignmentsForHIT -> Maybe ListAssignmentsForHIT
page ListAssignmentsForHIT
rq AWSResponse ListAssignmentsForHIT
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAssignmentsForHIT
ListAssignmentsForHITResponse
rs
            ListAssignmentsForHITResponse
-> Getting (First Text) ListAssignmentsForHITResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAssignmentsForHITResponse
-> Const (First Text) ListAssignmentsForHITResponse
Lens' ListAssignmentsForHITResponse (Maybe Text)
listAssignmentsForHITResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListAssignmentsForHITResponse
 -> Const (First Text) ListAssignmentsForHITResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAssignmentsForHITResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListAssignmentsForHIT
forall a. Maybe a
Prelude.Nothing
    | Maybe [Assignment] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAssignmentsForHIT
ListAssignmentsForHITResponse
rs
            ListAssignmentsForHITResponse
-> Getting
     (First [Assignment]) ListAssignmentsForHITResponse [Assignment]
-> Maybe [Assignment]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Assignment]
 -> Const (First [Assignment]) (Maybe [Assignment]))
-> ListAssignmentsForHITResponse
-> Const (First [Assignment]) ListAssignmentsForHITResponse
Lens' ListAssignmentsForHITResponse (Maybe [Assignment])
listAssignmentsForHITResponse_assignments
              ((Maybe [Assignment]
  -> Const (First [Assignment]) (Maybe [Assignment]))
 -> ListAssignmentsForHITResponse
 -> Const (First [Assignment]) ListAssignmentsForHITResponse)
-> (([Assignment] -> Const (First [Assignment]) [Assignment])
    -> Maybe [Assignment]
    -> Const (First [Assignment]) (Maybe [Assignment]))
-> Getting
     (First [Assignment]) ListAssignmentsForHITResponse [Assignment]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Assignment] -> Const (First [Assignment]) [Assignment])
-> Maybe [Assignment]
-> Const (First [Assignment]) (Maybe [Assignment])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListAssignmentsForHIT
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListAssignmentsForHIT -> Maybe ListAssignmentsForHIT
forall a. a -> Maybe a
Prelude.Just (ListAssignmentsForHIT -> Maybe ListAssignmentsForHIT)
-> ListAssignmentsForHIT -> Maybe ListAssignmentsForHIT
forall a b. (a -> b) -> a -> b
Prelude.$
        ListAssignmentsForHIT
rq
          ListAssignmentsForHIT
-> (ListAssignmentsForHIT -> ListAssignmentsForHIT)
-> ListAssignmentsForHIT
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListAssignmentsForHIT -> Identity ListAssignmentsForHIT
Lens
  ListAssignmentsForHIT
  ListAssignmentsForHIT
  (Maybe Text)
  (Maybe Text)
listAssignmentsForHIT_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListAssignmentsForHIT -> Identity ListAssignmentsForHIT)
-> Maybe Text -> ListAssignmentsForHIT -> ListAssignmentsForHIT
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListAssignmentsForHIT
ListAssignmentsForHITResponse
rs
          ListAssignmentsForHITResponse
-> Getting (First Text) ListAssignmentsForHITResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAssignmentsForHITResponse
-> Const (First Text) ListAssignmentsForHITResponse
Lens' ListAssignmentsForHITResponse (Maybe Text)
listAssignmentsForHITResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListAssignmentsForHITResponse
 -> Const (First Text) ListAssignmentsForHITResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAssignmentsForHITResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListAssignmentsForHIT where
  type
    AWSResponse ListAssignmentsForHIT =
      ListAssignmentsForHITResponse
  request :: ListAssignmentsForHIT -> Request ListAssignmentsForHIT
request = Service -> ListAssignmentsForHIT -> Request ListAssignmentsForHIT
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListAssignmentsForHIT
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListAssignmentsForHIT)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListAssignmentsForHIT))
-> Logger
-> Service
-> Proxy ListAssignmentsForHIT
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListAssignmentsForHIT)))
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 Int
-> Maybe [Assignment]
-> Int
-> ListAssignmentsForHITResponse
ListAssignmentsForHITResponse'
            (Maybe Text
 -> Maybe Int
 -> Maybe [Assignment]
 -> Int
 -> ListAssignmentsForHITResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Int
      -> Maybe [Assignment] -> Int -> ListAssignmentsForHITResponse)
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
"NextToken")
            Either
  String
  (Maybe Int
   -> Maybe [Assignment] -> Int -> ListAssignmentsForHITResponse)
-> Either String (Maybe Int)
-> Either
     String (Maybe [Assignment] -> Int -> ListAssignmentsForHITResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Int)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NumResults")
            Either
  String (Maybe [Assignment] -> Int -> ListAssignmentsForHITResponse)
-> Either String (Maybe [Assignment])
-> Either String (Int -> ListAssignmentsForHITResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [Assignment]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Assignments" Either String (Maybe (Maybe [Assignment]))
-> Maybe [Assignment] -> Either String (Maybe [Assignment])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Assignment]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> ListAssignmentsForHITResponse)
-> Either String Int -> Either String ListAssignmentsForHITResponse
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 ListAssignmentsForHIT

instance Prelude.NFData ListAssignmentsForHIT

instance Core.ToHeaders ListAssignmentsForHIT where
  toHeaders :: ListAssignmentsForHIT -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListAssignmentsForHIT -> 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.ListAssignmentsForHIT" ::
                          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 ListAssignmentsForHIT where
  toJSON :: ListAssignmentsForHIT -> Value
toJSON ListAssignmentsForHIT' {Maybe Natural
Maybe [AssignmentStatus]
Maybe Text
Text
hITId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
assignmentStatuses :: Maybe [AssignmentStatus]
$sel:hITId:ListAssignmentsForHIT' :: ListAssignmentsForHIT -> Text
$sel:maxResults:ListAssignmentsForHIT' :: ListAssignmentsForHIT -> Maybe Natural
$sel:nextToken:ListAssignmentsForHIT' :: ListAssignmentsForHIT -> Maybe Text
$sel:assignmentStatuses:ListAssignmentsForHIT' :: ListAssignmentsForHIT -> Maybe [AssignmentStatus]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AssignmentStatuses" Text -> [AssignmentStatus] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([AssignmentStatus] -> Pair)
-> Maybe [AssignmentStatus] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AssignmentStatus]
assignmentStatuses,
            (Text
"NextToken" 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
nextToken,
            (Text
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"HITId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
hITId)
          ]
      )

instance Core.ToPath ListAssignmentsForHIT where
  toPath :: ListAssignmentsForHIT -> ByteString
toPath = ByteString -> ListAssignmentsForHIT -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery ListAssignmentsForHIT where
  toQuery :: ListAssignmentsForHIT -> QueryString
toQuery = QueryString -> ListAssignmentsForHIT -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newListAssignmentsForHITResponse' smart constructor.
data ListAssignmentsForHITResponse = ListAssignmentsForHITResponse'
  { ListAssignmentsForHITResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The number of assignments on the page in the filtered results list,
    -- equivalent to the number of assignments returned by this call.
    ListAssignmentsForHITResponse -> Maybe Int
numResults :: Prelude.Maybe Prelude.Int,
    -- | The collection of Assignment data structures returned by this call.
    ListAssignmentsForHITResponse -> Maybe [Assignment]
assignments :: Prelude.Maybe [Assignment],
    -- | The response's http status code.
    ListAssignmentsForHITResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListAssignmentsForHITResponse
-> ListAssignmentsForHITResponse -> Bool
(ListAssignmentsForHITResponse
 -> ListAssignmentsForHITResponse -> Bool)
-> (ListAssignmentsForHITResponse
    -> ListAssignmentsForHITResponse -> Bool)
-> Eq ListAssignmentsForHITResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAssignmentsForHITResponse
-> ListAssignmentsForHITResponse -> Bool
$c/= :: ListAssignmentsForHITResponse
-> ListAssignmentsForHITResponse -> Bool
== :: ListAssignmentsForHITResponse
-> ListAssignmentsForHITResponse -> Bool
$c== :: ListAssignmentsForHITResponse
-> ListAssignmentsForHITResponse -> Bool
Prelude.Eq, ReadPrec [ListAssignmentsForHITResponse]
ReadPrec ListAssignmentsForHITResponse
Int -> ReadS ListAssignmentsForHITResponse
ReadS [ListAssignmentsForHITResponse]
(Int -> ReadS ListAssignmentsForHITResponse)
-> ReadS [ListAssignmentsForHITResponse]
-> ReadPrec ListAssignmentsForHITResponse
-> ReadPrec [ListAssignmentsForHITResponse]
-> Read ListAssignmentsForHITResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAssignmentsForHITResponse]
$creadListPrec :: ReadPrec [ListAssignmentsForHITResponse]
readPrec :: ReadPrec ListAssignmentsForHITResponse
$creadPrec :: ReadPrec ListAssignmentsForHITResponse
readList :: ReadS [ListAssignmentsForHITResponse]
$creadList :: ReadS [ListAssignmentsForHITResponse]
readsPrec :: Int -> ReadS ListAssignmentsForHITResponse
$creadsPrec :: Int -> ReadS ListAssignmentsForHITResponse
Prelude.Read, Int -> ListAssignmentsForHITResponse -> ShowS
[ListAssignmentsForHITResponse] -> ShowS
ListAssignmentsForHITResponse -> String
(Int -> ListAssignmentsForHITResponse -> ShowS)
-> (ListAssignmentsForHITResponse -> String)
-> ([ListAssignmentsForHITResponse] -> ShowS)
-> Show ListAssignmentsForHITResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAssignmentsForHITResponse] -> ShowS
$cshowList :: [ListAssignmentsForHITResponse] -> ShowS
show :: ListAssignmentsForHITResponse -> String
$cshow :: ListAssignmentsForHITResponse -> String
showsPrec :: Int -> ListAssignmentsForHITResponse -> ShowS
$cshowsPrec :: Int -> ListAssignmentsForHITResponse -> ShowS
Prelude.Show, (forall x.
 ListAssignmentsForHITResponse
 -> Rep ListAssignmentsForHITResponse x)
-> (forall x.
    Rep ListAssignmentsForHITResponse x
    -> ListAssignmentsForHITResponse)
-> Generic ListAssignmentsForHITResponse
forall x.
Rep ListAssignmentsForHITResponse x
-> ListAssignmentsForHITResponse
forall x.
ListAssignmentsForHITResponse
-> Rep ListAssignmentsForHITResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListAssignmentsForHITResponse x
-> ListAssignmentsForHITResponse
$cfrom :: forall x.
ListAssignmentsForHITResponse
-> Rep ListAssignmentsForHITResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListAssignmentsForHITResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'nextToken', 'listAssignmentsForHITResponse_nextToken' - Undocumented member.
--
-- 'numResults', 'listAssignmentsForHITResponse_numResults' - The number of assignments on the page in the filtered results list,
-- equivalent to the number of assignments returned by this call.
--
-- 'assignments', 'listAssignmentsForHITResponse_assignments' - The collection of Assignment data structures returned by this call.
--
-- 'httpStatus', 'listAssignmentsForHITResponse_httpStatus' - The response's http status code.
newListAssignmentsForHITResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAssignmentsForHITResponse
newListAssignmentsForHITResponse :: Int -> ListAssignmentsForHITResponse
newListAssignmentsForHITResponse Int
pHttpStatus_ =
  ListAssignmentsForHITResponse' :: Maybe Text
-> Maybe Int
-> Maybe [Assignment]
-> Int
-> ListAssignmentsForHITResponse
ListAssignmentsForHITResponse'
    { $sel:nextToken:ListAssignmentsForHITResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:numResults:ListAssignmentsForHITResponse' :: Maybe Int
numResults = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:assignments:ListAssignmentsForHITResponse' :: Maybe [Assignment]
assignments = Maybe [Assignment]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAssignmentsForHITResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
listAssignmentsForHITResponse_nextToken :: Lens.Lens' ListAssignmentsForHITResponse (Prelude.Maybe Prelude.Text)
listAssignmentsForHITResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAssignmentsForHITResponse -> f ListAssignmentsForHITResponse
listAssignmentsForHITResponse_nextToken = (ListAssignmentsForHITResponse -> Maybe Text)
-> (ListAssignmentsForHITResponse
    -> Maybe Text -> ListAssignmentsForHITResponse)
-> Lens' ListAssignmentsForHITResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssignmentsForHITResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAssignmentsForHITResponse' :: ListAssignmentsForHITResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAssignmentsForHITResponse
s@ListAssignmentsForHITResponse' {} Maybe Text
a -> ListAssignmentsForHITResponse
s {$sel:nextToken:ListAssignmentsForHITResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListAssignmentsForHITResponse)

-- | The number of assignments on the page in the filtered results list,
-- equivalent to the number of assignments returned by this call.
listAssignmentsForHITResponse_numResults :: Lens.Lens' ListAssignmentsForHITResponse (Prelude.Maybe Prelude.Int)
listAssignmentsForHITResponse_numResults :: (Maybe Int -> f (Maybe Int))
-> ListAssignmentsForHITResponse -> f ListAssignmentsForHITResponse
listAssignmentsForHITResponse_numResults = (ListAssignmentsForHITResponse -> Maybe Int)
-> (ListAssignmentsForHITResponse
    -> Maybe Int -> ListAssignmentsForHITResponse)
-> Lens
     ListAssignmentsForHITResponse
     ListAssignmentsForHITResponse
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssignmentsForHITResponse' {Maybe Int
numResults :: Maybe Int
$sel:numResults:ListAssignmentsForHITResponse' :: ListAssignmentsForHITResponse -> Maybe Int
numResults} -> Maybe Int
numResults) (\s :: ListAssignmentsForHITResponse
s@ListAssignmentsForHITResponse' {} Maybe Int
a -> ListAssignmentsForHITResponse
s {$sel:numResults:ListAssignmentsForHITResponse' :: Maybe Int
numResults = Maybe Int
a} :: ListAssignmentsForHITResponse)

-- | The collection of Assignment data structures returned by this call.
listAssignmentsForHITResponse_assignments :: Lens.Lens' ListAssignmentsForHITResponse (Prelude.Maybe [Assignment])
listAssignmentsForHITResponse_assignments :: (Maybe [Assignment] -> f (Maybe [Assignment]))
-> ListAssignmentsForHITResponse -> f ListAssignmentsForHITResponse
listAssignmentsForHITResponse_assignments = (ListAssignmentsForHITResponse -> Maybe [Assignment])
-> (ListAssignmentsForHITResponse
    -> Maybe [Assignment] -> ListAssignmentsForHITResponse)
-> Lens' ListAssignmentsForHITResponse (Maybe [Assignment])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssignmentsForHITResponse' {Maybe [Assignment]
assignments :: Maybe [Assignment]
$sel:assignments:ListAssignmentsForHITResponse' :: ListAssignmentsForHITResponse -> Maybe [Assignment]
assignments} -> Maybe [Assignment]
assignments) (\s :: ListAssignmentsForHITResponse
s@ListAssignmentsForHITResponse' {} Maybe [Assignment]
a -> ListAssignmentsForHITResponse
s {$sel:assignments:ListAssignmentsForHITResponse' :: Maybe [Assignment]
assignments = Maybe [Assignment]
a} :: ListAssignmentsForHITResponse) ((Maybe [Assignment] -> f (Maybe [Assignment]))
 -> ListAssignmentsForHITResponse
 -> f ListAssignmentsForHITResponse)
-> ((Maybe [Assignment] -> f (Maybe [Assignment]))
    -> Maybe [Assignment] -> f (Maybe [Assignment]))
-> (Maybe [Assignment] -> f (Maybe [Assignment]))
-> ListAssignmentsForHITResponse
-> f ListAssignmentsForHITResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Assignment] [Assignment] [Assignment] [Assignment]
-> Iso
     (Maybe [Assignment])
     (Maybe [Assignment])
     (Maybe [Assignment])
     (Maybe [Assignment])
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 AnIso [Assignment] [Assignment] [Assignment] [Assignment]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
listAssignmentsForHITResponse_httpStatus :: Lens.Lens' ListAssignmentsForHITResponse Prelude.Int
listAssignmentsForHITResponse_httpStatus :: (Int -> f Int)
-> ListAssignmentsForHITResponse -> f ListAssignmentsForHITResponse
listAssignmentsForHITResponse_httpStatus = (ListAssignmentsForHITResponse -> Int)
-> (ListAssignmentsForHITResponse
    -> Int -> ListAssignmentsForHITResponse)
-> Lens
     ListAssignmentsForHITResponse ListAssignmentsForHITResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssignmentsForHITResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListAssignmentsForHITResponse' :: ListAssignmentsForHITResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListAssignmentsForHITResponse
s@ListAssignmentsForHITResponse' {} Int
a -> ListAssignmentsForHITResponse
s {$sel:httpStatus:ListAssignmentsForHITResponse' :: Int
httpStatus = Int
a} :: ListAssignmentsForHITResponse)

instance Prelude.NFData ListAssignmentsForHITResponse