1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetQualityDefinitionByIdError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetQualityDefinitionLimitsError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ListQualityDefinitionError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum PutQualityDefinitionUpdateError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum UpdateQualityDefinitionError {
50 UnknownValue(serde_json::Value),
51}
52
53
54pub async fn get_quality_definition_by_id(configuration: &configuration::Configuration, id: i32) -> Result<models::QualityDefinitionResource, Error<GetQualityDefinitionByIdError>> {
55 let p_path_id = id;
57
58 let uri_str = format!("{}/api/v3/qualitydefinition/{id}", configuration.base_path, id=p_path_id);
59 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
60
61 if let Some(ref apikey) = configuration.api_key {
62 let key = apikey.key.clone();
63 let value = match apikey.prefix {
64 Some(ref prefix) => format!("{} {}", prefix, key),
65 None => key,
66 };
67 req_builder = req_builder.query(&[("apikey", value)]);
68 }
69 if let Some(ref user_agent) = configuration.user_agent {
70 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
71 }
72 if let Some(ref apikey) = configuration.api_key {
73 let key = apikey.key.clone();
74 let value = match apikey.prefix {
75 Some(ref prefix) => format!("{} {}", prefix, key),
76 None => key,
77 };
78 req_builder = req_builder.header("X-Api-Key", value);
79 };
80
81 let req = req_builder.build()?;
82 let resp = configuration.client.execute(req).await?;
83
84 let status = resp.status();
85 let content_type = resp
86 .headers()
87 .get("content-type")
88 .and_then(|v| v.to_str().ok())
89 .unwrap_or("application/octet-stream");
90 let content_type = super::ContentType::from(content_type);
91
92 if !status.is_client_error() && !status.is_server_error() {
93 let content = resp.text().await?;
94 match content_type {
95 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
96 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::QualityDefinitionResource`"))),
97 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::QualityDefinitionResource`")))),
98 }
99 } else {
100 let content = resp.text().await?;
101 let entity: Option<GetQualityDefinitionByIdError> = serde_json::from_str(&content).ok();
102 Err(Error::ResponseError(ResponseContent { status, content, entity }))
103 }
104}
105
106pub async fn get_quality_definition_limits(configuration: &configuration::Configuration, ) -> Result<models::QualityDefinitionLimitsResource, Error<GetQualityDefinitionLimitsError>> {
107
108 let uri_str = format!("{}/api/v3/qualitydefinition/limits", configuration.base_path);
109 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
110
111 if let Some(ref apikey) = configuration.api_key {
112 let key = apikey.key.clone();
113 let value = match apikey.prefix {
114 Some(ref prefix) => format!("{} {}", prefix, key),
115 None => key,
116 };
117 req_builder = req_builder.query(&[("apikey", value)]);
118 }
119 if let Some(ref user_agent) = configuration.user_agent {
120 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
121 }
122 if let Some(ref apikey) = configuration.api_key {
123 let key = apikey.key.clone();
124 let value = match apikey.prefix {
125 Some(ref prefix) => format!("{} {}", prefix, key),
126 None => key,
127 };
128 req_builder = req_builder.header("X-Api-Key", value);
129 };
130
131 let req = req_builder.build()?;
132 let resp = configuration.client.execute(req).await?;
133
134 let status = resp.status();
135 let content_type = resp
136 .headers()
137 .get("content-type")
138 .and_then(|v| v.to_str().ok())
139 .unwrap_or("application/octet-stream");
140 let content_type = super::ContentType::from(content_type);
141
142 if !status.is_client_error() && !status.is_server_error() {
143 let content = resp.text().await?;
144 match content_type {
145 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
146 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::QualityDefinitionLimitsResource`"))),
147 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::QualityDefinitionLimitsResource`")))),
148 }
149 } else {
150 let content = resp.text().await?;
151 let entity: Option<GetQualityDefinitionLimitsError> = serde_json::from_str(&content).ok();
152 Err(Error::ResponseError(ResponseContent { status, content, entity }))
153 }
154}
155
156pub async fn list_quality_definition(configuration: &configuration::Configuration, ) -> Result<Vec<models::QualityDefinitionResource>, Error<ListQualityDefinitionError>> {
157
158 let uri_str = format!("{}/api/v3/qualitydefinition", configuration.base_path);
159 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
160
161 if let Some(ref apikey) = configuration.api_key {
162 let key = apikey.key.clone();
163 let value = match apikey.prefix {
164 Some(ref prefix) => format!("{} {}", prefix, key),
165 None => key,
166 };
167 req_builder = req_builder.query(&[("apikey", value)]);
168 }
169 if let Some(ref user_agent) = configuration.user_agent {
170 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
171 }
172 if let Some(ref apikey) = configuration.api_key {
173 let key = apikey.key.clone();
174 let value = match apikey.prefix {
175 Some(ref prefix) => format!("{} {}", prefix, key),
176 None => key,
177 };
178 req_builder = req_builder.header("X-Api-Key", value);
179 };
180
181 let req = req_builder.build()?;
182 let resp = configuration.client.execute(req).await?;
183
184 let status = resp.status();
185 let content_type = resp
186 .headers()
187 .get("content-type")
188 .and_then(|v| v.to_str().ok())
189 .unwrap_or("application/octet-stream");
190 let content_type = super::ContentType::from(content_type);
191
192 if !status.is_client_error() && !status.is_server_error() {
193 let content = resp.text().await?;
194 match content_type {
195 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
196 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::QualityDefinitionResource>`"))),
197 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<models::QualityDefinitionResource>`")))),
198 }
199 } else {
200 let content = resp.text().await?;
201 let entity: Option<ListQualityDefinitionError> = serde_json::from_str(&content).ok();
202 Err(Error::ResponseError(ResponseContent { status, content, entity }))
203 }
204}
205
206pub async fn put_quality_definition_update(configuration: &configuration::Configuration, quality_definition_resource: Option<Vec<models::QualityDefinitionResource>>) -> Result<(), Error<PutQualityDefinitionUpdateError>> {
207 let p_body_quality_definition_resource = quality_definition_resource;
209
210 let uri_str = format!("{}/api/v3/qualitydefinition/update", configuration.base_path);
211 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
212
213 if let Some(ref apikey) = configuration.api_key {
214 let key = apikey.key.clone();
215 let value = match apikey.prefix {
216 Some(ref prefix) => format!("{} {}", prefix, key),
217 None => key,
218 };
219 req_builder = req_builder.query(&[("apikey", value)]);
220 }
221 if let Some(ref user_agent) = configuration.user_agent {
222 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
223 }
224 if let Some(ref apikey) = configuration.api_key {
225 let key = apikey.key.clone();
226 let value = match apikey.prefix {
227 Some(ref prefix) => format!("{} {}", prefix, key),
228 None => key,
229 };
230 req_builder = req_builder.header("X-Api-Key", value);
231 };
232 req_builder = req_builder.json(&p_body_quality_definition_resource);
233
234 let req = req_builder.build()?;
235 let resp = configuration.client.execute(req).await?;
236
237 let status = resp.status();
238
239 if !status.is_client_error() && !status.is_server_error() {
240 Ok(())
241 } else {
242 let content = resp.text().await?;
243 let entity: Option<PutQualityDefinitionUpdateError> = serde_json::from_str(&content).ok();
244 Err(Error::ResponseError(ResponseContent { status, content, entity }))
245 }
246}
247
248pub async fn update_quality_definition(configuration: &configuration::Configuration, id: &str, quality_definition_resource: Option<models::QualityDefinitionResource>) -> Result<models::QualityDefinitionResource, Error<UpdateQualityDefinitionError>> {
249 let p_path_id = id;
251 let p_body_quality_definition_resource = quality_definition_resource;
252
253 let uri_str = format!("{}/api/v3/qualitydefinition/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
254 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
255
256 if let Some(ref apikey) = configuration.api_key {
257 let key = apikey.key.clone();
258 let value = match apikey.prefix {
259 Some(ref prefix) => format!("{} {}", prefix, key),
260 None => key,
261 };
262 req_builder = req_builder.query(&[("apikey", value)]);
263 }
264 if let Some(ref user_agent) = configuration.user_agent {
265 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
266 }
267 if let Some(ref apikey) = configuration.api_key {
268 let key = apikey.key.clone();
269 let value = match apikey.prefix {
270 Some(ref prefix) => format!("{} {}", prefix, key),
271 None => key,
272 };
273 req_builder = req_builder.header("X-Api-Key", value);
274 };
275 req_builder = req_builder.json(&p_body_quality_definition_resource);
276
277 let req = req_builder.build()?;
278 let resp = configuration.client.execute(req).await?;
279
280 let status = resp.status();
281 let content_type = resp
282 .headers()
283 .get("content-type")
284 .and_then(|v| v.to_str().ok())
285 .unwrap_or("application/octet-stream");
286 let content_type = super::ContentType::from(content_type);
287
288 if !status.is_client_error() && !status.is_server_error() {
289 let content = resp.text().await?;
290 match content_type {
291 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
292 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::QualityDefinitionResource`"))),
293 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::QualityDefinitionResource`")))),
294 }
295 } else {
296 let content = resp.text().await?;
297 let entity: Option<UpdateQualityDefinitionError> = serde_json::from_str(&content).ok();
298 Err(Error::ResponseError(ResponseContent { status, content, entity }))
299 }
300}
301