windmill_api/apis/
volume_api.rs1use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateVolumeError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum DeleteVolumeError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetVolumeStorageError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ListVolumesError {
43 UnknownValue(serde_json::Value),
44}
45
46
47pub async fn create_volume(configuration: &configuration::Configuration, workspace: &str, list_hub_integrations200_response_inner: models::ListHubIntegrations200ResponseInner) -> Result<String, Error<CreateVolumeError>> {
48 let local_var_configuration = configuration;
49
50 let local_var_client = &local_var_configuration.client;
51
52 let local_var_uri_str = format!("{}/w/{workspace}/volumes/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
53 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
54
55 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
56 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
57 }
58 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
59 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
60 };
61 local_var_req_builder = local_var_req_builder.json(&list_hub_integrations200_response_inner);
62
63 let local_var_req = local_var_req_builder.build()?;
64 let local_var_resp = local_var_client.execute(local_var_req).await?;
65
66 let local_var_status = local_var_resp.status();
67 let local_var_content = local_var_resp.text().await?;
68
69 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
70 crate::from_str_patched(&local_var_content).map_err(Error::from)
71 } else {
72 let local_var_entity: Option<CreateVolumeError> = crate::from_str_patched(&local_var_content).ok();
73 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
74 Err(Error::ResponseError(local_var_error))
75 }
76}
77
78pub async fn delete_volume(configuration: &configuration::Configuration, workspace: &str, name: &str) -> Result<String, Error<DeleteVolumeError>> {
79 let local_var_configuration = configuration;
80
81 let local_var_client = &local_var_configuration.client;
82
83 let local_var_uri_str = format!("{}/w/{workspace}/volumes/delete/{name}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), name=crate::apis::urlencode(name));
84 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
85
86 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
87 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
88 }
89 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
90 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
91 };
92
93 let local_var_req = local_var_req_builder.build()?;
94 let local_var_resp = local_var_client.execute(local_var_req).await?;
95
96 let local_var_status = local_var_resp.status();
97 let local_var_content = local_var_resp.text().await?;
98
99 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
100 crate::from_str_patched(&local_var_content).map_err(Error::from)
101 } else {
102 let local_var_entity: Option<DeleteVolumeError> = crate::from_str_patched(&local_var_content).ok();
103 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
104 Err(Error::ResponseError(local_var_error))
105 }
106}
107
108pub async fn get_volume_storage(configuration: &configuration::Configuration, workspace: &str) -> Result<String, Error<GetVolumeStorageError>> {
109 let local_var_configuration = configuration;
110
111 let local_var_client = &local_var_configuration.client;
112
113 let local_var_uri_str = format!("{}/w/{workspace}/volumes/storage", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
114 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
115
116 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
117 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
118 }
119 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
120 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
121 };
122
123 let local_var_req = local_var_req_builder.build()?;
124 let local_var_resp = local_var_client.execute(local_var_req).await?;
125
126 let local_var_status = local_var_resp.status();
127 let local_var_content = local_var_resp.text().await?;
128
129 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
130 crate::from_str_patched(&local_var_content).map_err(Error::from)
131 } else {
132 let local_var_entity: Option<GetVolumeStorageError> = crate::from_str_patched(&local_var_content).ok();
133 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
134 Err(Error::ResponseError(local_var_error))
135 }
136}
137
138pub async fn list_volumes(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<models::Volume>, Error<ListVolumesError>> {
139 let local_var_configuration = configuration;
140
141 let local_var_client = &local_var_configuration.client;
142
143 let local_var_uri_str = format!("{}/w/{workspace}/volumes/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
144 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
145
146 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
147 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
148 }
149 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
150 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
151 };
152
153 let local_var_req = local_var_req_builder.build()?;
154 let local_var_resp = local_var_client.execute(local_var_req).await?;
155
156 let local_var_status = local_var_resp.status();
157 let local_var_content = local_var_resp.text().await?;
158
159 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
160 crate::from_str_patched(&local_var_content).map_err(Error::from)
161 } else {
162 let local_var_entity: Option<ListVolumesError> = crate::from_str_patched(&local_var_content).ok();
163 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
164 Err(Error::ResponseError(local_var_error))
165 }
166}
167