/*
* server
*
* ## Real-time data The only real-time path to get tracing data is to ingest via OpenTelemetry (`POST /api/public/otel/v1/traces`) and retrieve via Observations API v2 (`GET /api/public/v2/observations`) and Metrics API v2 (`GET /api/public/v2/metrics`). Other public API write and read endpoints can delay data by about 10 minutes. Direct OpenTelemetry exporters must send the `x-langfuse-ingestion-version: 4` header; current Python and JS SDKs already do. See the [Public API docs](https://langfuse.com/docs/api-and-data-platform/features/public-api) and [real-time ingestion](https://langfuse.com/integrations/native/opentelemetry.md#real-time-ingestion). ## 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 - Self-hosted deployments: interactive API reference at `/api/docs` and OpenAPI spec at `/api/openapi.yaml`
*
* The version of the OpenAPI document:
*
* Generated by: https://openapi-generator.tech
*/
use super::{configuration, ContentType, Error};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};
/// struct for typed errors of method [`annotation_queues_create_queue`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AnnotationQueuesCreateQueueError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status405(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`annotation_queues_create_queue_assignment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AnnotationQueuesCreateQueueAssignmentError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status405(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`annotation_queues_create_queue_item`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AnnotationQueuesCreateQueueItemError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status405(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`annotation_queues_delete_queue_assignment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AnnotationQueuesDeleteQueueAssignmentError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status405(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`annotation_queues_delete_queue_item`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AnnotationQueuesDeleteQueueItemError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status405(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`annotation_queues_get_queue`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AnnotationQueuesGetQueueError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status405(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`annotation_queues_get_queue_item`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AnnotationQueuesGetQueueItemError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status405(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`annotation_queues_list_queue_items`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AnnotationQueuesListQueueItemsError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status405(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`annotation_queues_list_queues`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AnnotationQueuesListQueuesError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status405(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`annotation_queues_update_queue_item`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AnnotationQueuesUpdateQueueItemError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status405(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// Create an annotation queue
#[bon::builder]
pub async fn annotation_queues_create_queue(
configuration: &configuration::Configuration,
create_annotation_queue_request: models::CreateAnnotationQueueRequest,
) -> Result<models::AnnotationQueue, Error<AnnotationQueuesCreateQueueError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_annotation_queue_request = create_annotation_queue_request;
let uri_str = format!("{}/api/public/annotation-queues", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
req_builder = req_builder.json(&p_body_create_annotation_queue_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AnnotationQueue`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AnnotationQueuesCreateQueueError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Create an assignment for a user to an annotation queue
#[bon::builder]
pub async fn annotation_queues_create_queue_assignment(
configuration: &configuration::Configuration,
queue_id: &str,
annotation_queue_assignment_request: models::AnnotationQueueAssignmentRequest,
) -> Result<
models::CreateAnnotationQueueAssignmentResponse,
Error<AnnotationQueuesCreateQueueAssignmentError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_queue_id = queue_id;
let p_body_annotation_queue_assignment_request = annotation_queue_assignment_request;
let uri_str = format!(
"{}/api/public/annotation-queues/{queueId}/assignments",
configuration.base_path,
queueId = crate::apis::urlencode(p_path_queue_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
req_builder = req_builder.json(&p_body_annotation_queue_assignment_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateAnnotationQueueAssignmentResponse`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AnnotationQueuesCreateQueueAssignmentError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Add an item to an annotation queue
#[bon::builder]
pub 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>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_queue_id = queue_id;
let p_body_create_annotation_queue_item_request = create_annotation_queue_item_request;
let uri_str = format!(
"{}/api/public/annotation-queues/{queueId}/items",
configuration.base_path,
queueId = crate::apis::urlencode(p_path_queue_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
req_builder = req_builder.json(&p_body_create_annotation_queue_item_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AnnotationQueueItem`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AnnotationQueuesCreateQueueItemError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Delete an assignment for a user to an annotation queue
#[bon::builder]
pub async fn annotation_queues_delete_queue_assignment(
configuration: &configuration::Configuration,
queue_id: &str,
annotation_queue_assignment_request: models::AnnotationQueueAssignmentRequest,
) -> Result<
models::DeleteAnnotationQueueAssignmentResponse,
Error<AnnotationQueuesDeleteQueueAssignmentError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_queue_id = queue_id;
let p_body_annotation_queue_assignment_request = annotation_queue_assignment_request;
let uri_str = format!(
"{}/api/public/annotation-queues/{queueId}/assignments",
configuration.base_path,
queueId = crate::apis::urlencode(p_path_queue_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
req_builder = req_builder.json(&p_body_annotation_queue_assignment_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAnnotationQueueAssignmentResponse`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AnnotationQueuesDeleteQueueAssignmentError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Remove an item from an annotation queue
#[bon::builder]
pub async fn annotation_queues_delete_queue_item(
configuration: &configuration::Configuration,
queue_id: &str,
item_id: &str,
) -> Result<models::DeleteAnnotationQueueItemResponse, Error<AnnotationQueuesDeleteQueueItemError>>
{
// add a prefix to parameters to efficiently prevent name collisions
let p_path_queue_id = queue_id;
let p_path_item_id = item_id;
let uri_str = format!(
"{}/api/public/annotation-queues/{queueId}/items/{itemId}",
configuration.base_path,
queueId = crate::apis::urlencode(p_path_queue_id),
itemId = crate::apis::urlencode(p_path_item_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAnnotationQueueItemResponse`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AnnotationQueuesDeleteQueueItemError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get an annotation queue by ID
#[bon::builder]
pub async fn annotation_queues_get_queue(
configuration: &configuration::Configuration,
queue_id: &str,
) -> Result<models::AnnotationQueue, Error<AnnotationQueuesGetQueueError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_queue_id = queue_id;
let uri_str = format!(
"{}/api/public/annotation-queues/{queueId}",
configuration.base_path,
queueId = crate::apis::urlencode(p_path_queue_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AnnotationQueue`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AnnotationQueuesGetQueueError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get a specific item from an annotation queue
#[bon::builder]
pub async fn annotation_queues_get_queue_item(
configuration: &configuration::Configuration,
queue_id: &str,
item_id: &str,
) -> Result<models::AnnotationQueueItem, Error<AnnotationQueuesGetQueueItemError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_queue_id = queue_id;
let p_path_item_id = item_id;
let uri_str = format!(
"{}/api/public/annotation-queues/{queueId}/items/{itemId}",
configuration.base_path,
queueId = crate::apis::urlencode(p_path_queue_id),
itemId = crate::apis::urlencode(p_path_item_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AnnotationQueueItem`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AnnotationQueuesGetQueueItemError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get items for a specific annotation queue
#[bon::builder]
pub 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>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_queue_id = queue_id;
let p_query_status = status;
let p_query_page = page;
let p_query_limit = limit;
let uri_str = format!(
"{}/api/public/annotation-queues/{queueId}/items",
configuration.base_path,
queueId = crate::apis::urlencode(p_path_queue_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_status {
req_builder = req_builder.query(&[("status", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedAnnotationQueueItems`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AnnotationQueuesListQueueItemsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get all annotation queues
#[bon::builder]
pub async fn annotation_queues_list_queues(
configuration: &configuration::Configuration,
page: Option<i32>,
limit: Option<i32>,
) -> Result<models::PaginatedAnnotationQueues, Error<AnnotationQueuesListQueuesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_page = page;
let p_query_limit = limit;
let uri_str = format!("{}/api/public/annotation-queues", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedAnnotationQueues`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AnnotationQueuesListQueuesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Update an annotation queue item
#[bon::builder]
pub 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>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_queue_id = queue_id;
let p_path_item_id = item_id;
let p_body_update_annotation_queue_item_request = update_annotation_queue_item_request;
let uri_str = format!(
"{}/api/public/annotation-queues/{queueId}/items/{itemId}",
configuration.base_path,
queueId = crate::apis::urlencode(p_path_queue_id),
itemId = crate::apis::urlencode(p_path_item_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
req_builder = req_builder.json(&p_body_update_annotation_queue_item_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AnnotationQueueItem`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AnnotationQueuesUpdateQueueItemError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}