use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StorageAggregateError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StorageClearError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StorageDeleteError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StorageDeleteIndexError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StorageDetailError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StorageExecuteFunctionError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StorageExportError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StorageImportError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StorageIndexesError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StorageListError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StoragePostError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StoragePostIndexError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StoragePutError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StorageRemoveError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StorageStatsError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StorageTablesError {
UnknownValue(serde_json::Value),
}
pub async fn storage_aggregate(configuration: &configuration::Configuration, table: &str, app_key: &str, pipeline: Option<&str>) -> Result<models::ObjectListApiResponse, Error<StorageAggregateError>> {
let p_table = table;
let p_app_key = app_key;
let p_pipeline = pipeline;
let uri_str = format!("{}/Storage/{appKey}/{table}/Aggregate", configuration.base_path, table=crate::apis::urlencode(p_table), appKey=crate::apis::urlencode(p_app_key));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_pipeline {
req_builder = req_builder.query(&[("pipeline", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ObjectListApiResponse`"))),
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::ObjectListApiResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<StorageAggregateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn storage_clear(configuration: &configuration::Configuration, table: &str, app_key: &str, filter: Option<&str>) -> Result<models::Int64ApiResponse, Error<StorageClearError>> {
let p_table = table;
let p_app_key = app_key;
let p_filter = filter;
let uri_str = format!("{}/Storage/{appKey}/{table}/Clear", configuration.base_path, table=crate::apis::urlencode(p_table), appKey=crate::apis::urlencode(p_app_key));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Int64ApiResponse`"))),
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::Int64ApiResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<StorageClearError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn storage_delete(configuration: &configuration::Configuration, table: &str, id: &str, app_key: &str) -> Result<models::BooleanApiResponse, Error<StorageDeleteError>> {
let p_table = table;
let p_id = id;
let p_app_key = app_key;
let uri_str = format!("{}/Storage/{appKey}/{table}/{id}", configuration.base_path, table=crate::apis::urlencode(p_table), id=crate::apis::urlencode(p_id), appKey=crate::apis::urlencode(p_app_key));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BooleanApiResponse`"))),
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::BooleanApiResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<StorageDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn storage_delete_index(configuration: &configuration::Configuration, table: &str, app_key: &str, index_name: Option<&str>) -> Result<models::BooleanApiResponse, Error<StorageDeleteIndexError>> {
let p_table = table;
let p_app_key = app_key;
let p_index_name = index_name;
let uri_str = format!("{}/Storage/{appKey}/{table}/indexes", configuration.base_path, table=crate::apis::urlencode(p_table), appKey=crate::apis::urlencode(p_app_key));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_index_name {
req_builder = req_builder.query(&[("indexName", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BooleanApiResponse`"))),
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::BooleanApiResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<StorageDeleteIndexError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn storage_detail(configuration: &configuration::Configuration, table: &str, id: &str, app_key: &str, project: Option<&str>) -> Result<models::ObjectApiResponse, Error<StorageDetailError>> {
let p_table = table;
let p_id = id;
let p_app_key = app_key;
let p_project = project;
let uri_str = format!("{}/Storage/{appKey}/{table}/{id}", configuration.base_path, table=crate::apis::urlencode(p_table), id=crate::apis::urlencode(p_id), appKey=crate::apis::urlencode(p_app_key));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_project {
req_builder = req_builder.query(&[("project", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ObjectApiResponse`"))),
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::ObjectApiResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<StorageDetailError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn storage_execute_function(configuration: &configuration::Configuration, nonce: &str, timestamp: i64, signature: &str, app_key: &str, execute_function_request: Option<models::ExecuteFunctionRequest>) -> Result<models::ObjectApiResponse, Error<StorageExecuteFunctionError>> {
let p_nonce = nonce;
let p_timestamp = timestamp;
let p_signature = signature;
let p_app_key = app_key;
let p_execute_function_request = execute_function_request;
let uri_str = format!("{}/Storage/{appKey}/ExecuteFunction", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("nonce", &p_nonce.to_string())]);
req_builder = req_builder.query(&[("timestamp", &p_timestamp.to_string())]);
req_builder = req_builder.query(&[("signature", &p_signature.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_execute_function_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ObjectApiResponse`"))),
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::ObjectApiResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<StorageExecuteFunctionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn storage_export(configuration: &configuration::Configuration, table: &str, app_key: &str, filter: Option<&str>, start_time: Option<String>, end_time: Option<String>) -> Result<reqwest::Response, Error<StorageExportError>> {
let p_table = table;
let p_app_key = app_key;
let p_filter = filter;
let p_start_time = start_time;
let p_end_time = end_time;
let uri_str = format!("{}/Storage/{appKey}/{table}/Export", configuration.base_path, table=crate::apis::urlencode(p_table), appKey=crate::apis::urlencode(p_app_key));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_start_time {
req_builder = req_builder.query(&[("startTime", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_end_time {
req_builder = req_builder.query(&[("endTime", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(resp)
} else {
let content = resp.text().await?;
let entity: Option<StorageExportError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn storage_import(configuration: &configuration::Configuration, table: &str, app_key: &str, file: Option<std::path::PathBuf>) -> Result<models::BooleanApiResponse, Error<StorageImportError>> {
let p_table = table;
let p_app_key = app_key;
let p_file = file;
let uri_str = format!("{}/Storage/{appKey}/{table}/Import", configuration.base_path, table=crate::apis::urlencode(p_table), appKey=crate::apis::urlencode(p_app_key));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let mut multipart_form = reqwest::multipart::Form::new();
req_builder = req_builder.multipart(multipart_form);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BooleanApiResponse`"))),
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::BooleanApiResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<StorageImportError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn storage_indexes(configuration: &configuration::Configuration, table: &str, app_key: &str) -> Result<models::ObjectListApiResponse, Error<StorageIndexesError>> {
let p_table = table;
let p_app_key = app_key;
let uri_str = format!("{}/Storage/{appKey}/{table}/Indexes", configuration.base_path, table=crate::apis::urlencode(p_table), appKey=crate::apis::urlencode(p_app_key));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ObjectListApiResponse`"))),
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::ObjectListApiResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<StorageIndexesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn storage_list(configuration: &configuration::Configuration, table: &str, app_key: &str, filter: Option<&str>, project: Option<&str>, sort: Option<&str>, start_time: Option<String>, end_time: Option<String>, explain: Option<bool>, take: Option<i32>, skip: Option<i32>) -> Result<models::StorageListResultApiResponse, Error<StorageListError>> {
let p_table = table;
let p_app_key = app_key;
let p_filter = filter;
let p_project = project;
let p_sort = sort;
let p_start_time = start_time;
let p_end_time = end_time;
let p_explain = explain;
let p_take = take;
let p_skip = skip;
let uri_str = format!("{}/Storage/{appKey}/{table}", configuration.base_path, table=crate::apis::urlencode(p_table), appKey=crate::apis::urlencode(p_app_key));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_project {
req_builder = req_builder.query(&[("project", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_sort {
req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_start_time {
req_builder = req_builder.query(&[("startTime", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_end_time {
req_builder = req_builder.query(&[("endTime", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_explain {
req_builder = req_builder.query(&[("explain", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_take {
req_builder = req_builder.query(&[("take", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_skip {
req_builder = req_builder.query(&[("skip", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::StorageListResultApiResponse`"))),
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::StorageListResultApiResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<StorageListError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn storage_post(configuration: &configuration::Configuration, table: &str, app_key: &str, request_body: Vec<serde_json::Value>) -> Result<models::StringApiResponse, Error<StoragePostError>> {
let p_table = table;
let p_app_key = app_key;
let p_request_body = request_body;
let uri_str = format!("{}/Storage/{appKey}/{table}", configuration.base_path, table=crate::apis::urlencode(p_table), appKey=crate::apis::urlencode(p_app_key));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_request_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::StringApiResponse`"))),
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::StringApiResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<StoragePostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn storage_post_index(configuration: &configuration::Configuration, table: &str, app_key: &str, post_index_request: Option<models::PostIndexRequest>) -> Result<models::StringApiResponse, Error<StoragePostIndexError>> {
let p_table = table;
let p_app_key = app_key;
let p_post_index_request = post_index_request;
let uri_str = format!("{}/Storage/{appKey}/{table}/indexes", configuration.base_path, table=crate::apis::urlencode(p_table), appKey=crate::apis::urlencode(p_app_key));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_post_index_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::StringApiResponse`"))),
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::StringApiResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<StoragePostIndexError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn storage_put(configuration: &configuration::Configuration, table: &str, id: &str, app_key: &str, body: Option<serde_json::Value>, replace: Option<bool>) -> Result<models::BooleanApiResponse, Error<StoragePutError>> {
let p_table = table;
let p_id = id;
let p_app_key = app_key;
let p_body = body;
let p_replace = replace;
let uri_str = format!("{}/Storage/{appKey}/{table}/{id}", configuration.base_path, table=crate::apis::urlencode(p_table), id=crate::apis::urlencode(p_id), appKey=crate::apis::urlencode(p_app_key));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref param_value) = p_replace {
req_builder = req_builder.query(&[("replace", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BooleanApiResponse`"))),
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::BooleanApiResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<StoragePutError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn storage_remove(configuration: &configuration::Configuration, table: &str, app_key: &str) -> Result<models::BooleanApiResponse, Error<StorageRemoveError>> {
let p_table = table;
let p_app_key = app_key;
let uri_str = format!("{}/Storage/{appKey}/{table}/Remove", configuration.base_path, table=crate::apis::urlencode(p_table), appKey=crate::apis::urlencode(p_app_key));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BooleanApiResponse`"))),
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::BooleanApiResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<StorageRemoveError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn storage_stats(configuration: &configuration::Configuration, table: &str, app_key: &str) -> Result<models::ObjectApiResponse, Error<StorageStatsError>> {
let p_table = table;
let p_app_key = app_key;
let uri_str = format!("{}/Storage/{appKey}/{table}/Stats", configuration.base_path, table=crate::apis::urlencode(p_table), appKey=crate::apis::urlencode(p_app_key));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ObjectApiResponse`"))),
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::ObjectApiResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<StorageStatsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn storage_tables(configuration: &configuration::Configuration, app_key: &str) -> Result<models::StringListApiResponse, Error<StorageTablesError>> {
let p_app_key = app_key;
let uri_str = format!("{}/Storage/{appKey}/Tables", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::StringListApiResponse`"))),
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::StringListApiResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<StorageTablesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}