1use reqwest;
12#[allow(unused_imports)]
13use serde::{de::Error as _};
14use crate::{apis::ResponseContent, models};
15#[allow(unused_imports)]
16use super::{Error, ContentType};
17use dtz_config::Configuration;
18
19fn build_url(config: &Configuration) -> String {
20 if let Some(base_path) = &config.base_path {
21 let base = url::Url::parse(base_path).unwrap();
22 let mut target_url = url::Url::parse(crate::apis::SVC_URL).unwrap();
23 let _ = target_url.set_scheme(base.scheme());
24 let _ = target_url.set_port(base.port());
25 let _ = target_url.set_host(Some(base.host_str().unwrap()));
26 format!("{target_url}")
27 } else {
28 crate::apis::SVC_URL.to_string()
29 }
30}
31
32
33#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum CreateDomainError {
37 Status409(),
38 UnknownValue(serde_json::Value),
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize)]
43#[serde(untagged)]
44pub enum CreateJobError {
45 Status400(models::CreateJob400Response),
46 UnknownValue(serde_json::Value),
47}
48
49#[derive(Debug, Clone, Serialize, Deserialize)]
51#[serde(untagged)]
52pub enum CreateServiceError {
53 UnknownValue(serde_json::Value),
54}
55
56#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(untagged)]
59pub enum CreateVolumeError {
60 Status400(),
61 UnknownValue(serde_json::Value),
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(untagged)]
67pub enum DeleteDomainError {
68 UnknownValue(serde_json::Value),
69}
70
71#[derive(Debug, Clone, Serialize, Deserialize)]
73#[serde(untagged)]
74pub enum DeleteJobError {
75 UnknownValue(serde_json::Value),
76}
77
78#[derive(Debug, Clone, Serialize, Deserialize)]
80#[serde(untagged)]
81pub enum DeleteServiceError {
82 UnknownValue(serde_json::Value),
83}
84
85#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum DeleteVolumeError {
89 UnknownValue(serde_json::Value),
90}
91
92#[derive(Debug, Clone, Serialize, Deserialize)]
94#[serde(untagged)]
95pub enum DisableError {
96 UnknownValue(serde_json::Value),
97}
98
99#[derive(Debug, Clone, Serialize, Deserialize)]
101#[serde(untagged)]
102pub enum EnableError {
103 Status401(models::ErrorResponse),
104 Status500(models::ErrorResponse),
105 UnknownValue(serde_json::Value),
106}
107
108#[derive(Debug, Clone, Serialize, Deserialize)]
110#[serde(untagged)]
111pub enum GetDomainError {
112 Status404(),
113 UnknownValue(serde_json::Value),
114}
115
116#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum GetDomainsError {
120 UnknownValue(serde_json::Value),
121}
122
123#[derive(Debug, Clone, Serialize, Deserialize)]
125#[serde(untagged)]
126pub enum GetJobError {
127 Status401(),
128 UnknownValue(serde_json::Value),
129}
130
131#[derive(Debug, Clone, Serialize, Deserialize)]
133#[serde(untagged)]
134pub enum GetJobsError {
135 UnknownValue(serde_json::Value),
136}
137
138#[derive(Debug, Clone, Serialize, Deserialize)]
140#[serde(untagged)]
141pub enum GetServiceError {
142 Status404(),
143 UnknownValue(serde_json::Value),
144}
145
146#[derive(Debug, Clone, Serialize, Deserialize)]
148#[serde(untagged)]
149pub enum GetServicesError {
150 UnknownValue(serde_json::Value),
151}
152
153#[derive(Debug, Clone, Serialize, Deserialize)]
155#[serde(untagged)]
156pub enum GetVolumeError {
157 Status404(),
158 UnknownValue(serde_json::Value),
159}
160
161#[derive(Debug, Clone, Serialize, Deserialize)]
163#[serde(untagged)]
164pub enum GetVolumeStatsError {
165 UnknownValue(serde_json::Value),
166}
167
168#[derive(Debug, Clone, Serialize, Deserialize)]
170#[serde(untagged)]
171pub enum GetVolumeStatsForVolumeError {
172 Status404(),
173 UnknownValue(serde_json::Value),
174}
175
176#[derive(Debug, Clone, Serialize, Deserialize)]
178#[serde(untagged)]
179pub enum GetVolumesError {
180 UnknownValue(serde_json::Value),
181}
182
183#[derive(Debug, Clone, Serialize, Deserialize)]
185#[serde(untagged)]
186pub enum TriggerJobError {
187 Status401(),
188 Status404(),
189 UnknownValue(serde_json::Value),
190}
191
192#[derive(Debug, Clone, Serialize, Deserialize)]
194#[serde(untagged)]
195pub enum UpdateJobError {
196 UnknownValue(serde_json::Value),
197}
198
199#[derive(Debug, Clone, Serialize, Deserialize)]
201#[serde(untagged)]
202pub enum UpdateServiceError {
203 Status404(),
204 UnknownValue(serde_json::Value),
205}
206
207#[derive(Debug, Clone, Serialize, Deserialize)]
209#[serde(untagged)]
210pub enum UpdateVolumeError {
211 Status404(),
212 UnknownValue(serde_json::Value),
213}
214
215#[derive(Debug, Clone, Serialize, Deserialize)]
217#[serde(untagged)]
218pub enum VerifyDomainError {
219 Status401(models::ErrorResponse),
220 Status409(models::ErrorResponse),
221 Status500(models::ErrorResponse),
222 UnknownValue(serde_json::Value),
223}
224
225
226pub async fn create_domain(configuration: &Configuration, create_domain_request: Option<models::CreateDomainRequest>) -> Result<models::Domain, Error<CreateDomainError>> {
227 let p_body_create_domain_request = create_domain_request;
229
230 let uri_str = format!("{}/domain", build_url(configuration));
231 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
232
233
234 if let Some(ref token) = configuration.oauth_access_token {
235 req_builder = req_builder.bearer_auth(token.to_owned());
236 };
237 if let Some(ref value) = configuration.api_key {
238 req_builder = req_builder.header("X-API-KEY", value);
239 };
240 req_builder = req_builder.json(&p_body_create_domain_request);
241
242 let req = req_builder.build()?;
243 let resp = configuration.client.execute(req).await?;
244
245 let status = resp.status();
246 let content_type = resp
247 .headers()
248 .get("content-type")
249 .and_then(|v| v.to_str().ok())
250 .unwrap_or("application/octet-stream");
251 let content_type = super::ContentType::from(content_type);
252
253 if !status.is_client_error() && !status.is_server_error() {
254 let content = resp.text().await?;
255 match content_type {
256 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
257 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Domain`"))),
258 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::Domain`")))),
259 }
260 } else {
261 let content = resp.text().await?;
262 let entity: Option<CreateDomainError> = serde_json::from_str(&content).ok();
263 Err(Error::ResponseError(ResponseContent { status, content, entity }))
264 }
265}
266
267pub async fn create_job(configuration: &Configuration, create_job_request: Option<models::CreateJobRequest>) -> Result<models::JobResponse, Error<CreateJobError>> {
268 let p_body_create_job_request = create_job_request;
270
271 let uri_str = format!("{}/job", build_url(configuration));
272 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
273
274
275 if let Some(ref token) = configuration.oauth_access_token {
276 req_builder = req_builder.bearer_auth(token.to_owned());
277 };
278 if let Some(ref value) = configuration.api_key {
279 req_builder = req_builder.header("X-API-KEY", value);
280 };
281 req_builder = req_builder.json(&p_body_create_job_request);
282
283 let req = req_builder.build()?;
284 let resp = configuration.client.execute(req).await?;
285
286 let status = resp.status();
287 let content_type = resp
288 .headers()
289 .get("content-type")
290 .and_then(|v| v.to_str().ok())
291 .unwrap_or("application/octet-stream");
292 let content_type = super::ContentType::from(content_type);
293
294 if !status.is_client_error() && !status.is_server_error() {
295 let content = resp.text().await?;
296 match content_type {
297 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
298 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::JobResponse`"))),
299 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::JobResponse`")))),
300 }
301 } else {
302 let content = resp.text().await?;
303 let entity: Option<CreateJobError> = serde_json::from_str(&content).ok();
304 Err(Error::ResponseError(ResponseContent { status, content, entity }))
305 }
306}
307
308pub async fn create_service(configuration: &Configuration, create_service_request: Option<models::CreateServiceRequest>) -> Result<models::Service, Error<CreateServiceError>> {
309 let p_body_create_service_request = create_service_request;
311
312 let uri_str = format!("{}/service", build_url(configuration));
313 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
314
315
316 if let Some(ref token) = configuration.oauth_access_token {
317 req_builder = req_builder.bearer_auth(token.to_owned());
318 };
319 if let Some(ref value) = configuration.api_key {
320 req_builder = req_builder.header("X-API-KEY", value);
321 };
322 req_builder = req_builder.json(&p_body_create_service_request);
323
324 let req = req_builder.build()?;
325 let resp = configuration.client.execute(req).await?;
326
327 let status = resp.status();
328 let content_type = resp
329 .headers()
330 .get("content-type")
331 .and_then(|v| v.to_str().ok())
332 .unwrap_or("application/octet-stream");
333 let content_type = super::ContentType::from(content_type);
334
335 if !status.is_client_error() && !status.is_server_error() {
336 let content = resp.text().await?;
337 match content_type {
338 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
339 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Service`"))),
340 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::Service`")))),
341 }
342 } else {
343 let content = resp.text().await?;
344 let entity: Option<CreateServiceError> = serde_json::from_str(&content).ok();
345 Err(Error::ResponseError(ResponseContent { status, content, entity }))
346 }
347}
348
349pub async fn create_volume(configuration: &Configuration, create_volume_request: Option<models::CreateVolumeRequest>) -> Result<models::Volume, Error<CreateVolumeError>> {
350 let p_body_create_volume_request = create_volume_request;
352
353 let uri_str = format!("{}/volume", build_url(configuration));
354 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
355
356
357 if let Some(ref token) = configuration.oauth_access_token {
358 req_builder = req_builder.bearer_auth(token.to_owned());
359 };
360 if let Some(ref value) = configuration.api_key {
361 req_builder = req_builder.header("X-API-KEY", value);
362 };
363 req_builder = req_builder.json(&p_body_create_volume_request);
364
365 let req = req_builder.build()?;
366 let resp = configuration.client.execute(req).await?;
367
368 let status = resp.status();
369 let content_type = resp
370 .headers()
371 .get("content-type")
372 .and_then(|v| v.to_str().ok())
373 .unwrap_or("application/octet-stream");
374 let content_type = super::ContentType::from(content_type);
375
376 if !status.is_client_error() && !status.is_server_error() {
377 let content = resp.text().await?;
378 match content_type {
379 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
380 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Volume`"))),
381 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::Volume`")))),
382 }
383 } else {
384 let content = resp.text().await?;
385 let entity: Option<CreateVolumeError> = serde_json::from_str(&content).ok();
386 Err(Error::ResponseError(ResponseContent { status, content, entity }))
387 }
388}
389
390pub async fn delete_domain(configuration: &Configuration, domain_name: &str) -> Result<(), Error<DeleteDomainError>> {
391 let p_path_domain_name = domain_name;
393
394 let uri_str = format!("{}/domain/{domainName}", build_url(configuration), domainName=crate::apis::urlencode(p_path_domain_name));
395 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
396
397
398 if let Some(ref token) = configuration.oauth_access_token {
399 req_builder = req_builder.bearer_auth(token.to_owned());
400 };
401 if let Some(ref value) = configuration.api_key {
402 req_builder = req_builder.header("X-API-KEY", value);
403 };
404
405 let req = req_builder.build()?;
406 let resp = configuration.client.execute(req).await?;
407
408 let status = resp.status();
409
410 if !status.is_client_error() && !status.is_server_error() {
411 Ok(())
412 } else {
413 let content = resp.text().await?;
414 let entity: Option<DeleteDomainError> = serde_json::from_str(&content).ok();
415 Err(Error::ResponseError(ResponseContent { status, content, entity }))
416 }
417}
418
419pub async fn delete_job(configuration: &Configuration, job_id: &str) -> Result<(), Error<DeleteJobError>> {
420 let p_path_job_id = job_id;
422
423 let uri_str = format!("{}/job/{jobId}", build_url(configuration), jobId=crate::apis::urlencode(p_path_job_id));
424 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
425
426
427 if let Some(ref token) = configuration.oauth_access_token {
428 req_builder = req_builder.bearer_auth(token.to_owned());
429 };
430 if let Some(ref value) = configuration.api_key {
431 req_builder = req_builder.header("X-API-KEY", value);
432 };
433
434 let req = req_builder.build()?;
435 let resp = configuration.client.execute(req).await?;
436
437 let status = resp.status();
438
439 if !status.is_client_error() && !status.is_server_error() {
440 Ok(())
441 } else {
442 let content = resp.text().await?;
443 let entity: Option<DeleteJobError> = serde_json::from_str(&content).ok();
444 Err(Error::ResponseError(ResponseContent { status, content, entity }))
445 }
446}
447
448pub async fn delete_service(configuration: &Configuration, service_id: &str) -> Result<(), Error<DeleteServiceError>> {
449 let p_path_service_id = service_id;
451
452 let uri_str = format!("{}/service/{serviceId}", build_url(configuration), serviceId=crate::apis::urlencode(p_path_service_id));
453 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
454
455
456 if let Some(ref token) = configuration.oauth_access_token {
457 req_builder = req_builder.bearer_auth(token.to_owned());
458 };
459 if let Some(ref value) = configuration.api_key {
460 req_builder = req_builder.header("X-API-KEY", value);
461 };
462
463 let req = req_builder.build()?;
464 let resp = configuration.client.execute(req).await?;
465
466 let status = resp.status();
467
468 if !status.is_client_error() && !status.is_server_error() {
469 Ok(())
470 } else {
471 let content = resp.text().await?;
472 let entity: Option<DeleteServiceError> = serde_json::from_str(&content).ok();
473 Err(Error::ResponseError(ResponseContent { status, content, entity }))
474 }
475}
476
477pub async fn delete_volume(configuration: &Configuration, volume_id: &str) -> Result<(), Error<DeleteVolumeError>> {
478 let p_path_volume_id = volume_id;
480
481 let uri_str = format!("{}/volume/{volumeId}", build_url(configuration), volumeId=crate::apis::urlencode(p_path_volume_id));
482 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
483
484
485 if let Some(ref token) = configuration.oauth_access_token {
486 req_builder = req_builder.bearer_auth(token.to_owned());
487 };
488 if let Some(ref value) = configuration.api_key {
489 req_builder = req_builder.header("X-API-KEY", value);
490 };
491
492 let req = req_builder.build()?;
493 let resp = configuration.client.execute(req).await?;
494
495 let status = resp.status();
496
497 if !status.is_client_error() && !status.is_server_error() {
498 Ok(())
499 } else {
500 let content = resp.text().await?;
501 let entity: Option<DeleteVolumeError> = serde_json::from_str(&content).ok();
502 Err(Error::ResponseError(ResponseContent { status, content, entity }))
503 }
504}
505
506pub async fn disable(configuration: &Configuration) -> Result<(), Error<DisableError>> {
507
508 let uri_str = format!("{}/disable", build_url(configuration));
509 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
510
511
512 if let Some(ref token) = configuration.oauth_access_token {
513 req_builder = req_builder.bearer_auth(token.to_owned());
514 };
515 if let Some(ref value) = configuration.api_key {
516 req_builder = req_builder.header("X-API-KEY", value);
517 };
518
519 let req = req_builder.build()?;
520 let resp = configuration.client.execute(req).await?;
521
522 let status = resp.status();
523
524 if !status.is_client_error() && !status.is_server_error() {
525 Ok(())
526 } else {
527 let content = resp.text().await?;
528 let entity: Option<DisableError> = serde_json::from_str(&content).ok();
529 Err(Error::ResponseError(ResponseContent { status, content, entity }))
530 }
531}
532
533pub async fn enable(configuration: &Configuration) -> Result<(), Error<EnableError>> {
534
535 let uri_str = format!("{}/enable", build_url(configuration));
536 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
537
538
539 if let Some(ref token) = configuration.oauth_access_token {
540 req_builder = req_builder.bearer_auth(token.to_owned());
541 };
542 if let Some(ref value) = configuration.api_key {
543 req_builder = req_builder.header("X-API-KEY", value);
544 };
545
546 let req = req_builder.build()?;
547 let resp = configuration.client.execute(req).await?;
548
549 let status = resp.status();
550
551 if !status.is_client_error() && !status.is_server_error() {
552 Ok(())
553 } else {
554 let content = resp.text().await?;
555 let entity: Option<EnableError> = serde_json::from_str(&content).ok();
556 Err(Error::ResponseError(ResponseContent { status, content, entity }))
557 }
558}
559
560pub async fn get_domain(configuration: &Configuration, domain_name: &str) -> Result<models::Domain, Error<GetDomainError>> {
561 let p_path_domain_name = domain_name;
563
564 let uri_str = format!("{}/domain/{domainName}", build_url(configuration), domainName=crate::apis::urlencode(p_path_domain_name));
565 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
566
567
568 if let Some(ref token) = configuration.oauth_access_token {
569 req_builder = req_builder.bearer_auth(token.to_owned());
570 };
571 if let Some(ref value) = configuration.api_key {
572 req_builder = req_builder.header("X-API-KEY", value);
573 };
574
575 let req = req_builder.build()?;
576 let resp = configuration.client.execute(req).await?;
577
578 let status = resp.status();
579 let content_type = resp
580 .headers()
581 .get("content-type")
582 .and_then(|v| v.to_str().ok())
583 .unwrap_or("application/octet-stream");
584 let content_type = super::ContentType::from(content_type);
585
586 if !status.is_client_error() && !status.is_server_error() {
587 let content = resp.text().await?;
588 match content_type {
589 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
590 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Domain`"))),
591 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::Domain`")))),
592 }
593 } else {
594 let content = resp.text().await?;
595 let entity: Option<GetDomainError> = serde_json::from_str(&content).ok();
596 Err(Error::ResponseError(ResponseContent { status, content, entity }))
597 }
598}
599
600pub async fn get_domains(configuration: &Configuration) -> Result<Vec<models::Domain>, Error<GetDomainsError>> {
601
602 let uri_str = format!("{}/domain", build_url(configuration));
603 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
604
605
606 if let Some(ref token) = configuration.oauth_access_token {
607 req_builder = req_builder.bearer_auth(token.to_owned());
608 };
609 if let Some(ref value) = configuration.api_key {
610 req_builder = req_builder.header("X-API-KEY", value);
611 };
612
613 let req = req_builder.build()?;
614 let resp = configuration.client.execute(req).await?;
615
616 let status = resp.status();
617 let content_type = resp
618 .headers()
619 .get("content-type")
620 .and_then(|v| v.to_str().ok())
621 .unwrap_or("application/octet-stream");
622 let content_type = super::ContentType::from(content_type);
623
624 if !status.is_client_error() && !status.is_server_error() {
625 let content = resp.text().await?;
626 match content_type {
627 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
628 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Domain>`"))),
629 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::Domain>`")))),
630 }
631 } else {
632 let content = resp.text().await?;
633 let entity: Option<GetDomainsError> = serde_json::from_str(&content).ok();
634 Err(Error::ResponseError(ResponseContent { status, content, entity }))
635 }
636}
637
638pub async fn get_job(configuration: &Configuration, job_id: &str) -> Result<models::JobResponse, Error<GetJobError>> {
639 let p_path_job_id = job_id;
641
642 let uri_str = format!("{}/job/{jobId}", build_url(configuration), jobId=crate::apis::urlencode(p_path_job_id));
643 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
644
645
646 if let Some(ref token) = configuration.oauth_access_token {
647 req_builder = req_builder.bearer_auth(token.to_owned());
648 };
649 if let Some(ref value) = configuration.api_key {
650 req_builder = req_builder.header("X-API-KEY", value);
651 };
652
653 let req = req_builder.build()?;
654 let resp = configuration.client.execute(req).await?;
655
656 let status = resp.status();
657 let content_type = resp
658 .headers()
659 .get("content-type")
660 .and_then(|v| v.to_str().ok())
661 .unwrap_or("application/octet-stream");
662 let content_type = super::ContentType::from(content_type);
663
664 if !status.is_client_error() && !status.is_server_error() {
665 let content = resp.text().await?;
666 match content_type {
667 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
668 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::JobResponse`"))),
669 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::JobResponse`")))),
670 }
671 } else {
672 let content = resp.text().await?;
673 let entity: Option<GetJobError> = serde_json::from_str(&content).ok();
674 Err(Error::ResponseError(ResponseContent { status, content, entity }))
675 }
676}
677
678pub async fn get_jobs(configuration: &Configuration) -> Result<Vec<models::JobResponse>, Error<GetJobsError>> {
679
680 let uri_str = format!("{}/job", build_url(configuration));
681 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
682
683
684 if let Some(ref token) = configuration.oauth_access_token {
685 req_builder = req_builder.bearer_auth(token.to_owned());
686 };
687 if let Some(ref value) = configuration.api_key {
688 req_builder = req_builder.header("X-API-KEY", 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 `Vec<models::JobResponse>`"))),
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 `Vec<models::JobResponse>`")))),
708 }
709 } else {
710 let content = resp.text().await?;
711 let entity: Option<GetJobsError> = serde_json::from_str(&content).ok();
712 Err(Error::ResponseError(ResponseContent { status, content, entity }))
713 }
714}
715
716pub async fn get_service(configuration: &Configuration, service_id: &str) -> Result<models::Service, Error<GetServiceError>> {
717 let p_path_service_id = service_id;
719
720 let uri_str = format!("{}/service/{serviceId}", build_url(configuration), serviceId=crate::apis::urlencode(p_path_service_id));
721 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
722
723
724 if let Some(ref token) = configuration.oauth_access_token {
725 req_builder = req_builder.bearer_auth(token.to_owned());
726 };
727 if let Some(ref value) = configuration.api_key {
728 req_builder = req_builder.header("X-API-KEY", value);
729 };
730
731 let req = req_builder.build()?;
732 let resp = configuration.client.execute(req).await?;
733
734 let status = resp.status();
735 let content_type = resp
736 .headers()
737 .get("content-type")
738 .and_then(|v| v.to_str().ok())
739 .unwrap_or("application/octet-stream");
740 let content_type = super::ContentType::from(content_type);
741
742 if !status.is_client_error() && !status.is_server_error() {
743 let content = resp.text().await?;
744 match content_type {
745 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
746 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Service`"))),
747 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::Service`")))),
748 }
749 } else {
750 let content = resp.text().await?;
751 let entity: Option<GetServiceError> = serde_json::from_str(&content).ok();
752 Err(Error::ResponseError(ResponseContent { status, content, entity }))
753 }
754}
755
756pub async fn get_services(configuration: &Configuration) -> Result<Vec<models::Service>, Error<GetServicesError>> {
757
758 let uri_str = format!("{}/service", build_url(configuration));
759 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
760
761
762 if let Some(ref token) = configuration.oauth_access_token {
763 req_builder = req_builder.bearer_auth(token.to_owned());
764 };
765 if let Some(ref value) = configuration.api_key {
766 req_builder = req_builder.header("X-API-KEY", value);
767 };
768
769 let req = req_builder.build()?;
770 let resp = configuration.client.execute(req).await?;
771
772 let status = resp.status();
773 let content_type = resp
774 .headers()
775 .get("content-type")
776 .and_then(|v| v.to_str().ok())
777 .unwrap_or("application/octet-stream");
778 let content_type = super::ContentType::from(content_type);
779
780 if !status.is_client_error() && !status.is_server_error() {
781 let content = resp.text().await?;
782 match content_type {
783 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
784 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Service>`"))),
785 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::Service>`")))),
786 }
787 } else {
788 let content = resp.text().await?;
789 let entity: Option<GetServicesError> = serde_json::from_str(&content).ok();
790 Err(Error::ResponseError(ResponseContent { status, content, entity }))
791 }
792}
793
794pub async fn get_volume(configuration: &Configuration, volume_id: &str) -> Result<models::Volume, Error<GetVolumeError>> {
795 let p_path_volume_id = volume_id;
797
798 let uri_str = format!("{}/volume/{volumeId}", build_url(configuration), volumeId=crate::apis::urlencode(p_path_volume_id));
799 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
800
801
802 if let Some(ref token) = configuration.oauth_access_token {
803 req_builder = req_builder.bearer_auth(token.to_owned());
804 };
805 if let Some(ref value) = configuration.api_key {
806 req_builder = req_builder.header("X-API-KEY", value);
807 };
808
809 let req = req_builder.build()?;
810 let resp = configuration.client.execute(req).await?;
811
812 let status = resp.status();
813 let content_type = resp
814 .headers()
815 .get("content-type")
816 .and_then(|v| v.to_str().ok())
817 .unwrap_or("application/octet-stream");
818 let content_type = super::ContentType::from(content_type);
819
820 if !status.is_client_error() && !status.is_server_error() {
821 let content = resp.text().await?;
822 match content_type {
823 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
824 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Volume`"))),
825 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::Volume`")))),
826 }
827 } else {
828 let content = resp.text().await?;
829 let entity: Option<GetVolumeError> = serde_json::from_str(&content).ok();
830 Err(Error::ResponseError(ResponseContent { status, content, entity }))
831 }
832}
833
834pub async fn get_volume_stats(configuration: &Configuration) -> Result<Vec<models::VolumeStats>, Error<GetVolumeStatsError>> {
835
836 let uri_str = format!("{}/volume/stats", build_url(configuration));
837 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
838
839
840 if let Some(ref token) = configuration.oauth_access_token {
841 req_builder = req_builder.bearer_auth(token.to_owned());
842 };
843 if let Some(ref value) = configuration.api_key {
844 req_builder = req_builder.header("X-API-KEY", value);
845 };
846
847 let req = req_builder.build()?;
848 let resp = configuration.client.execute(req).await?;
849
850 let status = resp.status();
851 let content_type = resp
852 .headers()
853 .get("content-type")
854 .and_then(|v| v.to_str().ok())
855 .unwrap_or("application/octet-stream");
856 let content_type = super::ContentType::from(content_type);
857
858 if !status.is_client_error() && !status.is_server_error() {
859 let content = resp.text().await?;
860 match content_type {
861 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
862 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::VolumeStats>`"))),
863 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::VolumeStats>`")))),
864 }
865 } else {
866 let content = resp.text().await?;
867 let entity: Option<GetVolumeStatsError> = serde_json::from_str(&content).ok();
868 Err(Error::ResponseError(ResponseContent { status, content, entity }))
869 }
870}
871
872pub async fn get_volume_stats_for_volume(configuration: &Configuration, volume_id: &str) -> Result<models::VolumeStats, Error<GetVolumeStatsForVolumeError>> {
873 let p_path_volume_id = volume_id;
875
876 let uri_str = format!("{}/volume/{volumeId}/stats", build_url(configuration), volumeId=crate::apis::urlencode(p_path_volume_id));
877 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
878
879
880 if let Some(ref token) = configuration.oauth_access_token {
881 req_builder = req_builder.bearer_auth(token.to_owned());
882 };
883 if let Some(ref value) = configuration.api_key {
884 req_builder = req_builder.header("X-API-KEY", value);
885 };
886
887 let req = req_builder.build()?;
888 let resp = configuration.client.execute(req).await?;
889
890 let status = resp.status();
891 let content_type = resp
892 .headers()
893 .get("content-type")
894 .and_then(|v| v.to_str().ok())
895 .unwrap_or("application/octet-stream");
896 let content_type = super::ContentType::from(content_type);
897
898 if !status.is_client_error() && !status.is_server_error() {
899 let content = resp.text().await?;
900 match content_type {
901 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
902 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VolumeStats`"))),
903 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::VolumeStats`")))),
904 }
905 } else {
906 let content = resp.text().await?;
907 let entity: Option<GetVolumeStatsForVolumeError> = serde_json::from_str(&content).ok();
908 Err(Error::ResponseError(ResponseContent { status, content, entity }))
909 }
910}
911
912pub async fn get_volumes(configuration: &Configuration) -> Result<Vec<models::Volume>, Error<GetVolumesError>> {
913
914 let uri_str = format!("{}/volume", build_url(configuration));
915 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
916
917
918 if let Some(ref token) = configuration.oauth_access_token {
919 req_builder = req_builder.bearer_auth(token.to_owned());
920 };
921 if let Some(ref value) = configuration.api_key {
922 req_builder = req_builder.header("X-API-KEY", value);
923 };
924
925 let req = req_builder.build()?;
926 let resp = configuration.client.execute(req).await?;
927
928 let status = resp.status();
929 let content_type = resp
930 .headers()
931 .get("content-type")
932 .and_then(|v| v.to_str().ok())
933 .unwrap_or("application/octet-stream");
934 let content_type = super::ContentType::from(content_type);
935
936 if !status.is_client_error() && !status.is_server_error() {
937 let content = resp.text().await?;
938 match content_type {
939 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
940 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Volume>`"))),
941 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::Volume>`")))),
942 }
943 } else {
944 let content = resp.text().await?;
945 let entity: Option<GetVolumesError> = serde_json::from_str(&content).ok();
946 Err(Error::ResponseError(ResponseContent { status, content, entity }))
947 }
948}
949
950pub async fn trigger_job(configuration: &Configuration, job_id: &str) -> Result<(), Error<TriggerJobError>> {
951 let p_path_job_id = job_id;
953
954 let uri_str = format!("{}/job/{jobId}", build_url(configuration), jobId=crate::apis::urlencode(p_path_job_id));
955 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
956
957
958 if let Some(ref token) = configuration.oauth_access_token {
959 req_builder = req_builder.bearer_auth(token.to_owned());
960 };
961 if let Some(ref value) = configuration.api_key {
962 req_builder = req_builder.header("X-API-KEY", value);
963 };
964
965 let req = req_builder.build()?;
966 let resp = configuration.client.execute(req).await?;
967
968 let status = resp.status();
969
970 if !status.is_client_error() && !status.is_server_error() {
971 Ok(())
972 } else {
973 let content = resp.text().await?;
974 let entity: Option<TriggerJobError> = serde_json::from_str(&content).ok();
975 Err(Error::ResponseError(ResponseContent { status, content, entity }))
976 }
977}
978
979pub async fn update_job(configuration: &Configuration, job_id: &str) -> Result<models::JobResponse, Error<UpdateJobError>> {
980 let p_path_job_id = job_id;
982
983 let uri_str = format!("{}/job/{jobId}", build_url(configuration), jobId=crate::apis::urlencode(p_path_job_id));
984 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
985
986
987 if let Some(ref token) = configuration.oauth_access_token {
988 req_builder = req_builder.bearer_auth(token.to_owned());
989 };
990 if let Some(ref value) = configuration.api_key {
991 req_builder = req_builder.header("X-API-KEY", 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::JobResponse`"))),
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::JobResponse`")))),
1011 }
1012 } else {
1013 let content = resp.text().await?;
1014 let entity: Option<UpdateJobError> = serde_json::from_str(&content).ok();
1015 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1016 }
1017}
1018
1019pub async fn update_service(configuration: &Configuration, service_id: &str, update_service_request: Option<models::UpdateServiceRequest>) -> Result<models::Service, Error<UpdateServiceError>> {
1020 let p_path_service_id = service_id;
1022 let p_body_update_service_request = update_service_request;
1023
1024 let uri_str = format!("{}/service/{serviceId}", build_url(configuration), serviceId=crate::apis::urlencode(p_path_service_id));
1025 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1026
1027
1028 if let Some(ref token) = configuration.oauth_access_token {
1029 req_builder = req_builder.bearer_auth(token.to_owned());
1030 };
1031 if let Some(ref value) = configuration.api_key {
1032 req_builder = req_builder.header("X-API-KEY", value);
1033 };
1034 req_builder = req_builder.json(&p_body_update_service_request);
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::Service`"))),
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::Service`")))),
1053 }
1054 } else {
1055 let content = resp.text().await?;
1056 let entity: Option<UpdateServiceError> = serde_json::from_str(&content).ok();
1057 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1058 }
1059}
1060
1061pub async fn update_volume(configuration: &Configuration, volume_id: &str, update_volume_request: Option<models::UpdateVolumeRequest>) -> Result<models::Volume, Error<UpdateVolumeError>> {
1062 let p_path_volume_id = volume_id;
1064 let p_body_update_volume_request = update_volume_request;
1065
1066 let uri_str = format!("{}/volume/{volumeId}", build_url(configuration), volumeId=crate::apis::urlencode(p_path_volume_id));
1067 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1068
1069
1070 if let Some(ref token) = configuration.oauth_access_token {
1071 req_builder = req_builder.bearer_auth(token.to_owned());
1072 };
1073 if let Some(ref value) = configuration.api_key {
1074 req_builder = req_builder.header("X-API-KEY", value);
1075 };
1076 req_builder = req_builder.json(&p_body_update_volume_request);
1077
1078 let req = req_builder.build()?;
1079 let resp = configuration.client.execute(req).await?;
1080
1081 let status = resp.status();
1082 let content_type = resp
1083 .headers()
1084 .get("content-type")
1085 .and_then(|v| v.to_str().ok())
1086 .unwrap_or("application/octet-stream");
1087 let content_type = super::ContentType::from(content_type);
1088
1089 if !status.is_client_error() && !status.is_server_error() {
1090 let content = resp.text().await?;
1091 match content_type {
1092 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1093 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Volume`"))),
1094 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::Volume`")))),
1095 }
1096 } else {
1097 let content = resp.text().await?;
1098 let entity: Option<UpdateVolumeError> = serde_json::from_str(&content).ok();
1099 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1100 }
1101}
1102
1103pub async fn verify_domain(configuration: &Configuration, domain_name: &str) -> Result<(), Error<VerifyDomainError>> {
1104 let p_path_domain_name = domain_name;
1106
1107 let uri_str = format!("{}/domain/{domainName}", build_url(configuration), domainName=crate::apis::urlencode(p_path_domain_name));
1108 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1109
1110
1111 if let Some(ref token) = configuration.oauth_access_token {
1112 req_builder = req_builder.bearer_auth(token.to_owned());
1113 };
1114 if let Some(ref value) = configuration.api_key {
1115 req_builder = req_builder.header("X-API-KEY", value);
1116 };
1117
1118 let req = req_builder.build()?;
1119 let resp = configuration.client.execute(req).await?;
1120
1121 let status = resp.status();
1122
1123 if !status.is_client_error() && !status.is_server_error() {
1124 Ok(())
1125 } else {
1126 let content = resp.text().await?;
1127 let entity: Option<VerifyDomainError> = serde_json::from_str(&content).ok();
1128 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1129 }
1130}
1131