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