Skip to content

update_collection

update_collection(
    id: CollectionId,
    *,
    config_overrides: Optional[OpenSearchServerlessClientConfig] = None,
    description: Optional[str] = None,
    vector_options: Optional[VectorOptions] = None,
    deletion_protection: Optional[DeletionProtection] = None,
    client_token: Optional[ClientToken] = None,
) -> UpdateCollectionResponse

Updates an OpenSearch Serverless collection.

Parameters:

  • id (CollectionId) –

    The unique identifier of the collection.

  • description (Optional[str], default: None ) –

    A description of the collection.

  • vector_options (Optional[VectorOptions], default: None ) –

    Configuration options for vector search capabilities in the collection.

  • deletion_protection (Optional[DeletionProtection], default: None ) –

    Indicates whether to enable or disable deletion protection for the collection. When set to ENABLED, the collection cannot be deleted.

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

    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.

  • 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 update_collection(
    self,
    id: "capo_opensearchserverless.types.collection_id.CollectionId",
    *,
    config_overrides: Optional[OpenSearchServerlessClientConfig] = None,
    description: Optional[str] = None,
    vector_options: Optional[
        "capo_opensearchserverless.types.vector_options.VectorOptions"
    ] = None,
    deletion_protection: Optional[
        "capo_opensearchserverless.types.deletion_protection.DeletionProtection"
    ] = None,
    client_token: Optional[
        "capo_opensearchserverless.types.client_token.ClientToken"
    ] = None,
) -> "capo_opensearchserverless.types.update_collection_response.UpdateCollectionResponse":
    """<p>Updates an OpenSearch Serverless collection.</p>

    Args:
        id: <p>The unique identifier of the collection.</p>
        description: <p>A description of the collection.</p>
        vector_options: <p>Configuration options for vector search capabilities in the collection.</p>
        deletion_protection: <p>Indicates whether to enable or disable deletion protection for the collection. When set to <code>ENABLED</code>, the collection cannot be deleted.</p>
        client_token: <p>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.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.update_collection_request.UpdateCollectionRequest]",
    ) -> OperationResponse[
        "capo_opensearchserverless.types.update_collection_response.UpdateCollectionResponse"
    ]:
        import capo_opensearchserverless._operations.open_search_serverless.update_collection

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateCollection")
    )
    input_: capo_opensearchserverless.types.update_collection_request.UpdateCollectionRequest = {
        "id": id
    }
    if description is not None:
        input_["description"] = description
    if vector_options is not None:
        input_["vector_options"] = vector_options
    if deletion_protection is not None:
        input_["deletion_protection"] = deletion_protection
    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