langfuse_rs/apis/
dataset_run_items_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, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{Deserialize, Serialize};
15
16/// struct for typed errors of method [`dataset_run_items_create`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum DatasetRunItemsCreateError {
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/// Create a dataset run item
29pub async fn dataset_run_items_create(
30	configuration: &configuration::Configuration,
31	create_dataset_run_item_request: models::CreateDatasetRunItemRequest,
32) -> Result<models::DatasetRunItem, Error<DatasetRunItemsCreateError>> {
33	// add a prefix to parameters to efficiently prevent name collisions
34	let p_create_dataset_run_item_request = create_dataset_run_item_request;
35
36	let uri_str = format!("{}/api/public/dataset-run-items", configuration.base_path);
37	let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
38
39	if let Some(ref user_agent) = configuration.user_agent {
40		req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
41	}
42	if let Some(ref auth_conf) = configuration.basic_auth {
43		req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
44	};
45	req_builder = req_builder.json(&p_create_dataset_run_item_request);
46
47	let req = req_builder.build()?;
48	let resp = configuration.client.execute(req).await?;
49
50	let status = resp.status();
51
52	if !status.is_client_error() && !status.is_server_error() {
53		let content = resp.text().await?;
54		serde_json::from_str(&content).map_err(Error::from)
55	} else {
56		let content = resp.text().await?;
57		let entity: Option<DatasetRunItemsCreateError> = serde_json::from_str(&content).ok();
58		Err(Error::ResponseError(ResponseContent { status, content, entity }))
59	}
60}