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.624.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 [`list_assets`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ListAssetsError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`list_assets_by_usage`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum ListAssetsByUsageError {
29    UnknownValue(serde_json::Value),
30}
31
32
33pub 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>) -> Result<models::ListAssets200Response, Error<ListAssetsError>> {
34    let local_var_configuration = configuration;
35
36    let local_var_client = &local_var_configuration.client;
37
38    let local_var_uri_str = format!("{}/w/{workspace}/assets/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
39    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
40
41    if let Some(ref local_var_str) = per_page {
42        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
43    }
44    if let Some(ref local_var_str) = cursor_created_at {
45        local_var_req_builder = local_var_req_builder.query(&[("cursor_created_at", &local_var_str.to_string())]);
46    }
47    if let Some(ref local_var_str) = cursor_id {
48        local_var_req_builder = local_var_req_builder.query(&[("cursor_id", &local_var_str.to_string())]);
49    }
50    if let Some(ref local_var_str) = asset_path {
51        local_var_req_builder = local_var_req_builder.query(&[("asset_path", &local_var_str.to_string())]);
52    }
53    if let Some(ref local_var_str) = usage_path {
54        local_var_req_builder = local_var_req_builder.query(&[("usage_path", &local_var_str.to_string())]);
55    }
56    if let Some(ref local_var_str) = asset_kinds {
57        local_var_req_builder = local_var_req_builder.query(&[("asset_kinds", &local_var_str.to_string())]);
58    }
59    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
60        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
61    }
62    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
63        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
64    };
65
66    let local_var_req = local_var_req_builder.build()?;
67    let local_var_resp = local_var_client.execute(local_var_req).await?;
68
69    let local_var_status = local_var_resp.status();
70    let local_var_content = local_var_resp.text().await?;
71
72    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
73        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
74    } else {
75        let local_var_entity: Option<ListAssetsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
76        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
77        Err(Error::ResponseError(local_var_error))
78    }
79}
80
81pub 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>> {
82    let local_var_configuration = configuration;
83
84    let local_var_client = &local_var_configuration.client;
85
86    let local_var_uri_str = format!("{}/w/{workspace}/assets/list_by_usages", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
87    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
88
89    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
90        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
91    }
92    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
93        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
94    };
95    local_var_req_builder = local_var_req_builder.json(&list_assets_by_usage_request);
96
97    let local_var_req = local_var_req_builder.build()?;
98    let local_var_resp = local_var_client.execute(local_var_req).await?;
99
100    let local_var_status = local_var_resp.status();
101    let local_var_content = local_var_resp.text().await?;
102
103    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
104        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
105    } else {
106        let local_var_entity: Option<ListAssetsByUsageError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
107        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
108        Err(Error::ResponseError(local_var_error))
109    }
110}
111