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