Adds one or more tags to a resource.
Parameters:
-
resource_arn
(ResourceArn)
–
The ARN of the resource to apply the tags to.
-
tags
(Optional[TagMap], default:
None
)
–
The tags to add to the resource. You can add up to 50 tags at a time. The tag keys can be no longer than 128 characters. The tag values can be no longer than 256 characters.
Raises:
Examples:
To tag a resource
The following example adds the 'Department' and 'Area' tags to the specified resource.
>>> await client.tag_resource(resource_arn='arn:aws:securityhub:us-west-1:123456789012:hub/default', tags={'Department': 'Operations', 'Area': 'USMidwest'})
Source code in docs_src/capo_securityhub/_services/async_security_hub.py
| async def tag_resource(
self,
resource_arn: "capo_securityhub.types.resource_arn.ResourceArn",
*,
config_overrides: Optional[AsyncSecurityHubClientConfig] = None,
tags: Optional["capo_securityhub.types.tag_map.TagMap"] = None,
) -> "capo_securityhub.types.tag_resource_response.TagResourceResponse":
"""<p>Adds one or more tags to a resource.</p>
Args:
resource_arn: <p>The ARN of the resource to apply the tags to.</p>
tags: <p>The tags to add to the resource. You can add up to 50 tags at a time. The tag keys can be no longer than 128 characters. The tag values can be no longer than 256 characters.</p>
Raises:
capo_securityhub.errors.internal_exception.InternalException: <p>Internal server error.</p>
capo_securityhub.errors.invalid_input_exception.InvalidInputException: <p>The request was rejected because you supplied an invalid or out-of-range value for an input parameter.</p>
capo_securityhub.errors.resource_not_found_exception.ResourceNotFoundException: <p>The request was rejected because we can't find the specified resource.</p>
capo_securityhub.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
To tag a resource
The following example adds the 'Department' and 'Area' tags to the specified resource.
>>> await client.tag_resource(resource_arn='arn:aws:securityhub:us-west-1:123456789012:hub/default', tags={'Department': 'Operations', 'Area': 'USMidwest'})
"""
async def _handler(
req: "AsyncOperationRequest[capo_securityhub.types.tag_resource_request.TagResourceRequest]",
) -> AsyncOperationResponse[
"capo_securityhub.types.tag_resource_response.TagResourceResponse"
]:
import capo_securityhub._operations.security_hub_api_service.tag_resource
(
output,
http_response,
) = await capo_securityhub._operations.security_hub_api_service.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_securityhub.types.tag_resource_request.TagResourceRequest = {
"resource_arn": resource_arn
}
if tags is not None:
input_["tags"] = tags
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|