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 DeleteSyncByIdError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetSyncError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetSyncByIdError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum PatchSyncByIdError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum PostSyncError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum PostSyncByIdRunError {
57 UnknownValue(serde_json::Value),
58}
59
60
61pub async fn delete_sync_by_id(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteSyncByIdError>> {
63 let p_id = id;
65
66 let uri_str = format!("{}/v1/sync/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
67 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &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 token) = configuration.bearer_access_token {
73 req_builder = req_builder.bearer_auth(token.to_owned());
74 };
75
76 let req = req_builder.build()?;
77 let resp = configuration.client.execute(req).await?;
78
79 let status = resp.status();
80
81 if !status.is_client_error() && !status.is_server_error() {
82 Ok(())
83 } else {
84 let content = resp.text().await?;
85 let entity: Option<DeleteSyncByIdError> = serde_json::from_str(&content).ok();
86 Err(Error::ResponseError(ResponseContent { status, content, entity }))
87 }
88}
89
90pub async fn get_sync(configuration: &configuration::Configuration, ) -> Result<models::SyncList, Error<GetSyncError>> {
92
93 let uri_str = format!("{}/v1/sync", configuration.base_path);
94 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
95
96 if let Some(ref user_agent) = configuration.user_agent {
97 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
98 }
99 if let Some(ref token) = configuration.bearer_access_token {
100 req_builder = req_builder.bearer_auth(token.to_owned());
101 };
102
103 let req = req_builder.build()?;
104 let resp = configuration.client.execute(req).await?;
105
106 let status = resp.status();
107 let content_type = resp
108 .headers()
109 .get("content-type")
110 .and_then(|v| v.to_str().ok())
111 .unwrap_or("application/octet-stream");
112 let content_type = super::ContentType::from(content_type);
113
114 if !status.is_client_error() && !status.is_server_error() {
115 let content = resp.text().await?;
116 match content_type {
117 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
118 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SyncList`"))),
119 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::SyncList`")))),
120 }
121 } else {
122 let content = resp.text().await?;
123 let entity: Option<GetSyncError> = serde_json::from_str(&content).ok();
124 Err(Error::ResponseError(ResponseContent { status, content, entity }))
125 }
126}
127
128pub async fn get_sync_by_id(configuration: &configuration::Configuration, id: &str) -> Result<models::SyncView, Error<GetSyncByIdError>> {
130 let p_id = id;
132
133 let uri_str = format!("{}/v1/sync/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
134 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
135
136 if let Some(ref user_agent) = configuration.user_agent {
137 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
138 }
139 if let Some(ref token) = configuration.bearer_access_token {
140 req_builder = req_builder.bearer_auth(token.to_owned());
141 };
142
143 let req = req_builder.build()?;
144 let resp = configuration.client.execute(req).await?;
145
146 let status = resp.status();
147 let content_type = resp
148 .headers()
149 .get("content-type")
150 .and_then(|v| v.to_str().ok())
151 .unwrap_or("application/octet-stream");
152 let content_type = super::ContentType::from(content_type);
153
154 if !status.is_client_error() && !status.is_server_error() {
155 let content = resp.text().await?;
156 match content_type {
157 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
158 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SyncView`"))),
159 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::SyncView`")))),
160 }
161 } else {
162 let content = resp.text().await?;
163 let entity: Option<GetSyncByIdError> = serde_json::from_str(&content).ok();
164 Err(Error::ResponseError(ResponseContent { status, content, entity }))
165 }
166}
167
168pub async fn patch_sync_by_id(configuration: &configuration::Configuration, id: &str, patch_sync_in: models::PatchSyncIn) -> Result<models::SyncView, Error<PatchSyncByIdError>> {
170 let p_id = id;
172 let p_patch_sync_in = patch_sync_in;
173
174 let uri_str = format!("{}/v1/sync/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
175 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
176
177 if let Some(ref user_agent) = configuration.user_agent {
178 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
179 }
180 if let Some(ref token) = configuration.bearer_access_token {
181 req_builder = req_builder.bearer_auth(token.to_owned());
182 };
183 req_builder = req_builder.json(&p_patch_sync_in);
184
185 let req = req_builder.build()?;
186 let resp = configuration.client.execute(req).await?;
187
188 let status = resp.status();
189 let content_type = resp
190 .headers()
191 .get("content-type")
192 .and_then(|v| v.to_str().ok())
193 .unwrap_or("application/octet-stream");
194 let content_type = super::ContentType::from(content_type);
195
196 if !status.is_client_error() && !status.is_server_error() {
197 let content = resp.text().await?;
198 match content_type {
199 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
200 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SyncView`"))),
201 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::SyncView`")))),
202 }
203 } else {
204 let content = resp.text().await?;
205 let entity: Option<PatchSyncByIdError> = serde_json::from_str(&content).ok();
206 Err(Error::ResponseError(ResponseContent { status, content, entity }))
207 }
208}
209
210pub async fn post_sync(configuration: &configuration::Configuration, sync_req: models::SyncReq) -> Result<models::SyncView, Error<PostSyncError>> {
212 let p_sync_req = sync_req;
214
215 let uri_str = format!("{}/v1/sync", configuration.base_path);
216 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
217
218 if let Some(ref user_agent) = configuration.user_agent {
219 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
220 }
221 if let Some(ref token) = configuration.bearer_access_token {
222 req_builder = req_builder.bearer_auth(token.to_owned());
223 };
224 req_builder = req_builder.json(&p_sync_req);
225
226 let req = req_builder.build()?;
227 let resp = configuration.client.execute(req).await?;
228
229 let status = resp.status();
230 let content_type = resp
231 .headers()
232 .get("content-type")
233 .and_then(|v| v.to_str().ok())
234 .unwrap_or("application/octet-stream");
235 let content_type = super::ContentType::from(content_type);
236
237 if !status.is_client_error() && !status.is_server_error() {
238 let content = resp.text().await?;
239 match content_type {
240 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
241 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SyncView`"))),
242 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::SyncView`")))),
243 }
244 } else {
245 let content = resp.text().await?;
246 let entity: Option<PostSyncError> = serde_json::from_str(&content).ok();
247 Err(Error::ResponseError(ResponseContent { status, content, entity }))
248 }
249}
250
251pub async fn post_sync_by_id_run(configuration: &configuration::Configuration, id: &str) -> Result<models::SyncQueued, Error<PostSyncByIdRunError>> {
253 let p_id = id;
255
256 let uri_str = format!("{}/v1/sync/{id}/run", configuration.base_path, id=crate::apis::urlencode(p_id));
257 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
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 token) = configuration.bearer_access_token {
263 req_builder = req_builder.bearer_auth(token.to_owned());
264 };
265
266 let req = req_builder.build()?;
267 let resp = configuration.client.execute(req).await?;
268
269 let status = resp.status();
270 let content_type = resp
271 .headers()
272 .get("content-type")
273 .and_then(|v| v.to_str().ok())
274 .unwrap_or("application/octet-stream");
275 let content_type = super::ContentType::from(content_type);
276
277 if !status.is_client_error() && !status.is_server_error() {
278 let content = resp.text().await?;
279 match content_type {
280 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
281 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SyncQueued`"))),
282 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::SyncQueued`")))),
283 }
284 } else {
285 let content = resp.text().await?;
286 let entity: Option<PostSyncByIdRunError> = serde_json::from_str(&content).ok();
287 Err(Error::ResponseError(ResponseContent { status, content, entity }))
288 }
289}
290