EnVectorClient
module EnVectorClient
EnVectorClientEnVectorClient 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
EnVectorClientclass 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__()
__init__()def __init__()Initializes the EnvectorClient class.
indexer()
indexer()@property
def indexer()Returns the indexer object.
Raises:
ValueError: If the indexer is not initialized.
indexer()
indexer()@indexer.setter
def indexer(indexer: Indexer)Sets the indexer object.
ARGUMENTS
indexer(Indexer): The indexer object.
Raises:
ValueError: If the indexer is not an instance of Indexer.
index_config()
index_config()@property
def index_config()Returns the index configuration.
Raises:
ValueError: If the index configuration is not initialized.
index_config()
index_config()@index_config.setter
def index_config(index_config: IndexConfig)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()
is_connected()@property
def is_connected()Checks if the EnVector client is connected to the server.
RETURNS
bool: True if connected, False otherwise.
disconnect()
disconnect()def disconnect()Disconnects the Envector client from the server.
register_key()
register_key()def register_key(key_id: Optional[str] = None)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()
load_key()def load_key(key_id: Optional[str] = None)Loads a key with the Envector server.
ARGUMENTS
key_id(str): The key ID.
Raises:
ValueError: If the indexer is not initialized.
unload_key()
unload_key()def unload_key(key_id: Optional[str] = None)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()
get_key_list()def 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()
get_key_info()def get_key_info(key_id: Optional[str] = None)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()
get_index_list()def 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()
generate_key()def generate_key(key_id: Optional[str] = None)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()
generate_and_register_key()def 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()
context_param()@property
def context_param() -> "ContextParameter"Returns the context parameters.
RETURNS
ContextParameter: The context parameters.
key_param()
key_param()@property
def key_param() -> "KeyParameter"Returns the key parameters.
RETURNS
KeyParameter: The key parameters.
init_connect()
init_connect()def init_connect(host: Optional[str] = None,
port: Optional[int] = None,
address: Optional[str] = None,
access_token: Optional[str] = None)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()
init_index_config()def init_index_config(index_name: Optional[str] = None,
dim: Optional[int] = None,
key_path: Optional[str] = None,
key_id: Optional[str] = None,
seal_mode: Optional[str] = None,
seal_kek_path: Optional[str] = None,
preset: Optional[str] = None,
eval_mode: Optional[str] = None,
query_encryption: Optional[str] = None,
index_encryption: Optional[str] = None,
index_params: Optional[dict] = None,
index_type: Optional[str] = None,
metadata_encryption: Optional[bool] = None,
auto_key_setup: Optional[bool] = None)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,flatandivf_flatindex types are supported.metadata_encryption(bool, optional): The encryption type for metadata, e.g. True, False. Defaults to None.
EXAMPLES
Initialize Envector environment:
>>> envector_client = EnvectorClient()
>>> envector_client.init_index_config(
... key_path="./keys",
... key_id="example_key",
... preset="ip",
... query_encryption="plain",
... index_encryption="cipher",
... index_params={"index_type": "flat"}
... metadata_encryption=True,
... auto_key_setup=True
... )init()
init()def init(host: Optional[str] = None,
port: Optional[int] = None,
address: Optional[str] = None,
access_token: Optional[str] = None,
index_name: Optional[str] = None,
dim: Optional[int] = None,
key_path: Optional[str] = None,
key_id: Optional[str] = None,
seal_mode: Optional[str] = None,
seal_kek_path: Optional[str] = None,
preset: Optional[str] = None,
eval_mode: Optional[str] = None,
query_encryption: Optional[str] = None,
index_encryption: Optional[str] = None,
index_params: Optional[dict] = None,
index_type: Optional[str] = None,
metadata_encryption: Optional[str] = None,
auto_key_setup: Optional[bool] = True)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 toplain.index_encryption(str): The encryption type for database, e.g. "plain", "cipher", "hybrid". Defaults tocipher.index_params(dict): The parameters for the index. Defaults to {"index_type": "flat"}. Currently,flatandivf_flatindex types are supported.index_type(str): The type of index. Currently,flatandivf_flatindex 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 toTrue.
RETURNS
EnvectorClient: The initialized EnvectorClient object.
create_index()
create_index()def create_index(index_name: Optional[str] = None,
dim: Optional[int] = None,
key_path: Optional[str] = None,
key_id: Optional[str] = None,
seal_mode: Optional[str] = None,
seal_kek_path: Optional[str] = None,
preset: Optional[str] = None,
eval_mode: Optional[str] = None,
query_encryption: Optional[str] = None,
index_encryption: Optional[str] = None,
index_params: Optional[dict] = None,
index_type: Optional[str] = None,
metadata_encryption: Optional[str] = None)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()
drop_index()def drop_index(index_name: str)Drops the current index.
Raises:
ValueError: If the indexer is not connected.
RETURNS
Index: The current index after dropping it.
release_key()
release_key()def release_key(key_id: str)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()
key_path()@property
def key_path()Returns the path to the key directory.
RETURNS
str: The path to the key directory.
reset()
reset()def reset()Resets the EnvectorClient by deleting all index and registered key in Server.
RETURNS
EnvectorClient: The reset EnvectorClient object.
Last updated

