{-# 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.CreateHITWithHITType -- Copyright : (c) 2013-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- The @CreateHITWithHITType@ operation creates a new Human Intelligence -- Task (HIT) using an existing HITTypeID generated by the @CreateHITType@ -- operation. -- -- This is an alternative way to create HITs from the @CreateHIT@ -- operation. This is the recommended best practice for Requesters who are -- creating large numbers of HITs. -- -- CreateHITWithHITType also supports several ways to provide question -- data: by providing a value for the @Question@ parameter that fully -- specifies the contents of the HIT, or by providing a @HitLayoutId@ and -- associated @HitLayoutParameters@. -- -- If a HIT is created with 10 or more maximum assignments, there is an -- additional fee. For more information, see -- . module Amazonka.MechanicalTurk.CreateHITWithHITType ( -- * Creating a Request CreateHITWithHITType (..), newCreateHITWithHITType, -- * Request Lenses createHITWithHITType_assignmentReviewPolicy, createHITWithHITType_hITLayoutId, createHITWithHITType_hITLayoutParameters, createHITWithHITType_hITReviewPolicy, createHITWithHITType_maxAssignments, createHITWithHITType_question, createHITWithHITType_requesterAnnotation, createHITWithHITType_uniqueRequestToken, createHITWithHITType_hITTypeId, createHITWithHITType_lifetimeInSeconds, -- * Destructuring the Response CreateHITWithHITTypeResponse (..), newCreateHITWithHITTypeResponse, -- * Response Lenses createHITWithHITTypeResponse_hit, createHITWithHITTypeResponse_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 -- | /See:/ 'newCreateHITWithHITType' smart constructor. data CreateHITWithHITType = CreateHITWithHITType' { -- | The Assignment-level Review Policy applies to the assignments under the -- HIT. You can specify for Mechanical Turk to take various actions based -- on the policy. assignmentReviewPolicy :: Prelude.Maybe ReviewPolicy, -- | The HITLayoutId allows you to use a pre-existing HIT design with -- placeholder values and create an additional HIT by providing those -- values as HITLayoutParameters. -- -- Constraints: Either a Question parameter or a HITLayoutId parameter must -- be provided. hITLayoutId :: Prelude.Maybe Prelude.Text, -- | If the HITLayoutId is provided, any placeholder values must be filled in -- with values using the HITLayoutParameter structure. For more -- information, see HITLayout. hITLayoutParameters :: Prelude.Maybe [HITLayoutParameter], -- | The HIT-level Review Policy applies to the HIT. You can specify for -- Mechanical Turk to take various actions based on the policy. hITReviewPolicy :: Prelude.Maybe ReviewPolicy, -- | The number of times the HIT can be accepted and completed before the HIT -- becomes unavailable. maxAssignments :: Prelude.Maybe Prelude.Int, -- | The data the person completing the HIT uses to produce the results. -- -- Constraints: Must be a QuestionForm data structure, an ExternalQuestion -- data structure, or an HTMLQuestion data structure. The XML question data -- must not be larger than 64 kilobytes (65,535 bytes) in size, including -- whitespace. -- -- Either a Question parameter or a HITLayoutId parameter must be provided. question :: Prelude.Maybe Prelude.Text, -- | An arbitrary data field. The RequesterAnnotation parameter lets your -- application attach arbitrary data to the HIT for tracking purposes. For -- example, this parameter could be an identifier internal to the -- Requester\'s application that corresponds with the HIT. -- -- The RequesterAnnotation parameter for a HIT is only visible to the -- Requester who created the HIT. It is not shown to the Worker, or any -- other Requester. -- -- The RequesterAnnotation parameter may be different for each HIT you -- submit. It does not affect how your HITs are grouped. requesterAnnotation :: Prelude.Maybe Prelude.Text, -- | A unique identifier for this request which allows you to retry the call -- on error without creating duplicate HITs. This is useful in cases such -- as network timeouts where it is unclear whether or not the call -- succeeded on the server. If the HIT already exists in the system from a -- previous call using the same UniqueRequestToken, subsequent calls will -- return a AWS.MechanicalTurk.HitAlreadyExists error with a message -- containing the HITId. -- -- Note: It is your responsibility to ensure uniqueness of the token. The -- unique token expires after 24 hours. Subsequent calls using the same -- UniqueRequestToken made after the 24 hour limit could create duplicate -- HITs. uniqueRequestToken :: Prelude.Maybe Prelude.Text, -- | The HIT type ID you want to create this HIT with. hITTypeId :: Prelude.Text, -- | An amount of time, in seconds, after which the HIT is no longer -- available for users to accept. After the lifetime of the HIT elapses, -- the HIT no longer appears in HIT searches, even if not all of the -- assignments for the HIT have been accepted. lifetimeInSeconds :: Prelude.Integer } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'CreateHITWithHITType' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'assignmentReviewPolicy', 'createHITWithHITType_assignmentReviewPolicy' - The Assignment-level Review Policy applies to the assignments under the -- HIT. You can specify for Mechanical Turk to take various actions based -- on the policy. -- -- 'hITLayoutId', 'createHITWithHITType_hITLayoutId' - The HITLayoutId allows you to use a pre-existing HIT design with -- placeholder values and create an additional HIT by providing those -- values as HITLayoutParameters. -- -- Constraints: Either a Question parameter or a HITLayoutId parameter must -- be provided. -- -- 'hITLayoutParameters', 'createHITWithHITType_hITLayoutParameters' - If the HITLayoutId is provided, any placeholder values must be filled in -- with values using the HITLayoutParameter structure. For more -- information, see HITLayout. -- -- 'hITReviewPolicy', 'createHITWithHITType_hITReviewPolicy' - The HIT-level Review Policy applies to the HIT. You can specify for -- Mechanical Turk to take various actions based on the policy. -- -- 'maxAssignments', 'createHITWithHITType_maxAssignments' - The number of times the HIT can be accepted and completed before the HIT -- becomes unavailable. -- -- 'question', 'createHITWithHITType_question' - The data the person completing the HIT uses to produce the results. -- -- Constraints: Must be a QuestionForm data structure, an ExternalQuestion -- data structure, or an HTMLQuestion data structure. The XML question data -- must not be larger than 64 kilobytes (65,535 bytes) in size, including -- whitespace. -- -- Either a Question parameter or a HITLayoutId parameter must be provided. -- -- 'requesterAnnotation', 'createHITWithHITType_requesterAnnotation' - An arbitrary data field. The RequesterAnnotation parameter lets your -- application attach arbitrary data to the HIT for tracking purposes. For -- example, this parameter could be an identifier internal to the -- Requester\'s application that corresponds with the HIT. -- -- The RequesterAnnotation parameter for a HIT is only visible to the -- Requester who created the HIT. It is not shown to the Worker, or any -- other Requester. -- -- The RequesterAnnotation parameter may be different for each HIT you -- submit. It does not affect how your HITs are grouped. -- -- 'uniqueRequestToken', 'createHITWithHITType_uniqueRequestToken' - A unique identifier for this request which allows you to retry the call -- on error without creating duplicate HITs. This is useful in cases such -- as network timeouts where it is unclear whether or not the call -- succeeded on the server. If the HIT already exists in the system from a -- previous call using the same UniqueRequestToken, subsequent calls will -- return a AWS.MechanicalTurk.HitAlreadyExists error with a message -- containing the HITId. -- -- Note: It is your responsibility to ensure uniqueness of the token. The -- unique token expires after 24 hours. Subsequent calls using the same -- UniqueRequestToken made after the 24 hour limit could create duplicate -- HITs. -- -- 'hITTypeId', 'createHITWithHITType_hITTypeId' - The HIT type ID you want to create this HIT with. -- -- 'lifetimeInSeconds', 'createHITWithHITType_lifetimeInSeconds' - An amount of time, in seconds, after which the HIT is no longer -- available for users to accept. After the lifetime of the HIT elapses, -- the HIT no longer appears in HIT searches, even if not all of the -- assignments for the HIT have been accepted. newCreateHITWithHITType :: -- | 'hITTypeId' Prelude.Text -> -- | 'lifetimeInSeconds' Prelude.Integer -> CreateHITWithHITType newCreateHITWithHITType pHITTypeId_ pLifetimeInSeconds_ = CreateHITWithHITType' { assignmentReviewPolicy = Prelude.Nothing, hITLayoutId = Prelude.Nothing, hITLayoutParameters = Prelude.Nothing, hITReviewPolicy = Prelude.Nothing, maxAssignments = Prelude.Nothing, question = Prelude.Nothing, requesterAnnotation = Prelude.Nothing, uniqueRequestToken = Prelude.Nothing, hITTypeId = pHITTypeId_, lifetimeInSeconds = pLifetimeInSeconds_ } -- | The Assignment-level Review Policy applies to the assignments under the -- HIT. You can specify for Mechanical Turk to take various actions based -- on the policy. createHITWithHITType_assignmentReviewPolicy :: Lens.Lens' CreateHITWithHITType (Prelude.Maybe ReviewPolicy) createHITWithHITType_assignmentReviewPolicy = Lens.lens (\CreateHITWithHITType' {assignmentReviewPolicy} -> assignmentReviewPolicy) (\s@CreateHITWithHITType' {} a -> s {assignmentReviewPolicy = a} :: CreateHITWithHITType) -- | The HITLayoutId allows you to use a pre-existing HIT design with -- placeholder values and create an additional HIT by providing those -- values as HITLayoutParameters. -- -- Constraints: Either a Question parameter or a HITLayoutId parameter must -- be provided. createHITWithHITType_hITLayoutId :: Lens.Lens' CreateHITWithHITType (Prelude.Maybe Prelude.Text) createHITWithHITType_hITLayoutId = Lens.lens (\CreateHITWithHITType' {hITLayoutId} -> hITLayoutId) (\s@CreateHITWithHITType' {} a -> s {hITLayoutId = a} :: CreateHITWithHITType) -- | If the HITLayoutId is provided, any placeholder values must be filled in -- with values using the HITLayoutParameter structure. For more -- information, see HITLayout. createHITWithHITType_hITLayoutParameters :: Lens.Lens' CreateHITWithHITType (Prelude.Maybe [HITLayoutParameter]) createHITWithHITType_hITLayoutParameters = Lens.lens (\CreateHITWithHITType' {hITLayoutParameters} -> hITLayoutParameters) (\s@CreateHITWithHITType' {} a -> s {hITLayoutParameters = a} :: CreateHITWithHITType) Prelude.. Lens.mapping Lens.coerced -- | The HIT-level Review Policy applies to the HIT. You can specify for -- Mechanical Turk to take various actions based on the policy. createHITWithHITType_hITReviewPolicy :: Lens.Lens' CreateHITWithHITType (Prelude.Maybe ReviewPolicy) createHITWithHITType_hITReviewPolicy = Lens.lens (\CreateHITWithHITType' {hITReviewPolicy} -> hITReviewPolicy) (\s@CreateHITWithHITType' {} a -> s {hITReviewPolicy = a} :: CreateHITWithHITType) -- | The number of times the HIT can be accepted and completed before the HIT -- becomes unavailable. createHITWithHITType_maxAssignments :: Lens.Lens' CreateHITWithHITType (Prelude.Maybe Prelude.Int) createHITWithHITType_maxAssignments = Lens.lens (\CreateHITWithHITType' {maxAssignments} -> maxAssignments) (\s@CreateHITWithHITType' {} a -> s {maxAssignments = a} :: CreateHITWithHITType) -- | The data the person completing the HIT uses to produce the results. -- -- Constraints: Must be a QuestionForm data structure, an ExternalQuestion -- data structure, or an HTMLQuestion data structure. The XML question data -- must not be larger than 64 kilobytes (65,535 bytes) in size, including -- whitespace. -- -- Either a Question parameter or a HITLayoutId parameter must be provided. createHITWithHITType_question :: Lens.Lens' CreateHITWithHITType (Prelude.Maybe Prelude.Text) createHITWithHITType_question = Lens.lens (\CreateHITWithHITType' {question} -> question) (\s@CreateHITWithHITType' {} a -> s {question = a} :: CreateHITWithHITType) -- | An arbitrary data field. The RequesterAnnotation parameter lets your -- application attach arbitrary data to the HIT for tracking purposes. For -- example, this parameter could be an identifier internal to the -- Requester\'s application that corresponds with the HIT. -- -- The RequesterAnnotation parameter for a HIT is only visible to the -- Requester who created the HIT. It is not shown to the Worker, or any -- other Requester. -- -- The RequesterAnnotation parameter may be different for each HIT you -- submit. It does not affect how your HITs are grouped. createHITWithHITType_requesterAnnotation :: Lens.Lens' CreateHITWithHITType (Prelude.Maybe Prelude.Text) createHITWithHITType_requesterAnnotation = Lens.lens (\CreateHITWithHITType' {requesterAnnotation} -> requesterAnnotation) (\s@CreateHITWithHITType' {} a -> s {requesterAnnotation = a} :: CreateHITWithHITType) -- | A unique identifier for this request which allows you to retry the call -- on error without creating duplicate HITs. This is useful in cases such -- as network timeouts where it is unclear whether or not the call -- succeeded on the server. If the HIT already exists in the system from a -- previous call using the same UniqueRequestToken, subsequent calls will -- return a AWS.MechanicalTurk.HitAlreadyExists error with a message -- containing the HITId. -- -- Note: It is your responsibility to ensure uniqueness of the token. The -- unique token expires after 24 hours. Subsequent calls using the same -- UniqueRequestToken made after the 24 hour limit could create duplicate -- HITs. createHITWithHITType_uniqueRequestToken :: Lens.Lens' CreateHITWithHITType (Prelude.Maybe Prelude.Text) createHITWithHITType_uniqueRequestToken = Lens.lens (\CreateHITWithHITType' {uniqueRequestToken} -> uniqueRequestToken) (\s@CreateHITWithHITType' {} a -> s {uniqueRequestToken = a} :: CreateHITWithHITType) -- | The HIT type ID you want to create this HIT with. createHITWithHITType_hITTypeId :: Lens.Lens' CreateHITWithHITType Prelude.Text createHITWithHITType_hITTypeId = Lens.lens (\CreateHITWithHITType' {hITTypeId} -> hITTypeId) (\s@CreateHITWithHITType' {} a -> s {hITTypeId = a} :: CreateHITWithHITType) -- | An amount of time, in seconds, after which the HIT is no longer -- available for users to accept. After the lifetime of the HIT elapses, -- the HIT no longer appears in HIT searches, even if not all of the -- assignments for the HIT have been accepted. createHITWithHITType_lifetimeInSeconds :: Lens.Lens' CreateHITWithHITType Prelude.Integer createHITWithHITType_lifetimeInSeconds = Lens.lens (\CreateHITWithHITType' {lifetimeInSeconds} -> lifetimeInSeconds) (\s@CreateHITWithHITType' {} a -> s {lifetimeInSeconds = a} :: CreateHITWithHITType) instance Core.AWSRequest CreateHITWithHITType where type AWSResponse CreateHITWithHITType = CreateHITWithHITTypeResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> CreateHITWithHITTypeResponse' Prelude.<$> (x Data..?> "HIT") Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable CreateHITWithHITType where hashWithSalt _salt CreateHITWithHITType' {..} = _salt `Prelude.hashWithSalt` assignmentReviewPolicy `Prelude.hashWithSalt` hITLayoutId `Prelude.hashWithSalt` hITLayoutParameters `Prelude.hashWithSalt` hITReviewPolicy `Prelude.hashWithSalt` maxAssignments `Prelude.hashWithSalt` question `Prelude.hashWithSalt` requesterAnnotation `Prelude.hashWithSalt` uniqueRequestToken `Prelude.hashWithSalt` hITTypeId `Prelude.hashWithSalt` lifetimeInSeconds instance Prelude.NFData CreateHITWithHITType where rnf CreateHITWithHITType' {..} = Prelude.rnf assignmentReviewPolicy `Prelude.seq` Prelude.rnf hITLayoutId `Prelude.seq` Prelude.rnf hITLayoutParameters `Prelude.seq` Prelude.rnf hITReviewPolicy `Prelude.seq` Prelude.rnf maxAssignments `Prelude.seq` Prelude.rnf question `Prelude.seq` Prelude.rnf requesterAnnotation `Prelude.seq` Prelude.rnf uniqueRequestToken `Prelude.seq` Prelude.rnf hITTypeId `Prelude.seq` Prelude.rnf lifetimeInSeconds instance Data.ToHeaders CreateHITWithHITType where toHeaders = Prelude.const ( Prelude.mconcat [ "X-Amz-Target" Data.=# ( "MTurkRequesterServiceV20170117.CreateHITWithHITType" :: Prelude.ByteString ), "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON CreateHITWithHITType where toJSON CreateHITWithHITType' {..} = Data.object ( Prelude.catMaybes [ ("AssignmentReviewPolicy" Data..=) Prelude.<$> assignmentReviewPolicy, ("HITLayoutId" Data..=) Prelude.<$> hITLayoutId, ("HITLayoutParameters" Data..=) Prelude.<$> hITLayoutParameters, ("HITReviewPolicy" Data..=) Prelude.<$> hITReviewPolicy, ("MaxAssignments" Data..=) Prelude.<$> maxAssignments, ("Question" Data..=) Prelude.<$> question, ("RequesterAnnotation" Data..=) Prelude.<$> requesterAnnotation, ("UniqueRequestToken" Data..=) Prelude.<$> uniqueRequestToken, Prelude.Just ("HITTypeId" Data..= hITTypeId), Prelude.Just ("LifetimeInSeconds" Data..= lifetimeInSeconds) ] ) instance Data.ToPath CreateHITWithHITType where toPath = Prelude.const "/" instance Data.ToQuery CreateHITWithHITType where toQuery = Prelude.const Prelude.mempty -- | /See:/ 'newCreateHITWithHITTypeResponse' smart constructor. data CreateHITWithHITTypeResponse = CreateHITWithHITTypeResponse' { -- | Contains the newly created HIT data. For a description of the HIT data -- structure as it appears in responses, see the HIT Data Structure -- documentation. hit :: Prelude.Maybe HIT, -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'CreateHITWithHITTypeResponse' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'hit', 'createHITWithHITTypeResponse_hit' - Contains the newly created HIT data. For a description of the HIT data -- structure as it appears in responses, see the HIT Data Structure -- documentation. -- -- 'httpStatus', 'createHITWithHITTypeResponse_httpStatus' - The response's http status code. newCreateHITWithHITTypeResponse :: -- | 'httpStatus' Prelude.Int -> CreateHITWithHITTypeResponse newCreateHITWithHITTypeResponse pHttpStatus_ = CreateHITWithHITTypeResponse' { hit = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | Contains the newly created HIT data. For a description of the HIT data -- structure as it appears in responses, see the HIT Data Structure -- documentation. createHITWithHITTypeResponse_hit :: Lens.Lens' CreateHITWithHITTypeResponse (Prelude.Maybe HIT) createHITWithHITTypeResponse_hit = Lens.lens (\CreateHITWithHITTypeResponse' {hit} -> hit) (\s@CreateHITWithHITTypeResponse' {} a -> s {hit = a} :: CreateHITWithHITTypeResponse) -- | The response's http status code. createHITWithHITTypeResponse_httpStatus :: Lens.Lens' CreateHITWithHITTypeResponse Prelude.Int createHITWithHITTypeResponse_httpStatus = Lens.lens (\CreateHITWithHITTypeResponse' {httpStatus} -> httpStatus) (\s@CreateHITWithHITTypeResponse' {} a -> s {httpStatus = a} :: CreateHITWithHITTypeResponse) instance Prelude.NFData CreateHITWithHITTypeResponse where rnf CreateHITWithHITTypeResponse' {..} = Prelude.rnf hit `Prelude.seq` Prelude.rnf httpStatus