Skip to main content

langfuse_client_base/apis/
evaluators_api.rs

1#![allow(deprecated)]
2/*
3 * server
4 *
5 * ## 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`
6 *
7 * The version of the OpenAPI document:
8 *
9 * Generated by: https://openapi-generator.tech
10 */
11
12use super::{configuration, ContentType, Error};
13use crate::{apis::ResponseContent, models};
14use serde::{de::Error as _, Deserialize, Serialize};
15use timvw_rust_runtime;
16
17/// struct for typed errors of method [`evaluators_create`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum EvaluatorsCreateError {
21    Status400(serde_json::Value),
22    Status401(serde_json::Value),
23    Status403(serde_json::Value),
24    Status404(serde_json::Value),
25    Status405(serde_json::Value),
26    Status412(models::PublicApiError),
27    Status429(models::PublicApiError),
28    Status500(models::PublicApiError),
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`evaluators_delete`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum EvaluatorsDeleteError {
36    Status400(serde_json::Value),
37    Status401(serde_json::Value),
38    Status403(serde_json::Value),
39    Status404(serde_json::Value),
40    Status405(serde_json::Value),
41    Status429(models::PublicApiError),
42    Status500(models::PublicApiError),
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`evaluators_get`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum EvaluatorsGetError {
50    Status400(serde_json::Value),
51    Status401(serde_json::Value),
52    Status403(serde_json::Value),
53    Status404(serde_json::Value),
54    Status405(serde_json::Value),
55    Status429(models::PublicApiError),
56    Status500(models::PublicApiError),
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`evaluators_list`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum EvaluatorsListError {
64    Status400(serde_json::Value),
65    Status401(serde_json::Value),
66    Status403(serde_json::Value),
67    Status404(serde_json::Value),
68    Status405(serde_json::Value),
69    Status429(models::PublicApiError),
70    Status500(models::PublicApiError),
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`evaluators_list_versions`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum EvaluatorsListVersionsError {
78    Status400(serde_json::Value),
79    Status401(serde_json::Value),
80    Status403(serde_json::Value),
81    Status404(serde_json::Value),
82    Status405(serde_json::Value),
83    Status429(models::PublicApiError),
84    Status500(models::PublicApiError),
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`evaluators_update`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum EvaluatorsUpdateError {
92    Status400(serde_json::Value),
93    Status401(serde_json::Value),
94    Status403(serde_json::Value),
95    Status404(serde_json::Value),
96    Status405(serde_json::Value),
97    Status409(models::PublicApiError),
98    Status412(models::PublicApiError),
99    Status429(models::PublicApiError),
100    Status500(models::PublicApiError),
101    UnknownValue(serde_json::Value),
102}
103
104/// Create an evaluator in the authenticated project.  An evaluator defines **how** Langfuse should score data. LLM-as-a-judge evaluators define a prompt, expected structured output, and optional model configuration. Code evaluators define source code and a runtime language.  This always creates a new evaluator with version `1`. Names are not identifiers and do not need to be unique.
105#[bon::builder]
106pub async fn evaluators_create(
107    configuration: &configuration::Configuration,
108    create_evaluator_request: &models::CreateEvaluatorRequest,
109    options: Option<&timvw_rust_runtime::RequestOptions>,
110) -> Result<models::Evaluator, Error<EvaluatorsCreateError>> {
111    // add a prefix to parameters to efficiently prevent name collisions
112    let p_body_create_evaluator_request = create_evaluator_request;
113
114    let uri_str = format!("{}/api/public/v2/evaluators", configuration.base_path);
115    let mut req_builder = configuration
116        .client
117        .request(timvw_rust_runtime::Method::POST, &uri_str);
118
119    if let Some(ref user_agent) = configuration.user_agent {
120        req_builder =
121            req_builder.header(timvw_rust_runtime::header::USER_AGENT, user_agent.clone());
122    }
123    if let Some(ref auth_conf) = configuration.basic_auth {
124        req_builder = req_builder.basic_auth(
125            &auth_conf.0,
126            auth_conf
127                .1
128                .as_ref()
129                .map(timvw_rust_runtime::ExposeSecret::expose_secret),
130        );
131    };
132    req_builder = req_builder.json(p_body_create_evaluator_request);
133
134    // last, so its headers replace the generated ones; its base URL replaces configuration.base_path
135    if let Some(options) = options {
136        req_builder = req_builder.base(&configuration.base_path).options(options);
137    }
138    let req = req_builder.build()?;
139    let resp = configuration.client.execute(req).await?;
140
141    let status = resp.status();
142    let content_type = resp
143        .headers()
144        .get("content-type")
145        .and_then(|v| v.to_str().ok())
146        .unwrap_or("application/octet-stream");
147    let content_type = super::ContentType::from(content_type);
148
149    if !status.is_client_error() && !status.is_server_error() {
150        let content = resp.text().await?;
151        match content_type {
152            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
153            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Evaluator`"))),
154            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Evaluator`")))),
155        }
156    } else {
157        let headers = resp.headers().clone();
158        let content = resp.text().await?;
159        let entity: Option<EvaluatorsCreateError> = match status.as_u16() {
160            400 => serde_json::from_str(&content)
161                .ok()
162                .map(EvaluatorsCreateError::Status400),
163            401 => serde_json::from_str(&content)
164                .ok()
165                .map(EvaluatorsCreateError::Status401),
166            403 => serde_json::from_str(&content)
167                .ok()
168                .map(EvaluatorsCreateError::Status403),
169            404 => serde_json::from_str(&content)
170                .ok()
171                .map(EvaluatorsCreateError::Status404),
172            405 => serde_json::from_str(&content)
173                .ok()
174                .map(EvaluatorsCreateError::Status405),
175            412 => serde_json::from_str(&content)
176                .ok()
177                .map(EvaluatorsCreateError::Status412),
178            429 => serde_json::from_str(&content)
179                .ok()
180                .map(EvaluatorsCreateError::Status429),
181            500 => serde_json::from_str(&content)
182                .ok()
183                .map(EvaluatorsCreateError::Status500),
184            _ => None,
185        }
186        .or_else(|| {
187            serde_json::from_str(&content)
188                .ok()
189                .map(EvaluatorsCreateError::UnknownValue)
190        });
191        Err(Error::ResponseError(Box::new(ResponseContent {
192            status,
193            content,
194            entity,
195            headers,
196        })))
197    }
198}
199
200/// Delete an evaluator and all of its stored versions.  Associated evaluation-rule assignments are also removed. Scores already produced by the evaluator are preserved.
201#[bon::builder]
202pub async fn evaluators_delete(
203    configuration: &configuration::Configuration,
204    evaluator_id: &str,
205    options: Option<&timvw_rust_runtime::RequestOptions>,
206) -> Result<models::DeletedEvaluator, Error<EvaluatorsDeleteError>> {
207    // add a prefix to parameters to efficiently prevent name collisions
208    let p_path_evaluator_id = evaluator_id;
209
210    let uri_str = format!(
211        "{}/api/public/v2/evaluators/{evaluatorId}",
212        configuration.base_path,
213        evaluatorId = crate::apis::urlencode(p_path_evaluator_id)
214    );
215    let mut req_builder = configuration
216        .client
217        .request(timvw_rust_runtime::Method::DELETE, &uri_str);
218
219    if let Some(ref user_agent) = configuration.user_agent {
220        req_builder =
221            req_builder.header(timvw_rust_runtime::header::USER_AGENT, user_agent.clone());
222    }
223    if let Some(ref auth_conf) = configuration.basic_auth {
224        req_builder = req_builder.basic_auth(
225            &auth_conf.0,
226            auth_conf
227                .1
228                .as_ref()
229                .map(timvw_rust_runtime::ExposeSecret::expose_secret),
230        );
231    };
232
233    // last, so its headers replace the generated ones; its base URL replaces configuration.base_path
234    if let Some(options) = options {
235        req_builder = req_builder.base(&configuration.base_path).options(options);
236    }
237    let req = req_builder.build()?;
238    let resp = configuration.client.execute(req).await?;
239
240    let status = resp.status();
241    let content_type = resp
242        .headers()
243        .get("content-type")
244        .and_then(|v| v.to_str().ok())
245        .unwrap_or("application/octet-stream");
246    let content_type = super::ContentType::from(content_type);
247
248    if !status.is_client_error() && !status.is_server_error() {
249        let content = resp.text().await?;
250        match content_type {
251            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
252            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeletedEvaluator`"))),
253            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeletedEvaluator`")))),
254        }
255    } else {
256        let headers = resp.headers().clone();
257        let content = resp.text().await?;
258        let entity: Option<EvaluatorsDeleteError> = match status.as_u16() {
259            400 => serde_json::from_str(&content)
260                .ok()
261                .map(EvaluatorsDeleteError::Status400),
262            401 => serde_json::from_str(&content)
263                .ok()
264                .map(EvaluatorsDeleteError::Status401),
265            403 => serde_json::from_str(&content)
266                .ok()
267                .map(EvaluatorsDeleteError::Status403),
268            404 => serde_json::from_str(&content)
269                .ok()
270                .map(EvaluatorsDeleteError::Status404),
271            405 => serde_json::from_str(&content)
272                .ok()
273                .map(EvaluatorsDeleteError::Status405),
274            429 => serde_json::from_str(&content)
275                .ok()
276                .map(EvaluatorsDeleteError::Status429),
277            500 => serde_json::from_str(&content)
278                .ok()
279                .map(EvaluatorsDeleteError::Status500),
280            _ => None,
281        }
282        .or_else(|| {
283            serde_json::from_str(&content)
284                .ok()
285                .map(EvaluatorsDeleteError::UnknownValue)
286        });
287        Err(Error::ResponseError(Box::new(ResponseContent {
288            status,
289            content,
290            entity,
291            headers,
292        })))
293    }
294}
295
296/// Get one evaluator by its stable identifier.  The response includes the evaluator's latest definition and version metadata flattened into the evaluator object, plus associated evaluation rules. Use the version-history endpoint when older definitions are needed.
297#[bon::builder]
298pub async fn evaluators_get(
299    configuration: &configuration::Configuration,
300    evaluator_id: &str,
301    options: Option<&timvw_rust_runtime::RequestOptions>,
302) -> Result<models::Evaluator, Error<EvaluatorsGetError>> {
303    // add a prefix to parameters to efficiently prevent name collisions
304    let p_path_evaluator_id = evaluator_id;
305
306    let uri_str = format!(
307        "{}/api/public/v2/evaluators/{evaluatorId}",
308        configuration.base_path,
309        evaluatorId = crate::apis::urlencode(p_path_evaluator_id)
310    );
311    let mut req_builder = configuration
312        .client
313        .request(timvw_rust_runtime::Method::GET, &uri_str);
314
315    if let Some(ref user_agent) = configuration.user_agent {
316        req_builder =
317            req_builder.header(timvw_rust_runtime::header::USER_AGENT, user_agent.clone());
318    }
319    if let Some(ref auth_conf) = configuration.basic_auth {
320        req_builder = req_builder.basic_auth(
321            &auth_conf.0,
322            auth_conf
323                .1
324                .as_ref()
325                .map(timvw_rust_runtime::ExposeSecret::expose_secret),
326        );
327    };
328
329    // last, so its headers replace the generated ones; its base URL replaces configuration.base_path
330    if let Some(options) = options {
331        req_builder = req_builder.base(&configuration.base_path).options(options);
332    }
333    let req = req_builder.build()?;
334    let resp = configuration.client.execute(req).await?;
335
336    let status = resp.status();
337    let content_type = resp
338        .headers()
339        .get("content-type")
340        .and_then(|v| v.to_str().ok())
341        .unwrap_or("application/octet-stream");
342    let content_type = super::ContentType::from(content_type);
343
344    if !status.is_client_error() && !status.is_server_error() {
345        let content = resp.text().await?;
346        match content_type {
347            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
348            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Evaluator`"))),
349            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Evaluator`")))),
350        }
351    } else {
352        let headers = resp.headers().clone();
353        let content = resp.text().await?;
354        let entity: Option<EvaluatorsGetError> = match status.as_u16() {
355            400 => serde_json::from_str(&content)
356                .ok()
357                .map(EvaluatorsGetError::Status400),
358            401 => serde_json::from_str(&content)
359                .ok()
360                .map(EvaluatorsGetError::Status401),
361            403 => serde_json::from_str(&content)
362                .ok()
363                .map(EvaluatorsGetError::Status403),
364            404 => serde_json::from_str(&content)
365                .ok()
366                .map(EvaluatorsGetError::Status404),
367            405 => serde_json::from_str(&content)
368                .ok()
369                .map(EvaluatorsGetError::Status405),
370            429 => serde_json::from_str(&content)
371                .ok()
372                .map(EvaluatorsGetError::Status429),
373            500 => serde_json::from_str(&content)
374                .ok()
375                .map(EvaluatorsGetError::Status500),
376            _ => None,
377        }
378        .or_else(|| {
379            serde_json::from_str(&content)
380                .ok()
381                .map(EvaluatorsGetError::UnknownValue)
382        });
383        Err(Error::ResponseError(Box::new(ResponseContent {
384            status,
385            content,
386            entity,
387            headers,
388        })))
389    }
390}
391
392/// List evaluators in newest-first creation order.  Every evaluator includes its latest definition and version metadata flattened into the evaluator object, plus associated evaluation rules. Treat the cursor as opaque and return it unchanged.
393#[bon::builder]
394pub async fn evaluators_list(
395    configuration: &configuration::Configuration,
396    limit: Option<i64>,
397    cursor: Option<&str>,
398    options: Option<&timvw_rust_runtime::RequestOptions>,
399) -> Result<models::EvaluatorsPage, Error<EvaluatorsListError>> {
400    // add a prefix to parameters to efficiently prevent name collisions
401    let p_query_limit = limit;
402    let p_query_cursor = cursor;
403
404    let uri_str = format!("{}/api/public/v2/evaluators", configuration.base_path);
405    let mut req_builder = configuration
406        .client
407        .request(timvw_rust_runtime::Method::GET, &uri_str);
408
409    if let Some(ref param_value) = p_query_limit {
410        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
411    }
412    if let Some(ref param_value) = p_query_cursor {
413        req_builder = req_builder.query(&[("cursor", &param_value.to_string())]);
414    }
415    if let Some(ref user_agent) = configuration.user_agent {
416        req_builder =
417            req_builder.header(timvw_rust_runtime::header::USER_AGENT, user_agent.clone());
418    }
419    if let Some(ref auth_conf) = configuration.basic_auth {
420        req_builder = req_builder.basic_auth(
421            &auth_conf.0,
422            auth_conf
423                .1
424                .as_ref()
425                .map(timvw_rust_runtime::ExposeSecret::expose_secret),
426        );
427    };
428
429    // last, so its headers replace the generated ones; its base URL replaces configuration.base_path
430    if let Some(options) = options {
431        req_builder = req_builder.base(&configuration.base_path).options(options);
432    }
433    let req = req_builder.build()?;
434    let resp = configuration.client.execute(req).await?;
435
436    let status = resp.status();
437    let content_type = resp
438        .headers()
439        .get("content-type")
440        .and_then(|v| v.to_str().ok())
441        .unwrap_or("application/octet-stream");
442    let content_type = super::ContentType::from(content_type);
443
444    if !status.is_client_error() && !status.is_server_error() {
445        let content = resp.text().await?;
446        match content_type {
447            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
448            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EvaluatorsPage`"))),
449            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EvaluatorsPage`")))),
450        }
451    } else {
452        let headers = resp.headers().clone();
453        let content = resp.text().await?;
454        let entity: Option<EvaluatorsListError> = match status.as_u16() {
455            400 => serde_json::from_str(&content)
456                .ok()
457                .map(EvaluatorsListError::Status400),
458            401 => serde_json::from_str(&content)
459                .ok()
460                .map(EvaluatorsListError::Status401),
461            403 => serde_json::from_str(&content)
462                .ok()
463                .map(EvaluatorsListError::Status403),
464            404 => serde_json::from_str(&content)
465                .ok()
466                .map(EvaluatorsListError::Status404),
467            405 => serde_json::from_str(&content)
468                .ok()
469                .map(EvaluatorsListError::Status405),
470            429 => serde_json::from_str(&content)
471                .ok()
472                .map(EvaluatorsListError::Status429),
473            500 => serde_json::from_str(&content)
474                .ok()
475                .map(EvaluatorsListError::Status500),
476            _ => None,
477        }
478        .or_else(|| {
479            serde_json::from_str(&content)
480                .ok()
481                .map(EvaluatorsListError::UnknownValue)
482        });
483        Err(Error::ResponseError(Box::new(ResponseContent {
484            status,
485            content,
486            entity,
487            headers,
488        })))
489    }
490}
491
492/// List an evaluator's version history in newest-first order.  This endpoint is intended for history and audit use cases. Ordinary clients can use the flattened `version` and definition fields on the evaluator response.
493#[bon::builder]
494pub async fn evaluators_list_versions(
495    configuration: &configuration::Configuration,
496    evaluator_id: &str,
497    limit: Option<i64>,
498    cursor: Option<&str>,
499    options: Option<&timvw_rust_runtime::RequestOptions>,
500) -> Result<models::EvaluatorVersionsPage, Error<EvaluatorsListVersionsError>> {
501    // add a prefix to parameters to efficiently prevent name collisions
502    let p_path_evaluator_id = evaluator_id;
503    let p_query_limit = limit;
504    let p_query_cursor = cursor;
505
506    let uri_str = format!(
507        "{}/api/public/v2/evaluators/{evaluatorId}/versions",
508        configuration.base_path,
509        evaluatorId = crate::apis::urlencode(p_path_evaluator_id)
510    );
511    let mut req_builder = configuration
512        .client
513        .request(timvw_rust_runtime::Method::GET, &uri_str);
514
515    if let Some(ref param_value) = p_query_limit {
516        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
517    }
518    if let Some(ref param_value) = p_query_cursor {
519        req_builder = req_builder.query(&[("cursor", &param_value.to_string())]);
520    }
521    if let Some(ref user_agent) = configuration.user_agent {
522        req_builder =
523            req_builder.header(timvw_rust_runtime::header::USER_AGENT, user_agent.clone());
524    }
525    if let Some(ref auth_conf) = configuration.basic_auth {
526        req_builder = req_builder.basic_auth(
527            &auth_conf.0,
528            auth_conf
529                .1
530                .as_ref()
531                .map(timvw_rust_runtime::ExposeSecret::expose_secret),
532        );
533    };
534
535    // last, so its headers replace the generated ones; its base URL replaces configuration.base_path
536    if let Some(options) = options {
537        req_builder = req_builder.base(&configuration.base_path).options(options);
538    }
539    let req = req_builder.build()?;
540    let resp = configuration.client.execute(req).await?;
541
542    let status = resp.status();
543    let content_type = resp
544        .headers()
545        .get("content-type")
546        .and_then(|v| v.to_str().ok())
547        .unwrap_or("application/octet-stream");
548    let content_type = super::ContentType::from(content_type);
549
550    if !status.is_client_error() && !status.is_server_error() {
551        let content = resp.text().await?;
552        match content_type {
553            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
554            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EvaluatorVersionsPage`"))),
555            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EvaluatorVersionsPage`")))),
556        }
557    } else {
558        let headers = resp.headers().clone();
559        let content = resp.text().await?;
560        let entity: Option<EvaluatorsListVersionsError> = match status.as_u16() {
561            400 => serde_json::from_str(&content)
562                .ok()
563                .map(EvaluatorsListVersionsError::Status400),
564            401 => serde_json::from_str(&content)
565                .ok()
566                .map(EvaluatorsListVersionsError::Status401),
567            403 => serde_json::from_str(&content)
568                .ok()
569                .map(EvaluatorsListVersionsError::Status403),
570            404 => serde_json::from_str(&content)
571                .ok()
572                .map(EvaluatorsListVersionsError::Status404),
573            405 => serde_json::from_str(&content)
574                .ok()
575                .map(EvaluatorsListVersionsError::Status405),
576            429 => serde_json::from_str(&content)
577                .ok()
578                .map(EvaluatorsListVersionsError::Status429),
579            500 => serde_json::from_str(&content)
580                .ok()
581                .map(EvaluatorsListVersionsError::Status500),
582            _ => None,
583        }
584        .or_else(|| {
585            serde_json::from_str(&content)
586                .ok()
587                .map(EvaluatorsListVersionsError::UnknownValue)
588        });
589        Err(Error::ResponseError(Box::new(ResponseContent {
590            status,
591            content,
592            entity,
593            headers,
594        })))
595    }
596}
597
598/// Update an evaluator by its stable identifier.  Provide only the top-level fields to change. Metadata-only changes do not create a version. Evaluator type cannot change.  Definition fields are flattened into the request. To replace a definition, include `type` and every definition field for that type. Definition fields are replaced as a complete unit rather than merged. For LLM-as-a-judge evaluators, omitting or setting `modelConfig` to `null` selects the project's default evaluation model.  Replacing a definition automatically returns an evaluator paused by an invalid or missing model configuration to `active`, while preserving its id and evaluation-rule assignments. Pauses caused by provider authentication, billing, connectivity, account state, or an unknown legacy reason remain paused until the explicit reactivation check succeeds.
599#[bon::builder]
600pub async fn evaluators_update(
601    configuration: &configuration::Configuration,
602    evaluator_id: &str,
603    update_evaluator_request: &models::UpdateEvaluatorRequest,
604    options: Option<&timvw_rust_runtime::RequestOptions>,
605) -> Result<models::Evaluator, Error<EvaluatorsUpdateError>> {
606    // add a prefix to parameters to efficiently prevent name collisions
607    let p_path_evaluator_id = evaluator_id;
608    let p_body_update_evaluator_request = update_evaluator_request;
609
610    let uri_str = format!(
611        "{}/api/public/v2/evaluators/{evaluatorId}",
612        configuration.base_path,
613        evaluatorId = crate::apis::urlencode(p_path_evaluator_id)
614    );
615    let mut req_builder = configuration
616        .client
617        .request(timvw_rust_runtime::Method::PATCH, &uri_str);
618
619    if let Some(ref user_agent) = configuration.user_agent {
620        req_builder =
621            req_builder.header(timvw_rust_runtime::header::USER_AGENT, user_agent.clone());
622    }
623    if let Some(ref auth_conf) = configuration.basic_auth {
624        req_builder = req_builder.basic_auth(
625            &auth_conf.0,
626            auth_conf
627                .1
628                .as_ref()
629                .map(timvw_rust_runtime::ExposeSecret::expose_secret),
630        );
631    };
632    req_builder = req_builder.json(p_body_update_evaluator_request);
633
634    // last, so its headers replace the generated ones; its base URL replaces configuration.base_path
635    if let Some(options) = options {
636        req_builder = req_builder.base(&configuration.base_path).options(options);
637    }
638    let req = req_builder.build()?;
639    let resp = configuration.client.execute(req).await?;
640
641    let status = resp.status();
642    let content_type = resp
643        .headers()
644        .get("content-type")
645        .and_then(|v| v.to_str().ok())
646        .unwrap_or("application/octet-stream");
647    let content_type = super::ContentType::from(content_type);
648
649    if !status.is_client_error() && !status.is_server_error() {
650        let content = resp.text().await?;
651        match content_type {
652            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
653            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Evaluator`"))),
654            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Evaluator`")))),
655        }
656    } else {
657        let headers = resp.headers().clone();
658        let content = resp.text().await?;
659        let entity: Option<EvaluatorsUpdateError> = match status.as_u16() {
660            400 => serde_json::from_str(&content)
661                .ok()
662                .map(EvaluatorsUpdateError::Status400),
663            401 => serde_json::from_str(&content)
664                .ok()
665                .map(EvaluatorsUpdateError::Status401),
666            403 => serde_json::from_str(&content)
667                .ok()
668                .map(EvaluatorsUpdateError::Status403),
669            404 => serde_json::from_str(&content)
670                .ok()
671                .map(EvaluatorsUpdateError::Status404),
672            405 => serde_json::from_str(&content)
673                .ok()
674                .map(EvaluatorsUpdateError::Status405),
675            409 => serde_json::from_str(&content)
676                .ok()
677                .map(EvaluatorsUpdateError::Status409),
678            412 => serde_json::from_str(&content)
679                .ok()
680                .map(EvaluatorsUpdateError::Status412),
681            429 => serde_json::from_str(&content)
682                .ok()
683                .map(EvaluatorsUpdateError::Status429),
684            500 => serde_json::from_str(&content)
685                .ok()
686                .map(EvaluatorsUpdateError::Status500),
687            _ => None,
688        }
689        .or_else(|| {
690            serde_json::from_str(&content)
691                .ok()
692                .map(EvaluatorsUpdateError::UnknownValue)
693        });
694        Err(Error::ResponseError(Box::new(ResponseContent {
695            status,
696            content,
697            entity,
698            headers,
699        })))
700    }
701}