pub struct Client { /* private fields */ }Expand description
The main client for interacting with the Shilp API
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(base_url: impl Into<String>) -> Self
pub fn new(base_url: impl Into<String>) -> Self
Creates a new Shilp API client with default settings
Sourcepub fn with_http_client(
base_url: impl Into<String>,
http_client: HttpClient,
) -> Self
pub fn with_http_client( base_url: impl Into<String>, http_client: HttpClient, ) -> Self
Creates a new Shilp API client with a custom HTTP client
Source§impl Client
impl Client
Sourcepub async fn list_collections(&self) -> Result<ListCollectionsResponse>
pub async fn list_collections(&self) -> Result<ListCollectionsResponse>
Lists all collections
Sourcepub async fn add_collection(
&self,
req: &AddCollectionRequest,
) -> Result<GenericResponse>
pub async fn add_collection( &self, req: &AddCollectionRequest, ) -> Result<GenericResponse>
Adds a new collection
Sourcepub async fn delete_record(
&self,
collection_name: &str,
id: &str,
) -> Result<GenericResponse>
pub async fn delete_record( &self, collection_name: &str, id: &str, ) -> Result<GenericResponse>
Deletes a record from a collection
Sourcepub async fn expiry_cleanup(
&self,
collection_name: &str,
) -> Result<GenericResponse>
pub async fn expiry_cleanup( &self, collection_name: &str, ) -> Result<GenericResponse>
Performs expiry cleanup on a collection
Sourcepub async fn drop_collection(&self, name: &str) -> Result<GenericResponse>
pub async fn drop_collection(&self, name: &str) -> Result<GenericResponse>
Drops an existing collection
Sourcepub async fn flush_collection(&self, name: &str) -> Result<GenericResponse>
pub async fn flush_collection(&self, name: &str) -> Result<GenericResponse>
Flushes a collection to disk
Sourcepub async fn load_collection(&self, name: &str) -> Result<GenericResponse>
pub async fn load_collection(&self, name: &str) -> Result<GenericResponse>
Loads a collection into memory
Sourcepub async fn unload_collection(&self, name: &str) -> Result<GenericResponse>
pub async fn unload_collection(&self, name: &str) -> Result<GenericResponse>
Unloads a collection from memory
Sourcepub async fn export_collection(&self, name: &str) -> Result<Response>
pub async fn export_collection(&self, name: &str) -> Result<Response>
Exports a collection and returns a Response for downloading the file The caller is responsible for processing the response (e.g., saving to a file)
Sourcepub async fn import_collection(&self, file_path: &Path) -> Result<()>
pub async fn import_collection(&self, file_path: &Path) -> Result<()>
Imports a collection from a file
Sourcepub async fn rename_collection(
&self,
old_name: &str,
new_name: &str,
) -> Result<GenericResponse>
pub async fn rename_collection( &self, old_name: &str, new_name: &str, ) -> Result<GenericResponse>
Renames an existing collection
Sourcepub async fn reindex_collection(
&self,
collection_name: &str,
) -> Result<GenericResponse>
pub async fn reindex_collection( &self, collection_name: &str, ) -> Result<GenericResponse>
Re-indexes a collection for debug purposes
Sourcepub async fn pq_train(&self, collection_name: &str) -> Result<GenericResponse>
pub async fn pq_train(&self, collection_name: &str) -> Result<GenericResponse>
Performs Product Quantization training for an existing collection
Sourcepub async fn insert_record(
&self,
req: &InsertRecordRequest,
) -> Result<InsertRecordResponse>
pub async fn insert_record( &self, req: &InsertRecordRequest, ) -> Result<InsertRecordResponse>
Inserts a new record into a collection
Sourcepub async fn get_collection_data(
&self,
collection_name: &str,
offset: i32,
limit: i32,
) -> Result<GetCollectionDataResponse>
pub async fn get_collection_data( &self, collection_name: &str, offset: i32, limit: i32, ) -> Result<GetCollectionDataResponse>
Gets paginated data records from a collection
Sourcepub async fn enable_nli(
&self,
collection: &str,
vertical: &str,
) -> Result<Response>
pub async fn enable_nli( &self, collection: &str, vertical: &str, ) -> Result<Response>
Enables Natural Language Inference for a collection and vertical.
This is an SSE endpoint that streams the progress of enabling NLI.
The vertical parameter specifies the NLI provider vertical; pass an empty string
for a custom vertical.
Returns the raw streaming response; the caller is responsible for reading the SSE events.
Sourcepub async fn get_collection_schema(
&self,
collection_name: &str,
) -> Result<GetCollectionSchemaResponse>
pub async fn get_collection_schema( &self, collection_name: &str, ) -> Result<GetCollectionSchemaResponse>
Gets the schema for a collection
Sourcepub async fn enable_metadata_store(
&self,
collection_name: &str,
req: &EnableMetadataStoreRequest,
) -> Result<EnableMetadataStoreResponse>
pub async fn enable_metadata_store( &self, collection_name: &str, req: &EnableMetadataStoreRequest, ) -> Result<EnableMetadataStoreResponse>
Enables metadata store for an existing collection
Sourcepub async fn list_collection_models(
&self,
) -> Result<ListCollectionsModelsResponse>
pub async fn list_collection_models( &self, ) -> Result<ListCollectionsModelsResponse>
Lists all collection models
Sourcepub async fn get_collection_model_info(
&self,
collection_name: &str,
model_id: &str,
) -> Result<GetCollectionModelResponse>
pub async fn get_collection_model_info( &self, collection_name: &str, model_id: &str, ) -> Result<GetCollectionModelResponse>
Gets information about a specific collection model
Sourcepub async fn update_collection_model(
&self,
collection_name: &str,
) -> Result<impl Stream<Item = Result<UpdateModelsEvent>>>
pub async fn update_collection_model( &self, collection_name: &str, ) -> Result<impl Stream<Item = Result<UpdateModelsEvent>>>
Updates collection models with streaming progress updates. Returns a stream of UpdateModelsEvent. The stream sends events line by line until completion or error. Each event is a newline-delimited JSON object.
Source§impl Client
impl Client
Sourcepub async fn ingest_data(&self, req: &IngestRequest) -> Result<IngestResponse>
pub async fn ingest_data(&self, req: &IngestRequest) -> Result<IngestResponse>
Ingests data into a collection
Sourcepub async fn search_data(&self, req: &SearchRequest) -> Result<SearchResponse>
pub async fn search_data(&self, req: &SearchRequest) -> Result<SearchResponse>
Searches for data in a collection using POST request This method supports field-specific weights via the SearchRequest.weights field
Sourcepub async fn list_storage(
&self,
path: Option<&str>,
_source: IngestSourceType,
) -> Result<ListStorageResponse>
pub async fn list_storage( &self, path: Option<&str>, _source: IngestSourceType, ) -> Result<ListStorageResponse>
Lists contents of a directory in uploads storage If the source is mongodb, then empty path lists all DBs. If path is a DB, lists all collections in that DB.
Sourcepub async fn list_ingest_sources(&self) -> Result<ListIngestionSourcesResponse>
pub async fn list_ingest_sources(&self) -> Result<ListIngestionSourcesResponse>
Lists available ingestion sources
Sourcepub async fn read_document(
&self,
path: &str,
options: &FileReaderOptions,
) -> Result<ReadDocumentResponse>
pub async fn read_document( &self, path: &str, options: &FileReaderOptions, ) -> Result<ReadDocumentResponse>
Reads the first few rows of a CSV document or MongoDB collection If the source is mongodb, then path is in the format “database/collection” options.query can be used to filter the documents returned in case of mongodb
Sourcepub async fn upload_data_file(&self, file_path: &Path) -> Result<()>
pub async fn upload_data_file(&self, file_path: &Path) -> Result<()>
Uploads a data file to the uploads storage which can be used for ingestion
Sourcepub async fn list_embedding_models(&self) -> Result<ListEmbeddingModelsResponse>
pub async fn list_embedding_models(&self) -> Result<ListEmbeddingModelsResponse>
Lists all available embedding providers and their models
Sourcepub async fn list_nli_verticals(&self) -> Result<ListNLIVerticalsResponse>
pub async fn list_nli_verticals(&self) -> Result<ListNLIVerticalsResponse>
Lists all available NLI verticals
Source§impl Client
impl Client
Sourcepub async fn get_collection_distance(
&self,
collection_name: &str,
field: &str,
node_id: i32,
text: &str,
custom_matcher_text: Option<&str>,
) -> Result<DebugDistanceResponse>
pub async fn get_collection_distance( &self, collection_name: &str, field: &str, node_id: i32, text: &str, custom_matcher_text: Option<&str>, ) -> Result<DebugDistanceResponse>
Gets the distance of a node in a collection for debug purposes
Sourcepub async fn get_collection_node_info(
&self,
collection_name: &str,
field: &str,
node_id: i32,
) -> Result<DebugNodeInfoResponse>
pub async fn get_collection_node_info( &self, collection_name: &str, field: &str, node_id: i32, ) -> Result<DebugNodeInfoResponse>
Gets node info of a collection for debug purposes
Sourcepub async fn get_collection_node_neighbors_at_level(
&self,
collection_name: &str,
field: &str,
node_id: i32,
level: i32,
limit: Option<i32>,
offset: Option<i32>,
) -> Result<DebugNodeInfoResponse>
pub async fn get_collection_node_neighbors_at_level( &self, collection_name: &str, field: &str, node_id: i32, level: i32, limit: Option<i32>, offset: Option<i32>, ) -> Result<DebugNodeInfoResponse>
Gets node neighbors at a level of a collection for debug purposes
Sourcepub async fn get_collection_levels(
&self,
collection_name: &str,
) -> Result<DebugLevelsResponse>
pub async fn get_collection_levels( &self, collection_name: &str, ) -> Result<DebugLevelsResponse>
Gets levels of a collection for debug purposes
Sourcepub async fn get_collection_nodes_at_level(
&self,
collection_name: &str,
level: i32,
) -> Result<DebugNodesAtLevelResponse>
pub async fn get_collection_nodes_at_level( &self, collection_name: &str, level: i32, ) -> Result<DebugNodesAtLevelResponse>
Gets nodes at a level of a collection for debug purposes
Sourcepub async fn get_collection_node_by_reference_node_id(
&self,
collection_name: &str,
node_id: &str,
) -> Result<DebugReferenceNodeResponse>
pub async fn get_collection_node_by_reference_node_id( &self, collection_name: &str, node_id: &str, ) -> Result<DebugReferenceNodeResponse>
Gets node by reference node ID of a collection for debug purposes
Sourcepub async fn get_collection_embeddings(
&self,
collection_name: &str,
req: DebugGetEmbeddingsRequest,
) -> Result<DebugGetEmbeddingsResponse>
pub async fn get_collection_embeddings( &self, collection_name: &str, req: DebugGetEmbeddingsRequest, ) -> Result<DebugGetEmbeddingsResponse>
Gets embeddings for a collection for debug purposes
Source§impl Client
impl Client
Sourcepub async fn health_check(&self) -> Result<HealthResponse>
pub async fn health_check(&self) -> Result<HealthResponse>
Performs a health check on the API
Source§impl Client
impl Client
Sourcepub async fn get_oplog_entries(
&self,
collection: Option<&str>,
after_lsn: u64,
limit: Option<i32>,
) -> Result<GetOplogResponse>
pub async fn get_oplog_entries( &self, collection: Option<&str>, after_lsn: u64, limit: Option<i32>, ) -> Result<GetOplogResponse>
Retrieves oplog entries after a specific LSN for replica synchronization Parameters:
- collection: Collection name to retrieve oplog entries for (optional, if empty returns entries for all collections)
- after_lsn: LSN after which to retrieve oplog entries (required)
- limit: Maximum number of oplog entries to retrieve (optional)
Sourcepub async fn update_replica_lsn(
&self,
collection: &str,
replica_id: &str,
lsn: u64,
) -> Result<UpdateReplicaLSNResponse>
pub async fn update_replica_lsn( &self, collection: &str, replica_id: &str, lsn: u64, ) -> Result<UpdateReplicaLSNResponse>
Updates the last applied LSN for a replica (heartbeat) Parameters:
- collection: Collection name
- replica_id: Replica identifier
- lsn: Last applied LSN
Sourcepub async fn register_replica(
&self,
replica_id: &str,
) -> Result<GenericResponse>
pub async fn register_replica( &self, replica_id: &str, ) -> Result<GenericResponse>
Registers a replica for oplog retention tracking Parameters:
- replica_id: Replica identifier
Sourcepub async fn unregister_replica(
&self,
replica_id: &str,
) -> Result<GenericResponse>
pub async fn unregister_replica( &self, replica_id: &str, ) -> Result<GenericResponse>
Unregisters a replica for oplog retention tracking Parameters:
- replica_id: Replica identifier
Sourcepub async fn get_oplog_status(
&self,
collection: &str,
) -> Result<OplogStatusResponse>
pub async fn get_oplog_status( &self, collection: &str, ) -> Result<OplogStatusResponse>
Retrieves current oplog status and statistics for a collection Parameters:
- collection: Collection name to retrieve oplog status for (required)
Source§impl Client
impl Client
Sourcepub async fn get_settings(&self) -> Result<GetSettingsResponse>
pub async fn get_settings(&self) -> Result<GetSettingsResponse>
Retrieves the server settings
Sourcepub async fn update_settings(
&self,
settings: &SettingsUpdateRequest,
) -> Result<GenericResponse>
pub async fn update_settings( &self, settings: &SettingsUpdateRequest, ) -> Result<GenericResponse>
Updates server settings
Sourcepub async fn list_providers(&self) -> Result<SettingsAvailableProvidersResponse>
pub async fn list_providers(&self) -> Result<SettingsAvailableProvidersResponse>
Lists available auth and integration providers