Skip to content

tag_resource

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

Associates a specific tag with an Amazon Comprehend resource. A tag is a key-value pair that adds as a metadata to a resource used by Amazon Comprehend. For example, a tag with "Sales" as the key might be added to a resource to indicate its use by the sales department.

Parameters:

  • resource_arn (ComprehendArn) –

    The Amazon Resource Name (ARN) of the given Amazon Comprehend resource to which you want to associate the tags.

  • tags (TagList) –

    Tags being associated with a specific Amazon Comprehend resource. There can be a maximum of 50 tags (both existing and pending) associated with a specific resource.

Raises:

Source code in docs_src/capo_comprehend/_services/comprehend.py
def tag_resource(
    self,
    resource_arn: "capo_comprehend.types.comprehend_arn.ComprehendArn",
    tags: "capo_comprehend.types.tag_list.TagList",
    *,
    config_overrides: Optional[ComprehendClientConfig] = None,
) -> "capo_comprehend.types.tag_resource_response.TagResourceResponse":
    """<p>Associates a specific tag with an Amazon Comprehend resource. A tag is a key-value pair that adds as a metadata to a resource used by Amazon Comprehend. For example, a tag with "Sales" as the key might be added to a resource to indicate its use by the sales department. </p>

    Args:
        resource_arn: <p>The Amazon Resource Name (ARN) of the given Amazon Comprehend resource to which you want to associate the tags. </p>
        tags: <p>Tags being associated with a specific Amazon Comprehend resource. There can be a maximum of 50 tags (both existing and pending) associated with a specific resource. </p>

    Raises:
        capo_comprehend.errors.concurrent_modification_exception.ConcurrentModificationException: <p>Concurrent modification of the tags associated with an Amazon Comprehend resource is not supported. </p>
        capo_comprehend.errors.internal_server_exception.InternalServerException: <p>An internal server error occurred. Retry your request.</p>
        capo_comprehend.errors.invalid_request_exception.InvalidRequestException: <p>The request is invalid.</p>
        capo_comprehend.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource ARN was not found. Check the ARN and try your request again.</p>
        capo_comprehend.errors.too_many_tags_exception.TooManyTagsException: <p>The request contains more tags than can be associated with a resource (50 tags per resource). The maximum number of tags includes both existing tags and those included in your current request. </p>
        capo_comprehend.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

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

        output, http_response = (
            capo_comprehend._operations.comprehend_20171127.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_comprehend.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