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 AnnotationQueuesCreateQueueItemError {
22 Status400(serde_json::Value),
23 Status401(serde_json::Value),
24 Status403(serde_json::Value),
25 Status404(serde_json::Value),
26 Status405(serde_json::Value),
27 UnknownValue(serde_json::Value),
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum AnnotationQueuesDeleteQueueItemError {
34 Status400(serde_json::Value),
35 Status401(serde_json::Value),
36 Status403(serde_json::Value),
37 Status404(serde_json::Value),
38 Status405(serde_json::Value),
39 UnknownValue(serde_json::Value),
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum AnnotationQueuesGetQueueError {
46 Status400(serde_json::Value),
47 Status401(serde_json::Value),
48 Status403(serde_json::Value),
49 Status404(serde_json::Value),
50 Status405(serde_json::Value),
51 UnknownValue(serde_json::Value),
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum AnnotationQueuesGetQueueItemError {
58 Status400(serde_json::Value),
59 Status401(serde_json::Value),
60 Status403(serde_json::Value),
61 Status404(serde_json::Value),
62 Status405(serde_json::Value),
63 UnknownValue(serde_json::Value),
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum AnnotationQueuesListQueueItemsError {
70 Status400(serde_json::Value),
71 Status401(serde_json::Value),
72 Status403(serde_json::Value),
73 Status404(serde_json::Value),
74 Status405(serde_json::Value),
75 UnknownValue(serde_json::Value),
76}
77
78#[derive(Debug, Clone, Serialize, Deserialize)]
80#[serde(untagged)]
81pub enum AnnotationQueuesListQueuesError {
82 Status400(serde_json::Value),
83 Status401(serde_json::Value),
84 Status403(serde_json::Value),
85 Status404(serde_json::Value),
86 Status405(serde_json::Value),
87 UnknownValue(serde_json::Value),
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize)]
92#[serde(untagged)]
93pub enum AnnotationQueuesUpdateQueueItemError {
94 Status400(serde_json::Value),
95 Status401(serde_json::Value),
96 Status403(serde_json::Value),
97 Status404(serde_json::Value),
98 Status405(serde_json::Value),
99 UnknownValue(serde_json::Value),
100}
101
102
103pub async fn annotation_queues_create_queue_item(configuration: &configuration::Configuration, queue_id: &str, create_annotation_queue_item_request: models::CreateAnnotationQueueItemRequest) -> Result<models::AnnotationQueueItem, Error<AnnotationQueuesCreateQueueItemError>> {
105 let p_queue_id = queue_id;
107 let p_create_annotation_queue_item_request = create_annotation_queue_item_request;
108
109 let uri_str = format!("{}/api/public/annotation-queues/{queueId}/items", configuration.base_path, queueId=crate::apis::urlencode(p_queue_id));
110 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
111
112 if let Some(ref user_agent) = configuration.user_agent {
113 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
114 }
115 if let Some(ref auth_conf) = configuration.basic_auth {
116 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
117 };
118 req_builder = req_builder.json(&p_create_annotation_queue_item_request);
119
120 let req = req_builder.build()?;
121 let resp = configuration.client.execute(req).await?;
122
123 let status = resp.status();
124 let content_type = resp
125 .headers()
126 .get("content-type")
127 .and_then(|v| v.to_str().ok())
128 .unwrap_or("application/octet-stream");
129 let content_type = super::ContentType::from(content_type);
130
131 if !status.is_client_error() && !status.is_server_error() {
132 let content = resp.text().await?;
133 match content_type {
134 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
135 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AnnotationQueueItem`"))),
136 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::AnnotationQueueItem`")))),
137 }
138 } else {
139 let content = resp.text().await?;
140 let entity: Option<AnnotationQueuesCreateQueueItemError> = serde_json::from_str(&content).ok();
141 Err(Error::ResponseError(ResponseContent { status, content, entity }))
142 }
143}
144
145pub async fn annotation_queues_delete_queue_item(configuration: &configuration::Configuration, queue_id: &str, item_id: &str) -> Result<models::DeleteAnnotationQueueItemResponse, Error<AnnotationQueuesDeleteQueueItemError>> {
147 let p_queue_id = queue_id;
149 let p_item_id = item_id;
150
151 let uri_str = format!("{}/api/public/annotation-queues/{queueId}/items/{itemId}", configuration.base_path, queueId=crate::apis::urlencode(p_queue_id), itemId=crate::apis::urlencode(p_item_id));
152 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
153
154 if let Some(ref user_agent) = configuration.user_agent {
155 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
156 }
157 if let Some(ref auth_conf) = configuration.basic_auth {
158 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
159 };
160
161 let req = req_builder.build()?;
162 let resp = configuration.client.execute(req).await?;
163
164 let status = resp.status();
165 let content_type = resp
166 .headers()
167 .get("content-type")
168 .and_then(|v| v.to_str().ok())
169 .unwrap_or("application/octet-stream");
170 let content_type = super::ContentType::from(content_type);
171
172 if !status.is_client_error() && !status.is_server_error() {
173 let content = resp.text().await?;
174 match content_type {
175 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
176 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAnnotationQueueItemResponse`"))),
177 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::DeleteAnnotationQueueItemResponse`")))),
178 }
179 } else {
180 let content = resp.text().await?;
181 let entity: Option<AnnotationQueuesDeleteQueueItemError> = serde_json::from_str(&content).ok();
182 Err(Error::ResponseError(ResponseContent { status, content, entity }))
183 }
184}
185
186pub async fn annotation_queues_get_queue(configuration: &configuration::Configuration, queue_id: &str) -> Result<models::AnnotationQueue, Error<AnnotationQueuesGetQueueError>> {
188 let p_queue_id = queue_id;
190
191 let uri_str = format!("{}/api/public/annotation-queues/{queueId}", configuration.base_path, queueId=crate::apis::urlencode(p_queue_id));
192 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
193
194 if let Some(ref user_agent) = configuration.user_agent {
195 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
196 }
197 if let Some(ref auth_conf) = configuration.basic_auth {
198 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
199 };
200
201 let req = req_builder.build()?;
202 let resp = configuration.client.execute(req).await?;
203
204 let status = resp.status();
205 let content_type = resp
206 .headers()
207 .get("content-type")
208 .and_then(|v| v.to_str().ok())
209 .unwrap_or("application/octet-stream");
210 let content_type = super::ContentType::from(content_type);
211
212 if !status.is_client_error() && !status.is_server_error() {
213 let content = resp.text().await?;
214 match content_type {
215 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
216 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AnnotationQueue`"))),
217 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::AnnotationQueue`")))),
218 }
219 } else {
220 let content = resp.text().await?;
221 let entity: Option<AnnotationQueuesGetQueueError> = serde_json::from_str(&content).ok();
222 Err(Error::ResponseError(ResponseContent { status, content, entity }))
223 }
224}
225
226pub async fn annotation_queues_get_queue_item(configuration: &configuration::Configuration, queue_id: &str, item_id: &str) -> Result<models::AnnotationQueueItem, Error<AnnotationQueuesGetQueueItemError>> {
228 let p_queue_id = queue_id;
230 let p_item_id = item_id;
231
232 let uri_str = format!("{}/api/public/annotation-queues/{queueId}/items/{itemId}", configuration.base_path, queueId=crate::apis::urlencode(p_queue_id), itemId=crate::apis::urlencode(p_item_id));
233 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
234
235 if let Some(ref user_agent) = configuration.user_agent {
236 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
237 }
238 if let Some(ref auth_conf) = configuration.basic_auth {
239 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
240 };
241
242 let req = req_builder.build()?;
243 let resp = configuration.client.execute(req).await?;
244
245 let status = resp.status();
246 let content_type = resp
247 .headers()
248 .get("content-type")
249 .and_then(|v| v.to_str().ok())
250 .unwrap_or("application/octet-stream");
251 let content_type = super::ContentType::from(content_type);
252
253 if !status.is_client_error() && !status.is_server_error() {
254 let content = resp.text().await?;
255 match content_type {
256 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
257 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AnnotationQueueItem`"))),
258 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::AnnotationQueueItem`")))),
259 }
260 } else {
261 let content = resp.text().await?;
262 let entity: Option<AnnotationQueuesGetQueueItemError> = serde_json::from_str(&content).ok();
263 Err(Error::ResponseError(ResponseContent { status, content, entity }))
264 }
265}
266
267pub async fn annotation_queues_list_queue_items(configuration: &configuration::Configuration, queue_id: &str, status: Option<models::AnnotationQueueStatus>, page: Option<i32>, limit: Option<i32>) -> Result<models::PaginatedAnnotationQueueItems, Error<AnnotationQueuesListQueueItemsError>> {
269 let p_queue_id = queue_id;
271 let p_status = status;
272 let p_page = page;
273 let p_limit = limit;
274
275 let uri_str = format!("{}/api/public/annotation-queues/{queueId}/items", configuration.base_path, queueId=crate::apis::urlencode(p_queue_id));
276 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
277
278 if let Some(ref param_value) = p_status {
279 req_builder = req_builder.query(&[("status", ¶m_value.to_string())]);
280 }
281 if let Some(ref param_value) = p_page {
282 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
283 }
284 if let Some(ref param_value) = p_limit {
285 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
286 }
287 if let Some(ref user_agent) = configuration.user_agent {
288 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
289 }
290 if let Some(ref auth_conf) = configuration.basic_auth {
291 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
292 };
293
294 let req = req_builder.build()?;
295 let resp = configuration.client.execute(req).await?;
296
297 let status = resp.status();
298 let content_type = resp
299 .headers()
300 .get("content-type")
301 .and_then(|v| v.to_str().ok())
302 .unwrap_or("application/octet-stream");
303 let content_type = super::ContentType::from(content_type);
304
305 if !status.is_client_error() && !status.is_server_error() {
306 let content = resp.text().await?;
307 match content_type {
308 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
309 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedAnnotationQueueItems`"))),
310 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::PaginatedAnnotationQueueItems`")))),
311 }
312 } else {
313 let content = resp.text().await?;
314 let entity: Option<AnnotationQueuesListQueueItemsError> = serde_json::from_str(&content).ok();
315 Err(Error::ResponseError(ResponseContent { status, content, entity }))
316 }
317}
318
319pub async fn annotation_queues_list_queues(configuration: &configuration::Configuration, page: Option<i32>, limit: Option<i32>) -> Result<models::PaginatedAnnotationQueues, Error<AnnotationQueuesListQueuesError>> {
321 let p_page = page;
323 let p_limit = limit;
324
325 let uri_str = format!("{}/api/public/annotation-queues", configuration.base_path);
326 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
327
328 if let Some(ref param_value) = p_page {
329 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
330 }
331 if let Some(ref param_value) = p_limit {
332 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
333 }
334 if let Some(ref user_agent) = configuration.user_agent {
335 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
336 }
337 if let Some(ref auth_conf) = configuration.basic_auth {
338 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
339 };
340
341 let req = req_builder.build()?;
342 let resp = configuration.client.execute(req).await?;
343
344 let status = resp.status();
345 let content_type = resp
346 .headers()
347 .get("content-type")
348 .and_then(|v| v.to_str().ok())
349 .unwrap_or("application/octet-stream");
350 let content_type = super::ContentType::from(content_type);
351
352 if !status.is_client_error() && !status.is_server_error() {
353 let content = resp.text().await?;
354 match content_type {
355 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
356 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedAnnotationQueues`"))),
357 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::PaginatedAnnotationQueues`")))),
358 }
359 } else {
360 let content = resp.text().await?;
361 let entity: Option<AnnotationQueuesListQueuesError> = serde_json::from_str(&content).ok();
362 Err(Error::ResponseError(ResponseContent { status, content, entity }))
363 }
364}
365
366pub async fn annotation_queues_update_queue_item(configuration: &configuration::Configuration, queue_id: &str, item_id: &str, update_annotation_queue_item_request: models::UpdateAnnotationQueueItemRequest) -> Result<models::AnnotationQueueItem, Error<AnnotationQueuesUpdateQueueItemError>> {
368 let p_queue_id = queue_id;
370 let p_item_id = item_id;
371 let p_update_annotation_queue_item_request = update_annotation_queue_item_request;
372
373 let uri_str = format!("{}/api/public/annotation-queues/{queueId}/items/{itemId}", configuration.base_path, queueId=crate::apis::urlencode(p_queue_id), itemId=crate::apis::urlencode(p_item_id));
374 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
375
376 if let Some(ref user_agent) = configuration.user_agent {
377 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
378 }
379 if let Some(ref auth_conf) = configuration.basic_auth {
380 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
381 };
382 req_builder = req_builder.json(&p_update_annotation_queue_item_request);
383
384 let req = req_builder.build()?;
385 let resp = configuration.client.execute(req).await?;
386
387 let status = resp.status();
388 let content_type = resp
389 .headers()
390 .get("content-type")
391 .and_then(|v| v.to_str().ok())
392 .unwrap_or("application/octet-stream");
393 let content_type = super::ContentType::from(content_type);
394
395 if !status.is_client_error() && !status.is_server_error() {
396 let content = resp.text().await?;
397 match content_type {
398 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
399 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AnnotationQueueItem`"))),
400 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::AnnotationQueueItem`")))),
401 }
402 } else {
403 let content = resp.text().await?;
404 let entity: Option<AnnotationQueuesUpdateQueueItemError> = serde_json::from_str(&content).ok();
405 Err(Error::ResponseError(ResponseContent { status, content, entity }))
406 }
407}
408