windmill_api/apis/
flow_conversation_api.rs

1/*
2 * Windmill API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 1.555.0
7 * Contact: contact@windmill.dev
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`delete_flow_conversation`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteFlowConversationError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`list_conversation_messages`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum ListConversationMessagesError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`list_flow_conversations`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ListFlowConversationsError {
36    UnknownValue(serde_json::Value),
37}
38
39
40pub async fn delete_flow_conversation(configuration: &configuration::Configuration, workspace: &str, conversation_id: &str) -> Result<String, Error<DeleteFlowConversationError>> {
41    let local_var_configuration = configuration;
42
43    let local_var_client = &local_var_configuration.client;
44
45    let local_var_uri_str = format!("{}/w/{workspace}/flow_conversations/delete/{conversation_id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), conversation_id=crate::apis::urlencode(conversation_id));
46    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
47
48    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
49        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
50    }
51    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
52        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
53    };
54
55    let local_var_req = local_var_req_builder.build()?;
56    let local_var_resp = local_var_client.execute(local_var_req).await?;
57
58    let local_var_status = local_var_resp.status();
59    let local_var_content = local_var_resp.text().await?;
60
61    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
62        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
63    } else {
64        let local_var_entity: Option<DeleteFlowConversationError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
65        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
66        Err(Error::ResponseError(local_var_error))
67    }
68}
69
70pub async fn list_conversation_messages(configuration: &configuration::Configuration, workspace: &str, conversation_id: &str, page: Option<i32>, per_page: Option<i32>) -> Result<Vec<models::FlowConversationMessage>, Error<ListConversationMessagesError>> {
71    let local_var_configuration = configuration;
72
73    let local_var_client = &local_var_configuration.client;
74
75    let local_var_uri_str = format!("{}/w/{workspace}/flow_conversations/{conversation_id}/messages", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), conversation_id=crate::apis::urlencode(conversation_id));
76    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
77
78    if let Some(ref local_var_str) = page {
79        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
80    }
81    if let Some(ref local_var_str) = per_page {
82        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
83    }
84    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
85        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
86    }
87    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
88        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
89    };
90
91    let local_var_req = local_var_req_builder.build()?;
92    let local_var_resp = local_var_client.execute(local_var_req).await?;
93
94    let local_var_status = local_var_resp.status();
95    let local_var_content = local_var_resp.text().await?;
96
97    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
98        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
99    } else {
100        let local_var_entity: Option<ListConversationMessagesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
101        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
102        Err(Error::ResponseError(local_var_error))
103    }
104}
105
106pub async fn list_flow_conversations(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>, flow_path: Option<&str>) -> Result<Vec<models::FlowConversation>, Error<ListFlowConversationsError>> {
107    let local_var_configuration = configuration;
108
109    let local_var_client = &local_var_configuration.client;
110
111    let local_var_uri_str = format!("{}/w/{workspace}/flow_conversations/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
112    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
113
114    if let Some(ref local_var_str) = page {
115        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
116    }
117    if let Some(ref local_var_str) = per_page {
118        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
119    }
120    if let Some(ref local_var_str) = flow_path {
121        local_var_req_builder = local_var_req_builder.query(&[("flow_path", &local_var_str.to_string())]);
122    }
123    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
124        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
125    }
126    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
127        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
128    };
129
130    let local_var_req = local_var_req_builder.build()?;
131    let local_var_resp = local_var_client.execute(local_var_req).await?;
132
133    let local_var_status = local_var_resp.status();
134    let local_var_content = local_var_resp.text().await?;
135
136    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
137        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
138    } else {
139        let local_var_entity: Option<ListFlowConversationsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
140        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
141        Err(Error::ResponseError(local_var_error))
142    }
143}
144