1use reqwest;
12use serde::{de::Error as _, Deserialize, Serialize};
13
14use super::{configuration, ContentType, Error};
15use crate::{apis::ResponseContent, models};
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum DeleteUploadError {
21 Status400(models::JsonErrorResponseNull),
22 Status401(models::JsonErrorResponseNull),
23 Status403(models::JsonErrorResponseNull),
24 Status404(models::JsonErrorResponseNull),
25 Status409(models::JsonErrorResponseNull),
26 Status429(models::JsonErrorResponseNull),
27 Status500(models::JsonErrorResponseNull),
28 UnknownValue(serde_json::Value),
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum GetAssetsError {
35 Status400(models::JsonErrorResponseNull),
36 Status401(models::JsonErrorResponseNull),
37 Status403(models::JsonErrorResponseNull),
38 Status404(models::JsonErrorResponseNull),
39 Status409(models::JsonErrorResponseNull),
40 Status429(models::JsonErrorResponseNull),
41 Status500(models::JsonErrorResponseNull),
42 UnknownValue(serde_json::Value),
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum GetDownloadError {
49 Status400(models::JsonErrorResponseNull),
50 Status401(models::JsonErrorResponseNull),
51 Status403(models::JsonErrorResponseNull),
52 Status404(models::JsonErrorResponseNull),
53 Status409(models::JsonErrorResponseNull),
54 Status429(models::JsonErrorResponseNull),
55 Status500(models::JsonErrorResponseNull),
56 UnknownValue(serde_json::Value),
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(untagged)]
62pub enum GetRestoreError {
63 Status400(models::JsonErrorResponseNull),
64 Status401(models::JsonErrorResponseNull),
65 Status403(models::JsonErrorResponseNull),
66 Status404(models::JsonErrorResponseNull),
67 Status409(models::JsonErrorResponseNull),
68 Status429(models::JsonErrorResponseNull),
69 Status500(models::JsonErrorResponseNull),
70 UnknownValue(serde_json::Value),
71}
72
73#[derive(Debug, Clone, Serialize, Deserialize)]
75#[serde(untagged)]
76pub enum HeadOffsetError {
77 Status400(models::JsonErrorResponseNull),
78 Status401(models::JsonErrorResponseNull),
79 Status403(models::JsonErrorResponseNull),
80 Status404(models::JsonErrorResponseNull),
81 Status409(models::JsonErrorResponseNull),
82 Status429(models::JsonErrorResponseNull),
83 Status500(models::JsonErrorResponseNull),
84 UnknownValue(serde_json::Value),
85}
86
87#[derive(Debug, Clone, Serialize, Deserialize)]
89#[serde(untagged)]
90pub enum PatchChunksError {
91 Status400(models::JsonErrorResponseNull),
92 Status401(models::JsonErrorResponseNull),
93 Status403(models::JsonErrorResponseNull),
94 Status404(models::JsonErrorResponseNull),
95 Status409(models::JsonErrorResponseNull),
96 Status429(models::JsonErrorResponseNull),
97 Status500(models::JsonErrorResponseNull),
98 UnknownValue(serde_json::Value),
99}
100
101#[derive(Debug, Clone, Serialize, Deserialize)]
103#[serde(untagged)]
104pub enum PostUploadError {
105 Status400(models::JsonErrorResponseNull),
106 Status401(models::JsonErrorResponseNull),
107 Status403(models::JsonErrorResponseNull),
108 Status404(models::JsonErrorResponseNull),
109 Status409(models::JsonErrorResponseNull),
110 Status429(models::JsonErrorResponseNull),
111 Status500(models::JsonErrorResponseNull),
112 UnknownValue(serde_json::Value),
113}
114
115pub async fn delete_upload(
116 configuration: &configuration::Configuration,
117 repo_ref: &str,
118 tag_ref: &str,
119) -> Result<(), Error<DeleteUploadError>> {
120 let p_path_repo_ref = repo_ref;
122 let p_path_tag_ref = tag_ref;
123
124 let uri_str = format!(
125 "{}/repos/{repo_ref}/+/uploads/releases/{tag_ref}",
126 configuration.base_path,
127 repo_ref = crate::apis::urlencode(p_path_repo_ref),
128 tag_ref = crate::apis::urlencode(p_path_tag_ref)
129 );
130 let mut req_builder = configuration
131 .client
132 .request(reqwest::Method::DELETE, &uri_str);
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.query(&[("access_token", value)]);
141 }
142 if let Some(ref user_agent) = configuration.user_agent {
143 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
144 }
145 if let Some(ref auth_conf) = configuration.basic_auth {
146 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
147 };
148 if let Some(ref token) = configuration.bearer_access_token {
149 req_builder = req_builder.bearer_auth(token.to_owned());
150 };
151
152 let req = req_builder.build()?;
153 let resp = configuration.client.execute(req).await?;
154
155 let status = resp.status();
156
157 if !status.is_client_error() && !status.is_server_error() {
158 Ok(())
159 } else {
160 let content = resp.text().await?;
161 let entity: Option<DeleteUploadError> = serde_json::from_str(&content).ok();
162 Err(Error::ResponseError(ResponseContent {
163 status,
164 content,
165 entity,
166 }))
167 }
168}
169
170pub async fn get_assets(
171 configuration: &configuration::Configuration,
172 repo_ref: &str,
173 tag_ref: &str,
174) -> Result<Vec<String>, Error<GetAssetsError>> {
175 let p_path_repo_ref = repo_ref;
177 let p_path_tag_ref = tag_ref;
178
179 let uri_str = format!(
180 "{}/repos/{repo_ref}/+/uploads/releases/assets/{tag_ref}",
181 configuration.base_path,
182 repo_ref = crate::apis::urlencode(p_path_repo_ref),
183 tag_ref = crate::apis::urlencode(p_path_tag_ref)
184 );
185 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
186
187 if let Some(ref apikey) = configuration.api_key {
188 let key = apikey.key.clone();
189 let value = match apikey.prefix {
190 Some(ref prefix) => format!("{} {}", prefix, key),
191 None => key,
192 };
193 req_builder = req_builder.query(&[("access_token", value)]);
194 }
195 if let Some(ref user_agent) = configuration.user_agent {
196 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
197 }
198 if let Some(ref auth_conf) = configuration.basic_auth {
199 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
200 };
201 if let Some(ref token) = configuration.bearer_access_token {
202 req_builder = req_builder.bearer_auth(token.to_owned());
203 };
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 => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<String>`"))),
221 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<String>`")))),
222 }
223 } else {
224 let content = resp.text().await?;
225 let entity: Option<GetAssetsError> = serde_json::from_str(&content).ok();
226 Err(Error::ResponseError(ResponseContent {
227 status,
228 content,
229 entity,
230 }))
231 }
232}
233
234pub async fn get_download(
235 configuration: &configuration::Configuration,
236 repo_ref: &str,
237 tag_ref: &str,
238) -> Result<Vec<i32>, Error<GetDownloadError>> {
239 let p_path_repo_ref = repo_ref;
241 let p_path_tag_ref = tag_ref;
242
243 let uri_str = format!(
244 "{}/repos/{repo_ref}/+/uploads/download/{tag_ref}",
245 configuration.base_path,
246 repo_ref = crate::apis::urlencode(p_path_repo_ref),
247 tag_ref = crate::apis::urlencode(p_path_tag_ref)
248 );
249 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
250
251 if let Some(ref apikey) = configuration.api_key {
252 let key = apikey.key.clone();
253 let value = match apikey.prefix {
254 Some(ref prefix) => format!("{} {}", prefix, key),
255 None => key,
256 };
257 req_builder = req_builder.query(&[("access_token", value)]);
258 }
259 if let Some(ref user_agent) = configuration.user_agent {
260 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
261 }
262 if let Some(ref auth_conf) = configuration.basic_auth {
263 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
264 };
265 if let Some(ref token) = configuration.bearer_access_token {
266 req_builder = req_builder.bearer_auth(token.to_owned());
267 };
268
269 let req = req_builder.build()?;
270 let resp = configuration.client.execute(req).await?;
271
272 let status = resp.status();
273 let content_type = resp
274 .headers()
275 .get("content-type")
276 .and_then(|v| v.to_str().ok())
277 .unwrap_or("application/octet-stream");
278 let content_type = super::ContentType::from(content_type);
279
280 if !status.is_client_error() && !status.is_server_error() {
281 let content = resp.text().await?;
282 match content_type {
283 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
284 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<i32>`"))),
285 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<i32>`")))),
286 }
287 } else {
288 let content = resp.text().await?;
289 let entity: Option<GetDownloadError> = serde_json::from_str(&content).ok();
290 Err(Error::ResponseError(ResponseContent {
291 status,
292 content,
293 entity,
294 }))
295 }
296}
297
298pub async fn get_restore(
299 configuration: &configuration::Configuration,
300 repo_ref: &str,
301 tag_ref: &str,
302) -> Result<Vec<i32>, Error<GetRestoreError>> {
303 let p_path_repo_ref = repo_ref;
305 let p_path_tag_ref = tag_ref;
306
307 let uri_str = format!(
308 "{}/repos/{repo_ref}/+/uploads/releases/{tag_ref}",
309 configuration.base_path,
310 repo_ref = crate::apis::urlencode(p_path_repo_ref),
311 tag_ref = crate::apis::urlencode(p_path_tag_ref)
312 );
313 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
314
315 if let Some(ref apikey) = configuration.api_key {
316 let key = apikey.key.clone();
317 let value = match apikey.prefix {
318 Some(ref prefix) => format!("{} {}", prefix, key),
319 None => key,
320 };
321 req_builder = req_builder.query(&[("access_token", value)]);
322 }
323 if let Some(ref user_agent) = configuration.user_agent {
324 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
325 }
326 if let Some(ref auth_conf) = configuration.basic_auth {
327 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
328 };
329 if let Some(ref token) = configuration.bearer_access_token {
330 req_builder = req_builder.bearer_auth(token.to_owned());
331 };
332
333 let req = req_builder.build()?;
334 let resp = configuration.client.execute(req).await?;
335
336 let status = resp.status();
337 let content_type = resp
338 .headers()
339 .get("content-type")
340 .and_then(|v| v.to_str().ok())
341 .unwrap_or("application/octet-stream");
342 let content_type = super::ContentType::from(content_type);
343
344 if !status.is_client_error() && !status.is_server_error() {
345 let content = resp.text().await?;
346 match content_type {
347 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
348 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<i32>`"))),
349 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<i32>`")))),
350 }
351 } else {
352 let content = resp.text().await?;
353 let entity: Option<GetRestoreError> = serde_json::from_str(&content).ok();
354 Err(Error::ResponseError(ResponseContent {
355 status,
356 content,
357 entity,
358 }))
359 }
360}
361
362pub async fn head_offset(
363 configuration: &configuration::Configuration,
364 repo_ref: &str,
365) -> Result<(), Error<HeadOffsetError>> {
366 let p_path_repo_ref = repo_ref;
368
369 let uri_str = format!(
370 "{}/repos/{repo_ref}/+/uploads/releases",
371 configuration.base_path,
372 repo_ref = crate::apis::urlencode(p_path_repo_ref)
373 );
374 let mut req_builder = configuration
375 .client
376 .request(reqwest::Method::HEAD, &uri_str);
377
378 if let Some(ref apikey) = configuration.api_key {
379 let key = apikey.key.clone();
380 let value = match apikey.prefix {
381 Some(ref prefix) => format!("{} {}", prefix, key),
382 None => key,
383 };
384 req_builder = req_builder.query(&[("access_token", value)]);
385 }
386 if let Some(ref user_agent) = configuration.user_agent {
387 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
388 }
389 if let Some(ref auth_conf) = configuration.basic_auth {
390 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
391 };
392 if let Some(ref token) = configuration.bearer_access_token {
393 req_builder = req_builder.bearer_auth(token.to_owned());
394 };
395
396 let req = req_builder.build()?;
397 let resp = configuration.client.execute(req).await?;
398
399 let status = resp.status();
400
401 if !status.is_client_error() && !status.is_server_error() {
402 Ok(())
403 } else {
404 let content = resp.text().await?;
405 let entity: Option<HeadOffsetError> = serde_json::from_str(&content).ok();
406 Err(Error::ResponseError(ResponseContent {
407 status,
408 content,
409 entity,
410 }))
411 }
412}
413
414pub async fn patch_chunks(
415 configuration: &configuration::Configuration,
416 repo_ref: &str,
417 tag_ref: &str,
418) -> Result<String, Error<PatchChunksError>> {
419 let p_path_repo_ref = repo_ref;
421 let p_path_tag_ref = tag_ref;
422
423 let uri_str = format!(
424 "{}/repos/{repo_ref}/+/uploads/releases/{tag_ref}",
425 configuration.base_path,
426 repo_ref = crate::apis::urlencode(p_path_repo_ref),
427 tag_ref = crate::apis::urlencode(p_path_tag_ref)
428 );
429 let mut req_builder = configuration
430 .client
431 .request(reqwest::Method::PATCH, &uri_str);
432
433 if let Some(ref apikey) = configuration.api_key {
434 let key = apikey.key.clone();
435 let value = match apikey.prefix {
436 Some(ref prefix) => format!("{} {}", prefix, key),
437 None => key,
438 };
439 req_builder = req_builder.query(&[("access_token", value)]);
440 }
441 if let Some(ref user_agent) = configuration.user_agent {
442 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
443 }
444 if let Some(ref auth_conf) = configuration.basic_auth {
445 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
446 };
447 if let Some(ref token) = configuration.bearer_access_token {
448 req_builder = req_builder.bearer_auth(token.to_owned());
449 };
450
451 let req = req_builder.build()?;
452 let resp = configuration.client.execute(req).await?;
453
454 let status = resp.status();
455 let content_type = resp
456 .headers()
457 .get("content-type")
458 .and_then(|v| v.to_str().ok())
459 .unwrap_or("application/octet-stream");
460 let content_type = super::ContentType::from(content_type);
461
462 if !status.is_client_error() && !status.is_server_error() {
463 let content = resp.text().await?;
464 match content_type {
465 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
466 ContentType::Text => Ok(content),
467 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
468 }
469 } else {
470 let content = resp.text().await?;
471 let entity: Option<PatchChunksError> = serde_json::from_str(&content).ok();
472 Err(Error::ResponseError(ResponseContent {
473 status,
474 content,
475 entity,
476 }))
477 }
478}
479
480pub async fn post_upload(
481 configuration: &configuration::Configuration,
482 repo_ref: &str,
483 tag_ref: &str,
484) -> Result<String, Error<PostUploadError>> {
485 let p_path_repo_ref = repo_ref;
487 let p_path_tag_ref = tag_ref;
488
489 let uri_str = format!(
490 "{}/repos/{repo_ref}/+/uploads/releases/{tag_ref}",
491 configuration.base_path,
492 repo_ref = crate::apis::urlencode(p_path_repo_ref),
493 tag_ref = crate::apis::urlencode(p_path_tag_ref)
494 );
495 let mut req_builder = configuration
496 .client
497 .request(reqwest::Method::POST, &uri_str);
498
499 if let Some(ref apikey) = configuration.api_key {
500 let key = apikey.key.clone();
501 let value = match apikey.prefix {
502 Some(ref prefix) => format!("{} {}", prefix, key),
503 None => key,
504 };
505 req_builder = req_builder.query(&[("access_token", value)]);
506 }
507 if let Some(ref user_agent) = configuration.user_agent {
508 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
509 }
510 if let Some(ref auth_conf) = configuration.basic_auth {
511 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
512 };
513 if let Some(ref token) = configuration.bearer_access_token {
514 req_builder = req_builder.bearer_auth(token.to_owned());
515 };
516
517 let req = req_builder.build()?;
518 let resp = configuration.client.execute(req).await?;
519
520 let status = resp.status();
521 let content_type = resp
522 .headers()
523 .get("content-type")
524 .and_then(|v| v.to_str().ok())
525 .unwrap_or("application/octet-stream");
526 let content_type = super::ContentType::from(content_type);
527
528 if !status.is_client_error() && !status.is_server_error() {
529 let content = resp.text().await?;
530 match content_type {
531 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
532 ContentType::Text => Ok(content),
533 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
534 }
535 } else {
536 let content = resp.text().await?;
537 let entity: Option<PostUploadError> = serde_json::from_str(&content).ok();
538 Err(Error::ResponseError(ResponseContent {
539 status,
540 content,
541 entity,
542 }))
543 }
544}