windmill_api/apis/
data_metric_api.rs1use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ListDataMetricsError {
22 UnknownValue(serde_json::Value),
23}
24
25
26pub async fn list_data_metrics(configuration: &configuration::Configuration, workspace: &str, table: Option<&str>, path_prefix: Option<&str>, per_page: Option<i32>, cursor_table: Option<&str>, cursor_kind: Option<&str>, cursor_name: Option<&str>, cursor_script: Option<&str>) -> Result<models::ListDataMetrics200Response, Error<ListDataMetricsError>> {
28 let local_var_configuration = configuration;
29
30 let local_var_client = &local_var_configuration.client;
31
32 let local_var_uri_str = format!("{}/w/{workspace}/data_metrics/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
33 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
34
35 if let Some(ref local_var_str) = table {
36 local_var_req_builder = local_var_req_builder.query(&[("table", &local_var_str.to_string())]);
37 }
38 if let Some(ref local_var_str) = path_prefix {
39 local_var_req_builder = local_var_req_builder.query(&[("path_prefix", &local_var_str.to_string())]);
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_table {
45 local_var_req_builder = local_var_req_builder.query(&[("cursor_table", &local_var_str.to_string())]);
46 }
47 if let Some(ref local_var_str) = cursor_kind {
48 local_var_req_builder = local_var_req_builder.query(&[("cursor_kind", &local_var_str.to_string())]);
49 }
50 if let Some(ref local_var_str) = cursor_name {
51 local_var_req_builder = local_var_req_builder.query(&[("cursor_name", &local_var_str.to_string())]);
52 }
53 if let Some(ref local_var_str) = cursor_script {
54 local_var_req_builder = local_var_req_builder.query(&[("cursor_script", &local_var_str.to_string())]);
55 }
56 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
57 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
58 }
59 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
60 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
61 };
62
63 let local_var_req = local_var_req_builder.build()?;
64 let local_var_resp = local_var_client.execute(local_var_req).await?;
65
66 let local_var_status = local_var_resp.status();
67 let local_var_content = local_var_resp.text().await?;
68
69 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
70 crate::from_str_patched(&local_var_content).map_err(Error::from)
71 } else {
72 let local_var_entity: Option<ListDataMetricsError> = crate::from_str_patched(&local_var_content).ok();
73 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
74 Err(Error::ResponseError(local_var_error))
75 }
76}
77