Skip to content

associate_targets_with_job async

associate_targets_with_job(
    targets: JobTargets,
    job_id: JobId,
    *,
    config_overrides: Optional[AsyncIoTClientConfig] = None,
    comment: Optional[Comment] = None,
    namespace_id: Optional[NamespaceId] = None,
) -> AssociateTargetsWithJobResponse

Associates a group with a continuous job. The following criteria must be met:

  • The job must have been created with the targetSelection field set to "CONTINUOUS".

  • The job status must currently be "IN_PROGRESS".

  • The total number of targets associated with a job must not exceed 100.

Requires permission to access the AssociateTargetsWithJob action.

Parameters:

  • targets (JobTargets) –

    A list of thing group ARNs that define the targets of the job.

  • job_id (JobId) –

    The unique identifier you assigned to this job when it was created.

  • comment (Optional[Comment], default: None ) –

    An optional comment string describing why the job was associated with the targets.

  • 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.

Raises:

Source code in docs_src/capo_iot/_services/async_io_t.py
async def associate_targets_with_job(
    self,
    targets: "capo_iot.types.job_targets.JobTargets",
    job_id: "capo_iot.types.job_id.JobId",
    *,
    config_overrides: Optional[AsyncIoTClientConfig] = None,
    comment: Optional["capo_iot.types.comment.Comment"] = None,
    namespace_id: Optional["capo_iot.types.namespace_id.NamespaceId"] = None,
) -> "capo_iot.types.associate_targets_with_job_response.AssociateTargetsWithJobResponse":
    """<p>Associates a group with a continuous job. The following criteria must be met: </p> <ul> <li> <p>The job must have been created with the <code>targetSelection</code> field set to "CONTINUOUS".</p> </li> <li> <p>The job status must currently be "IN_PROGRESS".</p> </li> <li> <p>The total number of targets associated with a job must not exceed 100.</p> </li> </ul> <p>Requires permission to access the <a href="https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions">AssociateTargetsWithJob</a> action.</p>

    Args:
        targets: <p>A list of thing group ARNs that define the targets of the job.</p>
        job_id: <p>The unique identifier you assigned to this job when it was created.</p>
        comment: <p>An optional comment string describing why the job was associated with the targets.</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>

    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_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.associate_targets_with_job_request.AssociateTargetsWithJobRequest]",
    ) -> AsyncOperationResponse[
        "capo_iot.types.associate_targets_with_job_response.AssociateTargetsWithJobResponse"
    ]:
        import capo_iot._operations.aws_iot_service.associate_targets_with_job

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AssociateTargetsWithJob")
    )
    input_: capo_iot.types.associate_targets_with_job_request.AssociateTargetsWithJobRequest = {
        "targets": targets,
        "job_id": job_id,
    }
    if comment is not None:
        input_["comment"] = comment
    if namespace_id is not None:
        input_["namespace_id"] = namespace_id

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