lance_namespace_reqwest_client/apis/
transaction_api.rs1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[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#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum DescribeTransactionError {
36 Status400(models::ErrorResponse),
37 Status401(models::ErrorResponse),
38 Status403(models::ErrorResponse),
39 Status404(models::ErrorResponse),
40 Status503(models::ErrorResponse),
41 Status5XX(models::ErrorResponse),
42 UnknownValue(serde_json::Value),
43}
44
45
46pub async fn alter_transaction(configuration: &configuration::Configuration, id: &str, alter_transaction_request: models::AlterTransactionRequest, delimiter: Option<&str>) -> Result<models::AlterTransactionResponse, Error<AlterTransactionError>> {
48 let p_id = id;
50 let p_alter_transaction_request = alter_transaction_request;
51 let p_delimiter = delimiter;
52
53 let uri_str = format!("{}/v1/transaction/{id}/alter", configuration.base_path, id=crate::apis::urlencode(p_id));
54 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
55
56 if let Some(ref param_value) = p_delimiter {
57 req_builder = req_builder.query(&[("delimiter", ¶m_value.to_string())]);
58 }
59 if let Some(ref user_agent) = configuration.user_agent {
60 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
61 }
62 req_builder = req_builder.json(&p_alter_transaction_request);
63
64 let req = req_builder.build()?;
65 let resp = configuration.client.execute(req).await?;
66
67 let status = resp.status();
68 let content_type = resp
69 .headers()
70 .get("content-type")
71 .and_then(|v| v.to_str().ok())
72 .unwrap_or("application/octet-stream");
73 let content_type = super::ContentType::from(content_type);
74
75 if !status.is_client_error() && !status.is_server_error() {
76 let content = resp.text().await?;
77 match content_type {
78 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
79 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AlterTransactionResponse`"))),
80 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`")))),
81 }
82 } else {
83 let content = resp.text().await?;
84 let entity: Option<AlterTransactionError> = serde_json::from_str(&content).ok();
85 Err(Error::ResponseError(ResponseContent { status, content, entity }))
86 }
87}
88
89pub async fn describe_transaction(configuration: &configuration::Configuration, id: &str, describe_transaction_request: models::DescribeTransactionRequest, delimiter: Option<&str>) -> Result<models::DescribeTransactionResponse, Error<DescribeTransactionError>> {
91 let p_id = id;
93 let p_describe_transaction_request = describe_transaction_request;
94 let p_delimiter = delimiter;
95
96 let uri_str = format!("{}/v1/transaction/{id}/describe", configuration.base_path, id=crate::apis::urlencode(p_id));
97 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
98
99 if let Some(ref param_value) = p_delimiter {
100 req_builder = req_builder.query(&[("delimiter", ¶m_value.to_string())]);
101 }
102 if let Some(ref user_agent) = configuration.user_agent {
103 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
104 }
105 req_builder = req_builder.json(&p_describe_transaction_request);
106
107 let req = req_builder.build()?;
108 let resp = configuration.client.execute(req).await?;
109
110 let status = resp.status();
111 let content_type = resp
112 .headers()
113 .get("content-type")
114 .and_then(|v| v.to_str().ok())
115 .unwrap_or("application/octet-stream");
116 let content_type = super::ContentType::from(content_type);
117
118 if !status.is_client_error() && !status.is_server_error() {
119 let content = resp.text().await?;
120 match content_type {
121 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
122 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DescribeTransactionResponse`"))),
123 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`")))),
124 }
125 } else {
126 let content = resp.text().await?;
127 let entity: Option<DescribeTransactionError> = serde_json::from_str(&content).ok();
128 Err(Error::ResponseError(ResponseContent { status, content, entity }))
129 }
130}
131