1use 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 SessionControllerCreateError {
20 UnknownValue(serde_json::Value),
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum SessionControllerFindAllPaginatedError {
27 UnknownValue(serde_json::Value),
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum SessionControllerFindOneError {
34 UnknownValue(serde_json::Value),
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum SessionControllerRemoveError {
41 UnknownValue(serde_json::Value),
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum SessionControllerUpdateError {
48 UnknownValue(serde_json::Value),
49}
50
51pub async fn session_controller_create(
52 configuration: &configuration::Configuration,
53 create_session_dto: models::CreateSessionDto,
54) -> Result<models::Session, Error<SessionControllerCreateError>> {
55 let p_create_session_dto = create_session_dto;
57
58 let uri_str = format!("{}/session", configuration.base_path);
59 let mut req_builder = configuration
60 .client
61 .request(reqwest::Method::POST, &uri_str);
62
63 if let Some(ref user_agent) = configuration.user_agent {
64 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
65 }
66 if let Some(ref token) = configuration.bearer_access_token {
67 req_builder = req_builder.bearer_auth(token.to_owned());
68 };
69 req_builder = req_builder.json(&p_create_session_dto);
70
71 let req = req_builder.build()?;
72 let resp = configuration.client.execute(req).await?;
73
74 let status = resp.status();
75 let content_type = resp
76 .headers()
77 .get("content-type")
78 .and_then(|v| v.to_str().ok())
79 .unwrap_or("application/octet-stream");
80 let content_type = super::ContentType::from(content_type);
81
82 if !status.is_client_error() && !status.is_server_error() {
83 let content = resp.text().await?;
84 match content_type {
85 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
86 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Session`"))),
87 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::Session`")))),
88 }
89 } else {
90 let content = resp.text().await?;
91 let entity: Option<SessionControllerCreateError> = serde_json::from_str(&content).ok();
92 Err(Error::ResponseError(ResponseContent {
93 status,
94 content,
95 entity,
96 }))
97 }
98}
99
100pub async fn session_controller_find_all_paginated(
101 configuration: &configuration::Configuration,
102 name: Option<&str>,
103 assistant_id: Option<&str>,
104 workflow_id: Option<&str>,
105 page: Option<f64>,
106 sort_order: Option<&str>,
107 limit: Option<f64>,
108 created_at_gt: Option<String>,
109 created_at_lt: Option<String>,
110 created_at_ge: Option<String>,
111 created_at_le: Option<String>,
112 updated_at_gt: Option<String>,
113 updated_at_lt: Option<String>,
114 updated_at_ge: Option<String>,
115 updated_at_le: Option<String>,
116) -> Result<models::SessionPaginatedResponse, Error<SessionControllerFindAllPaginatedError>> {
117 let p_name = name;
119 let p_assistant_id = assistant_id;
120 let p_workflow_id = workflow_id;
121 let p_page = page;
122 let p_sort_order = sort_order;
123 let p_limit = limit;
124 let p_created_at_gt = created_at_gt;
125 let p_created_at_lt = created_at_lt;
126 let p_created_at_ge = created_at_ge;
127 let p_created_at_le = created_at_le;
128 let p_updated_at_gt = updated_at_gt;
129 let p_updated_at_lt = updated_at_lt;
130 let p_updated_at_ge = updated_at_ge;
131 let p_updated_at_le = updated_at_le;
132
133 let uri_str = format!("{}/session", configuration.base_path);
134 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
135
136 if let Some(ref param_value) = p_name {
137 req_builder = req_builder.query(&[("name", ¶m_value.to_string())]);
138 }
139 if let Some(ref param_value) = p_assistant_id {
140 req_builder = req_builder.query(&[("assistantId", ¶m_value.to_string())]);
141 }
142 if let Some(ref param_value) = p_workflow_id {
143 req_builder = req_builder.query(&[("workflowId", ¶m_value.to_string())]);
144 }
145 if let Some(ref param_value) = p_page {
146 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
147 }
148 if let Some(ref param_value) = p_sort_order {
149 req_builder = req_builder.query(&[("sortOrder", ¶m_value.to_string())]);
150 }
151 if let Some(ref param_value) = p_limit {
152 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
153 }
154 if let Some(ref param_value) = p_created_at_gt {
155 req_builder = req_builder.query(&[("createdAtGt", ¶m_value.to_string())]);
156 }
157 if let Some(ref param_value) = p_created_at_lt {
158 req_builder = req_builder.query(&[("createdAtLt", ¶m_value.to_string())]);
159 }
160 if let Some(ref param_value) = p_created_at_ge {
161 req_builder = req_builder.query(&[("createdAtGe", ¶m_value.to_string())]);
162 }
163 if let Some(ref param_value) = p_created_at_le {
164 req_builder = req_builder.query(&[("createdAtLe", ¶m_value.to_string())]);
165 }
166 if let Some(ref param_value) = p_updated_at_gt {
167 req_builder = req_builder.query(&[("updatedAtGt", ¶m_value.to_string())]);
168 }
169 if let Some(ref param_value) = p_updated_at_lt {
170 req_builder = req_builder.query(&[("updatedAtLt", ¶m_value.to_string())]);
171 }
172 if let Some(ref param_value) = p_updated_at_ge {
173 req_builder = req_builder.query(&[("updatedAtGe", ¶m_value.to_string())]);
174 }
175 if let Some(ref param_value) = p_updated_at_le {
176 req_builder = req_builder.query(&[("updatedAtLe", ¶m_value.to_string())]);
177 }
178 if let Some(ref user_agent) = configuration.user_agent {
179 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
180 }
181 if let Some(ref token) = configuration.bearer_access_token {
182 req_builder = req_builder.bearer_auth(token.to_owned());
183 };
184
185 let req = req_builder.build()?;
186 let resp = configuration.client.execute(req).await?;
187
188 let status = resp.status();
189 let content_type = resp
190 .headers()
191 .get("content-type")
192 .and_then(|v| v.to_str().ok())
193 .unwrap_or("application/octet-stream");
194 let content_type = super::ContentType::from(content_type);
195
196 if !status.is_client_error() && !status.is_server_error() {
197 let content = resp.text().await?;
198 match content_type {
199 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
200 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SessionPaginatedResponse`"))),
201 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::SessionPaginatedResponse`")))),
202 }
203 } else {
204 let content = resp.text().await?;
205 let entity: Option<SessionControllerFindAllPaginatedError> =
206 serde_json::from_str(&content).ok();
207 Err(Error::ResponseError(ResponseContent {
208 status,
209 content,
210 entity,
211 }))
212 }
213}
214
215pub async fn session_controller_find_one(
216 configuration: &configuration::Configuration,
217 id: &str,
218) -> Result<models::Session, Error<SessionControllerFindOneError>> {
219 let p_id = id;
221
222 let uri_str = format!(
223 "{}/session/{id}",
224 configuration.base_path,
225 id = crate::apis::urlencode(p_id)
226 );
227 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
228
229 if let Some(ref user_agent) = configuration.user_agent {
230 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
231 }
232 if let Some(ref token) = configuration.bearer_access_token {
233 req_builder = req_builder.bearer_auth(token.to_owned());
234 };
235
236 let req = req_builder.build()?;
237 let resp = configuration.client.execute(req).await?;
238
239 let status = resp.status();
240 let content_type = resp
241 .headers()
242 .get("content-type")
243 .and_then(|v| v.to_str().ok())
244 .unwrap_or("application/octet-stream");
245 let content_type = super::ContentType::from(content_type);
246
247 if !status.is_client_error() && !status.is_server_error() {
248 let content = resp.text().await?;
249 match content_type {
250 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
251 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Session`"))),
252 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::Session`")))),
253 }
254 } else {
255 let content = resp.text().await?;
256 let entity: Option<SessionControllerFindOneError> = serde_json::from_str(&content).ok();
257 Err(Error::ResponseError(ResponseContent {
258 status,
259 content,
260 entity,
261 }))
262 }
263}
264
265pub async fn session_controller_remove(
266 configuration: &configuration::Configuration,
267 id: &str,
268) -> Result<models::Session, Error<SessionControllerRemoveError>> {
269 let p_id = id;
271
272 let uri_str = format!(
273 "{}/session/{id}",
274 configuration.base_path,
275 id = crate::apis::urlencode(p_id)
276 );
277 let mut req_builder = configuration
278 .client
279 .request(reqwest::Method::DELETE, &uri_str);
280
281 if let Some(ref user_agent) = configuration.user_agent {
282 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
283 }
284 if let Some(ref token) = configuration.bearer_access_token {
285 req_builder = req_builder.bearer_auth(token.to_owned());
286 };
287
288 let req = req_builder.build()?;
289 let resp = configuration.client.execute(req).await?;
290
291 let status = resp.status();
292 let content_type = resp
293 .headers()
294 .get("content-type")
295 .and_then(|v| v.to_str().ok())
296 .unwrap_or("application/octet-stream");
297 let content_type = super::ContentType::from(content_type);
298
299 if !status.is_client_error() && !status.is_server_error() {
300 let content = resp.text().await?;
301 match content_type {
302 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
303 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Session`"))),
304 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::Session`")))),
305 }
306 } else {
307 let content = resp.text().await?;
308 let entity: Option<SessionControllerRemoveError> = serde_json::from_str(&content).ok();
309 Err(Error::ResponseError(ResponseContent {
310 status,
311 content,
312 entity,
313 }))
314 }
315}
316
317pub async fn session_controller_update(
318 configuration: &configuration::Configuration,
319 id: &str,
320 update_session_dto: models::UpdateSessionDto,
321) -> Result<models::Session, Error<SessionControllerUpdateError>> {
322 let p_id = id;
324 let p_update_session_dto = update_session_dto;
325
326 let uri_str = format!(
327 "{}/session/{id}",
328 configuration.base_path,
329 id = crate::apis::urlencode(p_id)
330 );
331 let mut req_builder = configuration
332 .client
333 .request(reqwest::Method::PATCH, &uri_str);
334
335 if let Some(ref user_agent) = configuration.user_agent {
336 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
337 }
338 if let Some(ref token) = configuration.bearer_access_token {
339 req_builder = req_builder.bearer_auth(token.to_owned());
340 };
341 req_builder = req_builder.json(&p_update_session_dto);
342
343 let req = req_builder.build()?;
344 let resp = configuration.client.execute(req).await?;
345
346 let status = resp.status();
347 let content_type = resp
348 .headers()
349 .get("content-type")
350 .and_then(|v| v.to_str().ok())
351 .unwrap_or("application/octet-stream");
352 let content_type = super::ContentType::from(content_type);
353
354 if !status.is_client_error() && !status.is_server_error() {
355 let content = resp.text().await?;
356 match content_type {
357 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
358 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Session`"))),
359 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::Session`")))),
360 }
361 } else {
362 let content = resp.text().await?;
363 let entity: Option<SessionControllerUpdateError> = serde_json::from_str(&content).ok();
364 Err(Error::ResponseError(ResponseContent {
365 status,
366 content,
367 entity,
368 }))
369 }
370}