Skip to content

tag_resource

tag_resource(
    resource_arn: RuleArn,
    rule_revision: int,
    tags: TagList,
    *,
    config_overrides: Optional[ComputeOptimizerAutomationClientConfig] = None,
    client_token: Optional[ClientToken] = None,
) -> TagResourceResponse

Adds tags to the specified resource.

Parameters:

  • resource_arn (RuleArn) –

    The ARN of the resource to tag.

  • rule_revision (int) –

    The revision number of the automation rule to tag. This ensures you're tagging the correct version of the rule.

  • tags (TagList) –

    The tags to add to the resource.

  • client_token (Optional[ClientToken], default: None ) –

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Must be 1-64 characters long and contain only alphanumeric characters, underscores, and hyphens.

Raises:

Source code in docs_src/capo_compute_optimizer_automation/_services/compute_optimizer_automation.py
def tag_resource(
    self,
    resource_arn: "capo_compute_optimizer_automation.types.rule_arn.RuleArn",
    rule_revision: int,
    tags: "capo_compute_optimizer_automation.types.tag_list.TagList",
    *,
    config_overrides: Optional[ComputeOptimizerAutomationClientConfig] = None,
    client_token: Optional[
        "capo_compute_optimizer_automation.types.client_token.ClientToken"
    ] = None,
) -> "capo_compute_optimizer_automation.types.tag_resource_response.TagResourceResponse":
    """<p> Adds tags to the specified resource. </p>

    Args:
        resource_arn: <p> The ARN of the resource to tag. </p>
        rule_revision: <p>The revision number of the automation rule to tag. This ensures you're tagging the correct version of the rule.</p>
        tags: <p> The tags to add to the resource. </p>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Must be 1-64 characters long and contain only alphanumeric characters, underscores, and hyphens.</p>

    Raises:
        capo_compute_optimizer_automation.errors.access_denied_exception.AccessDeniedException: <p> You do not have sufficient permissions to perform this action. </p>
        capo_compute_optimizer_automation.errors.forbidden_exception.ForbiddenException: <p> You are not authorized to perform this action. </p>
        capo_compute_optimizer_automation.errors.idempotency_token_in_use_exception.IdempotencyTokenInUseException: <p> The specified client token is already in use. </p>
        capo_compute_optimizer_automation.errors.idempotent_parameter_mismatch_exception.IdempotentParameterMismatchException: <p>Exception thrown when the same client token is used with different parameters, indicating a mismatch in idempotent request parameters.</p>
        capo_compute_optimizer_automation.errors.internal_server_exception.InternalServerException: <p> An internal error occurred while processing the request. </p>
        capo_compute_optimizer_automation.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p> One or more parameter values are not valid. </p>
        capo_compute_optimizer_automation.errors.opt_in_required_exception.OptInRequiredException: <p> The account must be opted in to Compute Optimizer Automation before performing this action. </p>
        capo_compute_optimizer_automation.errors.resource_not_found_exception.ResourceNotFoundException: <p> The specified resource was not found. </p>
        capo_compute_optimizer_automation.errors.service_unavailable_exception.ServiceUnavailableException: <p> The service is temporarily unavailable. </p>
        capo_compute_optimizer_automation.errors.throttling_exception.ThrottlingException: <p> The request was denied due to request throttling. </p>
        capo_compute_optimizer_automation.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_compute_optimizer_automation.types.tag_resource_request.TagResourceRequest]",
    ) -> OperationResponse[
        "capo_compute_optimizer_automation.types.tag_resource_response.TagResourceResponse"
    ]:
        import capo_compute_optimizer_automation._operations.compute_optimizer_automation_service.tag_resource

        output, http_response = (
            capo_compute_optimizer_automation._operations.compute_optimizer_automation_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_compute_optimizer_automation.types.tag_resource_request.TagResourceRequest = {
        "resource_arn": resource_arn,
        "rule_revision": rule_revision,
        "tags": tags,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output