windmill_api/apis/
npm_proxy_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.610.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 [`get_npm_package_file`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetNpmPackageFileError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`get_npm_package_filetree`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetNpmPackageFiletreeError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`get_npm_package_metadata`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetNpmPackageMetadataError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`resolve_npm_package_version`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ResolveNpmPackageVersionError {
43    UnknownValue(serde_json::Value),
44}
45
46
47pub async fn get_npm_package_file(configuration: &configuration::Configuration, workspace: &str, package: &str, version: &str, filepath: &str) -> Result<String, Error<GetNpmPackageFileError>> {
48    let local_var_configuration = configuration;
49
50    let local_var_client = &local_var_configuration.client;
51
52    let local_var_uri_str = format!("{}/w/{workspace}/npm_proxy/file/{package}/{version}/{filepath}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), package=crate::apis::urlencode(package), version=crate::apis::urlencode(version), filepath=crate::apis::urlencode(filepath));
53    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
54
55    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
56        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
57    }
58    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
59        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
60    };
61
62    let local_var_req = local_var_req_builder.build()?;
63    let local_var_resp = local_var_client.execute(local_var_req).await?;
64
65    let local_var_status = local_var_resp.status();
66    let local_var_content = local_var_resp.text().await?;
67
68    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
69        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
70    } else {
71        let local_var_entity: Option<GetNpmPackageFileError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
72        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
73        Err(Error::ResponseError(local_var_error))
74    }
75}
76
77pub async fn get_npm_package_filetree(configuration: &configuration::Configuration, workspace: &str, package: &str, version: &str) -> Result<models::GetNpmPackageFiletree200Response, Error<GetNpmPackageFiletreeError>> {
78    let local_var_configuration = configuration;
79
80    let local_var_client = &local_var_configuration.client;
81
82    let local_var_uri_str = format!("{}/w/{workspace}/npm_proxy/filetree/{package}/{version}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), package=crate::apis::urlencode(package), version=crate::apis::urlencode(version));
83    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
84
85    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
86        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
87    }
88    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
89        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
90    };
91
92    let local_var_req = local_var_req_builder.build()?;
93    let local_var_resp = local_var_client.execute(local_var_req).await?;
94
95    let local_var_status = local_var_resp.status();
96    let local_var_content = local_var_resp.text().await?;
97
98    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
99        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
100    } else {
101        let local_var_entity: Option<GetNpmPackageFiletreeError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
102        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
103        Err(Error::ResponseError(local_var_error))
104    }
105}
106
107pub async fn get_npm_package_metadata(configuration: &configuration::Configuration, workspace: &str, package: &str) -> Result<models::GetNpmPackageMetadata200Response, Error<GetNpmPackageMetadataError>> {
108    let local_var_configuration = configuration;
109
110    let local_var_client = &local_var_configuration.client;
111
112    let local_var_uri_str = format!("{}/w/{workspace}/npm_proxy/metadata/{package}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), package=crate::apis::urlencode(package));
113    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
114
115    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
116        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
117    }
118    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
119        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
120    };
121
122    let local_var_req = local_var_req_builder.build()?;
123    let local_var_resp = local_var_client.execute(local_var_req).await?;
124
125    let local_var_status = local_var_resp.status();
126    let local_var_content = local_var_resp.text().await?;
127
128    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
129        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
130    } else {
131        let local_var_entity: Option<GetNpmPackageMetadataError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
132        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
133        Err(Error::ResponseError(local_var_error))
134    }
135}
136
137pub async fn resolve_npm_package_version(configuration: &configuration::Configuration, workspace: &str, package: &str, tag: Option<&str>) -> Result<models::ResolveNpmPackageVersion200Response, Error<ResolveNpmPackageVersionError>> {
138    let local_var_configuration = configuration;
139
140    let local_var_client = &local_var_configuration.client;
141
142    let local_var_uri_str = format!("{}/w/{workspace}/npm_proxy/resolve/{package}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), package=crate::apis::urlencode(package));
143    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
144
145    if let Some(ref local_var_str) = tag {
146        local_var_req_builder = local_var_req_builder.query(&[("tag", &local_var_str.to_string())]);
147    }
148    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
149        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
150    }
151    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
152        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
153    };
154
155    let local_var_req = local_var_req_builder.build()?;
156    let local_var_resp = local_var_client.execute(local_var_req).await?;
157
158    let local_var_status = local_var_resp.status();
159    let local_var_content = local_var_resp.text().await?;
160
161    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
162        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
163    } else {
164        let local_var_entity: Option<ResolveNpmPackageVersionError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
165        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
166        Err(Error::ResponseError(local_var_error))
167    }
168}
169