windmill_api/apis/
teams_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.505.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 [`send_message_to_conversation`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum SendMessageToConversationError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`sync_teams`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum SyncTeamsError {
29    UnknownValue(serde_json::Value),
30}
31
32
33/// Respond to a Microsoft Teams activity after a workspace command is run
34pub async fn send_message_to_conversation(configuration: &configuration::Configuration, send_message_to_conversation_request: models::SendMessageToConversationRequest) -> Result<(), Error<SendMessageToConversationError>> {
35    let local_var_configuration = configuration;
36
37    let local_var_client = &local_var_configuration.client;
38
39    let local_var_uri_str = format!("{}/teams/activities", local_var_configuration.base_path);
40    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
41
42    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
43        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
44    }
45    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
46        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
47    };
48    local_var_req_builder = local_var_req_builder.json(&send_message_to_conversation_request);
49
50    let local_var_req = local_var_req_builder.build()?;
51    let local_var_resp = local_var_client.execute(local_var_req).await?;
52
53    let local_var_status = local_var_resp.status();
54    let local_var_content = local_var_resp.text().await?;
55
56    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
57        Ok(())
58    } else {
59        let local_var_entity: Option<SendMessageToConversationError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
60        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
61        Err(Error::ResponseError(local_var_error))
62    }
63}
64
65pub async fn sync_teams(configuration: &configuration::Configuration, ) -> Result<Vec<models::TeamInfo>, Error<SyncTeamsError>> {
66    let local_var_configuration = configuration;
67
68    let local_var_client = &local_var_configuration.client;
69
70    let local_var_uri_str = format!("{}/teams/sync", local_var_configuration.base_path);
71    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
72
73    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
74        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
75    }
76    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
77        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
78    };
79
80    let local_var_req = local_var_req_builder.build()?;
81    let local_var_resp = local_var_client.execute(local_var_req).await?;
82
83    let local_var_status = local_var_resp.status();
84    let local_var_content = local_var_resp.text().await?;
85
86    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
87        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
88    } else {
89        let local_var_entity: Option<SyncTeamsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
90        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
91        Err(Error::ResponseError(local_var_error))
92    }
93}
94