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://lance.org/format/namespace/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://lance.org/format/namespace/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 [`create_table_scalar_index`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum CreateTableScalarIndexError {
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 [`describe_table_index_stats`]
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum DescribeTableIndexStatsError {
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 [`drop_table_index`]
58#[derive(Debug, Clone, Serialize, Deserialize)]
59#[serde(untagged)]
60pub enum DropTableIndexError {
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/// struct for typed errors of method [`list_table_indices`]
71#[derive(Debug, Clone, Serialize, Deserialize)]
72#[serde(untagged)]
73pub enum ListTableIndicesError {
74    Status400(models::ErrorResponse),
75    Status401(models::ErrorResponse),
76    Status403(models::ErrorResponse),
77    Status404(models::ErrorResponse),
78    Status503(models::ErrorResponse),
79    Status5XX(models::ErrorResponse),
80    UnknownValue(serde_json::Value),
81}
82
83
84/// 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. 
85pub async fn create_table_index(configuration: &configuration::Configuration, id: &str, create_table_index_request: models::CreateTableIndexRequest, delimiter: Option<&str>) -> Result<models::CreateTableIndexResponse, Error<CreateTableIndexError>> {
86    // add a prefix to parameters to efficiently prevent name collisions
87    let p_id = id;
88    let p_create_table_index_request = create_table_index_request;
89    let p_delimiter = delimiter;
90
91    let uri_str = format!("{}/v1/table/{id}/create_index", configuration.base_path, id=crate::apis::urlencode(p_id));
92    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
93
94    if let Some(ref param_value) = p_delimiter {
95        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
96    }
97    if let Some(ref user_agent) = configuration.user_agent {
98        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
99    }
100    if let Some(ref token) = configuration.oauth_access_token {
101        req_builder = req_builder.bearer_auth(token.to_owned());
102    };
103    if let Some(ref apikey) = configuration.api_key {
104        let key = apikey.key.clone();
105        let value = match apikey.prefix {
106            Some(ref prefix) => format!("{} {}", prefix, key),
107            None => key,
108        };
109        req_builder = req_builder.header("x-api-key", value);
110    };
111    if let Some(ref token) = configuration.bearer_access_token {
112        req_builder = req_builder.bearer_auth(token.to_owned());
113    };
114    req_builder = req_builder.json(&p_create_table_index_request);
115
116    let req = req_builder.build()?;
117    let resp = configuration.client.execute(req).await?;
118
119    let status = resp.status();
120    let content_type = resp
121        .headers()
122        .get("content-type")
123        .and_then(|v| v.to_str().ok())
124        .unwrap_or("application/octet-stream");
125    let content_type = super::ContentType::from(content_type);
126
127    if !status.is_client_error() && !status.is_server_error() {
128        let content = resp.text().await?;
129        match content_type {
130            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
131            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateTableIndexResponse`"))),
132            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`")))),
133        }
134    } else {
135        let content = resp.text().await?;
136        let entity: Option<CreateTableIndexError> = serde_json::from_str(&content).ok();
137        Err(Error::ResponseError(ResponseContent { status, content, entity }))
138    }
139}
140
141/// Create a scalar index on a table column for faster filtering operations. Supports scalar indexes (BTREE, BITMAP, LABEL_LIST, FTS, etc.). This is an alias for CreateTableIndex specifically for scalar indexes. Index creation is handled asynchronously. Use the `ListTableIndices` and `DescribeTableIndexStats` operations to monitor index creation progress. 
142pub async fn create_table_scalar_index(configuration: &configuration::Configuration, id: &str, create_table_index_request: models::CreateTableIndexRequest, delimiter: Option<&str>) -> Result<models::CreateTableScalarIndexResponse, Error<CreateTableScalarIndexError>> {
143    // add a prefix to parameters to efficiently prevent name collisions
144    let p_id = id;
145    let p_create_table_index_request = create_table_index_request;
146    let p_delimiter = delimiter;
147
148    let uri_str = format!("{}/v1/table/{id}/create_scalar_index", configuration.base_path, id=crate::apis::urlencode(p_id));
149    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
150
151    if let Some(ref param_value) = p_delimiter {
152        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
153    }
154    if let Some(ref user_agent) = configuration.user_agent {
155        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
156    }
157    if let Some(ref token) = configuration.oauth_access_token {
158        req_builder = req_builder.bearer_auth(token.to_owned());
159    };
160    if let Some(ref apikey) = configuration.api_key {
161        let key = apikey.key.clone();
162        let value = match apikey.prefix {
163            Some(ref prefix) => format!("{} {}", prefix, key),
164            None => key,
165        };
166        req_builder = req_builder.header("x-api-key", value);
167    };
168    if let Some(ref token) = configuration.bearer_access_token {
169        req_builder = req_builder.bearer_auth(token.to_owned());
170    };
171    req_builder = req_builder.json(&p_create_table_index_request);
172
173    let req = req_builder.build()?;
174    let resp = configuration.client.execute(req).await?;
175
176    let status = resp.status();
177    let content_type = resp
178        .headers()
179        .get("content-type")
180        .and_then(|v| v.to_str().ok())
181        .unwrap_or("application/octet-stream");
182    let content_type = super::ContentType::from(content_type);
183
184    if !status.is_client_error() && !status.is_server_error() {
185        let content = resp.text().await?;
186        match content_type {
187            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
188            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateTableScalarIndexResponse`"))),
189            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::CreateTableScalarIndexResponse`")))),
190        }
191    } else {
192        let content = resp.text().await?;
193        let entity: Option<CreateTableScalarIndexError> = serde_json::from_str(&content).ok();
194        Err(Error::ResponseError(ResponseContent { status, content, entity }))
195    }
196}
197
198/// Get statistics for a specific index on a table. Returns information about the index type, distance type (for vector indices), and row counts. 
199pub 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>> {
200    // add a prefix to parameters to efficiently prevent name collisions
201    let p_id = id;
202    let p_index_name = index_name;
203    let p_describe_table_index_stats_request = describe_table_index_stats_request;
204    let p_delimiter = delimiter;
205
206    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));
207    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
208
209    if let Some(ref param_value) = p_delimiter {
210        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
211    }
212    if let Some(ref user_agent) = configuration.user_agent {
213        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
214    }
215    if let Some(ref token) = configuration.oauth_access_token {
216        req_builder = req_builder.bearer_auth(token.to_owned());
217    };
218    if let Some(ref apikey) = configuration.api_key {
219        let key = apikey.key.clone();
220        let value = match apikey.prefix {
221            Some(ref prefix) => format!("{} {}", prefix, key),
222            None => key,
223        };
224        req_builder = req_builder.header("x-api-key", value);
225    };
226    if let Some(ref token) = configuration.bearer_access_token {
227        req_builder = req_builder.bearer_auth(token.to_owned());
228    };
229    req_builder = req_builder.json(&p_describe_table_index_stats_request);
230
231    let req = req_builder.build()?;
232    let resp = configuration.client.execute(req).await?;
233
234    let status = resp.status();
235    let content_type = resp
236        .headers()
237        .get("content-type")
238        .and_then(|v| v.to_str().ok())
239        .unwrap_or("application/octet-stream");
240    let content_type = super::ContentType::from(content_type);
241
242    if !status.is_client_error() && !status.is_server_error() {
243        let content = resp.text().await?;
244        match content_type {
245            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
246            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DescribeTableIndexStatsResponse`"))),
247            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`")))),
248        }
249    } else {
250        let content = resp.text().await?;
251        let entity: Option<DescribeTableIndexStatsError> = serde_json::from_str(&content).ok();
252        Err(Error::ResponseError(ResponseContent { status, content, entity }))
253    }
254}
255
256/// Drop the specified index from table `id`.  REST NAMESPACE ONLY REST namespace does not use a request body for this operation. The `DropTableIndexRequest` information is passed in the following way: - `id`: pass through path parameter of the same name - `index_name`: pass through path parameter of the same name 
257pub async fn drop_table_index(configuration: &configuration::Configuration, id: &str, index_name: &str, delimiter: Option<&str>) -> Result<models::DropTableIndexResponse, Error<DropTableIndexError>> {
258    // add a prefix to parameters to efficiently prevent name collisions
259    let p_id = id;
260    let p_index_name = index_name;
261    let p_delimiter = delimiter;
262
263    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));
264    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
265
266    if let Some(ref param_value) = p_delimiter {
267        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
268    }
269    if let Some(ref user_agent) = configuration.user_agent {
270        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
271    }
272    if let Some(ref token) = configuration.oauth_access_token {
273        req_builder = req_builder.bearer_auth(token.to_owned());
274    };
275    if let Some(ref apikey) = configuration.api_key {
276        let key = apikey.key.clone();
277        let value = match apikey.prefix {
278            Some(ref prefix) => format!("{} {}", prefix, key),
279            None => key,
280        };
281        req_builder = req_builder.header("x-api-key", value);
282    };
283    if let Some(ref token) = configuration.bearer_access_token {
284        req_builder = req_builder.bearer_auth(token.to_owned());
285    };
286
287    let req = req_builder.build()?;
288    let resp = configuration.client.execute(req).await?;
289
290    let status = resp.status();
291    let content_type = resp
292        .headers()
293        .get("content-type")
294        .and_then(|v| v.to_str().ok())
295        .unwrap_or("application/octet-stream");
296    let content_type = super::ContentType::from(content_type);
297
298    if !status.is_client_error() && !status.is_server_error() {
299        let content = resp.text().await?;
300        match content_type {
301            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
302            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DropTableIndexResponse`"))),
303            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`")))),
304        }
305    } else {
306        let content = resp.text().await?;
307        let entity: Option<DropTableIndexError> = serde_json::from_str(&content).ok();
308        Err(Error::ResponseError(ResponseContent { status, content, entity }))
309    }
310}
311
312/// List all indices created on a table. Returns information about each index including name, columns, status, and UUID. 
313pub async fn list_table_indices(configuration: &configuration::Configuration, id: &str, list_table_indices_request: models::ListTableIndicesRequest, delimiter: Option<&str>) -> Result<models::ListTableIndicesResponse, Error<ListTableIndicesError>> {
314    // add a prefix to parameters to efficiently prevent name collisions
315    let p_id = id;
316    let p_list_table_indices_request = list_table_indices_request;
317    let p_delimiter = delimiter;
318
319    let uri_str = format!("{}/v1/table/{id}/index/list", configuration.base_path, id=crate::apis::urlencode(p_id));
320    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
321
322    if let Some(ref param_value) = p_delimiter {
323        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
324    }
325    if let Some(ref user_agent) = configuration.user_agent {
326        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
327    }
328    if let Some(ref token) = configuration.oauth_access_token {
329        req_builder = req_builder.bearer_auth(token.to_owned());
330    };
331    if let Some(ref apikey) = configuration.api_key {
332        let key = apikey.key.clone();
333        let value = match apikey.prefix {
334            Some(ref prefix) => format!("{} {}", prefix, key),
335            None => key,
336        };
337        req_builder = req_builder.header("x-api-key", value);
338    };
339    if let Some(ref token) = configuration.bearer_access_token {
340        req_builder = req_builder.bearer_auth(token.to_owned());
341    };
342    req_builder = req_builder.json(&p_list_table_indices_request);
343
344    let req = req_builder.build()?;
345    let resp = configuration.client.execute(req).await?;
346
347    let status = resp.status();
348    let content_type = resp
349        .headers()
350        .get("content-type")
351        .and_then(|v| v.to_str().ok())
352        .unwrap_or("application/octet-stream");
353    let content_type = super::ContentType::from(content_type);
354
355    if !status.is_client_error() && !status.is_server_error() {
356        let content = resp.text().await?;
357        match content_type {
358            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
359            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListTableIndicesResponse`"))),
360            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`")))),
361        }
362    } else {
363        let content = resp.text().await?;
364        let entity: Option<ListTableIndicesError> = serde_json::from_str(&content).ok();
365        Err(Error::ResponseError(ResponseContent { status, content, entity }))
366    }
367}
368