lance_namespace_reqwest_client/apis/
index_api.rs1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[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#[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#[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#[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#[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
84pub 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 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", ¶m_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
141pub 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 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", ¶m_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
198pub 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 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", ¶m_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
256pub async fn drop_table_index(configuration: &configuration::Configuration, id: &str, index_name: &str, delimiter: Option<&str>, branch: Option<&str>) -> Result<models::DropTableIndexResponse, Error<DropTableIndexError>> {
258 let p_id = id;
260 let p_index_name = index_name;
261 let p_delimiter = delimiter;
262 let p_branch = branch;
263
264 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));
265 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
266
267 if let Some(ref param_value) = p_delimiter {
268 req_builder = req_builder.query(&[("delimiter", ¶m_value.to_string())]);
269 }
270 if let Some(ref param_value) = p_branch {
271 req_builder = req_builder.query(&[("branch", ¶m_value.to_string())]);
272 }
273 if let Some(ref user_agent) = configuration.user_agent {
274 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
275 }
276 if let Some(ref token) = configuration.oauth_access_token {
277 req_builder = req_builder.bearer_auth(token.to_owned());
278 };
279 if let Some(ref apikey) = configuration.api_key {
280 let key = apikey.key.clone();
281 let value = match apikey.prefix {
282 Some(ref prefix) => format!("{} {}", prefix, key),
283 None => key,
284 };
285 req_builder = req_builder.header("x-api-key", value);
286 };
287 if let Some(ref token) = configuration.bearer_access_token {
288 req_builder = req_builder.bearer_auth(token.to_owned());
289 };
290
291 let req = req_builder.build()?;
292 let resp = configuration.client.execute(req).await?;
293
294 let status = resp.status();
295 let content_type = resp
296 .headers()
297 .get("content-type")
298 .and_then(|v| v.to_str().ok())
299 .unwrap_or("application/octet-stream");
300 let content_type = super::ContentType::from(content_type);
301
302 if !status.is_client_error() && !status.is_server_error() {
303 let content = resp.text().await?;
304 match content_type {
305 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
306 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DropTableIndexResponse`"))),
307 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`")))),
308 }
309 } else {
310 let content = resp.text().await?;
311 let entity: Option<DropTableIndexError> = serde_json::from_str(&content).ok();
312 Err(Error::ResponseError(ResponseContent { status, content, entity }))
313 }
314}
315
316pub async fn list_table_indices(configuration: &configuration::Configuration, id: &str, list_table_indices_request: models::ListTableIndicesRequest, delimiter: Option<&str>) -> Result<models::ListTableIndicesResponse, Error<ListTableIndicesError>> {
318 let p_id = id;
320 let p_list_table_indices_request = list_table_indices_request;
321 let p_delimiter = delimiter;
322
323 let uri_str = format!("{}/v1/table/{id}/index/list", configuration.base_path, id=crate::apis::urlencode(p_id));
324 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
325
326 if let Some(ref param_value) = p_delimiter {
327 req_builder = req_builder.query(&[("delimiter", ¶m_value.to_string())]);
328 }
329 if let Some(ref user_agent) = configuration.user_agent {
330 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
331 }
332 if let Some(ref token) = configuration.oauth_access_token {
333 req_builder = req_builder.bearer_auth(token.to_owned());
334 };
335 if let Some(ref apikey) = configuration.api_key {
336 let key = apikey.key.clone();
337 let value = match apikey.prefix {
338 Some(ref prefix) => format!("{} {}", prefix, key),
339 None => key,
340 };
341 req_builder = req_builder.header("x-api-key", value);
342 };
343 if let Some(ref token) = configuration.bearer_access_token {
344 req_builder = req_builder.bearer_auth(token.to_owned());
345 };
346 req_builder = req_builder.json(&p_list_table_indices_request);
347
348 let req = req_builder.build()?;
349 let resp = configuration.client.execute(req).await?;
350
351 let status = resp.status();
352 let content_type = resp
353 .headers()
354 .get("content-type")
355 .and_then(|v| v.to_str().ok())
356 .unwrap_or("application/octet-stream");
357 let content_type = super::ContentType::from(content_type);
358
359 if !status.is_client_error() && !status.is_server_error() {
360 let content = resp.text().await?;
361 match content_type {
362 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
363 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListTableIndicesResponse`"))),
364 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`")))),
365 }
366 } else {
367 let content = resp.text().await?;
368 let entity: Option<ListTableIndicesError> = serde_json::from_str(&content).ok();
369 Err(Error::ResponseError(ResponseContent { status, content, entity }))
370 }
371}
372