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