Adds one or more tags to the specified resource.
Parameters:
-
resource_arn
(AmazonResourceName)
–
The Amazon Resource Name (ARN) of the resource that you want to retrieve tags for.
-
tags
(TagList)
–
The tags to add to the specified resource. Specifying the tag key is required. You can set the value of a tag to an empty string, but you can't set the value of a tag to null.
Raises:
-
InvalidInput
–
One or more specified values aren't valid. For example, a required value might be missing, a numeric value might be outside the allowed range, or a string value might exceed length constraints.
-
ResourceNotFoundException
–
The operation can't be completed because the resource was not found.
-
TooManyTagsException
–
The list of tags on the resource is over the quota. The maximum number of tags that can be applied to a resource is 50.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Examples:
TagResource example
This example adds "Department" and "Project" tags to a resource.
>>> client.tag_resource(resource_arn='arn:aws:servicediscovery:us-east-1:123456789012:namespace/ns-ylexjili4cdxy3xm', tags=[{'Key': 'Department', 'Value': 'Engineering'}, {'Key': 'Project', 'Value': 'Zeta'}])
Source code in docs_src/capo_servicediscovery/_services/service_discovery.py
| def tag_resource(
self,
resource_arn: "capo_servicediscovery.types.amazon_resource_name.AmazonResourceName",
tags: "capo_servicediscovery.types.tag_list.TagList",
*,
config_overrides: Optional[ServiceDiscoveryClientConfig] = None,
) -> "capo_servicediscovery.types.tag_resource_response.TagResourceResponse":
"""<p>Adds one or more tags to the specified resource.</p>
Args:
resource_arn: <p>The Amazon Resource Name (ARN) of the resource that you want to retrieve tags for.</p>
tags: <p>The tags to add to the specified resource. Specifying the tag key is required. You can set the value of a tag to an empty string, but you can't set the value of a tag to null.</p>
Raises:
capo_servicediscovery.errors.invalid_input.InvalidInput: <p>One or more specified values aren't valid. For example, a required value might be missing, a numeric value might be outside the allowed range, or a string value might exceed length constraints.</p>
capo_servicediscovery.errors.resource_not_found_exception.ResourceNotFoundException: <p>The operation can't be completed because the resource was not found.</p>
capo_servicediscovery.errors.too_many_tags_exception.TooManyTagsException: <p>The list of tags on the resource is over the quota. The maximum number of tags that can be applied to a resource is 50.</p>
capo_servicediscovery.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
TagResource example
This example adds "Department" and "Project" tags to a resource.
>>> client.tag_resource(resource_arn='arn:aws:servicediscovery:us-east-1:123456789012:namespace/ns-ylexjili4cdxy3xm', tags=[{'Key': 'Department', 'Value': 'Engineering'}, {'Key': 'Project', 'Value': 'Zeta'}])
"""
def _handler(
req: "OperationRequest[capo_servicediscovery.types.tag_resource_request.TagResourceRequest]",
) -> OperationResponse[
"capo_servicediscovery.types.tag_resource_response.TagResourceResponse"
]:
import capo_servicediscovery._operations.route53_auto_naming_v20170314.tag_resource
output, http_response = (
capo_servicediscovery._operations.route53_auto_naming_v20170314.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_servicediscovery.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
|