1use super::{ContentType, Error, UploadFile, configuration};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{Deserialize, Serialize, de::Error as _};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum CancelRunHttpThreadsThreadIdRunsRunIdCancelPostError {
20 Status404(String),
21 Status422(String),
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum CancelRunsPostError {
29 Status404(String),
30 Status422(String),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum CreateRunThreadsThreadIdRunsPostError {
38 Status404(String),
39 Status409(String),
40 Status422(String),
41 UnknownValue(serde_json::Value),
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum DeleteRunThreadsThreadIdRunsRunIdDeleteError {
48 Status404(String),
49 Status422(String),
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetRunHttpThreadsThreadIdRunsRunIdGetError {
57 Status404(String),
58 Status422(String),
59 UnknownValue(serde_json::Value),
60}
61
62#[derive(Debug, Clone, Serialize, Deserialize)]
64#[serde(untagged)]
65pub enum JoinRunHttpThreadsThreadIdRunsRunIdJoinGetError {
66 Status404(String),
67 Status422(String),
68 UnknownValue(serde_json::Value),
69}
70
71#[derive(Debug, Clone, Serialize, Deserialize)]
73#[serde(untagged)]
74pub enum ListRunsHttpThreadsThreadIdRunsGetError {
75 Status404(String),
76 Status422(String),
77 UnknownValue(serde_json::Value),
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize)]
82#[serde(untagged)]
83pub enum StreamRunHttpThreadsThreadIdRunsRunIdJoinGetError {
84 Status404(String),
85 Status422(String),
86 UnknownValue(serde_json::Value),
87}
88
89#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum StreamRunThreadsThreadIdRunsStreamPostError {
93 Status404(String),
94 Status409(String),
95 Status422(String),
96 UnknownValue(serde_json::Value),
97}
98
99#[derive(Debug, Clone, Serialize, Deserialize)]
101#[serde(untagged)]
102pub enum WaitRunThreadsThreadIdRunsWaitPostError {
103 Status404(String),
104 Status409(String),
105 Status422(String),
106 UnknownValue(serde_json::Value),
107}
108
109pub fn cancel_run_http_threads_thread_id_runs_run_id_cancel_post_request_builder(
110 configuration: &configuration::Configuration,
111 thread_id: &str,
112 run_id: &str,
113 wait: Option<bool>,
114 action: Option<&str>,
115) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
116 let p_path_thread_id = thread_id;
118 let p_path_run_id = run_id;
119 let p_query_wait = wait;
120 let p_query_action = action;
121
122 let uri_str = format!(
123 "{}/threads/{thread_id}/runs/{run_id}/cancel",
124 configuration.base_path,
125 thread_id = crate::apis::urlencode(p_path_thread_id),
126 run_id = crate::apis::urlencode(p_path_run_id)
127 );
128 let mut req_builder = configuration
129 .client
130 .request(reqwest::Method::POST, &uri_str);
131
132 if let Some(ref param_value) = p_query_wait {
133 req_builder = req_builder.query(&[("wait", ¶m_value.to_string())]);
134 }
135 if let Some(ref param_value) = p_query_action {
136 req_builder = req_builder.query(&[("action", ¶m_value.to_string())]);
137 }
138 if let Some(ref user_agent) = configuration.user_agent {
139 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
140 }
141
142 Ok(req_builder)
143}
144
145pub async fn cancel_run_http_threads_thread_id_runs_run_id_cancel_post(
146 configuration: &configuration::Configuration,
147 thread_id: &str,
148 run_id: &str,
149 wait: Option<bool>,
150 action: Option<&str>,
151) -> Result<serde_json::Value, Error<CancelRunHttpThreadsThreadIdRunsRunIdCancelPostError>> {
152 let req_builder = cancel_run_http_threads_thread_id_runs_run_id_cancel_post_request_builder(
153 configuration,
154 thread_id,
155 run_id,
156 wait,
157 action,
158 )
159 .map_err(super::map_request_builder_error)?;
160 let req = req_builder.build()?;
161 let resp = configuration.client.execute(req).await?;
162
163 let status = resp.status();
164 let content_type = resp
165 .headers()
166 .get("content-type")
167 .and_then(|v| v.to_str().ok())
168 .unwrap_or("application/octet-stream");
169 let content_type = super::ContentType::from(content_type);
170
171 if !status.is_client_error() && !status.is_server_error() {
172 let content = resp.text().await?;
173 match content_type {
174 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
175 ContentType::Text => Err(Error::from(serde_json::Error::custom(
176 "Received `text/plain` content type response that cannot be converted to `serde_json::Value`",
177 ))),
178 ContentType::Unsupported(unknown_type) => {
179 Err(Error::from(serde_json::Error::custom(format!(
180 "Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`"
181 ))))
182 }
183 }
184 } else {
185 let content = resp.text().await?;
186 let entity: Option<CancelRunHttpThreadsThreadIdRunsRunIdCancelPostError> =
187 serde_json::from_str(&content).ok();
188 Err(Error::ResponseError(ResponseContent {
189 status,
190 content,
191 entity,
192 }))
193 }
194}
195
196pub fn cancel_runs_post_request_builder(
198 configuration: &configuration::Configuration,
199 runs_cancel: Option<models::RunsCancel>,
200 action: Option<&str>,
201) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
202 let p_body_runs_cancel = runs_cancel;
204 let p_query_action = action;
205
206 let uri_str = format!("{}/runs/cancel", configuration.base_path);
207 let mut req_builder = configuration
208 .client
209 .request(reqwest::Method::POST, &uri_str);
210
211 if let Some(ref param_value) = p_query_action {
212 req_builder = req_builder.query(&[("action", ¶m_value.to_string())]);
213 }
214 if let Some(ref user_agent) = configuration.user_agent {
215 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
216 }
217 req_builder = req_builder.json(&p_body_runs_cancel);
218
219 Ok(req_builder)
220}
221
222pub async fn cancel_runs_post(
223 configuration: &configuration::Configuration,
224 runs_cancel: Option<models::RunsCancel>,
225 action: Option<&str>,
226) -> Result<(), Error<CancelRunsPostError>> {
227 let req_builder = cancel_runs_post_request_builder(configuration, runs_cancel, action)
228 .map_err(super::map_request_builder_error)?;
229 let req = req_builder.build()?;
230 let resp = configuration.client.execute(req).await?;
231
232 let status = resp.status();
233
234 if !status.is_client_error() && !status.is_server_error() {
235 Ok(())
236 } else {
237 let content = resp.text().await?;
238 let entity: Option<CancelRunsPostError> = serde_json::from_str(&content).ok();
239 Err(Error::ResponseError(ResponseContent {
240 status,
241 content,
242 entity,
243 }))
244 }
245}
246
247pub fn create_run_threads_thread_id_runs_post_request_builder(
249 configuration: &configuration::Configuration,
250 thread_id: &str,
251 run_create_stateful: models::RunCreateStateful,
252) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
253 let p_path_thread_id = thread_id;
255 let p_body_run_create_stateful = run_create_stateful;
256
257 let uri_str = format!(
258 "{}/threads/{thread_id}/runs",
259 configuration.base_path,
260 thread_id = crate::apis::urlencode(p_path_thread_id)
261 );
262 let mut req_builder = configuration
263 .client
264 .request(reqwest::Method::POST, &uri_str);
265
266 if let Some(ref user_agent) = configuration.user_agent {
267 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
268 }
269 req_builder = req_builder.json(&p_body_run_create_stateful);
270
271 Ok(req_builder)
272}
273
274pub async fn create_run_threads_thread_id_runs_post(
275 configuration: &configuration::Configuration,
276 thread_id: &str,
277 run_create_stateful: models::RunCreateStateful,
278) -> Result<models::Run, Error<CreateRunThreadsThreadIdRunsPostError>> {
279 let req_builder = create_run_threads_thread_id_runs_post_request_builder(
280 configuration,
281 thread_id,
282 run_create_stateful,
283 )
284 .map_err(super::map_request_builder_error)?;
285 let req = req_builder.build()?;
286 let resp = configuration.client.execute(req).await?;
287
288 let status = resp.status();
289 let content_type = resp
290 .headers()
291 .get("content-type")
292 .and_then(|v| v.to_str().ok())
293 .unwrap_or("application/octet-stream");
294 let content_type = super::ContentType::from(content_type);
295
296 if !status.is_client_error() && !status.is_server_error() {
297 let content = resp.text().await?;
298 match content_type {
299 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
300 ContentType::Text => Err(Error::from(serde_json::Error::custom(
301 "Received `text/plain` content type response that cannot be converted to `models::Run`",
302 ))),
303 ContentType::Unsupported(unknown_type) => {
304 Err(Error::from(serde_json::Error::custom(format!(
305 "Received `{unknown_type}` content type response that cannot be converted to `models::Run`"
306 ))))
307 }
308 }
309 } else {
310 let content = resp.text().await?;
311 let entity: Option<CreateRunThreadsThreadIdRunsPostError> =
312 serde_json::from_str(&content).ok();
313 Err(Error::ResponseError(ResponseContent {
314 status,
315 content,
316 entity,
317 }))
318 }
319}
320
321pub fn delete_run_threads_thread_id_runs_run_id_delete_request_builder(
323 configuration: &configuration::Configuration,
324 thread_id: &str,
325 run_id: &str,
326) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
327 let p_path_thread_id = thread_id;
329 let p_path_run_id = run_id;
330
331 let uri_str = format!(
332 "{}/threads/{thread_id}/runs/{run_id}",
333 configuration.base_path,
334 thread_id = crate::apis::urlencode(p_path_thread_id),
335 run_id = crate::apis::urlencode(p_path_run_id)
336 );
337 let mut req_builder = configuration
338 .client
339 .request(reqwest::Method::DELETE, &uri_str);
340
341 if let Some(ref user_agent) = configuration.user_agent {
342 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
343 }
344
345 Ok(req_builder)
346}
347
348pub async fn delete_run_threads_thread_id_runs_run_id_delete(
349 configuration: &configuration::Configuration,
350 thread_id: &str,
351 run_id: &str,
352) -> Result<serde_json::Value, Error<DeleteRunThreadsThreadIdRunsRunIdDeleteError>> {
353 let req_builder = delete_run_threads_thread_id_runs_run_id_delete_request_builder(
354 configuration,
355 thread_id,
356 run_id,
357 )
358 .map_err(super::map_request_builder_error)?;
359 let req = req_builder.build()?;
360 let resp = configuration.client.execute(req).await?;
361
362 let status = resp.status();
363 let content_type = resp
364 .headers()
365 .get("content-type")
366 .and_then(|v| v.to_str().ok())
367 .unwrap_or("application/octet-stream");
368 let content_type = super::ContentType::from(content_type);
369
370 if !status.is_client_error() && !status.is_server_error() {
371 let content = resp.text().await?;
372 match content_type {
373 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
374 ContentType::Text => Err(Error::from(serde_json::Error::custom(
375 "Received `text/plain` content type response that cannot be converted to `serde_json::Value`",
376 ))),
377 ContentType::Unsupported(unknown_type) => {
378 Err(Error::from(serde_json::Error::custom(format!(
379 "Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`"
380 ))))
381 }
382 }
383 } else {
384 let content = resp.text().await?;
385 let entity: Option<DeleteRunThreadsThreadIdRunsRunIdDeleteError> =
386 serde_json::from_str(&content).ok();
387 Err(Error::ResponseError(ResponseContent {
388 status,
389 content,
390 entity,
391 }))
392 }
393}
394
395pub fn get_run_http_threads_thread_id_runs_run_id_get_request_builder(
397 configuration: &configuration::Configuration,
398 thread_id: &str,
399 run_id: &str,
400) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
401 let p_path_thread_id = thread_id;
403 let p_path_run_id = run_id;
404
405 let uri_str = format!(
406 "{}/threads/{thread_id}/runs/{run_id}",
407 configuration.base_path,
408 thread_id = crate::apis::urlencode(p_path_thread_id),
409 run_id = crate::apis::urlencode(p_path_run_id)
410 );
411 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
412
413 if let Some(ref user_agent) = configuration.user_agent {
414 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
415 }
416
417 Ok(req_builder)
418}
419
420pub async fn get_run_http_threads_thread_id_runs_run_id_get(
421 configuration: &configuration::Configuration,
422 thread_id: &str,
423 run_id: &str,
424) -> Result<models::Run, Error<GetRunHttpThreadsThreadIdRunsRunIdGetError>> {
425 let req_builder = get_run_http_threads_thread_id_runs_run_id_get_request_builder(
426 configuration,
427 thread_id,
428 run_id,
429 )
430 .map_err(super::map_request_builder_error)?;
431 let req = req_builder.build()?;
432 let resp = configuration.client.execute(req).await?;
433
434 let status = resp.status();
435 let content_type = resp
436 .headers()
437 .get("content-type")
438 .and_then(|v| v.to_str().ok())
439 .unwrap_or("application/octet-stream");
440 let content_type = super::ContentType::from(content_type);
441
442 if !status.is_client_error() && !status.is_server_error() {
443 let content = resp.text().await?;
444 match content_type {
445 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
446 ContentType::Text => Err(Error::from(serde_json::Error::custom(
447 "Received `text/plain` content type response that cannot be converted to `models::Run`",
448 ))),
449 ContentType::Unsupported(unknown_type) => {
450 Err(Error::from(serde_json::Error::custom(format!(
451 "Received `{unknown_type}` content type response that cannot be converted to `models::Run`"
452 ))))
453 }
454 }
455 } else {
456 let content = resp.text().await?;
457 let entity: Option<GetRunHttpThreadsThreadIdRunsRunIdGetError> =
458 serde_json::from_str(&content).ok();
459 Err(Error::ResponseError(ResponseContent {
460 status,
461 content,
462 entity,
463 }))
464 }
465}
466
467pub fn join_run_http_threads_thread_id_runs_run_id_join_get_request_builder(
469 configuration: &configuration::Configuration,
470 thread_id: &str,
471 run_id: &str,
472 cancel_on_disconnect: Option<bool>,
473) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
474 let p_path_thread_id = thread_id;
476 let p_path_run_id = run_id;
477 let p_query_cancel_on_disconnect = cancel_on_disconnect;
478
479 let uri_str = format!(
480 "{}/threads/{thread_id}/runs/{run_id}/join",
481 configuration.base_path,
482 thread_id = crate::apis::urlencode(p_path_thread_id),
483 run_id = crate::apis::urlencode(p_path_run_id)
484 );
485 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
486
487 if let Some(ref param_value) = p_query_cancel_on_disconnect {
488 req_builder = req_builder.query(&[("cancel_on_disconnect", ¶m_value.to_string())]);
489 }
490 if let Some(ref user_agent) = configuration.user_agent {
491 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
492 }
493
494 Ok(req_builder)
495}
496
497pub async fn join_run_http_threads_thread_id_runs_run_id_join_get(
498 configuration: &configuration::Configuration,
499 thread_id: &str,
500 run_id: &str,
501 cancel_on_disconnect: Option<bool>,
502) -> Result<serde_json::Value, Error<JoinRunHttpThreadsThreadIdRunsRunIdJoinGetError>> {
503 let req_builder = join_run_http_threads_thread_id_runs_run_id_join_get_request_builder(
504 configuration,
505 thread_id,
506 run_id,
507 cancel_on_disconnect,
508 )
509 .map_err(super::map_request_builder_error)?;
510 let req = req_builder.build()?;
511 let resp = configuration.client.execute(req).await?;
512
513 let status = resp.status();
514 let content_type = resp
515 .headers()
516 .get("content-type")
517 .and_then(|v| v.to_str().ok())
518 .unwrap_or("application/octet-stream");
519 let content_type = super::ContentType::from(content_type);
520
521 if !status.is_client_error() && !status.is_server_error() {
522 let content = resp.text().await?;
523 match content_type {
524 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
525 ContentType::Text => Err(Error::from(serde_json::Error::custom(
526 "Received `text/plain` content type response that cannot be converted to `serde_json::Value`",
527 ))),
528 ContentType::Unsupported(unknown_type) => {
529 Err(Error::from(serde_json::Error::custom(format!(
530 "Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`"
531 ))))
532 }
533 }
534 } else {
535 let content = resp.text().await?;
536 let entity: Option<JoinRunHttpThreadsThreadIdRunsRunIdJoinGetError> =
537 serde_json::from_str(&content).ok();
538 Err(Error::ResponseError(ResponseContent {
539 status,
540 content,
541 entity,
542 }))
543 }
544}
545
546pub fn list_runs_http_threads_thread_id_runs_get_request_builder(
548 configuration: &configuration::Configuration,
549 thread_id: &str,
550 limit: Option<i32>,
551 offset: Option<i32>,
552 status: Option<&str>,
553 select: Option<Vec<String>>,
554) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
555 let p_path_thread_id = thread_id;
557 let p_query_limit = limit;
558 let p_query_offset = offset;
559 let p_query_status = status;
560 let p_query_select = select;
561
562 let uri_str = format!(
563 "{}/threads/{thread_id}/runs",
564 configuration.base_path,
565 thread_id = crate::apis::urlencode(p_path_thread_id)
566 );
567 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
568
569 if let Some(ref param_value) = p_query_limit {
570 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
571 }
572 if let Some(ref param_value) = p_query_offset {
573 req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
574 }
575 if let Some(ref param_value) = p_query_status {
576 req_builder = req_builder.query(&[("status", ¶m_value.to_string())]);
577 }
578 if let Some(ref param_value) = p_query_select {
579 req_builder = match "multi" {
580 "multi" => req_builder.query(
581 ¶m_value
582 .iter()
583 .map(|p| ("select".to_owned(), p.to_string()))
584 .collect::<Vec<(std::string::String, std::string::String)>>(),
585 ),
586 _ => req_builder.query(&[(
587 "select",
588 ¶m_value
589 .iter()
590 .map(|p| p.to_string())
591 .collect::<Vec<String>>()
592 .join(",")
593 .to_string(),
594 )]),
595 };
596 }
597 if let Some(ref user_agent) = configuration.user_agent {
598 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
599 }
600
601 Ok(req_builder)
602}
603
604pub async fn list_runs_http_threads_thread_id_runs_get(
605 configuration: &configuration::Configuration,
606 thread_id: &str,
607 limit: Option<i32>,
608 offset: Option<i32>,
609 status: Option<&str>,
610 select: Option<Vec<String>>,
611) -> Result<Vec<models::Run>, Error<ListRunsHttpThreadsThreadIdRunsGetError>> {
612 let req_builder = list_runs_http_threads_thread_id_runs_get_request_builder(
613 configuration,
614 thread_id,
615 limit,
616 offset,
617 status,
618 select,
619 )
620 .map_err(super::map_request_builder_error)?;
621 let req = req_builder.build()?;
622 let resp = configuration.client.execute(req).await?;
623
624 let status = resp.status();
625 let content_type = resp
626 .headers()
627 .get("content-type")
628 .and_then(|v| v.to_str().ok())
629 .unwrap_or("application/octet-stream");
630 let content_type = super::ContentType::from(content_type);
631
632 if !status.is_client_error() && !status.is_server_error() {
633 let content = resp.text().await?;
634 match content_type {
635 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
636 ContentType::Text => Err(Error::from(serde_json::Error::custom(
637 "Received `text/plain` content type response that cannot be converted to `Vec<models::Run>`",
638 ))),
639 ContentType::Unsupported(unknown_type) => {
640 Err(Error::from(serde_json::Error::custom(format!(
641 "Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Run>`"
642 ))))
643 }
644 }
645 } else {
646 let content = resp.text().await?;
647 let entity: Option<ListRunsHttpThreadsThreadIdRunsGetError> =
648 serde_json::from_str(&content).ok();
649 Err(Error::ResponseError(ResponseContent {
650 status,
651 content,
652 entity,
653 }))
654 }
655}
656
657pub fn stream_run_http_threads_thread_id_runs_run_id_join_get_request_builder(
659 configuration: &configuration::Configuration,
660 thread_id: &str,
661 run_id: &str,
662 last_event_id: Option<&str>,
663 stream_mode: Option<&str>,
664 cancel_on_disconnect: Option<bool>,
665) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
666 let p_path_thread_id = thread_id;
668 let p_path_run_id = run_id;
669 let p_header_last_event_id = last_event_id;
670 let p_query_stream_mode = stream_mode;
671 let p_query_cancel_on_disconnect = cancel_on_disconnect;
672
673 let uri_str = format!(
674 "{}/threads/{thread_id}/runs/{run_id}/stream",
675 configuration.base_path,
676 thread_id = crate::apis::urlencode(p_path_thread_id),
677 run_id = crate::apis::urlencode(p_path_run_id)
678 );
679 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
680
681 if let Some(ref param_value) = p_query_stream_mode {
682 req_builder = req_builder.query(&[("stream_mode", ¶m_value.to_string())]);
683 }
684 if let Some(ref param_value) = p_query_cancel_on_disconnect {
685 req_builder = req_builder.query(&[("cancel_on_disconnect", ¶m_value.to_string())]);
686 }
687 if let Some(ref user_agent) = configuration.user_agent {
688 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
689 }
690 if let Some(param_value) = p_header_last_event_id {
691 req_builder = req_builder.header("Last-Event-ID", param_value.to_string());
692 }
693
694 Ok(req_builder)
695}
696
697pub async fn stream_run_http_threads_thread_id_runs_run_id_join_get(
698 configuration: &configuration::Configuration,
699 thread_id: &str,
700 run_id: &str,
701 last_event_id: Option<&str>,
702 stream_mode: Option<&str>,
703 cancel_on_disconnect: Option<bool>,
704) -> Result<String, Error<StreamRunHttpThreadsThreadIdRunsRunIdJoinGetError>> {
705 let req_builder = stream_run_http_threads_thread_id_runs_run_id_join_get_request_builder(
706 configuration,
707 thread_id,
708 run_id,
709 last_event_id,
710 stream_mode,
711 cancel_on_disconnect,
712 )
713 .map_err(super::map_request_builder_error)?;
714 let req = req_builder.build()?;
715 let resp = configuration.client.execute(req).await?;
716
717 let status = resp.status();
718 let content_type = resp
719 .headers()
720 .get("content-type")
721 .and_then(|v| v.to_str().ok())
722 .unwrap_or("application/octet-stream");
723 let content_type = super::ContentType::from(content_type);
724
725 if !status.is_client_error() && !status.is_server_error() {
726 let content = resp.text().await?;
727 match content_type {
728 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
729 ContentType::Text => Err(Error::from(serde_json::Error::custom(
730 "Received `text/plain` content type response that cannot be converted to `String`",
731 ))),
732 ContentType::Unsupported(unknown_type) => {
733 Err(Error::from(serde_json::Error::custom(format!(
734 "Received `{unknown_type}` content type response that cannot be converted to `String`"
735 ))))
736 }
737 }
738 } else {
739 let content = resp.text().await?;
740 let entity: Option<StreamRunHttpThreadsThreadIdRunsRunIdJoinGetError> =
741 serde_json::from_str(&content).ok();
742 Err(Error::ResponseError(ResponseContent {
743 status,
744 content,
745 entity,
746 }))
747 }
748}
749
750pub fn stream_run_threads_thread_id_runs_stream_post_request_builder(
752 configuration: &configuration::Configuration,
753 thread_id: &str,
754 run_create_stateful: models::RunCreateStateful,
755) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
756 let p_path_thread_id = thread_id;
758 let p_body_run_create_stateful = run_create_stateful;
759
760 let uri_str = format!(
761 "{}/threads/{thread_id}/runs/stream",
762 configuration.base_path,
763 thread_id = crate::apis::urlencode(p_path_thread_id)
764 );
765 let mut req_builder = configuration
766 .client
767 .request(reqwest::Method::POST, &uri_str);
768
769 if let Some(ref user_agent) = configuration.user_agent {
770 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
771 }
772 req_builder = req_builder.json(&p_body_run_create_stateful);
773
774 Ok(req_builder)
775}
776
777pub async fn stream_run_threads_thread_id_runs_stream_post(
778 configuration: &configuration::Configuration,
779 thread_id: &str,
780 run_create_stateful: models::RunCreateStateful,
781) -> Result<String, Error<StreamRunThreadsThreadIdRunsStreamPostError>> {
782 let req_builder = stream_run_threads_thread_id_runs_stream_post_request_builder(
783 configuration,
784 thread_id,
785 run_create_stateful,
786 )
787 .map_err(super::map_request_builder_error)?;
788 let req = req_builder.build()?;
789 let resp = configuration.client.execute(req).await?;
790
791 let status = resp.status();
792 let content_type = resp
793 .headers()
794 .get("content-type")
795 .and_then(|v| v.to_str().ok())
796 .unwrap_or("application/octet-stream");
797 let content_type = super::ContentType::from(content_type);
798
799 if !status.is_client_error() && !status.is_server_error() {
800 let content = resp.text().await?;
801 match content_type {
802 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
803 ContentType::Text => Err(Error::from(serde_json::Error::custom(
804 "Received `text/plain` content type response that cannot be converted to `String`",
805 ))),
806 ContentType::Unsupported(unknown_type) => {
807 Err(Error::from(serde_json::Error::custom(format!(
808 "Received `{unknown_type}` content type response that cannot be converted to `String`"
809 ))))
810 }
811 }
812 } else {
813 let content = resp.text().await?;
814 let entity: Option<StreamRunThreadsThreadIdRunsStreamPostError> =
815 serde_json::from_str(&content).ok();
816 Err(Error::ResponseError(ResponseContent {
817 status,
818 content,
819 entity,
820 }))
821 }
822}
823
824pub fn wait_run_threads_thread_id_runs_wait_post_request_builder(
826 configuration: &configuration::Configuration,
827 thread_id: &str,
828 run_create_stateful: models::RunCreateStateful,
829) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
830 let p_path_thread_id = thread_id;
832 let p_body_run_create_stateful = run_create_stateful;
833
834 let uri_str = format!(
835 "{}/threads/{thread_id}/runs/wait",
836 configuration.base_path,
837 thread_id = crate::apis::urlencode(p_path_thread_id)
838 );
839 let mut req_builder = configuration
840 .client
841 .request(reqwest::Method::POST, &uri_str);
842
843 if let Some(ref user_agent) = configuration.user_agent {
844 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
845 }
846 req_builder = req_builder.json(&p_body_run_create_stateful);
847
848 Ok(req_builder)
849}
850
851pub async fn wait_run_threads_thread_id_runs_wait_post(
852 configuration: &configuration::Configuration,
853 thread_id: &str,
854 run_create_stateful: models::RunCreateStateful,
855) -> Result<serde_json::Value, Error<WaitRunThreadsThreadIdRunsWaitPostError>> {
856 let req_builder = wait_run_threads_thread_id_runs_wait_post_request_builder(
857 configuration,
858 thread_id,
859 run_create_stateful,
860 )
861 .map_err(super::map_request_builder_error)?;
862 let req = req_builder.build()?;
863 let resp = configuration.client.execute(req).await?;
864
865 let status = resp.status();
866 let content_type = resp
867 .headers()
868 .get("content-type")
869 .and_then(|v| v.to_str().ok())
870 .unwrap_or("application/octet-stream");
871 let content_type = super::ContentType::from(content_type);
872
873 if !status.is_client_error() && !status.is_server_error() {
874 let content = resp.text().await?;
875 match content_type {
876 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
877 ContentType::Text => Err(Error::from(serde_json::Error::custom(
878 "Received `text/plain` content type response that cannot be converted to `serde_json::Value`",
879 ))),
880 ContentType::Unsupported(unknown_type) => {
881 Err(Error::from(serde_json::Error::custom(format!(
882 "Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`"
883 ))))
884 }
885 }
886 } else {
887 let content = resp.text().await?;
888 let entity: Option<WaitRunThreadsThreadIdRunsWaitPostError> =
889 serde_json::from_str(&content).ok();
890 Err(Error::ResponseError(ResponseContent {
891 status,
892 content,
893 entity,
894 }))
895 }
896}