Skip to main content

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 [`alter_table_backfill_columns`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum AlterTableBackfillColumnsError {
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 [`analyze_table_query_plan`]
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum AnalyzeTableQueryPlanError {
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 [`count_table_rows`]
58#[derive(Debug, Clone, Serialize, Deserialize)]
59#[serde(untagged)]
60pub enum CountTableRowsError {
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 [`create_table`]
71#[derive(Debug, Clone, Serialize, Deserialize)]
72#[serde(untagged)]
73pub enum CreateTableError {
74    Status400(models::ErrorResponse),
75    Status401(models::ErrorResponse),
76    Status403(models::ErrorResponse),
77    Status404(models::ErrorResponse),
78    Status409(models::ErrorResponse),
79    Status503(models::ErrorResponse),
80    Status5XX(models::ErrorResponse),
81    UnknownValue(serde_json::Value),
82}
83
84/// struct for typed errors of method [`delete_from_table`]
85#[derive(Debug, Clone, Serialize, Deserialize)]
86#[serde(untagged)]
87pub enum DeleteFromTableError {
88    Status400(models::ErrorResponse),
89    Status401(models::ErrorResponse),
90    Status403(models::ErrorResponse),
91    Status404(models::ErrorResponse),
92    Status503(models::ErrorResponse),
93    Status5XX(models::ErrorResponse),
94    UnknownValue(serde_json::Value),
95}
96
97/// struct for typed errors of method [`explain_table_query_plan`]
98#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(untagged)]
100pub enum ExplainTableQueryPlanError {
101    Status400(models::ErrorResponse),
102    Status401(models::ErrorResponse),
103    Status403(models::ErrorResponse),
104    Status404(models::ErrorResponse),
105    Status503(models::ErrorResponse),
106    Status5XX(models::ErrorResponse),
107    UnknownValue(serde_json::Value),
108}
109
110/// struct for typed errors of method [`insert_into_table`]
111#[derive(Debug, Clone, Serialize, Deserialize)]
112#[serde(untagged)]
113pub enum InsertIntoTableError {
114    Status400(models::ErrorResponse),
115    Status401(models::ErrorResponse),
116    Status403(models::ErrorResponse),
117    Status404(models::ErrorResponse),
118    Status503(models::ErrorResponse),
119    Status5XX(models::ErrorResponse),
120    UnknownValue(serde_json::Value),
121}
122
123/// struct for typed errors of method [`merge_insert_into_table`]
124#[derive(Debug, Clone, Serialize, Deserialize)]
125#[serde(untagged)]
126pub enum MergeInsertIntoTableError {
127    Status400(models::ErrorResponse),
128    Status401(models::ErrorResponse),
129    Status403(models::ErrorResponse),
130    Status404(models::ErrorResponse),
131    Status503(models::ErrorResponse),
132    Status5XX(models::ErrorResponse),
133    UnknownValue(serde_json::Value),
134}
135
136/// struct for typed errors of method [`query_table`]
137#[derive(Debug, Clone, Serialize, Deserialize)]
138#[serde(untagged)]
139pub enum QueryTableError {
140    Status400(models::ErrorResponse),
141    Status401(models::ErrorResponse),
142    Status403(models::ErrorResponse),
143    Status404(models::ErrorResponse),
144    Status503(models::ErrorResponse),
145    Status5XX(models::ErrorResponse),
146    UnknownValue(serde_json::Value),
147}
148
149/// struct for typed errors of method [`refresh_materialized_view`]
150#[derive(Debug, Clone, Serialize, Deserialize)]
151#[serde(untagged)]
152pub enum RefreshMaterializedViewError {
153    Status400(models::ErrorResponse),
154    Status401(models::ErrorResponse),
155    Status403(models::ErrorResponse),
156    Status404(models::ErrorResponse),
157    Status503(models::ErrorResponse),
158    Status5XX(models::ErrorResponse),
159    UnknownValue(serde_json::Value),
160}
161
162/// struct for typed errors of method [`update_table`]
163#[derive(Debug, Clone, Serialize, Deserialize)]
164#[serde(untagged)]
165pub enum UpdateTableError {
166    Status400(models::ErrorResponse),
167    Status401(models::ErrorResponse),
168    Status403(models::ErrorResponse),
169    Status404(models::ErrorResponse),
170    Status503(models::ErrorResponse),
171    Status5XX(models::ErrorResponse),
172    UnknownValue(serde_json::Value),
173}
174
175
176/// Add new columns to table `id` using SQL expressions or default values. 
177pub 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>> {
178    // add a prefix to parameters to efficiently prevent name collisions
179    let p_id = id;
180    let p_alter_table_add_columns_request = alter_table_add_columns_request;
181    let p_delimiter = delimiter;
182
183    let uri_str = format!("{}/v1/table/{id}/add_columns", configuration.base_path, id=crate::apis::urlencode(p_id));
184    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
185
186    if let Some(ref param_value) = p_delimiter {
187        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
188    }
189    if let Some(ref user_agent) = configuration.user_agent {
190        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
191    }
192    if let Some(ref token) = configuration.oauth_access_token {
193        req_builder = req_builder.bearer_auth(token.to_owned());
194    };
195    if let Some(ref apikey) = configuration.api_key {
196        let key = apikey.key.clone();
197        let value = match apikey.prefix {
198            Some(ref prefix) => format!("{} {}", prefix, key),
199            None => key,
200        };
201        req_builder = req_builder.header("x-api-key", value);
202    };
203    if let Some(ref token) = configuration.bearer_access_token {
204        req_builder = req_builder.bearer_auth(token.to_owned());
205    };
206    req_builder = req_builder.json(&p_alter_table_add_columns_request);
207
208    let req = req_builder.build()?;
209    let resp = configuration.client.execute(req).await?;
210
211    let status = resp.status();
212    let content_type = resp
213        .headers()
214        .get("content-type")
215        .and_then(|v| v.to_str().ok())
216        .unwrap_or("application/octet-stream");
217    let content_type = super::ContentType::from(content_type);
218
219    if !status.is_client_error() && !status.is_server_error() {
220        let content = resp.text().await?;
221        match content_type {
222            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
223            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AlterTableAddColumnsResponse`"))),
224            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`")))),
225        }
226    } else {
227        let content = resp.text().await?;
228        let entity: Option<AlterTableAddColumnsError> = serde_json::from_str(&content).ok();
229        Err(Error::ResponseError(ResponseContent { status, content, entity }))
230    }
231}
232
233/// Trigger an asynchronous backfill job for a computed column on table `id`. The column must be a virtual (UDF-backed) column. Returns a job ID for tracking. 
234pub async fn alter_table_backfill_columns(configuration: &configuration::Configuration, id: &str, alter_table_backfill_columns_request: models::AlterTableBackfillColumnsRequest, delimiter: Option<&str>) -> Result<models::AlterTableBackfillColumnsResponse, Error<AlterTableBackfillColumnsError>> {
235    // add a prefix to parameters to efficiently prevent name collisions
236    let p_id = id;
237    let p_alter_table_backfill_columns_request = alter_table_backfill_columns_request;
238    let p_delimiter = delimiter;
239
240    let uri_str = format!("{}/v1/table/{id}/backfill_column", configuration.base_path, id=crate::apis::urlencode(p_id));
241    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
242
243    if let Some(ref param_value) = p_delimiter {
244        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
245    }
246    if let Some(ref user_agent) = configuration.user_agent {
247        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
248    }
249    if let Some(ref token) = configuration.oauth_access_token {
250        req_builder = req_builder.bearer_auth(token.to_owned());
251    };
252    if let Some(ref apikey) = configuration.api_key {
253        let key = apikey.key.clone();
254        let value = match apikey.prefix {
255            Some(ref prefix) => format!("{} {}", prefix, key),
256            None => key,
257        };
258        req_builder = req_builder.header("x-api-key", value);
259    };
260    if let Some(ref token) = configuration.bearer_access_token {
261        req_builder = req_builder.bearer_auth(token.to_owned());
262    };
263    req_builder = req_builder.json(&p_alter_table_backfill_columns_request);
264
265    let req = req_builder.build()?;
266    let resp = configuration.client.execute(req).await?;
267
268    let status = resp.status();
269    let content_type = resp
270        .headers()
271        .get("content-type")
272        .and_then(|v| v.to_str().ok())
273        .unwrap_or("application/octet-stream");
274    let content_type = super::ContentType::from(content_type);
275
276    if !status.is_client_error() && !status.is_server_error() {
277        let content = resp.text().await?;
278        match content_type {
279            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
280            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AlterTableBackfillColumnsResponse`"))),
281            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::AlterTableBackfillColumnsResponse`")))),
282        }
283    } else {
284        let content = resp.text().await?;
285        let entity: Option<AlterTableBackfillColumnsError> = serde_json::from_str(&content).ok();
286        Err(Error::ResponseError(ResponseContent { status, content, entity }))
287    }
288}
289
290/// 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. 
291pub 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>> {
292    // add a prefix to parameters to efficiently prevent name collisions
293    let p_id = id;
294    let p_analyze_table_query_plan_request = analyze_table_query_plan_request;
295    let p_delimiter = delimiter;
296
297    let uri_str = format!("{}/v1/table/{id}/analyze_plan", configuration.base_path, id=crate::apis::urlencode(p_id));
298    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
299
300    if let Some(ref param_value) = p_delimiter {
301        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
302    }
303    if let Some(ref user_agent) = configuration.user_agent {
304        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
305    }
306    if let Some(ref token) = configuration.oauth_access_token {
307        req_builder = req_builder.bearer_auth(token.to_owned());
308    };
309    if let Some(ref apikey) = configuration.api_key {
310        let key = apikey.key.clone();
311        let value = match apikey.prefix {
312            Some(ref prefix) => format!("{} {}", prefix, key),
313            None => key,
314        };
315        req_builder = req_builder.header("x-api-key", value);
316    };
317    if let Some(ref token) = configuration.bearer_access_token {
318        req_builder = req_builder.bearer_auth(token.to_owned());
319    };
320    req_builder = req_builder.json(&p_analyze_table_query_plan_request);
321
322    let req = req_builder.build()?;
323    let resp = configuration.client.execute(req).await?;
324
325    let status = resp.status();
326    let content_type = resp
327        .headers()
328        .get("content-type")
329        .and_then(|v| v.to_str().ok())
330        .unwrap_or("application/octet-stream");
331    let content_type = super::ContentType::from(content_type);
332
333    if !status.is_client_error() && !status.is_server_error() {
334        let content = resp.text().await?;
335        match content_type {
336            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
337            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
338            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`")))),
339        }
340    } else {
341        let content = resp.text().await?;
342        let entity: Option<AnalyzeTableQueryPlanError> = serde_json::from_str(&content).ok();
343        Err(Error::ResponseError(ResponseContent { status, content, entity }))
344    }
345}
346
347/// 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. 
348pub async fn count_table_rows(configuration: &configuration::Configuration, id: &str, count_table_rows_request: models::CountTableRowsRequest, delimiter: Option<&str>) -> Result<i64, Error<CountTableRowsError>> {
349    // add a prefix to parameters to efficiently prevent name collisions
350    let p_id = id;
351    let p_count_table_rows_request = count_table_rows_request;
352    let p_delimiter = delimiter;
353
354    let uri_str = format!("{}/v1/table/{id}/count_rows", configuration.base_path, id=crate::apis::urlencode(p_id));
355    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
356
357    if let Some(ref param_value) = p_delimiter {
358        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
359    }
360    if let Some(ref user_agent) = configuration.user_agent {
361        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
362    }
363    if let Some(ref token) = configuration.oauth_access_token {
364        req_builder = req_builder.bearer_auth(token.to_owned());
365    };
366    if let Some(ref apikey) = configuration.api_key {
367        let key = apikey.key.clone();
368        let value = match apikey.prefix {
369            Some(ref prefix) => format!("{} {}", prefix, key),
370            None => key,
371        };
372        req_builder = req_builder.header("x-api-key", value);
373    };
374    if let Some(ref token) = configuration.bearer_access_token {
375        req_builder = req_builder.bearer_auth(token.to_owned());
376    };
377    req_builder = req_builder.json(&p_count_table_rows_request);
378
379    let req = req_builder.build()?;
380    let resp = configuration.client.execute(req).await?;
381
382    let status = resp.status();
383    let content_type = resp
384        .headers()
385        .get("content-type")
386        .and_then(|v| v.to_str().ok())
387        .unwrap_or("application/octet-stream");
388    let content_type = super::ContentType::from(content_type);
389
390    if !status.is_client_error() && !status.is_server_error() {
391        let content = resp.text().await?;
392        match content_type {
393            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
394            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `i64`"))),
395            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`")))),
396        }
397    } else {
398        let content = resp.text().await?;
399        let entity: Option<CountTableRowsError> = serde_json::from_str(&content).ok();
400        Err(Error::ResponseError(ResponseContent { status, content, entity }))
401    }
402}
403
404/// 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 - `properties`: serialize as a single JSON-encoded query parameter such as   `properties={\"user\":\"alice\",\"team\":\"eng\"}`; these are business logic properties   managed by the namespace implementation outside Lance context - `storage_options`: serialize as a single JSON-encoded query parameter such as   `storage_options={\"aws_region\":\"us-east-1\",\"timeout\":\"30s\"}`; these configure   write-time overrides for data and metadata written during table creation 
405pub async fn create_table(configuration: &configuration::Configuration, id: &str, body: Vec<u8>, delimiter: Option<&str>, mode: Option<&str>, properties: Option<&str>, storage_options: Option<&str>) -> Result<models::CreateTableResponse, Error<CreateTableError>> {
406    // add a prefix to parameters to efficiently prevent name collisions
407    let p_id = id;
408    let p_body = body;
409    let p_delimiter = delimiter;
410    let p_mode = mode;
411    let p_properties = properties;
412    let p_storage_options = storage_options;
413
414    let uri_str = format!("{}/v1/table/{id}/create", configuration.base_path, id=crate::apis::urlencode(p_id));
415    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
416
417    if let Some(ref param_value) = p_delimiter {
418        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
419    }
420    if let Some(ref param_value) = p_mode {
421        req_builder = req_builder.query(&[("mode", &param_value.to_string())]);
422    }
423    if let Some(ref param_value) = p_properties {
424        req_builder = req_builder.query(&[("properties", &param_value.to_string())]);
425    }
426    if let Some(ref param_value) = p_storage_options {
427        req_builder = req_builder.query(&[("storage_options", &param_value.to_string())]);
428    }
429    if let Some(ref user_agent) = configuration.user_agent {
430        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
431    }
432    if let Some(ref token) = configuration.oauth_access_token {
433        req_builder = req_builder.bearer_auth(token.to_owned());
434    };
435    if let Some(ref apikey) = configuration.api_key {
436        let key = apikey.key.clone();
437        let value = match apikey.prefix {
438            Some(ref prefix) => format!("{} {}", prefix, key),
439            None => key,
440        };
441        req_builder = req_builder.header("x-api-key", value);
442    };
443    if let Some(ref token) = configuration.bearer_access_token {
444        req_builder = req_builder.bearer_auth(token.to_owned());
445    };
446    req_builder = req_builder.body(p_body);
447
448    let req = req_builder.build()?;
449    let resp = configuration.client.execute(req).await?;
450
451    let status = resp.status();
452    let content_type = resp
453        .headers()
454        .get("content-type")
455        .and_then(|v| v.to_str().ok())
456        .unwrap_or("application/octet-stream");
457    let content_type = super::ContentType::from(content_type);
458
459    if !status.is_client_error() && !status.is_server_error() {
460        let content = resp.text().await?;
461        match content_type {
462            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
463            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateTableResponse`"))),
464            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`")))),
465        }
466    } else {
467        let content = resp.text().await?;
468        let entity: Option<CreateTableError> = serde_json::from_str(&content).ok();
469        Err(Error::ResponseError(ResponseContent { status, content, entity }))
470    }
471}
472
473/// Delete rows from table `id`. 
474pub async fn delete_from_table(configuration: &configuration::Configuration, id: &str, delete_from_table_request: models::DeleteFromTableRequest, delimiter: Option<&str>) -> Result<models::DeleteFromTableResponse, Error<DeleteFromTableError>> {
475    // add a prefix to parameters to efficiently prevent name collisions
476    let p_id = id;
477    let p_delete_from_table_request = delete_from_table_request;
478    let p_delimiter = delimiter;
479
480    let uri_str = format!("{}/v1/table/{id}/delete", configuration.base_path, id=crate::apis::urlencode(p_id));
481    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
482
483    if let Some(ref param_value) = p_delimiter {
484        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
485    }
486    if let Some(ref user_agent) = configuration.user_agent {
487        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
488    }
489    if let Some(ref token) = configuration.oauth_access_token {
490        req_builder = req_builder.bearer_auth(token.to_owned());
491    };
492    if let Some(ref apikey) = configuration.api_key {
493        let key = apikey.key.clone();
494        let value = match apikey.prefix {
495            Some(ref prefix) => format!("{} {}", prefix, key),
496            None => key,
497        };
498        req_builder = req_builder.header("x-api-key", value);
499    };
500    if let Some(ref token) = configuration.bearer_access_token {
501        req_builder = req_builder.bearer_auth(token.to_owned());
502    };
503    req_builder = req_builder.json(&p_delete_from_table_request);
504
505    let req = req_builder.build()?;
506    let resp = configuration.client.execute(req).await?;
507
508    let status = resp.status();
509    let content_type = resp
510        .headers()
511        .get("content-type")
512        .and_then(|v| v.to_str().ok())
513        .unwrap_or("application/octet-stream");
514    let content_type = super::ContentType::from(content_type);
515
516    if !status.is_client_error() && !status.is_server_error() {
517        let content = resp.text().await?;
518        match content_type {
519            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
520            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteFromTableResponse`"))),
521            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`")))),
522        }
523    } else {
524        let content = resp.text().await?;
525        let entity: Option<DeleteFromTableError> = serde_json::from_str(&content).ok();
526        Err(Error::ResponseError(ResponseContent { status, content, entity }))
527    }
528}
529
530/// 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. 
531pub 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>> {
532    // add a prefix to parameters to efficiently prevent name collisions
533    let p_id = id;
534    let p_explain_table_query_plan_request = explain_table_query_plan_request;
535    let p_delimiter = delimiter;
536
537    let uri_str = format!("{}/v1/table/{id}/explain_plan", configuration.base_path, id=crate::apis::urlencode(p_id));
538    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
539
540    if let Some(ref param_value) = p_delimiter {
541        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
542    }
543    if let Some(ref user_agent) = configuration.user_agent {
544        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
545    }
546    if let Some(ref token) = configuration.oauth_access_token {
547        req_builder = req_builder.bearer_auth(token.to_owned());
548    };
549    if let Some(ref apikey) = configuration.api_key {
550        let key = apikey.key.clone();
551        let value = match apikey.prefix {
552            Some(ref prefix) => format!("{} {}", prefix, key),
553            None => key,
554        };
555        req_builder = req_builder.header("x-api-key", value);
556    };
557    if let Some(ref token) = configuration.bearer_access_token {
558        req_builder = req_builder.bearer_auth(token.to_owned());
559    };
560    req_builder = req_builder.json(&p_explain_table_query_plan_request);
561
562    let req = req_builder.build()?;
563    let resp = configuration.client.execute(req).await?;
564
565    let status = resp.status();
566    let content_type = resp
567        .headers()
568        .get("content-type")
569        .and_then(|v| v.to_str().ok())
570        .unwrap_or("application/octet-stream");
571    let content_type = super::ContentType::from(content_type);
572
573    if !status.is_client_error() && !status.is_server_error() {
574        let content = resp.text().await?;
575        match content_type {
576            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
577            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
578            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`")))),
579        }
580    } else {
581        let content = resp.text().await?;
582        let entity: Option<ExplainTableQueryPlanError> = serde_json::from_str(&content).ok();
583        Err(Error::ResponseError(ResponseContent { status, content, entity }))
584    }
585}
586
587/// Insert new records into table `id`.  For tables that have been declared but not yet created on storage (is_only_declared=true), this operation will create the table with the provided data.  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 
588pub async fn insert_into_table(configuration: &configuration::Configuration, id: &str, body: Vec<u8>, delimiter: Option<&str>, mode: Option<&str>) -> Result<models::InsertIntoTableResponse, Error<InsertIntoTableError>> {
589    // add a prefix to parameters to efficiently prevent name collisions
590    let p_id = id;
591    let p_body = body;
592    let p_delimiter = delimiter;
593    let p_mode = mode;
594
595    let uri_str = format!("{}/v1/table/{id}/insert", configuration.base_path, id=crate::apis::urlencode(p_id));
596    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
597
598    if let Some(ref param_value) = p_delimiter {
599        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
600    }
601    if let Some(ref param_value) = p_mode {
602        req_builder = req_builder.query(&[("mode", &param_value.to_string())]);
603    }
604    if let Some(ref user_agent) = configuration.user_agent {
605        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
606    }
607    if let Some(ref token) = configuration.oauth_access_token {
608        req_builder = req_builder.bearer_auth(token.to_owned());
609    };
610    if let Some(ref apikey) = configuration.api_key {
611        let key = apikey.key.clone();
612        let value = match apikey.prefix {
613            Some(ref prefix) => format!("{} {}", prefix, key),
614            None => key,
615        };
616        req_builder = req_builder.header("x-api-key", value);
617    };
618    if let Some(ref token) = configuration.bearer_access_token {
619        req_builder = req_builder.bearer_auth(token.to_owned());
620    };
621    req_builder = req_builder.body(p_body);
622
623    let req = req_builder.build()?;
624    let resp = configuration.client.execute(req).await?;
625
626    let status = resp.status();
627    let content_type = resp
628        .headers()
629        .get("content-type")
630        .and_then(|v| v.to_str().ok())
631        .unwrap_or("application/octet-stream");
632    let content_type = super::ContentType::from(content_type);
633
634    if !status.is_client_error() && !status.is_server_error() {
635        let content = resp.text().await?;
636        match content_type {
637            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
638            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InsertIntoTableResponse`"))),
639            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`")))),
640        }
641    } else {
642        let content = resp.text().await?;
643        let entity: Option<InsertIntoTableError> = serde_json::from_str(&content).ok();
644        Err(Error::ResponseError(ResponseContent { status, content, entity }))
645    }
646}
647
648/// 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.  For tables that have been declared but not yet created on storage (is_only_declared=true), this operation will create the table with the provided data (since there are no existing rows to merge with).  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 
649pub 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>> {
650    // add a prefix to parameters to efficiently prevent name collisions
651    let p_id = id;
652    let p_on = on;
653    let p_body = body;
654    let p_delimiter = delimiter;
655    let p_when_matched_update_all = when_matched_update_all;
656    let p_when_matched_update_all_filt = when_matched_update_all_filt;
657    let p_when_not_matched_insert_all = when_not_matched_insert_all;
658    let p_when_not_matched_by_source_delete = when_not_matched_by_source_delete;
659    let p_when_not_matched_by_source_delete_filt = when_not_matched_by_source_delete_filt;
660    let p_timeout = timeout;
661    let p_use_index = use_index;
662
663    let uri_str = format!("{}/v1/table/{id}/merge_insert", configuration.base_path, id=crate::apis::urlencode(p_id));
664    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
665
666    if let Some(ref param_value) = p_delimiter {
667        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
668    }
669    req_builder = req_builder.query(&[("on", &p_on.to_string())]);
670    if let Some(ref param_value) = p_when_matched_update_all {
671        req_builder = req_builder.query(&[("when_matched_update_all", &param_value.to_string())]);
672    }
673    if let Some(ref param_value) = p_when_matched_update_all_filt {
674        req_builder = req_builder.query(&[("when_matched_update_all_filt", &param_value.to_string())]);
675    }
676    if let Some(ref param_value) = p_when_not_matched_insert_all {
677        req_builder = req_builder.query(&[("when_not_matched_insert_all", &param_value.to_string())]);
678    }
679    if let Some(ref param_value) = p_when_not_matched_by_source_delete {
680        req_builder = req_builder.query(&[("when_not_matched_by_source_delete", &param_value.to_string())]);
681    }
682    if let Some(ref param_value) = p_when_not_matched_by_source_delete_filt {
683        req_builder = req_builder.query(&[("when_not_matched_by_source_delete_filt", &param_value.to_string())]);
684    }
685    if let Some(ref param_value) = p_timeout {
686        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
687    }
688    if let Some(ref param_value) = p_use_index {
689        req_builder = req_builder.query(&[("use_index", &param_value.to_string())]);
690    }
691    if let Some(ref user_agent) = configuration.user_agent {
692        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
693    }
694    if let Some(ref token) = configuration.oauth_access_token {
695        req_builder = req_builder.bearer_auth(token.to_owned());
696    };
697    if let Some(ref apikey) = configuration.api_key {
698        let key = apikey.key.clone();
699        let value = match apikey.prefix {
700            Some(ref prefix) => format!("{} {}", prefix, key),
701            None => key,
702        };
703        req_builder = req_builder.header("x-api-key", value);
704    };
705    if let Some(ref token) = configuration.bearer_access_token {
706        req_builder = req_builder.bearer_auth(token.to_owned());
707    };
708    req_builder = req_builder.body(p_body);
709
710    let req = req_builder.build()?;
711    let resp = configuration.client.execute(req).await?;
712
713    let status = resp.status();
714    let content_type = resp
715        .headers()
716        .get("content-type")
717        .and_then(|v| v.to_str().ok())
718        .unwrap_or("application/octet-stream");
719    let content_type = super::ContentType::from(content_type);
720
721    if !status.is_client_error() && !status.is_server_error() {
722        let content = resp.text().await?;
723        match content_type {
724            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
725            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MergeInsertIntoTableResponse`"))),
726            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`")))),
727        }
728    } else {
729        let content = resp.text().await?;
730        let entity: Option<MergeInsertIntoTableError> = serde_json::from_str(&content).ok();
731        Err(Error::ResponseError(ResponseContent { status, content, entity }))
732    }
733}
734
735/// 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. 
736pub async fn query_table(configuration: &configuration::Configuration, id: &str, query_table_request: models::QueryTableRequest, delimiter: Option<&str>) -> Result<reqwest::Response, Error<QueryTableError>> {
737    // add a prefix to parameters to efficiently prevent name collisions
738    let p_id = id;
739    let p_query_table_request = query_table_request;
740    let p_delimiter = delimiter;
741
742    let uri_str = format!("{}/v1/table/{id}/query", configuration.base_path, id=crate::apis::urlencode(p_id));
743    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
744
745    if let Some(ref param_value) = p_delimiter {
746        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
747    }
748    if let Some(ref user_agent) = configuration.user_agent {
749        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
750    }
751    if let Some(ref token) = configuration.oauth_access_token {
752        req_builder = req_builder.bearer_auth(token.to_owned());
753    };
754    if let Some(ref apikey) = configuration.api_key {
755        let key = apikey.key.clone();
756        let value = match apikey.prefix {
757            Some(ref prefix) => format!("{} {}", prefix, key),
758            None => key,
759        };
760        req_builder = req_builder.header("x-api-key", value);
761    };
762    if let Some(ref token) = configuration.bearer_access_token {
763        req_builder = req_builder.bearer_auth(token.to_owned());
764    };
765    req_builder = req_builder.json(&p_query_table_request);
766
767    let req = req_builder.build()?;
768    let resp = configuration.client.execute(req).await?;
769
770    let status = resp.status();
771
772    if !status.is_client_error() && !status.is_server_error() {
773        Ok(resp)
774    } else {
775        let content = resp.text().await?;
776        let entity: Option<QueryTableError> = serde_json::from_str(&content).ok();
777        Err(Error::ResponseError(ResponseContent { status, content, entity }))
778    }
779}
780
781/// Trigger an asynchronous refresh job for a materialized view backed by table `id`. Returns a job ID for tracking. 
782pub async fn refresh_materialized_view(configuration: &configuration::Configuration, id: &str, delimiter: Option<&str>, refresh_materialized_view_request: Option<models::RefreshMaterializedViewRequest>) -> Result<models::RefreshMaterializedViewResponse, Error<RefreshMaterializedViewError>> {
783    // add a prefix to parameters to efficiently prevent name collisions
784    let p_id = id;
785    let p_delimiter = delimiter;
786    let p_refresh_materialized_view_request = refresh_materialized_view_request;
787
788    let uri_str = format!("{}/v1/table/{id}/refresh", configuration.base_path, id=crate::apis::urlencode(p_id));
789    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
790
791    if let Some(ref param_value) = p_delimiter {
792        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
793    }
794    if let Some(ref user_agent) = configuration.user_agent {
795        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
796    }
797    if let Some(ref token) = configuration.oauth_access_token {
798        req_builder = req_builder.bearer_auth(token.to_owned());
799    };
800    if let Some(ref apikey) = configuration.api_key {
801        let key = apikey.key.clone();
802        let value = match apikey.prefix {
803            Some(ref prefix) => format!("{} {}", prefix, key),
804            None => key,
805        };
806        req_builder = req_builder.header("x-api-key", value);
807    };
808    if let Some(ref token) = configuration.bearer_access_token {
809        req_builder = req_builder.bearer_auth(token.to_owned());
810    };
811    req_builder = req_builder.json(&p_refresh_materialized_view_request);
812
813    let req = req_builder.build()?;
814    let resp = configuration.client.execute(req).await?;
815
816    let status = resp.status();
817    let content_type = resp
818        .headers()
819        .get("content-type")
820        .and_then(|v| v.to_str().ok())
821        .unwrap_or("application/octet-stream");
822    let content_type = super::ContentType::from(content_type);
823
824    if !status.is_client_error() && !status.is_server_error() {
825        let content = resp.text().await?;
826        match content_type {
827            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
828            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RefreshMaterializedViewResponse`"))),
829            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::RefreshMaterializedViewResponse`")))),
830        }
831    } else {
832        let content = resp.text().await?;
833        let entity: Option<RefreshMaterializedViewError> = serde_json::from_str(&content).ok();
834        Err(Error::ResponseError(ResponseContent { status, content, entity }))
835    }
836}
837
838/// Update existing rows in table `id`. 
839pub async fn update_table(configuration: &configuration::Configuration, id: &str, update_table_request: models::UpdateTableRequest, delimiter: Option<&str>) -> Result<models::UpdateTableResponse, Error<UpdateTableError>> {
840    // add a prefix to parameters to efficiently prevent name collisions
841    let p_id = id;
842    let p_update_table_request = update_table_request;
843    let p_delimiter = delimiter;
844
845    let uri_str = format!("{}/v1/table/{id}/update", configuration.base_path, id=crate::apis::urlencode(p_id));
846    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
847
848    if let Some(ref param_value) = p_delimiter {
849        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
850    }
851    if let Some(ref user_agent) = configuration.user_agent {
852        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
853    }
854    if let Some(ref token) = configuration.oauth_access_token {
855        req_builder = req_builder.bearer_auth(token.to_owned());
856    };
857    if let Some(ref apikey) = configuration.api_key {
858        let key = apikey.key.clone();
859        let value = match apikey.prefix {
860            Some(ref prefix) => format!("{} {}", prefix, key),
861            None => key,
862        };
863        req_builder = req_builder.header("x-api-key", value);
864    };
865    if let Some(ref token) = configuration.bearer_access_token {
866        req_builder = req_builder.bearer_auth(token.to_owned());
867    };
868    req_builder = req_builder.json(&p_update_table_request);
869
870    let req = req_builder.build()?;
871    let resp = configuration.client.execute(req).await?;
872
873    let status = resp.status();
874    let content_type = resp
875        .headers()
876        .get("content-type")
877        .and_then(|v| v.to_str().ok())
878        .unwrap_or("application/octet-stream");
879    let content_type = super::ContentType::from(content_type);
880
881    if !status.is_client_error() && !status.is_server_error() {
882        let content = resp.text().await?;
883        match content_type {
884            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
885            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateTableResponse`"))),
886            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`")))),
887        }
888    } else {
889        let content = resp.text().await?;
890        let entity: Option<UpdateTableError> = serde_json::from_str(&content).ok();
891        Err(Error::ResponseError(ResponseContent { status, content, entity }))
892    }
893}
894