jira_api_v2/apis/
workflow_scheme_project_associations_api.rs1use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AssociateSchemeWithProjectError {
22 Status400(),
23 Status401(),
24 Status403(),
25 Status404(),
26 UnknownValue(serde_json::Value),
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum GetWorkflowSchemeProjectAssociationsError {
33 Status400(),
34 Status401(),
35 Status403(),
36 UnknownValue(serde_json::Value),
37}
38
39
40pub async fn associate_scheme_with_project(configuration: &configuration::Configuration, workflow_scheme_project_association: models::WorkflowSchemeProjectAssociation) -> Result<serde_json::Value, Error<AssociateSchemeWithProjectError>> {
42 let p_workflow_scheme_project_association = workflow_scheme_project_association;
44
45 let uri_str = format!("{}/rest/api/2/workflowscheme/project", configuration.base_path);
46 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
47
48 if let Some(ref user_agent) = configuration.user_agent {
49 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
50 }
51 if let Some(ref token) = configuration.oauth_access_token {
52 req_builder = req_builder.bearer_auth(token.to_owned());
53 };
54 if let Some(ref auth_conf) = configuration.basic_auth {
55 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
56 };
57 req_builder = req_builder.json(&p_workflow_scheme_project_association);
58
59 let req = req_builder.build()?;
60 let resp = configuration.client.execute(req).await?;
61
62 let status = resp.status();
63
64 if !status.is_client_error() && !status.is_server_error() {
65 let content = resp.text().await?;
66 serde_json::from_str(&content).map_err(Error::from)
67 } else {
68 let content = resp.text().await?;
69 let entity: Option<AssociateSchemeWithProjectError> = serde_json::from_str(&content).ok();
70 Err(Error::ResponseError(ResponseContent { status, content, entity }))
71 }
72}
73
74pub async fn get_workflow_scheme_project_associations(configuration: &configuration::Configuration, project_id: Vec<i64>) -> Result<models::ContainerOfWorkflowSchemeAssociations, Error<GetWorkflowSchemeProjectAssociationsError>> {
76 let p_project_id = project_id;
78
79 let uri_str = format!("{}/rest/api/2/workflowscheme/project", configuration.base_path);
80 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
81
82 req_builder = match "multi" {
83 "multi" => req_builder.query(&p_project_id.into_iter().map(|p| ("projectId".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
84 _ => req_builder.query(&[("projectId", &p_project_id.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
85 };
86 if let Some(ref user_agent) = configuration.user_agent {
87 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
88 }
89 if let Some(ref token) = configuration.oauth_access_token {
90 req_builder = req_builder.bearer_auth(token.to_owned());
91 };
92 if let Some(ref auth_conf) = configuration.basic_auth {
93 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
94 };
95
96 let req = req_builder.build()?;
97 let resp = configuration.client.execute(req).await?;
98
99 let status = resp.status();
100
101 if !status.is_client_error() && !status.is_server_error() {
102 let content = resp.text().await?;
103 serde_json::from_str(&content).map_err(Error::from)
104 } else {
105 let content = resp.text().await?;
106 let entity: Option<GetWorkflowSchemeProjectAssociationsError> = serde_json::from_str(&content).ok();
107 Err(Error::ResponseError(ResponseContent { status, content, entity }))
108 }
109}
110