1use 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 AdminS3GetS3Error {
22 Status400(models::PbsError),
23 Status401(models::PbsError),
24 Status403(models::PbsError),
25 Status404(models::PbsError),
26 Status500(models::PbsError),
27 Status501(models::PbsError),
28 Status503(models::PbsError),
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum AdminS3UpdateCheckError {
36 Status400(models::PbsError),
37 Status401(models::PbsError),
38 Status403(models::PbsError),
39 Status404(models::PbsError),
40 Status500(models::PbsError),
41 Status501(models::PbsError),
42 Status503(models::PbsError),
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum AdminS3UpdateResetCountersError {
50 Status400(models::PbsError),
51 Status401(models::PbsError),
52 Status403(models::PbsError),
53 Status404(models::PbsError),
54 Status500(models::PbsError),
55 Status501(models::PbsError),
56 Status503(models::PbsError),
57 UnknownValue(serde_json::Value),
58}
59
60
61pub async fn admin_s3_get_s3(configuration: &configuration::Configuration, s3_endpoint_id: &str) -> Result<models::AdminS3GetS3Response, Error<AdminS3GetS3Error>> {
63 let p_path_s3_endpoint_id = s3_endpoint_id;
65
66 let uri_str = format!("{}/admin/s3/{s3_endpoint_id}", configuration.base_path, s3_endpoint_id=crate::apis::urlencode(p_path_s3_endpoint_id));
67 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
68
69 if let Some(ref user_agent) = configuration.user_agent {
70 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
71 }
72 if let Some(ref apikey) = configuration.api_key {
73 let key = apikey.key.clone();
74 let value = match apikey.prefix {
75 Some(ref prefix) => format!("{} {}", prefix, key),
76 None => key,
77 };
78 req_builder = req_builder.header("Authorization", value);
79 };
80 if let Some(ref apikey) = configuration.api_key {
81 let key = apikey.key.clone();
82 let value = match apikey.prefix {
83 Some(ref prefix) => format!("{} {}", prefix, key),
84 None => key,
85 };
86 req_builder = req_builder.header("CSRFPreventionToken", value);
87 };
88
89 let req = req_builder.build()?;
90 let resp = configuration.client.execute(req).await?;
91
92 let status = resp.status();
93 let content_type = resp
94 .headers()
95 .get("content-type")
96 .and_then(|v| v.to_str().ok())
97 .unwrap_or("application/octet-stream");
98 let content_type = super::ContentType::from(content_type);
99
100 if !status.is_client_error() && !status.is_server_error() {
101 let content = resp.text().await?;
102 match content_type {
103 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
104 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AdminS3GetS3Response`"))),
105 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::AdminS3GetS3Response`")))),
106 }
107 } else {
108 let content = resp.text().await?;
109 let entity: Option<AdminS3GetS3Error> = serde_json::from_str(&content).ok();
110 Err(Error::ResponseError(ResponseContent { status, content, entity }))
111 }
112}
113
114pub async fn admin_s3_update_check(configuration: &configuration::Configuration, s3_endpoint_id: &str, admin_s3_update_check_request: models::AdminS3UpdateCheckRequest) -> Result<models::AdminS3UpdateCheckResponse, Error<AdminS3UpdateCheckError>> {
116 let p_path_s3_endpoint_id = s3_endpoint_id;
118 let p_body_admin_s3_update_check_request = admin_s3_update_check_request;
119
120 let uri_str = format!("{}/admin/s3/{s3_endpoint_id}/check", configuration.base_path, s3_endpoint_id=crate::apis::urlencode(p_path_s3_endpoint_id));
121 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
122
123 if let Some(ref user_agent) = configuration.user_agent {
124 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
125 }
126 if let Some(ref apikey) = configuration.api_key {
127 let key = apikey.key.clone();
128 let value = match apikey.prefix {
129 Some(ref prefix) => format!("{} {}", prefix, key),
130 None => key,
131 };
132 req_builder = req_builder.header("Authorization", value);
133 };
134 if let Some(ref apikey) = configuration.api_key {
135 let key = apikey.key.clone();
136 let value = match apikey.prefix {
137 Some(ref prefix) => format!("{} {}", prefix, key),
138 None => key,
139 };
140 req_builder = req_builder.header("CSRFPreventionToken", value);
141 };
142 req_builder = req_builder.json(&p_body_admin_s3_update_check_request);
143
144 let req = req_builder.build()?;
145 let resp = configuration.client.execute(req).await?;
146
147 let status = resp.status();
148 let content_type = resp
149 .headers()
150 .get("content-type")
151 .and_then(|v| v.to_str().ok())
152 .unwrap_or("application/octet-stream");
153 let content_type = super::ContentType::from(content_type);
154
155 if !status.is_client_error() && !status.is_server_error() {
156 let content = resp.text().await?;
157 match content_type {
158 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
159 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AdminS3UpdateCheckResponse`"))),
160 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::AdminS3UpdateCheckResponse`")))),
161 }
162 } else {
163 let content = resp.text().await?;
164 let entity: Option<AdminS3UpdateCheckError> = serde_json::from_str(&content).ok();
165 Err(Error::ResponseError(ResponseContent { status, content, entity }))
166 }
167}
168
169pub async fn admin_s3_update_reset_counters(configuration: &configuration::Configuration, s3_endpoint_id: &str, admin_s3_update_check_request: models::AdminS3UpdateCheckRequest) -> Result<models::AdminS3UpdateResetCountersResponse, Error<AdminS3UpdateResetCountersError>> {
171 let p_path_s3_endpoint_id = s3_endpoint_id;
173 let p_body_admin_s3_update_check_request = admin_s3_update_check_request;
174
175 let uri_str = format!("{}/admin/s3/{s3_endpoint_id}/reset-counters", configuration.base_path, s3_endpoint_id=crate::apis::urlencode(p_path_s3_endpoint_id));
176 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
177
178 if let Some(ref user_agent) = configuration.user_agent {
179 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
180 }
181 if let Some(ref apikey) = configuration.api_key {
182 let key = apikey.key.clone();
183 let value = match apikey.prefix {
184 Some(ref prefix) => format!("{} {}", prefix, key),
185 None => key,
186 };
187 req_builder = req_builder.header("Authorization", value);
188 };
189 if let Some(ref apikey) = configuration.api_key {
190 let key = apikey.key.clone();
191 let value = match apikey.prefix {
192 Some(ref prefix) => format!("{} {}", prefix, key),
193 None => key,
194 };
195 req_builder = req_builder.header("CSRFPreventionToken", value);
196 };
197 req_builder = req_builder.json(&p_body_admin_s3_update_check_request);
198
199 let req = req_builder.build()?;
200 let resp = configuration.client.execute(req).await?;
201
202 let status = resp.status();
203 let content_type = resp
204 .headers()
205 .get("content-type")
206 .and_then(|v| v.to_str().ok())
207 .unwrap_or("application/octet-stream");
208 let content_type = super::ContentType::from(content_type);
209
210 if !status.is_client_error() && !status.is_server_error() {
211 let content = resp.text().await?;
212 match content_type {
213 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
214 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AdminS3UpdateResetCountersResponse`"))),
215 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::AdminS3UpdateResetCountersResponse`")))),
216 }
217 } else {
218 let content = resp.text().await?;
219 let entity: Option<AdminS3UpdateResetCountersError> = serde_json::from_str(&content).ok();
220 Err(Error::ResponseError(ResponseContent { status, content, entity }))
221 }
222}
223