Skip to content

tag_resource

tag_resource(
    resource_arn: str,
    tags: TagMap,
    *,
    config_overrides: Optional[ampClientConfig] = None,
) -> TagResourceResponse

The TagResource operation associates tags with an Amazon Managed Service for Prometheus resource. The only resources that can be tagged are rule groups namespaces, scrapers, and workspaces.

If you specify a new tag key for the resource, this tag is appended to the list of tags associated with the resource. If you specify a tag key that is already associated with the resource, the new tag value that you specify replaces the previous value for that tag. To remove a tag, use UntagResource.

Parameters:

  • resource_arn (str) –

    The ARN of the resource to apply tags to.

  • tags (TagMap) –

    The list of tag keys and values to associate with the resource.

    Keys must not begin with aws:.

Raises:

Source code in docs_src/capo_amp/_services/amp.py
def tag_resource(
    self,
    resource_arn: str,
    tags: "capo_amp.types.tag_map.TagMap",
    *,
    config_overrides: Optional[ampClientConfig] = None,
) -> "capo_amp.types.tag_resource_response.TagResourceResponse":
    """<p>The <code>TagResource</code> operation associates tags with an Amazon Managed Service for Prometheus resource. The only resources that can be tagged are rule groups namespaces, scrapers, and workspaces.</p> <p>If you specify a new tag key for the resource, this tag is appended to the list of tags associated with the resource. If you specify a tag key that is already associated with the resource, the new tag value that you specify replaces the previous value for that tag. To remove a tag, use <code>UntagResource</code>.</p>

    Args:
        resource_arn: <p>The ARN of the resource to apply tags to.</p>
        tags: <p>The list of tag keys and values to associate with the resource.</p> <p>Keys must not begin with <code>aws:</code>.</p>

    Raises:
        capo_amp.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_amp.errors.internal_server_exception.InternalServerException: <p>An unexpected error occurred during the processing of the request.</p>
        capo_amp.errors.resource_not_found_exception.ResourceNotFoundException: <p>The request references a resources that doesn't exist.</p>
        capo_amp.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_amp.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by an Amazon Web Services service.</p>
        capo_amp.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

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

        output, http_response = (
            capo_amp._operations.amazon_prometheus_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_amp.types.tag_resource_request.TagResourceRequest = {
        "resource_arn": resource_arn,
        "tags": tags,
    }

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