harbor_api/apis/
replication_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_replication_policy`]
18#[derive(Clone, Debug)]
19pub struct CreateReplicationPolicyParams {
20    /// The replication policy
21    pub policy: models::ReplicationPolicy,
22    /// An unique ID for the request
23    pub x_request_id: Option<String>
24}
25
26/// struct for passing parameters to the method [`delete_replication_policy`]
27#[derive(Clone, Debug)]
28pub struct DeleteReplicationPolicyParams {
29    /// Replication policy ID
30    pub id: i64,
31    /// An unique ID for the request
32    pub x_request_id: Option<String>
33}
34
35/// struct for passing parameters to the method [`get_replication_execution`]
36#[derive(Clone, Debug)]
37pub struct GetReplicationExecutionParams {
38    /// The ID of the execution.
39    pub id: i64,
40    /// An unique ID for the request
41    pub x_request_id: Option<String>
42}
43
44/// struct for passing parameters to the method [`get_replication_log`]
45#[derive(Clone, Debug)]
46pub struct GetReplicationLogParams {
47    /// The ID of the execution that the tasks belongs to.
48    pub id: i64,
49    /// The ID of the task.
50    pub task_id: i64,
51    /// An unique ID for the request
52    pub x_request_id: Option<String>
53}
54
55/// struct for passing parameters to the method [`get_replication_policy`]
56#[derive(Clone, Debug)]
57pub struct GetReplicationPolicyParams {
58    /// Policy ID
59    pub id: i64,
60    /// An unique ID for the request
61    pub x_request_id: Option<String>
62}
63
64/// struct for passing parameters to the method [`list_replication_executions`]
65#[derive(Clone, Debug)]
66pub struct ListReplicationExecutionsParams {
67    /// An unique ID for the request
68    pub x_request_id: Option<String>,
69    /// 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\"
70    pub sort: Option<String>,
71    /// The page number
72    pub page: Option<i64>,
73    /// The size of per page
74    pub page_size: Option<i64>,
75    /// The ID of the policy that the executions belong to.
76    pub policy_id: Option<i32>,
77    /// The execution status.
78    pub status: Option<String>,
79    /// The trigger mode.
80    pub trigger: Option<String>
81}
82
83/// struct for passing parameters to the method [`list_replication_policies`]
84#[derive(Clone, Debug)]
85pub struct ListReplicationPoliciesParams {
86    /// An unique ID for the request
87    pub x_request_id: Option<String>,
88    /// 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]
89    pub q: Option<String>,
90    /// 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\"
91    pub sort: Option<String>,
92    /// The page number
93    pub page: Option<i64>,
94    /// The size of per page
95    pub page_size: Option<i64>,
96    /// Deprecated, use \"query\" instead. The policy name.
97    pub name: Option<String>
98}
99
100/// struct for passing parameters to the method [`list_replication_tasks`]
101#[derive(Clone, Debug)]
102pub struct ListReplicationTasksParams {
103    /// The ID of the execution that the tasks belongs to.
104    pub id: i64,
105    /// An unique ID for the request
106    pub x_request_id: Option<String>,
107    /// 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\"
108    pub sort: Option<String>,
109    /// The page number
110    pub page: Option<i64>,
111    /// The size of per page
112    pub page_size: Option<i64>,
113    /// The task status.
114    pub status: Option<String>,
115    /// The resource type.
116    pub resource_type: Option<String>
117}
118
119/// struct for passing parameters to the method [`start_replication`]
120#[derive(Clone, Debug)]
121pub struct StartReplicationParams {
122    /// The ID of policy that the execution belongs to
123    pub execution: models::StartReplicationExecution,
124    /// An unique ID for the request
125    pub x_request_id: Option<String>
126}
127
128/// struct for passing parameters to the method [`stop_replication`]
129#[derive(Clone, Debug)]
130pub struct StopReplicationParams {
131    /// The ID of the execution.
132    pub id: i64,
133    /// An unique ID for the request
134    pub x_request_id: Option<String>
135}
136
137/// struct for passing parameters to the method [`update_replication_policy`]
138#[derive(Clone, Debug)]
139pub struct UpdateReplicationPolicyParams {
140    /// The policy ID
141    pub id: i64,
142    /// The replication policy
143    pub policy: models::ReplicationPolicy,
144    /// An unique ID for the request
145    pub x_request_id: Option<String>
146}
147
148
149/// struct for typed errors of method [`create_replication_policy`]
150#[derive(Debug, Clone, Serialize, Deserialize)]
151#[serde(untagged)]
152pub enum CreateReplicationPolicyError {
153    Status400(models::Errors),
154    Status401(models::Errors),
155    Status403(models::Errors),
156    Status409(models::Errors),
157    Status500(models::Errors),
158    UnknownValue(serde_json::Value),
159}
160
161/// struct for typed errors of method [`delete_replication_policy`]
162#[derive(Debug, Clone, Serialize, Deserialize)]
163#[serde(untagged)]
164pub enum DeleteReplicationPolicyError {
165    Status401(models::Errors),
166    Status403(models::Errors),
167    Status404(models::Errors),
168    Status412(models::Errors),
169    Status500(models::Errors),
170    UnknownValue(serde_json::Value),
171}
172
173/// struct for typed errors of method [`get_replication_execution`]
174#[derive(Debug, Clone, Serialize, Deserialize)]
175#[serde(untagged)]
176pub enum GetReplicationExecutionError {
177    Status401(models::Errors),
178    Status403(models::Errors),
179    Status404(models::Errors),
180    Status500(models::Errors),
181    UnknownValue(serde_json::Value),
182}
183
184/// struct for typed errors of method [`get_replication_log`]
185#[derive(Debug, Clone, Serialize, Deserialize)]
186#[serde(untagged)]
187pub enum GetReplicationLogError {
188    Status401(models::Errors),
189    Status403(models::Errors),
190    Status404(models::Errors),
191    Status500(models::Errors),
192    UnknownValue(serde_json::Value),
193}
194
195/// struct for typed errors of method [`get_replication_policy`]
196#[derive(Debug, Clone, Serialize, Deserialize)]
197#[serde(untagged)]
198pub enum GetReplicationPolicyError {
199    Status401(models::Errors),
200    Status403(models::Errors),
201    Status500(models::Errors),
202    UnknownValue(serde_json::Value),
203}
204
205/// struct for typed errors of method [`list_replication_executions`]
206#[derive(Debug, Clone, Serialize, Deserialize)]
207#[serde(untagged)]
208pub enum ListReplicationExecutionsError {
209    Status401(models::Errors),
210    Status403(models::Errors),
211    Status500(models::Errors),
212    UnknownValue(serde_json::Value),
213}
214
215/// struct for typed errors of method [`list_replication_policies`]
216#[derive(Debug, Clone, Serialize, Deserialize)]
217#[serde(untagged)]
218pub enum ListReplicationPoliciesError {
219    Status401(models::Errors),
220    Status403(models::Errors),
221    Status500(models::Errors),
222    UnknownValue(serde_json::Value),
223}
224
225/// struct for typed errors of method [`list_replication_tasks`]
226#[derive(Debug, Clone, Serialize, Deserialize)]
227#[serde(untagged)]
228pub enum ListReplicationTasksError {
229    Status401(models::Errors),
230    Status403(models::Errors),
231    Status500(models::Errors),
232    UnknownValue(serde_json::Value),
233}
234
235/// struct for typed errors of method [`start_replication`]
236#[derive(Debug, Clone, Serialize, Deserialize)]
237#[serde(untagged)]
238pub enum StartReplicationError {
239    Status400(models::Errors),
240    Status401(models::Errors),
241    Status403(models::Errors),
242    Status500(models::Errors),
243    UnknownValue(serde_json::Value),
244}
245
246/// struct for typed errors of method [`stop_replication`]
247#[derive(Debug, Clone, Serialize, Deserialize)]
248#[serde(untagged)]
249pub enum StopReplicationError {
250    Status401(models::Errors),
251    Status403(models::Errors),
252    Status404(models::Errors),
253    Status500(models::Errors),
254    UnknownValue(serde_json::Value),
255}
256
257/// struct for typed errors of method [`update_replication_policy`]
258#[derive(Debug, Clone, Serialize, Deserialize)]
259#[serde(untagged)]
260pub enum UpdateReplicationPolicyError {
261    Status401(models::Errors),
262    Status403(models::Errors),
263    Status404(models::Errors),
264    Status409(models::Errors),
265    Status500(models::Errors),
266    UnknownValue(serde_json::Value),
267}
268
269
270/// Create a replication policy
271pub async fn create_replication_policy(configuration: &configuration::Configuration, params: CreateReplicationPolicyParams) -> Result<(), Error<CreateReplicationPolicyError>> {
272
273    let uri_str = format!("{}/replication/policies", configuration.base_path);
274    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
275
276    if let Some(ref user_agent) = configuration.user_agent {
277        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
278    }
279    if let Some(param_value) = params.x_request_id {
280        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
281    }
282    if let Some(ref auth_conf) = configuration.basic_auth {
283        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
284    };
285    req_builder = req_builder.json(&params.policy);
286
287    let req = req_builder.build()?;
288    let resp = configuration.client.execute(req).await?;
289
290    let status = resp.status();
291
292    if !status.is_client_error() && !status.is_server_error() {
293        Ok(())
294    } else {
295        let content = resp.text().await?;
296        let entity: Option<CreateReplicationPolicyError> = serde_json::from_str(&content).ok();
297        Err(Error::ResponseError(ResponseContent { status, content, entity }))
298    }
299}
300
301/// Delete the specific replication policy
302pub async fn delete_replication_policy(configuration: &configuration::Configuration, params: DeleteReplicationPolicyParams) -> Result<(), Error<DeleteReplicationPolicyError>> {
303
304    let uri_str = format!("{}/replication/policies/{id}", configuration.base_path, id=params.id);
305    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
306
307    if let Some(ref user_agent) = configuration.user_agent {
308        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
309    }
310    if let Some(param_value) = params.x_request_id {
311        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
312    }
313    if let Some(ref auth_conf) = configuration.basic_auth {
314        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
315    };
316
317    let req = req_builder.build()?;
318    let resp = configuration.client.execute(req).await?;
319
320    let status = resp.status();
321
322    if !status.is_client_error() && !status.is_server_error() {
323        Ok(())
324    } else {
325        let content = resp.text().await?;
326        let entity: Option<DeleteReplicationPolicyError> = serde_json::from_str(&content).ok();
327        Err(Error::ResponseError(ResponseContent { status, content, entity }))
328    }
329}
330
331/// Get the replication execution specified by ID
332pub async fn get_replication_execution(configuration: &configuration::Configuration, params: GetReplicationExecutionParams) -> Result<models::ReplicationExecution, Error<GetReplicationExecutionError>> {
333
334    let uri_str = format!("{}/replication/executions/{id}", configuration.base_path, id=params.id);
335    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
336
337    if let Some(ref user_agent) = configuration.user_agent {
338        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
339    }
340    if let Some(param_value) = params.x_request_id {
341        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
342    }
343    if let Some(ref auth_conf) = configuration.basic_auth {
344        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
345    };
346
347    let req = req_builder.build()?;
348    let resp = configuration.client.execute(req).await?;
349
350    let status = resp.status();
351    let content_type = resp
352        .headers()
353        .get("content-type")
354        .and_then(|v| v.to_str().ok())
355        .unwrap_or("application/octet-stream");
356    let content_type = super::ContentType::from(content_type);
357
358    if !status.is_client_error() && !status.is_server_error() {
359        let content = resp.text().await?;
360        match content_type {
361            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
362            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ReplicationExecution`"))),
363            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::ReplicationExecution`")))),
364        }
365    } else {
366        let content = resp.text().await?;
367        let entity: Option<GetReplicationExecutionError> = serde_json::from_str(&content).ok();
368        Err(Error::ResponseError(ResponseContent { status, content, entity }))
369    }
370}
371
372/// Get the log of the specific replication task
373pub async fn get_replication_log(configuration: &configuration::Configuration, params: GetReplicationLogParams) -> Result<String, Error<GetReplicationLogError>> {
374
375    let uri_str = format!("{}/replication/executions/{id}/tasks/{task_id}/log", configuration.base_path, id=params.id, task_id=params.task_id);
376    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
377
378    if let Some(ref user_agent) = configuration.user_agent {
379        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
380    }
381    if let Some(param_value) = params.x_request_id {
382        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
383    }
384    if let Some(ref auth_conf) = configuration.basic_auth {
385        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
386    };
387
388    let req = req_builder.build()?;
389    let resp = configuration.client.execute(req).await?;
390
391    let status = resp.status();
392    let content_type = resp
393        .headers()
394        .get("content-type")
395        .and_then(|v| v.to_str().ok())
396        .unwrap_or("application/octet-stream");
397    let content_type = super::ContentType::from(content_type);
398
399    if !status.is_client_error() && !status.is_server_error() {
400        let content = resp.text().await?;
401        match content_type {
402            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
403            ContentType::Text => return Ok(content),
404            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`")))),
405        }
406    } else {
407        let content = resp.text().await?;
408        let entity: Option<GetReplicationLogError> = serde_json::from_str(&content).ok();
409        Err(Error::ResponseError(ResponseContent { status, content, entity }))
410    }
411}
412
413/// Get the specific replication policy
414pub async fn get_replication_policy(configuration: &configuration::Configuration, params: GetReplicationPolicyParams) -> Result<models::ReplicationPolicy, Error<GetReplicationPolicyError>> {
415
416    let uri_str = format!("{}/replication/policies/{id}", configuration.base_path, id=params.id);
417    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
418
419    if let Some(ref user_agent) = configuration.user_agent {
420        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
421    }
422    if let Some(param_value) = params.x_request_id {
423        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
424    }
425    if let Some(ref auth_conf) = configuration.basic_auth {
426        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
427    };
428
429    let req = req_builder.build()?;
430    let resp = configuration.client.execute(req).await?;
431
432    let status = resp.status();
433    let content_type = resp
434        .headers()
435        .get("content-type")
436        .and_then(|v| v.to_str().ok())
437        .unwrap_or("application/octet-stream");
438    let content_type = super::ContentType::from(content_type);
439
440    if !status.is_client_error() && !status.is_server_error() {
441        let content = resp.text().await?;
442        match content_type {
443            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
444            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ReplicationPolicy`"))),
445            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::ReplicationPolicy`")))),
446        }
447    } else {
448        let content = resp.text().await?;
449        let entity: Option<GetReplicationPolicyError> = serde_json::from_str(&content).ok();
450        Err(Error::ResponseError(ResponseContent { status, content, entity }))
451    }
452}
453
454/// List replication executions
455pub async fn list_replication_executions(configuration: &configuration::Configuration, params: ListReplicationExecutionsParams) -> Result<Vec<models::ReplicationExecution>, Error<ListReplicationExecutionsError>> {
456
457    let uri_str = format!("{}/replication/executions", configuration.base_path);
458    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
459
460    if let Some(ref param_value) = params.sort {
461        req_builder = req_builder.query(&[("sort", &param_value.to_string())]);
462    }
463    if let Some(ref param_value) = params.page {
464        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
465    }
466    if let Some(ref param_value) = params.page_size {
467        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
468    }
469    if let Some(ref param_value) = params.policy_id {
470        req_builder = req_builder.query(&[("policy_id", &param_value.to_string())]);
471    }
472    if let Some(ref param_value) = params.status {
473        req_builder = req_builder.query(&[("status", &param_value.to_string())]);
474    }
475    if let Some(ref param_value) = params.trigger {
476        req_builder = req_builder.query(&[("trigger", &param_value.to_string())]);
477    }
478    if let Some(ref user_agent) = configuration.user_agent {
479        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
480    }
481    if let Some(param_value) = params.x_request_id {
482        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
483    }
484    if let Some(ref auth_conf) = configuration.basic_auth {
485        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
486    };
487
488    let req = req_builder.build()?;
489    let resp = configuration.client.execute(req).await?;
490
491    let status = resp.status();
492    let content_type = resp
493        .headers()
494        .get("content-type")
495        .and_then(|v| v.to_str().ok())
496        .unwrap_or("application/octet-stream");
497    let content_type = super::ContentType::from(content_type);
498
499    if !status.is_client_error() && !status.is_server_error() {
500        let content = resp.text().await?;
501        match content_type {
502            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
503            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::ReplicationExecution&gt;`"))),
504            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::ReplicationExecution&gt;`")))),
505        }
506    } else {
507        let content = resp.text().await?;
508        let entity: Option<ListReplicationExecutionsError> = serde_json::from_str(&content).ok();
509        Err(Error::ResponseError(ResponseContent { status, content, entity }))
510    }
511}
512
513/// List replication policies
514pub async fn list_replication_policies(configuration: &configuration::Configuration, params: ListReplicationPoliciesParams) -> Result<Vec<models::ReplicationPolicy>, Error<ListReplicationPoliciesError>> {
515
516    let uri_str = format!("{}/replication/policies", configuration.base_path);
517    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
518
519    if let Some(ref param_value) = params.q {
520        req_builder = req_builder.query(&[("q", &param_value.to_string())]);
521    }
522    if let Some(ref param_value) = params.sort {
523        req_builder = req_builder.query(&[("sort", &param_value.to_string())]);
524    }
525    if let Some(ref param_value) = params.page {
526        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
527    }
528    if let Some(ref param_value) = params.page_size {
529        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
530    }
531    if let Some(ref param_value) = params.name {
532        req_builder = req_builder.query(&[("name", &param_value.to_string())]);
533    }
534    if let Some(ref user_agent) = configuration.user_agent {
535        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
536    }
537    if let Some(param_value) = params.x_request_id {
538        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
539    }
540    if let Some(ref auth_conf) = configuration.basic_auth {
541        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
542    };
543
544    let req = req_builder.build()?;
545    let resp = configuration.client.execute(req).await?;
546
547    let status = resp.status();
548    let content_type = resp
549        .headers()
550        .get("content-type")
551        .and_then(|v| v.to_str().ok())
552        .unwrap_or("application/octet-stream");
553    let content_type = super::ContentType::from(content_type);
554
555    if !status.is_client_error() && !status.is_server_error() {
556        let content = resp.text().await?;
557        match content_type {
558            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
559            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::ReplicationPolicy&gt;`"))),
560            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::ReplicationPolicy&gt;`")))),
561        }
562    } else {
563        let content = resp.text().await?;
564        let entity: Option<ListReplicationPoliciesError> = serde_json::from_str(&content).ok();
565        Err(Error::ResponseError(ResponseContent { status, content, entity }))
566    }
567}
568
569/// List replication tasks for a specific execution
570pub async fn list_replication_tasks(configuration: &configuration::Configuration, params: ListReplicationTasksParams) -> Result<Vec<models::ReplicationTask>, Error<ListReplicationTasksError>> {
571
572    let uri_str = format!("{}/replication/executions/{id}/tasks", configuration.base_path, id=params.id);
573    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
574
575    if let Some(ref param_value) = params.sort {
576        req_builder = req_builder.query(&[("sort", &param_value.to_string())]);
577    }
578    if let Some(ref param_value) = params.page {
579        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
580    }
581    if let Some(ref param_value) = params.page_size {
582        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
583    }
584    if let Some(ref param_value) = params.status {
585        req_builder = req_builder.query(&[("status", &param_value.to_string())]);
586    }
587    if let Some(ref param_value) = params.resource_type {
588        req_builder = req_builder.query(&[("resource_type", &param_value.to_string())]);
589    }
590    if let Some(ref user_agent) = configuration.user_agent {
591        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
592    }
593    if let Some(param_value) = params.x_request_id {
594        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
595    }
596    if let Some(ref auth_conf) = configuration.basic_auth {
597        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
598    };
599
600    let req = req_builder.build()?;
601    let resp = configuration.client.execute(req).await?;
602
603    let status = resp.status();
604    let content_type = resp
605        .headers()
606        .get("content-type")
607        .and_then(|v| v.to_str().ok())
608        .unwrap_or("application/octet-stream");
609    let content_type = super::ContentType::from(content_type);
610
611    if !status.is_client_error() && !status.is_server_error() {
612        let content = resp.text().await?;
613        match content_type {
614            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
615            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::ReplicationTask&gt;`"))),
616            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::ReplicationTask&gt;`")))),
617        }
618    } else {
619        let content = resp.text().await?;
620        let entity: Option<ListReplicationTasksError> = serde_json::from_str(&content).ok();
621        Err(Error::ResponseError(ResponseContent { status, content, entity }))
622    }
623}
624
625/// Start one replication execution according to the policy
626pub async fn start_replication(configuration: &configuration::Configuration, params: StartReplicationParams) -> Result<(), Error<StartReplicationError>> {
627
628    let uri_str = format!("{}/replication/executions", configuration.base_path);
629    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
630
631    if let Some(ref user_agent) = configuration.user_agent {
632        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
633    }
634    if let Some(param_value) = params.x_request_id {
635        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
636    }
637    if let Some(ref auth_conf) = configuration.basic_auth {
638        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
639    };
640    req_builder = req_builder.json(&params.execution);
641
642    let req = req_builder.build()?;
643    let resp = configuration.client.execute(req).await?;
644
645    let status = resp.status();
646
647    if !status.is_client_error() && !status.is_server_error() {
648        Ok(())
649    } else {
650        let content = resp.text().await?;
651        let entity: Option<StartReplicationError> = serde_json::from_str(&content).ok();
652        Err(Error::ResponseError(ResponseContent { status, content, entity }))
653    }
654}
655
656/// Stop the replication execution specified by ID
657pub async fn stop_replication(configuration: &configuration::Configuration, params: StopReplicationParams) -> Result<(), Error<StopReplicationError>> {
658
659    let uri_str = format!("{}/replication/executions/{id}", configuration.base_path, id=params.id);
660    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
661
662    if let Some(ref user_agent) = configuration.user_agent {
663        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
664    }
665    if let Some(param_value) = params.x_request_id {
666        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
667    }
668    if let Some(ref auth_conf) = configuration.basic_auth {
669        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
670    };
671
672    let req = req_builder.build()?;
673    let resp = configuration.client.execute(req).await?;
674
675    let status = resp.status();
676
677    if !status.is_client_error() && !status.is_server_error() {
678        Ok(())
679    } else {
680        let content = resp.text().await?;
681        let entity: Option<StopReplicationError> = serde_json::from_str(&content).ok();
682        Err(Error::ResponseError(ResponseContent { status, content, entity }))
683    }
684}
685
686/// Update the replication policy
687pub async fn update_replication_policy(configuration: &configuration::Configuration, params: UpdateReplicationPolicyParams) -> Result<(), Error<UpdateReplicationPolicyError>> {
688
689    let uri_str = format!("{}/replication/policies/{id}", configuration.base_path, id=params.id);
690    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
691
692    if let Some(ref user_agent) = configuration.user_agent {
693        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
694    }
695    if let Some(param_value) = params.x_request_id {
696        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
697    }
698    if let Some(ref auth_conf) = configuration.basic_auth {
699        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
700    };
701    req_builder = req_builder.json(&params.policy);
702
703    let req = req_builder.build()?;
704    let resp = configuration.client.execute(req).await?;
705
706    let status = resp.status();
707
708    if !status.is_client_error() && !status.is_server_error() {
709        Ok(())
710    } else {
711        let content = resp.text().await?;
712        let entity: Option<UpdateReplicationPolicyError> = serde_json::from_str(&content).ok();
713        Err(Error::ResponseError(ResponseContent { status, content, entity }))
714    }
715}
716