Skip to main content

lance_namespace_reqwest_client/apis/
transaction_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_transaction`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AlterTransactionError {
22    Status400(models::ErrorResponse),
23    Status401(models::ErrorResponse),
24    Status403(models::ErrorResponse),
25    Status404(models::ErrorResponse),
26    Status409(models::ErrorResponse),
27    Status503(models::ErrorResponse),
28    Status5XX(models::ErrorResponse),
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`batch_commit_tables`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum BatchCommitTablesError {
36    Status400(models::ErrorResponse),
37    Status401(models::ErrorResponse),
38    Status403(models::ErrorResponse),
39    Status404(models::ErrorResponse),
40    Status409(models::ErrorResponse),
41    Status503(models::ErrorResponse),
42    Status5XX(models::ErrorResponse),
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`describe_transaction`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum DescribeTransactionError {
50    Status400(models::ErrorResponse),
51    Status401(models::ErrorResponse),
52    Status403(models::ErrorResponse),
53    Status404(models::ErrorResponse),
54    Status503(models::ErrorResponse),
55    Status5XX(models::ErrorResponse),
56    UnknownValue(serde_json::Value),
57}
58
59
60/// Alter a transaction with a list of actions such as setting status or properties. The server should either succeed and apply all actions, or fail and apply no action. 
61pub async fn alter_transaction(configuration: &configuration::Configuration, id: &str, alter_transaction_request: models::AlterTransactionRequest, delimiter: Option<&str>) -> Result<models::AlterTransactionResponse, Error<AlterTransactionError>> {
62    // add a prefix to parameters to efficiently prevent name collisions
63    let p_id = id;
64    let p_alter_transaction_request = alter_transaction_request;
65    let p_delimiter = delimiter;
66
67    let uri_str = format!("{}/v1/transaction/{id}/alter", configuration.base_path, id=crate::apis::urlencode(p_id));
68    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
69
70    if let Some(ref param_value) = p_delimiter {
71        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
72    }
73    if let Some(ref user_agent) = configuration.user_agent {
74        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
75    }
76    if let Some(ref token) = configuration.oauth_access_token {
77        req_builder = req_builder.bearer_auth(token.to_owned());
78    };
79    if let Some(ref apikey) = configuration.api_key {
80        let key = apikey.key.clone();
81        let value = match apikey.prefix {
82            Some(ref prefix) => format!("{} {}", prefix, key),
83            None => key,
84        };
85        req_builder = req_builder.header("x-api-key", value);
86    };
87    if let Some(ref token) = configuration.bearer_access_token {
88        req_builder = req_builder.bearer_auth(token.to_owned());
89    };
90    req_builder = req_builder.json(&p_alter_transaction_request);
91
92    let req = req_builder.build()?;
93    let resp = configuration.client.execute(req).await?;
94
95    let status = resp.status();
96    let content_type = resp
97        .headers()
98        .get("content-type")
99        .and_then(|v| v.to_str().ok())
100        .unwrap_or("application/octet-stream");
101    let content_type = super::ContentType::from(content_type);
102
103    if !status.is_client_error() && !status.is_server_error() {
104        let content = resp.text().await?;
105        match content_type {
106            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
107            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AlterTransactionResponse`"))),
108            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::AlterTransactionResponse`")))),
109        }
110    } else {
111        let content = resp.text().await?;
112        let entity: Option<AlterTransactionError> = serde_json::from_str(&content).ok();
113        Err(Error::ResponseError(ResponseContent { status, content, entity }))
114    }
115}
116
117/// Atomically commit a batch of table operations. This is a generalized version of `BatchCreateTableVersions` that supports mixed operation types within a single atomic transaction at the metadata layer.  Supported operation types: - `DeclareTable`: Declare (reserve) a new table - `CreateTableVersion`: Create a new version entry for a table - `DeleteTableVersions`: Delete version ranges from a table - `DeregisterTable`: Deregister (soft-delete) a table  All operations are committed atomically: either all succeed or none are applied. 
118pub async fn batch_commit_tables(configuration: &configuration::Configuration, batch_commit_tables_request: models::BatchCommitTablesRequest, delimiter: Option<&str>) -> Result<models::BatchCommitTablesResponse, Error<BatchCommitTablesError>> {
119    // add a prefix to parameters to efficiently prevent name collisions
120    let p_batch_commit_tables_request = batch_commit_tables_request;
121    let p_delimiter = delimiter;
122
123    let uri_str = format!("{}/v1/table/batch-commit", configuration.base_path);
124    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
125
126    if let Some(ref param_value) = p_delimiter {
127        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
128    }
129    if let Some(ref user_agent) = configuration.user_agent {
130        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
131    }
132    if let Some(ref token) = configuration.oauth_access_token {
133        req_builder = req_builder.bearer_auth(token.to_owned());
134    };
135    if let Some(ref apikey) = configuration.api_key {
136        let key = apikey.key.clone();
137        let value = match apikey.prefix {
138            Some(ref prefix) => format!("{} {}", prefix, key),
139            None => key,
140        };
141        req_builder = req_builder.header("x-api-key", value);
142    };
143    if let Some(ref token) = configuration.bearer_access_token {
144        req_builder = req_builder.bearer_auth(token.to_owned());
145    };
146    req_builder = req_builder.json(&p_batch_commit_tables_request);
147
148    let req = req_builder.build()?;
149    let resp = configuration.client.execute(req).await?;
150
151    let status = resp.status();
152    let content_type = resp
153        .headers()
154        .get("content-type")
155        .and_then(|v| v.to_str().ok())
156        .unwrap_or("application/octet-stream");
157    let content_type = super::ContentType::from(content_type);
158
159    if !status.is_client_error() && !status.is_server_error() {
160        let content = resp.text().await?;
161        match content_type {
162            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
163            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BatchCommitTablesResponse`"))),
164            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::BatchCommitTablesResponse`")))),
165        }
166    } else {
167        let content = resp.text().await?;
168        let entity: Option<BatchCommitTablesError> = serde_json::from_str(&content).ok();
169        Err(Error::ResponseError(ResponseContent { status, content, entity }))
170    }
171}
172
173/// Return a detailed information for a given transaction 
174pub async fn describe_transaction(configuration: &configuration::Configuration, id: &str, describe_transaction_request: models::DescribeTransactionRequest, delimiter: Option<&str>) -> Result<models::DescribeTransactionResponse, Error<DescribeTransactionError>> {
175    // add a prefix to parameters to efficiently prevent name collisions
176    let p_id = id;
177    let p_describe_transaction_request = describe_transaction_request;
178    let p_delimiter = delimiter;
179
180    let uri_str = format!("{}/v1/transaction/{id}/describe", configuration.base_path, id=crate::apis::urlencode(p_id));
181    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
182
183    if let Some(ref param_value) = p_delimiter {
184        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
185    }
186    if let Some(ref user_agent) = configuration.user_agent {
187        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
188    }
189    if let Some(ref token) = configuration.oauth_access_token {
190        req_builder = req_builder.bearer_auth(token.to_owned());
191    };
192    if let Some(ref apikey) = configuration.api_key {
193        let key = apikey.key.clone();
194        let value = match apikey.prefix {
195            Some(ref prefix) => format!("{} {}", prefix, key),
196            None => key,
197        };
198        req_builder = req_builder.header("x-api-key", value);
199    };
200    if let Some(ref token) = configuration.bearer_access_token {
201        req_builder = req_builder.bearer_auth(token.to_owned());
202    };
203    req_builder = req_builder.json(&p_describe_transaction_request);
204
205    let req = req_builder.build()?;
206    let resp = configuration.client.execute(req).await?;
207
208    let status = resp.status();
209    let content_type = resp
210        .headers()
211        .get("content-type")
212        .and_then(|v| v.to_str().ok())
213        .unwrap_or("application/octet-stream");
214    let content_type = super::ContentType::from(content_type);
215
216    if !status.is_client_error() && !status.is_server_error() {
217        let content = resp.text().await?;
218        match content_type {
219            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
220            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DescribeTransactionResponse`"))),
221            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::DescribeTransactionResponse`")))),
222        }
223    } else {
224        let content = resp.text().await?;
225        let entity: Option<DescribeTransactionError> = serde_json::from_str(&content).ok();
226        Err(Error::ResponseError(ResponseContent { status, content, entity }))
227    }
228}
229