Skip to content

cancel_export_job_v2 async

cancel_export_job_v2(
    export_job_id: ExportJobId,
    *,
    config_overrides: Optional[AsyncSecurityHubClientConfig] = None,
) -> CancelExportJobV2Response

Cancels a findings export job that is in progress. Security Hub transitions a running job to the CANCELLED state and returns the ExportJobId and its new Status. Canceling a job that is already in the CANCELLED state succeeds and returns the same result, so you can safely retry a cancel request.

You can't cancel an export job that has already reached a terminal SUCCEEDED or FAILED state; in that case, this operation returns a ConflictException. If no export job matches the ExportJobId that you provide, this operation returns a ResourceNotFoundException.

The Status value returned by this operation reflects the cancellation immediately, even though the job can take a short time to stop completely.

Parameters:

  • export_job_id (ExportJobId) –

    The unique identifier of the export job to cancel. This is the value returned by StartExportJobV2.

Raises:

Examples:

Example – Canceling a running export job The following example cancels an export job that is in progress. Security Hub transitions the job to the CANCELLED state and returns its new status.

>>> await client.cancel_export_job_v2(export_job_id='a1b2c3d4e5f6')
Source code in docs_src/capo_securityhub/_services/async_security_hub.py
async def cancel_export_job_v2(
    self,
    export_job_id: "capo_securityhub.types.export_job_id.ExportJobId",
    *,
    config_overrides: Optional[AsyncSecurityHubClientConfig] = None,
) -> (
    "capo_securityhub.types.cancel_export_job_v2_response.CancelExportJobV2Response"
):
    """<p>Cancels a findings export job that is in progress. Security Hub transitions a running job to the <code>CANCELLED</code> state and returns the <code>ExportJobId</code> and its new <code>Status</code>. Canceling a job that is already in the <code>CANCELLED</code> state succeeds and returns the same result, so you can safely retry a cancel request.</p> <p>You can't cancel an export job that has already reached a terminal <code>SUCCEEDED</code> or <code>FAILED</code> state; in that case, this operation returns a <code>ConflictException</code>. If no export job matches the <code>ExportJobId</code> that you provide, this operation returns a <code>ResourceNotFoundException</code>.</p> <p>The <code>Status</code> value returned by this operation reflects the cancellation immediately, even though the job can take a short time to stop completely.</p>

    Args:
        export_job_id: <p>The unique identifier of the export job to cancel. This is the value returned by <code>StartExportJobV2</code>.</p>

    Raises:
        capo_securityhub.errors.access_denied_exception.AccessDeniedException: <p>You don't have permission to perform the action specified in the request.</p>
        capo_securityhub.errors.conflict_exception.ConflictException: <p>The request causes conflict with the current state of the service resource.</p>
        capo_securityhub.errors.internal_server_exception.InternalServerException: <p> The request has failed due to an internal failure of the service. </p>
        capo_securityhub.errors.resource_not_found_exception.ResourceNotFoundException: <p>The request was rejected because we can't find the specified resource.</p>
        capo_securityhub.errors.throttling_exception.ThrottlingException: <p> The limit on the number of requests per second was exceeded. </p>
        capo_securityhub.errors.validation_exception.ValidationException: <p>The request has failed validation because it's missing required fields or has invalid inputs.</p>
        capo_securityhub.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Example – Canceling a running export job
        The following example cancels an export job that is in progress. Security Hub transitions the job to the CANCELLED state and returns its new status.

        >>> await client.cancel_export_job_v2(export_job_id='a1b2c3d4e5f6')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_securityhub.types.cancel_export_job_v2_request.CancelExportJobV2Request]",
    ) -> AsyncOperationResponse[
        "capo_securityhub.types.cancel_export_job_v2_response.CancelExportJobV2Response"
    ]:
        import capo_securityhub._operations.security_hub_api_service.cancel_export_job_v2

        (
            output,
            http_response,
        ) = await capo_securityhub._operations.security_hub_api_service.cancel_export_job_v2.async_cancel_export_job_v2(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CancelExportJobV2")
    )
    input_: capo_securityhub.types.cancel_export_job_v2_request.CancelExportJobV2Request = {
        "export_job_id": export_job_id
    }

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