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.557.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>, after_id: Option<&str>) -> 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_str) = after_id {
85        local_var_req_builder = local_var_req_builder.query(&[("after_id", &local_var_str.to_string())]);
86    }
87    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
88        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
89    }
90    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
91        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
92    };
93
94    let local_var_req = local_var_req_builder.build()?;
95    let local_var_resp = local_var_client.execute(local_var_req).await?;
96
97    let local_var_status = local_var_resp.status();
98    let local_var_content = local_var_resp.text().await?;
99
100    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
101        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
102    } else {
103        let local_var_entity: Option<ListConversationMessagesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
104        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
105        Err(Error::ResponseError(local_var_error))
106    }
107}
108
109pub 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>> {
110    let local_var_configuration = configuration;
111
112    let local_var_client = &local_var_configuration.client;
113
114    let local_var_uri_str = format!("{}/w/{workspace}/flow_conversations/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
115    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
116
117    if let Some(ref local_var_str) = page {
118        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
119    }
120    if let Some(ref local_var_str) = per_page {
121        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
122    }
123    if let Some(ref local_var_str) = flow_path {
124        local_var_req_builder = local_var_req_builder.query(&[("flow_path", &local_var_str.to_string())]);
125    }
126    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
127        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
128    }
129    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
130        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
131    };
132
133    let local_var_req = local_var_req_builder.build()?;
134    let local_var_resp = local_var_client.execute(local_var_req).await?;
135
136    let local_var_status = local_var_resp.status();
137    let local_var_content = local_var_resp.text().await?;
138
139    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
140        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
141    } else {
142        let local_var_entity: Option<ListFlowConversationsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
143        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
144        Err(Error::ResponseError(local_var_error))
145    }
146}
147