harbor_api/apis/
preheat_api.rs

1/*
2 * Harbor API
3 *
4 * These APIs provide services for manipulating Harbor project.
5 *
6 * The version of the OpenAPI document: 2.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`create_instance`]
18#[derive(Clone, Debug)]
19pub struct CreateInstanceParams {
20    /// The JSON object of instance.
21    pub instance: models::Instance,
22    /// An unique ID for the request
23    pub x_request_id: Option<String>
24}
25
26/// struct for passing parameters to the method [`create_policy`]
27#[derive(Clone, Debug)]
28pub struct CreatePolicyParams {
29    /// The name of the project
30    pub project_name: String,
31    /// The policy schema info
32    pub policy: models::PreheatPolicy,
33    /// An unique ID for the request
34    pub x_request_id: Option<String>
35}
36
37/// struct for passing parameters to the method [`delete_instance`]
38#[derive(Clone, Debug)]
39pub struct DeleteInstanceParams {
40    /// Instance Name
41    pub preheat_instance_name: String,
42    /// An unique ID for the request
43    pub x_request_id: Option<String>
44}
45
46/// struct for passing parameters to the method [`delete_policy`]
47#[derive(Clone, Debug)]
48pub struct DeletePolicyParams {
49    /// The name of the project
50    pub project_name: String,
51    /// Preheat Policy Name
52    pub preheat_policy_name: String,
53    /// An unique ID for the request
54    pub x_request_id: Option<String>
55}
56
57/// struct for passing parameters to the method [`get_execution`]
58#[derive(Clone, Debug)]
59pub struct GetExecutionParams {
60    /// The name of the project
61    pub project_name: String,
62    /// Preheat Policy Name
63    pub preheat_policy_name: String,
64    /// Execution ID
65    pub execution_id: i32,
66    /// An unique ID for the request
67    pub x_request_id: Option<String>
68}
69
70/// struct for passing parameters to the method [`get_instance`]
71#[derive(Clone, Debug)]
72pub struct GetInstanceParams {
73    /// Instance Name
74    pub preheat_instance_name: String,
75    /// An unique ID for the request
76    pub x_request_id: Option<String>
77}
78
79/// struct for passing parameters to the method [`get_policy`]
80#[derive(Clone, Debug)]
81pub struct GetPolicyParams {
82    /// The name of the project
83    pub project_name: String,
84    /// Preheat Policy Name
85    pub preheat_policy_name: String,
86    /// An unique ID for the request
87    pub x_request_id: Option<String>
88}
89
90/// struct for passing parameters to the method [`get_preheat_log`]
91#[derive(Clone, Debug)]
92pub struct GetPreheatLogParams {
93    /// The name of the project
94    pub project_name: String,
95    /// Preheat Policy Name
96    pub preheat_policy_name: String,
97    /// Execution ID
98    pub execution_id: i32,
99    /// Task ID
100    pub task_id: i32,
101    /// An unique ID for the request
102    pub x_request_id: Option<String>
103}
104
105/// struct for passing parameters to the method [`list_executions`]
106#[derive(Clone, Debug)]
107pub struct ListExecutionsParams {
108    /// The name of the project
109    pub project_name: String,
110    /// Preheat Policy Name
111    pub preheat_policy_name: String,
112    /// An unique ID for the request
113    pub x_request_id: Option<String>,
114    /// The page number
115    pub page: Option<i64>,
116    /// The size of per page
117    pub page_size: Option<i64>,
118    /// Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]
119    pub q: Option<String>,
120    /// Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with \"sort=field1,-field2\"
121    pub sort: Option<String>
122}
123
124/// struct for passing parameters to the method [`list_instances`]
125#[derive(Clone, Debug)]
126pub struct ListInstancesParams {
127    /// An unique ID for the request
128    pub x_request_id: Option<String>,
129    /// The page number
130    pub page: Option<i64>,
131    /// The size of per page
132    pub page_size: Option<i64>,
133    /// Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]
134    pub q: Option<String>,
135    /// Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with \"sort=field1,-field2\"
136    pub sort: Option<String>
137}
138
139/// struct for passing parameters to the method [`list_policies`]
140#[derive(Clone, Debug)]
141pub struct ListPoliciesParams {
142    /// The name of the project
143    pub project_name: String,
144    /// An unique ID for the request
145    pub x_request_id: Option<String>,
146    /// The page number
147    pub page: Option<i64>,
148    /// The size of per page
149    pub page_size: Option<i64>,
150    /// Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]
151    pub q: Option<String>,
152    /// Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with \"sort=field1,-field2\"
153    pub sort: Option<String>
154}
155
156/// struct for passing parameters to the method [`list_providers`]
157#[derive(Clone, Debug)]
158pub struct ListProvidersParams {
159    /// An unique ID for the request
160    pub x_request_id: Option<String>
161}
162
163/// struct for passing parameters to the method [`list_providers_under_project`]
164#[derive(Clone, Debug)]
165pub struct ListProvidersUnderProjectParams {
166    /// The name of the project
167    pub project_name: String,
168    /// An unique ID for the request
169    pub x_request_id: Option<String>
170}
171
172/// struct for passing parameters to the method [`list_tasks`]
173#[derive(Clone, Debug)]
174pub struct ListTasksParams {
175    /// The name of the project
176    pub project_name: String,
177    /// Preheat Policy Name
178    pub preheat_policy_name: String,
179    /// Execution ID
180    pub execution_id: i32,
181    /// An unique ID for the request
182    pub x_request_id: Option<String>,
183    /// The page number
184    pub page: Option<i64>,
185    /// The size of per page
186    pub page_size: Option<i64>,
187    /// Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]
188    pub q: Option<String>,
189    /// Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with \"sort=field1,-field2\"
190    pub sort: Option<String>
191}
192
193/// struct for passing parameters to the method [`manual_preheat`]
194#[derive(Clone, Debug)]
195pub struct ManualPreheatParams {
196    /// The name of the project
197    pub project_name: String,
198    /// Preheat Policy Name
199    pub preheat_policy_name: String,
200    /// The policy schema info
201    pub policy: models::PreheatPolicy,
202    /// An unique ID for the request
203    pub x_request_id: Option<String>
204}
205
206/// struct for passing parameters to the method [`ping_instances`]
207#[derive(Clone, Debug)]
208pub struct PingInstancesParams {
209    /// The JSON object of instance.
210    pub instance: models::Instance,
211    /// An unique ID for the request
212    pub x_request_id: Option<String>
213}
214
215/// struct for passing parameters to the method [`stop_execution`]
216#[derive(Clone, Debug)]
217pub struct StopExecutionParams {
218    /// The name of the project
219    pub project_name: String,
220    /// Preheat Policy Name
221    pub preheat_policy_name: String,
222    /// Execution ID
223    pub execution_id: i32,
224    /// The data of execution
225    pub execution: models::Execution,
226    /// An unique ID for the request
227    pub x_request_id: Option<String>
228}
229
230/// struct for passing parameters to the method [`update_instance`]
231#[derive(Clone, Debug)]
232pub struct UpdateInstanceParams {
233    /// Instance Name
234    pub preheat_instance_name: String,
235    /// The instance to update
236    pub instance: models::Instance,
237    /// An unique ID for the request
238    pub x_request_id: Option<String>
239}
240
241/// struct for passing parameters to the method [`update_policy`]
242#[derive(Clone, Debug)]
243pub struct UpdatePolicyParams {
244    /// The name of the project
245    pub project_name: String,
246    /// Preheat Policy Name
247    pub preheat_policy_name: String,
248    /// The policy schema info
249    pub policy: models::PreheatPolicy,
250    /// An unique ID for the request
251    pub x_request_id: Option<String>
252}
253
254
255/// struct for typed errors of method [`create_instance`]
256#[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/// struct for typed errors of method [`create_policy`]
269#[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/// struct for typed errors of method [`delete_instance`]
281#[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/// struct for typed errors of method [`delete_policy`]
292#[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/// struct for typed errors of method [`get_execution`]
304#[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/// struct for typed errors of method [`get_instance`]
316#[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/// struct for typed errors of method [`get_policy`]
328#[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/// struct for typed errors of method [`get_preheat_log`]
340#[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/// struct for typed errors of method [`list_executions`]
352#[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/// struct for typed errors of method [`list_instances`]
364#[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/// struct for typed errors of method [`list_policies`]
376#[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/// struct for typed errors of method [`list_providers`]
387#[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/// struct for typed errors of method [`list_providers_under_project`]
399#[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/// struct for typed errors of method [`list_tasks`]
411#[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/// struct for typed errors of method [`manual_preheat`]
423#[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/// struct for typed errors of method [`ping_instances`]
435#[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/// struct for typed errors of method [`stop_execution`]
446#[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/// struct for typed errors of method [`update_instance`]
458#[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/// struct for typed errors of method [`update_policy`]
470#[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
483/// Create p2p provider instances
484pub 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(&params.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
514/// Create a preheat policy under a project
515pub 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(&params.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
545/// Delete the specified P2P provider instance
546pub 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
575/// Delete a preheat policy
576pub 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
605/// Get a execution detail by id
606pub 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
646/// Get a P2P provider instance
647pub 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
687/// Get a preheat policy
688pub 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
728/// Get the log text stream of the specified task for the given execution
729pub 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
769/// List executions for the given policy
770pub 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", &param_value.to_string())]);
777    }
778    if let Some(ref param_value) = params.page_size {
779        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
780    }
781    if let Some(ref param_value) = params.q {
782        req_builder = req_builder.query(&[("q", &param_value.to_string())]);
783    }
784    if let Some(ref param_value) = params.sort {
785        req_builder = req_builder.query(&[("sort", &param_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&lt;models::Execution&gt;`"))),
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&lt;models::Execution&gt;`")))),
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
822/// List P2P provider instances
823pub 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", &param_value.to_string())]);
830    }
831    if let Some(ref param_value) = params.page_size {
832        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
833    }
834    if let Some(ref param_value) = params.q {
835        req_builder = req_builder.query(&[("q", &param_value.to_string())]);
836    }
837    if let Some(ref param_value) = params.sort {
838        req_builder = req_builder.query(&[("sort", &param_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&lt;models::Instance&gt;`"))),
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&lt;models::Instance&gt;`")))),
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
875/// List preheat policies
876pub 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", &param_value.to_string())]);
883    }
884    if let Some(ref param_value) = params.page_size {
885        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
886    }
887    if let Some(ref param_value) = params.q {
888        req_builder = req_builder.query(&[("q", &param_value.to_string())]);
889    }
890    if let Some(ref param_value) = params.sort {
891        req_builder = req_builder.query(&[("sort", &param_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&lt;models::PreheatPolicy&gt;`"))),
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&lt;models::PreheatPolicy&gt;`")))),
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
928/// List P2P providers
929pub 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&lt;models::Metadata&gt;`"))),
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&lt;models::Metadata&gt;`")))),
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
969/// Get all providers at project level
970pub 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&lt;models::ProviderUnderProject&gt;`"))),
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&lt;models::ProviderUnderProject&gt;`")))),
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
1010/// List all the related tasks for the given execution
1011pub 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", &param_value.to_string())]);
1018    }
1019    if let Some(ref param_value) = params.page_size {
1020        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
1021    }
1022    if let Some(ref param_value) = params.q {
1023        req_builder = req_builder.query(&[("q", &param_value.to_string())]);
1024    }
1025    if let Some(ref param_value) = params.sort {
1026        req_builder = req_builder.query(&[("sort", &param_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&lt;models::Task&gt;`"))),
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&lt;models::Task&gt;`")))),
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
1063/// Manual preheat
1064pub 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(&params.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
1094/// This endpoint checks status of a instance, the instance can be given by ID or Endpoint URL (together with credential) 
1095pub 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(&params.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
1125/// Stop a execution
1126pub 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(&params.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
1156/// Update the specified P2P provider instance
1157pub 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(&params.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
1187/// Update preheat policy
1188pub 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(&params.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