Skip to content

create_additional_assignments_for_hit async

create_additional_assignments_for_hit(
    hit_id: EntityId,
    number_of_additional_assignments: Integer,
    *,
    config_overrides: Optional[AsyncMTurkClientConfig] = None,
    unique_request_token: Optional[IdempotencyToken] = None,
) -> CreateAdditionalAssignmentsForHITResponse

The CreateAdditionalAssignmentsForHIT operation increases the maximum number of assignments of an existing HIT.

To extend the maximum number of assignments, specify the number of additional assignments.

  • HITs created with fewer than 10 assignments cannot be extended to have 10 or more assignments. Attempting to add assignments in a way that brings the total number of assignments for a HIT from fewer than 10 assignments to 10 or more assignments will result in an AWS.MechanicalTurk.InvalidMaximumAssignmentsIncrease exception.

  • HITs that were created before July 22, 2015 cannot be extended. Attempting to extend HITs that were created before July 22, 2015 will result in an AWS.MechanicalTurk.HITTooOldForExtension exception.

Parameters:

  • hit_id (EntityId) –

    The ID of the HIT to extend.

  • number_of_additional_assignments (Integer) –

    The number of additional assignments to request for this HIT.

  • unique_request_token (Optional[IdempotencyToken], default: None ) –

    A unique identifier for this request, which allows you to retry the call on error without extending the HIT multiple times. This is useful in cases such as network timeouts where it is unclear whether or not the call succeeded on the server. If the extend HIT already exists in the system from a previous call using the same UniqueRequestToken, subsequent calls will return an error with a message containing the request ID.

Raises:

  • RequestError –

    Your request is invalid.

  • ServiceFault –

    Amazon Mechanical Turk is temporarily unable to process your request. Try your call again.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_mturk/_services/async_m_turk.py
async def create_additional_assignments_for_hit(
    self,
    hit_id: "capo_mturk.types.entity_id.EntityId",
    number_of_additional_assignments: "capo_mturk.types.integer.Integer",
    *,
    config_overrides: Optional[AsyncMTurkClientConfig] = None,
    unique_request_token: Optional[
        "capo_mturk.types.idempotency_token.IdempotencyToken"
    ] = None,
) -> "capo_mturk.types.create_additional_assignments_for_hit_response.CreateAdditionalAssignmentsForHITResponse":
    """<p> The <code>CreateAdditionalAssignmentsForHIT</code> operation increases the maximum number of assignments of an existing HIT. </p> <p> To extend the maximum number of assignments, specify the number of additional assignments.</p> <note> <ul> <li> <p>HITs created with fewer than 10 assignments cannot be extended to have 10 or more assignments. Attempting to add assignments in a way that brings the total number of assignments for a HIT from fewer than 10 assignments to 10 or more assignments will result in an <code>AWS.MechanicalTurk.InvalidMaximumAssignmentsIncrease</code> exception.</p> </li> <li> <p>HITs that were created before July 22, 2015 cannot be extended. Attempting to extend HITs that were created before July 22, 2015 will result in an <code>AWS.MechanicalTurk.HITTooOldForExtension</code> exception. </p> </li> </ul> </note>

    Args:
        hit_id: <p>The ID of the HIT to extend.</p>
        number_of_additional_assignments: <p>The number of additional assignments to request for this HIT.</p>
        unique_request_token: <p> A unique identifier for this request, which allows you to retry the call on error without extending the HIT multiple times. This is useful in cases such as network timeouts where it is unclear whether or not the call succeeded on the server. If the extend HIT already exists in the system from a previous call using the same <code>UniqueRequestToken</code>, subsequent calls will return an error with a message containing the request ID. </p>

    Raises:
        capo_mturk.errors.request_error.RequestError: <p>Your request is invalid.</p>
        capo_mturk.errors.service_fault.ServiceFault: <p>Amazon Mechanical Turk is temporarily unable to process your request. Try your call again.</p>
        capo_mturk.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_mturk.types.create_additional_assignments_for_hit_request.CreateAdditionalAssignmentsForHITRequest]",
    ) -> AsyncOperationResponse[
        "capo_mturk.types.create_additional_assignments_for_hit_response.CreateAdditionalAssignmentsForHITResponse"
    ]:
        import capo_mturk._operations.m_turk_requester_service_v20170117.create_additional_assignments_for_hit

        (
            output,
            http_response,
        ) = await capo_mturk._operations.m_turk_requester_service_v20170117.create_additional_assignments_for_hit.async_create_additional_assignments_for_hit(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateAdditionalAssignmentsForHIT")
    )
    input_: capo_mturk.types.create_additional_assignments_for_hit_request.CreateAdditionalAssignmentsForHITRequest = {
        "hit_id": hit_id,
        "number_of_additional_assignments": number_of_additional_assignments,
    }
    if unique_request_token is not None:
        input_["unique_request_token"] = unique_request_token

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output