Skip to content

delete_hit async

delete_hit(
    hit_id: EntityId, *, config_overrides: Optional[AsyncMTurkClientConfig] = None
) -> DeleteHITResponse

The DeleteHIT operation is used to delete HIT that is no longer needed. Only the Requester who created the HIT can delete it.

You can only dispose of HITs that are in the Reviewable state, with all of their submitted assignments already either approved or rejected. If you call the DeleteHIT operation on a HIT that is not in the Reviewable state (for example, that has not expired, or still has active assignments), or on a HIT that is Reviewable but without all of its submitted assignments already approved or rejected, the service will return an error.

  • HITs are automatically disposed of after 120 days.

  • After you dispose of a HIT, you can no longer approve the HIT's rejected assignments.

  • Disposed HITs are not returned in results for the ListHITs operation.

  • Disposing HITs can improve the performance of operations such as ListReviewableHITs and ListHITs.

Parameters:

  • hit_id (EntityId) –

    The ID of the HIT to be deleted.

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 delete_hit(
    self,
    hit_id: "capo_mturk.types.entity_id.EntityId",
    *,
    config_overrides: Optional[AsyncMTurkClientConfig] = None,
) -> "capo_mturk.types.delete_hit_response.DeleteHITResponse":
    """<p> The <code>DeleteHIT</code> operation is used to delete HIT that is no longer needed. Only the Requester who created the HIT can delete it. </p> <p> You can only dispose of HITs that are in the <code>Reviewable</code> state, with all of their submitted assignments already either approved or rejected. If you call the DeleteHIT operation on a HIT that is not in the <code>Reviewable</code> state (for example, that has not expired, or still has active assignments), or on a HIT that is Reviewable but without all of its submitted assignments already approved or rejected, the service will return an error. </p> <note> <ul> <li> <p> HITs are automatically disposed of after 120 days. </p> </li> <li> <p> After you dispose of a HIT, you can no longer approve the HIT's rejected assignments. </p> </li> <li> <p> Disposed HITs are not returned in results for the ListHITs operation. </p> </li> <li> <p> Disposing HITs can improve the performance of operations such as ListReviewableHITs and ListHITs. </p> </li> </ul> </note>

    Args:
        hit_id: <p>The ID of the HIT to be deleted.</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.delete_hit_request.DeleteHITRequest]",
    ) -> AsyncOperationResponse[
        "capo_mturk.types.delete_hit_response.DeleteHITResponse"
    ]:
        import capo_mturk._operations.m_turk_requester_service_v20170117.delete_hit

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteHIT")
    )
    input_: capo_mturk.types.delete_hit_request.DeleteHITRequest = {
        "hit_id": hit_id
    }

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