windmill_api/apis/
resource_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.561.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 [`create_resource`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateResourceError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`create_resource_type`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum CreateResourceTypeError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`delete_resource`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum DeleteResourceError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`delete_resource_type`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum DeleteResourceTypeError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`delete_resources_bulk`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum DeleteResourcesBulkError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`exists_resource`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum ExistsResourceError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`exists_resource_type`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ExistsResourceTypeError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`file_resource_type_to_file_ext_map`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum FileResourceTypeToFileExtMapError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`get_git_commit_hash`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum GetGitCommitHashError {
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`get_resource`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum GetResourceError {
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`get_resource_type`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum GetResourceTypeError {
92    UnknownValue(serde_json::Value),
93}
94
95/// struct for typed errors of method [`get_resource_value`]
96#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum GetResourceValueError {
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`get_resource_value_interpolated`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum GetResourceValueInterpolatedError {
106    UnknownValue(serde_json::Value),
107}
108
109/// struct for typed errors of method [`list_resource`]
110#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum ListResourceError {
113    UnknownValue(serde_json::Value),
114}
115
116/// struct for typed errors of method [`list_resource_names`]
117#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum ListResourceNamesError {
120    UnknownValue(serde_json::Value),
121}
122
123/// struct for typed errors of method [`list_resource_type`]
124#[derive(Debug, Clone, Serialize, Deserialize)]
125#[serde(untagged)]
126pub enum ListResourceTypeError {
127    UnknownValue(serde_json::Value),
128}
129
130/// struct for typed errors of method [`list_resource_type_names`]
131#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum ListResourceTypeNamesError {
134    UnknownValue(serde_json::Value),
135}
136
137/// struct for typed errors of method [`list_search_resource`]
138#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum ListSearchResourceError {
141    UnknownValue(serde_json::Value),
142}
143
144/// struct for typed errors of method [`query_resource_types`]
145#[derive(Debug, Clone, Serialize, Deserialize)]
146#[serde(untagged)]
147pub enum QueryResourceTypesError {
148    UnknownValue(serde_json::Value),
149}
150
151/// struct for typed errors of method [`update_resource`]
152#[derive(Debug, Clone, Serialize, Deserialize)]
153#[serde(untagged)]
154pub enum UpdateResourceError {
155    UnknownValue(serde_json::Value),
156}
157
158/// struct for typed errors of method [`update_resource_type`]
159#[derive(Debug, Clone, Serialize, Deserialize)]
160#[serde(untagged)]
161pub enum UpdateResourceTypeError {
162    UnknownValue(serde_json::Value),
163}
164
165/// struct for typed errors of method [`update_resource_value`]
166#[derive(Debug, Clone, Serialize, Deserialize)]
167#[serde(untagged)]
168pub enum UpdateResourceValueError {
169    UnknownValue(serde_json::Value),
170}
171
172
173pub async fn create_resource(configuration: &configuration::Configuration, workspace: &str, create_resource: models::CreateResource, update_if_exists: Option<bool>) -> Result<String, Error<CreateResourceError>> {
174    let local_var_configuration = configuration;
175
176    let local_var_client = &local_var_configuration.client;
177
178    let local_var_uri_str = format!("{}/w/{workspace}/resources/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
179    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
180
181    if let Some(ref local_var_str) = update_if_exists {
182        local_var_req_builder = local_var_req_builder.query(&[("update_if_exists", &local_var_str.to_string())]);
183    }
184    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
185        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
186    }
187    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
188        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
189    };
190    local_var_req_builder = local_var_req_builder.json(&create_resource);
191
192    let local_var_req = local_var_req_builder.build()?;
193    let local_var_resp = local_var_client.execute(local_var_req).await?;
194
195    let local_var_status = local_var_resp.status();
196    let local_var_content = local_var_resp.text().await?;
197
198    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
199        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
200    } else {
201        let local_var_entity: Option<CreateResourceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
202        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
203        Err(Error::ResponseError(local_var_error))
204    }
205}
206
207pub async fn create_resource_type(configuration: &configuration::Configuration, workspace: &str, resource_type: models::ResourceType) -> Result<String, Error<CreateResourceTypeError>> {
208    let local_var_configuration = configuration;
209
210    let local_var_client = &local_var_configuration.client;
211
212    let local_var_uri_str = format!("{}/w/{workspace}/resources/type/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
213    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
214
215    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
216        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
217    }
218    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
219        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
220    };
221    local_var_req_builder = local_var_req_builder.json(&resource_type);
222
223    let local_var_req = local_var_req_builder.build()?;
224    let local_var_resp = local_var_client.execute(local_var_req).await?;
225
226    let local_var_status = local_var_resp.status();
227    let local_var_content = local_var_resp.text().await?;
228
229    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
230        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
231    } else {
232        let local_var_entity: Option<CreateResourceTypeError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
233        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
234        Err(Error::ResponseError(local_var_error))
235    }
236}
237
238pub async fn delete_resource(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<String, Error<DeleteResourceError>> {
239    let local_var_configuration = configuration;
240
241    let local_var_client = &local_var_configuration.client;
242
243    let local_var_uri_str = format!("{}/w/{workspace}/resources/delete/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
244    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
245
246    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
247        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
248    }
249    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
250        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
251    };
252
253    let local_var_req = local_var_req_builder.build()?;
254    let local_var_resp = local_var_client.execute(local_var_req).await?;
255
256    let local_var_status = local_var_resp.status();
257    let local_var_content = local_var_resp.text().await?;
258
259    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
260        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
261    } else {
262        let local_var_entity: Option<DeleteResourceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
263        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
264        Err(Error::ResponseError(local_var_error))
265    }
266}
267
268pub async fn delete_resource_type(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<String, Error<DeleteResourceTypeError>> {
269    let local_var_configuration = configuration;
270
271    let local_var_client = &local_var_configuration.client;
272
273    let local_var_uri_str = format!("{}/w/{workspace}/resources/type/delete/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
274    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
275
276    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
277        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
278    }
279    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
280        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
281    };
282
283    let local_var_req = local_var_req_builder.build()?;
284    let local_var_resp = local_var_client.execute(local_var_req).await?;
285
286    let local_var_status = local_var_resp.status();
287    let local_var_content = local_var_resp.text().await?;
288
289    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
290        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
291    } else {
292        let local_var_entity: Option<DeleteResourceTypeError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
293        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
294        Err(Error::ResponseError(local_var_error))
295    }
296}
297
298pub async fn delete_resources_bulk(configuration: &configuration::Configuration, workspace: &str, delete_variables_bulk_request: models::DeleteVariablesBulkRequest) -> Result<Vec<String>, Error<DeleteResourcesBulkError>> {
299    let local_var_configuration = configuration;
300
301    let local_var_client = &local_var_configuration.client;
302
303    let local_var_uri_str = format!("{}/w/{workspace}/resources/delete_bulk", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
304    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
305
306    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
307        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
308    }
309    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
310        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
311    };
312    local_var_req_builder = local_var_req_builder.json(&delete_variables_bulk_request);
313
314    let local_var_req = local_var_req_builder.build()?;
315    let local_var_resp = local_var_client.execute(local_var_req).await?;
316
317    let local_var_status = local_var_resp.status();
318    let local_var_content = local_var_resp.text().await?;
319
320    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
321        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
322    } else {
323        let local_var_entity: Option<DeleteResourcesBulkError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
324        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
325        Err(Error::ResponseError(local_var_error))
326    }
327}
328
329pub async fn exists_resource(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<bool, Error<ExistsResourceError>> {
330    let local_var_configuration = configuration;
331
332    let local_var_client = &local_var_configuration.client;
333
334    let local_var_uri_str = format!("{}/w/{workspace}/resources/exists/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
335    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
336
337    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
338        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
339    }
340    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
341        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
342    };
343
344    let local_var_req = local_var_req_builder.build()?;
345    let local_var_resp = local_var_client.execute(local_var_req).await?;
346
347    let local_var_status = local_var_resp.status();
348    let local_var_content = local_var_resp.text().await?;
349
350    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
351        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
352    } else {
353        let local_var_entity: Option<ExistsResourceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
354        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
355        Err(Error::ResponseError(local_var_error))
356    }
357}
358
359pub async fn exists_resource_type(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<bool, Error<ExistsResourceTypeError>> {
360    let local_var_configuration = configuration;
361
362    let local_var_client = &local_var_configuration.client;
363
364    let local_var_uri_str = format!("{}/w/{workspace}/resources/type/exists/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
365    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
366
367    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
368        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
369    }
370    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
371        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
372    };
373
374    let local_var_req = local_var_req_builder.build()?;
375    let local_var_resp = local_var_client.execute(local_var_req).await?;
376
377    let local_var_status = local_var_resp.status();
378    let local_var_content = local_var_resp.text().await?;
379
380    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
381        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
382    } else {
383        let local_var_entity: Option<ExistsResourceTypeError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
384        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
385        Err(Error::ResponseError(local_var_error))
386    }
387}
388
389pub async fn file_resource_type_to_file_ext_map(configuration: &configuration::Configuration, workspace: &str) -> Result<serde_json::Value, Error<FileResourceTypeToFileExtMapError>> {
390    let local_var_configuration = configuration;
391
392    let local_var_client = &local_var_configuration.client;
393
394    let local_var_uri_str = format!("{}/w/{workspace}/resources/file_resource_type_to_file_ext_map", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
395    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
396
397    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
398        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
399    }
400    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
401        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
402    };
403
404    let local_var_req = local_var_req_builder.build()?;
405    let local_var_resp = local_var_client.execute(local_var_req).await?;
406
407    let local_var_status = local_var_resp.status();
408    let local_var_content = local_var_resp.text().await?;
409
410    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
411        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
412    } else {
413        let local_var_entity: Option<FileResourceTypeToFileExtMapError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
414        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
415        Err(Error::ResponseError(local_var_error))
416    }
417}
418
419pub async fn get_git_commit_hash(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<models::GetGitCommitHash200Response, Error<GetGitCommitHashError>> {
420    let local_var_configuration = configuration;
421
422    let local_var_client = &local_var_configuration.client;
423
424    let local_var_uri_str = format!("{}/w/{workspace}/resources/git_commit_hash/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
425    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
426
427    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
428        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
429    }
430    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
431        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
432    };
433
434    let local_var_req = local_var_req_builder.build()?;
435    let local_var_resp = local_var_client.execute(local_var_req).await?;
436
437    let local_var_status = local_var_resp.status();
438    let local_var_content = local_var_resp.text().await?;
439
440    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
441        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
442    } else {
443        let local_var_entity: Option<GetGitCommitHashError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
444        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
445        Err(Error::ResponseError(local_var_error))
446    }
447}
448
449pub async fn get_resource(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<models::Resource, Error<GetResourceError>> {
450    let local_var_configuration = configuration;
451
452    let local_var_client = &local_var_configuration.client;
453
454    let local_var_uri_str = format!("{}/w/{workspace}/resources/get/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
455    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
456
457    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
458        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
459    }
460    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
461        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
462    };
463
464    let local_var_req = local_var_req_builder.build()?;
465    let local_var_resp = local_var_client.execute(local_var_req).await?;
466
467    let local_var_status = local_var_resp.status();
468    let local_var_content = local_var_resp.text().await?;
469
470    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
471        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
472    } else {
473        let local_var_entity: Option<GetResourceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
474        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
475        Err(Error::ResponseError(local_var_error))
476    }
477}
478
479pub async fn get_resource_type(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<models::ResourceType, Error<GetResourceTypeError>> {
480    let local_var_configuration = configuration;
481
482    let local_var_client = &local_var_configuration.client;
483
484    let local_var_uri_str = format!("{}/w/{workspace}/resources/type/get/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
485    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
486
487    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
488        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
489    }
490    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
491        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
492    };
493
494    let local_var_req = local_var_req_builder.build()?;
495    let local_var_resp = local_var_client.execute(local_var_req).await?;
496
497    let local_var_status = local_var_resp.status();
498    let local_var_content = local_var_resp.text().await?;
499
500    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
501        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
502    } else {
503        let local_var_entity: Option<GetResourceTypeError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
504        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
505        Err(Error::ResponseError(local_var_error))
506    }
507}
508
509pub async fn get_resource_value(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<serde_json::Value, Error<GetResourceValueError>> {
510    let local_var_configuration = configuration;
511
512    let local_var_client = &local_var_configuration.client;
513
514    let local_var_uri_str = format!("{}/w/{workspace}/resources/get_value/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
515    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
516
517    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
518        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
519    }
520    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
521        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
522    };
523
524    let local_var_req = local_var_req_builder.build()?;
525    let local_var_resp = local_var_client.execute(local_var_req).await?;
526
527    let local_var_status = local_var_resp.status();
528    let local_var_content = local_var_resp.text().await?;
529
530    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
531        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
532    } else {
533        let local_var_entity: Option<GetResourceValueError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
534        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
535        Err(Error::ResponseError(local_var_error))
536    }
537}
538
539pub async fn get_resource_value_interpolated(configuration: &configuration::Configuration, workspace: &str, path: &str, job_id: Option<&str>, allow_cache: Option<bool>) -> Result<serde_json::Value, Error<GetResourceValueInterpolatedError>> {
540    let local_var_configuration = configuration;
541
542    let local_var_client = &local_var_configuration.client;
543
544    let local_var_uri_str = format!("{}/w/{workspace}/resources/get_value_interpolated/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
545    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
546
547    if let Some(ref local_var_str) = job_id {
548        local_var_req_builder = local_var_req_builder.query(&[("job_id", &local_var_str.to_string())]);
549    }
550    if let Some(ref local_var_str) = allow_cache {
551        local_var_req_builder = local_var_req_builder.query(&[("allow_cache", &local_var_str.to_string())]);
552    }
553    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
554        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
555    }
556    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
557        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
558    };
559
560    let local_var_req = local_var_req_builder.build()?;
561    let local_var_resp = local_var_client.execute(local_var_req).await?;
562
563    let local_var_status = local_var_resp.status();
564    let local_var_content = local_var_resp.text().await?;
565
566    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
567        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
568    } else {
569        let local_var_entity: Option<GetResourceValueInterpolatedError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
570        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
571        Err(Error::ResponseError(local_var_error))
572    }
573}
574
575pub async fn list_resource(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>, resource_type: Option<&str>, resource_type_exclude: Option<&str>, path_start: Option<&str>) -> Result<Vec<models::ListableResource>, Error<ListResourceError>> {
576    let local_var_configuration = configuration;
577
578    let local_var_client = &local_var_configuration.client;
579
580    let local_var_uri_str = format!("{}/w/{workspace}/resources/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
581    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
582
583    if let Some(ref local_var_str) = page {
584        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
585    }
586    if let Some(ref local_var_str) = per_page {
587        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
588    }
589    if let Some(ref local_var_str) = resource_type {
590        local_var_req_builder = local_var_req_builder.query(&[("resource_type", &local_var_str.to_string())]);
591    }
592    if let Some(ref local_var_str) = resource_type_exclude {
593        local_var_req_builder = local_var_req_builder.query(&[("resource_type_exclude", &local_var_str.to_string())]);
594    }
595    if let Some(ref local_var_str) = path_start {
596        local_var_req_builder = local_var_req_builder.query(&[("path_start", &local_var_str.to_string())]);
597    }
598    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
599        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
600    }
601    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
602        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
603    };
604
605    let local_var_req = local_var_req_builder.build()?;
606    let local_var_resp = local_var_client.execute(local_var_req).await?;
607
608    let local_var_status = local_var_resp.status();
609    let local_var_content = local_var_resp.text().await?;
610
611    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
612        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
613    } else {
614        let local_var_entity: Option<ListResourceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
615        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
616        Err(Error::ResponseError(local_var_error))
617    }
618}
619
620pub async fn list_resource_names(configuration: &configuration::Configuration, workspace: &str, name: &str) -> Result<Vec<models::ListResourceNames200ResponseInner>, Error<ListResourceNamesError>> {
621    let local_var_configuration = configuration;
622
623    let local_var_client = &local_var_configuration.client;
624
625    let local_var_uri_str = format!("{}/w/{workspace}/resources/list_names/{name}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), name=crate::apis::urlencode(name));
626    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
627
628    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
629        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
630    }
631    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
632        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
633    };
634
635    let local_var_req = local_var_req_builder.build()?;
636    let local_var_resp = local_var_client.execute(local_var_req).await?;
637
638    let local_var_status = local_var_resp.status();
639    let local_var_content = local_var_resp.text().await?;
640
641    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
642        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
643    } else {
644        let local_var_entity: Option<ListResourceNamesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
645        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
646        Err(Error::ResponseError(local_var_error))
647    }
648}
649
650pub async fn list_resource_type(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<models::ResourceType>, Error<ListResourceTypeError>> {
651    let local_var_configuration = configuration;
652
653    let local_var_client = &local_var_configuration.client;
654
655    let local_var_uri_str = format!("{}/w/{workspace}/resources/type/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
656    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
657
658    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
659        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
660    }
661    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
662        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
663    };
664
665    let local_var_req = local_var_req_builder.build()?;
666    let local_var_resp = local_var_client.execute(local_var_req).await?;
667
668    let local_var_status = local_var_resp.status();
669    let local_var_content = local_var_resp.text().await?;
670
671    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
672        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
673    } else {
674        let local_var_entity: Option<ListResourceTypeError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
675        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
676        Err(Error::ResponseError(local_var_error))
677    }
678}
679
680pub async fn list_resource_type_names(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<String>, Error<ListResourceTypeNamesError>> {
681    let local_var_configuration = configuration;
682
683    let local_var_client = &local_var_configuration.client;
684
685    let local_var_uri_str = format!("{}/w/{workspace}/resources/type/listnames", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
686    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
687
688    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
689        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
690    }
691    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
692        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
693    };
694
695    let local_var_req = local_var_req_builder.build()?;
696    let local_var_resp = local_var_client.execute(local_var_req).await?;
697
698    let local_var_status = local_var_resp.status();
699    let local_var_content = local_var_resp.text().await?;
700
701    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
702        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
703    } else {
704        let local_var_entity: Option<ListResourceTypeNamesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
705        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
706        Err(Error::ResponseError(local_var_error))
707    }
708}
709
710pub async fn list_search_resource(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<models::ListSearchResource200ResponseInner>, Error<ListSearchResourceError>> {
711    let local_var_configuration = configuration;
712
713    let local_var_client = &local_var_configuration.client;
714
715    let local_var_uri_str = format!("{}/w/{workspace}/resources/list_search", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
716    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
717
718    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
719        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
720    }
721    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
722        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
723    };
724
725    let local_var_req = local_var_req_builder.build()?;
726    let local_var_resp = local_var_client.execute(local_var_req).await?;
727
728    let local_var_status = local_var_resp.status();
729    let local_var_content = local_var_resp.text().await?;
730
731    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
732        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
733    } else {
734        let local_var_entity: Option<ListSearchResourceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
735        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
736        Err(Error::ResponseError(local_var_error))
737    }
738}
739
740pub async fn query_resource_types(configuration: &configuration::Configuration, workspace: &str, text: &str, limit: Option<f64>) -> Result<Vec<models::QueryResourceTypes200ResponseInner>, Error<QueryResourceTypesError>> {
741    let local_var_configuration = configuration;
742
743    let local_var_client = &local_var_configuration.client;
744
745    let local_var_uri_str = format!("{}/w/{workspace}/embeddings/query_resource_types", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
746    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
747
748    local_var_req_builder = local_var_req_builder.query(&[("text", &text.to_string())]);
749    if let Some(ref local_var_str) = limit {
750        local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
751    }
752    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
753        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
754    }
755    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
756        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
757    };
758
759    let local_var_req = local_var_req_builder.build()?;
760    let local_var_resp = local_var_client.execute(local_var_req).await?;
761
762    let local_var_status = local_var_resp.status();
763    let local_var_content = local_var_resp.text().await?;
764
765    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
766        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
767    } else {
768        let local_var_entity: Option<QueryResourceTypesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
769        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
770        Err(Error::ResponseError(local_var_error))
771    }
772}
773
774pub async fn update_resource(configuration: &configuration::Configuration, workspace: &str, path: &str, edit_resource: models::EditResource) -> Result<String, Error<UpdateResourceError>> {
775    let local_var_configuration = configuration;
776
777    let local_var_client = &local_var_configuration.client;
778
779    let local_var_uri_str = format!("{}/w/{workspace}/resources/update/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
780    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
781
782    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
783        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
784    }
785    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
786        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
787    };
788    local_var_req_builder = local_var_req_builder.json(&edit_resource);
789
790    let local_var_req = local_var_req_builder.build()?;
791    let local_var_resp = local_var_client.execute(local_var_req).await?;
792
793    let local_var_status = local_var_resp.status();
794    let local_var_content = local_var_resp.text().await?;
795
796    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
797        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
798    } else {
799        let local_var_entity: Option<UpdateResourceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
800        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
801        Err(Error::ResponseError(local_var_error))
802    }
803}
804
805pub async fn update_resource_type(configuration: &configuration::Configuration, workspace: &str, path: &str, edit_resource_type: models::EditResourceType) -> Result<String, Error<UpdateResourceTypeError>> {
806    let local_var_configuration = configuration;
807
808    let local_var_client = &local_var_configuration.client;
809
810    let local_var_uri_str = format!("{}/w/{workspace}/resources/type/update/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
811    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
812
813    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
814        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
815    }
816    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
817        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
818    };
819    local_var_req_builder = local_var_req_builder.json(&edit_resource_type);
820
821    let local_var_req = local_var_req_builder.build()?;
822    let local_var_resp = local_var_client.execute(local_var_req).await?;
823
824    let local_var_status = local_var_resp.status();
825    let local_var_content = local_var_resp.text().await?;
826
827    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
828        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
829    } else {
830        let local_var_entity: Option<UpdateResourceTypeError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
831        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
832        Err(Error::ResponseError(local_var_error))
833    }
834}
835
836pub async fn update_resource_value(configuration: &configuration::Configuration, workspace: &str, path: &str, set_global_request: models::SetGlobalRequest) -> Result<String, Error<UpdateResourceValueError>> {
837    let local_var_configuration = configuration;
838
839    let local_var_client = &local_var_configuration.client;
840
841    let local_var_uri_str = format!("{}/w/{workspace}/resources/update_value/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
842    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
843
844    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
845        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
846    }
847    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
848        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
849    };
850    local_var_req_builder = local_var_req_builder.json(&set_global_request);
851
852    let local_var_req = local_var_req_builder.build()?;
853    let local_var_resp = local_var_client.execute(local_var_req).await?;
854
855    let local_var_status = local_var_resp.status();
856    let local_var_content = local_var_resp.text().await?;
857
858    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
859        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
860    } else {
861        let local_var_entity: Option<UpdateResourceValueError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
862        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
863        Err(Error::ResponseError(local_var_error))
864    }
865}
866