zsgf_client/apis/
project_api.rs

1/*
2 * 全部  API 文档
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: v1
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
18/// struct for typed errors of method [`project`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ProjectError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`project_delete`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum ProjectDeleteError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`project_post`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ProjectPostError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`project_put`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ProjectPutError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`projects`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ProjectsError {
50    UnknownValue(serde_json::Value),
51}
52
53
54/// 根据项目ID获取项目详情
55pub async fn project(configuration: &configuration::Configuration, id: i64) -> Result<models::ProjectApiResponse, Error<ProjectError>> {
56    // add a prefix to parameters to efficiently prevent name collisions
57    let p_id = id;
58
59    let uri_str = format!("{}/Project/{id}", configuration.base_path, id=p_id);
60    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
61
62    if let Some(ref user_agent) = configuration.user_agent {
63        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
64    }
65    if let Some(ref token) = configuration.bearer_access_token {
66        req_builder = req_builder.bearer_auth(token.to_owned());
67    };
68
69    let req = req_builder.build()?;
70    let resp = configuration.client.execute(req).await?;
71
72    let status = resp.status();
73    let content_type = resp
74        .headers()
75        .get("content-type")
76        .and_then(|v| v.to_str().ok())
77        .unwrap_or("application/octet-stream");
78    let content_type = super::ContentType::from(content_type);
79
80    if !status.is_client_error() && !status.is_server_error() {
81        let content = resp.text().await?;
82        match content_type {
83            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
84            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectApiResponse`"))),
85            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::ProjectApiResponse`")))),
86        }
87    } else {
88        let content = resp.text().await?;
89        let entity: Option<ProjectError> = serde_json::from_str(&content).ok();
90        Err(Error::ResponseError(ResponseContent { status, content, entity }))
91    }
92}
93
94/// 根据项目ID删除项目
95pub async fn project_delete(configuration: &configuration::Configuration, id: i64) -> Result<models::BooleanApiResponse, Error<ProjectDeleteError>> {
96    // add a prefix to parameters to efficiently prevent name collisions
97    let p_id = id;
98
99    let uri_str = format!("{}/Project/{id}", configuration.base_path, id=p_id);
100    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
101
102    if let Some(ref user_agent) = configuration.user_agent {
103        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
104    }
105    if let Some(ref token) = configuration.bearer_access_token {
106        req_builder = req_builder.bearer_auth(token.to_owned());
107    };
108
109    let req = req_builder.build()?;
110    let resp = configuration.client.execute(req).await?;
111
112    let status = resp.status();
113    let content_type = resp
114        .headers()
115        .get("content-type")
116        .and_then(|v| v.to_str().ok())
117        .unwrap_or("application/octet-stream");
118    let content_type = super::ContentType::from(content_type);
119
120    if !status.is_client_error() && !status.is_server_error() {
121        let content = resp.text().await?;
122        match content_type {
123            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
124            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BooleanApiResponse`"))),
125            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::BooleanApiResponse`")))),
126        }
127    } else {
128        let content = resp.text().await?;
129        let entity: Option<ProjectDeleteError> = serde_json::from_str(&content).ok();
130        Err(Error::ResponseError(ResponseContent { status, content, entity }))
131    }
132}
133
134/// 创建一个新项目
135pub async fn project_post(configuration: &configuration::Configuration, project: Option<models::Project>) -> Result<models::PostResultApiResponse, Error<ProjectPostError>> {
136    // add a prefix to parameters to efficiently prevent name collisions
137    let p_project = project;
138
139    let uri_str = format!("{}/Project", configuration.base_path);
140    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
141
142    if let Some(ref user_agent) = configuration.user_agent {
143        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
144    }
145    if let Some(ref token) = configuration.bearer_access_token {
146        req_builder = req_builder.bearer_auth(token.to_owned());
147    };
148    req_builder = req_builder.json(&p_project);
149
150    let req = req_builder.build()?;
151    let resp = configuration.client.execute(req).await?;
152
153    let status = resp.status();
154    let content_type = resp
155        .headers()
156        .get("content-type")
157        .and_then(|v| v.to_str().ok())
158        .unwrap_or("application/octet-stream");
159    let content_type = super::ContentType::from(content_type);
160
161    if !status.is_client_error() && !status.is_server_error() {
162        let content = resp.text().await?;
163        match content_type {
164            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
165            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PostResultApiResponse`"))),
166            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::PostResultApiResponse`")))),
167        }
168    } else {
169        let content = resp.text().await?;
170        let entity: Option<ProjectPostError> = serde_json::from_str(&content).ok();
171        Err(Error::ResponseError(ResponseContent { status, content, entity }))
172    }
173}
174
175/// 根据项目ID更新项目
176pub async fn project_put(configuration: &configuration::Configuration, id: &str, project: Option<models::Project>) -> Result<models::BooleanApiResponse, Error<ProjectPutError>> {
177    // add a prefix to parameters to efficiently prevent name collisions
178    let p_id = id;
179    let p_project = project;
180
181    let uri_str = format!("{}/Project/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
182    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
183
184    if let Some(ref user_agent) = configuration.user_agent {
185        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
186    }
187    if let Some(ref token) = configuration.bearer_access_token {
188        req_builder = req_builder.bearer_auth(token.to_owned());
189    };
190    req_builder = req_builder.json(&p_project);
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 => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BooleanApiResponse`"))),
208            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::BooleanApiResponse`")))),
209        }
210    } else {
211        let content = resp.text().await?;
212        let entity: Option<ProjectPutError> = serde_json::from_str(&content).ok();
213        Err(Error::ResponseError(ResponseContent { status, content, entity }))
214    }
215}
216
217/// 获取项目列表,支持分页
218pub async fn projects(configuration: &configuration::Configuration, skip: Option<i32>, take: Option<i32>) -> Result<models::ProjectListResultApiResponse, Error<ProjectsError>> {
219    // add a prefix to parameters to efficiently prevent name collisions
220    let p_skip = skip;
221    let p_take = take;
222
223    let uri_str = format!("{}/Project", configuration.base_path);
224    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
225
226    if let Some(ref param_value) = p_skip {
227        req_builder = req_builder.query(&[("skip", &param_value.to_string())]);
228    }
229    if let Some(ref param_value) = p_take {
230        req_builder = req_builder.query(&[("take", &param_value.to_string())]);
231    }
232    if let Some(ref user_agent) = configuration.user_agent {
233        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
234    }
235    if let Some(ref token) = configuration.bearer_access_token {
236        req_builder = req_builder.bearer_auth(token.to_owned());
237    };
238
239    let req = req_builder.build()?;
240    let resp = configuration.client.execute(req).await?;
241
242    let status = resp.status();
243    let content_type = resp
244        .headers()
245        .get("content-type")
246        .and_then(|v| v.to_str().ok())
247        .unwrap_or("application/octet-stream");
248    let content_type = super::ContentType::from(content_type);
249
250    if !status.is_client_error() && !status.is_server_error() {
251        let content = resp.text().await?;
252        match content_type {
253            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
254            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectListResultApiResponse`"))),
255            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::ProjectListResultApiResponse`")))),
256        }
257    } else {
258        let content = resp.text().await?;
259        let entity: Option<ProjectsError> = serde_json::from_str(&content).ok();
260        Err(Error::ResponseError(ResponseContent { status, content, entity }))
261    }
262}
263