1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetBenchmarkCatalogError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetBenchmarkClaimsError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetBenchmarkCompareError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetBenchmarkHistoryError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetBenchmarkLeaderboardError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetBenchmarkPresetsError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum PostBenchmarkClaimsError {
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum PostBenchmarkPresetsError {
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum PostBenchmarkRunsError {
78 UnknownValue(serde_json::Value),
79}
80
81
82pub async fn get_benchmark_catalog(configuration: &configuration::Configuration, ) -> Result<models::BenchmarkCatalog, Error<GetBenchmarkCatalogError>> {
84
85 let uri_str = format!("{}/v1/benchmark/catalog", configuration.base_path);
86 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
87
88 if let Some(ref user_agent) = configuration.user_agent {
89 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
90 }
91 if let Some(ref token) = configuration.bearer_access_token {
92 req_builder = req_builder.bearer_auth(token.to_owned());
93 };
94
95 let req = req_builder.build()?;
96 let resp = configuration.client.execute(req).await?;
97
98 let status = resp.status();
99 let content_type = resp
100 .headers()
101 .get("content-type")
102 .and_then(|v| v.to_str().ok())
103 .unwrap_or("application/octet-stream");
104 let content_type = super::ContentType::from(content_type);
105
106 if !status.is_client_error() && !status.is_server_error() {
107 let content = resp.text().await?;
108 match content_type {
109 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
110 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BenchmarkCatalog`"))),
111 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::BenchmarkCatalog`")))),
112 }
113 } else {
114 let content = resp.text().await?;
115 let entity: Option<GetBenchmarkCatalogError> = serde_json::from_str(&content).ok();
116 Err(Error::ResponseError(ResponseContent { status, content, entity }))
117 }
118}
119
120pub async fn get_benchmark_claims(configuration: &configuration::Configuration, benchmark: Option<&str>, model: Option<&str>, provider: Option<&str>, source: Option<&str>, protocol: Option<&str>) -> Result<models::ClaimsOut, Error<GetBenchmarkClaimsError>> {
122 let p_benchmark = benchmark;
124 let p_model = model;
125 let p_provider = provider;
126 let p_source = source;
127 let p_protocol = protocol;
128
129 let uri_str = format!("{}/v1/benchmark/claims", configuration.base_path);
130 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
131
132 if let Some(ref param_value) = p_benchmark {
133 req_builder = req_builder.query(&[("Benchmark", ¶m_value.to_string())]);
134 }
135 if let Some(ref param_value) = p_model {
136 req_builder = req_builder.query(&[("Model", ¶m_value.to_string())]);
137 }
138 if let Some(ref param_value) = p_provider {
139 req_builder = req_builder.query(&[("Provider", ¶m_value.to_string())]);
140 }
141 if let Some(ref param_value) = p_source {
142 req_builder = req_builder.query(&[("Source", ¶m_value.to_string())]);
143 }
144 if let Some(ref param_value) = p_protocol {
145 req_builder = req_builder.query(&[("Protocol", ¶m_value.to_string())]);
146 }
147 if let Some(ref user_agent) = configuration.user_agent {
148 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
149 }
150 if let Some(ref token) = configuration.bearer_access_token {
151 req_builder = req_builder.bearer_auth(token.to_owned());
152 };
153
154 let req = req_builder.build()?;
155 let resp = configuration.client.execute(req).await?;
156
157 let status = resp.status();
158 let content_type = resp
159 .headers()
160 .get("content-type")
161 .and_then(|v| v.to_str().ok())
162 .unwrap_or("application/octet-stream");
163 let content_type = super::ContentType::from(content_type);
164
165 if !status.is_client_error() && !status.is_server_error() {
166 let content = resp.text().await?;
167 match content_type {
168 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
169 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClaimsOut`"))),
170 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::ClaimsOut`")))),
171 }
172 } else {
173 let content = resp.text().await?;
174 let entity: Option<GetBenchmarkClaimsError> = serde_json::from_str(&content).ok();
175 Err(Error::ResponseError(ResponseContent { status, content, entity }))
176 }
177}
178
179pub async fn get_benchmark_compare(configuration: &configuration::Configuration, a: &str, b: &str, benchmark: Option<&str>) -> Result<models::Pairing, Error<GetBenchmarkCompareError>> {
181 let p_a = a;
183 let p_b = b;
184 let p_benchmark = benchmark;
185
186 let uri_str = format!("{}/v1/benchmark/compare", configuration.base_path);
187 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
188
189 if let Some(ref param_value) = p_benchmark {
190 req_builder = req_builder.query(&[("benchmark", ¶m_value.to_string())]);
191 }
192 req_builder = req_builder.query(&[("a", &p_a.to_string())]);
193 req_builder = req_builder.query(&[("b", &p_b.to_string())]);
194 if let Some(ref user_agent) = configuration.user_agent {
195 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
196 }
197 if let Some(ref token) = configuration.bearer_access_token {
198 req_builder = req_builder.bearer_auth(token.to_owned());
199 };
200
201 let req = req_builder.build()?;
202 let resp = configuration.client.execute(req).await?;
203
204 let status = resp.status();
205 let content_type = resp
206 .headers()
207 .get("content-type")
208 .and_then(|v| v.to_str().ok())
209 .unwrap_or("application/octet-stream");
210 let content_type = super::ContentType::from(content_type);
211
212 if !status.is_client_error() && !status.is_server_error() {
213 let content = resp.text().await?;
214 match content_type {
215 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
216 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Pairing`"))),
217 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::Pairing`")))),
218 }
219 } else {
220 let content = resp.text().await?;
221 let entity: Option<GetBenchmarkCompareError> = serde_json::from_str(&content).ok();
222 Err(Error::ResponseError(ResponseContent { status, content, entity }))
223 }
224}
225
226pub async fn get_benchmark_history(configuration: &configuration::Configuration, benchmark: Option<&str>, model: Option<&str>) -> Result<models::HistoryOut, Error<GetBenchmarkHistoryError>> {
228 let p_benchmark = benchmark;
230 let p_model = model;
231
232 let uri_str = format!("{}/v1/benchmark/history", configuration.base_path);
233 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
234
235 if let Some(ref param_value) = p_benchmark {
236 req_builder = req_builder.query(&[("Benchmark", ¶m_value.to_string())]);
237 }
238 if let Some(ref param_value) = p_model {
239 req_builder = req_builder.query(&[("Model", ¶m_value.to_string())]);
240 }
241 if let Some(ref user_agent) = configuration.user_agent {
242 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
243 }
244 if let Some(ref token) = configuration.bearer_access_token {
245 req_builder = req_builder.bearer_auth(token.to_owned());
246 };
247
248 let req = req_builder.build()?;
249 let resp = configuration.client.execute(req).await?;
250
251 let status = resp.status();
252 let content_type = resp
253 .headers()
254 .get("content-type")
255 .and_then(|v| v.to_str().ok())
256 .unwrap_or("application/octet-stream");
257 let content_type = super::ContentType::from(content_type);
258
259 if !status.is_client_error() && !status.is_server_error() {
260 let content = resp.text().await?;
261 match content_type {
262 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
263 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::HistoryOut`"))),
264 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::HistoryOut`")))),
265 }
266 } else {
267 let content = resp.text().await?;
268 let entity: Option<GetBenchmarkHistoryError> = serde_json::from_str(&content).ok();
269 Err(Error::ResponseError(ResponseContent { status, content, entity }))
270 }
271}
272
273pub async fn get_benchmark_leaderboard(configuration: &configuration::Configuration, benchmark: Option<&str>) -> Result<models::Leaderboard, Error<GetBenchmarkLeaderboardError>> {
275 let p_benchmark = benchmark;
277
278 let uri_str = format!("{}/v1/benchmark/leaderboard", configuration.base_path);
279 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
280
281 if let Some(ref param_value) = p_benchmark {
282 req_builder = req_builder.query(&[("benchmark", ¶m_value.to_string())]);
283 }
284 if let Some(ref user_agent) = configuration.user_agent {
285 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
286 }
287 if let Some(ref token) = configuration.bearer_access_token {
288 req_builder = req_builder.bearer_auth(token.to_owned());
289 };
290
291 let req = req_builder.build()?;
292 let resp = configuration.client.execute(req).await?;
293
294 let status = resp.status();
295 let content_type = resp
296 .headers()
297 .get("content-type")
298 .and_then(|v| v.to_str().ok())
299 .unwrap_or("application/octet-stream");
300 let content_type = super::ContentType::from(content_type);
301
302 if !status.is_client_error() && !status.is_server_error() {
303 let content = resp.text().await?;
304 match content_type {
305 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
306 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Leaderboard`"))),
307 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::Leaderboard`")))),
308 }
309 } else {
310 let content = resp.text().await?;
311 let entity: Option<GetBenchmarkLeaderboardError> = serde_json::from_str(&content).ok();
312 Err(Error::ResponseError(ResponseContent { status, content, entity }))
313 }
314}
315
316pub async fn get_benchmark_presets(configuration: &configuration::Configuration, ) -> Result<models::PresetList, Error<GetBenchmarkPresetsError>> {
318
319 let uri_str = format!("{}/v1/benchmark/presets", configuration.base_path);
320 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
321
322 if let Some(ref user_agent) = configuration.user_agent {
323 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
324 }
325 if let Some(ref token) = configuration.bearer_access_token {
326 req_builder = req_builder.bearer_auth(token.to_owned());
327 };
328
329 let req = req_builder.build()?;
330 let resp = configuration.client.execute(req).await?;
331
332 let status = resp.status();
333 let content_type = resp
334 .headers()
335 .get("content-type")
336 .and_then(|v| v.to_str().ok())
337 .unwrap_or("application/octet-stream");
338 let content_type = super::ContentType::from(content_type);
339
340 if !status.is_client_error() && !status.is_server_error() {
341 let content = resp.text().await?;
342 match content_type {
343 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
344 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PresetList`"))),
345 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::PresetList`")))),
346 }
347 } else {
348 let content = resp.text().await?;
349 let entity: Option<GetBenchmarkPresetsError> = serde_json::from_str(&content).ok();
350 Err(Error::ResponseError(ResponseContent { status, content, entity }))
351 }
352}
353
354pub async fn post_benchmark_claims(configuration: &configuration::Configuration, put_claims_in: models::PutClaimsIn) -> Result<models::PutClaimsOut, Error<PostBenchmarkClaimsError>> {
356 let p_put_claims_in = put_claims_in;
358
359 let uri_str = format!("{}/v1/benchmark/claims", configuration.base_path);
360 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
361
362 if let Some(ref user_agent) = configuration.user_agent {
363 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
364 }
365 if let Some(ref token) = configuration.bearer_access_token {
366 req_builder = req_builder.bearer_auth(token.to_owned());
367 };
368 req_builder = req_builder.json(&p_put_claims_in);
369
370 let req = req_builder.build()?;
371 let resp = configuration.client.execute(req).await?;
372
373 let status = resp.status();
374 let content_type = resp
375 .headers()
376 .get("content-type")
377 .and_then(|v| v.to_str().ok())
378 .unwrap_or("application/octet-stream");
379 let content_type = super::ContentType::from(content_type);
380
381 if !status.is_client_error() && !status.is_server_error() {
382 let content = resp.text().await?;
383 match content_type {
384 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
385 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PutClaimsOut`"))),
386 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::PutClaimsOut`")))),
387 }
388 } else {
389 let content = resp.text().await?;
390 let entity: Option<PostBenchmarkClaimsError> = serde_json::from_str(&content).ok();
391 Err(Error::ResponseError(ResponseContent { status, content, entity }))
392 }
393}
394
395pub async fn post_benchmark_presets(configuration: &configuration::Configuration, preset: models::Preset) -> Result<models::PresetAccepted, Error<PostBenchmarkPresetsError>> {
397 let p_preset = preset;
399
400 let uri_str = format!("{}/v1/benchmark/presets", configuration.base_path);
401 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
402
403 if let Some(ref user_agent) = configuration.user_agent {
404 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
405 }
406 if let Some(ref token) = configuration.bearer_access_token {
407 req_builder = req_builder.bearer_auth(token.to_owned());
408 };
409 req_builder = req_builder.json(&p_preset);
410
411 let req = req_builder.build()?;
412 let resp = configuration.client.execute(req).await?;
413
414 let status = resp.status();
415 let content_type = resp
416 .headers()
417 .get("content-type")
418 .and_then(|v| v.to_str().ok())
419 .unwrap_or("application/octet-stream");
420 let content_type = super::ContentType::from(content_type);
421
422 if !status.is_client_error() && !status.is_server_error() {
423 let content = resp.text().await?;
424 match content_type {
425 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
426 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PresetAccepted`"))),
427 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::PresetAccepted`")))),
428 }
429 } else {
430 let content = resp.text().await?;
431 let entity: Option<PostBenchmarkPresetsError> = serde_json::from_str(&content).ok();
432 Err(Error::ResponseError(ResponseContent { status, content, entity }))
433 }
434}
435
436pub async fn post_benchmark_runs(configuration: &configuration::Configuration, suite: models::Suite) -> Result<models::Admission, Error<PostBenchmarkRunsError>> {
438 let p_suite = suite;
440
441 let uri_str = format!("{}/v1/benchmark/runs", configuration.base_path);
442 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
443
444 if let Some(ref user_agent) = configuration.user_agent {
445 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
446 }
447 if let Some(ref token) = configuration.bearer_access_token {
448 req_builder = req_builder.bearer_auth(token.to_owned());
449 };
450 req_builder = req_builder.json(&p_suite);
451
452 let req = req_builder.build()?;
453 let resp = configuration.client.execute(req).await?;
454
455 let status = resp.status();
456 let content_type = resp
457 .headers()
458 .get("content-type")
459 .and_then(|v| v.to_str().ok())
460 .unwrap_or("application/octet-stream");
461 let content_type = super::ContentType::from(content_type);
462
463 if !status.is_client_error() && !status.is_server_error() {
464 let content = resp.text().await?;
465 match content_type {
466 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
467 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Admission`"))),
468 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::Admission`")))),
469 }
470 } else {
471 let content = resp.text().await?;
472 let entity: Option<PostBenchmarkRunsError> = serde_json::from_str(&content).ok();
473 Err(Error::ResponseError(ResponseContent { status, content, entity }))
474 }
475}
476