Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

The main client for interacting with the Shilp API

Implementations§

Source§

impl Client

Source

pub fn new(base_url: impl Into<String>) -> Self

Creates a new Shilp API client with default settings

Source

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

pub fn with_auth( base_url: impl Into<String>, auth_token: impl Into<String>, ) -> Self

Creates a new Shilp API client with authentication token

Source§

impl Client

Source

pub async fn list_collections(&self) -> Result<ListCollectionsResponse>

Lists all collections

Source

pub async fn add_collection( &self, req: &AddCollectionRequest, ) -> Result<GenericResponse>

Adds a new collection

Source

pub async fn delete_record( &self, collection_name: &str, id: &str, ) -> Result<GenericResponse>

Deletes a record from a collection

Source

pub async fn expiry_cleanup( &self, collection_name: &str, ) -> Result<GenericResponse>

Performs expiry cleanup on a collection

Source

pub async fn drop_collection(&self, name: &str) -> Result<GenericResponse>

Drops an existing collection

Source

pub async fn flush_collection(&self, name: &str) -> Result<GenericResponse>

Flushes a collection to disk

Source

pub async fn load_collection(&self, name: &str) -> Result<GenericResponse>

Loads a collection into memory

Source

pub async fn unload_collection(&self, name: &str) -> Result<GenericResponse>

Unloads a collection from memory

Source

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)

Source

pub async fn import_collection(&self, file_path: &Path) -> Result<()>

Imports a collection from a file

Source

pub async fn rename_collection( &self, old_name: &str, new_name: &str, ) -> Result<GenericResponse>

Renames an existing collection

Source

pub async fn reindex_collection( &self, collection_name: &str, ) -> Result<GenericResponse>

Re-indexes a collection for debug purposes

Source

pub async fn pq_train(&self, collection_name: &str) -> Result<GenericResponse>

Performs Product Quantization training for an existing collection

Source

pub async fn insert_record( &self, req: &InsertRecordRequest, ) -> Result<InsertRecordResponse>

Inserts a new record into a collection

Source

pub async fn get_collection_data( &self, collection_name: &str, offset: i32, limit: i32, ) -> Result<GetCollectionDataResponse>

Gets paginated data records from a collection

Source

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.

Source

pub async fn get_collection_schema( &self, collection_name: &str, ) -> Result<GetCollectionSchemaResponse>

Gets the schema for a collection

Source

pub async fn enable_metadata_store( &self, collection_name: &str, req: &EnableMetadataStoreRequest, ) -> Result<EnableMetadataStoreResponse>

Enables metadata store for an existing collection

Source

pub async fn list_collection_models( &self, ) -> Result<ListCollectionsModelsResponse>

Lists all collection models

Source

pub async fn get_collection_model_info( &self, collection_name: &str, model_id: &str, ) -> Result<GetCollectionModelResponse>

Gets information about a specific collection model

Source

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

Source

pub async fn ingest_data(&self, req: &IngestRequest) -> Result<IngestResponse>

Ingests data into a collection

Source

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

Source

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.

Source

pub async fn list_ingest_sources(&self) -> Result<ListIngestionSourcesResponse>

Lists available ingestion sources

Source

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

Source

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

Source

pub async fn list_embedding_models(&self) -> Result<ListEmbeddingModelsResponse>

Lists all available embedding providers and their models

Source

pub async fn list_nli_verticals(&self) -> Result<ListNLIVerticalsResponse>

Lists all available NLI verticals

Source§

impl Client

Source

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

Source

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

Source

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

Source

pub async fn get_collection_levels( &self, collection_name: &str, ) -> Result<DebugLevelsResponse>

Gets levels of a collection for debug purposes

Source

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

Source

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

Source

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

Source

pub async fn health_check(&self) -> Result<HealthResponse>

Performs a health check on the API

Source§

impl Client

Source

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)
Source

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
Source

pub async fn register_replica( &self, replica_id: &str, ) -> Result<GenericResponse>

Registers a replica for oplog retention tracking Parameters:

  • replica_id: Replica identifier
Source

pub async fn unregister_replica( &self, replica_id: &str, ) -> Result<GenericResponse>

Unregisters a replica for oplog retention tracking Parameters:

  • replica_id: Replica identifier
Source

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

Source

pub async fn get_settings(&self) -> Result<GetSettingsResponse>

Retrieves the server settings

Source

pub async fn update_settings( &self, settings: &SettingsUpdateRequest, ) -> Result<GenericResponse>

Updates server settings

Source

pub async fn list_providers(&self) -> Result<SettingsAvailableProvidersResponse>

Lists available auth and integration providers

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more