Adds specified tags to a resource with the specified ARN. Existing tags on a resource are not changed if they are not specified in the request parameters. If you specify a tag key that already exists on the resource, the value in the request replaces the existing value.
Parameters:
-
resource_arn
(AmazonResourceName)
–
The Amazon Resource Name (ARN) of the resource to add tags to. You can tag Amazon Polly lexicons and custom voices.
-
tags
(TagMap)
–
The tags to add to the resource, as key-value pairs. Tag keys can have a maximum character length of 128 characters, and tag values can have a maximum length of 256 characters.
Raises:
-
InvalidTagParameterException
–
The resource ARN or a tag in the request isn't valid. Specify the ARN of a supported resource in the Amazon Web Services account and Region of the request. Tag keys can have a maximum length of 128 characters, and tag values can have a maximum length of 256 characters. Correct the ARN or the tags, and then try again.
-
ResourceNotFoundException
–
Amazon Polly can't find the specified resource. Verify that the resource exists in the Amazon Web Services account and Region of the request and that its ARN or ID is spelled correctly, and then try again.
-
ServiceFailureException
–
An unknown condition has caused a service failure.
-
ThrottlingException
–
The request was denied because of request throttling.
-
TooManyTagsException
–
The list of tags on the resource is over the limit. The maximum number of tags that can be applied to a resource is 50. Remove unused tags or reduce the number of tags in the request, and then try again.
-
ValidationException
–
The input fails to satisfy the constraints specified by the service.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Examples:
To add tags to a lexicon
The following example adds the specified tags to a pronunciation lexicon.
>>> await client.tag_resource(resource_arn='arn:aws:polly:us-east-1:111122223333:lexicon/example', tags={'Project': 'Narration', 'Environment': 'Production'})
Source code in docs_src/capo_polly/_services/async_polly.py
| async def tag_resource(
self,
resource_arn: "capo_polly.types.amazon_resource_name.AmazonResourceName",
tags: "capo_polly.types.tag_map.TagMap",
*,
config_overrides: Optional[AsyncPollyClientConfig] = None,
) -> "capo_polly.types.tag_resource_output.TagResourceOutput":
"""<p>Adds specified tags to a resource with the specified ARN. Existing tags on a resource are not changed if they are not specified in the request parameters. If you specify a tag key that already exists on the resource, the value in the request replaces the existing value.</p>
Args:
resource_arn: <p>The Amazon Resource Name (ARN) of the resource to add tags to. You can tag Amazon Polly lexicons and custom voices.</p>
tags: <p>The tags to add to the resource, as key-value pairs. Tag keys can have a maximum character length of 128 characters, and tag values can have a maximum length of 256 characters.</p>
Raises:
capo_polly.errors.invalid_tag_parameter_exception.InvalidTagParameterException: <p>The resource ARN or a tag in the request isn't valid. Specify the ARN of a supported resource in the Amazon Web Services account and Region of the request. Tag keys can have a maximum length of 128 characters, and tag values can have a maximum length of 256 characters. Correct the ARN or the tags, and then try again.</p>
capo_polly.errors.resource_not_found_exception.ResourceNotFoundException: <p>Amazon Polly can't find the specified resource. Verify that the resource exists in the Amazon Web Services account and Region of the request and that its ARN or ID is spelled correctly, and then try again.</p>
capo_polly.errors.service_failure_exception.ServiceFailureException: <p>An unknown condition has caused a service failure.</p>
capo_polly.errors.throttling_exception.ThrottlingException: <p>The request was denied because of request throttling.</p>
capo_polly.errors.too_many_tags_exception.TooManyTagsException: <p>The list of tags on the resource is over the limit. The maximum number of tags that can be applied to a resource is 50. Remove unused tags or reduce the number of tags in the request, and then try again.</p>
capo_polly.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by the service.</p>
capo_polly.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
To add tags to a lexicon
The following example adds the specified tags to a pronunciation lexicon.
>>> await client.tag_resource(resource_arn='arn:aws:polly:us-east-1:111122223333:lexicon/example', tags={'Project': 'Narration', 'Environment': 'Production'})
"""
async def _handler(
req: "AsyncOperationRequest[capo_polly.types.tag_resource_input.TagResourceInput]",
) -> AsyncOperationResponse[
"capo_polly.types.tag_resource_output.TagResourceOutput"
]:
import capo_polly._operations.parrot_v1.tag_resource
(
output,
http_response,
) = await capo_polly._operations.parrot_v1.tag_resource.async_tag_resource(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("TagResource")
)
input_: capo_polly.types.tag_resource_input.TagResourceInput = {
"resource_arn": resource_arn,
"tags": tags,
}
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|