Skip to content

tag_resource

tag_resource(
    resource_arn: ARN,
    tags: TagList,
    *,
    config_overrides: Optional[WorkSpacesWebClientConfig] = None,
    client_token: Optional[ClientToken] = None,
) -> TagResourceResponse

Adds or overwrites one or more tags for the specified resource.

Parameters:

  • resource_arn (ARN) –

    The ARN of the resource.

  • tags (TagList) –

    The tags of the resource.

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

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Idempotency ensures that an API request completes only once. With an idempotent request, if the original request completes successfully, subsequent retries with the same client token returns the result from the original successful request.

    If you do not specify a client token, one is automatically generated by the Amazon Web Services SDK.

Raises:

Source code in docs_src/capo_workspaces_web/_services/work_spaces_web.py
def tag_resource(
    self,
    resource_arn: "capo_workspaces_web.types.arn.ARN",
    tags: "capo_workspaces_web.types.tag_list.TagList",
    *,
    config_overrides: Optional[WorkSpacesWebClientConfig] = None,
    client_token: Optional[
        "capo_workspaces_web.types.client_token.ClientToken"
    ] = None,
) -> "capo_workspaces_web.types.tag_resource_response.TagResourceResponse":
    """<p>Adds or overwrites one or more tags for the specified resource.</p>

    Args:
        resource_arn: <p>The ARN of the resource.</p>
        tags: <p>The tags of the resource.</p>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Idempotency ensures that an API request completes only once. With an idempotent request, if the original request completes successfully, subsequent retries with the same client token returns the result from the original successful request. </p> <p>If you do not specify a client token, one is automatically generated by the Amazon Web Services SDK.</p>

    Raises:
        capo_workspaces_web.errors.access_denied_exception.AccessDeniedException: <p>Access is denied.</p>
        capo_workspaces_web.errors.internal_server_exception.InternalServerException: <p>There is an internal server error.</p>
        capo_workspaces_web.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource cannot be found.</p>
        capo_workspaces_web.errors.throttling_exception.ThrottlingException: <p>There is a throttling error.</p>
        capo_workspaces_web.errors.too_many_tags_exception.TooManyTagsException: <p>There are too many tags.</p>
        capo_workspaces_web.errors.validation_exception.ValidationException: <p>There is a validation error.</p>
        capo_workspaces_web.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

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

        output, http_response = (
            capo_workspaces_web._operations.aws_ermine_control_plane_service.tag_resource.tag_resource(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_workspaces_web.types.tag_resource_request.TagResourceRequest",
    ) -> dict[str, Any]:
        import capo_workspaces_web.types.tag_resource_request

        return capo_workspaces_web.types.tag_resource_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("TagResource", redact_input=_redact_input),
    )
    input_: capo_workspaces_web.types.tag_resource_request.TagResourceRequest = {
        "resource_arn": resource_arn,
        "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