Skip to content

create_job async

create_job(
    job_id: JobId,
    targets: JobTargets,
    *,
    config_overrides: Optional[AsyncIoTClientConfig] = None,
    document_source: Optional[JobDocumentSource] = None,
    document: Optional[JobDocument] = None,
    description: Optional[JobDescription] = None,
    presigned_url_config: Optional[PresignedUrlConfig] = None,
    target_selection: Optional[TargetSelection] = None,
    job_executions_rollout_config: Optional[JobExecutionsRolloutConfig] = None,
    abort_config: Optional[AbortConfig] = None,
    timeout_config: Optional[TimeoutConfig] = None,
    tags: Optional[TagList] = None,
    namespace_id: Optional[NamespaceId] = None,
    job_template_arn: Optional[JobTemplateArn] = None,
    job_executions_retry_config: Optional[JobExecutionsRetryConfig] = None,
    document_parameters: Optional[ParameterMap] = None,
    scheduling_config: Optional[SchedulingConfig] = None,
    destination_package_versions: Optional[DestinationPackageVersions] = None,
) -> CreateJobResponse

Creates a job.

Requires permission to access the CreateJob action.

Parameters:

  • job_id (JobId) –

    A job identifier which must be unique for your account. We recommend using a UUID. Alpha-numeric characters, "-" and "_" are valid for use here.

  • targets (JobTargets) –

    A list of things and thing groups to which the job should be sent.

  • document_source (Optional[JobDocumentSource], default: None ) –

    An S3 link, or S3 object URL, to the job document. The link is an Amazon S3 object URL and is required if you don't specify a value for document.

    For example, --document-source https://s3.region-code.amazonaws.com/example-firmware/device-firmware.1.0

    For more information, see Methods for accessing a bucket.

  • document (Optional[JobDocument], default: None ) –

    The job document. Required if you don't specify a value for documentSource.

  • description (Optional[JobDescription], default: None ) –

    A short text description of the job.

  • presigned_url_config (Optional[PresignedUrlConfig], default: None ) –

    Configuration information for pre-signed S3 URLs.

  • target_selection (Optional[TargetSelection], default: None ) –

    Specifies whether the job will continue to run (CONTINUOUS), or will be complete after all those things specified as targets have completed the job (SNAPSHOT). If continuous, the job may also be run on a thing when a change is detected in a target. For example, a job will run on a thing when the thing is added to a target group, even after the job was completed by all things originally in the group.

    We recommend that you use continuous jobs instead of snapshot jobs for dynamic thing group targets. By using continuous jobs, devices that join the group receive the job execution even after the job has been created.

  • job_executions_rollout_config (Optional[JobExecutionsRolloutConfig], default: None ) –

    Allows you to create a staged rollout of the job.

  • abort_config (Optional[AbortConfig], default: None ) –

    Allows you to create the criteria to abort a job.

  • timeout_config (Optional[TimeoutConfig], default: None ) –

    Specifies the amount of time each device has to finish its execution of the job. The timer is started when the job execution status is set to IN_PROGRESS. If the job execution status is not set to another terminal state before the time expires, it will be automatically set to TIMED_OUT.

  • tags (Optional[TagList], default: None ) –

    Metadata which can be used to manage the job.

  • namespace_id (Optional[NamespaceId], default: None ) –

    The namespace used to indicate that a job is a customer-managed job.

    When you specify a value for this parameter, Amazon Web Services IoT Core sends jobs notifications to MQTT topics that contain the value in the following format.

    $aws/things/THING_NAME/jobs/JOB_ID/notify-namespace-NAMESPACE_ID/

    The namespaceId feature is only supported by IoT Greengrass at this time. For more information, see Setting up IoT Greengrass core devices.

  • job_template_arn (Optional[JobTemplateArn], default: None ) –

    The ARN of the job template used to create the job.

  • job_executions_retry_config (Optional[JobExecutionsRetryConfig], default: None ) –

    Allows you to create the criteria to retry a job.

  • document_parameters (Optional[ParameterMap], default: None ) –

    Parameters of an Amazon Web Services managed template that you can specify to create the job document.

    documentParameters can only be used when creating jobs from Amazon Web Services managed templates. This parameter can't be used with custom job templates or to create jobs from them.

  • scheduling_config (Optional[SchedulingConfig], default: None ) –

    The configuration that allows you to schedule a job for a future date and time in addition to specifying the end behavior for each job execution.

  • destination_package_versions (Optional[DestinationPackageVersions], default: None ) –

    The package version Amazon Resource Names (ARNs) that are installed on the device when the job successfully completes. The package version must be in either the Published or Deprecated state when the job deploys. For more information, see Package version lifecycle.

    Note:The following Length Constraints relates to a single ARN. Up to 25 package version ARNs are allowed.

Raises:

Source code in docs_src/capo_iot/_services/async_io_t.py
async def create_job(
    self,
    job_id: "capo_iot.types.job_id.JobId",
    targets: "capo_iot.types.job_targets.JobTargets",
    *,
    config_overrides: Optional[AsyncIoTClientConfig] = None,
    document_source: Optional[
        "capo_iot.types.job_document_source.JobDocumentSource"
    ] = None,
    document: Optional["capo_iot.types.job_document.JobDocument"] = None,
    description: Optional["capo_iot.types.job_description.JobDescription"] = None,
    presigned_url_config: Optional[
        "capo_iot.types.presigned_url_config.PresignedUrlConfig"
    ] = None,
    target_selection: Optional[
        "capo_iot.types.target_selection.TargetSelection"
    ] = None,
    job_executions_rollout_config: Optional[
        "capo_iot.types.job_executions_rollout_config.JobExecutionsRolloutConfig"
    ] = None,
    abort_config: Optional["capo_iot.types.abort_config.AbortConfig"] = None,
    timeout_config: Optional["capo_iot.types.timeout_config.TimeoutConfig"] = None,
    tags: Optional["capo_iot.types.tag_list.TagList"] = None,
    namespace_id: Optional["capo_iot.types.namespace_id.NamespaceId"] = None,
    job_template_arn: Optional[
        "capo_iot.types.job_template_arn.JobTemplateArn"
    ] = None,
    job_executions_retry_config: Optional[
        "capo_iot.types.job_executions_retry_config.JobExecutionsRetryConfig"
    ] = None,
    document_parameters: Optional[
        "capo_iot.types.parameter_map.ParameterMap"
    ] = None,
    scheduling_config: Optional[
        "capo_iot.types.scheduling_config.SchedulingConfig"
    ] = None,
    destination_package_versions: Optional[
        "capo_iot.types.destination_package_versions.DestinationPackageVersions"
    ] = None,
) -> "capo_iot.types.create_job_response.CreateJobResponse":
    """<p>Creates a job.</p> <p>Requires permission to access the <a href="https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions">CreateJob</a> action.</p>

    Args:
        job_id: <p>A job identifier which must be unique for your account. We recommend using a UUID. Alpha-numeric characters, "-" and "_" are valid for use here.</p>
        targets: <p>A list of things and thing groups to which the job should be sent.</p>
        document_source: <p>An S3 link, or S3 object URL, to the job document. The link is an Amazon S3 object URL and is required if you don't specify a value for <code>document</code>.</p> <p>For example, <code>--document-source https://s3.<i>region-code</i>.amazonaws.com/example-firmware/device-firmware.1.0</code> </p> <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-bucket-intro.html">Methods for accessing a bucket</a>.</p>
        document: <p>The job document. Required if you don't specify a value for <code>documentSource</code>.</p>
        description: <p>A short text description of the job.</p>
        presigned_url_config: <p>Configuration information for pre-signed S3 URLs.</p>
        target_selection: <p>Specifies whether the job will continue to run (CONTINUOUS), or will be complete after all those things specified as targets have completed the job (SNAPSHOT). If continuous, the job may also be run on a thing when a change is detected in a target. For example, a job will run on a thing when the thing is added to a target group, even after the job was completed by all things originally in the group.</p> <note> <p>We recommend that you use continuous jobs instead of snapshot jobs for dynamic thing group targets. By using continuous jobs, devices that join the group receive the job execution even after the job has been created.</p> </note>
        job_executions_rollout_config: <p>Allows you to create a staged rollout of the job.</p>
        abort_config: <p>Allows you to create the criteria to abort a job.</p>
        timeout_config: <p>Specifies the amount of time each device has to finish its execution of the job. The timer is started when the job execution status is set to <code>IN_PROGRESS</code>. If the job execution status is not set to another terminal state before the time expires, it will be automatically set to <code>TIMED_OUT</code>.</p>
        tags: <p>Metadata which can be used to manage the job.</p>
        namespace_id: <p>The namespace used to indicate that a job is a customer-managed job.</p> <p>When you specify a value for this parameter, Amazon Web Services IoT Core sends jobs notifications to MQTT topics that contain the value in the following format.</p> <p> <code>$aws/things/<i>THING_NAME</i>/jobs/<i>JOB_ID</i>/notify-namespace-<i>NAMESPACE_ID</i>/</code> </p> <note> <p>The <code>namespaceId</code> feature is only supported by IoT Greengrass at this time. For more information, see <a href="https://docs.aws.amazon.com/greengrass/v2/developerguide/setting-up.html">Setting up IoT Greengrass core devices.</a> </p> </note>
        job_template_arn: <p>The ARN of the job template used to create the job.</p>
        job_executions_retry_config: <p>Allows you to create the criteria to retry a job.</p>
        document_parameters: <p>Parameters of an Amazon Web Services managed template that you can specify to create the job document.</p> <note> <p> <code>documentParameters</code> can only be used when creating jobs from Amazon Web Services managed templates. This parameter can't be used with custom job templates or to create jobs from them.</p> </note>
        scheduling_config: <p>The configuration that allows you to schedule a job for a future date and time in addition to specifying the end behavior for each job execution.</p>
        destination_package_versions: <p>The package version Amazon Resource Names (ARNs) that are installed on the device when the job successfully completes. The package version must be in either the Published or Deprecated state when the job deploys. For more information, see <a href="https://docs.aws.amazon.com/iot/latest/developerguide/preparing-to-use-software-package-catalog.html#package-version-lifecycle">Package version lifecycle</a>. </p> <p> <b>Note:</b>The following Length Constraints relates to a single ARN. Up to 25 package version ARNs are allowed.</p>

    Raises:
        capo_iot.errors.invalid_request_exception.InvalidRequestException: <p>The request is not valid.</p>
        capo_iot.errors.limit_exceeded_exception.LimitExceededException: <p>A limit has been exceeded.</p>
        capo_iot.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>The resource already exists.</p>
        capo_iot.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
        capo_iot.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service is temporarily unavailable.</p>
        capo_iot.errors.throttling_exception.ThrottlingException: <p>The rate exceeds the limit.</p>
        capo_iot.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_iot.types.create_job_request.CreateJobRequest]",
    ) -> AsyncOperationResponse[
        "capo_iot.types.create_job_response.CreateJobResponse"
    ]:
        import capo_iot._operations.aws_iot_service.create_job

        (
            output,
            http_response,
        ) = await capo_iot._operations.aws_iot_service.create_job.async_create_job(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateJob")
    )
    input_: capo_iot.types.create_job_request.CreateJobRequest = {
        "job_id": job_id,
        "targets": targets,
    }
    if document_source is not None:
        input_["document_source"] = document_source
    if document is not None:
        input_["document"] = document
    if description is not None:
        input_["description"] = description
    if presigned_url_config is not None:
        input_["presigned_url_config"] = presigned_url_config
    if target_selection is not None:
        input_["target_selection"] = target_selection
    if job_executions_rollout_config is not None:
        input_["job_executions_rollout_config"] = job_executions_rollout_config
    if abort_config is not None:
        input_["abort_config"] = abort_config
    if timeout_config is not None:
        input_["timeout_config"] = timeout_config
    if tags is not None:
        input_["tags"] = tags
    if namespace_id is not None:
        input_["namespace_id"] = namespace_id
    if job_template_arn is not None:
        input_["job_template_arn"] = job_template_arn
    if job_executions_retry_config is not None:
        input_["job_executions_retry_config"] = job_executions_retry_config
    if document_parameters is not None:
        input_["document_parameters"] = document_parameters
    if scheduling_config is not None:
        input_["scheduling_config"] = scheduling_config
    if destination_package_versions is not None:
        input_["destination_package_versions"] = destination_package_versions

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