1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17#[derive(Clone, Debug)]
19pub struct CreateInstanceParams {
20 pub instance: models::Instance,
22 pub x_request_id: Option<String>
24}
25
26#[derive(Clone, Debug)]
28pub struct CreatePolicyParams {
29 pub project_name: String,
31 pub policy: models::PreheatPolicy,
33 pub x_request_id: Option<String>
35}
36
37#[derive(Clone, Debug)]
39pub struct DeleteInstanceParams {
40 pub preheat_instance_name: String,
42 pub x_request_id: Option<String>
44}
45
46#[derive(Clone, Debug)]
48pub struct DeletePolicyParams {
49 pub project_name: String,
51 pub preheat_policy_name: String,
53 pub x_request_id: Option<String>
55}
56
57#[derive(Clone, Debug)]
59pub struct GetExecutionParams {
60 pub project_name: String,
62 pub preheat_policy_name: String,
64 pub execution_id: i32,
66 pub x_request_id: Option<String>
68}
69
70#[derive(Clone, Debug)]
72pub struct GetInstanceParams {
73 pub preheat_instance_name: String,
75 pub x_request_id: Option<String>
77}
78
79#[derive(Clone, Debug)]
81pub struct GetPolicyParams {
82 pub project_name: String,
84 pub preheat_policy_name: String,
86 pub x_request_id: Option<String>
88}
89
90#[derive(Clone, Debug)]
92pub struct GetPreheatLogParams {
93 pub project_name: String,
95 pub preheat_policy_name: String,
97 pub execution_id: i32,
99 pub task_id: i32,
101 pub x_request_id: Option<String>
103}
104
105#[derive(Clone, Debug)]
107pub struct ListExecutionsParams {
108 pub project_name: String,
110 pub preheat_policy_name: String,
112 pub x_request_id: Option<String>,
114 pub page: Option<i64>,
116 pub page_size: Option<i64>,
118 pub q: Option<String>,
120 pub sort: Option<String>
122}
123
124#[derive(Clone, Debug)]
126pub struct ListInstancesParams {
127 pub x_request_id: Option<String>,
129 pub page: Option<i64>,
131 pub page_size: Option<i64>,
133 pub q: Option<String>,
135 pub sort: Option<String>
137}
138
139#[derive(Clone, Debug)]
141pub struct ListPoliciesParams {
142 pub project_name: String,
144 pub x_request_id: Option<String>,
146 pub page: Option<i64>,
148 pub page_size: Option<i64>,
150 pub q: Option<String>,
152 pub sort: Option<String>
154}
155
156#[derive(Clone, Debug)]
158pub struct ListProvidersParams {
159 pub x_request_id: Option<String>
161}
162
163#[derive(Clone, Debug)]
165pub struct ListProvidersUnderProjectParams {
166 pub project_name: String,
168 pub x_request_id: Option<String>
170}
171
172#[derive(Clone, Debug)]
174pub struct ListTasksParams {
175 pub project_name: String,
177 pub preheat_policy_name: String,
179 pub execution_id: i32,
181 pub x_request_id: Option<String>,
183 pub page: Option<i64>,
185 pub page_size: Option<i64>,
187 pub q: Option<String>,
189 pub sort: Option<String>
191}
192
193#[derive(Clone, Debug)]
195pub struct ManualPreheatParams {
196 pub project_name: String,
198 pub preheat_policy_name: String,
200 pub policy: models::PreheatPolicy,
202 pub x_request_id: Option<String>
204}
205
206#[derive(Clone, Debug)]
208pub struct PingInstancesParams {
209 pub instance: models::Instance,
211 pub x_request_id: Option<String>
213}
214
215#[derive(Clone, Debug)]
217pub struct StopExecutionParams {
218 pub project_name: String,
220 pub preheat_policy_name: String,
222 pub execution_id: i32,
224 pub execution: models::Execution,
226 pub x_request_id: Option<String>
228}
229
230#[derive(Clone, Debug)]
232pub struct UpdateInstanceParams {
233 pub preheat_instance_name: String,
235 pub instance: models::Instance,
237 pub x_request_id: Option<String>
239}
240
241#[derive(Clone, Debug)]
243pub struct UpdatePolicyParams {
244 pub project_name: String,
246 pub preheat_policy_name: String,
248 pub policy: models::PreheatPolicy,
250 pub x_request_id: Option<String>
252}
253
254
255#[derive(Debug, Clone, Serialize, Deserialize)]
257#[serde(untagged)]
258pub enum CreateInstanceError {
259 Status400(models::Errors),
260 Status401(models::Errors),
261 Status403(models::Errors),
262 Status404(models::Errors),
263 Status409(models::Errors),
264 Status500(models::Errors),
265 UnknownValue(serde_json::Value),
266}
267
268#[derive(Debug, Clone, Serialize, Deserialize)]
270#[serde(untagged)]
271pub enum CreatePolicyError {
272 Status400(models::Errors),
273 Status401(models::Errors),
274 Status403(models::Errors),
275 Status409(models::Errors),
276 Status500(models::Errors),
277 UnknownValue(serde_json::Value),
278}
279
280#[derive(Debug, Clone, Serialize, Deserialize)]
282#[serde(untagged)]
283pub enum DeleteInstanceError {
284 Status401(models::Errors),
285 Status403(models::Errors),
286 Status404(models::Errors),
287 Status500(models::Errors),
288 UnknownValue(serde_json::Value),
289}
290
291#[derive(Debug, Clone, Serialize, Deserialize)]
293#[serde(untagged)]
294pub enum DeletePolicyError {
295 Status400(models::Errors),
296 Status401(models::Errors),
297 Status403(models::Errors),
298 Status404(models::Errors),
299 Status500(models::Errors),
300 UnknownValue(serde_json::Value),
301}
302
303#[derive(Debug, Clone, Serialize, Deserialize)]
305#[serde(untagged)]
306pub enum GetExecutionError {
307 Status400(models::Errors),
308 Status401(models::Errors),
309 Status403(models::Errors),
310 Status404(models::Errors),
311 Status500(models::Errors),
312 UnknownValue(serde_json::Value),
313}
314
315#[derive(Debug, Clone, Serialize, Deserialize)]
317#[serde(untagged)]
318pub enum GetInstanceError {
319 Status400(models::Errors),
320 Status401(models::Errors),
321 Status403(models::Errors),
322 Status404(models::Errors),
323 Status500(models::Errors),
324 UnknownValue(serde_json::Value),
325}
326
327#[derive(Debug, Clone, Serialize, Deserialize)]
329#[serde(untagged)]
330pub enum GetPolicyError {
331 Status400(models::Errors),
332 Status401(models::Errors),
333 Status403(models::Errors),
334 Status404(models::Errors),
335 Status500(models::Errors),
336 UnknownValue(serde_json::Value),
337}
338
339#[derive(Debug, Clone, Serialize, Deserialize)]
341#[serde(untagged)]
342pub enum GetPreheatLogError {
343 Status400(models::Errors),
344 Status401(models::Errors),
345 Status403(models::Errors),
346 Status404(models::Errors),
347 Status500(models::Errors),
348 UnknownValue(serde_json::Value),
349}
350
351#[derive(Debug, Clone, Serialize, Deserialize)]
353#[serde(untagged)]
354pub enum ListExecutionsError {
355 Status400(models::Errors),
356 Status401(models::Errors),
357 Status403(models::Errors),
358 Status404(models::Errors),
359 Status500(models::Errors),
360 UnknownValue(serde_json::Value),
361}
362
363#[derive(Debug, Clone, Serialize, Deserialize)]
365#[serde(untagged)]
366pub enum ListInstancesError {
367 Status400(models::Errors),
368 Status401(models::Errors),
369 Status403(models::Errors),
370 Status404(models::Errors),
371 Status500(models::Errors),
372 UnknownValue(serde_json::Value),
373}
374
375#[derive(Debug, Clone, Serialize, Deserialize)]
377#[serde(untagged)]
378pub enum ListPoliciesError {
379 Status400(models::Errors),
380 Status401(models::Errors),
381 Status403(models::Errors),
382 Status500(models::Errors),
383 UnknownValue(serde_json::Value),
384}
385
386#[derive(Debug, Clone, Serialize, Deserialize)]
388#[serde(untagged)]
389pub enum ListProvidersError {
390 Status400(models::Errors),
391 Status401(models::Errors),
392 Status403(models::Errors),
393 Status404(models::Errors),
394 Status500(models::Errors),
395 UnknownValue(serde_json::Value),
396}
397
398#[derive(Debug, Clone, Serialize, Deserialize)]
400#[serde(untagged)]
401pub enum ListProvidersUnderProjectError {
402 Status400(models::Errors),
403 Status401(models::Errors),
404 Status403(models::Errors),
405 Status404(models::Errors),
406 Status500(models::Errors),
407 UnknownValue(serde_json::Value),
408}
409
410#[derive(Debug, Clone, Serialize, Deserialize)]
412#[serde(untagged)]
413pub enum ListTasksError {
414 Status400(models::Errors),
415 Status401(models::Errors),
416 Status403(models::Errors),
417 Status404(models::Errors),
418 Status500(models::Errors),
419 UnknownValue(serde_json::Value),
420}
421
422#[derive(Debug, Clone, Serialize, Deserialize)]
424#[serde(untagged)]
425pub enum ManualPreheatError {
426 Status400(models::Errors),
427 Status401(models::Errors),
428 Status403(models::Errors),
429 Status404(models::Errors),
430 Status500(models::Errors),
431 UnknownValue(serde_json::Value),
432}
433
434#[derive(Debug, Clone, Serialize, Deserialize)]
436#[serde(untagged)]
437pub enum PingInstancesError {
438 Status400(models::Errors),
439 Status401(models::Errors),
440 Status404(),
441 Status500(models::Errors),
442 UnknownValue(serde_json::Value),
443}
444
445#[derive(Debug, Clone, Serialize, Deserialize)]
447#[serde(untagged)]
448pub enum StopExecutionError {
449 Status400(models::Errors),
450 Status401(models::Errors),
451 Status403(models::Errors),
452 Status404(models::Errors),
453 Status500(models::Errors),
454 UnknownValue(serde_json::Value),
455}
456
457#[derive(Debug, Clone, Serialize, Deserialize)]
459#[serde(untagged)]
460pub enum UpdateInstanceError {
461 Status400(models::Errors),
462 Status401(models::Errors),
463 Status403(models::Errors),
464 Status404(models::Errors),
465 Status500(models::Errors),
466 UnknownValue(serde_json::Value),
467}
468
469#[derive(Debug, Clone, Serialize, Deserialize)]
471#[serde(untagged)]
472pub enum UpdatePolicyError {
473 Status400(models::Errors),
474 Status401(models::Errors),
475 Status403(models::Errors),
476 Status404(models::Errors),
477 Status409(models::Errors),
478 Status500(models::Errors),
479 UnknownValue(serde_json::Value),
480}
481
482
483pub async fn create_instance(configuration: &configuration::Configuration, params: CreateInstanceParams) -> Result<(), Error<CreateInstanceError>> {
485
486 let uri_str = format!("{}/p2p/preheat/instances", configuration.base_path);
487 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
488
489 if let Some(ref user_agent) = configuration.user_agent {
490 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
491 }
492 if let Some(param_value) = params.x_request_id {
493 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
494 }
495 if let Some(ref auth_conf) = configuration.basic_auth {
496 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
497 };
498 req_builder = req_builder.json(¶ms.instance);
499
500 let req = req_builder.build()?;
501 let resp = configuration.client.execute(req).await?;
502
503 let status = resp.status();
504
505 if !status.is_client_error() && !status.is_server_error() {
506 Ok(())
507 } else {
508 let content = resp.text().await?;
509 let entity: Option<CreateInstanceError> = serde_json::from_str(&content).ok();
510 Err(Error::ResponseError(ResponseContent { status, content, entity }))
511 }
512}
513
514pub async fn create_policy(configuration: &configuration::Configuration, params: CreatePolicyParams) -> Result<(), Error<CreatePolicyError>> {
516
517 let uri_str = format!("{}/projects/{project_name}/preheat/policies", configuration.base_path, project_name=crate::apis::urlencode(params.project_name));
518 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
519
520 if let Some(ref user_agent) = configuration.user_agent {
521 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
522 }
523 if let Some(param_value) = params.x_request_id {
524 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
525 }
526 if let Some(ref auth_conf) = configuration.basic_auth {
527 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
528 };
529 req_builder = req_builder.json(¶ms.policy);
530
531 let req = req_builder.build()?;
532 let resp = configuration.client.execute(req).await?;
533
534 let status = resp.status();
535
536 if !status.is_client_error() && !status.is_server_error() {
537 Ok(())
538 } else {
539 let content = resp.text().await?;
540 let entity: Option<CreatePolicyError> = serde_json::from_str(&content).ok();
541 Err(Error::ResponseError(ResponseContent { status, content, entity }))
542 }
543}
544
545pub async fn delete_instance(configuration: &configuration::Configuration, params: DeleteInstanceParams) -> Result<(), Error<DeleteInstanceError>> {
547
548 let uri_str = format!("{}/p2p/preheat/instances/{preheat_instance_name}", configuration.base_path, preheat_instance_name=crate::apis::urlencode(params.preheat_instance_name));
549 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
550
551 if let Some(ref user_agent) = configuration.user_agent {
552 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
553 }
554 if let Some(param_value) = params.x_request_id {
555 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
556 }
557 if let Some(ref auth_conf) = configuration.basic_auth {
558 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
559 };
560
561 let req = req_builder.build()?;
562 let resp = configuration.client.execute(req).await?;
563
564 let status = resp.status();
565
566 if !status.is_client_error() && !status.is_server_error() {
567 Ok(())
568 } else {
569 let content = resp.text().await?;
570 let entity: Option<DeleteInstanceError> = serde_json::from_str(&content).ok();
571 Err(Error::ResponseError(ResponseContent { status, content, entity }))
572 }
573}
574
575pub async fn delete_policy(configuration: &configuration::Configuration, params: DeletePolicyParams) -> Result<(), Error<DeletePolicyError>> {
577
578 let uri_str = format!("{}/projects/{project_name}/preheat/policies/{preheat_policy_name}", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), preheat_policy_name=crate::apis::urlencode(params.preheat_policy_name));
579 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
580
581 if let Some(ref user_agent) = configuration.user_agent {
582 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
583 }
584 if let Some(param_value) = params.x_request_id {
585 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
586 }
587 if let Some(ref auth_conf) = configuration.basic_auth {
588 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
589 };
590
591 let req = req_builder.build()?;
592 let resp = configuration.client.execute(req).await?;
593
594 let status = resp.status();
595
596 if !status.is_client_error() && !status.is_server_error() {
597 Ok(())
598 } else {
599 let content = resp.text().await?;
600 let entity: Option<DeletePolicyError> = serde_json::from_str(&content).ok();
601 Err(Error::ResponseError(ResponseContent { status, content, entity }))
602 }
603}
604
605pub async fn get_execution(configuration: &configuration::Configuration, params: GetExecutionParams) -> Result<models::Execution, Error<GetExecutionError>> {
607
608 let uri_str = format!("{}/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), preheat_policy_name=crate::apis::urlencode(params.preheat_policy_name), execution_id=params.execution_id);
609 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
610
611 if let Some(ref user_agent) = configuration.user_agent {
612 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
613 }
614 if let Some(param_value) = params.x_request_id {
615 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
616 }
617 if let Some(ref auth_conf) = configuration.basic_auth {
618 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
619 };
620
621 let req = req_builder.build()?;
622 let resp = configuration.client.execute(req).await?;
623
624 let status = resp.status();
625 let content_type = resp
626 .headers()
627 .get("content-type")
628 .and_then(|v| v.to_str().ok())
629 .unwrap_or("application/octet-stream");
630 let content_type = super::ContentType::from(content_type);
631
632 if !status.is_client_error() && !status.is_server_error() {
633 let content = resp.text().await?;
634 match content_type {
635 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
636 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Execution`"))),
637 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::Execution`")))),
638 }
639 } else {
640 let content = resp.text().await?;
641 let entity: Option<GetExecutionError> = serde_json::from_str(&content).ok();
642 Err(Error::ResponseError(ResponseContent { status, content, entity }))
643 }
644}
645
646pub async fn get_instance(configuration: &configuration::Configuration, params: GetInstanceParams) -> Result<models::Instance, Error<GetInstanceError>> {
648
649 let uri_str = format!("{}/p2p/preheat/instances/{preheat_instance_name}", configuration.base_path, preheat_instance_name=crate::apis::urlencode(params.preheat_instance_name));
650 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
651
652 if let Some(ref user_agent) = configuration.user_agent {
653 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
654 }
655 if let Some(param_value) = params.x_request_id {
656 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
657 }
658 if let Some(ref auth_conf) = configuration.basic_auth {
659 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
660 };
661
662 let req = req_builder.build()?;
663 let resp = configuration.client.execute(req).await?;
664
665 let status = resp.status();
666 let content_type = resp
667 .headers()
668 .get("content-type")
669 .and_then(|v| v.to_str().ok())
670 .unwrap_or("application/octet-stream");
671 let content_type = super::ContentType::from(content_type);
672
673 if !status.is_client_error() && !status.is_server_error() {
674 let content = resp.text().await?;
675 match content_type {
676 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
677 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Instance`"))),
678 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::Instance`")))),
679 }
680 } else {
681 let content = resp.text().await?;
682 let entity: Option<GetInstanceError> = serde_json::from_str(&content).ok();
683 Err(Error::ResponseError(ResponseContent { status, content, entity }))
684 }
685}
686
687pub async fn get_policy(configuration: &configuration::Configuration, params: GetPolicyParams) -> Result<models::PreheatPolicy, Error<GetPolicyError>> {
689
690 let uri_str = format!("{}/projects/{project_name}/preheat/policies/{preheat_policy_name}", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), preheat_policy_name=crate::apis::urlencode(params.preheat_policy_name));
691 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
692
693 if let Some(ref user_agent) = configuration.user_agent {
694 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
695 }
696 if let Some(param_value) = params.x_request_id {
697 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
698 }
699 if let Some(ref auth_conf) = configuration.basic_auth {
700 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
701 };
702
703 let req = req_builder.build()?;
704 let resp = configuration.client.execute(req).await?;
705
706 let status = resp.status();
707 let content_type = resp
708 .headers()
709 .get("content-type")
710 .and_then(|v| v.to_str().ok())
711 .unwrap_or("application/octet-stream");
712 let content_type = super::ContentType::from(content_type);
713
714 if !status.is_client_error() && !status.is_server_error() {
715 let content = resp.text().await?;
716 match content_type {
717 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
718 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PreheatPolicy`"))),
719 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::PreheatPolicy`")))),
720 }
721 } else {
722 let content = resp.text().await?;
723 let entity: Option<GetPolicyError> = serde_json::from_str(&content).ok();
724 Err(Error::ResponseError(ResponseContent { status, content, entity }))
725 }
726}
727
728pub async fn get_preheat_log(configuration: &configuration::Configuration, params: GetPreheatLogParams) -> Result<String, Error<GetPreheatLogError>> {
730
731 let uri_str = format!("{}/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}/tasks/{task_id}/logs", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), preheat_policy_name=crate::apis::urlencode(params.preheat_policy_name), execution_id=params.execution_id, task_id=params.task_id);
732 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
733
734 if let Some(ref user_agent) = configuration.user_agent {
735 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
736 }
737 if let Some(param_value) = params.x_request_id {
738 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
739 }
740 if let Some(ref auth_conf) = configuration.basic_auth {
741 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
742 };
743
744 let req = req_builder.build()?;
745 let resp = configuration.client.execute(req).await?;
746
747 let status = resp.status();
748 let content_type = resp
749 .headers()
750 .get("content-type")
751 .and_then(|v| v.to_str().ok())
752 .unwrap_or("application/octet-stream");
753 let content_type = super::ContentType::from(content_type);
754
755 if !status.is_client_error() && !status.is_server_error() {
756 let content = resp.text().await?;
757 match content_type {
758 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
759 ContentType::Text => return Ok(content),
760 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
761 }
762 } else {
763 let content = resp.text().await?;
764 let entity: Option<GetPreheatLogError> = serde_json::from_str(&content).ok();
765 Err(Error::ResponseError(ResponseContent { status, content, entity }))
766 }
767}
768
769pub async fn list_executions(configuration: &configuration::Configuration, params: ListExecutionsParams) -> Result<Vec<models::Execution>, Error<ListExecutionsError>> {
771
772 let uri_str = format!("{}/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), preheat_policy_name=crate::apis::urlencode(params.preheat_policy_name));
773 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
774
775 if let Some(ref param_value) = params.page {
776 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
777 }
778 if let Some(ref param_value) = params.page_size {
779 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
780 }
781 if let Some(ref param_value) = params.q {
782 req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
783 }
784 if let Some(ref param_value) = params.sort {
785 req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
786 }
787 if let Some(ref user_agent) = configuration.user_agent {
788 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
789 }
790 if let Some(param_value) = params.x_request_id {
791 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
792 }
793 if let Some(ref auth_conf) = configuration.basic_auth {
794 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
795 };
796
797 let req = req_builder.build()?;
798 let resp = configuration.client.execute(req).await?;
799
800 let status = resp.status();
801 let content_type = resp
802 .headers()
803 .get("content-type")
804 .and_then(|v| v.to_str().ok())
805 .unwrap_or("application/octet-stream");
806 let content_type = super::ContentType::from(content_type);
807
808 if !status.is_client_error() && !status.is_server_error() {
809 let content = resp.text().await?;
810 match content_type {
811 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
812 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Execution>`"))),
813 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::Execution>`")))),
814 }
815 } else {
816 let content = resp.text().await?;
817 let entity: Option<ListExecutionsError> = serde_json::from_str(&content).ok();
818 Err(Error::ResponseError(ResponseContent { status, content, entity }))
819 }
820}
821
822pub async fn list_instances(configuration: &configuration::Configuration, params: ListInstancesParams) -> Result<Vec<models::Instance>, Error<ListInstancesError>> {
824
825 let uri_str = format!("{}/p2p/preheat/instances", configuration.base_path);
826 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
827
828 if let Some(ref param_value) = params.page {
829 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
830 }
831 if let Some(ref param_value) = params.page_size {
832 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
833 }
834 if let Some(ref param_value) = params.q {
835 req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
836 }
837 if let Some(ref param_value) = params.sort {
838 req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
839 }
840 if let Some(ref user_agent) = configuration.user_agent {
841 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
842 }
843 if let Some(param_value) = params.x_request_id {
844 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
845 }
846 if let Some(ref auth_conf) = configuration.basic_auth {
847 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
848 };
849
850 let req = req_builder.build()?;
851 let resp = configuration.client.execute(req).await?;
852
853 let status = resp.status();
854 let content_type = resp
855 .headers()
856 .get("content-type")
857 .and_then(|v| v.to_str().ok())
858 .unwrap_or("application/octet-stream");
859 let content_type = super::ContentType::from(content_type);
860
861 if !status.is_client_error() && !status.is_server_error() {
862 let content = resp.text().await?;
863 match content_type {
864 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
865 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Instance>`"))),
866 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::Instance>`")))),
867 }
868 } else {
869 let content = resp.text().await?;
870 let entity: Option<ListInstancesError> = serde_json::from_str(&content).ok();
871 Err(Error::ResponseError(ResponseContent { status, content, entity }))
872 }
873}
874
875pub async fn list_policies(configuration: &configuration::Configuration, params: ListPoliciesParams) -> Result<Vec<models::PreheatPolicy>, Error<ListPoliciesError>> {
877
878 let uri_str = format!("{}/projects/{project_name}/preheat/policies", configuration.base_path, project_name=crate::apis::urlencode(params.project_name));
879 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
880
881 if let Some(ref param_value) = params.page {
882 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
883 }
884 if let Some(ref param_value) = params.page_size {
885 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
886 }
887 if let Some(ref param_value) = params.q {
888 req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
889 }
890 if let Some(ref param_value) = params.sort {
891 req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
892 }
893 if let Some(ref user_agent) = configuration.user_agent {
894 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
895 }
896 if let Some(param_value) = params.x_request_id {
897 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
898 }
899 if let Some(ref auth_conf) = configuration.basic_auth {
900 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
901 };
902
903 let req = req_builder.build()?;
904 let resp = configuration.client.execute(req).await?;
905
906 let status = resp.status();
907 let content_type = resp
908 .headers()
909 .get("content-type")
910 .and_then(|v| v.to_str().ok())
911 .unwrap_or("application/octet-stream");
912 let content_type = super::ContentType::from(content_type);
913
914 if !status.is_client_error() && !status.is_server_error() {
915 let content = resp.text().await?;
916 match content_type {
917 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
918 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PreheatPolicy>`"))),
919 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::PreheatPolicy>`")))),
920 }
921 } else {
922 let content = resp.text().await?;
923 let entity: Option<ListPoliciesError> = serde_json::from_str(&content).ok();
924 Err(Error::ResponseError(ResponseContent { status, content, entity }))
925 }
926}
927
928pub async fn list_providers(configuration: &configuration::Configuration, params: ListProvidersParams) -> Result<Vec<models::Metadata>, Error<ListProvidersError>> {
930
931 let uri_str = format!("{}/p2p/preheat/providers", configuration.base_path);
932 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
933
934 if let Some(ref user_agent) = configuration.user_agent {
935 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
936 }
937 if let Some(param_value) = params.x_request_id {
938 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
939 }
940 if let Some(ref auth_conf) = configuration.basic_auth {
941 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
942 };
943
944 let req = req_builder.build()?;
945 let resp = configuration.client.execute(req).await?;
946
947 let status = resp.status();
948 let content_type = resp
949 .headers()
950 .get("content-type")
951 .and_then(|v| v.to_str().ok())
952 .unwrap_or("application/octet-stream");
953 let content_type = super::ContentType::from(content_type);
954
955 if !status.is_client_error() && !status.is_server_error() {
956 let content = resp.text().await?;
957 match content_type {
958 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
959 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Metadata>`"))),
960 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::Metadata>`")))),
961 }
962 } else {
963 let content = resp.text().await?;
964 let entity: Option<ListProvidersError> = serde_json::from_str(&content).ok();
965 Err(Error::ResponseError(ResponseContent { status, content, entity }))
966 }
967}
968
969pub async fn list_providers_under_project(configuration: &configuration::Configuration, params: ListProvidersUnderProjectParams) -> Result<Vec<models::ProviderUnderProject>, Error<ListProvidersUnderProjectError>> {
971
972 let uri_str = format!("{}/projects/{project_name}/preheat/providers", configuration.base_path, project_name=crate::apis::urlencode(params.project_name));
973 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
974
975 if let Some(ref user_agent) = configuration.user_agent {
976 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
977 }
978 if let Some(param_value) = params.x_request_id {
979 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
980 }
981 if let Some(ref auth_conf) = configuration.basic_auth {
982 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
983 };
984
985 let req = req_builder.build()?;
986 let resp = configuration.client.execute(req).await?;
987
988 let status = resp.status();
989 let content_type = resp
990 .headers()
991 .get("content-type")
992 .and_then(|v| v.to_str().ok())
993 .unwrap_or("application/octet-stream");
994 let content_type = super::ContentType::from(content_type);
995
996 if !status.is_client_error() && !status.is_server_error() {
997 let content = resp.text().await?;
998 match content_type {
999 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1000 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ProviderUnderProject>`"))),
1001 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::ProviderUnderProject>`")))),
1002 }
1003 } else {
1004 let content = resp.text().await?;
1005 let entity: Option<ListProvidersUnderProjectError> = serde_json::from_str(&content).ok();
1006 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1007 }
1008}
1009
1010pub async fn list_tasks(configuration: &configuration::Configuration, params: ListTasksParams) -> Result<Vec<models::Task>, Error<ListTasksError>> {
1012
1013 let uri_str = format!("{}/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}/tasks", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), preheat_policy_name=crate::apis::urlencode(params.preheat_policy_name), execution_id=params.execution_id);
1014 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1015
1016 if let Some(ref param_value) = params.page {
1017 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
1018 }
1019 if let Some(ref param_value) = params.page_size {
1020 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
1021 }
1022 if let Some(ref param_value) = params.q {
1023 req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
1024 }
1025 if let Some(ref param_value) = params.sort {
1026 req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
1027 }
1028 if let Some(ref user_agent) = configuration.user_agent {
1029 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1030 }
1031 if let Some(param_value) = params.x_request_id {
1032 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
1033 }
1034 if let Some(ref auth_conf) = configuration.basic_auth {
1035 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
1036 };
1037
1038 let req = req_builder.build()?;
1039 let resp = configuration.client.execute(req).await?;
1040
1041 let status = resp.status();
1042 let content_type = resp
1043 .headers()
1044 .get("content-type")
1045 .and_then(|v| v.to_str().ok())
1046 .unwrap_or("application/octet-stream");
1047 let content_type = super::ContentType::from(content_type);
1048
1049 if !status.is_client_error() && !status.is_server_error() {
1050 let content = resp.text().await?;
1051 match content_type {
1052 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1053 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Task>`"))),
1054 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::Task>`")))),
1055 }
1056 } else {
1057 let content = resp.text().await?;
1058 let entity: Option<ListTasksError> = serde_json::from_str(&content).ok();
1059 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1060 }
1061}
1062
1063pub async fn manual_preheat(configuration: &configuration::Configuration, params: ManualPreheatParams) -> Result<(), Error<ManualPreheatError>> {
1065
1066 let uri_str = format!("{}/projects/{project_name}/preheat/policies/{preheat_policy_name}", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), preheat_policy_name=crate::apis::urlencode(params.preheat_policy_name));
1067 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1068
1069 if let Some(ref user_agent) = configuration.user_agent {
1070 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1071 }
1072 if let Some(param_value) = params.x_request_id {
1073 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
1074 }
1075 if let Some(ref auth_conf) = configuration.basic_auth {
1076 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
1077 };
1078 req_builder = req_builder.json(¶ms.policy);
1079
1080 let req = req_builder.build()?;
1081 let resp = configuration.client.execute(req).await?;
1082
1083 let status = resp.status();
1084
1085 if !status.is_client_error() && !status.is_server_error() {
1086 Ok(())
1087 } else {
1088 let content = resp.text().await?;
1089 let entity: Option<ManualPreheatError> = serde_json::from_str(&content).ok();
1090 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1091 }
1092}
1093
1094pub async fn ping_instances(configuration: &configuration::Configuration, params: PingInstancesParams) -> Result<(), Error<PingInstancesError>> {
1096
1097 let uri_str = format!("{}/p2p/preheat/instances/ping", configuration.base_path);
1098 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1099
1100 if let Some(ref user_agent) = configuration.user_agent {
1101 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1102 }
1103 if let Some(param_value) = params.x_request_id {
1104 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
1105 }
1106 if let Some(ref auth_conf) = configuration.basic_auth {
1107 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
1108 };
1109 req_builder = req_builder.json(¶ms.instance);
1110
1111 let req = req_builder.build()?;
1112 let resp = configuration.client.execute(req).await?;
1113
1114 let status = resp.status();
1115
1116 if !status.is_client_error() && !status.is_server_error() {
1117 Ok(())
1118 } else {
1119 let content = resp.text().await?;
1120 let entity: Option<PingInstancesError> = serde_json::from_str(&content).ok();
1121 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1122 }
1123}
1124
1125pub async fn stop_execution(configuration: &configuration::Configuration, params: StopExecutionParams) -> Result<(), Error<StopExecutionError>> {
1127
1128 let uri_str = format!("{}/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), preheat_policy_name=crate::apis::urlencode(params.preheat_policy_name), execution_id=params.execution_id);
1129 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1130
1131 if let Some(ref user_agent) = configuration.user_agent {
1132 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1133 }
1134 if let Some(param_value) = params.x_request_id {
1135 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
1136 }
1137 if let Some(ref auth_conf) = configuration.basic_auth {
1138 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
1139 };
1140 req_builder = req_builder.json(¶ms.execution);
1141
1142 let req = req_builder.build()?;
1143 let resp = configuration.client.execute(req).await?;
1144
1145 let status = resp.status();
1146
1147 if !status.is_client_error() && !status.is_server_error() {
1148 Ok(())
1149 } else {
1150 let content = resp.text().await?;
1151 let entity: Option<StopExecutionError> = serde_json::from_str(&content).ok();
1152 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1153 }
1154}
1155
1156pub async fn update_instance(configuration: &configuration::Configuration, params: UpdateInstanceParams) -> Result<(), Error<UpdateInstanceError>> {
1158
1159 let uri_str = format!("{}/p2p/preheat/instances/{preheat_instance_name}", configuration.base_path, preheat_instance_name=crate::apis::urlencode(params.preheat_instance_name));
1160 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1161
1162 if let Some(ref user_agent) = configuration.user_agent {
1163 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1164 }
1165 if let Some(param_value) = params.x_request_id {
1166 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
1167 }
1168 if let Some(ref auth_conf) = configuration.basic_auth {
1169 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
1170 };
1171 req_builder = req_builder.json(¶ms.instance);
1172
1173 let req = req_builder.build()?;
1174 let resp = configuration.client.execute(req).await?;
1175
1176 let status = resp.status();
1177
1178 if !status.is_client_error() && !status.is_server_error() {
1179 Ok(())
1180 } else {
1181 let content = resp.text().await?;
1182 let entity: Option<UpdateInstanceError> = serde_json::from_str(&content).ok();
1183 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1184 }
1185}
1186
1187pub async fn update_policy(configuration: &configuration::Configuration, params: UpdatePolicyParams) -> Result<(), Error<UpdatePolicyError>> {
1189
1190 let uri_str = format!("{}/projects/{project_name}/preheat/policies/{preheat_policy_name}", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), preheat_policy_name=crate::apis::urlencode(params.preheat_policy_name));
1191 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1192
1193 if let Some(ref user_agent) = configuration.user_agent {
1194 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1195 }
1196 if let Some(param_value) = params.x_request_id {
1197 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
1198 }
1199 if let Some(ref auth_conf) = configuration.basic_auth {
1200 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
1201 };
1202 req_builder = req_builder.json(¶ms.policy);
1203
1204 let req = req_builder.build()?;
1205 let resp = configuration.client.execute(req).await?;
1206
1207 let status = resp.status();
1208
1209 if !status.is_client_error() && !status.is_server_error() {
1210 Ok(())
1211 } else {
1212 let content = resp.text().await?;
1213 let entity: Option<UpdatePolicyError> = serde_json::from_str(&content).ok();
1214 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1215 }
1216}
1217