Skip to content

tag_resource async

tag_resource(
    resource_arn: Arn,
    tags: Tags,
    *,
    config_overrides: Optional[AsyncOpenSearchServerlessClientConfig] = None,
) -> TagResourceResponse

Associates tags with an OpenSearch Serverless resource. For more information, see Tagging Amazon OpenSearch Serverless collections.

Parameters:

  • resource_arn (Arn) –

    The Amazon Resource Name (ARN) of the resource. The resource must be active (not in the DELETING state), and must be owned by the account ID included in the request.

  • tags (Tags) –

    A list of tags (key-value pairs) to add to the resource. All tag keys in the request must be unique.

Raises:

  • ConflictException –

    When creating a resource, thrown when a resource with the same name already exists or is being created. When deleting a resource, thrown when the resource is not in the ACTIVE, FAILED, or UPDATE_FAILED state.

  • InternalServerException –

    Thrown when an error internal to the service occurs while processing a request.

  • ResourceNotFoundException –

    Thrown when accessing or deleting a resource that does not exist.

  • ServiceQuotaExceededException –

    Thrown when you attempt to create more resources than the service allows based on service quotas.

  • ValidationException –

    Thrown when the HTTP request contains invalid input or is missing required input.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_opensearchserverless/_services/async_open_search_serverless.py
async def tag_resource(
    self,
    resource_arn: "capo_opensearchserverless.types.arn.Arn",
    tags: "capo_opensearchserverless.types.tags.Tags",
    *,
    config_overrides: Optional[AsyncOpenSearchServerlessClientConfig] = None,
) -> "capo_opensearchserverless.types.tag_resource_response.TagResourceResponse":
    """<p>Associates tags with an OpenSearch Serverless resource. For more information, see <a href="https://docs.aws.amazon.com/opensearch-service/latest/developerguide/tag-collection.html">Tagging Amazon OpenSearch Serverless collections</a>.</p>

    Args:
        resource_arn: <p>The Amazon Resource Name (ARN) of the resource. The resource must be active (not in the <code>DELETING</code> state), and must be owned by the account ID included in the request.</p>
        tags: <p>A list of tags (key-value pairs) to add to the resource. All tag keys in the request must be unique.</p>

    Raises:
        capo_opensearchserverless.errors.conflict_exception.ConflictException: <p>When creating a resource, thrown when a resource with the same name already exists or is being created. When deleting a resource, thrown when the resource is not in the ACTIVE, FAILED, or UPDATE_FAILED state.</p>
        capo_opensearchserverless.errors.internal_server_exception.InternalServerException: <p>Thrown when an error internal to the service occurs while processing a request.</p>
        capo_opensearchserverless.errors.resource_not_found_exception.ResourceNotFoundException: <p>Thrown when accessing or deleting a resource that does not exist.</p>
        capo_opensearchserverless.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>Thrown when you attempt to create more resources than the service allows based on service quotas.</p>
        capo_opensearchserverless.errors.validation_exception.ValidationException: <p>Thrown when the HTTP request contains invalid input or is missing required input.</p>
        capo_opensearchserverless.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_opensearchserverless.types.tag_resource_request.TagResourceRequest]",
    ) -> AsyncOperationResponse[
        "capo_opensearchserverless.types.tag_resource_response.TagResourceResponse"
    ]:
        import capo_opensearchserverless._operations.open_search_serverless.tag_resource

        (
            output,
            http_response,
        ) = await capo_opensearchserverless._operations.open_search_serverless.tag_resource.async_tag_resource(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("TagResource")
    )
    input_: capo_opensearchserverless.types.tag_resource_request.TagResourceRequest = {
        "resource_arn": resource_arn,
        "tags": tags,
    }

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output