artcoded_api/apis/
label_controller_api.rs1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum FindAll3Error {
20 UnknownValue(serde_json::Value),
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum FindByNameError {
27 UnknownValue(serde_json::Value),
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum UpdateAllError {
34 UnknownValue(serde_json::Value),
35}
36
37pub async fn find_all3(
38 configuration: &configuration::Configuration,
39) -> Result<Vec<models::Label>, Error<FindAll3Error>> {
40 let uri_str = format!("{}/api/label/find-all", configuration.base_path);
41 let mut req_builder = configuration
42 .client
43 .request(reqwest::Method::POST, &uri_str);
44
45 if let Some(ref user_agent) = configuration.user_agent {
46 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
47 }
48 if let Some(ref token) = configuration.bearer_access_token {
49 req_builder = req_builder.bearer_auth(token.to_owned());
50 };
51
52 let req = req_builder.build()?;
53 let resp = configuration.client.execute(req).await?;
54
55 let status = resp.status();
56 let content_type = resp
57 .headers()
58 .get("content-type")
59 .and_then(|v| v.to_str().ok())
60 .unwrap_or("application/octet-stream");
61 let content_type = super::ContentType::from(content_type);
62
63 if !status.is_client_error() && !status.is_server_error() {
64 let content = resp.text().await?;
65 match content_type {
66 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
67 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Label>`"))),
68 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Label>`")))),
69 }
70 } else {
71 let content = resp.text().await?;
72 let entity: Option<FindAll3Error> = serde_json::from_str(&content).ok();
73 Err(Error::ResponseError(ResponseContent {
74 status,
75 content,
76 entity,
77 }))
78 }
79}
80
81pub async fn find_by_name(
82 configuration: &configuration::Configuration,
83 name: &str,
84) -> Result<models::Label, Error<FindByNameError>> {
85 let p_query_name = name;
87
88 let uri_str = format!("{}/api/label/find-by-name", configuration.base_path);
89 let mut req_builder = configuration
90 .client
91 .request(reqwest::Method::POST, &uri_str);
92
93 req_builder = req_builder.query(&[("name", &p_query_name.to_string())]);
94 if let Some(ref user_agent) = configuration.user_agent {
95 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
96 }
97 if let Some(ref token) = configuration.bearer_access_token {
98 req_builder = req_builder.bearer_auth(token.to_owned());
99 };
100
101 let req = req_builder.build()?;
102 let resp = configuration.client.execute(req).await?;
103
104 let status = resp.status();
105 let content_type = resp
106 .headers()
107 .get("content-type")
108 .and_then(|v| v.to_str().ok())
109 .unwrap_or("application/octet-stream");
110 let content_type = super::ContentType::from(content_type);
111
112 if !status.is_client_error() && !status.is_server_error() {
113 let content = resp.text().await?;
114 match content_type {
115 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
116 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Label`"))),
117 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Label`")))),
118 }
119 } else {
120 let content = resp.text().await?;
121 let entity: Option<FindByNameError> = serde_json::from_str(&content).ok();
122 Err(Error::ResponseError(ResponseContent {
123 status,
124 content,
125 entity,
126 }))
127 }
128}
129
130pub async fn update_all(
131 configuration: &configuration::Configuration,
132 label: Vec<models::Label>,
133) -> Result<Vec<models::Label>, Error<UpdateAllError>> {
134 let p_body_label = label;
136
137 let uri_str = format!("{}/api/label/update-all", configuration.base_path);
138 let mut req_builder = configuration
139 .client
140 .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_body_label);
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 => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Label>`"))),
166 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Label>`")))),
167 }
168 } else {
169 let content = resp.text().await?;
170 let entity: Option<UpdateAllError> = serde_json::from_str(&content).ok();
171 Err(Error::ResponseError(ResponseContent {
172 status,
173 content,
174 entity,
175 }))
176 }
177}