EnvectorClient

module EnvectorClient

EnvectorClient Configuration Module

This module provides the EnvectorClient class and related functions for managing connections, keys, and indexes.

  • EnvectorClient — Main class for managing EnvectorClient operations.

  • init_connect — Initializes the connection to the EnVector server.

  • init_index_config — Initializes the index configuration.

  • create_index — Creates a new index.

  • init — Initializes the EnvectorClient environment.

class EnvectorClient

class EnvectorClient()

Main class for managing EnvectorClient operations.

Methods: init_connect(host, port, address, access_token): Initializes the connection to the EnVector server. register_key(key_id, key_path): Registers a key with the EnVector server. generate_and_register_key(key_id, key_path, preset): Generates and registers a key. init_index_config(key_path, key_id, preset, query_encryption, index_encryption, index_type): Initializes the index configuration. create_index(index_name, dim, index_encryption, index_type): Creates a new index. init(host, port, address, access_token, key_path, key_id, preset, query_encryption, index_encryption, index_type, auto_key_setup): Initializes the EnVector environment.


__init__()

def __init__()

Initializes the EnvectorClient class.


indexer()

Returns the indexer object.

Raises:

  • ValueError: If the indexer is not initialized.


indexer()

Sets the indexer object.

ARGUMENTS

  • indexer (Indexer): The indexer object.

Raises:

  • ValueError: If the indexer is not an instance of Indexer.


index_config()

Returns the index configuration.

Raises:

  • ValueError: If the index configuration is not initialized.


index_config()

Sets the index configuration.

ARGUMENTS

  • index_config (IndexConfig): The index configuration.

Raises:

  • ValueError: If the index configuration is not an instance of IndexConfig.


is_connected()

Checks if the EnVector client is connected to the server.

RETURNS

bool: True if connected, False otherwise.


disconnect()

Disconnects the Envector client from the server.


register_key()

Registers and loads a key with the Envector server.

ARGUMENTS

  • key_id (str): The key ID.

  • key_path (str): The path to the key.

Raises:

  • ValueError: If the indexer is not initialized.


load_key()

Loads a key with the Envector server.

ARGUMENTS

  • key_id (str): The key ID.

Raises:

  • ValueError: If the indexer is not initialized.


unload_key()

Unloads a key with the Envector server.

ARGUMENTS

  • key_id (str): The key ID.

Raises:

  • ValueError: If the indexer is not initialized.


get_key_list()

Retrieves the list of registered keys.

Raises:

  • ValueError: If the indexer is not initialized.

RETURNS

list: A list of registered keys.


get_key_info()

Retrieves the information of the registered keys.

Raises:

  • ValueError: If the indexer is not initialized.

RETURNS

dict: A dictionary containing key information.


get_index_list()

Retrieves the list of registered index.

Raises:

  • ValueError: If the indexer is not initialized.

RETURNS

list: A list of registered indexes.


generate_key()

Generates a key using the KeyGenerator.

ARGUMENTS

  • key_id (str): The key ID.

  • key_path (str): The path to the key.

  • preset (str): The preset for the key.

RETURNS

KeyGenerator: The KeyGenerator instance used to generate the key.


generate_and_register_key()

Generates and registers a key.

ARGUMENTS

  • key_id (str): The key ID.

  • key_path (str): The path to the key.

  • preset (str): The preset for the key.


context_param()

Returns the context parameters.

RETURNS

ContextParameter: The context parameters.


key_param()

Returns the key parameters.

RETURNS

KeyParameter: The key parameters.


init_connect()

Initializes the connection to the Envector server.

ARGUMENTS

  • host (str): The host address.

  • port (int): The port number.

  • address (str): The full address.

  • access_token (str): The access token.

Raises:

  • ValueError: If neither host and port nor address are provided.

RETURNS

EnvectorClient: The initialized EnvectorClient object.


init_index_config()

Initializes the index configuration.

PARAMETERS

  • index_name (str, optional): The name of the index.

  • dim (int, optional): The dimensionality of the index.

  • key_path (str, optional): The path to the key. Defaults to None.

  • key_id (str, optional): The key ID. Defaults to None.

  • seal_mode (str, optional): The seal mode. Defaults to None.

  • seal_kek_path (str, optional): The key encryption key (KEK) path. Defaults to None.

  • preset (str, optional): The preset for the key. Defaults to None.

  • eval_mode (str, optional): The evaluation mode. Defaults to None.

  • query_encryption (str, optional): The encryption type for query, e.g. "plain", "cipher", "hybrid". Defaults to None.

  • index_encryption (str, optional): The encryption type for database, e.g. "plain", "cipher", "hybrid". Defaults to None.

  • index_params (dict, optional): The parameters for the index. Defaults to None.

  • index_type (str, optional): The type of index. Currently, flat and ivf_flat index types are supported.

  • metadata_encryption (bool, optional): The encryption type for metadata, e.g. True, False. Defaults to None.

EXAMPLES


init()

Initializes the Envector environment (connection, key, and index config).

ARGUMENTS

  • host (str): The host address to connect to Envector server.

  • port (int): The port number to connect to Envector server.

  • address (str): The full address to connect to Envector server.

  • access_token (str): The access token to connect to Envector server.

  • index_name (str): The name of the index.

  • dim (int): The dimensionality of the index.

  • key_path (str): The path to the key directory.

  • key_id (str): The key ID.

  • seal_kek_path (str): The path to the key encryption key for secret key sealing.

  • preset (str): The preset for the key.

  • eval_mode (str): The evaluation mode.

  • query_encryption (str): The encryption type for query, e.g. "plain", "cipher", "hybrid". Defaults to plain.

  • index_encryption (str): The encryption type for database, e.g. "plain", "cipher", "hybrid". Defaults to cipher.

  • index_params (dict): The parameters for the index. Defaults to {"index_type": "flat"}. Currently, flat and ivf_flat index types are supported.

  • index_type (str): The type of index. Currently, flat and ivf_flat index types are supported.

  • metadata_encryption (bool): The encryption type for metadata, e.g. True, False. Defaults to None.

  • auto_key_setup (bool): Whether to automatically generate and register the key. Defaults to True.

RETURNS

EnvectorClient: The initialized EnvectorClient object.


create_index()

Creates a new index.

ARGUMENTS

  • index_name (str): The name of the index.

  • dim (int): The dimensionality of the index.

  • index_encryption (str): The encryption type for database, e.g. "plain", "cipher", "hybrid".

  • index_type (str): The type of index.

RETURNS

Index: The created index.


drop_index()

Drops the current index.

Raises:

  • ValueError: If the indexer is not connected.

RETURNS

Index: The current index after dropping it.


release_key()

Releases the key with the given key_id.

ARGUMENTS

  • key_id (str): The ID of the key to release.

Raises:

  • ValueError: If the indexer is not connected.


key_path()

Returns the path to the key directory.

RETURNS

str: The path to the key directory.


reset()

Resets the EnvectorClient by deleting all index and registered key in Server.

RETURNS

EnvectorClient: The reset EnvectorClient object.

Last updated