Skip to main content

windmill_api/apis/
workspace_integration_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.617.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 [`check_if_native_triggers_service_exists`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CheckIfNativeTriggersServiceExistsError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`create_native_trigger_service`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum CreateNativeTriggerServiceError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`delete_native_trigger_service`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum DeleteNativeTriggerServiceError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`generate_native_trigger_service_connect_url`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GenerateNativeTriggerServiceConnectUrlError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`list_native_trigger_services`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ListNativeTriggerServicesError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`native_trigger_service_callback`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum NativeTriggerServiceCallbackError {
57    UnknownValue(serde_json::Value),
58}
59
60
61pub async fn check_if_native_triggers_service_exists(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName) -> Result<bool, Error<CheckIfNativeTriggersServiceExistsError>> {
62    let local_var_configuration = configuration;
63
64    let local_var_client = &local_var_configuration.client;
65
66    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/integrations/{service_name}/exists", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), service_name=service_name.to_string());
67    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
68
69    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
70        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
71    }
72    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
73        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
74    };
75
76    let local_var_req = local_var_req_builder.build()?;
77    let local_var_resp = local_var_client.execute(local_var_req).await?;
78
79    let local_var_status = local_var_resp.status();
80    let local_var_content = local_var_resp.text().await?;
81
82    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
83        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
84    } else {
85        let local_var_entity: Option<CheckIfNativeTriggersServiceExistsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
86        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
87        Err(Error::ResponseError(local_var_error))
88    }
89}
90
91pub async fn create_native_trigger_service(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName, workspace_o_auth_config: models::WorkspaceOAuthConfig) -> Result<String, Error<CreateNativeTriggerServiceError>> {
92    let local_var_configuration = configuration;
93
94    let local_var_client = &local_var_configuration.client;
95
96    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/integrations/{service_name}/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), service_name=service_name.to_string());
97    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
98
99    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
100        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
101    }
102    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
103        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
104    };
105    local_var_req_builder = local_var_req_builder.json(&workspace_o_auth_config);
106
107    let local_var_req = local_var_req_builder.build()?;
108    let local_var_resp = local_var_client.execute(local_var_req).await?;
109
110    let local_var_status = local_var_resp.status();
111    let local_var_content = local_var_resp.text().await?;
112
113    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
114        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
115    } else {
116        let local_var_entity: Option<CreateNativeTriggerServiceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
117        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
118        Err(Error::ResponseError(local_var_error))
119    }
120}
121
122pub async fn delete_native_trigger_service(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName) -> Result<String, Error<DeleteNativeTriggerServiceError>> {
123    let local_var_configuration = configuration;
124
125    let local_var_client = &local_var_configuration.client;
126
127    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/integrations/{service_name}/delete", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), service_name=service_name.to_string());
128    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
129
130    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
131        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
132    }
133    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
134        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
135    };
136
137    let local_var_req = local_var_req_builder.build()?;
138    let local_var_resp = local_var_client.execute(local_var_req).await?;
139
140    let local_var_status = local_var_resp.status();
141    let local_var_content = local_var_resp.text().await?;
142
143    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
144        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
145    } else {
146        let local_var_entity: Option<DeleteNativeTriggerServiceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
147        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
148        Err(Error::ResponseError(local_var_error))
149    }
150}
151
152pub async fn generate_native_trigger_service_connect_url(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName, redirect_uri: models::RedirectUri) -> Result<String, Error<GenerateNativeTriggerServiceConnectUrlError>> {
153    let local_var_configuration = configuration;
154
155    let local_var_client = &local_var_configuration.client;
156
157    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/integrations/{service_name}/generate_connect_url", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), service_name=service_name.to_string());
158    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
159
160    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
161        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
162    }
163    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
164        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
165    };
166    local_var_req_builder = local_var_req_builder.json(&redirect_uri);
167
168    let local_var_req = local_var_req_builder.build()?;
169    let local_var_resp = local_var_client.execute(local_var_req).await?;
170
171    let local_var_status = local_var_resp.status();
172    let local_var_content = local_var_resp.text().await?;
173
174    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
175        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
176    } else {
177        let local_var_entity: Option<GenerateNativeTriggerServiceConnectUrlError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
178        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
179        Err(Error::ResponseError(local_var_error))
180    }
181}
182
183pub async fn list_native_trigger_services(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<models::WorkspaceIntegrations>, Error<ListNativeTriggerServicesError>> {
184    let local_var_configuration = configuration;
185
186    let local_var_client = &local_var_configuration.client;
187
188    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/integrations/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
189    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
190
191    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
192        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
193    }
194    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
195        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
196    };
197
198    let local_var_req = local_var_req_builder.build()?;
199    let local_var_resp = local_var_client.execute(local_var_req).await?;
200
201    let local_var_status = local_var_resp.status();
202    let local_var_content = local_var_resp.text().await?;
203
204    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
205        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
206    } else {
207        let local_var_entity: Option<ListNativeTriggerServicesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
208        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
209        Err(Error::ResponseError(local_var_error))
210    }
211}
212
213pub async fn native_trigger_service_callback(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName, code: &str, state: &str, redirect_uri: models::RedirectUri) -> Result<String, Error<NativeTriggerServiceCallbackError>> {
214    let local_var_configuration = configuration;
215
216    let local_var_client = &local_var_configuration.client;
217
218    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/integrations/{service_name}/callback/{code}/{state}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), service_name=service_name.to_string(), code=crate::apis::urlencode(code), state=crate::apis::urlencode(state));
219    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
220
221    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
222        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
223    }
224    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
225        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
226    };
227    local_var_req_builder = local_var_req_builder.json(&redirect_uri);
228
229    let local_var_req = local_var_req_builder.build()?;
230    let local_var_resp = local_var_client.execute(local_var_req).await?;
231
232    let local_var_status = local_var_resp.status();
233    let local_var_content = local_var_resp.text().await?;
234
235    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
236        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
237    } else {
238        let local_var_entity: Option<NativeTriggerServiceCallbackError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
239        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
240        Err(Error::ResponseError(local_var_error))
241    }
242}
243