Skip to main content

windmill_api/apis/
asset_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.744.0
7 * Contact: contact@windmill.dev
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`get_assets_graph`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetAssetsGraphError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`list_asset_partitions`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum ListAssetPartitionsError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`list_asset_schemas`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ListAssetSchemasError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`list_assets`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ListAssetsError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`list_assets_by_usage`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ListAssetsByUsageError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`list_favorite_assets`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum ListFavoriteAssetsError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`list_pipeline_folders`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ListPipelineFoldersError {
64    UnknownValue(serde_json::Value),
65}
66
67
68pub async fn get_assets_graph(configuration: &configuration::Configuration, workspace: &str, asset_kinds: Option<&str>, folder: Option<&str>) -> Result<models::GetAssetsGraph200Response, Error<GetAssetsGraphError>> {
69    let local_var_configuration = configuration;
70
71    let local_var_client = &local_var_configuration.client;
72
73    let local_var_uri_str = format!("{}/w/{workspace}/assets/graph", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
74    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
75
76    if let Some(ref local_var_str) = asset_kinds {
77        local_var_req_builder = local_var_req_builder.query(&[("asset_kinds", &local_var_str.to_string())]);
78    }
79    if let Some(ref local_var_str) = folder {
80        local_var_req_builder = local_var_req_builder.query(&[("folder", &local_var_str.to_string())]);
81    }
82    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
83        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
84    }
85    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
86        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
87    };
88
89    let local_var_req = local_var_req_builder.build()?;
90    let local_var_resp = local_var_client.execute(local_var_req).await?;
91
92    let local_var_status = local_var_resp.status();
93    let local_var_content = local_var_resp.text().await?;
94
95    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
96        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
97    } else {
98        let local_var_entity: Option<GetAssetsGraphError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
99        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
100        Err(Error::ResponseError(local_var_error))
101    }
102}
103
104pub async fn list_asset_partitions(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<Vec<models::MaterializedPartition>, Error<ListAssetPartitionsError>> {
105    let local_var_configuration = configuration;
106
107    let local_var_client = &local_var_configuration.client;
108
109    let local_var_uri_str = format!("{}/w/{workspace}/assets/partitions", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
110    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
111
112    local_var_req_builder = local_var_req_builder.query(&[("path", &path.to_string())]);
113    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
114        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
115    }
116    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
117        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
118    };
119
120    let local_var_req = local_var_req_builder.build()?;
121    let local_var_resp = local_var_client.execute(local_var_req).await?;
122
123    let local_var_status = local_var_resp.status();
124    let local_var_content = local_var_resp.text().await?;
125
126    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
127        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
128    } else {
129        let local_var_entity: Option<ListAssetPartitionsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
130        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
131        Err(Error::ResponseError(local_var_error))
132    }
133}
134
135pub async fn list_asset_schemas(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<Vec<models::AssetSchemaVersion>, Error<ListAssetSchemasError>> {
136    let local_var_configuration = configuration;
137
138    let local_var_client = &local_var_configuration.client;
139
140    let local_var_uri_str = format!("{}/w/{workspace}/assets/asset_schemas", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
141    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
142
143    local_var_req_builder = local_var_req_builder.query(&[("path", &path.to_string())]);
144    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
145        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
146    }
147    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
148        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
149    };
150
151    let local_var_req = local_var_req_builder.build()?;
152    let local_var_resp = local_var_client.execute(local_var_req).await?;
153
154    let local_var_status = local_var_resp.status();
155    let local_var_content = local_var_resp.text().await?;
156
157    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
158        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
159    } else {
160        let local_var_entity: Option<ListAssetSchemasError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
161        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
162        Err(Error::ResponseError(local_var_error))
163    }
164}
165
166pub async fn list_assets(configuration: &configuration::Configuration, workspace: &str, per_page: Option<i32>, cursor_created_at: Option<String>, cursor_id: Option<i64>, asset_path: Option<&str>, usage_path: Option<&str>, asset_kinds: Option<&str>, path: Option<&str>, columns: Option<&str>, broad_filter: Option<&str>) -> Result<models::ListAssets200Response, Error<ListAssetsError>> {
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}/assets/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
172    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
173
174    if let Some(ref local_var_str) = per_page {
175        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
176    }
177    if let Some(ref local_var_str) = cursor_created_at {
178        local_var_req_builder = local_var_req_builder.query(&[("cursor_created_at", &local_var_str.to_string())]);
179    }
180    if let Some(ref local_var_str) = cursor_id {
181        local_var_req_builder = local_var_req_builder.query(&[("cursor_id", &local_var_str.to_string())]);
182    }
183    if let Some(ref local_var_str) = asset_path {
184        local_var_req_builder = local_var_req_builder.query(&[("asset_path", &local_var_str.to_string())]);
185    }
186    if let Some(ref local_var_str) = usage_path {
187        local_var_req_builder = local_var_req_builder.query(&[("usage_path", &local_var_str.to_string())]);
188    }
189    if let Some(ref local_var_str) = asset_kinds {
190        local_var_req_builder = local_var_req_builder.query(&[("asset_kinds", &local_var_str.to_string())]);
191    }
192    if let Some(ref local_var_str) = path {
193        local_var_req_builder = local_var_req_builder.query(&[("path", &local_var_str.to_string())]);
194    }
195    if let Some(ref local_var_str) = columns {
196        local_var_req_builder = local_var_req_builder.query(&[("columns", &local_var_str.to_string())]);
197    }
198    if let Some(ref local_var_str) = broad_filter {
199        local_var_req_builder = local_var_req_builder.query(&[("broad_filter", &local_var_str.to_string())]);
200    }
201    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
202        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
203    }
204    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
205        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
206    };
207
208    let local_var_req = local_var_req_builder.build()?;
209    let local_var_resp = local_var_client.execute(local_var_req).await?;
210
211    let local_var_status = local_var_resp.status();
212    let local_var_content = local_var_resp.text().await?;
213
214    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
215        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
216    } else {
217        let local_var_entity: Option<ListAssetsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
218        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
219        Err(Error::ResponseError(local_var_error))
220    }
221}
222
223pub async fn list_assets_by_usage(configuration: &configuration::Configuration, workspace: &str, list_assets_by_usage_request: models::ListAssetsByUsageRequest) -> Result<Vec<Vec<models::ListAssetsByUsage200ResponseInnerInner>>, Error<ListAssetsByUsageError>> {
224    let local_var_configuration = configuration;
225
226    let local_var_client = &local_var_configuration.client;
227
228    let local_var_uri_str = format!("{}/w/{workspace}/assets/list_by_usages", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
229    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
230
231    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
232        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
233    }
234    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
235        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
236    };
237    local_var_req_builder = local_var_req_builder.json(&list_assets_by_usage_request);
238
239    let local_var_req = local_var_req_builder.build()?;
240    let local_var_resp = local_var_client.execute(local_var_req).await?;
241
242    let local_var_status = local_var_resp.status();
243    let local_var_content = local_var_resp.text().await?;
244
245    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
246        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
247    } else {
248        let local_var_entity: Option<ListAssetsByUsageError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
249        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
250        Err(Error::ResponseError(local_var_error))
251    }
252}
253
254pub async fn list_favorite_assets(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<models::ListFavoriteAssets200ResponseInner>, Error<ListFavoriteAssetsError>> {
255    let local_var_configuration = configuration;
256
257    let local_var_client = &local_var_configuration.client;
258
259    let local_var_uri_str = format!("{}/w/{workspace}/assets/list_favorites", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
260    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
261
262    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
263        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
264    }
265    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
266        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
267    };
268
269    let local_var_req = local_var_req_builder.build()?;
270    let local_var_resp = local_var_client.execute(local_var_req).await?;
271
272    let local_var_status = local_var_resp.status();
273    let local_var_content = local_var_resp.text().await?;
274
275    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
276        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
277    } else {
278        let local_var_entity: Option<ListFavoriteAssetsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
279        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
280        Err(Error::ResponseError(local_var_error))
281    }
282}
283
284pub async fn list_pipeline_folders(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<models::ListPipelineFolders200ResponseInner>, Error<ListPipelineFoldersError>> {
285    let local_var_configuration = configuration;
286
287    let local_var_client = &local_var_configuration.client;
288
289    let local_var_uri_str = format!("{}/w/{workspace}/assets/pipelines", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
290    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
291
292    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
293        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
294    }
295    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
296        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
297    };
298
299    let local_var_req = local_var_req_builder.build()?;
300    let local_var_resp = local_var_client.execute(local_var_req).await?;
301
302    let local_var_status = local_var_resp.status();
303    let local_var_content = local_var_resp.text().await?;
304
305    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
306        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
307    } else {
308        let local_var_entity: Option<ListPipelineFoldersError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
309        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
310        Err(Error::ResponseError(local_var_error))
311    }
312}
313