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 AddServerError {
22 Status403(models::UnauthorizedApiError),
23 Status404(models::NotFoundApiError),
24 DefaultResponse(models::ApiError),
25 UnknownValue(serde_json::Value),
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum CacheServerError {
32 Status403(models::UnauthorizedApiError),
33 Status404(models::NotFoundApiError),
34 DefaultResponse(models::ApiError),
35 UnknownValue(serde_json::Value),
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum CreateSyncError {
42 Status403(models::UnauthorizedApiError),
43 Status404(models::NotFoundApiError),
44 DefaultResponse(models::ApiError),
45 UnknownValue(serde_json::Value),
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum DeleteServerError {
52 Status403(models::UnauthorizedApiError),
53 Status404(models::NotFoundApiError),
54 DefaultResponse(models::ApiError),
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum EditServerError {
62 Status403(models::UnauthorizedApiError),
63 Status404(models::NotFoundApiError),
64 DefaultResponse(models::ApiError),
65 UnknownValue(serde_json::Value),
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum EditServerSettingError {
72 Status403(models::UnauthorizedApiError),
73 Status404(models::NotFoundApiError),
74 DefaultResponse(models::ApiError),
75 UnknownValue(serde_json::Value),
76}
77
78#[derive(Debug, Clone, Serialize, Deserialize)]
80#[serde(untagged)]
81pub enum GetPyMispVersionError {
82 Status403(models::UnauthorizedApiError),
83 Status404(models::NotFoundApiError),
84 DefaultResponse(models::ApiError),
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum GetServerSettingError {
92 Status403(models::UnauthorizedApiError),
93 Status404(models::NotFoundApiError),
94 DefaultResponse(models::ApiError),
95 UnknownValue(serde_json::Value),
96}
97
98#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum GetServerSettingsError {
102 Status403(models::UnauthorizedApiError),
103 Status404(models::NotFoundApiError),
104 DefaultResponse(models::ApiError),
105 UnknownValue(serde_json::Value),
106}
107
108#[derive(Debug, Clone, Serialize, Deserialize)]
110#[serde(untagged)]
111pub enum GetServerUuidError {
112 Status403(models::UnauthorizedApiError),
113 Status404(models::NotFoundApiError),
114 DefaultResponse(models::ApiError),
115 UnknownValue(serde_json::Value),
116}
117
118#[derive(Debug, Clone, Serialize, Deserialize)]
120#[serde(untagged)]
121pub enum GetServerVersionError {
122 Status403(models::UnauthorizedApiError),
123 Status404(models::NotFoundApiError),
124 DefaultResponse(models::ApiError),
125 UnknownValue(serde_json::Value),
126}
127
128#[derive(Debug, Clone, Serialize, Deserialize)]
130#[serde(untagged)]
131pub enum GetServersError {
132 Status403(models::UnauthorizedApiError),
133 Status404(models::NotFoundApiError),
134 DefaultResponse(models::ApiError),
135 UnknownValue(serde_json::Value),
136}
137
138#[derive(Debug, Clone, Serialize, Deserialize)]
140#[serde(untagged)]
141pub enum GetWorkersError {
142 Status403(models::UnauthorizedApiError),
143 Status404(models::NotFoundApiError),
144 DefaultResponse(models::ApiError),
145 UnknownValue(serde_json::Value),
146}
147
148#[derive(Debug, Clone, Serialize, Deserialize)]
150#[serde(untagged)]
151pub enum ImportServerError {
152 Status403(models::UnauthorizedApiError),
153 Status404(models::NotFoundApiError),
154 DefaultResponse(models::ApiError),
155 UnknownValue(serde_json::Value),
156}
157
158#[derive(Debug, Clone, Serialize, Deserialize)]
160#[serde(untagged)]
161pub enum KillAllWorkersError {
162 Status403(models::UnauthorizedApiError),
163 Status404(models::NotFoundApiError),
164 DefaultResponse(models::ApiError),
165 UnknownValue(serde_json::Value),
166}
167
168#[derive(Debug, Clone, Serialize, Deserialize)]
170#[serde(untagged)]
171pub enum PullServerError {
172 Status403(models::UnauthorizedApiError),
173 Status404(models::NotFoundApiError),
174 DefaultResponse(models::ApiError),
175 UnknownValue(serde_json::Value),
176}
177
178#[derive(Debug, Clone, Serialize, Deserialize)]
180#[serde(untagged)]
181pub enum PushServerError {
182 Status403(models::UnauthorizedApiError),
183 Status404(models::NotFoundApiError),
184 DefaultResponse(models::ApiError),
185 UnknownValue(serde_json::Value),
186}
187
188#[derive(Debug, Clone, Serialize, Deserialize)]
190#[serde(untagged)]
191pub enum RestartDeadWorkersError {
192 Status403(models::UnauthorizedApiError),
193 Status404(models::NotFoundApiError),
194 DefaultResponse(models::ApiError),
195 UnknownValue(serde_json::Value),
196}
197
198#[derive(Debug, Clone, Serialize, Deserialize)]
200#[serde(untagged)]
201pub enum RestartWorkersError {
202 Status403(models::UnauthorizedApiError),
203 Status404(models::NotFoundApiError),
204 DefaultResponse(models::ApiError),
205 UnknownValue(serde_json::Value),
206}
207
208#[derive(Debug, Clone, Serialize, Deserialize)]
210#[serde(untagged)]
211pub enum StartWorkerError {
212 Status403(models::UnauthorizedApiError),
213 Status404(models::NotFoundApiError),
214 DefaultResponse(models::ApiError),
215 UnknownValue(serde_json::Value),
216}
217
218#[derive(Debug, Clone, Serialize, Deserialize)]
220#[serde(untagged)]
221pub enum StopWorkerError {
222 Status403(models::UnauthorizedApiError),
223 Status404(models::NotFoundApiError),
224 DefaultResponse(models::ApiError),
225 UnknownValue(serde_json::Value),
226}
227
228#[derive(Debug, Clone, Serialize, Deserialize)]
230#[serde(untagged)]
231pub enum UpdateServerError {
232 Status403(models::UnauthorizedApiError),
233 Status404(models::NotFoundApiError),
234 DefaultResponse(models::ApiError),
235 UnknownValue(serde_json::Value),
236}
237
238
239pub async fn add_server(configuration: &configuration::Configuration, server_no_id: Option<models::ServerNoId>) -> Result<models::AddServer200Response, Error<AddServerError>> {
240 let p_server_no_id = server_no_id;
242
243 let uri_str = format!("{}/servers/add", configuration.base_path);
244 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
245
246 if let Some(ref user_agent) = configuration.user_agent {
247 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
248 }
249 if let Some(ref apikey) = configuration.api_key {
250 let key = apikey.key.clone();
251 let value = match apikey.prefix {
252 Some(ref prefix) => format!("{} {}", prefix, key),
253 None => key,
254 };
255 req_builder = req_builder.header("Authorization", value);
256 };
257 req_builder = req_builder.json(&p_server_no_id);
258
259 let req = req_builder.build()?;
260 let resp = configuration.client.execute(req).await?;
261
262 let status = resp.status();
263 let content_type = resp
264 .headers()
265 .get("content-type")
266 .and_then(|v| v.to_str().ok())
267 .unwrap_or("application/octet-stream");
268 let content_type = super::ContentType::from(content_type);
269
270 if !status.is_client_error() && !status.is_server_error() {
271 let content = resp.text().await?;
272 match content_type {
273 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
274 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AddServer200Response`"))),
275 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::AddServer200Response`")))),
276 }
277 } else {
278 let content = resp.text().await?;
279 let entity: Option<AddServerError> = serde_json::from_str(&content).ok();
280 Err(Error::ResponseError(ResponseContent { status, content, entity }))
281 }
282}
283
284pub async fn cache_server(configuration: &configuration::Configuration, ) -> Result<models::CacheServer200Response, Error<CacheServerError>> {
285
286 let uri_str = format!("{}/servers/cache", configuration.base_path);
287 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
288
289 if let Some(ref user_agent) = configuration.user_agent {
290 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
291 }
292 if let Some(ref apikey) = configuration.api_key {
293 let key = apikey.key.clone();
294 let value = match apikey.prefix {
295 Some(ref prefix) => format!("{} {}", prefix, key),
296 None => key,
297 };
298 req_builder = req_builder.header("Authorization", value);
299 };
300
301 let req = req_builder.build()?;
302 let resp = configuration.client.execute(req).await?;
303
304 let status = resp.status();
305 let content_type = resp
306 .headers()
307 .get("content-type")
308 .and_then(|v| v.to_str().ok())
309 .unwrap_or("application/octet-stream");
310 let content_type = super::ContentType::from(content_type);
311
312 if !status.is_client_error() && !status.is_server_error() {
313 let content = resp.text().await?;
314 match content_type {
315 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
316 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CacheServer200Response`"))),
317 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::CacheServer200Response`")))),
318 }
319 } else {
320 let content = resp.text().await?;
321 let entity: Option<CacheServerError> = serde_json::from_str(&content).ok();
322 Err(Error::ResponseError(ResponseContent { status, content, entity }))
323 }
324}
325
326pub async fn create_sync(configuration: &configuration::Configuration, ) -> Result<models::CreateSync200Response, Error<CreateSyncError>> {
327
328 let uri_str = format!("{}/servers/createSync", configuration.base_path);
329 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
330
331 if let Some(ref user_agent) = configuration.user_agent {
332 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
333 }
334 if let Some(ref apikey) = configuration.api_key {
335 let key = apikey.key.clone();
336 let value = match apikey.prefix {
337 Some(ref prefix) => format!("{} {}", prefix, key),
338 None => key,
339 };
340 req_builder = req_builder.header("Authorization", value);
341 };
342
343 let req = req_builder.build()?;
344 let resp = configuration.client.execute(req).await?;
345
346 let status = resp.status();
347 let content_type = resp
348 .headers()
349 .get("content-type")
350 .and_then(|v| v.to_str().ok())
351 .unwrap_or("application/octet-stream");
352 let content_type = super::ContentType::from(content_type);
353
354 if !status.is_client_error() && !status.is_server_error() {
355 let content = resp.text().await?;
356 match content_type {
357 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
358 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateSync200Response`"))),
359 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::CreateSync200Response`")))),
360 }
361 } else {
362 let content = resp.text().await?;
363 let entity: Option<CreateSyncError> = serde_json::from_str(&content).ok();
364 Err(Error::ResponseError(ResponseContent { status, content, entity }))
365 }
366}
367
368pub async fn delete_server(configuration: &configuration::Configuration, server_id: &str) -> Result<models::DeleteServer200Response, Error<DeleteServerError>> {
369 let p_server_id = server_id;
371
372 let uri_str = format!("{}/servers/delete/{serverId}", configuration.base_path, serverId=p_server_id.to_string());
373 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
374
375 if let Some(ref user_agent) = configuration.user_agent {
376 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
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.header("Authorization", value);
385 };
386
387 let req = req_builder.build()?;
388 let resp = configuration.client.execute(req).await?;
389
390 let status = resp.status();
391 let content_type = resp
392 .headers()
393 .get("content-type")
394 .and_then(|v| v.to_str().ok())
395 .unwrap_or("application/octet-stream");
396 let content_type = super::ContentType::from(content_type);
397
398 if !status.is_client_error() && !status.is_server_error() {
399 let content = resp.text().await?;
400 match content_type {
401 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
402 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteServer200Response`"))),
403 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::DeleteServer200Response`")))),
404 }
405 } else {
406 let content = resp.text().await?;
407 let entity: Option<DeleteServerError> = serde_json::from_str(&content).ok();
408 Err(Error::ResponseError(ResponseContent { status, content, entity }))
409 }
410}
411
412pub async fn edit_server(configuration: &configuration::Configuration, server_id: &str, server: Option<models::Server>) -> Result<models::AddServer200Response, Error<EditServerError>> {
413 let p_server_id = server_id;
415 let p_server = server;
416
417 let uri_str = format!("{}/servers/edit/{serverId}", configuration.base_path, serverId=p_server_id.to_string());
418 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
419
420 if let Some(ref user_agent) = configuration.user_agent {
421 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
422 }
423 if let Some(ref apikey) = configuration.api_key {
424 let key = apikey.key.clone();
425 let value = match apikey.prefix {
426 Some(ref prefix) => format!("{} {}", prefix, key),
427 None => key,
428 };
429 req_builder = req_builder.header("Authorization", value);
430 };
431 req_builder = req_builder.json(&p_server);
432
433 let req = req_builder.build()?;
434 let resp = configuration.client.execute(req).await?;
435
436 let status = resp.status();
437 let content_type = resp
438 .headers()
439 .get("content-type")
440 .and_then(|v| v.to_str().ok())
441 .unwrap_or("application/octet-stream");
442 let content_type = super::ContentType::from(content_type);
443
444 if !status.is_client_error() && !status.is_server_error() {
445 let content = resp.text().await?;
446 match content_type {
447 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
448 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AddServer200Response`"))),
449 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::AddServer200Response`")))),
450 }
451 } else {
452 let content = resp.text().await?;
453 let entity: Option<EditServerError> = serde_json::from_str(&content).ok();
454 Err(Error::ResponseError(ResponseContent { status, content, entity }))
455 }
456}
457
458pub async fn edit_server_setting(configuration: &configuration::Configuration, setting_name: &str, edit_server_setting_request: Option<models::EditServerSettingRequest>) -> Result<models::EditServerSetting200Response, Error<EditServerSettingError>> {
459 let p_setting_name = setting_name;
461 let p_edit_server_setting_request = edit_server_setting_request;
462
463 let uri_str = format!("{}/servers/serverSettingsEdit/{settingName}", configuration.base_path, settingName=crate::apis::urlencode(p_setting_name));
464 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
465
466 if let Some(ref user_agent) = configuration.user_agent {
467 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
468 }
469 if let Some(ref apikey) = configuration.api_key {
470 let key = apikey.key.clone();
471 let value = match apikey.prefix {
472 Some(ref prefix) => format!("{} {}", prefix, key),
473 None => key,
474 };
475 req_builder = req_builder.header("Authorization", value);
476 };
477 req_builder = req_builder.json(&p_edit_server_setting_request);
478
479 let req = req_builder.build()?;
480 let resp = configuration.client.execute(req).await?;
481
482 let status = resp.status();
483 let content_type = resp
484 .headers()
485 .get("content-type")
486 .and_then(|v| v.to_str().ok())
487 .unwrap_or("application/octet-stream");
488 let content_type = super::ContentType::from(content_type);
489
490 if !status.is_client_error() && !status.is_server_error() {
491 let content = resp.text().await?;
492 match content_type {
493 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
494 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EditServerSetting200Response`"))),
495 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::EditServerSetting200Response`")))),
496 }
497 } else {
498 let content = resp.text().await?;
499 let entity: Option<EditServerSettingError> = serde_json::from_str(&content).ok();
500 Err(Error::ResponseError(ResponseContent { status, content, entity }))
501 }
502}
503
504pub async fn get_py_misp_version(configuration: &configuration::Configuration, ) -> Result<models::GetPyMispVersion200Response, Error<GetPyMispVersionError>> {
505
506 let uri_str = format!("{}/servers/getPyMISPVersion", configuration.base_path);
507 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
508
509 if let Some(ref user_agent) = configuration.user_agent {
510 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
511 }
512 if let Some(ref apikey) = configuration.api_key {
513 let key = apikey.key.clone();
514 let value = match apikey.prefix {
515 Some(ref prefix) => format!("{} {}", prefix, key),
516 None => key,
517 };
518 req_builder = req_builder.header("Authorization", value);
519 };
520
521 let req = req_builder.build()?;
522 let resp = configuration.client.execute(req).await?;
523
524 let status = resp.status();
525 let content_type = resp
526 .headers()
527 .get("content-type")
528 .and_then(|v| v.to_str().ok())
529 .unwrap_or("application/octet-stream");
530 let content_type = super::ContentType::from(content_type);
531
532 if !status.is_client_error() && !status.is_server_error() {
533 let content = resp.text().await?;
534 match content_type {
535 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
536 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetPyMispVersion200Response`"))),
537 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::GetPyMispVersion200Response`")))),
538 }
539 } else {
540 let content = resp.text().await?;
541 let entity: Option<GetPyMispVersionError> = serde_json::from_str(&content).ok();
542 Err(Error::ResponseError(ResponseContent { status, content, entity }))
543 }
544}
545
546pub async fn get_server_setting(configuration: &configuration::Configuration, setting_name: &str) -> Result<models::MispSetting, Error<GetServerSettingError>> {
547 let p_setting_name = setting_name;
549
550 let uri_str = format!("{}/servers/getSetting/{settingName}", configuration.base_path, settingName=crate::apis::urlencode(p_setting_name));
551 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
552
553 if let Some(ref user_agent) = configuration.user_agent {
554 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
555 }
556 if let Some(ref apikey) = configuration.api_key {
557 let key = apikey.key.clone();
558 let value = match apikey.prefix {
559 Some(ref prefix) => format!("{} {}", prefix, key),
560 None => key,
561 };
562 req_builder = req_builder.header("Authorization", value);
563 };
564
565 let req = req_builder.build()?;
566 let resp = configuration.client.execute(req).await?;
567
568 let status = resp.status();
569 let content_type = resp
570 .headers()
571 .get("content-type")
572 .and_then(|v| v.to_str().ok())
573 .unwrap_or("application/octet-stream");
574 let content_type = super::ContentType::from(content_type);
575
576 if !status.is_client_error() && !status.is_server_error() {
577 let content = resp.text().await?;
578 match content_type {
579 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
580 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MispSetting`"))),
581 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::MispSetting`")))),
582 }
583 } else {
584 let content = resp.text().await?;
585 let entity: Option<GetServerSettingError> = serde_json::from_str(&content).ok();
586 Err(Error::ResponseError(ResponseContent { status, content, entity }))
587 }
588}
589
590pub async fn get_server_settings(configuration: &configuration::Configuration, ) -> Result<models::GetServerSettings200Response, Error<GetServerSettingsError>> {
591
592 let uri_str = format!("{}/servers/serverSettings", configuration.base_path);
593 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
594
595 if let Some(ref user_agent) = configuration.user_agent {
596 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
597 }
598 if let Some(ref apikey) = configuration.api_key {
599 let key = apikey.key.clone();
600 let value = match apikey.prefix {
601 Some(ref prefix) => format!("{} {}", prefix, key),
602 None => key,
603 };
604 req_builder = req_builder.header("Authorization", value);
605 };
606
607 let req = req_builder.build()?;
608 let resp = configuration.client.execute(req).await?;
609
610 let status = resp.status();
611 let content_type = resp
612 .headers()
613 .get("content-type")
614 .and_then(|v| v.to_str().ok())
615 .unwrap_or("application/octet-stream");
616 let content_type = super::ContentType::from(content_type);
617
618 if !status.is_client_error() && !status.is_server_error() {
619 let content = resp.text().await?;
620 match content_type {
621 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
622 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetServerSettings200Response`"))),
623 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::GetServerSettings200Response`")))),
624 }
625 } else {
626 let content = resp.text().await?;
627 let entity: Option<GetServerSettingsError> = serde_json::from_str(&content).ok();
628 Err(Error::ResponseError(ResponseContent { status, content, entity }))
629 }
630}
631
632pub async fn get_server_uuid(configuration: &configuration::Configuration, ) -> Result<models::GetServerUuid200Response, Error<GetServerUuidError>> {
633
634 let uri_str = format!("{}/servers/getInstanceUUID", configuration.base_path);
635 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
636
637 if let Some(ref user_agent) = configuration.user_agent {
638 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
639 }
640 if let Some(ref apikey) = configuration.api_key {
641 let key = apikey.key.clone();
642 let value = match apikey.prefix {
643 Some(ref prefix) => format!("{} {}", prefix, key),
644 None => key,
645 };
646 req_builder = req_builder.header("Authorization", value);
647 };
648
649 let req = req_builder.build()?;
650 let resp = configuration.client.execute(req).await?;
651
652 let status = resp.status();
653 let content_type = resp
654 .headers()
655 .get("content-type")
656 .and_then(|v| v.to_str().ok())
657 .unwrap_or("application/octet-stream");
658 let content_type = super::ContentType::from(content_type);
659
660 if !status.is_client_error() && !status.is_server_error() {
661 let content = resp.text().await?;
662 match content_type {
663 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
664 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetServerUuid200Response`"))),
665 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::GetServerUuid200Response`")))),
666 }
667 } else {
668 let content = resp.text().await?;
669 let entity: Option<GetServerUuidError> = serde_json::from_str(&content).ok();
670 Err(Error::ResponseError(ResponseContent { status, content, entity }))
671 }
672}
673
674pub async fn get_server_version(configuration: &configuration::Configuration, ) -> Result<models::GetServerVersion200Response, Error<GetServerVersionError>> {
675
676 let uri_str = format!("{}/servers/getVersion", configuration.base_path);
677 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
678
679 if let Some(ref user_agent) = configuration.user_agent {
680 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
681 }
682 if let Some(ref apikey) = configuration.api_key {
683 let key = apikey.key.clone();
684 let value = match apikey.prefix {
685 Some(ref prefix) => format!("{} {}", prefix, key),
686 None => key,
687 };
688 req_builder = req_builder.header("Authorization", value);
689 };
690
691 let req = req_builder.build()?;
692 let resp = configuration.client.execute(req).await?;
693
694 let status = resp.status();
695 let content_type = resp
696 .headers()
697 .get("content-type")
698 .and_then(|v| v.to_str().ok())
699 .unwrap_or("application/octet-stream");
700 let content_type = super::ContentType::from(content_type);
701
702 if !status.is_client_error() && !status.is_server_error() {
703 let content = resp.text().await?;
704 match content_type {
705 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
706 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetServerVersion200Response`"))),
707 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::GetServerVersion200Response`")))),
708 }
709 } else {
710 let content = resp.text().await?;
711 let entity: Option<GetServerVersionError> = serde_json::from_str(&content).ok();
712 Err(Error::ResponseError(ResponseContent { status, content, entity }))
713 }
714}
715
716pub async fn get_servers(configuration: &configuration::Configuration, ) -> Result<Vec<models::ServerListItem>, Error<GetServersError>> {
717
718 let uri_str = format!("{}/servers", configuration.base_path);
719 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
720
721 if let Some(ref user_agent) = configuration.user_agent {
722 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
723 }
724 if let Some(ref apikey) = configuration.api_key {
725 let key = apikey.key.clone();
726 let value = match apikey.prefix {
727 Some(ref prefix) => format!("{} {}", prefix, key),
728 None => key,
729 };
730 req_builder = req_builder.header("Authorization", value);
731 };
732
733 let req = req_builder.build()?;
734 let resp = configuration.client.execute(req).await?;
735
736 let status = resp.status();
737 let content_type = resp
738 .headers()
739 .get("content-type")
740 .and_then(|v| v.to_str().ok())
741 .unwrap_or("application/octet-stream");
742 let content_type = super::ContentType::from(content_type);
743
744 if !status.is_client_error() && !status.is_server_error() {
745 let content = resp.text().await?;
746 match content_type {
747 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
748 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ServerListItem>`"))),
749 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::ServerListItem>`")))),
750 }
751 } else {
752 let content = resp.text().await?;
753 let entity: Option<GetServersError> = serde_json::from_str(&content).ok();
754 Err(Error::ResponseError(ResponseContent { status, content, entity }))
755 }
756}
757
758pub async fn get_workers(configuration: &configuration::Configuration, ) -> Result<models::GetServerSettings200ResponseWorkers, Error<GetWorkersError>> {
759
760 let uri_str = format!("{}/servers/getWorkers", configuration.base_path);
761 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
762
763 if let Some(ref user_agent) = configuration.user_agent {
764 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
765 }
766 if let Some(ref apikey) = configuration.api_key {
767 let key = apikey.key.clone();
768 let value = match apikey.prefix {
769 Some(ref prefix) => format!("{} {}", prefix, key),
770 None => key,
771 };
772 req_builder = req_builder.header("Authorization", value);
773 };
774
775 let req = req_builder.build()?;
776 let resp = configuration.client.execute(req).await?;
777
778 let status = resp.status();
779 let content_type = resp
780 .headers()
781 .get("content-type")
782 .and_then(|v| v.to_str().ok())
783 .unwrap_or("application/octet-stream");
784 let content_type = super::ContentType::from(content_type);
785
786 if !status.is_client_error() && !status.is_server_error() {
787 let content = resp.text().await?;
788 match content_type {
789 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
790 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetServerSettings200ResponseWorkers`"))),
791 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::GetServerSettings200ResponseWorkers`")))),
792 }
793 } else {
794 let content = resp.text().await?;
795 let entity: Option<GetWorkersError> = serde_json::from_str(&content).ok();
796 Err(Error::ResponseError(ResponseContent { status, content, entity }))
797 }
798}
799
800pub async fn import_server(configuration: &configuration::Configuration, import_server_request: Option<models::ImportServerRequest>) -> Result<models::AddServer200Response, Error<ImportServerError>> {
801 let p_import_server_request = import_server_request;
803
804 let uri_str = format!("{}/servers/import", configuration.base_path);
805 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
806
807 if let Some(ref user_agent) = configuration.user_agent {
808 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
809 }
810 if let Some(ref apikey) = configuration.api_key {
811 let key = apikey.key.clone();
812 let value = match apikey.prefix {
813 Some(ref prefix) => format!("{} {}", prefix, key),
814 None => key,
815 };
816 req_builder = req_builder.header("Authorization", value);
817 };
818 req_builder = req_builder.json(&p_import_server_request);
819
820 let req = req_builder.build()?;
821 let resp = configuration.client.execute(req).await?;
822
823 let status = resp.status();
824 let content_type = resp
825 .headers()
826 .get("content-type")
827 .and_then(|v| v.to_str().ok())
828 .unwrap_or("application/octet-stream");
829 let content_type = super::ContentType::from(content_type);
830
831 if !status.is_client_error() && !status.is_server_error() {
832 let content = resp.text().await?;
833 match content_type {
834 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
835 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AddServer200Response`"))),
836 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::AddServer200Response`")))),
837 }
838 } else {
839 let content = resp.text().await?;
840 let entity: Option<ImportServerError> = serde_json::from_str(&content).ok();
841 Err(Error::ResponseError(ResponseContent { status, content, entity }))
842 }
843}
844
845pub async fn kill_all_workers(configuration: &configuration::Configuration, ) -> Result<models::KillAllWorkers200Response, Error<KillAllWorkersError>> {
846
847 let uri_str = format!("{}/servers/killAllWorkers", configuration.base_path);
848 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
849
850 if let Some(ref user_agent) = configuration.user_agent {
851 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
852 }
853 if let Some(ref apikey) = configuration.api_key {
854 let key = apikey.key.clone();
855 let value = match apikey.prefix {
856 Some(ref prefix) => format!("{} {}", prefix, key),
857 None => key,
858 };
859 req_builder = req_builder.header("Authorization", value);
860 };
861
862 let req = req_builder.build()?;
863 let resp = configuration.client.execute(req).await?;
864
865 let status = resp.status();
866 let content_type = resp
867 .headers()
868 .get("content-type")
869 .and_then(|v| v.to_str().ok())
870 .unwrap_or("application/octet-stream");
871 let content_type = super::ContentType::from(content_type);
872
873 if !status.is_client_error() && !status.is_server_error() {
874 let content = resp.text().await?;
875 match content_type {
876 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
877 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::KillAllWorkers200Response`"))),
878 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::KillAllWorkers200Response`")))),
879 }
880 } else {
881 let content = resp.text().await?;
882 let entity: Option<KillAllWorkersError> = serde_json::from_str(&content).ok();
883 Err(Error::ResponseError(ResponseContent { status, content, entity }))
884 }
885}
886
887pub async fn pull_server(configuration: &configuration::Configuration, server_id: &str, pull_technique: &str) -> Result<models::PullServer200Response, Error<PullServerError>> {
888 let p_server_id = server_id;
890 let p_pull_technique = pull_technique;
891
892 let uri_str = format!("{}/servers/pull/{serverId}/{pullTechnique}", configuration.base_path, serverId=p_server_id.to_string(), pullTechnique=crate::apis::urlencode(p_pull_technique));
893 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
894
895 if let Some(ref user_agent) = configuration.user_agent {
896 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
897 }
898 if let Some(ref apikey) = configuration.api_key {
899 let key = apikey.key.clone();
900 let value = match apikey.prefix {
901 Some(ref prefix) => format!("{} {}", prefix, key),
902 None => key,
903 };
904 req_builder = req_builder.header("Authorization", value);
905 };
906
907 let req = req_builder.build()?;
908 let resp = configuration.client.execute(req).await?;
909
910 let status = resp.status();
911 let content_type = resp
912 .headers()
913 .get("content-type")
914 .and_then(|v| v.to_str().ok())
915 .unwrap_or("application/octet-stream");
916 let content_type = super::ContentType::from(content_type);
917
918 if !status.is_client_error() && !status.is_server_error() {
919 let content = resp.text().await?;
920 match content_type {
921 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
922 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PullServer200Response`"))),
923 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::PullServer200Response`")))),
924 }
925 } else {
926 let content = resp.text().await?;
927 let entity: Option<PullServerError> = serde_json::from_str(&content).ok();
928 Err(Error::ResponseError(ResponseContent { status, content, entity }))
929 }
930}
931
932pub async fn push_server(configuration: &configuration::Configuration, server_id: &str, push_technique: &str) -> Result<models::PushServer200Response, Error<PushServerError>> {
933 let p_server_id = server_id;
935 let p_push_technique = push_technique;
936
937 let uri_str = format!("{}/servers/push/{serverId}/{pushTechnique}", configuration.base_path, serverId=p_server_id.to_string(), pushTechnique=crate::apis::urlencode(p_push_technique));
938 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
939
940 if let Some(ref user_agent) = configuration.user_agent {
941 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
942 }
943 if let Some(ref apikey) = configuration.api_key {
944 let key = apikey.key.clone();
945 let value = match apikey.prefix {
946 Some(ref prefix) => format!("{} {}", prefix, key),
947 None => key,
948 };
949 req_builder = req_builder.header("Authorization", value);
950 };
951
952 let req = req_builder.build()?;
953 let resp = configuration.client.execute(req).await?;
954
955 let status = resp.status();
956 let content_type = resp
957 .headers()
958 .get("content-type")
959 .and_then(|v| v.to_str().ok())
960 .unwrap_or("application/octet-stream");
961 let content_type = super::ContentType::from(content_type);
962
963 if !status.is_client_error() && !status.is_server_error() {
964 let content = resp.text().await?;
965 match content_type {
966 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
967 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PushServer200Response`"))),
968 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::PushServer200Response`")))),
969 }
970 } else {
971 let content = resp.text().await?;
972 let entity: Option<PushServerError> = serde_json::from_str(&content).ok();
973 Err(Error::ResponseError(ResponseContent { status, content, entity }))
974 }
975}
976
977pub async fn restart_dead_workers(configuration: &configuration::Configuration, ) -> Result<models::RestartDeadWorkers200Response, Error<RestartDeadWorkersError>> {
978
979 let uri_str = format!("{}/servers/restartDeadWorkers", configuration.base_path);
980 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
981
982 if let Some(ref user_agent) = configuration.user_agent {
983 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
984 }
985 if let Some(ref apikey) = configuration.api_key {
986 let key = apikey.key.clone();
987 let value = match apikey.prefix {
988 Some(ref prefix) => format!("{} {}", prefix, key),
989 None => key,
990 };
991 req_builder = req_builder.header("Authorization", value);
992 };
993
994 let req = req_builder.build()?;
995 let resp = configuration.client.execute(req).await?;
996
997 let status = resp.status();
998 let content_type = resp
999 .headers()
1000 .get("content-type")
1001 .and_then(|v| v.to_str().ok())
1002 .unwrap_or("application/octet-stream");
1003 let content_type = super::ContentType::from(content_type);
1004
1005 if !status.is_client_error() && !status.is_server_error() {
1006 let content = resp.text().await?;
1007 match content_type {
1008 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1009 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RestartDeadWorkers200Response`"))),
1010 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::RestartDeadWorkers200Response`")))),
1011 }
1012 } else {
1013 let content = resp.text().await?;
1014 let entity: Option<RestartDeadWorkersError> = serde_json::from_str(&content).ok();
1015 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1016 }
1017}
1018
1019pub async fn restart_workers(configuration: &configuration::Configuration, ) -> Result<models::RestartWorkers200Response, Error<RestartWorkersError>> {
1020
1021 let uri_str = format!("{}/servers/restartWorkers", configuration.base_path);
1022 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1023
1024 if let Some(ref user_agent) = configuration.user_agent {
1025 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1026 }
1027 if let Some(ref apikey) = configuration.api_key {
1028 let key = apikey.key.clone();
1029 let value = match apikey.prefix {
1030 Some(ref prefix) => format!("{} {}", prefix, key),
1031 None => key,
1032 };
1033 req_builder = req_builder.header("Authorization", value);
1034 };
1035
1036 let req = req_builder.build()?;
1037 let resp = configuration.client.execute(req).await?;
1038
1039 let status = resp.status();
1040 let content_type = resp
1041 .headers()
1042 .get("content-type")
1043 .and_then(|v| v.to_str().ok())
1044 .unwrap_or("application/octet-stream");
1045 let content_type = super::ContentType::from(content_type);
1046
1047 if !status.is_client_error() && !status.is_server_error() {
1048 let content = resp.text().await?;
1049 match content_type {
1050 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1051 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RestartWorkers200Response`"))),
1052 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::RestartWorkers200Response`")))),
1053 }
1054 } else {
1055 let content = resp.text().await?;
1056 let entity: Option<RestartWorkersError> = serde_json::from_str(&content).ok();
1057 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1058 }
1059}
1060
1061pub async fn start_worker(configuration: &configuration::Configuration, worker_type: &str) -> Result<models::StartWorker200Response, Error<StartWorkerError>> {
1062 let p_worker_type = worker_type;
1064
1065 let uri_str = format!("{}/servers/startWorker/{workerType}", configuration.base_path, workerType=crate::apis::urlencode(p_worker_type));
1066 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1067
1068 if let Some(ref user_agent) = configuration.user_agent {
1069 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1070 }
1071 if let Some(ref apikey) = configuration.api_key {
1072 let key = apikey.key.clone();
1073 let value = match apikey.prefix {
1074 Some(ref prefix) => format!("{} {}", prefix, key),
1075 None => key,
1076 };
1077 req_builder = req_builder.header("Authorization", value);
1078 };
1079
1080 let req = req_builder.build()?;
1081 let resp = configuration.client.execute(req).await?;
1082
1083 let status = resp.status();
1084 let content_type = resp
1085 .headers()
1086 .get("content-type")
1087 .and_then(|v| v.to_str().ok())
1088 .unwrap_or("application/octet-stream");
1089 let content_type = super::ContentType::from(content_type);
1090
1091 if !status.is_client_error() && !status.is_server_error() {
1092 let content = resp.text().await?;
1093 match content_type {
1094 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1095 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::StartWorker200Response`"))),
1096 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::StartWorker200Response`")))),
1097 }
1098 } else {
1099 let content = resp.text().await?;
1100 let entity: Option<StartWorkerError> = serde_json::from_str(&content).ok();
1101 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1102 }
1103}
1104
1105pub async fn stop_worker(configuration: &configuration::Configuration, worker_pid: &str) -> Result<models::StopWorker200Response, Error<StopWorkerError>> {
1106 let p_worker_pid = worker_pid;
1108
1109 let uri_str = format!("{}/servers/stopWorker/{workerPid}", configuration.base_path, workerPid=crate::apis::urlencode(p_worker_pid));
1110 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1111
1112 if let Some(ref user_agent) = configuration.user_agent {
1113 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1114 }
1115 if let Some(ref apikey) = configuration.api_key {
1116 let key = apikey.key.clone();
1117 let value = match apikey.prefix {
1118 Some(ref prefix) => format!("{} {}", prefix, key),
1119 None => key,
1120 };
1121 req_builder = req_builder.header("Authorization", value);
1122 };
1123
1124 let req = req_builder.build()?;
1125 let resp = configuration.client.execute(req).await?;
1126
1127 let status = resp.status();
1128 let content_type = resp
1129 .headers()
1130 .get("content-type")
1131 .and_then(|v| v.to_str().ok())
1132 .unwrap_or("application/octet-stream");
1133 let content_type = super::ContentType::from(content_type);
1134
1135 if !status.is_client_error() && !status.is_server_error() {
1136 let content = resp.text().await?;
1137 match content_type {
1138 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1139 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::StopWorker200Response`"))),
1140 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::StopWorker200Response`")))),
1141 }
1142 } else {
1143 let content = resp.text().await?;
1144 let entity: Option<StopWorkerError> = serde_json::from_str(&content).ok();
1145 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1146 }
1147}
1148
1149pub async fn update_server(configuration: &configuration::Configuration, ) -> Result<models::UpdateServer200Response, Error<UpdateServerError>> {
1150
1151 let uri_str = format!("{}/servers/update", configuration.base_path);
1152 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1153
1154 if let Some(ref user_agent) = configuration.user_agent {
1155 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1156 }
1157 if let Some(ref apikey) = configuration.api_key {
1158 let key = apikey.key.clone();
1159 let value = match apikey.prefix {
1160 Some(ref prefix) => format!("{} {}", prefix, key),
1161 None => key,
1162 };
1163 req_builder = req_builder.header("Authorization", value);
1164 };
1165
1166 let req = req_builder.build()?;
1167 let resp = configuration.client.execute(req).await?;
1168
1169 let status = resp.status();
1170 let content_type = resp
1171 .headers()
1172 .get("content-type")
1173 .and_then(|v| v.to_str().ok())
1174 .unwrap_or("application/octet-stream");
1175 let content_type = super::ContentType::from(content_type);
1176
1177 if !status.is_client_error() && !status.is_server_error() {
1178 let content = resp.text().await?;
1179 match content_type {
1180 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1181 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateServer200Response`"))),
1182 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::UpdateServer200Response`")))),
1183 }
1184 } else {
1185 let content = resp.text().await?;
1186 let entity: Option<UpdateServerError> = serde_json::from_str(&content).ok();
1187 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1188 }
1189}
1190