Skip to content

delete_collection

delete_collection(
    id: CollectionId,
    *,
    config_overrides: Optional[OpenSearchServerlessClientConfig] = None,
    client_token: Optional[ClientToken] = None,
) -> DeleteCollectionResponse

Deletes an OpenSearch Serverless collection. For more information, see Creating and managing Amazon OpenSearch Serverless collections.

Parameters:

  • id (CollectionId) –

    The unique identifier of the collection. For example, 1iu5usc406kd. The ID is part of the collection endpoint. You can also retrieve it using the ListCollections API.

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

    A unique, case-sensitive identifier to ensure idempotency of the request.

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.

  • 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/open_search_serverless.py
def delete_collection(
    self,
    id: "capo_opensearchserverless.types.collection_id.CollectionId",
    *,
    config_overrides: Optional[OpenSearchServerlessClientConfig] = None,
    client_token: Optional[
        "capo_opensearchserverless.types.client_token.ClientToken"
    ] = None,
) -> "capo_opensearchserverless.types.delete_collection_response.DeleteCollectionResponse":
    """<p>Deletes an OpenSearch Serverless collection. For more information, see <a href="https://docs.aws.amazon.com/opensearch-service/latest/developerguide/serverless-manage.html">Creating and managing Amazon OpenSearch Serverless collections</a>.</p>

    Args:
        id: <p>The unique identifier of the collection. For example, <code>1iu5usc406kd</code>. The ID is part of the collection endpoint. You can also retrieve it using the <a href="https://docs.aws.amazon.com/opensearch-service/latest/ServerlessAPIReference/API_ListCollections.html">ListCollections</a> API.</p>
        client_token: <p>A unique, case-sensitive identifier to ensure idempotency of the request.</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.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.
    """

    def _handler(
        req: "OperationRequest[capo_opensearchserverless.types.delete_collection_request.DeleteCollectionRequest]",
    ) -> OperationResponse[
        "capo_opensearchserverless.types.delete_collection_response.DeleteCollectionResponse"
    ]:
        import capo_opensearchserverless._operations.open_search_serverless.delete_collection

        output, http_response = (
            capo_opensearchserverless._operations.open_search_serverless.delete_collection.delete_collection(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteCollection")
    )
    input_: capo_opensearchserverless.types.delete_collection_request.DeleteCollectionRequest = {
        "id": id
    }
    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