Skip to main content

orvanta_api/apis/
flow_conversations_api.rs

1/*
2 * Orvanta API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 6.5.0
7 * Contact: contact@orvanta.cloud
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/// struct for typed errors of method [`reassign_agent_memory_key_owner`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ReassignAgentMemoryKeyOwnerError {
43    UnknownValue(serde_json::Value),
44}
45
46
47pub async fn delete_flow_conversation(configuration: &configuration::Configuration, workspace: &str, conversation_id: &str) -> Result<String, Error<DeleteFlowConversationError>> {
48    let local_var_configuration = configuration;
49
50    let local_var_client = &local_var_configuration.client;
51
52    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));
53    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
54
55    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
56        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
57    }
58    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
59        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
60    };
61
62    let local_var_req = local_var_req_builder.build()?;
63    let local_var_resp = local_var_client.execute(local_var_req).await?;
64
65    let local_var_status = local_var_resp.status();
66    let local_var_content = local_var_resp.text().await?;
67
68    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
69        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
70    } else {
71        let local_var_entity: Option<DeleteFlowConversationError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
72        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
73        Err(Error::ResponseError(local_var_error))
74    }
75}
76
77pub async fn list_conversation_messages(configuration: &configuration::Configuration, workspace: &str, conversation_id: &str, page: Option<i32>, per_page: Option<i32>, after_seq: Option<i64>) -> Result<Vec<models::FlowConversationMessage>, Error<ListConversationMessagesError>> {
78    let local_var_configuration = configuration;
79
80    let local_var_client = &local_var_configuration.client;
81
82    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));
83    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
84
85    if let Some(ref local_var_str) = page {
86        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
87    }
88    if let Some(ref local_var_str) = per_page {
89        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
90    }
91    if let Some(ref local_var_str) = after_seq {
92        local_var_req_builder = local_var_req_builder.query(&[("after_seq", &local_var_str.to_string())]);
93    }
94    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
95        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
96    }
97    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
98        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
99    };
100
101    let local_var_req = local_var_req_builder.build()?;
102    let local_var_resp = local_var_client.execute(local_var_req).await?;
103
104    let local_var_status = local_var_resp.status();
105    let local_var_content = local_var_resp.text().await?;
106
107    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
108        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
109    } else {
110        let local_var_entity: Option<ListConversationMessagesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
111        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
112        Err(Error::ResponseError(local_var_error))
113    }
114}
115
116pub 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>> {
117    let local_var_configuration = configuration;
118
119    let local_var_client = &local_var_configuration.client;
120
121    let local_var_uri_str = format!("{}/w/{workspace}/flow_conversations/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
122    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
123
124    if let Some(ref local_var_str) = page {
125        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
126    }
127    if let Some(ref local_var_str) = per_page {
128        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
129    }
130    if let Some(ref local_var_str) = flow_path {
131        local_var_req_builder = local_var_req_builder.query(&[("flow_path", &local_var_str.to_string())]);
132    }
133    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
134        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
135    }
136    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
137        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
138    };
139
140    let local_var_req = local_var_req_builder.build()?;
141    let local_var_resp = local_var_client.execute(local_var_req).await?;
142
143    let local_var_status = local_var_resp.status();
144    let local_var_content = local_var_resp.text().await?;
145
146    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
147        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
148    } else {
149        let local_var_entity: Option<ListFlowConversationsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
150        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
151        Err(Error::ResponseError(local_var_error))
152    }
153}
154
155/// Sets the owner of an existing agent-memory key (one that names no chat conversation) to a user of the workspace. Used to hand over an admin-only key, or to take a key from whoever claimed it first. 404 if the key has never been claimed or the user is not in the workspace. 
156pub async fn reassign_agent_memory_key_owner(configuration: &configuration::Configuration, workspace: &str, memory_id: &str, reassign_agent_memory_key_owner_request: models::ReassignAgentMemoryKeyOwnerRequest) -> Result<String, Error<ReassignAgentMemoryKeyOwnerError>> {
157    let local_var_configuration = configuration;
158
159    let local_var_client = &local_var_configuration.client;
160
161    let local_var_uri_str = format!("{}/w/{workspace}/flow_conversations/memory_keys/{memory_id}/owner", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), memory_id=crate::apis::urlencode(memory_id));
162    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
163
164    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
165        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
166    }
167    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
168        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
169    };
170    local_var_req_builder = local_var_req_builder.json(&reassign_agent_memory_key_owner_request);
171
172    let local_var_req = local_var_req_builder.build()?;
173    let local_var_resp = local_var_client.execute(local_var_req).await?;
174
175    let local_var_status = local_var_resp.status();
176    let local_var_content = local_var_resp.text().await?;
177
178    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
179        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
180    } else {
181        let local_var_entity: Option<ReassignAgentMemoryKeyOwnerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
182        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
183        Err(Error::ResponseError(local_var_error))
184    }
185}
186