Skip to content

create_collection

create_collection(
    name: CollectionName,
    *,
    config_overrides: Optional[OpenSearchServerlessClientConfig] = None,
    type: Optional[CollectionType] = None,
    description: Optional[str] = None,
    tags: Optional[Tags] = None,
    standby_replicas: Optional[StandbyReplicas] = None,
    vector_options: Optional[VectorOptions] = None,
    collection_group_name: Optional[CollectionGroupName] = None,
    encryption_config: Optional[EncryptionConfig] = None,
    deletion_protection: Optional[DeletionProtection] = None,
    client_token: Optional[ClientToken] = None,
) -> CreateCollectionResponse

Creates a new OpenSearch Serverless collection. For more information, see Creating and managing Amazon OpenSearch Serverless collections.

Parameters:

  • name (CollectionName) –

    Name of the collection.

  • type (Optional[CollectionType], default: None ) –

    The type of collection.

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

    Description of the collection.

  • tags (Optional[Tags], default: None ) –

    An arbitrary set of tags (key–value pairs) to associate with the OpenSearch Serverless collection.

  • standby_replicas (Optional[StandbyReplicas], default: None ) –

    Indicates whether standby replicas should be used for a collection.

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

    Configuration options for vector search capabilities in the collection.

  • collection_group_name (Optional[CollectionGroupName], default: None ) –

    The name of the collection group to associate with the collection.

  • encryption_config (Optional[EncryptionConfig], default: None ) –

    Encryption settings for the collection.

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

    Indicates whether to enable 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.

  • OcuLimitExceededException –

    Thrown when the collection you're attempting to create results in a number of search or indexing OCUs that exceeds the account limit.

  • 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/open_search_serverless.py
def create_collection(
    self,
    name: "capo_opensearchserverless.types.collection_name.CollectionName",
    *,
    config_overrides: Optional[OpenSearchServerlessClientConfig] = None,
    type: Optional[
        "capo_opensearchserverless.types.collection_type.CollectionType"
    ] = None,
    description: Optional[str] = None,
    tags: Optional["capo_opensearchserverless.types.tags.Tags"] = None,
    standby_replicas: Optional[
        "capo_opensearchserverless.types.standby_replicas.StandbyReplicas"
    ] = None,
    vector_options: Optional[
        "capo_opensearchserverless.types.vector_options.VectorOptions"
    ] = None,
    collection_group_name: Optional[
        "capo_opensearchserverless.types.collection_group_name.CollectionGroupName"
    ] = None,
    encryption_config: Optional[
        "capo_opensearchserverless.types.encryption_config.EncryptionConfig"
    ] = None,
    deletion_protection: Optional[
        "capo_opensearchserverless.types.deletion_protection.DeletionProtection"
    ] = None,
    client_token: Optional[
        "capo_opensearchserverless.types.client_token.ClientToken"
    ] = None,
) -> "capo_opensearchserverless.types.create_collection_response.CreateCollectionResponse":
    """<p>Creates a new 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:
        name: <p>Name of the collection.</p>
        type: <p>The type of collection.</p>
        description: <p>Description of the collection.</p>
        tags: <p>An arbitrary set of tags (key–value pairs) to associate with the OpenSearch Serverless collection.</p>
        standby_replicas: <p>Indicates whether standby replicas should be used for a collection.</p>
        vector_options: <p>Configuration options for vector search capabilities in the collection.</p>
        collection_group_name: <p>The name of the collection group to associate with the collection.</p>
        encryption_config: <p>Encryption settings for the collection.</p>
        deletion_protection: <p>Indicates whether to enable 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.ocu_limit_exceeded_exception.OcuLimitExceededException: <p>Thrown when the collection you're attempting to create results in a number of search or indexing OCUs that exceeds the account limit. </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.
    """

    def _handler(
        req: "OperationRequest[capo_opensearchserverless.types.create_collection_request.CreateCollectionRequest]",
    ) -> OperationResponse[
        "capo_opensearchserverless.types.create_collection_response.CreateCollectionResponse"
    ]:
        import capo_opensearchserverless._operations.open_search_serverless.create_collection

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateCollection")
    )
    input_: capo_opensearchserverless.types.create_collection_request.CreateCollectionRequest = {
        "name": name
    }
    if type is not None:
        input_["type"] = type
    if description is not None:
        input_["description"] = description
    if tags is not None:
        input_["tags"] = tags
    if standby_replicas is not None:
        input_["standby_replicas"] = standby_replicas
    if vector_options is not None:
        input_["vector_options"] = vector_options
    if collection_group_name is not None:
        input_["collection_group_name"] = collection_group_name
    if encryption_config is not None:
        input_["encryption_config"] = encryption_config
    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