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.
>>> 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/security_hub.py
| def tag_resource(
self,
resource_arn: "capo_securityhub.types.resource_arn.ResourceArn",
*,
config_overrides: Optional[SecurityHubClientConfig] = 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.
>>> client.tag_resource(resource_arn='arn:aws:securityhub:us-west-1:123456789012:hub/default', tags={'Department': 'Operations', 'Area': 'USMidwest'})
"""
def _handler(
req: "OperationRequest[capo_securityhub.types.tag_resource_request.TagResourceRequest]",
) -> OperationResponse[
"capo_securityhub.types.tag_resource_response.TagResourceResponse"
]:
import capo_securityhub._operations.security_hub_api_service.tag_resource
output, http_response = (
capo_securityhub._operations.security_hub_api_service.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_securityhub.types.tag_resource_request.TagResourceRequest = {
"resource_arn": resource_arn
}
if tags is not None:
input_["tags"] = tags
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|