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>) -> Result<models::DropTableIndexResponse, Error<DropTableIndexError>> {
258 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", ¶m_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
312pub 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 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", ¶m_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