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