langfuse_client_base/apis/
annotation_queues_api.rs

1/*
2 * langfuse
3 *
4 * ## Authentication  Authenticate with the API using [Basic Auth](https://en.wikipedia.org/wiki/Basic_access_authentication), get API keys in the project settings:  - username: Langfuse Public Key - password: Langfuse Secret Key  ## Exports  - OpenAPI spec: https://cloud.langfuse.com/generated/api/openapi.yml - Postman collection: https://cloud.langfuse.com/generated/postman/collection.json
5 *
6 * The version of the OpenAPI document:
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16/// struct for typed errors of method [`annotation_queues_create_queue`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum AnnotationQueuesCreateQueueError {
20    Status400(serde_json::Value),
21    Status401(serde_json::Value),
22    Status403(serde_json::Value),
23    Status404(serde_json::Value),
24    Status405(serde_json::Value),
25    UnknownValue(serde_json::Value),
26}
27
28/// struct for typed errors of method [`annotation_queues_create_queue_assignment`]
29#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum AnnotationQueuesCreateQueueAssignmentError {
32    Status400(serde_json::Value),
33    Status401(serde_json::Value),
34    Status403(serde_json::Value),
35    Status404(serde_json::Value),
36    Status405(serde_json::Value),
37    UnknownValue(serde_json::Value),
38}
39
40/// struct for typed errors of method [`annotation_queues_create_queue_item`]
41#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum AnnotationQueuesCreateQueueItemError {
44    Status400(serde_json::Value),
45    Status401(serde_json::Value),
46    Status403(serde_json::Value),
47    Status404(serde_json::Value),
48    Status405(serde_json::Value),
49    UnknownValue(serde_json::Value),
50}
51
52/// struct for typed errors of method [`annotation_queues_delete_queue_assignment`]
53#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum AnnotationQueuesDeleteQueueAssignmentError {
56    Status400(serde_json::Value),
57    Status401(serde_json::Value),
58    Status403(serde_json::Value),
59    Status404(serde_json::Value),
60    Status405(serde_json::Value),
61    UnknownValue(serde_json::Value),
62}
63
64/// struct for typed errors of method [`annotation_queues_delete_queue_item`]
65#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(untagged)]
67pub enum AnnotationQueuesDeleteQueueItemError {
68    Status400(serde_json::Value),
69    Status401(serde_json::Value),
70    Status403(serde_json::Value),
71    Status404(serde_json::Value),
72    Status405(serde_json::Value),
73    UnknownValue(serde_json::Value),
74}
75
76/// struct for typed errors of method [`annotation_queues_get_queue`]
77#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum AnnotationQueuesGetQueueError {
80    Status400(serde_json::Value),
81    Status401(serde_json::Value),
82    Status403(serde_json::Value),
83    Status404(serde_json::Value),
84    Status405(serde_json::Value),
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`annotation_queues_get_queue_item`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum AnnotationQueuesGetQueueItemError {
92    Status400(serde_json::Value),
93    Status401(serde_json::Value),
94    Status403(serde_json::Value),
95    Status404(serde_json::Value),
96    Status405(serde_json::Value),
97    UnknownValue(serde_json::Value),
98}
99
100/// struct for typed errors of method [`annotation_queues_list_queue_items`]
101#[derive(Debug, Clone, Serialize, Deserialize)]
102#[serde(untagged)]
103pub enum AnnotationQueuesListQueueItemsError {
104    Status400(serde_json::Value),
105    Status401(serde_json::Value),
106    Status403(serde_json::Value),
107    Status404(serde_json::Value),
108    Status405(serde_json::Value),
109    UnknownValue(serde_json::Value),
110}
111
112/// struct for typed errors of method [`annotation_queues_list_queues`]
113#[derive(Debug, Clone, Serialize, Deserialize)]
114#[serde(untagged)]
115pub enum AnnotationQueuesListQueuesError {
116    Status400(serde_json::Value),
117    Status401(serde_json::Value),
118    Status403(serde_json::Value),
119    Status404(serde_json::Value),
120    Status405(serde_json::Value),
121    UnknownValue(serde_json::Value),
122}
123
124/// struct for typed errors of method [`annotation_queues_update_queue_item`]
125#[derive(Debug, Clone, Serialize, Deserialize)]
126#[serde(untagged)]
127pub enum AnnotationQueuesUpdateQueueItemError {
128    Status400(serde_json::Value),
129    Status401(serde_json::Value),
130    Status403(serde_json::Value),
131    Status404(serde_json::Value),
132    Status405(serde_json::Value),
133    UnknownValue(serde_json::Value),
134}
135
136/// Create an annotation queue
137#[bon::builder]
138pub async fn annotation_queues_create_queue(
139    configuration: &configuration::Configuration,
140    create_annotation_queue_request: models::CreateAnnotationQueueRequest,
141) -> Result<models::AnnotationQueue, Error<AnnotationQueuesCreateQueueError>> {
142    // add a prefix to parameters to efficiently prevent name collisions
143    let p_body_create_annotation_queue_request = create_annotation_queue_request;
144
145    let uri_str = format!("{}/api/public/annotation-queues", configuration.base_path);
146    let mut req_builder = configuration
147        .client
148        .request(reqwest::Method::POST, &uri_str);
149
150    if let Some(ref user_agent) = configuration.user_agent {
151        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
152    }
153    if let Some(ref auth_conf) = configuration.basic_auth {
154        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
155    };
156    req_builder = req_builder.json(&p_body_create_annotation_queue_request);
157
158    let req = req_builder.build()?;
159    let resp = configuration.client.execute(req).await?;
160
161    let status = resp.status();
162    let content_type = resp
163        .headers()
164        .get("content-type")
165        .and_then(|v| v.to_str().ok())
166        .unwrap_or("application/octet-stream");
167    let content_type = super::ContentType::from(content_type);
168
169    if !status.is_client_error() && !status.is_server_error() {
170        let content = resp.text().await?;
171        match content_type {
172            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
173            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AnnotationQueue`"))),
174            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`")))),
175        }
176    } else {
177        let content = resp.text().await?;
178        let entity: Option<AnnotationQueuesCreateQueueError> = serde_json::from_str(&content).ok();
179        Err(Error::ResponseError(ResponseContent {
180            status,
181            content,
182            entity,
183        }))
184    }
185}
186
187/// Create an assignment for a user to an annotation queue
188#[bon::builder]
189pub async fn annotation_queues_create_queue_assignment(
190    configuration: &configuration::Configuration,
191    queue_id: &str,
192    annotation_queue_assignment_request: models::AnnotationQueueAssignmentRequest,
193) -> Result<
194    models::CreateAnnotationQueueAssignmentResponse,
195    Error<AnnotationQueuesCreateQueueAssignmentError>,
196> {
197    // add a prefix to parameters to efficiently prevent name collisions
198    let p_path_queue_id = queue_id;
199    let p_body_annotation_queue_assignment_request = annotation_queue_assignment_request;
200
201    let uri_str = format!(
202        "{}/api/public/annotation-queues/{queueId}/assignments",
203        configuration.base_path,
204        queueId = crate::apis::urlencode(p_path_queue_id)
205    );
206    let mut req_builder = configuration
207        .client
208        .request(reqwest::Method::POST, &uri_str);
209
210    if let Some(ref user_agent) = configuration.user_agent {
211        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
212    }
213    if let Some(ref auth_conf) = configuration.basic_auth {
214        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
215    };
216    req_builder = req_builder.json(&p_body_annotation_queue_assignment_request);
217
218    let req = req_builder.build()?;
219    let resp = configuration.client.execute(req).await?;
220
221    let status = resp.status();
222    let content_type = resp
223        .headers()
224        .get("content-type")
225        .and_then(|v| v.to_str().ok())
226        .unwrap_or("application/octet-stream");
227    let content_type = super::ContentType::from(content_type);
228
229    if !status.is_client_error() && !status.is_server_error() {
230        let content = resp.text().await?;
231        match content_type {
232            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
233            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateAnnotationQueueAssignmentResponse`"))),
234            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::CreateAnnotationQueueAssignmentResponse`")))),
235        }
236    } else {
237        let content = resp.text().await?;
238        let entity: Option<AnnotationQueuesCreateQueueAssignmentError> =
239            serde_json::from_str(&content).ok();
240        Err(Error::ResponseError(ResponseContent {
241            status,
242            content,
243            entity,
244        }))
245    }
246}
247
248/// Add an item to an annotation queue
249#[bon::builder]
250pub async fn annotation_queues_create_queue_item(
251    configuration: &configuration::Configuration,
252    queue_id: &str,
253    create_annotation_queue_item_request: models::CreateAnnotationQueueItemRequest,
254) -> Result<models::AnnotationQueueItem, Error<AnnotationQueuesCreateQueueItemError>> {
255    // add a prefix to parameters to efficiently prevent name collisions
256    let p_path_queue_id = queue_id;
257    let p_body_create_annotation_queue_item_request = create_annotation_queue_item_request;
258
259    let uri_str = format!(
260        "{}/api/public/annotation-queues/{queueId}/items",
261        configuration.base_path,
262        queueId = crate::apis::urlencode(p_path_queue_id)
263    );
264    let mut req_builder = configuration
265        .client
266        .request(reqwest::Method::POST, &uri_str);
267
268    if let Some(ref user_agent) = configuration.user_agent {
269        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
270    }
271    if let Some(ref auth_conf) = configuration.basic_auth {
272        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
273    };
274    req_builder = req_builder.json(&p_body_create_annotation_queue_item_request);
275
276    let req = req_builder.build()?;
277    let resp = configuration.client.execute(req).await?;
278
279    let status = resp.status();
280    let content_type = resp
281        .headers()
282        .get("content-type")
283        .and_then(|v| v.to_str().ok())
284        .unwrap_or("application/octet-stream");
285    let content_type = super::ContentType::from(content_type);
286
287    if !status.is_client_error() && !status.is_server_error() {
288        let content = resp.text().await?;
289        match content_type {
290            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
291            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AnnotationQueueItem`"))),
292            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`")))),
293        }
294    } else {
295        let content = resp.text().await?;
296        let entity: Option<AnnotationQueuesCreateQueueItemError> =
297            serde_json::from_str(&content).ok();
298        Err(Error::ResponseError(ResponseContent {
299            status,
300            content,
301            entity,
302        }))
303    }
304}
305
306/// Delete an assignment for a user to an annotation queue
307#[bon::builder]
308pub async fn annotation_queues_delete_queue_assignment(
309    configuration: &configuration::Configuration,
310    queue_id: &str,
311    annotation_queue_assignment_request: models::AnnotationQueueAssignmentRequest,
312) -> Result<
313    models::DeleteAnnotationQueueAssignmentResponse,
314    Error<AnnotationQueuesDeleteQueueAssignmentError>,
315> {
316    // add a prefix to parameters to efficiently prevent name collisions
317    let p_path_queue_id = queue_id;
318    let p_body_annotation_queue_assignment_request = annotation_queue_assignment_request;
319
320    let uri_str = format!(
321        "{}/api/public/annotation-queues/{queueId}/assignments",
322        configuration.base_path,
323        queueId = crate::apis::urlencode(p_path_queue_id)
324    );
325    let mut req_builder = configuration
326        .client
327        .request(reqwest::Method::DELETE, &uri_str);
328
329    if let Some(ref user_agent) = configuration.user_agent {
330        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
331    }
332    if let Some(ref auth_conf) = configuration.basic_auth {
333        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
334    };
335    req_builder = req_builder.json(&p_body_annotation_queue_assignment_request);
336
337    let req = req_builder.build()?;
338    let resp = configuration.client.execute(req).await?;
339
340    let status = resp.status();
341    let content_type = resp
342        .headers()
343        .get("content-type")
344        .and_then(|v| v.to_str().ok())
345        .unwrap_or("application/octet-stream");
346    let content_type = super::ContentType::from(content_type);
347
348    if !status.is_client_error() && !status.is_server_error() {
349        let content = resp.text().await?;
350        match content_type {
351            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
352            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAnnotationQueueAssignmentResponse`"))),
353            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::DeleteAnnotationQueueAssignmentResponse`")))),
354        }
355    } else {
356        let content = resp.text().await?;
357        let entity: Option<AnnotationQueuesDeleteQueueAssignmentError> =
358            serde_json::from_str(&content).ok();
359        Err(Error::ResponseError(ResponseContent {
360            status,
361            content,
362            entity,
363        }))
364    }
365}
366
367/// Remove an item from an annotation queue
368#[bon::builder]
369pub async fn annotation_queues_delete_queue_item(
370    configuration: &configuration::Configuration,
371    queue_id: &str,
372    item_id: &str,
373) -> Result<models::DeleteAnnotationQueueItemResponse, Error<AnnotationQueuesDeleteQueueItemError>>
374{
375    // add a prefix to parameters to efficiently prevent name collisions
376    let p_path_queue_id = queue_id;
377    let p_path_item_id = item_id;
378
379    let uri_str = format!(
380        "{}/api/public/annotation-queues/{queueId}/items/{itemId}",
381        configuration.base_path,
382        queueId = crate::apis::urlencode(p_path_queue_id),
383        itemId = crate::apis::urlencode(p_path_item_id)
384    );
385    let mut req_builder = configuration
386        .client
387        .request(reqwest::Method::DELETE, &uri_str);
388
389    if let Some(ref user_agent) = configuration.user_agent {
390        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
391    }
392    if let Some(ref auth_conf) = configuration.basic_auth {
393        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
394    };
395
396    let req = req_builder.build()?;
397    let resp = configuration.client.execute(req).await?;
398
399    let status = resp.status();
400    let content_type = resp
401        .headers()
402        .get("content-type")
403        .and_then(|v| v.to_str().ok())
404        .unwrap_or("application/octet-stream");
405    let content_type = super::ContentType::from(content_type);
406
407    if !status.is_client_error() && !status.is_server_error() {
408        let content = resp.text().await?;
409        match content_type {
410            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
411            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAnnotationQueueItemResponse`"))),
412            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`")))),
413        }
414    } else {
415        let content = resp.text().await?;
416        let entity: Option<AnnotationQueuesDeleteQueueItemError> =
417            serde_json::from_str(&content).ok();
418        Err(Error::ResponseError(ResponseContent {
419            status,
420            content,
421            entity,
422        }))
423    }
424}
425
426/// Get an annotation queue by ID
427#[bon::builder]
428pub async fn annotation_queues_get_queue(
429    configuration: &configuration::Configuration,
430    queue_id: &str,
431) -> Result<models::AnnotationQueue, Error<AnnotationQueuesGetQueueError>> {
432    // add a prefix to parameters to efficiently prevent name collisions
433    let p_path_queue_id = queue_id;
434
435    let uri_str = format!(
436        "{}/api/public/annotation-queues/{queueId}",
437        configuration.base_path,
438        queueId = crate::apis::urlencode(p_path_queue_id)
439    );
440    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
441
442    if let Some(ref user_agent) = configuration.user_agent {
443        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
444    }
445    if let Some(ref auth_conf) = configuration.basic_auth {
446        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
447    };
448
449    let req = req_builder.build()?;
450    let resp = configuration.client.execute(req).await?;
451
452    let status = resp.status();
453    let content_type = resp
454        .headers()
455        .get("content-type")
456        .and_then(|v| v.to_str().ok())
457        .unwrap_or("application/octet-stream");
458    let content_type = super::ContentType::from(content_type);
459
460    if !status.is_client_error() && !status.is_server_error() {
461        let content = resp.text().await?;
462        match content_type {
463            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
464            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AnnotationQueue`"))),
465            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`")))),
466        }
467    } else {
468        let content = resp.text().await?;
469        let entity: Option<AnnotationQueuesGetQueueError> = serde_json::from_str(&content).ok();
470        Err(Error::ResponseError(ResponseContent {
471            status,
472            content,
473            entity,
474        }))
475    }
476}
477
478/// Get a specific item from an annotation queue
479#[bon::builder]
480pub async fn annotation_queues_get_queue_item(
481    configuration: &configuration::Configuration,
482    queue_id: &str,
483    item_id: &str,
484) -> Result<models::AnnotationQueueItem, Error<AnnotationQueuesGetQueueItemError>> {
485    // add a prefix to parameters to efficiently prevent name collisions
486    let p_path_queue_id = queue_id;
487    let p_path_item_id = item_id;
488
489    let uri_str = format!(
490        "{}/api/public/annotation-queues/{queueId}/items/{itemId}",
491        configuration.base_path,
492        queueId = crate::apis::urlencode(p_path_queue_id),
493        itemId = crate::apis::urlencode(p_path_item_id)
494    );
495    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
496
497    if let Some(ref user_agent) = configuration.user_agent {
498        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
499    }
500    if let Some(ref auth_conf) = configuration.basic_auth {
501        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
502    };
503
504    let req = req_builder.build()?;
505    let resp = configuration.client.execute(req).await?;
506
507    let status = resp.status();
508    let content_type = resp
509        .headers()
510        .get("content-type")
511        .and_then(|v| v.to_str().ok())
512        .unwrap_or("application/octet-stream");
513    let content_type = super::ContentType::from(content_type);
514
515    if !status.is_client_error() && !status.is_server_error() {
516        let content = resp.text().await?;
517        match content_type {
518            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
519            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AnnotationQueueItem`"))),
520            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`")))),
521        }
522    } else {
523        let content = resp.text().await?;
524        let entity: Option<AnnotationQueuesGetQueueItemError> = serde_json::from_str(&content).ok();
525        Err(Error::ResponseError(ResponseContent {
526            status,
527            content,
528            entity,
529        }))
530    }
531}
532
533/// Get items for a specific annotation queue
534#[bon::builder]
535pub async fn annotation_queues_list_queue_items(
536    configuration: &configuration::Configuration,
537    queue_id: &str,
538    status: Option<models::AnnotationQueueStatus>,
539    page: Option<i32>,
540    limit: Option<i32>,
541) -> Result<models::PaginatedAnnotationQueueItems, Error<AnnotationQueuesListQueueItemsError>> {
542    // add a prefix to parameters to efficiently prevent name collisions
543    let p_path_queue_id = queue_id;
544    let p_query_status = status;
545    let p_query_page = page;
546    let p_query_limit = limit;
547
548    let uri_str = format!(
549        "{}/api/public/annotation-queues/{queueId}/items",
550        configuration.base_path,
551        queueId = crate::apis::urlencode(p_path_queue_id)
552    );
553    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
554
555    if let Some(ref param_value) = p_query_status {
556        req_builder = req_builder.query(&[("status", &param_value.to_string())]);
557    }
558    if let Some(ref param_value) = p_query_page {
559        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
560    }
561    if let Some(ref param_value) = p_query_limit {
562        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
563    }
564    if let Some(ref user_agent) = configuration.user_agent {
565        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
566    }
567    if let Some(ref auth_conf) = configuration.basic_auth {
568        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
569    };
570
571    let req = req_builder.build()?;
572    let resp = configuration.client.execute(req).await?;
573
574    let status = resp.status();
575    let content_type = resp
576        .headers()
577        .get("content-type")
578        .and_then(|v| v.to_str().ok())
579        .unwrap_or("application/octet-stream");
580    let content_type = super::ContentType::from(content_type);
581
582    if !status.is_client_error() && !status.is_server_error() {
583        let content = resp.text().await?;
584        match content_type {
585            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
586            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedAnnotationQueueItems`"))),
587            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`")))),
588        }
589    } else {
590        let content = resp.text().await?;
591        let entity: Option<AnnotationQueuesListQueueItemsError> =
592            serde_json::from_str(&content).ok();
593        Err(Error::ResponseError(ResponseContent {
594            status,
595            content,
596            entity,
597        }))
598    }
599}
600
601/// Get all annotation queues
602#[bon::builder]
603pub async fn annotation_queues_list_queues(
604    configuration: &configuration::Configuration,
605    page: Option<i32>,
606    limit: Option<i32>,
607) -> Result<models::PaginatedAnnotationQueues, Error<AnnotationQueuesListQueuesError>> {
608    // add a prefix to parameters to efficiently prevent name collisions
609    let p_query_page = page;
610    let p_query_limit = limit;
611
612    let uri_str = format!("{}/api/public/annotation-queues", configuration.base_path);
613    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
614
615    if let Some(ref param_value) = p_query_page {
616        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
617    }
618    if let Some(ref param_value) = p_query_limit {
619        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
620    }
621    if let Some(ref user_agent) = configuration.user_agent {
622        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
623    }
624    if let Some(ref auth_conf) = configuration.basic_auth {
625        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
626    };
627
628    let req = req_builder.build()?;
629    let resp = configuration.client.execute(req).await?;
630
631    let status = resp.status();
632    let content_type = resp
633        .headers()
634        .get("content-type")
635        .and_then(|v| v.to_str().ok())
636        .unwrap_or("application/octet-stream");
637    let content_type = super::ContentType::from(content_type);
638
639    if !status.is_client_error() && !status.is_server_error() {
640        let content = resp.text().await?;
641        match content_type {
642            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
643            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedAnnotationQueues`"))),
644            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`")))),
645        }
646    } else {
647        let content = resp.text().await?;
648        let entity: Option<AnnotationQueuesListQueuesError> = serde_json::from_str(&content).ok();
649        Err(Error::ResponseError(ResponseContent {
650            status,
651            content,
652            entity,
653        }))
654    }
655}
656
657/// Update an annotation queue item
658#[bon::builder]
659pub async fn annotation_queues_update_queue_item(
660    configuration: &configuration::Configuration,
661    queue_id: &str,
662    item_id: &str,
663    update_annotation_queue_item_request: models::UpdateAnnotationQueueItemRequest,
664) -> Result<models::AnnotationQueueItem, Error<AnnotationQueuesUpdateQueueItemError>> {
665    // add a prefix to parameters to efficiently prevent name collisions
666    let p_path_queue_id = queue_id;
667    let p_path_item_id = item_id;
668    let p_body_update_annotation_queue_item_request = update_annotation_queue_item_request;
669
670    let uri_str = format!(
671        "{}/api/public/annotation-queues/{queueId}/items/{itemId}",
672        configuration.base_path,
673        queueId = crate::apis::urlencode(p_path_queue_id),
674        itemId = crate::apis::urlencode(p_path_item_id)
675    );
676    let mut req_builder = configuration
677        .client
678        .request(reqwest::Method::PATCH, &uri_str);
679
680    if let Some(ref user_agent) = configuration.user_agent {
681        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
682    }
683    if let Some(ref auth_conf) = configuration.basic_auth {
684        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
685    };
686    req_builder = req_builder.json(&p_body_update_annotation_queue_item_request);
687
688    let req = req_builder.build()?;
689    let resp = configuration.client.execute(req).await?;
690
691    let status = resp.status();
692    let content_type = resp
693        .headers()
694        .get("content-type")
695        .and_then(|v| v.to_str().ok())
696        .unwrap_or("application/octet-stream");
697    let content_type = super::ContentType::from(content_type);
698
699    if !status.is_client_error() && !status.is_server_error() {
700        let content = resp.text().await?;
701        match content_type {
702            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
703            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AnnotationQueueItem`"))),
704            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`")))),
705        }
706    } else {
707        let content = resp.text().await?;
708        let entity: Option<AnnotationQueuesUpdateQueueItemError> =
709            serde_json::from_str(&content).ok();
710        Err(Error::ResponseError(ResponseContent {
711            status,
712            content,
713            entity,
714        }))
715    }
716}