langfuse_client_base/apis/
llm_connections_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 LlmConnectionsDeleteError {
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 LlmConnectionsListError {
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 LlmConnectionsUpsertError {
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#[bon::builder]
54pub async fn llm_connections_delete(
55 configuration: &configuration::Configuration,
56 id: &str,
57) -> Result<models::DeleteLlmConnectionResponse, Error<LlmConnectionsDeleteError>> {
58 let p_path_id = id;
60
61 let uri_str = format!(
62 "{}/api/public/llm-connections/{id}",
63 configuration.base_path,
64 id = crate::apis::urlencode(p_path_id)
65 );
66 let mut req_builder = configuration
67 .client
68 .request(reqwest::Method::DELETE, &uri_str);
69
70 if let Some(ref user_agent) = configuration.user_agent {
71 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
72 }
73 if let Some(ref auth_conf) = configuration.basic_auth {
74 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
75 };
76
77 let req = req_builder.build()?;
78 let resp = configuration.client.execute(req).await?;
79
80 let status = resp.status();
81 let content_type = resp
82 .headers()
83 .get("content-type")
84 .and_then(|v| v.to_str().ok())
85 .unwrap_or("application/octet-stream");
86 let content_type = super::ContentType::from(content_type);
87
88 if !status.is_client_error() && !status.is_server_error() {
89 let content = resp.text().await?;
90 match content_type {
91 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
92 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteLlmConnectionResponse`"))),
93 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::DeleteLlmConnectionResponse`")))),
94 }
95 } else {
96 let content = resp.text().await?;
97 let entity: Option<LlmConnectionsDeleteError> = serde_json::from_str(&content).ok();
98 Err(Error::ResponseError(ResponseContent {
99 status,
100 content,
101 entity,
102 }))
103 }
104}
105
106#[bon::builder]
108pub async fn llm_connections_list(
109 configuration: &configuration::Configuration,
110 page: Option<i32>,
111 limit: Option<i32>,
112) -> Result<models::PaginatedLlmConnections, Error<LlmConnectionsListError>> {
113 let p_query_page = page;
115 let p_query_limit = limit;
116
117 let uri_str = format!("{}/api/public/llm-connections", configuration.base_path);
118 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
119
120 if let Some(ref param_value) = p_query_page {
121 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
122 }
123 if let Some(ref param_value) = p_query_limit {
124 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
125 }
126 if let Some(ref user_agent) = configuration.user_agent {
127 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
128 }
129 if let Some(ref auth_conf) = configuration.basic_auth {
130 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
131 };
132
133 let req = req_builder.build()?;
134 let resp = configuration.client.execute(req).await?;
135
136 let status = resp.status();
137 let content_type = resp
138 .headers()
139 .get("content-type")
140 .and_then(|v| v.to_str().ok())
141 .unwrap_or("application/octet-stream");
142 let content_type = super::ContentType::from(content_type);
143
144 if !status.is_client_error() && !status.is_server_error() {
145 let content = resp.text().await?;
146 match content_type {
147 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
148 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedLlmConnections`"))),
149 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::PaginatedLlmConnections`")))),
150 }
151 } else {
152 let content = resp.text().await?;
153 let entity: Option<LlmConnectionsListError> = serde_json::from_str(&content).ok();
154 Err(Error::ResponseError(ResponseContent {
155 status,
156 content,
157 entity,
158 }))
159 }
160}
161
162#[bon::builder]
164pub async fn llm_connections_upsert(
165 configuration: &configuration::Configuration,
166 upsert_llm_connection_request: models::UpsertLlmConnectionRequest,
167) -> Result<models::LlmConnection, Error<LlmConnectionsUpsertError>> {
168 let p_body_upsert_llm_connection_request = upsert_llm_connection_request;
170
171 let uri_str = format!("{}/api/public/llm-connections", configuration.base_path);
172 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
173
174 if let Some(ref user_agent) = configuration.user_agent {
175 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
176 }
177 if let Some(ref auth_conf) = configuration.basic_auth {
178 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
179 };
180 req_builder = req_builder.json(&p_body_upsert_llm_connection_request);
181
182 let req = req_builder.build()?;
183 let resp = configuration.client.execute(req).await?;
184
185 let status = resp.status();
186 let content_type = resp
187 .headers()
188 .get("content-type")
189 .and_then(|v| v.to_str().ok())
190 .unwrap_or("application/octet-stream");
191 let content_type = super::ContentType::from(content_type);
192
193 if !status.is_client_error() && !status.is_server_error() {
194 let content = resp.text().await?;
195 match content_type {
196 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
197 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LlmConnection`"))),
198 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::LlmConnection`")))),
199 }
200 } else {
201 let content = resp.text().await?;
202 let entity: Option<LlmConnectionsUpsertError> = serde_json::from_str(&content).ok();
203 Err(Error::ResponseError(ResponseContent {
204 status,
205 content,
206 entity,
207 }))
208 }
209}