Skip to content

cancel_enrichment_job async

cancel_enrichment_job(
    workspace_name: WorkspaceName,
    job_id: ID,
    *,
    config_overrides: Optional[AsyncIoTSiteWiseClientConfig] = None,
) -> CancelEnrichmentJobResponse

Cancels a running or pending enrichment job. This is an idempotent operation—calling it multiple times with the same jobId is safe and returns the current status.

Behavior

  • Jobs in PENDING or RUNNING status transition to CANCELLED
  • Jobs in RUNNING state may not be cancellable once they have progressed to certain processing stages
  • Jobs already in terminal states (COMPLETED, FAILED, TIMED_OUT) cannot be cancelled; the operation returns a ConflictingOperationException
  • Cancelling an already-CANCELLED job is a no-op and returns the current status (idempotent behavior)
  • The API responds immediately after recording the cancellation
  • Cleanup of job resources happens asynchronously in the background

When to Cancel

Cancel a job when:

  • The job is taking longer than expected
  • The job was created with incorrect parameters
  • You no longer need the results

Idempotency

You can safely retry cancellation requests. Calling CancelEnrichmentJob multiple times for the same job returns the current status without error as long as the job is not in a terminal state other than CANCELLED.

Parameters:

  • workspace_name (WorkspaceName) –

    The name of the IoT SiteWise workspace containing the enrichment job to cancel.

  • job_id (ID) –

    The unique identifier of the enrichment job to cancel. This is the jobId returned by CreateEnrichmentJob.

Raises:

  • AccessDeniedException –

    Access is denied.

  • ConflictingOperationException –

    Your request has conflicting operations. This can occur if you're trying to perform more than one operation on the same resource at the same time.

  • InternalFailureException –

    IoT SiteWise can't process your request right now. Try again later.

  • InvalidRequestException –

    The request isn't valid. This can occur if your request contains malformed JSON or unsupported characters. Check your request and try again.

  • LimitExceededException –

    You've reached the quota for a resource. For example, this can occur if you're trying to associate more than the allowed number of child assets or attempting to create more than the allowed number of properties for an asset model.

    For more information, see Quotas in the IoT SiteWise User Guide.

  • ResourceNotFoundException –

    The requested resource can't be found.

  • ThrottlingException –

    Your request exceeded a rate limit. For example, you might have exceeded the number of IoT SiteWise assets that can be created per second, the allowed number of messages per second, and so on.

    For more information, see Quotas in the IoT SiteWise User Guide.

  • UnknownServiceError –

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

Source code in docs_src/capo_iotsitewise/_services/async_io_t_site_wise.py
async def cancel_enrichment_job(
    self,
    workspace_name: "capo_iotsitewise.types.workspace_name.WorkspaceName",
    job_id: "capo_iotsitewise.types.id.ID",
    *,
    config_overrides: Optional[AsyncIoTSiteWiseClientConfig] = None,
) -> "capo_iotsitewise.types.cancel_enrichment_job_response.CancelEnrichmentJobResponse":
    """<p>Cancels a running or pending enrichment job. This is an idempotent operation—calling it multiple times with the same jobId is safe and returns the current status.</p> <h2>Behavior</h2> <ul> <li>Jobs in PENDING or RUNNING status transition to CANCELLED</li> <li>Jobs in RUNNING state may not be cancellable once they have progressed to certain processing stages</li> <li>Jobs already in terminal states (COMPLETED, FAILED, TIMED_OUT) cannot be cancelled; the operation returns a ConflictingOperationException</li> <li>Cancelling an already-CANCELLED job is a no-op and returns the current status (idempotent behavior)</li> <li>The API responds immediately after recording the cancellation</li> <li>Cleanup of job resources happens asynchronously in the background</li> </ul> <h2>When to Cancel</h2> <p>Cancel a job when:</p> <ul> <li>The job is taking longer than expected</li> <li>The job was created with incorrect parameters</li> <li>You no longer need the results</li> </ul> <h2>Idempotency</h2> <p>You can safely retry cancellation requests. Calling CancelEnrichmentJob multiple times for the same job returns the current status without error as long as the job is not in a terminal state other than CANCELLED.</p>

    Args:
        workspace_name: <p>The name of the IoT SiteWise workspace containing the enrichment job to cancel.</p>
        job_id: <p>The unique identifier of the enrichment job to cancel. This is the jobId returned by CreateEnrichmentJob.</p>

    Raises:
        capo_iotsitewise.errors.access_denied_exception.AccessDeniedException: <p>Access is denied.</p>
        capo_iotsitewise.errors.conflicting_operation_exception.ConflictingOperationException: <p>Your request has conflicting operations. This can occur if you're trying to perform more than one operation on the same resource at the same time.</p>
        capo_iotsitewise.errors.internal_failure_exception.InternalFailureException: <p>IoT SiteWise can't process your request right now. Try again later.</p>
        capo_iotsitewise.errors.invalid_request_exception.InvalidRequestException: <p>The request isn't valid. This can occur if your request contains malformed JSON or unsupported characters. Check your request and try again.</p>
        capo_iotsitewise.errors.limit_exceeded_exception.LimitExceededException: <p>You've reached the quota for a resource. For example, this can occur if you're trying to associate more than the allowed number of child assets or attempting to create more than the allowed number of properties for an asset model.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/iot-sitewise/latest/userguide/quotas.html">Quotas</a> in the <i>IoT SiteWise User Guide</i>.</p>
        capo_iotsitewise.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource can't be found.</p>
        capo_iotsitewise.errors.throttling_exception.ThrottlingException: <p>Your request exceeded a rate limit. For example, you might have exceeded the number of IoT SiteWise assets that can be created per second, the allowed number of messages per second, and so on.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/iot-sitewise/latest/userguide/quotas.html">Quotas</a> in the <i>IoT SiteWise User Guide</i>.</p>
        capo_iotsitewise.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_iotsitewise.types.cancel_enrichment_job_request.CancelEnrichmentJobRequest]",
    ) -> AsyncOperationResponse[
        "capo_iotsitewise.types.cancel_enrichment_job_response.CancelEnrichmentJobResponse"
    ]:
        import capo_iotsitewise._operations.aws_io_t_site_wise.cancel_enrichment_job

        (
            output,
            http_response,
        ) = await capo_iotsitewise._operations.aws_io_t_site_wise.cancel_enrichment_job.async_cancel_enrichment_job(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CancelEnrichmentJob")
    )
    input_: capo_iotsitewise.types.cancel_enrichment_job_request.CancelEnrichmentJobRequest = {
        "workspace_name": workspace_name,
        "job_id": job_id,
    }

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