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://lancedb.github.io/lance-namespace/spec/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://lancedb.github.io/lance-namespace/spec/impls/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    req_builder = req_builder.json(&p_create_namespace_request);
119
120    let req = req_builder.build()?;
121    let resp = configuration.client.execute(req).await?;
122
123    let status = resp.status();
124    let content_type = resp
125        .headers()
126        .get("content-type")
127        .and_then(|v| v.to_str().ok())
128        .unwrap_or("application/octet-stream");
129    let content_type = super::ContentType::from(content_type);
130
131    if !status.is_client_error() && !status.is_server_error() {
132        let content = resp.text().await?;
133        match content_type {
134            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
135            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateNamespaceResponse`"))),
136            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`")))),
137        }
138    } else {
139        let content = resp.text().await?;
140        let entity: Option<CreateNamespaceError> = serde_json::from_str(&content).ok();
141        Err(Error::ResponseError(ResponseContent { status, content, entity }))
142    }
143}
144
145/// Describe the detailed information for namespace `id`. 
146pub async fn describe_namespace(configuration: &configuration::Configuration, id: &str, describe_namespace_request: models::DescribeNamespaceRequest, delimiter: Option<&str>) -> Result<models::DescribeNamespaceResponse, Error<DescribeNamespaceError>> {
147    // add a prefix to parameters to efficiently prevent name collisions
148    let p_id = id;
149    let p_describe_namespace_request = describe_namespace_request;
150    let p_delimiter = delimiter;
151
152    let uri_str = format!("{}/v1/namespace/{id}/describe", configuration.base_path, id=crate::apis::urlencode(p_id));
153    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
154
155    if let Some(ref param_value) = p_delimiter {
156        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
157    }
158    if let Some(ref user_agent) = configuration.user_agent {
159        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
160    }
161    req_builder = req_builder.json(&p_describe_namespace_request);
162
163    let req = req_builder.build()?;
164    let resp = configuration.client.execute(req).await?;
165
166    let status = resp.status();
167    let content_type = resp
168        .headers()
169        .get("content-type")
170        .and_then(|v| v.to_str().ok())
171        .unwrap_or("application/octet-stream");
172    let content_type = super::ContentType::from(content_type);
173
174    if !status.is_client_error() && !status.is_server_error() {
175        let content = resp.text().await?;
176        match content_type {
177            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
178            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DescribeNamespaceResponse`"))),
179            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`")))),
180        }
181    } else {
182        let content = resp.text().await?;
183        let entity: Option<DescribeNamespaceError> = serde_json::from_str(&content).ok();
184        Err(Error::ResponseError(ResponseContent { status, content, entity }))
185    }
186}
187
188/// Drop namespace `id` from its parent namespace. 
189pub async fn drop_namespace(configuration: &configuration::Configuration, id: &str, drop_namespace_request: models::DropNamespaceRequest, delimiter: Option<&str>) -> Result<models::DropNamespaceResponse, Error<DropNamespaceError>> {
190    // add a prefix to parameters to efficiently prevent name collisions
191    let p_id = id;
192    let p_drop_namespace_request = drop_namespace_request;
193    let p_delimiter = delimiter;
194
195    let uri_str = format!("{}/v1/namespace/{id}/drop", configuration.base_path, id=crate::apis::urlencode(p_id));
196    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
197
198    if let Some(ref param_value) = p_delimiter {
199        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
200    }
201    if let Some(ref user_agent) = configuration.user_agent {
202        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
203    }
204    req_builder = req_builder.json(&p_drop_namespace_request);
205
206    let req = req_builder.build()?;
207    let resp = configuration.client.execute(req).await?;
208
209    let status = resp.status();
210    let content_type = resp
211        .headers()
212        .get("content-type")
213        .and_then(|v| v.to_str().ok())
214        .unwrap_or("application/octet-stream");
215    let content_type = super::ContentType::from(content_type);
216
217    if !status.is_client_error() && !status.is_server_error() {
218        let content = resp.text().await?;
219        match content_type {
220            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
221            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DropNamespaceResponse`"))),
222            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`")))),
223        }
224    } else {
225        let content = resp.text().await?;
226        let entity: Option<DropNamespaceError> = serde_json::from_str(&content).ok();
227        Err(Error::ResponseError(ResponseContent { status, content, entity }))
228    }
229}
230
231/// 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 
232pub async fn list_namespaces(configuration: &configuration::Configuration, id: &str, delimiter: Option<&str>, page_token: Option<&str>, limit: Option<i32>) -> Result<models::ListNamespacesResponse, Error<ListNamespacesError>> {
233    // add a prefix to parameters to efficiently prevent name collisions
234    let p_id = id;
235    let p_delimiter = delimiter;
236    let p_page_token = page_token;
237    let p_limit = limit;
238
239    let uri_str = format!("{}/v1/namespace/{id}/list", configuration.base_path, id=crate::apis::urlencode(p_id));
240    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
241
242    if let Some(ref param_value) = p_delimiter {
243        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
244    }
245    if let Some(ref param_value) = p_page_token {
246        req_builder = req_builder.query(&[("page_token", &param_value.to_string())]);
247    }
248    if let Some(ref param_value) = p_limit {
249        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
250    }
251    if let Some(ref user_agent) = configuration.user_agent {
252        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
253    }
254
255    let req = req_builder.build()?;
256    let resp = configuration.client.execute(req).await?;
257
258    let status = resp.status();
259    let content_type = resp
260        .headers()
261        .get("content-type")
262        .and_then(|v| v.to_str().ok())
263        .unwrap_or("application/octet-stream");
264    let content_type = super::ContentType::from(content_type);
265
266    if !status.is_client_error() && !status.is_server_error() {
267        let content = resp.text().await?;
268        match content_type {
269            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
270            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListNamespacesResponse`"))),
271            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`")))),
272        }
273    } else {
274        let content = resp.text().await?;
275        let entity: Option<ListNamespacesError> = serde_json::from_str(&content).ok();
276        Err(Error::ResponseError(ResponseContent { status, content, entity }))
277    }
278}
279
280/// 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 
281pub async fn list_tables(configuration: &configuration::Configuration, id: &str, delimiter: Option<&str>, page_token: Option<&str>, limit: Option<i32>) -> Result<models::ListTablesResponse, Error<ListTablesError>> {
282    // add a prefix to parameters to efficiently prevent name collisions
283    let p_id = id;
284    let p_delimiter = delimiter;
285    let p_page_token = page_token;
286    let p_limit = limit;
287
288    let uri_str = format!("{}/v1/namespace/{id}/table/list", configuration.base_path, id=crate::apis::urlencode(p_id));
289    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
290
291    if let Some(ref param_value) = p_delimiter {
292        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
293    }
294    if let Some(ref param_value) = p_page_token {
295        req_builder = req_builder.query(&[("page_token", &param_value.to_string())]);
296    }
297    if let Some(ref param_value) = p_limit {
298        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
299    }
300    if let Some(ref user_agent) = configuration.user_agent {
301        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
302    }
303
304    let req = req_builder.build()?;
305    let resp = configuration.client.execute(req).await?;
306
307    let status = resp.status();
308    let content_type = resp
309        .headers()
310        .get("content-type")
311        .and_then(|v| v.to_str().ok())
312        .unwrap_or("application/octet-stream");
313    let content_type = super::ContentType::from(content_type);
314
315    if !status.is_client_error() && !status.is_server_error() {
316        let content = resp.text().await?;
317        match content_type {
318            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
319            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListTablesResponse`"))),
320            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`")))),
321        }
322    } else {
323        let content = resp.text().await?;
324        let entity: Option<ListTablesError> = serde_json::from_str(&content).ok();
325        Err(Error::ResponseError(ResponseContent { status, content, entity }))
326    }
327}
328
329/// Check if namespace `id` exists.  This operation must behave exactly like the DescribeNamespace API,  except it does not contain a response body. 
330pub async fn namespace_exists(configuration: &configuration::Configuration, id: &str, namespace_exists_request: models::NamespaceExistsRequest, delimiter: Option<&str>) -> Result<(), Error<NamespaceExistsError>> {
331    // add a prefix to parameters to efficiently prevent name collisions
332    let p_id = id;
333    let p_namespace_exists_request = namespace_exists_request;
334    let p_delimiter = delimiter;
335
336    let uri_str = format!("{}/v1/namespace/{id}/exists", configuration.base_path, id=crate::apis::urlencode(p_id));
337    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
338
339    if let Some(ref param_value) = p_delimiter {
340        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
341    }
342    if let Some(ref user_agent) = configuration.user_agent {
343        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
344    }
345    req_builder = req_builder.json(&p_namespace_exists_request);
346
347    let req = req_builder.build()?;
348    let resp = configuration.client.execute(req).await?;
349
350    let status = resp.status();
351
352    if !status.is_client_error() && !status.is_server_error() {
353        Ok(())
354    } else {
355        let content = resp.text().await?;
356        let entity: Option<NamespaceExistsError> = serde_json::from_str(&content).ok();
357        Err(Error::ResponseError(ResponseContent { status, content, entity }))
358    }
359}
360