Skip to content

tag_resource

tag_resource(
    resource_arn: DeviceFarmArn,
    tags: TagList,
    *,
    config_overrides: Optional[DeviceFarmClientConfig] = None,
) -> TagResourceResponse

Associates the specified tags to a resource with the specified resourceArn. If existing tags on a resource are not specified in the request parameters, they are not changed. When a resource is deleted, the tags associated with that resource are also deleted.

Parameters:

  • resource_arn (DeviceFarmArn) –

    The Amazon Resource Name (ARN) of the resource or resources to which to add tags. You can associate tags with the following Device Farm resources: PROJECT, TESTGRID_PROJECT, RUN, NETWORK_PROFILE, INSTANCE_PROFILE, DEVICE_INSTANCE, SESSION, DEVICE_POOL, DEVICE, and VPCE_CONFIGURATION.

  • tags (TagList) –

    The tags to add to the resource. A tag is an array of key-value pairs. Tag keys can have a maximum character length of 128 characters. Tag values can have a maximum length of 256 characters.

Raises:

  • ArgumentException –

    An invalid argument was specified.

  • NotFoundException –

    The specified entity was not found.

  • TagOperationException –

    The operation was not successful. Try again.

  • TagPolicyException –

    The request doesn't comply with the AWS Identity and Access Management (IAM) tag policy. Correct your request and then retry it.

  • TooManyTagsException –

    The list of tags on the repository is over the limit. The maximum number of tags that can be applied to a repository is 50.

  • UnknownServiceError –

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

Source code in docs_src/capo_device_farm/_services/device_farm.py
def tag_resource(
    self,
    resource_arn: "capo_device_farm.types.device_farm_arn.DeviceFarmArn",
    tags: "capo_device_farm.types.tag_list.TagList",
    *,
    config_overrides: Optional[DeviceFarmClientConfig] = None,
) -> "capo_device_farm.types.tag_resource_response.TagResourceResponse":
    """<p>Associates the specified tags to a resource with the specified <code>resourceArn</code>. If existing tags on a resource are not specified in the request parameters, they are not changed. When a resource is deleted, the tags associated with that resource are also deleted.</p>

    Args:
        resource_arn: <p>The Amazon Resource Name (ARN) of the resource or resources to which to add tags. You can associate tags with the following Device Farm resources: <code>PROJECT</code>, <code>TESTGRID_PROJECT</code>, <code>RUN</code>, <code>NETWORK_PROFILE</code>, <code>INSTANCE_PROFILE</code>, <code>DEVICE_INSTANCE</code>, <code>SESSION</code>, <code>DEVICE_POOL</code>, <code>DEVICE</code>, and <code>VPCE_CONFIGURATION</code>.</p>
        tags: <p>The tags to add to the resource. A tag is an array of key-value pairs. Tag keys can have a maximum character length of 128 characters. Tag values can have a maximum length of 256 characters.</p>

    Raises:
        capo_device_farm.errors.argument_exception.ArgumentException: <p>An invalid argument was specified.</p>
        capo_device_farm.errors.not_found_exception.NotFoundException: <p>The specified entity was not found.</p>
        capo_device_farm.errors.tag_operation_exception.TagOperationException: <p>The operation was not successful. Try again.</p>
        capo_device_farm.errors.tag_policy_exception.TagPolicyException: <p>The request doesn't comply with the AWS Identity and Access Management (IAM) tag policy. Correct your request and then retry it.</p>
        capo_device_farm.errors.too_many_tags_exception.TooManyTagsException: <p>The list of tags on the repository is over the limit. The maximum number of tags that can be applied to a repository is 50. </p>
        capo_device_farm.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_device_farm.types.tag_resource_request.TagResourceRequest]",
    ) -> OperationResponse[
        "capo_device_farm.types.tag_resource_response.TagResourceResponse"
    ]:
        import capo_device_farm._operations.device_farm_20150623.tag_resource

        output, http_response = (
            capo_device_farm._operations.device_farm_20150623.tag_resource.tag_resource(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("TagResource")
    )
    input_: capo_device_farm.types.tag_resource_request.TagResourceRequest = {
        "resource_arn": resource_arn,
        "tags": tags,
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output