Skip to main content

hanzo_client/apis/
tasks_api.rs

1/*
2 * Hanzo Cloud API
3 *
4 * The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
5 *
6 * The version of the OpenAPI document: v1
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`delete_tasks`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteTasksError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`get_tasks`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetTasksError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`patch_tasks`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum PatchTasksError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`post_tasks`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum PostTasksError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`put_tasks`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum PutTasksError {
50    UnknownValue(serde_json::Value),
51}
52
53
54/// Answers 307 with Location /v1/tasks/ — this address serves nothing itself. The status and the Location are the same on every method; a GET additionally carries the short HTML body a browser falls back to when it does not follow the redirect itself.  A 307 preserves both the method and the body, so a client that follows redirects re-sends the request unchanged to /v1/tasks/ and nothing is lost. A client that does NOT follow redirects sees only the 307 and performs no work — address /v1/tasks/ directly and the hop disappears.
55pub async fn delete_tasks(configuration: &configuration::Configuration, ) -> Result<(), Error<DeleteTasksError>> {
56
57    let uri_str = format!("{}/v1/tasks", configuration.base_path);
58    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
59
60    if let Some(ref user_agent) = configuration.user_agent {
61        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
62    }
63    if let Some(ref token) = configuration.bearer_access_token {
64        req_builder = req_builder.bearer_auth(token.to_owned());
65    };
66
67    let req = req_builder.build()?;
68    let resp = configuration.client.execute(req).await?;
69
70    let status = resp.status();
71
72    if !status.is_client_error() && !status.is_server_error() {
73        Ok(())
74    } else {
75        let content = resp.text().await?;
76        let entity: Option<DeleteTasksError> = serde_json::from_str(&content).ok();
77        Err(Error::ResponseError(ResponseContent { status, content, entity }))
78    }
79}
80
81/// Answers 307 with Location /v1/tasks/ — this address serves nothing itself. The status and the Location are the same on every method; a GET additionally carries the short HTML body a browser falls back to when it does not follow the redirect itself.  A 307 preserves both the method and the body, so a client that follows redirects re-sends the request unchanged to /v1/tasks/ and nothing is lost. A client that does NOT follow redirects sees only the 307 and performs no work — address /v1/tasks/ directly and the hop disappears.
82pub async fn get_tasks(configuration: &configuration::Configuration, ) -> Result<(), Error<GetTasksError>> {
83
84    let uri_str = format!("{}/v1/tasks", configuration.base_path);
85    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
86
87    if let Some(ref user_agent) = configuration.user_agent {
88        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
89    }
90    if let Some(ref token) = configuration.bearer_access_token {
91        req_builder = req_builder.bearer_auth(token.to_owned());
92    };
93
94    let req = req_builder.build()?;
95    let resp = configuration.client.execute(req).await?;
96
97    let status = resp.status();
98
99    if !status.is_client_error() && !status.is_server_error() {
100        Ok(())
101    } else {
102        let content = resp.text().await?;
103        let entity: Option<GetTasksError> = serde_json::from_str(&content).ok();
104        Err(Error::ResponseError(ResponseContent { status, content, entity }))
105    }
106}
107
108/// Answers 307 with Location /v1/tasks/ — this address serves nothing itself. The status and the Location are the same on every method; a GET additionally carries the short HTML body a browser falls back to when it does not follow the redirect itself.  A 307 preserves both the method and the body, so a client that follows redirects re-sends the request unchanged to /v1/tasks/ and nothing is lost. A client that does NOT follow redirects sees only the 307 and performs no work — address /v1/tasks/ directly and the hop disappears.
109pub async fn patch_tasks(configuration: &configuration::Configuration, ) -> Result<(), Error<PatchTasksError>> {
110
111    let uri_str = format!("{}/v1/tasks", configuration.base_path);
112    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
113
114    if let Some(ref user_agent) = configuration.user_agent {
115        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
116    }
117    if let Some(ref token) = configuration.bearer_access_token {
118        req_builder = req_builder.bearer_auth(token.to_owned());
119    };
120
121    let req = req_builder.build()?;
122    let resp = configuration.client.execute(req).await?;
123
124    let status = resp.status();
125
126    if !status.is_client_error() && !status.is_server_error() {
127        Ok(())
128    } else {
129        let content = resp.text().await?;
130        let entity: Option<PatchTasksError> = serde_json::from_str(&content).ok();
131        Err(Error::ResponseError(ResponseContent { status, content, entity }))
132    }
133}
134
135/// Answers 307 with Location /v1/tasks/ — this address serves nothing itself. The status and the Location are the same on every method; a GET additionally carries the short HTML body a browser falls back to when it does not follow the redirect itself.  A 307 preserves both the method and the body, so a client that follows redirects re-sends the request unchanged to /v1/tasks/ and nothing is lost. A client that does NOT follow redirects sees only the 307 and performs no work — address /v1/tasks/ directly and the hop disappears.
136pub async fn post_tasks(configuration: &configuration::Configuration, ) -> Result<(), Error<PostTasksError>> {
137
138    let uri_str = format!("{}/v1/tasks", configuration.base_path);
139    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
140
141    if let Some(ref user_agent) = configuration.user_agent {
142        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
143    }
144    if let Some(ref token) = configuration.bearer_access_token {
145        req_builder = req_builder.bearer_auth(token.to_owned());
146    };
147
148    let req = req_builder.build()?;
149    let resp = configuration.client.execute(req).await?;
150
151    let status = resp.status();
152
153    if !status.is_client_error() && !status.is_server_error() {
154        Ok(())
155    } else {
156        let content = resp.text().await?;
157        let entity: Option<PostTasksError> = serde_json::from_str(&content).ok();
158        Err(Error::ResponseError(ResponseContent { status, content, entity }))
159    }
160}
161
162/// Answers 307 with Location /v1/tasks/ — this address serves nothing itself. The status and the Location are the same on every method; a GET additionally carries the short HTML body a browser falls back to when it does not follow the redirect itself.  A 307 preserves both the method and the body, so a client that follows redirects re-sends the request unchanged to /v1/tasks/ and nothing is lost. A client that does NOT follow redirects sees only the 307 and performs no work — address /v1/tasks/ directly and the hop disappears.
163pub async fn put_tasks(configuration: &configuration::Configuration, ) -> Result<(), Error<PutTasksError>> {
164
165    let uri_str = format!("{}/v1/tasks", configuration.base_path);
166    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
167
168    if let Some(ref user_agent) = configuration.user_agent {
169        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
170    }
171    if let Some(ref token) = configuration.bearer_access_token {
172        req_builder = req_builder.bearer_auth(token.to_owned());
173    };
174
175    let req = req_builder.build()?;
176    let resp = configuration.client.execute(req).await?;
177
178    let status = resp.status();
179
180    if !status.is_client_error() && !status.is_server_error() {
181        Ok(())
182    } else {
183        let content = resp.text().await?;
184        let entity: Option<PutTasksError> = serde_json::from_str(&content).ok();
185        Err(Error::ResponseError(ResponseContent { status, content, entity }))
186    }
187}
188