lance_namespace_reqwest_client/apis/
data_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 [`alter_table_add_columns`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AlterTableAddColumnsError {
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 [`analyze_table_query_plan`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum AnalyzeTableQueryPlanError {
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 [`count_table_rows`]
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum CountTableRowsError {
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 [`create_table`]
58#[derive(Debug, Clone, Serialize, Deserialize)]
59#[serde(untagged)]
60pub enum CreateTableError {
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 [`delete_from_table`]
71#[derive(Debug, Clone, Serialize, Deserialize)]
72#[serde(untagged)]
73pub enum DeleteFromTableError {
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/// struct for typed errors of method [`explain_table_query_plan`]
84#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(untagged)]
86pub enum ExplainTableQueryPlanError {
87    Status400(models::ErrorResponse),
88    Status401(models::ErrorResponse),
89    Status403(models::ErrorResponse),
90    Status404(models::ErrorResponse),
91    Status503(models::ErrorResponse),
92    Status5XX(models::ErrorResponse),
93    UnknownValue(serde_json::Value),
94}
95
96/// struct for typed errors of method [`insert_into_table`]
97#[derive(Debug, Clone, Serialize, Deserialize)]
98#[serde(untagged)]
99pub enum InsertIntoTableError {
100    Status400(models::ErrorResponse),
101    Status401(models::ErrorResponse),
102    Status403(models::ErrorResponse),
103    Status404(models::ErrorResponse),
104    Status503(models::ErrorResponse),
105    Status5XX(models::ErrorResponse),
106    UnknownValue(serde_json::Value),
107}
108
109/// struct for typed errors of method [`merge_insert_into_table`]
110#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum MergeInsertIntoTableError {
113    Status400(models::ErrorResponse),
114    Status401(models::ErrorResponse),
115    Status403(models::ErrorResponse),
116    Status404(models::ErrorResponse),
117    Status503(models::ErrorResponse),
118    Status5XX(models::ErrorResponse),
119    UnknownValue(serde_json::Value),
120}
121
122/// struct for typed errors of method [`query_table`]
123#[derive(Debug, Clone, Serialize, Deserialize)]
124#[serde(untagged)]
125pub enum QueryTableError {
126    Status400(models::ErrorResponse),
127    Status401(models::ErrorResponse),
128    Status403(models::ErrorResponse),
129    Status404(models::ErrorResponse),
130    Status503(models::ErrorResponse),
131    Status5XX(models::ErrorResponse),
132    UnknownValue(serde_json::Value),
133}
134
135/// struct for typed errors of method [`update_table`]
136#[derive(Debug, Clone, Serialize, Deserialize)]
137#[serde(untagged)]
138pub enum UpdateTableError {
139    Status400(models::ErrorResponse),
140    Status401(models::ErrorResponse),
141    Status403(models::ErrorResponse),
142    Status404(models::ErrorResponse),
143    Status503(models::ErrorResponse),
144    Status5XX(models::ErrorResponse),
145    UnknownValue(serde_json::Value),
146}
147
148
149/// Add new columns to table `id` using SQL expressions or default values. 
150pub async fn alter_table_add_columns(configuration: &configuration::Configuration, id: &str, alter_table_add_columns_request: models::AlterTableAddColumnsRequest, delimiter: Option<&str>) -> Result<models::AlterTableAddColumnsResponse, Error<AlterTableAddColumnsError>> {
151    // add a prefix to parameters to efficiently prevent name collisions
152    let p_id = id;
153    let p_alter_table_add_columns_request = alter_table_add_columns_request;
154    let p_delimiter = delimiter;
155
156    let uri_str = format!("{}/v1/table/{id}/add_columns", configuration.base_path, id=crate::apis::urlencode(p_id));
157    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
158
159    if let Some(ref param_value) = p_delimiter {
160        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
161    }
162    if let Some(ref user_agent) = configuration.user_agent {
163        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
164    }
165    if let Some(ref token) = configuration.oauth_access_token {
166        req_builder = req_builder.bearer_auth(token.to_owned());
167    };
168    if let Some(ref apikey) = configuration.api_key {
169        let key = apikey.key.clone();
170        let value = match apikey.prefix {
171            Some(ref prefix) => format!("{} {}", prefix, key),
172            None => key,
173        };
174        req_builder = req_builder.header("x-api-key", value);
175    };
176    if let Some(ref token) = configuration.bearer_access_token {
177        req_builder = req_builder.bearer_auth(token.to_owned());
178    };
179    req_builder = req_builder.json(&p_alter_table_add_columns_request);
180
181    let req = req_builder.build()?;
182    let resp = configuration.client.execute(req).await?;
183
184    let status = resp.status();
185    let content_type = resp
186        .headers()
187        .get("content-type")
188        .and_then(|v| v.to_str().ok())
189        .unwrap_or("application/octet-stream");
190    let content_type = super::ContentType::from(content_type);
191
192    if !status.is_client_error() && !status.is_server_error() {
193        let content = resp.text().await?;
194        match content_type {
195            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
196            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AlterTableAddColumnsResponse`"))),
197            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::AlterTableAddColumnsResponse`")))),
198        }
199    } else {
200        let content = resp.text().await?;
201        let entity: Option<AlterTableAddColumnsError> = serde_json::from_str(&content).ok();
202        Err(Error::ResponseError(ResponseContent { status, content, entity }))
203    }
204}
205
206/// Analyze the query execution plan for a query against table `id`. Returns detailed statistics and analysis of the query execution plan.  REST NAMESPACE ONLY REST namespace returns the response as a plain string instead of the `AnalyzeTableQueryPlanResponse` JSON object. 
207pub async fn analyze_table_query_plan(configuration: &configuration::Configuration, id: &str, analyze_table_query_plan_request: models::AnalyzeTableQueryPlanRequest, delimiter: Option<&str>) -> Result<String, Error<AnalyzeTableQueryPlanError>> {
208    // add a prefix to parameters to efficiently prevent name collisions
209    let p_id = id;
210    let p_analyze_table_query_plan_request = analyze_table_query_plan_request;
211    let p_delimiter = delimiter;
212
213    let uri_str = format!("{}/v1/table/{id}/analyze_plan", configuration.base_path, id=crate::apis::urlencode(p_id));
214    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
215
216    if let Some(ref param_value) = p_delimiter {
217        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
218    }
219    if let Some(ref user_agent) = configuration.user_agent {
220        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
221    }
222    if let Some(ref token) = configuration.oauth_access_token {
223        req_builder = req_builder.bearer_auth(token.to_owned());
224    };
225    if let Some(ref apikey) = configuration.api_key {
226        let key = apikey.key.clone();
227        let value = match apikey.prefix {
228            Some(ref prefix) => format!("{} {}", prefix, key),
229            None => key,
230        };
231        req_builder = req_builder.header("x-api-key", value);
232    };
233    if let Some(ref token) = configuration.bearer_access_token {
234        req_builder = req_builder.bearer_auth(token.to_owned());
235    };
236    req_builder = req_builder.json(&p_analyze_table_query_plan_request);
237
238    let req = req_builder.build()?;
239    let resp = configuration.client.execute(req).await?;
240
241    let status = resp.status();
242    let content_type = resp
243        .headers()
244        .get("content-type")
245        .and_then(|v| v.to_str().ok())
246        .unwrap_or("application/octet-stream");
247    let content_type = super::ContentType::from(content_type);
248
249    if !status.is_client_error() && !status.is_server_error() {
250        let content = resp.text().await?;
251        match content_type {
252            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
253            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
254            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
255        }
256    } else {
257        let content = resp.text().await?;
258        let entity: Option<AnalyzeTableQueryPlanError> = serde_json::from_str(&content).ok();
259        Err(Error::ResponseError(ResponseContent { status, content, entity }))
260    }
261}
262
263/// Count the number of rows in table `id`  REST NAMESPACE ONLY REST namespace returns the response as a plain integer instead of the `CountTableRowsResponse` JSON object. 
264pub async fn count_table_rows(configuration: &configuration::Configuration, id: &str, count_table_rows_request: models::CountTableRowsRequest, delimiter: Option<&str>) -> Result<i64, Error<CountTableRowsError>> {
265    // add a prefix to parameters to efficiently prevent name collisions
266    let p_id = id;
267    let p_count_table_rows_request = count_table_rows_request;
268    let p_delimiter = delimiter;
269
270    let uri_str = format!("{}/v1/table/{id}/count_rows", configuration.base_path, id=crate::apis::urlencode(p_id));
271    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
272
273    if let Some(ref param_value) = p_delimiter {
274        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
275    }
276    if let Some(ref user_agent) = configuration.user_agent {
277        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
278    }
279    if let Some(ref token) = configuration.oauth_access_token {
280        req_builder = req_builder.bearer_auth(token.to_owned());
281    };
282    if let Some(ref apikey) = configuration.api_key {
283        let key = apikey.key.clone();
284        let value = match apikey.prefix {
285            Some(ref prefix) => format!("{} {}", prefix, key),
286            None => key,
287        };
288        req_builder = req_builder.header("x-api-key", value);
289    };
290    if let Some(ref token) = configuration.bearer_access_token {
291        req_builder = req_builder.bearer_auth(token.to_owned());
292    };
293    req_builder = req_builder.json(&p_count_table_rows_request);
294
295    let req = req_builder.build()?;
296    let resp = configuration.client.execute(req).await?;
297
298    let status = resp.status();
299    let content_type = resp
300        .headers()
301        .get("content-type")
302        .and_then(|v| v.to_str().ok())
303        .unwrap_or("application/octet-stream");
304    let content_type = super::ContentType::from(content_type);
305
306    if !status.is_client_error() && !status.is_server_error() {
307        let content = resp.text().await?;
308        match content_type {
309            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
310            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `i64`"))),
311            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `i64`")))),
312        }
313    } else {
314        let content = resp.text().await?;
315        let entity: Option<CountTableRowsError> = serde_json::from_str(&content).ok();
316        Err(Error::ResponseError(ResponseContent { status, content, entity }))
317    }
318}
319
320/// Create table `id` in the namespace with the given data in Arrow IPC stream.  The schema of the Arrow IPC stream is used as the table schema. If the stream is empty, the API creates a new empty table.  REST NAMESPACE ONLY REST namespace uses Arrow IPC stream as the request body. It passes in the `CreateTableRequest` information in the following way: - `id`: pass through path parameter of the same name - `mode`: pass through query parameter of the same name 
321pub async fn create_table(configuration: &configuration::Configuration, id: &str, body: Vec<u8>, delimiter: Option<&str>, mode: Option<&str>) -> Result<models::CreateTableResponse, Error<CreateTableError>> {
322    // add a prefix to parameters to efficiently prevent name collisions
323    let p_id = id;
324    let p_body = body;
325    let p_delimiter = delimiter;
326    let p_mode = mode;
327
328    let uri_str = format!("{}/v1/table/{id}/create", configuration.base_path, id=crate::apis::urlencode(p_id));
329    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
330
331    if let Some(ref param_value) = p_delimiter {
332        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
333    }
334    if let Some(ref param_value) = p_mode {
335        req_builder = req_builder.query(&[("mode", &param_value.to_string())]);
336    }
337    if let Some(ref user_agent) = configuration.user_agent {
338        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
339    }
340    if let Some(ref token) = configuration.oauth_access_token {
341        req_builder = req_builder.bearer_auth(token.to_owned());
342    };
343    if let Some(ref apikey) = configuration.api_key {
344        let key = apikey.key.clone();
345        let value = match apikey.prefix {
346            Some(ref prefix) => format!("{} {}", prefix, key),
347            None => key,
348        };
349        req_builder = req_builder.header("x-api-key", value);
350    };
351    if let Some(ref token) = configuration.bearer_access_token {
352        req_builder = req_builder.bearer_auth(token.to_owned());
353    };
354    req_builder = req_builder.body(p_body);
355
356    let req = req_builder.build()?;
357    let resp = configuration.client.execute(req).await?;
358
359    let status = resp.status();
360    let content_type = resp
361        .headers()
362        .get("content-type")
363        .and_then(|v| v.to_str().ok())
364        .unwrap_or("application/octet-stream");
365    let content_type = super::ContentType::from(content_type);
366
367    if !status.is_client_error() && !status.is_server_error() {
368        let content = resp.text().await?;
369        match content_type {
370            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
371            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateTableResponse`"))),
372            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::CreateTableResponse`")))),
373        }
374    } else {
375        let content = resp.text().await?;
376        let entity: Option<CreateTableError> = serde_json::from_str(&content).ok();
377        Err(Error::ResponseError(ResponseContent { status, content, entity }))
378    }
379}
380
381/// Delete rows from table `id`. 
382pub async fn delete_from_table(configuration: &configuration::Configuration, id: &str, delete_from_table_request: models::DeleteFromTableRequest, delimiter: Option<&str>) -> Result<models::DeleteFromTableResponse, Error<DeleteFromTableError>> {
383    // add a prefix to parameters to efficiently prevent name collisions
384    let p_id = id;
385    let p_delete_from_table_request = delete_from_table_request;
386    let p_delimiter = delimiter;
387
388    let uri_str = format!("{}/v1/table/{id}/delete", configuration.base_path, id=crate::apis::urlencode(p_id));
389    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
390
391    if let Some(ref param_value) = p_delimiter {
392        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
393    }
394    if let Some(ref user_agent) = configuration.user_agent {
395        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
396    }
397    if let Some(ref token) = configuration.oauth_access_token {
398        req_builder = req_builder.bearer_auth(token.to_owned());
399    };
400    if let Some(ref apikey) = configuration.api_key {
401        let key = apikey.key.clone();
402        let value = match apikey.prefix {
403            Some(ref prefix) => format!("{} {}", prefix, key),
404            None => key,
405        };
406        req_builder = req_builder.header("x-api-key", value);
407    };
408    if let Some(ref token) = configuration.bearer_access_token {
409        req_builder = req_builder.bearer_auth(token.to_owned());
410    };
411    req_builder = req_builder.json(&p_delete_from_table_request);
412
413    let req = req_builder.build()?;
414    let resp = configuration.client.execute(req).await?;
415
416    let status = resp.status();
417    let content_type = resp
418        .headers()
419        .get("content-type")
420        .and_then(|v| v.to_str().ok())
421        .unwrap_or("application/octet-stream");
422    let content_type = super::ContentType::from(content_type);
423
424    if !status.is_client_error() && !status.is_server_error() {
425        let content = resp.text().await?;
426        match content_type {
427            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
428            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteFromTableResponse`"))),
429            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::DeleteFromTableResponse`")))),
430        }
431    } else {
432        let content = resp.text().await?;
433        let entity: Option<DeleteFromTableError> = serde_json::from_str(&content).ok();
434        Err(Error::ResponseError(ResponseContent { status, content, entity }))
435    }
436}
437
438/// Get the query execution plan for a query against table `id`. Returns a human-readable explanation of how the query will be executed.  REST NAMESPACE ONLY REST namespace returns the response as a plain string instead of the `ExplainTableQueryPlanResponse` JSON object. 
439pub async fn explain_table_query_plan(configuration: &configuration::Configuration, id: &str, explain_table_query_plan_request: models::ExplainTableQueryPlanRequest, delimiter: Option<&str>) -> Result<String, Error<ExplainTableQueryPlanError>> {
440    // add a prefix to parameters to efficiently prevent name collisions
441    let p_id = id;
442    let p_explain_table_query_plan_request = explain_table_query_plan_request;
443    let p_delimiter = delimiter;
444
445    let uri_str = format!("{}/v1/table/{id}/explain_plan", configuration.base_path, id=crate::apis::urlencode(p_id));
446    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
447
448    if let Some(ref param_value) = p_delimiter {
449        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
450    }
451    if let Some(ref user_agent) = configuration.user_agent {
452        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
453    }
454    if let Some(ref token) = configuration.oauth_access_token {
455        req_builder = req_builder.bearer_auth(token.to_owned());
456    };
457    if let Some(ref apikey) = configuration.api_key {
458        let key = apikey.key.clone();
459        let value = match apikey.prefix {
460            Some(ref prefix) => format!("{} {}", prefix, key),
461            None => key,
462        };
463        req_builder = req_builder.header("x-api-key", value);
464    };
465    if let Some(ref token) = configuration.bearer_access_token {
466        req_builder = req_builder.bearer_auth(token.to_owned());
467    };
468    req_builder = req_builder.json(&p_explain_table_query_plan_request);
469
470    let req = req_builder.build()?;
471    let resp = configuration.client.execute(req).await?;
472
473    let status = resp.status();
474    let content_type = resp
475        .headers()
476        .get("content-type")
477        .and_then(|v| v.to_str().ok())
478        .unwrap_or("application/octet-stream");
479    let content_type = super::ContentType::from(content_type);
480
481    if !status.is_client_error() && !status.is_server_error() {
482        let content = resp.text().await?;
483        match content_type {
484            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
485            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
486            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
487        }
488    } else {
489        let content = resp.text().await?;
490        let entity: Option<ExplainTableQueryPlanError> = serde_json::from_str(&content).ok();
491        Err(Error::ResponseError(ResponseContent { status, content, entity }))
492    }
493}
494
495/// Insert new records into table `id`.  REST NAMESPACE ONLY REST namespace uses Arrow IPC stream as the request body. It passes in the `InsertIntoTableRequest` information in the following way: - `id`: pass through path parameter of the same name - `mode`: pass through query parameter of the same name 
496pub async fn insert_into_table(configuration: &configuration::Configuration, id: &str, body: Vec<u8>, delimiter: Option<&str>, mode: Option<&str>) -> Result<models::InsertIntoTableResponse, Error<InsertIntoTableError>> {
497    // add a prefix to parameters to efficiently prevent name collisions
498    let p_id = id;
499    let p_body = body;
500    let p_delimiter = delimiter;
501    let p_mode = mode;
502
503    let uri_str = format!("{}/v1/table/{id}/insert", configuration.base_path, id=crate::apis::urlencode(p_id));
504    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
505
506    if let Some(ref param_value) = p_delimiter {
507        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
508    }
509    if let Some(ref param_value) = p_mode {
510        req_builder = req_builder.query(&[("mode", &param_value.to_string())]);
511    }
512    if let Some(ref user_agent) = configuration.user_agent {
513        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
514    }
515    if let Some(ref token) = configuration.oauth_access_token {
516        req_builder = req_builder.bearer_auth(token.to_owned());
517    };
518    if let Some(ref apikey) = configuration.api_key {
519        let key = apikey.key.clone();
520        let value = match apikey.prefix {
521            Some(ref prefix) => format!("{} {}", prefix, key),
522            None => key,
523        };
524        req_builder = req_builder.header("x-api-key", value);
525    };
526    if let Some(ref token) = configuration.bearer_access_token {
527        req_builder = req_builder.bearer_auth(token.to_owned());
528    };
529    req_builder = req_builder.body(p_body);
530
531    let req = req_builder.build()?;
532    let resp = configuration.client.execute(req).await?;
533
534    let status = resp.status();
535    let content_type = resp
536        .headers()
537        .get("content-type")
538        .and_then(|v| v.to_str().ok())
539        .unwrap_or("application/octet-stream");
540    let content_type = super::ContentType::from(content_type);
541
542    if !status.is_client_error() && !status.is_server_error() {
543        let content = resp.text().await?;
544        match content_type {
545            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
546            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InsertIntoTableResponse`"))),
547            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::InsertIntoTableResponse`")))),
548        }
549    } else {
550        let content = resp.text().await?;
551        let entity: Option<InsertIntoTableError> = serde_json::from_str(&content).ok();
552        Err(Error::ResponseError(ResponseContent { status, content, entity }))
553    }
554}
555
556/// Performs a merge insert (upsert) operation on table `id`. This operation updates existing rows based on a matching column and inserts new rows that don't match. It returns the number of rows inserted and updated.  REST NAMESPACE ONLY REST namespace uses Arrow IPC stream as the request body. It passes in the `MergeInsertIntoTableRequest` information in the following way: - `id`: pass through path parameter of the same name - `on`: pass through query parameter of the same name - `when_matched_update_all`: pass through query parameter of the same name - `when_matched_update_all_filt`: pass through query parameter of the same name - `when_not_matched_insert_all`: pass through query parameter of the same name - `when_not_matched_by_source_delete`: pass through query parameter of the same name - `when_not_matched_by_source_delete_filt`: pass through query parameter of the same name 
557pub async fn merge_insert_into_table(configuration: &configuration::Configuration, id: &str, on: &str, body: Vec<u8>, delimiter: Option<&str>, when_matched_update_all: Option<bool>, when_matched_update_all_filt: Option<&str>, when_not_matched_insert_all: Option<bool>, when_not_matched_by_source_delete: Option<bool>, when_not_matched_by_source_delete_filt: Option<&str>, timeout: Option<&str>, use_index: Option<bool>) -> Result<models::MergeInsertIntoTableResponse, Error<MergeInsertIntoTableError>> {
558    // add a prefix to parameters to efficiently prevent name collisions
559    let p_id = id;
560    let p_on = on;
561    let p_body = body;
562    let p_delimiter = delimiter;
563    let p_when_matched_update_all = when_matched_update_all;
564    let p_when_matched_update_all_filt = when_matched_update_all_filt;
565    let p_when_not_matched_insert_all = when_not_matched_insert_all;
566    let p_when_not_matched_by_source_delete = when_not_matched_by_source_delete;
567    let p_when_not_matched_by_source_delete_filt = when_not_matched_by_source_delete_filt;
568    let p_timeout = timeout;
569    let p_use_index = use_index;
570
571    let uri_str = format!("{}/v1/table/{id}/merge_insert", configuration.base_path, id=crate::apis::urlencode(p_id));
572    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
573
574    if let Some(ref param_value) = p_delimiter {
575        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
576    }
577    req_builder = req_builder.query(&[("on", &p_on.to_string())]);
578    if let Some(ref param_value) = p_when_matched_update_all {
579        req_builder = req_builder.query(&[("when_matched_update_all", &param_value.to_string())]);
580    }
581    if let Some(ref param_value) = p_when_matched_update_all_filt {
582        req_builder = req_builder.query(&[("when_matched_update_all_filt", &param_value.to_string())]);
583    }
584    if let Some(ref param_value) = p_when_not_matched_insert_all {
585        req_builder = req_builder.query(&[("when_not_matched_insert_all", &param_value.to_string())]);
586    }
587    if let Some(ref param_value) = p_when_not_matched_by_source_delete {
588        req_builder = req_builder.query(&[("when_not_matched_by_source_delete", &param_value.to_string())]);
589    }
590    if let Some(ref param_value) = p_when_not_matched_by_source_delete_filt {
591        req_builder = req_builder.query(&[("when_not_matched_by_source_delete_filt", &param_value.to_string())]);
592    }
593    if let Some(ref param_value) = p_timeout {
594        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
595    }
596    if let Some(ref param_value) = p_use_index {
597        req_builder = req_builder.query(&[("use_index", &param_value.to_string())]);
598    }
599    if let Some(ref user_agent) = configuration.user_agent {
600        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
601    }
602    if let Some(ref token) = configuration.oauth_access_token {
603        req_builder = req_builder.bearer_auth(token.to_owned());
604    };
605    if let Some(ref apikey) = configuration.api_key {
606        let key = apikey.key.clone();
607        let value = match apikey.prefix {
608            Some(ref prefix) => format!("{} {}", prefix, key),
609            None => key,
610        };
611        req_builder = req_builder.header("x-api-key", value);
612    };
613    if let Some(ref token) = configuration.bearer_access_token {
614        req_builder = req_builder.bearer_auth(token.to_owned());
615    };
616    req_builder = req_builder.body(p_body);
617
618    let req = req_builder.build()?;
619    let resp = configuration.client.execute(req).await?;
620
621    let status = resp.status();
622    let content_type = resp
623        .headers()
624        .get("content-type")
625        .and_then(|v| v.to_str().ok())
626        .unwrap_or("application/octet-stream");
627    let content_type = super::ContentType::from(content_type);
628
629    if !status.is_client_error() && !status.is_server_error() {
630        let content = resp.text().await?;
631        match content_type {
632            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
633            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MergeInsertIntoTableResponse`"))),
634            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::MergeInsertIntoTableResponse`")))),
635        }
636    } else {
637        let content = resp.text().await?;
638        let entity: Option<MergeInsertIntoTableError> = serde_json::from_str(&content).ok();
639        Err(Error::ResponseError(ResponseContent { status, content, entity }))
640    }
641}
642
643/// Query table `id` with vector search, full text search and optional SQL filtering. Returns results in Arrow IPC file or stream format.  REST NAMESPACE ONLY REST namespace returns the response as Arrow IPC file binary data instead of the `QueryTableResponse` JSON object. 
644pub async fn query_table(configuration: &configuration::Configuration, id: &str, query_table_request: models::QueryTableRequest, delimiter: Option<&str>) -> Result<reqwest::Response, Error<QueryTableError>> {
645    // add a prefix to parameters to efficiently prevent name collisions
646    let p_id = id;
647    let p_query_table_request = query_table_request;
648    let p_delimiter = delimiter;
649
650    let uri_str = format!("{}/v1/table/{id}/query", configuration.base_path, id=crate::apis::urlencode(p_id));
651    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
652
653    if let Some(ref param_value) = p_delimiter {
654        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
655    }
656    if let Some(ref user_agent) = configuration.user_agent {
657        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
658    }
659    if let Some(ref token) = configuration.oauth_access_token {
660        req_builder = req_builder.bearer_auth(token.to_owned());
661    };
662    if let Some(ref apikey) = configuration.api_key {
663        let key = apikey.key.clone();
664        let value = match apikey.prefix {
665            Some(ref prefix) => format!("{} {}", prefix, key),
666            None => key,
667        };
668        req_builder = req_builder.header("x-api-key", value);
669    };
670    if let Some(ref token) = configuration.bearer_access_token {
671        req_builder = req_builder.bearer_auth(token.to_owned());
672    };
673    req_builder = req_builder.json(&p_query_table_request);
674
675    let req = req_builder.build()?;
676    let resp = configuration.client.execute(req).await?;
677
678    let status = resp.status();
679
680    if !status.is_client_error() && !status.is_server_error() {
681        Ok(resp)
682    } else {
683        let content = resp.text().await?;
684        let entity: Option<QueryTableError> = serde_json::from_str(&content).ok();
685        Err(Error::ResponseError(ResponseContent { status, content, entity }))
686    }
687}
688
689/// Update existing rows in table `id`. 
690pub async fn update_table(configuration: &configuration::Configuration, id: &str, update_table_request: models::UpdateTableRequest, delimiter: Option<&str>) -> Result<models::UpdateTableResponse, Error<UpdateTableError>> {
691    // add a prefix to parameters to efficiently prevent name collisions
692    let p_id = id;
693    let p_update_table_request = update_table_request;
694    let p_delimiter = delimiter;
695
696    let uri_str = format!("{}/v1/table/{id}/update", configuration.base_path, id=crate::apis::urlencode(p_id));
697    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
698
699    if let Some(ref param_value) = p_delimiter {
700        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
701    }
702    if let Some(ref user_agent) = configuration.user_agent {
703        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
704    }
705    if let Some(ref token) = configuration.oauth_access_token {
706        req_builder = req_builder.bearer_auth(token.to_owned());
707    };
708    if let Some(ref apikey) = configuration.api_key {
709        let key = apikey.key.clone();
710        let value = match apikey.prefix {
711            Some(ref prefix) => format!("{} {}", prefix, key),
712            None => key,
713        };
714        req_builder = req_builder.header("x-api-key", value);
715    };
716    if let Some(ref token) = configuration.bearer_access_token {
717        req_builder = req_builder.bearer_auth(token.to_owned());
718    };
719    req_builder = req_builder.json(&p_update_table_request);
720
721    let req = req_builder.build()?;
722    let resp = configuration.client.execute(req).await?;
723
724    let status = resp.status();
725    let content_type = resp
726        .headers()
727        .get("content-type")
728        .and_then(|v| v.to_str().ok())
729        .unwrap_or("application/octet-stream");
730    let content_type = super::ContentType::from(content_type);
731
732    if !status.is_client_error() && !status.is_server_error() {
733        let content = resp.text().await?;
734        match content_type {
735            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
736            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateTableResponse`"))),
737            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::UpdateTableResponse`")))),
738        }
739    } else {
740        let content = resp.text().await?;
741        let entity: Option<UpdateTableError> = serde_json::from_str(&content).ok();
742        Err(Error::ResponseError(ResponseContent { status, content, entity }))
743    }
744}
745