Skip to main content

lance_namespace_reqwest_client/apis/
namespace_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 [`create_namespace`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateNamespaceError {
22    Status400(models::ErrorResponse),
23    Status401(models::ErrorResponse),
24    Status403(models::ErrorResponse),
25    Status404(models::ErrorResponse),
26    Status406(models::ErrorResponse),
27    Status409(models::ErrorResponse),
28    Status503(models::ErrorResponse),
29    Status5XX(models::ErrorResponse),
30    UnknownValue(serde_json::Value),
31}
32
33/// struct for typed errors of method [`describe_namespace`]
34#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum DescribeNamespaceError {
37    Status400(models::ErrorResponse),
38    Status401(models::ErrorResponse),
39    Status403(models::ErrorResponse),
40    Status404(models::ErrorResponse),
41    Status503(models::ErrorResponse),
42    Status5XX(models::ErrorResponse),
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`drop_namespace`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum DropNamespaceError {
50    Status400(models::ErrorResponse),
51    Status401(models::ErrorResponse),
52    Status403(models::ErrorResponse),
53    Status404(models::ErrorResponse),
54    Status409(models::ErrorResponse),
55    Status503(models::ErrorResponse),
56    Status5XX(models::ErrorResponse),
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`list_namespaces`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ListNamespacesError {
64    Status400(models::ErrorResponse),
65    Status401(models::ErrorResponse),
66    Status403(models::ErrorResponse),
67    Status404(models::ErrorResponse),
68    Status406(models::ErrorResponse),
69    Status503(models::ErrorResponse),
70    Status5XX(models::ErrorResponse),
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`list_tables`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum ListTablesError {
78    Status400(models::ErrorResponse),
79    Status401(models::ErrorResponse),
80    Status403(models::ErrorResponse),
81    Status404(models::ErrorResponse),
82    Status406(models::ErrorResponse),
83    Status503(models::ErrorResponse),
84    Status5XX(models::ErrorResponse),
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`namespace_exists`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum NamespaceExistsError {
92    Status400(models::ErrorResponse),
93    Status401(models::ErrorResponse),
94    Status403(models::ErrorResponse),
95    Status404(models::ErrorResponse),
96    Status503(models::ErrorResponse),
97    Status5XX(models::ErrorResponse),
98    UnknownValue(serde_json::Value),
99}
100
101
102/// Create new namespace `id`.  During the creation process, the implementation may modify user-provided `properties`, such as adding additional properties like `created_at` to user-provided properties, omitting any specific property, or performing actions based on any property value. 
103pub async fn create_namespace(configuration: &configuration::Configuration, id: &str, create_namespace_request: models::CreateNamespaceRequest, delimiter: Option<&str>) -> Result<models::CreateNamespaceResponse, Error<CreateNamespaceError>> {
104    // add a prefix to parameters to efficiently prevent name collisions
105    let p_id = id;
106    let p_create_namespace_request = create_namespace_request;
107    let p_delimiter = delimiter;
108
109    let uri_str = format!("{}/v1/namespace/{id}/create", configuration.base_path, id=crate::apis::urlencode(p_id));
110    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
111
112    if let Some(ref param_value) = p_delimiter {
113        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
114    }
115    if let Some(ref user_agent) = configuration.user_agent {
116        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
117    }
118    if let Some(ref token) = configuration.oauth_access_token {
119        req_builder = req_builder.bearer_auth(token.to_owned());
120    };
121    if let Some(ref apikey) = configuration.api_key {
122        let key = apikey.key.clone();
123        let value = match apikey.prefix {
124            Some(ref prefix) => format!("{} {}", prefix, key),
125            None => key,
126        };
127        req_builder = req_builder.header("x-api-key", value);
128    };
129    if let Some(ref token) = configuration.bearer_access_token {
130        req_builder = req_builder.bearer_auth(token.to_owned());
131    };
132    req_builder = req_builder.json(&p_create_namespace_request);
133
134    let req = req_builder.build()?;
135    let resp = configuration.client.execute(req).await?;
136
137    let status = resp.status();
138    let content_type = resp
139        .headers()
140        .get("content-type")
141        .and_then(|v| v.to_str().ok())
142        .unwrap_or("application/octet-stream");
143    let content_type = super::ContentType::from(content_type);
144
145    if !status.is_client_error() && !status.is_server_error() {
146        let content = resp.text().await?;
147        match content_type {
148            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
149            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateNamespaceResponse`"))),
150            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::CreateNamespaceResponse`")))),
151        }
152    } else {
153        let content = resp.text().await?;
154        let entity: Option<CreateNamespaceError> = serde_json::from_str(&content).ok();
155        Err(Error::ResponseError(ResponseContent { status, content, entity }))
156    }
157}
158
159/// Describe the detailed information for namespace `id`. 
160pub async fn describe_namespace(configuration: &configuration::Configuration, id: &str, describe_namespace_request: models::DescribeNamespaceRequest, delimiter: Option<&str>) -> Result<models::DescribeNamespaceResponse, Error<DescribeNamespaceError>> {
161    // add a prefix to parameters to efficiently prevent name collisions
162    let p_id = id;
163    let p_describe_namespace_request = describe_namespace_request;
164    let p_delimiter = delimiter;
165
166    let uri_str = format!("{}/v1/namespace/{id}/describe", configuration.base_path, id=crate::apis::urlencode(p_id));
167    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
168
169    if let Some(ref param_value) = p_delimiter {
170        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
171    }
172    if let Some(ref user_agent) = configuration.user_agent {
173        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
174    }
175    if let Some(ref token) = configuration.oauth_access_token {
176        req_builder = req_builder.bearer_auth(token.to_owned());
177    };
178    if let Some(ref apikey) = configuration.api_key {
179        let key = apikey.key.clone();
180        let value = match apikey.prefix {
181            Some(ref prefix) => format!("{} {}", prefix, key),
182            None => key,
183        };
184        req_builder = req_builder.header("x-api-key", value);
185    };
186    if let Some(ref token) = configuration.bearer_access_token {
187        req_builder = req_builder.bearer_auth(token.to_owned());
188    };
189    req_builder = req_builder.json(&p_describe_namespace_request);
190
191    let req = req_builder.build()?;
192    let resp = configuration.client.execute(req).await?;
193
194    let status = resp.status();
195    let content_type = resp
196        .headers()
197        .get("content-type")
198        .and_then(|v| v.to_str().ok())
199        .unwrap_or("application/octet-stream");
200    let content_type = super::ContentType::from(content_type);
201
202    if !status.is_client_error() && !status.is_server_error() {
203        let content = resp.text().await?;
204        match content_type {
205            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
206            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DescribeNamespaceResponse`"))),
207            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::DescribeNamespaceResponse`")))),
208        }
209    } else {
210        let content = resp.text().await?;
211        let entity: Option<DescribeNamespaceError> = serde_json::from_str(&content).ok();
212        Err(Error::ResponseError(ResponseContent { status, content, entity }))
213    }
214}
215
216/// Drop namespace `id` from its parent namespace. 
217pub async fn drop_namespace(configuration: &configuration::Configuration, id: &str, drop_namespace_request: models::DropNamespaceRequest, delimiter: Option<&str>) -> Result<models::DropNamespaceResponse, Error<DropNamespaceError>> {
218    // add a prefix to parameters to efficiently prevent name collisions
219    let p_id = id;
220    let p_drop_namespace_request = drop_namespace_request;
221    let p_delimiter = delimiter;
222
223    let uri_str = format!("{}/v1/namespace/{id}/drop", configuration.base_path, id=crate::apis::urlencode(p_id));
224    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
225
226    if let Some(ref param_value) = p_delimiter {
227        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
228    }
229    if let Some(ref user_agent) = configuration.user_agent {
230        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
231    }
232    if let Some(ref token) = configuration.oauth_access_token {
233        req_builder = req_builder.bearer_auth(token.to_owned());
234    };
235    if let Some(ref apikey) = configuration.api_key {
236        let key = apikey.key.clone();
237        let value = match apikey.prefix {
238            Some(ref prefix) => format!("{} {}", prefix, key),
239            None => key,
240        };
241        req_builder = req_builder.header("x-api-key", value);
242    };
243    if let Some(ref token) = configuration.bearer_access_token {
244        req_builder = req_builder.bearer_auth(token.to_owned());
245    };
246    req_builder = req_builder.json(&p_drop_namespace_request);
247
248    let req = req_builder.build()?;
249    let resp = configuration.client.execute(req).await?;
250
251    let status = resp.status();
252    let content_type = resp
253        .headers()
254        .get("content-type")
255        .and_then(|v| v.to_str().ok())
256        .unwrap_or("application/octet-stream");
257    let content_type = super::ContentType::from(content_type);
258
259    if !status.is_client_error() && !status.is_server_error() {
260        let content = resp.text().await?;
261        match content_type {
262            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
263            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DropNamespaceResponse`"))),
264            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::DropNamespaceResponse`")))),
265        }
266    } else {
267        let content = resp.text().await?;
268        let entity: Option<DropNamespaceError> = serde_json::from_str(&content).ok();
269        Err(Error::ResponseError(ResponseContent { status, content, entity }))
270    }
271}
272
273/// List all child namespace names of the parent namespace `id`.  REST NAMESPACE ONLY REST namespace uses GET to perform this operation without a request body. It passes in the `ListNamespacesRequest` information in the following way: - `id`: pass through path parameter of the same name - `page_token`: pass through query parameter of the same name - `limit`: pass through query parameter of the same name 
274pub async fn list_namespaces(configuration: &configuration::Configuration, id: &str, delimiter: Option<&str>, page_token: Option<&str>, limit: Option<i32>) -> Result<models::ListNamespacesResponse, Error<ListNamespacesError>> {
275    // add a prefix to parameters to efficiently prevent name collisions
276    let p_id = id;
277    let p_delimiter = delimiter;
278    let p_page_token = page_token;
279    let p_limit = limit;
280
281    let uri_str = format!("{}/v1/namespace/{id}/list", configuration.base_path, id=crate::apis::urlencode(p_id));
282    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
283
284    if let Some(ref param_value) = p_delimiter {
285        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
286    }
287    if let Some(ref param_value) = p_page_token {
288        req_builder = req_builder.query(&[("page_token", &param_value.to_string())]);
289    }
290    if let Some(ref param_value) = p_limit {
291        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
292    }
293    if let Some(ref user_agent) = configuration.user_agent {
294        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
295    }
296    if let Some(ref token) = configuration.oauth_access_token {
297        req_builder = req_builder.bearer_auth(token.to_owned());
298    };
299    if let Some(ref apikey) = configuration.api_key {
300        let key = apikey.key.clone();
301        let value = match apikey.prefix {
302            Some(ref prefix) => format!("{} {}", prefix, key),
303            None => key,
304        };
305        req_builder = req_builder.header("x-api-key", value);
306    };
307    if let Some(ref token) = configuration.bearer_access_token {
308        req_builder = req_builder.bearer_auth(token.to_owned());
309    };
310
311    let req = req_builder.build()?;
312    let resp = configuration.client.execute(req).await?;
313
314    let status = resp.status();
315    let content_type = resp
316        .headers()
317        .get("content-type")
318        .and_then(|v| v.to_str().ok())
319        .unwrap_or("application/octet-stream");
320    let content_type = super::ContentType::from(content_type);
321
322    if !status.is_client_error() && !status.is_server_error() {
323        let content = resp.text().await?;
324        match content_type {
325            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
326            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListNamespacesResponse`"))),
327            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::ListNamespacesResponse`")))),
328        }
329    } else {
330        let content = resp.text().await?;
331        let entity: Option<ListNamespacesError> = serde_json::from_str(&content).ok();
332        Err(Error::ResponseError(ResponseContent { status, content, entity }))
333    }
334}
335
336/// List all child table names of the parent namespace `id`.  REST NAMESPACE ONLY REST namespace uses GET to perform this operation without a request body. It passes in the `ListTablesRequest` information in the following way: - `id`: pass through path parameter of the same name - `page_token`: pass through query parameter of the same name - `limit`: pass through query parameter of the same name - `include_declared`: pass through query parameter of the same name 
337pub async fn list_tables(configuration: &configuration::Configuration, id: &str, delimiter: Option<&str>, page_token: Option<&str>, limit: Option<i32>, include_declared: Option<bool>) -> Result<models::ListTablesResponse, Error<ListTablesError>> {
338    // add a prefix to parameters to efficiently prevent name collisions
339    let p_id = id;
340    let p_delimiter = delimiter;
341    let p_page_token = page_token;
342    let p_limit = limit;
343    let p_include_declared = include_declared;
344
345    let uri_str = format!("{}/v1/namespace/{id}/table/list", configuration.base_path, id=crate::apis::urlencode(p_id));
346    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
347
348    if let Some(ref param_value) = p_delimiter {
349        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
350    }
351    if let Some(ref param_value) = p_page_token {
352        req_builder = req_builder.query(&[("page_token", &param_value.to_string())]);
353    }
354    if let Some(ref param_value) = p_limit {
355        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
356    }
357    if let Some(ref param_value) = p_include_declared {
358        req_builder = req_builder.query(&[("include_declared", &param_value.to_string())]);
359    }
360    if let Some(ref user_agent) = configuration.user_agent {
361        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
362    }
363    if let Some(ref token) = configuration.oauth_access_token {
364        req_builder = req_builder.bearer_auth(token.to_owned());
365    };
366    if let Some(ref apikey) = configuration.api_key {
367        let key = apikey.key.clone();
368        let value = match apikey.prefix {
369            Some(ref prefix) => format!("{} {}", prefix, key),
370            None => key,
371        };
372        req_builder = req_builder.header("x-api-key", value);
373    };
374    if let Some(ref token) = configuration.bearer_access_token {
375        req_builder = req_builder.bearer_auth(token.to_owned());
376    };
377
378    let req = req_builder.build()?;
379    let resp = configuration.client.execute(req).await?;
380
381    let status = resp.status();
382    let content_type = resp
383        .headers()
384        .get("content-type")
385        .and_then(|v| v.to_str().ok())
386        .unwrap_or("application/octet-stream");
387    let content_type = super::ContentType::from(content_type);
388
389    if !status.is_client_error() && !status.is_server_error() {
390        let content = resp.text().await?;
391        match content_type {
392            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
393            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListTablesResponse`"))),
394            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::ListTablesResponse`")))),
395        }
396    } else {
397        let content = resp.text().await?;
398        let entity: Option<ListTablesError> = serde_json::from_str(&content).ok();
399        Err(Error::ResponseError(ResponseContent { status, content, entity }))
400    }
401}
402
403/// Check if namespace `id` exists.  This operation must behave exactly like the DescribeNamespace API, except it does not contain a response body. 
404pub async fn namespace_exists(configuration: &configuration::Configuration, id: &str, namespace_exists_request: models::NamespaceExistsRequest, delimiter: Option<&str>) -> Result<(), Error<NamespaceExistsError>> {
405    // add a prefix to parameters to efficiently prevent name collisions
406    let p_id = id;
407    let p_namespace_exists_request = namespace_exists_request;
408    let p_delimiter = delimiter;
409
410    let uri_str = format!("{}/v1/namespace/{id}/exists", configuration.base_path, id=crate::apis::urlencode(p_id));
411    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
412
413    if let Some(ref param_value) = p_delimiter {
414        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
415    }
416    if let Some(ref user_agent) = configuration.user_agent {
417        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
418    }
419    if let Some(ref token) = configuration.oauth_access_token {
420        req_builder = req_builder.bearer_auth(token.to_owned());
421    };
422    if let Some(ref apikey) = configuration.api_key {
423        let key = apikey.key.clone();
424        let value = match apikey.prefix {
425            Some(ref prefix) => format!("{} {}", prefix, key),
426            None => key,
427        };
428        req_builder = req_builder.header("x-api-key", value);
429    };
430    if let Some(ref token) = configuration.bearer_access_token {
431        req_builder = req_builder.bearer_auth(token.to_owned());
432    };
433    req_builder = req_builder.json(&p_namespace_exists_request);
434
435    let req = req_builder.build()?;
436    let resp = configuration.client.execute(req).await?;
437
438    let status = resp.status();
439
440    if !status.is_client_error() && !status.is_server_error() {
441        Ok(())
442    } else {
443        let content = resp.text().await?;
444        let entity: Option<NamespaceExistsError> = serde_json::from_str(&content).ok();
445        Err(Error::ResponseError(ResponseContent { status, content, entity }))
446    }
447}
448