Skip to main content

tapis_workflows/apis/
pipelines_api.rs

1/*
2 * Tapis Workflows API
3 *
4 * Create and manage pipelines
5 *
6 * The version of the OpenAPI document: 1.6.0
7 * Contact: cicsupport@tacc.utexas.edu
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16/// struct for typed errors of method [`add_pipeline_archive`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum AddPipelineArchiveError {
20    UnknownValue(serde_json::Value),
21}
22
23/// struct for typed errors of method [`change_pipeline_owner`]
24#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum ChangePipelineOwnerError {
27    UnknownValue(serde_json::Value),
28}
29
30/// struct for typed errors of method [`create_pipeline`]
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum CreatePipelineError {
34    Status400(models::RespError),
35    Status401(models::RespError),
36    Status403(models::RespError),
37    Status405(models::RespError),
38    Status409(models::RespError),
39    Status415(models::RespError),
40    Status422(models::RespError),
41    Status500(models::RespError),
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`delete_pipeline`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum DeletePipelineError {
49    Status401(models::RespError),
50    Status403(models::RespError),
51    Status404(models::RespError),
52    UnknownValue(serde_json::Value),
53}
54
55/// struct for typed errors of method [`get_pipeline`]
56#[derive(Debug, Clone, Serialize, Deserialize)]
57#[serde(untagged)]
58pub enum GetPipelineError {
59    Status400(models::RespError),
60    Status401(models::RespError),
61    Status404(models::RespError),
62    Status500(models::RespError),
63    UnknownValue(serde_json::Value),
64}
65
66/// struct for typed errors of method [`list_pipelines`]
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum ListPipelinesError {
70    Status400(models::RespError),
71    Status401(models::RespError),
72    Status403(models::RespError),
73    Status404(models::RespError),
74    Status405(models::RespError),
75    Status409(models::RespError),
76    Status415(models::RespError),
77    Status422(models::RespError),
78    Status500(models::RespError),
79    UnknownValue(serde_json::Value),
80}
81
82/// struct for typed errors of method [`remove_pipeline_archive`]
83#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum RemovePipelineArchiveError {
86    UnknownValue(serde_json::Value),
87}
88
89/// struct for typed errors of method [`run_pipeline`]
90#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum RunPipelineError {
93    UnknownValue(serde_json::Value),
94}
95
96/// Add an archive to a pipeline.
97pub async fn add_pipeline_archive(
98    configuration: &configuration::Configuration,
99    group_id: &str,
100    pipeline_id: &str,
101) -> Result<models::RespBase, Error<AddPipelineArchiveError>> {
102    // add a prefix to parameters to efficiently prevent name collisions
103    let p_path_group_id = group_id;
104    let p_path_pipeline_id = pipeline_id;
105
106    let uri_str = format!(
107        "{}/v3/workflows/groups/{group_id}/pipelines/{pipeline_id}/archives/add",
108        configuration.base_path,
109        group_id = crate::apis::urlencode(p_path_group_id),
110        pipeline_id = crate::apis::urlencode(p_path_pipeline_id)
111    );
112    let mut req_builder = configuration
113        .client
114        .request(reqwest::Method::POST, &uri_str);
115
116    if let Some(ref user_agent) = configuration.user_agent {
117        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
118    }
119    if let Some(ref apikey) = configuration.api_key {
120        let key = apikey.key.clone();
121        let value = match apikey.prefix {
122            Some(ref prefix) => format!("{} {}", prefix, key),
123            None => key,
124        };
125        req_builder = req_builder.header("X-TAPIS-TOKEN", value);
126    };
127
128    let req = req_builder.build()?;
129    let resp = configuration.client.execute(req).await?;
130
131    let status = resp.status();
132    let content_type = resp
133        .headers()
134        .get("content-type")
135        .and_then(|v| v.to_str().ok())
136        .unwrap_or("application/octet-stream");
137    let content_type = super::ContentType::from(content_type);
138
139    if !status.is_client_error() && !status.is_server_error() {
140        let content = resp.text().await?;
141        match content_type {
142            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
143            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespBase`"))),
144            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespBase`")))),
145        }
146    } else {
147        let content = resp.text().await?;
148        let entity: Option<AddPipelineArchiveError> = serde_json::from_str(&content).ok();
149        Err(Error::ResponseError(ResponseContent {
150            status,
151            content,
152            entity,
153        }))
154    }
155}
156
157/// Change the owner of a pipeline. Requesting user must be the current owner
158pub async fn change_pipeline_owner(
159    configuration: &configuration::Configuration,
160    group_id: &str,
161    pipeline_id: &str,
162    username: &str,
163) -> Result<models::RespBase, Error<ChangePipelineOwnerError>> {
164    // add a prefix to parameters to efficiently prevent name collisions
165    let p_path_group_id = group_id;
166    let p_path_pipeline_id = pipeline_id;
167    let p_path_username = username;
168
169    let uri_str = format!(
170        "{}/v3/workflows/groups/{group_id}/pipelines/{pipeline_id}/changeOwner/{username}",
171        configuration.base_path,
172        group_id = crate::apis::urlencode(p_path_group_id),
173        pipeline_id = crate::apis::urlencode(p_path_pipeline_id),
174        username = crate::apis::urlencode(p_path_username)
175    );
176    let mut req_builder = configuration
177        .client
178        .request(reqwest::Method::PATCH, &uri_str);
179
180    if let Some(ref user_agent) = configuration.user_agent {
181        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
182    }
183    if let Some(ref apikey) = configuration.api_key {
184        let key = apikey.key.clone();
185        let value = match apikey.prefix {
186            Some(ref prefix) => format!("{} {}", prefix, key),
187            None => key,
188        };
189        req_builder = req_builder.header("X-TAPIS-TOKEN", value);
190    };
191
192    let req = req_builder.build()?;
193    let resp = configuration.client.execute(req).await?;
194
195    let status = resp.status();
196    let content_type = resp
197        .headers()
198        .get("content-type")
199        .and_then(|v| v.to_str().ok())
200        .unwrap_or("application/octet-stream");
201    let content_type = super::ContentType::from(content_type);
202
203    if !status.is_client_error() && !status.is_server_error() {
204        let content = resp.text().await?;
205        match content_type {
206            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
207            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespBase`"))),
208            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespBase`")))),
209        }
210    } else {
211        let content = resp.text().await?;
212        let entity: Option<ChangePipelineOwnerError> = serde_json::from_str(&content).ok();
213        Err(Error::ResponseError(ResponseContent {
214            status,
215            content,
216            entity,
217        }))
218    }
219}
220
221/// Create a pipeline using a request body. Pipeline id must be unique within a group and can be composed of alphanumeric characters and the following special characters [-_.].
222pub async fn create_pipeline(
223    configuration: &configuration::Configuration,
224    group_id: &str,
225    req_pipeline: models::ReqPipeline,
226) -> Result<models::RespResourceUrl, Error<CreatePipelineError>> {
227    // add a prefix to parameters to efficiently prevent name collisions
228    let p_path_group_id = group_id;
229    let p_body_req_pipeline = req_pipeline;
230
231    let uri_str = format!(
232        "{}/v3/workflows/groups/{group_id}/pipelines",
233        configuration.base_path,
234        group_id = crate::apis::urlencode(p_path_group_id)
235    );
236    let mut req_builder = configuration
237        .client
238        .request(reqwest::Method::POST, &uri_str);
239
240    if let Some(ref user_agent) = configuration.user_agent {
241        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
242    }
243    if let Some(ref apikey) = configuration.api_key {
244        let key = apikey.key.clone();
245        let value = match apikey.prefix {
246            Some(ref prefix) => format!("{} {}", prefix, key),
247            None => key,
248        };
249        req_builder = req_builder.header("X-TAPIS-TOKEN", value);
250    };
251    req_builder = req_builder.json(&p_body_req_pipeline);
252
253    let req = req_builder.build()?;
254    let resp = configuration.client.execute(req).await?;
255
256    let status = resp.status();
257    let content_type = resp
258        .headers()
259        .get("content-type")
260        .and_then(|v| v.to_str().ok())
261        .unwrap_or("application/octet-stream");
262    let content_type = super::ContentType::from(content_type);
263
264    if !status.is_client_error() && !status.is_server_error() {
265        let content = resp.text().await?;
266        match content_type {
267            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
268            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespResourceUrl`"))),
269            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespResourceUrl`")))),
270        }
271    } else {
272        let content = resp.text().await?;
273        let entity: Option<CreatePipelineError> = serde_json::from_str(&content).ok();
274        Err(Error::ResponseError(ResponseContent {
275            status,
276            content,
277            entity,
278        }))
279    }
280}
281
282/// Delete a pipeline
283pub async fn delete_pipeline(
284    configuration: &configuration::Configuration,
285    group_id: &str,
286    pipeline_id: &str,
287) -> Result<models::RespString, Error<DeletePipelineError>> {
288    // add a prefix to parameters to efficiently prevent name collisions
289    let p_path_group_id = group_id;
290    let p_path_pipeline_id = pipeline_id;
291
292    let uri_str = format!(
293        "{}/v3/workflows/groups/{group_id}/pipelines/{pipeline_id}",
294        configuration.base_path,
295        group_id = crate::apis::urlencode(p_path_group_id),
296        pipeline_id = crate::apis::urlencode(p_path_pipeline_id)
297    );
298    let mut req_builder = configuration
299        .client
300        .request(reqwest::Method::DELETE, &uri_str);
301
302    if let Some(ref user_agent) = configuration.user_agent {
303        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
304    }
305    if let Some(ref apikey) = configuration.api_key {
306        let key = apikey.key.clone();
307        let value = match apikey.prefix {
308            Some(ref prefix) => format!("{} {}", prefix, key),
309            None => key,
310        };
311        req_builder = req_builder.header("X-TAPIS-TOKEN", value);
312    };
313
314    let req = req_builder.build()?;
315    let resp = configuration.client.execute(req).await?;
316
317    let status = resp.status();
318    let content_type = resp
319        .headers()
320        .get("content-type")
321        .and_then(|v| v.to_str().ok())
322        .unwrap_or("application/octet-stream");
323    let content_type = super::ContentType::from(content_type);
324
325    if !status.is_client_error() && !status.is_server_error() {
326        let content = resp.text().await?;
327        match content_type {
328            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
329            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespString`"))),
330            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespString`")))),
331        }
332    } else {
333        let content = resp.text().await?;
334        let entity: Option<DeletePipelineError> = serde_json::from_str(&content).ok();
335        Err(Error::ResponseError(ResponseContent {
336            status,
337            content,
338            entity,
339        }))
340    }
341}
342
343/// Retrieve information for a pipeline given the pipeline id
344pub async fn get_pipeline(
345    configuration: &configuration::Configuration,
346    group_id: &str,
347    pipeline_id: &str,
348) -> Result<models::RespPipeline, Error<GetPipelineError>> {
349    // add a prefix to parameters to efficiently prevent name collisions
350    let p_path_group_id = group_id;
351    let p_path_pipeline_id = pipeline_id;
352
353    let uri_str = format!(
354        "{}/v3/workflows/groups/{group_id}/pipelines/{pipeline_id}",
355        configuration.base_path,
356        group_id = crate::apis::urlencode(p_path_group_id),
357        pipeline_id = crate::apis::urlencode(p_path_pipeline_id)
358    );
359    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
360
361    if let Some(ref user_agent) = configuration.user_agent {
362        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
363    }
364    if let Some(ref apikey) = configuration.api_key {
365        let key = apikey.key.clone();
366        let value = match apikey.prefix {
367            Some(ref prefix) => format!("{} {}", prefix, key),
368            None => key,
369        };
370        req_builder = req_builder.header("X-TAPIS-TOKEN", value);
371    };
372
373    let req = req_builder.build()?;
374    let resp = configuration.client.execute(req).await?;
375
376    let status = resp.status();
377    let content_type = resp
378        .headers()
379        .get("content-type")
380        .and_then(|v| v.to_str().ok())
381        .unwrap_or("application/octet-stream");
382    let content_type = super::ContentType::from(content_type);
383
384    if !status.is_client_error() && !status.is_server_error() {
385        let content = resp.text().await?;
386        match content_type {
387            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
388            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespPipeline`"))),
389            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespPipeline`")))),
390        }
391    } else {
392        let content = resp.text().await?;
393        let entity: Option<GetPipelineError> = serde_json::from_str(&content).ok();
394        Err(Error::ResponseError(ResponseContent {
395            status,
396            content,
397            entity,
398        }))
399    }
400}
401
402/// Retrieve a list of pipelines for all groups that the requesting user belongs to.
403pub async fn list_pipelines(
404    configuration: &configuration::Configuration,
405    group_id: &str,
406) -> Result<models::RespPipelineList, Error<ListPipelinesError>> {
407    // add a prefix to parameters to efficiently prevent name collisions
408    let p_path_group_id = group_id;
409
410    let uri_str = format!(
411        "{}/v3/workflows/groups/{group_id}/pipelines",
412        configuration.base_path,
413        group_id = crate::apis::urlencode(p_path_group_id)
414    );
415    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
416
417    if let Some(ref user_agent) = configuration.user_agent {
418        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
419    }
420    if let Some(ref apikey) = configuration.api_key {
421        let key = apikey.key.clone();
422        let value = match apikey.prefix {
423            Some(ref prefix) => format!("{} {}", prefix, key),
424            None => key,
425        };
426        req_builder = req_builder.header("X-TAPIS-TOKEN", value);
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 => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespPipelineList`"))),
445            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespPipelineList`")))),
446        }
447    } else {
448        let content = resp.text().await?;
449        let entity: Option<ListPipelinesError> = serde_json::from_str(&content).ok();
450        Err(Error::ResponseError(ResponseContent {
451            status,
452            content,
453            entity,
454        }))
455    }
456}
457
458/// Remove an archive to a pipeline.
459pub async fn remove_pipeline_archive(
460    configuration: &configuration::Configuration,
461    group_id: &str,
462    pipeline_id: &str,
463) -> Result<models::RespBase, Error<RemovePipelineArchiveError>> {
464    // add a prefix to parameters to efficiently prevent name collisions
465    let p_path_group_id = group_id;
466    let p_path_pipeline_id = pipeline_id;
467
468    let uri_str = format!(
469        "{}/v3/workflows/groups/{group_id}/pipelines/{pipeline_id}/archives/remove",
470        configuration.base_path,
471        group_id = crate::apis::urlencode(p_path_group_id),
472        pipeline_id = crate::apis::urlencode(p_path_pipeline_id)
473    );
474    let mut req_builder = configuration
475        .client
476        .request(reqwest::Method::DELETE, &uri_str);
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(ref apikey) = configuration.api_key {
482        let key = apikey.key.clone();
483        let value = match apikey.prefix {
484            Some(ref prefix) => format!("{} {}", prefix, key),
485            None => key,
486        };
487        req_builder = req_builder.header("X-TAPIS-TOKEN", value);
488    };
489
490    let req = req_builder.build()?;
491    let resp = configuration.client.execute(req).await?;
492
493    let status = resp.status();
494    let content_type = resp
495        .headers()
496        .get("content-type")
497        .and_then(|v| v.to_str().ok())
498        .unwrap_or("application/octet-stream");
499    let content_type = super::ContentType::from(content_type);
500
501    if !status.is_client_error() && !status.is_server_error() {
502        let content = resp.text().await?;
503        match content_type {
504            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
505            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespBase`"))),
506            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespBase`")))),
507        }
508    } else {
509        let content = resp.text().await?;
510        let entity: Option<RemovePipelineArchiveError> = serde_json::from_str(&content).ok();
511        Err(Error::ResponseError(ResponseContent {
512            status,
513            content,
514            entity,
515        }))
516    }
517}
518
519/// Trigger a pipeline run
520pub async fn run_pipeline(
521    configuration: &configuration::Configuration,
522    group_id: &str,
523    pipeline_id: &str,
524    req_run_pipeline: models::ReqRunPipeline,
525) -> Result<models::RespPipelineRun, Error<RunPipelineError>> {
526    // add a prefix to parameters to efficiently prevent name collisions
527    let p_path_group_id = group_id;
528    let p_path_pipeline_id = pipeline_id;
529    let p_body_req_run_pipeline = req_run_pipeline;
530
531    let uri_str = format!(
532        "{}/v3/workflows/groups/{group_id}/pipelines/{pipeline_id}/run",
533        configuration.base_path,
534        group_id = crate::apis::urlencode(p_path_group_id),
535        pipeline_id = crate::apis::urlencode(p_path_pipeline_id)
536    );
537    let mut req_builder = configuration
538        .client
539        .request(reqwest::Method::POST, &uri_str);
540
541    if let Some(ref user_agent) = configuration.user_agent {
542        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
543    }
544    if let Some(ref apikey) = configuration.api_key {
545        let key = apikey.key.clone();
546        let value = match apikey.prefix {
547            Some(ref prefix) => format!("{} {}", prefix, key),
548            None => key,
549        };
550        req_builder = req_builder.header("X-TAPIS-TOKEN", value);
551    };
552    req_builder = req_builder.json(&p_body_req_run_pipeline);
553
554    let req = req_builder.build()?;
555    let resp = configuration.client.execute(req).await?;
556
557    let status = resp.status();
558    let content_type = resp
559        .headers()
560        .get("content-type")
561        .and_then(|v| v.to_str().ok())
562        .unwrap_or("application/octet-stream");
563    let content_type = super::ContentType::from(content_type);
564
565    if !status.is_client_error() && !status.is_server_error() {
566        let content = resp.text().await?;
567        match content_type {
568            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
569            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespPipelineRun`"))),
570            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespPipelineRun`")))),
571        }
572    } else {
573        let content = resp.text().await?;
574        let entity: Option<RunPipelineError> = serde_json::from_str(&content).ok();
575        Err(Error::ResponseError(ResponseContent {
576            status,
577            content,
578            entity,
579        }))
580    }
581}