Associates the specified tags to a resource with the specified resourceArn. If existing tags on a resource aren't specified in the request parameters, they aren't changed. When a resource is deleted, the tags that are associated with that resource are deleted as well. Batch resources that support tags are compute environments, jobs, job definitions, job queues, and scheduling policies. ARNs for child jobs of array and multi-node parallel (MNP) jobs aren't supported.
Parameters:
-
resource_arn
(String)
–
The Amazon Resource Name (ARN) of the resource that tags are added to. Batch resources that support tags are compute environments, jobs, job definitions, job queues, and scheduling policies. ARNs for child jobs of array and multi-node parallel (MNP) jobs aren't supported.
-
tags
(Optional[TagrisTagsMap], default:
None
)
–
The tags that you apply to the resource to help you categorize and organize your resources. Each tag consists of a key and an optional value. For more information, see Tagging Amazon Web Services Resources in Amazon Web Services General Reference.
Raises:
-
ClientException
–
These errors are usually caused by a client action. One example cause is using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Another cause is specifying an identifier that's not valid.
-
ServerException
–
These errors are usually caused by a server issue.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Examples:
TagResource Example
This demonstrates calling the TagResource action.
>>> client.tag_resource(resource_arn='arn:aws:batch:us-east-1:123456789012:job-definition/sleep30:1', tags={'Stage': 'Alpha'})
Source code in docs_src/capo_batch/_services/batch.py
| def tag_resource(
self,
resource_arn: "capo_batch.types.string.String",
*,
config_overrides: Optional[BatchClientConfig] = None,
tags: Optional["capo_batch.types.tagris_tags_map.TagrisTagsMap"] = None,
) -> "capo_batch.types.tag_resource_response.TagResourceResponse":
"""<p>Associates the specified tags to a resource with the specified <code>resourceArn</code>. If existing tags on a resource aren't specified in the request parameters, they aren't changed. When a resource is deleted, the tags that are associated with that resource are deleted as well. Batch resources that support tags are compute environments, jobs, job definitions, job queues, and scheduling policies. ARNs for child jobs of array and multi-node parallel (MNP) jobs aren't supported.</p>
Args:
resource_arn: <p>The Amazon Resource Name (ARN) of the resource that tags are added to. Batch resources that support tags are compute environments, jobs, job definitions, job queues, and scheduling policies. ARNs for child jobs of array and multi-node parallel (MNP) jobs aren't supported.</p>
tags: <p>The tags that you apply to the resource to help you categorize and organize your resources. Each tag consists of a key and an optional value. For more information, see <a href="https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html">Tagging Amazon Web Services Resources</a> in <i>Amazon Web Services General Reference</i>.</p>
Raises:
capo_batch.errors.client_exception.ClientException: <p>These errors are usually caused by a client action. One example cause is using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Another cause is specifying an identifier that's not valid.</p>
capo_batch.errors.server_exception.ServerException: <p>These errors are usually caused by a server issue.</p>
capo_batch.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
TagResource Example
This demonstrates calling the TagResource action.
>>> client.tag_resource(resource_arn='arn:aws:batch:us-east-1:123456789012:job-definition/sleep30:1', tags={'Stage': 'Alpha'})
"""
def _handler(
req: "OperationRequest[capo_batch.types.tag_resource_request.TagResourceRequest]",
) -> OperationResponse[
"capo_batch.types.tag_resource_response.TagResourceResponse"
]:
import capo_batch._operations.aws_batch_v20160810.tag_resource
output, http_response = (
capo_batch._operations.aws_batch_v20160810.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_batch.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
|