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 or a computed column declared with an expression binding. 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. The REST response maps to the `CountTableRowsResponse` model as follows: - the integer response body maps to `count` - response headers map to `context` via the `header.` prefix (see the `Context` schema) 
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>, branch: 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_branch = branch;
665    let p_mode = mode;
666
667    let uri_str = format!("{}/v1/table/{id}/insert", configuration.base_path, id=crate::apis::urlencode(p_id));
668    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
669
670    if let Some(ref param_value) = p_delimiter {
671        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
672    }
673    if let Some(ref param_value) = p_branch {
674        req_builder = req_builder.query(&[("branch", &param_value.to_string())]);
675    }
676    if let Some(ref param_value) = p_mode {
677        req_builder = req_builder.query(&[("mode", &param_value.to_string())]);
678    }
679    if let Some(ref user_agent) = configuration.user_agent {
680        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
681    }
682    if let Some(ref token) = configuration.oauth_access_token {
683        req_builder = req_builder.bearer_auth(token.to_owned());
684    };
685    if let Some(ref apikey) = configuration.api_key {
686        let key = apikey.key.clone();
687        let value = match apikey.prefix {
688            Some(ref prefix) => format!("{} {}", prefix, key),
689            None => key,
690        };
691        req_builder = req_builder.header("x-api-key", value);
692    };
693    if let Some(ref token) = configuration.bearer_access_token {
694        req_builder = req_builder.bearer_auth(token.to_owned());
695    };
696    req_builder = req_builder.body(p_body);
697
698    let req = req_builder.build()?;
699    let resp = configuration.client.execute(req).await?;
700
701    let status = resp.status();
702    let content_type = resp
703        .headers()
704        .get("content-type")
705        .and_then(|v| v.to_str().ok())
706        .unwrap_or("application/octet-stream");
707    let content_type = super::ContentType::from(content_type);
708
709    if !status.is_client_error() && !status.is_server_error() {
710        let content = resp.text().await?;
711        match content_type {
712            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
713            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InsertIntoTableResponse`"))),
714            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`")))),
715        }
716    } else {
717        let content = resp.text().await?;
718        let entity: Option<InsertIntoTableError> = serde_json::from_str(&content).ok();
719        Err(Error::ResponseError(ResponseContent { status, content, entity }))
720    }
721}
722
723/// Performs a merge insert (upsert) operation on table `id`. This operation updates existing rows based on one or more matching columns 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, repeated once per field path - `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 
724pub async fn merge_insert_into_table(configuration: &configuration::Configuration, id: &str, on: Vec<String>, body: Vec<u8>, delimiter: Option<&str>, branch: 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>> {
725    // add a prefix to parameters to efficiently prevent name collisions
726    let p_id = id;
727    let p_on = on;
728    let p_body = body;
729    let p_delimiter = delimiter;
730    let p_branch = branch;
731    let p_when_matched_update_all = when_matched_update_all;
732    let p_when_matched_update_all_filt = when_matched_update_all_filt;
733    let p_when_not_matched_insert_all = when_not_matched_insert_all;
734    let p_when_not_matched_by_source_delete = when_not_matched_by_source_delete;
735    let p_when_not_matched_by_source_delete_filt = when_not_matched_by_source_delete_filt;
736    let p_timeout = timeout;
737    let p_use_index = use_index;
738
739    let uri_str = format!("{}/v1/table/{id}/merge_insert", configuration.base_path, id=crate::apis::urlencode(p_id));
740    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
741
742    if let Some(ref param_value) = p_delimiter {
743        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
744    }
745    if let Some(ref param_value) = p_branch {
746        req_builder = req_builder.query(&[("branch", &param_value.to_string())]);
747    }
748    req_builder = match "multi" {
749        "multi" => req_builder.query(&p_on.into_iter().map(|p| ("on".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
750        _ => req_builder.query(&[("on", &p_on.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
751    };
752    if let Some(ref param_value) = p_when_matched_update_all {
753        req_builder = req_builder.query(&[("when_matched_update_all", &param_value.to_string())]);
754    }
755    if let Some(ref param_value) = p_when_matched_update_all_filt {
756        req_builder = req_builder.query(&[("when_matched_update_all_filt", &param_value.to_string())]);
757    }
758    if let Some(ref param_value) = p_when_not_matched_insert_all {
759        req_builder = req_builder.query(&[("when_not_matched_insert_all", &param_value.to_string())]);
760    }
761    if let Some(ref param_value) = p_when_not_matched_by_source_delete {
762        req_builder = req_builder.query(&[("when_not_matched_by_source_delete", &param_value.to_string())]);
763    }
764    if let Some(ref param_value) = p_when_not_matched_by_source_delete_filt {
765        req_builder = req_builder.query(&[("when_not_matched_by_source_delete_filt", &param_value.to_string())]);
766    }
767    if let Some(ref param_value) = p_timeout {
768        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
769    }
770    if let Some(ref param_value) = p_use_index {
771        req_builder = req_builder.query(&[("use_index", &param_value.to_string())]);
772    }
773    if let Some(ref user_agent) = configuration.user_agent {
774        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
775    }
776    if let Some(ref token) = configuration.oauth_access_token {
777        req_builder = req_builder.bearer_auth(token.to_owned());
778    };
779    if let Some(ref apikey) = configuration.api_key {
780        let key = apikey.key.clone();
781        let value = match apikey.prefix {
782            Some(ref prefix) => format!("{} {}", prefix, key),
783            None => key,
784        };
785        req_builder = req_builder.header("x-api-key", value);
786    };
787    if let Some(ref token) = configuration.bearer_access_token {
788        req_builder = req_builder.bearer_auth(token.to_owned());
789    };
790    req_builder = req_builder.body(p_body);
791
792    let req = req_builder.build()?;
793    let resp = configuration.client.execute(req).await?;
794
795    let status = resp.status();
796    let content_type = resp
797        .headers()
798        .get("content-type")
799        .and_then(|v| v.to_str().ok())
800        .unwrap_or("application/octet-stream");
801    let content_type = super::ContentType::from(content_type);
802
803    if !status.is_client_error() && !status.is_server_error() {
804        let content = resp.text().await?;
805        match content_type {
806            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
807            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MergeInsertIntoTableResponse`"))),
808            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`")))),
809        }
810    } else {
811        let content = resp.text().await?;
812        let entity: Option<MergeInsertIntoTableError> = serde_json::from_str(&content).ok();
813        Err(Error::ResponseError(ResponseContent { status, content, entity }))
814    }
815}
816
817/// 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. The REST response maps to the `QueryTableResponse` model as follows: - the Arrow IPC file binary body maps to `data` - response headers map to `context` via the `header.` prefix (see the `Context` schema) 
818pub async fn query_table(configuration: &configuration::Configuration, id: &str, query_table_request: models::QueryTableRequest, delimiter: Option<&str>) -> Result<reqwest::Response, Error<QueryTableError>> {
819    // add a prefix to parameters to efficiently prevent name collisions
820    let p_id = id;
821    let p_query_table_request = query_table_request;
822    let p_delimiter = delimiter;
823
824    let uri_str = format!("{}/v1/table/{id}/query", configuration.base_path, id=crate::apis::urlencode(p_id));
825    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
826
827    if let Some(ref param_value) = p_delimiter {
828        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
829    }
830    if let Some(ref user_agent) = configuration.user_agent {
831        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
832    }
833    if let Some(ref token) = configuration.oauth_access_token {
834        req_builder = req_builder.bearer_auth(token.to_owned());
835    };
836    if let Some(ref apikey) = configuration.api_key {
837        let key = apikey.key.clone();
838        let value = match apikey.prefix {
839            Some(ref prefix) => format!("{} {}", prefix, key),
840            None => key,
841        };
842        req_builder = req_builder.header("x-api-key", value);
843    };
844    if let Some(ref token) = configuration.bearer_access_token {
845        req_builder = req_builder.bearer_auth(token.to_owned());
846    };
847    req_builder = req_builder.json(&p_query_table_request);
848
849    let req = req_builder.build()?;
850    let resp = configuration.client.execute(req).await?;
851
852    let status = resp.status();
853
854    if !status.is_client_error() && !status.is_server_error() {
855        Ok(resp)
856    } else {
857        let content = resp.text().await?;
858        let entity: Option<QueryTableError> = serde_json::from_str(&content).ok();
859        Err(Error::ResponseError(ResponseContent { status, content, entity }))
860    }
861}
862
863/// Trigger an asynchronous refresh job for materialized view `id`. Returns a job ID for tracking. 
864pub 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>> {
865    // add a prefix to parameters to efficiently prevent name collisions
866    let p_id = id;
867    let p_delimiter = delimiter;
868    let p_refresh_materialized_view_request = refresh_materialized_view_request;
869
870    let uri_str = format!("{}/v1/materialized_view/{id}/refresh", configuration.base_path, id=crate::apis::urlencode(p_id));
871    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
872
873    if let Some(ref param_value) = p_delimiter {
874        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
875    }
876    if let Some(ref user_agent) = configuration.user_agent {
877        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
878    }
879    if let Some(ref token) = configuration.oauth_access_token {
880        req_builder = req_builder.bearer_auth(token.to_owned());
881    };
882    if let Some(ref apikey) = configuration.api_key {
883        let key = apikey.key.clone();
884        let value = match apikey.prefix {
885            Some(ref prefix) => format!("{} {}", prefix, key),
886            None => key,
887        };
888        req_builder = req_builder.header("x-api-key", value);
889    };
890    if let Some(ref token) = configuration.bearer_access_token {
891        req_builder = req_builder.bearer_auth(token.to_owned());
892    };
893    req_builder = req_builder.json(&p_refresh_materialized_view_request);
894
895    let req = req_builder.build()?;
896    let resp = configuration.client.execute(req).await?;
897
898    let status = resp.status();
899    let content_type = resp
900        .headers()
901        .get("content-type")
902        .and_then(|v| v.to_str().ok())
903        .unwrap_or("application/octet-stream");
904    let content_type = super::ContentType::from(content_type);
905
906    if !status.is_client_error() && !status.is_server_error() {
907        let content = resp.text().await?;
908        match content_type {
909            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
910            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RefreshMaterializedViewResponse`"))),
911            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`")))),
912        }
913    } else {
914        let content = resp.text().await?;
915        let entity: Option<RefreshMaterializedViewError> = serde_json::from_str(&content).ok();
916        Err(Error::ResponseError(ResponseContent { status, content, entity }))
917    }
918}
919
920/// Update existing rows in table `id`. 
921pub async fn update_table(configuration: &configuration::Configuration, id: &str, update_table_request: models::UpdateTableRequest, delimiter: Option<&str>) -> Result<models::UpdateTableResponse, Error<UpdateTableError>> {
922    // add a prefix to parameters to efficiently prevent name collisions
923    let p_id = id;
924    let p_update_table_request = update_table_request;
925    let p_delimiter = delimiter;
926
927    let uri_str = format!("{}/v1/table/{id}/update", configuration.base_path, id=crate::apis::urlencode(p_id));
928    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
929
930    if let Some(ref param_value) = p_delimiter {
931        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
932    }
933    if let Some(ref user_agent) = configuration.user_agent {
934        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
935    }
936    if let Some(ref token) = configuration.oauth_access_token {
937        req_builder = req_builder.bearer_auth(token.to_owned());
938    };
939    if let Some(ref apikey) = configuration.api_key {
940        let key = apikey.key.clone();
941        let value = match apikey.prefix {
942            Some(ref prefix) => format!("{} {}", prefix, key),
943            None => key,
944        };
945        req_builder = req_builder.header("x-api-key", value);
946    };
947    if let Some(ref token) = configuration.bearer_access_token {
948        req_builder = req_builder.bearer_auth(token.to_owned());
949    };
950    req_builder = req_builder.json(&p_update_table_request);
951
952    let req = req_builder.build()?;
953    let resp = configuration.client.execute(req).await?;
954
955    let status = resp.status();
956    let content_type = resp
957        .headers()
958        .get("content-type")
959        .and_then(|v| v.to_str().ok())
960        .unwrap_or("application/octet-stream");
961    let content_type = super::ContentType::from(content_type);
962
963    if !status.is_client_error() && !status.is_server_error() {
964        let content = resp.text().await?;
965        match content_type {
966            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
967            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateTableResponse`"))),
968            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`")))),
969        }
970    } else {
971        let content = resp.text().await?;
972        let entity: Option<UpdateTableError> = serde_json::from_str(&content).ok();
973        Err(Error::ResponseError(ResponseContent { status, content, entity }))
974    }
975}
976