langfuse_client_base/apis/
datasets_api.rs1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum DatasetsCreateError {
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#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum DatasetsDeleteRunError {
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#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum DatasetsGetError {
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#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum DatasetsGetRunError {
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#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(untagged)]
67pub enum DatasetsGetRunsError {
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#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum DatasetsListError {
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#[bon::builder]
90pub async fn datasets_create(
91 configuration: &configuration::Configuration,
92 create_dataset_request: models::CreateDatasetRequest,
93) -> Result<models::Dataset, Error<DatasetsCreateError>> {
94 let p_body_create_dataset_request = create_dataset_request;
96
97 let uri_str = format!("{}/api/public/v2/datasets", configuration.base_path);
98 let mut req_builder = configuration
99 .client
100 .request(reqwest::Method::POST, &uri_str);
101
102 if let Some(ref user_agent) = configuration.user_agent {
103 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
104 }
105 if let Some(ref auth_conf) = configuration.basic_auth {
106 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
107 };
108 req_builder = req_builder.json(&p_body_create_dataset_request);
109
110 let req = req_builder.build()?;
111 let resp = configuration.client.execute(req).await?;
112
113 let status = resp.status();
114 let content_type = resp
115 .headers()
116 .get("content-type")
117 .and_then(|v| v.to_str().ok())
118 .unwrap_or("application/octet-stream");
119 let content_type = super::ContentType::from(content_type);
120
121 if !status.is_client_error() && !status.is_server_error() {
122 let content = resp.text().await?;
123 match content_type {
124 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
125 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Dataset`"))),
126 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::Dataset`")))),
127 }
128 } else {
129 let content = resp.text().await?;
130 let entity: Option<DatasetsCreateError> = serde_json::from_str(&content).ok();
131 Err(Error::ResponseError(ResponseContent {
132 status,
133 content,
134 entity,
135 }))
136 }
137}
138
139#[bon::builder]
141pub async fn datasets_delete_run(
142 configuration: &configuration::Configuration,
143 dataset_name: &str,
144 run_name: &str,
145) -> Result<models::DeleteDatasetRunResponse, Error<DatasetsDeleteRunError>> {
146 let p_path_dataset_name = dataset_name;
148 let p_path_run_name = run_name;
149
150 let uri_str = format!(
151 "{}/api/public/datasets/{datasetName}/runs/{runName}",
152 configuration.base_path,
153 datasetName = crate::apis::urlencode(p_path_dataset_name),
154 runName = crate::apis::urlencode(p_path_run_name)
155 );
156 let mut req_builder = configuration
157 .client
158 .request(reqwest::Method::DELETE, &uri_str);
159
160 if let Some(ref user_agent) = configuration.user_agent {
161 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
162 }
163 if let Some(ref auth_conf) = configuration.basic_auth {
164 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
165 };
166
167 let req = req_builder.build()?;
168 let resp = configuration.client.execute(req).await?;
169
170 let status = resp.status();
171 let content_type = resp
172 .headers()
173 .get("content-type")
174 .and_then(|v| v.to_str().ok())
175 .unwrap_or("application/octet-stream");
176 let content_type = super::ContentType::from(content_type);
177
178 if !status.is_client_error() && !status.is_server_error() {
179 let content = resp.text().await?;
180 match content_type {
181 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
182 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteDatasetRunResponse`"))),
183 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::DeleteDatasetRunResponse`")))),
184 }
185 } else {
186 let content = resp.text().await?;
187 let entity: Option<DatasetsDeleteRunError> = serde_json::from_str(&content).ok();
188 Err(Error::ResponseError(ResponseContent {
189 status,
190 content,
191 entity,
192 }))
193 }
194}
195
196#[bon::builder]
198pub async fn datasets_get(
199 configuration: &configuration::Configuration,
200 dataset_name: &str,
201) -> Result<models::Dataset, Error<DatasetsGetError>> {
202 let p_path_dataset_name = dataset_name;
204
205 let uri_str = format!(
206 "{}/api/public/v2/datasets/{datasetName}",
207 configuration.base_path,
208 datasetName = crate::apis::urlencode(p_path_dataset_name)
209 );
210 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
211
212 if let Some(ref user_agent) = configuration.user_agent {
213 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
214 }
215 if let Some(ref auth_conf) = configuration.basic_auth {
216 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
217 };
218
219 let req = req_builder.build()?;
220 let resp = configuration.client.execute(req).await?;
221
222 let status = resp.status();
223 let content_type = resp
224 .headers()
225 .get("content-type")
226 .and_then(|v| v.to_str().ok())
227 .unwrap_or("application/octet-stream");
228 let content_type = super::ContentType::from(content_type);
229
230 if !status.is_client_error() && !status.is_server_error() {
231 let content = resp.text().await?;
232 match content_type {
233 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
234 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Dataset`"))),
235 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::Dataset`")))),
236 }
237 } else {
238 let content = resp.text().await?;
239 let entity: Option<DatasetsGetError> = serde_json::from_str(&content).ok();
240 Err(Error::ResponseError(ResponseContent {
241 status,
242 content,
243 entity,
244 }))
245 }
246}
247
248#[bon::builder]
250pub async fn datasets_get_run(
251 configuration: &configuration::Configuration,
252 dataset_name: &str,
253 run_name: &str,
254) -> Result<models::DatasetRunWithItems, Error<DatasetsGetRunError>> {
255 let p_path_dataset_name = dataset_name;
257 let p_path_run_name = run_name;
258
259 let uri_str = format!(
260 "{}/api/public/datasets/{datasetName}/runs/{runName}",
261 configuration.base_path,
262 datasetName = crate::apis::urlencode(p_path_dataset_name),
263 runName = crate::apis::urlencode(p_path_run_name)
264 );
265 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
266
267 if let Some(ref user_agent) = configuration.user_agent {
268 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
269 }
270 if let Some(ref auth_conf) = configuration.basic_auth {
271 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
272 };
273
274 let req = req_builder.build()?;
275 let resp = configuration.client.execute(req).await?;
276
277 let status = resp.status();
278 let content_type = resp
279 .headers()
280 .get("content-type")
281 .and_then(|v| v.to_str().ok())
282 .unwrap_or("application/octet-stream");
283 let content_type = super::ContentType::from(content_type);
284
285 if !status.is_client_error() && !status.is_server_error() {
286 let content = resp.text().await?;
287 match content_type {
288 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
289 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DatasetRunWithItems`"))),
290 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::DatasetRunWithItems`")))),
291 }
292 } else {
293 let content = resp.text().await?;
294 let entity: Option<DatasetsGetRunError> = serde_json::from_str(&content).ok();
295 Err(Error::ResponseError(ResponseContent {
296 status,
297 content,
298 entity,
299 }))
300 }
301}
302
303#[bon::builder]
305pub async fn datasets_get_runs(
306 configuration: &configuration::Configuration,
307 dataset_name: &str,
308 page: Option<i32>,
309 limit: Option<i32>,
310) -> Result<models::PaginatedDatasetRuns, Error<DatasetsGetRunsError>> {
311 let p_path_dataset_name = dataset_name;
313 let p_query_page = page;
314 let p_query_limit = limit;
315
316 let uri_str = format!(
317 "{}/api/public/datasets/{datasetName}/runs",
318 configuration.base_path,
319 datasetName = crate::apis::urlencode(p_path_dataset_name)
320 );
321 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
322
323 if let Some(ref param_value) = p_query_page {
324 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
325 }
326 if let Some(ref param_value) = p_query_limit {
327 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
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
336 let req = req_builder.build()?;
337 let resp = configuration.client.execute(req).await?;
338
339 let status = resp.status();
340 let content_type = resp
341 .headers()
342 .get("content-type")
343 .and_then(|v| v.to_str().ok())
344 .unwrap_or("application/octet-stream");
345 let content_type = super::ContentType::from(content_type);
346
347 if !status.is_client_error() && !status.is_server_error() {
348 let content = resp.text().await?;
349 match content_type {
350 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
351 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedDatasetRuns`"))),
352 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::PaginatedDatasetRuns`")))),
353 }
354 } else {
355 let content = resp.text().await?;
356 let entity: Option<DatasetsGetRunsError> = serde_json::from_str(&content).ok();
357 Err(Error::ResponseError(ResponseContent {
358 status,
359 content,
360 entity,
361 }))
362 }
363}
364
365#[bon::builder]
367pub async fn datasets_list(
368 configuration: &configuration::Configuration,
369 page: Option<i32>,
370 limit: Option<i32>,
371) -> Result<models::PaginatedDatasets, Error<DatasetsListError>> {
372 let p_query_page = page;
374 let p_query_limit = limit;
375
376 let uri_str = format!("{}/api/public/v2/datasets", configuration.base_path);
377 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
378
379 if let Some(ref param_value) = p_query_page {
380 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
381 }
382 if let Some(ref param_value) = p_query_limit {
383 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
384 }
385 if let Some(ref user_agent) = configuration.user_agent {
386 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
387 }
388 if let Some(ref auth_conf) = configuration.basic_auth {
389 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
390 };
391
392 let req = req_builder.build()?;
393 let resp = configuration.client.execute(req).await?;
394
395 let status = resp.status();
396 let content_type = resp
397 .headers()
398 .get("content-type")
399 .and_then(|v| v.to_str().ok())
400 .unwrap_or("application/octet-stream");
401 let content_type = super::ContentType::from(content_type);
402
403 if !status.is_client_error() && !status.is_server_error() {
404 let content = resp.text().await?;
405 match content_type {
406 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
407 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedDatasets`"))),
408 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::PaginatedDatasets`")))),
409 }
410 } else {
411 let content = resp.text().await?;
412 let entity: Option<DatasetsListError> = serde_json::from_str(&content).ok();
413 Err(Error::ResponseError(ResponseContent {
414 status,
415 content,
416 entity,
417 }))
418 }
419}