/*
* 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 [`blob_storage_integrations_delete_blob_storage_integration`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BlobStorageIntegrationsDeleteBlobStorageIntegrationError {
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 [`blob_storage_integrations_get_blob_storage_integration_status`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BlobStorageIntegrationsGetBlobStorageIntegrationStatusError {
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 [`blob_storage_integrations_get_blob_storage_integrations`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BlobStorageIntegrationsGetBlobStorageIntegrationsError {
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 [`blob_storage_integrations_upsert_blob_storage_integration`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BlobStorageIntegrationsUpsertBlobStorageIntegrationError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status405(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// Delete a blob storage integration by ID (requires organization-scoped API key)
#[bon::builder]
pub async fn blob_storage_integrations_delete_blob_storage_integration(
configuration: &configuration::Configuration,
id: &str,
) -> Result<
models::BlobStorageIntegrationDeletionResponse,
Error<BlobStorageIntegrationsDeleteBlobStorageIntegrationError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_id = id;
let uri_str = format!(
"{}/api/public/integrations/blob-storage/{id}",
configuration.base_path,
id = crate::apis::urlencode(p_path_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::BlobStorageIntegrationDeletionResponse`"))),
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::BlobStorageIntegrationDeletionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<BlobStorageIntegrationsDeleteBlobStorageIntegrationError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get the sync status of a blob storage integration by integration ID (requires organization-scoped API key)
#[bon::builder]
pub async fn blob_storage_integrations_get_blob_storage_integration_status(
configuration: &configuration::Configuration,
id: &str,
) -> Result<
models::BlobStorageIntegrationStatusResponse,
Error<BlobStorageIntegrationsGetBlobStorageIntegrationStatusError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_id = id;
let uri_str = format!(
"{}/api/public/integrations/blob-storage/{id}",
configuration.base_path,
id = crate::apis::urlencode(p_path_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::BlobStorageIntegrationStatusResponse`"))),
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::BlobStorageIntegrationStatusResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<BlobStorageIntegrationsGetBlobStorageIntegrationStatusError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get all blob storage integrations for the organization (requires organization-scoped API key)
#[bon::builder]
pub async fn blob_storage_integrations_get_blob_storage_integrations(
configuration: &configuration::Configuration,
) -> Result<
models::BlobStorageIntegrationsResponse,
Error<BlobStorageIntegrationsGetBlobStorageIntegrationsError>,
> {
let uri_str = format!(
"{}/api/public/integrations/blob-storage",
configuration.base_path
);
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::BlobStorageIntegrationsResponse`"))),
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::BlobStorageIntegrationsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<BlobStorageIntegrationsGetBlobStorageIntegrationsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Create or update a blob storage integration for a specific project (requires organization-scoped API key). The configuration is validated by performing a test upload to the bucket.
#[bon::builder]
pub async fn blob_storage_integrations_upsert_blob_storage_integration(
configuration: &configuration::Configuration,
create_blob_storage_integration_request: models::CreateBlobStorageIntegrationRequest,
) -> Result<
models::BlobStorageIntegrationResponse,
Error<BlobStorageIntegrationsUpsertBlobStorageIntegrationError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_blob_storage_integration_request = create_blob_storage_integration_request;
let uri_str = format!(
"{}/api/public/integrations/blob-storage",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &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_blob_storage_integration_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::BlobStorageIntegrationResponse`"))),
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::BlobStorageIntegrationResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<BlobStorageIntegrationsUpsertBlobStorageIntegrationError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}