lance_namespace_reqwest_client/apis/
index_api.rs

1/*
2 * Lance Namespace Specification
3 *
4 * This OpenAPI specification is a part of the Lance namespace specification. It contains 2 parts:  The `components/schemas`, `components/responses`, `components/examples`, `tags` sections define the request and response shape for each operation in a Lance Namespace across all implementations. See https://lancedb.github.io/lance-namespace/spec/operations for more details.  The `servers`, `security`, `paths`, `components/parameters` sections are for the  Lance REST Namespace implementation, which defines a complete REST server that can work with Lance datasets. See https://lancedb.github.io/lance-namespace/spec/impls/rest for more details. 
5 *
6 * The version of the OpenAPI document: 1.0.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`create_table_index`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateTableIndexError {
22    Status400(models::ErrorResponse),
23    Status401(models::ErrorResponse),
24    Status403(models::ErrorResponse),
25    Status404(models::ErrorResponse),
26    Status503(models::ErrorResponse),
27    Status5XX(models::ErrorResponse),
28    UnknownValue(serde_json::Value),
29}
30
31/// struct for typed errors of method [`describe_table_index_stats`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum DescribeTableIndexStatsError {
35    Status400(models::ErrorResponse),
36    Status401(models::ErrorResponse),
37    Status403(models::ErrorResponse),
38    Status404(models::ErrorResponse),
39    Status503(models::ErrorResponse),
40    Status5XX(models::ErrorResponse),
41    UnknownValue(serde_json::Value),
42}
43
44/// struct for typed errors of method [`drop_table_index`]
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum DropTableIndexError {
48    Status400(models::ErrorResponse),
49    Status401(models::ErrorResponse),
50    Status403(models::ErrorResponse),
51    Status404(models::ErrorResponse),
52    Status503(models::ErrorResponse),
53    Status5XX(models::ErrorResponse),
54    UnknownValue(serde_json::Value),
55}
56
57/// struct for typed errors of method [`list_table_indices`]
58#[derive(Debug, Clone, Serialize, Deserialize)]
59#[serde(untagged)]
60pub enum ListTableIndicesError {
61    Status400(models::ErrorResponse),
62    Status401(models::ErrorResponse),
63    Status403(models::ErrorResponse),
64    Status404(models::ErrorResponse),
65    Status503(models::ErrorResponse),
66    Status5XX(models::ErrorResponse),
67    UnknownValue(serde_json::Value),
68}
69
70
71/// Create an index on a table column for faster search operations. Supports vector indexes (IVF_FLAT, IVF_HNSW_SQ, IVF_PQ, etc.) and scalar indexes (BTREE, BITMAP, FTS, etc.). Index creation is handled asynchronously.  Use the `ListTableIndices` and `DescribeTableIndexStats` operations to monitor index creation progress. 
72pub async fn create_table_index(configuration: &configuration::Configuration, id: &str, create_table_index_request: models::CreateTableIndexRequest, delimiter: Option<&str>) -> Result<models::CreateTableIndexResponse, Error<CreateTableIndexError>> {
73    // add a prefix to parameters to efficiently prevent name collisions
74    let p_id = id;
75    let p_create_table_index_request = create_table_index_request;
76    let p_delimiter = delimiter;
77
78    let uri_str = format!("{}/v1/table/{id}/create_index", configuration.base_path, id=crate::apis::urlencode(p_id));
79    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
80
81    if let Some(ref param_value) = p_delimiter {
82        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
83    }
84    if let Some(ref user_agent) = configuration.user_agent {
85        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
86    }
87    req_builder = req_builder.json(&p_create_table_index_request);
88
89    let req = req_builder.build()?;
90    let resp = configuration.client.execute(req).await?;
91
92    let status = resp.status();
93    let content_type = resp
94        .headers()
95        .get("content-type")
96        .and_then(|v| v.to_str().ok())
97        .unwrap_or("application/octet-stream");
98    let content_type = super::ContentType::from(content_type);
99
100    if !status.is_client_error() && !status.is_server_error() {
101        let content = resp.text().await?;
102        match content_type {
103            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
104            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateTableIndexResponse`"))),
105            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateTableIndexResponse`")))),
106        }
107    } else {
108        let content = resp.text().await?;
109        let entity: Option<CreateTableIndexError> = serde_json::from_str(&content).ok();
110        Err(Error::ResponseError(ResponseContent { status, content, entity }))
111    }
112}
113
114/// Get statistics for a specific index on a table. Returns information about the index type, distance type (for vector indices), and row counts. 
115pub async fn describe_table_index_stats(configuration: &configuration::Configuration, id: &str, index_name: &str, describe_table_index_stats_request: models::DescribeTableIndexStatsRequest, delimiter: Option<&str>) -> Result<models::DescribeTableIndexStatsResponse, Error<DescribeTableIndexStatsError>> {
116    // add a prefix to parameters to efficiently prevent name collisions
117    let p_id = id;
118    let p_index_name = index_name;
119    let p_describe_table_index_stats_request = describe_table_index_stats_request;
120    let p_delimiter = delimiter;
121
122    let uri_str = format!("{}/v1/table/{id}/index/{index_name}/stats", configuration.base_path, id=crate::apis::urlencode(p_id), index_name=crate::apis::urlencode(p_index_name));
123    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
124
125    if let Some(ref param_value) = p_delimiter {
126        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
127    }
128    if let Some(ref user_agent) = configuration.user_agent {
129        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
130    }
131    req_builder = req_builder.json(&p_describe_table_index_stats_request);
132
133    let req = req_builder.build()?;
134    let resp = configuration.client.execute(req).await?;
135
136    let status = resp.status();
137    let content_type = resp
138        .headers()
139        .get("content-type")
140        .and_then(|v| v.to_str().ok())
141        .unwrap_or("application/octet-stream");
142    let content_type = super::ContentType::from(content_type);
143
144    if !status.is_client_error() && !status.is_server_error() {
145        let content = resp.text().await?;
146        match content_type {
147            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
148            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DescribeTableIndexStatsResponse`"))),
149            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DescribeTableIndexStatsResponse`")))),
150        }
151    } else {
152        let content = resp.text().await?;
153        let entity: Option<DescribeTableIndexStatsError> = serde_json::from_str(&content).ok();
154        Err(Error::ResponseError(ResponseContent { status, content, entity }))
155    }
156}
157
158/// Drop the specified index from table `id`. 
159pub async fn drop_table_index(configuration: &configuration::Configuration, id: &str, index_name: &str, drop_table_index_request: models::DropTableIndexRequest, delimiter: Option<&str>) -> Result<models::DropTableIndexResponse, Error<DropTableIndexError>> {
160    // add a prefix to parameters to efficiently prevent name collisions
161    let p_id = id;
162    let p_index_name = index_name;
163    let p_drop_table_index_request = drop_table_index_request;
164    let p_delimiter = delimiter;
165
166    let uri_str = format!("{}/v1/table/{id}/index/{index_name}/drop", configuration.base_path, id=crate::apis::urlencode(p_id), index_name=crate::apis::urlencode(p_index_name));
167    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
168
169    if let Some(ref param_value) = p_delimiter {
170        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
171    }
172    if let Some(ref user_agent) = configuration.user_agent {
173        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
174    }
175    req_builder = req_builder.json(&p_drop_table_index_request);
176
177    let req = req_builder.build()?;
178    let resp = configuration.client.execute(req).await?;
179
180    let status = resp.status();
181    let content_type = resp
182        .headers()
183        .get("content-type")
184        .and_then(|v| v.to_str().ok())
185        .unwrap_or("application/octet-stream");
186    let content_type = super::ContentType::from(content_type);
187
188    if !status.is_client_error() && !status.is_server_error() {
189        let content = resp.text().await?;
190        match content_type {
191            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
192            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DropTableIndexResponse`"))),
193            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DropTableIndexResponse`")))),
194        }
195    } else {
196        let content = resp.text().await?;
197        let entity: Option<DropTableIndexError> = serde_json::from_str(&content).ok();
198        Err(Error::ResponseError(ResponseContent { status, content, entity }))
199    }
200}
201
202/// List all indices created on a table. Returns information about each index including name, columns, status, and UUID. 
203pub async fn list_table_indices(configuration: &configuration::Configuration, id: &str, list_table_indices_request: models::ListTableIndicesRequest, delimiter: Option<&str>) -> Result<models::ListTableIndicesResponse, Error<ListTableIndicesError>> {
204    // add a prefix to parameters to efficiently prevent name collisions
205    let p_id = id;
206    let p_list_table_indices_request = list_table_indices_request;
207    let p_delimiter = delimiter;
208
209    let uri_str = format!("{}/v1/table/{id}/index/list", configuration.base_path, id=crate::apis::urlencode(p_id));
210    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
211
212    if let Some(ref param_value) = p_delimiter {
213        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
214    }
215    if let Some(ref user_agent) = configuration.user_agent {
216        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
217    }
218    req_builder = req_builder.json(&p_list_table_indices_request);
219
220    let req = req_builder.build()?;
221    let resp = configuration.client.execute(req).await?;
222
223    let status = resp.status();
224    let content_type = resp
225        .headers()
226        .get("content-type")
227        .and_then(|v| v.to_str().ok())
228        .unwrap_or("application/octet-stream");
229    let content_type = super::ContentType::from(content_type);
230
231    if !status.is_client_error() && !status.is_server_error() {
232        let content = resp.text().await?;
233        match content_type {
234            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
235            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListTableIndicesResponse`"))),
236            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListTableIndicesResponse`")))),
237        }
238    } else {
239        let content = resp.text().await?;
240        let entity: Option<ListTableIndicesError> = serde_json::from_str(&content).ok();
241        Err(Error::ResponseError(ResponseContent { status, content, entity }))
242    }
243}
244