langfuse_client_base/models/
public_api_error_code.rs1#![allow(deprecated)]
2use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
17pub enum PublicApiErrorCode {
18 #[serde(rename = "authentication_failed")]
19 AuthenticationFailed,
20 #[serde(rename = "access_denied")]
21 AccessDenied,
22 #[serde(rename = "invalid_request")]
23 InvalidRequest,
24 #[serde(rename = "invalid_query")]
25 InvalidQuery,
26 #[serde(rename = "invalid_body")]
27 InvalidBody,
28 #[serde(rename = "resource_not_found")]
29 ResourceNotFound,
30 #[serde(rename = "conflict")]
31 Conflict,
32 #[serde(rename = "rate_limited")]
33 RateLimited,
34 #[serde(rename = "method_not_allowed")]
35 MethodNotAllowed,
36 #[serde(rename = "internal_error")]
37 InternalError,
38
39 #[serde(rename = "unknown", other)]
41 Unknown,
42}
43
44impl std::fmt::Display for PublicApiErrorCode {
45 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
46 match self {
47 Self::AuthenticationFailed => write!(f, "authentication_failed"),
48 Self::AccessDenied => write!(f, "access_denied"),
49 Self::InvalidRequest => write!(f, "invalid_request"),
50 Self::InvalidQuery => write!(f, "invalid_query"),
51 Self::InvalidBody => write!(f, "invalid_body"),
52 Self::ResourceNotFound => write!(f, "resource_not_found"),
53 Self::Conflict => write!(f, "conflict"),
54 Self::RateLimited => write!(f, "rate_limited"),
55 Self::MethodNotAllowed => write!(f, "method_not_allowed"),
56 Self::InternalError => write!(f, "internal_error"),
57 Self::Unknown => write!(f, "unknown"),
58 }
59 }
60}
61
62impl crate::models::validation::Validate for PublicApiErrorCode {
63 fn validate_into(
64 &self,
65 _path: &crate::models::validation::Path<'_>,
66 _errors: &mut Vec<crate::models::validation::ValidationError>,
67 ) {
68 }
69}
70
71impl ::std::str::FromStr for PublicApiErrorCode {
72 type Err = crate::models::ParseEnumError;
73
74 fn from_str(value: &str) -> ::std::result::Result<Self, crate::models::ParseEnumError> {
75 match value {
76 "authentication_failed" => Ok(Self::AuthenticationFailed),
77 "access_denied" => Ok(Self::AccessDenied),
78 "invalid_request" => Ok(Self::InvalidRequest),
79 "invalid_query" => Ok(Self::InvalidQuery),
80 "invalid_body" => Ok(Self::InvalidBody),
81 "resource_not_found" => Ok(Self::ResourceNotFound),
82 "conflict" => Ok(Self::Conflict),
83 "rate_limited" => Ok(Self::RateLimited),
84 "method_not_allowed" => Ok(Self::MethodNotAllowed),
85 "internal_error" => Ok(Self::InternalError),
86 _ => Err(crate::models::ParseEnumError::new(
87 "PublicApiErrorCode",
88 value,
89 )),
90 }
91 }
92}
93
94impl ::std::convert::TryFrom<&str> for PublicApiErrorCode {
95 type Error = crate::models::ParseEnumError;
96
97 fn try_from(value: &str) -> ::std::result::Result<Self, crate::models::ParseEnumError> {
98 value.parse()
99 }
100}
101
102impl ::std::convert::TryFrom<&::std::string::String> for PublicApiErrorCode {
103 type Error = crate::models::ParseEnumError;
104
105 fn try_from(
106 value: &::std::string::String,
107 ) -> ::std::result::Result<Self, crate::models::ParseEnumError> {
108 value.parse()
109 }
110}
111
112impl ::std::convert::TryFrom<::std::string::String> for PublicApiErrorCode {
113 type Error = crate::models::ParseEnumError;
114
115 fn try_from(
116 value: ::std::string::String,
117 ) -> ::std::result::Result<Self, crate::models::ParseEnumError> {
118 value.parse()
119 }
120}