windmill_api/apis/
oauth_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.508.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 [`connect_callback`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ConnectCallbackError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`connect_client_credentials`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum ConnectClientCredentialsError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`connect_slack_callback`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ConnectSlackCallbackError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`connect_slack_callback_instance`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ConnectSlackCallbackInstanceError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`create_account`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum CreateAccountError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`disconnect_account`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum DisconnectAccountError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`disconnect_slack`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum DisconnectSlackError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`disconnect_teams`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum DisconnectTeamsError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`get_o_auth_connect`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum GetOAuthConnectError {
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`list_o_auth_connects`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum ListOAuthConnectsError {
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`list_o_auth_logins`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum ListOAuthLoginsError {
92    UnknownValue(serde_json::Value),
93}
94
95/// struct for typed errors of method [`refresh_token`]
96#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum RefreshTokenError {
99    UnknownValue(serde_json::Value),
100}
101
102
103pub async fn connect_callback(configuration: &configuration::Configuration, client_name: &str, connect_slack_callback_request: models::ConnectSlackCallbackRequest) -> Result<models::TokenResponse, Error<ConnectCallbackError>> {
104    let local_var_configuration = configuration;
105
106    let local_var_client = &local_var_configuration.client;
107
108    let local_var_uri_str = format!("{}/oauth/connect_callback/{client_name}", local_var_configuration.base_path, client_name=crate::apis::urlencode(client_name));
109    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
110
111    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
112        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
113    }
114    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
115        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
116    };
117    local_var_req_builder = local_var_req_builder.json(&connect_slack_callback_request);
118
119    let local_var_req = local_var_req_builder.build()?;
120    let local_var_resp = local_var_client.execute(local_var_req).await?;
121
122    let local_var_status = local_var_resp.status();
123    let local_var_content = local_var_resp.text().await?;
124
125    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
126        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
127    } else {
128        let local_var_entity: Option<ConnectCallbackError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
129        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
130        Err(Error::ResponseError(local_var_error))
131    }
132}
133
134pub async fn connect_client_credentials(configuration: &configuration::Configuration, client: &str, connect_client_credentials_request: models::ConnectClientCredentialsRequest) -> Result<models::TokenResponse, Error<ConnectClientCredentialsError>> {
135    let local_var_configuration = configuration;
136
137    let local_var_client = &local_var_configuration.client;
138
139    let local_var_uri_str = format!("{}/oauth/connect_client_credentials/{client}", local_var_configuration.base_path, client=crate::apis::urlencode(client));
140    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
141
142    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
143        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
144    }
145    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
146        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
147    };
148    local_var_req_builder = local_var_req_builder.json(&connect_client_credentials_request);
149
150    let local_var_req = local_var_req_builder.build()?;
151    let local_var_resp = local_var_client.execute(local_var_req).await?;
152
153    let local_var_status = local_var_resp.status();
154    let local_var_content = local_var_resp.text().await?;
155
156    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
157        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
158    } else {
159        let local_var_entity: Option<ConnectClientCredentialsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
160        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
161        Err(Error::ResponseError(local_var_error))
162    }
163}
164
165pub async fn connect_slack_callback(configuration: &configuration::Configuration, workspace: &str, connect_slack_callback_request: models::ConnectSlackCallbackRequest) -> Result<String, Error<ConnectSlackCallbackError>> {
166    let local_var_configuration = configuration;
167
168    let local_var_client = &local_var_configuration.client;
169
170    let local_var_uri_str = format!("{}/w/{workspace}/oauth/connect_slack_callback", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
171    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
172
173    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
174        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
175    }
176    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
177        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
178    };
179    local_var_req_builder = local_var_req_builder.json(&connect_slack_callback_request);
180
181    let local_var_req = local_var_req_builder.build()?;
182    let local_var_resp = local_var_client.execute(local_var_req).await?;
183
184    let local_var_status = local_var_resp.status();
185    let local_var_content = local_var_resp.text().await?;
186
187    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
188        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
189    } else {
190        let local_var_entity: Option<ConnectSlackCallbackError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
191        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
192        Err(Error::ResponseError(local_var_error))
193    }
194}
195
196pub async fn connect_slack_callback_instance(configuration: &configuration::Configuration, connect_slack_callback_request: models::ConnectSlackCallbackRequest) -> Result<String, Error<ConnectSlackCallbackInstanceError>> {
197    let local_var_configuration = configuration;
198
199    let local_var_client = &local_var_configuration.client;
200
201    let local_var_uri_str = format!("{}/oauth/connect_slack_callback", local_var_configuration.base_path);
202    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
203
204    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
205        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
206    }
207    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
208        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
209    };
210    local_var_req_builder = local_var_req_builder.json(&connect_slack_callback_request);
211
212    let local_var_req = local_var_req_builder.build()?;
213    let local_var_resp = local_var_client.execute(local_var_req).await?;
214
215    let local_var_status = local_var_resp.status();
216    let local_var_content = local_var_resp.text().await?;
217
218    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
219        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
220    } else {
221        let local_var_entity: Option<ConnectSlackCallbackInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
222        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
223        Err(Error::ResponseError(local_var_error))
224    }
225}
226
227pub async fn create_account(configuration: &configuration::Configuration, workspace: &str, create_account_request: models::CreateAccountRequest) -> Result<String, Error<CreateAccountError>> {
228    let local_var_configuration = configuration;
229
230    let local_var_client = &local_var_configuration.client;
231
232    let local_var_uri_str = format!("{}/w/{workspace}/oauth/create_account", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
233    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
234
235    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
236        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
237    }
238    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
239        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
240    };
241    local_var_req_builder = local_var_req_builder.json(&create_account_request);
242
243    let local_var_req = local_var_req_builder.build()?;
244    let local_var_resp = local_var_client.execute(local_var_req).await?;
245
246    let local_var_status = local_var_resp.status();
247    let local_var_content = local_var_resp.text().await?;
248
249    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
250        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
251    } else {
252        let local_var_entity: Option<CreateAccountError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
253        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
254        Err(Error::ResponseError(local_var_error))
255    }
256}
257
258pub async fn disconnect_account(configuration: &configuration::Configuration, workspace: &str, id: i32) -> Result<String, Error<DisconnectAccountError>> {
259    let local_var_configuration = configuration;
260
261    let local_var_client = &local_var_configuration.client;
262
263    let local_var_uri_str = format!("{}/w/{workspace}/oauth/disconnect/{id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=id);
264    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
265
266    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
267        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
268    }
269    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
270        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
271    };
272
273    let local_var_req = local_var_req_builder.build()?;
274    let local_var_resp = local_var_client.execute(local_var_req).await?;
275
276    let local_var_status = local_var_resp.status();
277    let local_var_content = local_var_resp.text().await?;
278
279    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
280        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
281    } else {
282        let local_var_entity: Option<DisconnectAccountError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
283        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
284        Err(Error::ResponseError(local_var_error))
285    }
286}
287
288pub async fn disconnect_slack(configuration: &configuration::Configuration, workspace: &str) -> Result<String, Error<DisconnectSlackError>> {
289    let local_var_configuration = configuration;
290
291    let local_var_client = &local_var_configuration.client;
292
293    let local_var_uri_str = format!("{}/w/{workspace}/oauth/disconnect_slack", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
294    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
295
296    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
297        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
298    }
299    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
300        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
301    };
302
303    let local_var_req = local_var_req_builder.build()?;
304    let local_var_resp = local_var_client.execute(local_var_req).await?;
305
306    let local_var_status = local_var_resp.status();
307    let local_var_content = local_var_resp.text().await?;
308
309    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
310        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
311    } else {
312        let local_var_entity: Option<DisconnectSlackError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
313        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
314        Err(Error::ResponseError(local_var_error))
315    }
316}
317
318pub async fn disconnect_teams(configuration: &configuration::Configuration, workspace: &str) -> Result<String, Error<DisconnectTeamsError>> {
319    let local_var_configuration = configuration;
320
321    let local_var_client = &local_var_configuration.client;
322
323    let local_var_uri_str = format!("{}/w/{workspace}/oauth/disconnect_teams", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
324    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
325
326    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
327        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
328    }
329    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
330        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
331    };
332
333    let local_var_req = local_var_req_builder.build()?;
334    let local_var_resp = local_var_client.execute(local_var_req).await?;
335
336    let local_var_status = local_var_resp.status();
337    let local_var_content = local_var_resp.text().await?;
338
339    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
340        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
341    } else {
342        let local_var_entity: Option<DisconnectTeamsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
343        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
344        Err(Error::ResponseError(local_var_error))
345    }
346}
347
348pub async fn get_o_auth_connect(configuration: &configuration::Configuration, client: &str) -> Result<models::GetOAuthConnect200Response, Error<GetOAuthConnectError>> {
349    let local_var_configuration = configuration;
350
351    let local_var_client = &local_var_configuration.client;
352
353    let local_var_uri_str = format!("{}/oauth/get_connect/{client}", local_var_configuration.base_path, client=crate::apis::urlencode(client));
354    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
355
356    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
357        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
358    }
359    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
360        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
361    };
362
363    let local_var_req = local_var_req_builder.build()?;
364    let local_var_resp = local_var_client.execute(local_var_req).await?;
365
366    let local_var_status = local_var_resp.status();
367    let local_var_content = local_var_resp.text().await?;
368
369    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
370        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
371    } else {
372        let local_var_entity: Option<GetOAuthConnectError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
373        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
374        Err(Error::ResponseError(local_var_error))
375    }
376}
377
378pub async fn list_o_auth_connects(configuration: &configuration::Configuration, ) -> Result<Vec<String>, Error<ListOAuthConnectsError>> {
379    let local_var_configuration = configuration;
380
381    let local_var_client = &local_var_configuration.client;
382
383    let local_var_uri_str = format!("{}/oauth/list_connects", local_var_configuration.base_path);
384    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
385
386    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
387        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
388    }
389    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
390        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
391    };
392
393    let local_var_req = local_var_req_builder.build()?;
394    let local_var_resp = local_var_client.execute(local_var_req).await?;
395
396    let local_var_status = local_var_resp.status();
397    let local_var_content = local_var_resp.text().await?;
398
399    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
400        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
401    } else {
402        let local_var_entity: Option<ListOAuthConnectsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
403        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
404        Err(Error::ResponseError(local_var_error))
405    }
406}
407
408pub async fn list_o_auth_logins(configuration: &configuration::Configuration, ) -> Result<models::ListOAuthLogins200Response, Error<ListOAuthLoginsError>> {
409    let local_var_configuration = configuration;
410
411    let local_var_client = &local_var_configuration.client;
412
413    let local_var_uri_str = format!("{}/oauth/list_logins", local_var_configuration.base_path);
414    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
415
416    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
417        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
418    }
419    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
420        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
421    };
422
423    let local_var_req = local_var_req_builder.build()?;
424    let local_var_resp = local_var_client.execute(local_var_req).await?;
425
426    let local_var_status = local_var_resp.status();
427    let local_var_content = local_var_resp.text().await?;
428
429    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
430        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
431    } else {
432        let local_var_entity: Option<ListOAuthLoginsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
433        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
434        Err(Error::ResponseError(local_var_error))
435    }
436}
437
438pub async fn refresh_token(configuration: &configuration::Configuration, workspace: &str, id: i32, refresh_token_request: models::RefreshTokenRequest) -> Result<String, Error<RefreshTokenError>> {
439    let local_var_configuration = configuration;
440
441    let local_var_client = &local_var_configuration.client;
442
443    let local_var_uri_str = format!("{}/w/{workspace}/oauth/refresh_token/{id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=id);
444    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
445
446    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
447        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
448    }
449    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
450        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
451    };
452    local_var_req_builder = local_var_req_builder.json(&refresh_token_request);
453
454    let local_var_req = local_var_req_builder.build()?;
455    let local_var_resp = local_var_client.execute(local_var_req).await?;
456
457    let local_var_status = local_var_resp.status();
458    let local_var_content = local_var_resp.text().await?;
459
460    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
461        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
462    } else {
463        let local_var_entity: Option<RefreshTokenError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
464        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
465        Err(Error::ResponseError(local_var_error))
466    }
467}
468