argo_workflows_rs/apis/
event_service_api.rs

1/*
2 * Argo Workflows API
3 *
4 * Argo Workflows is an open source container-native workflow engine for orchestrating parallel jobs on Kubernetes. For more information, please see https://argoproj.github.io/argo-workflows/
5 *
6 * The version of the OpenAPI document: VERSION
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`event_service_list_workflow_event_bindings`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum EventServiceListWorkflowEventBindingsError {
22    DefaultResponse(crate::models::GrpcPeriodGatewayPeriodRuntimePeriodError),
23    UnknownValue(serde_json::Value),
24}
25
26/// struct for typed errors of method [`event_service_receive_event`]
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum EventServiceReceiveEventError {
30    DefaultResponse(crate::models::GrpcPeriodGatewayPeriodRuntimePeriodError),
31    UnknownValue(serde_json::Value),
32}
33
34
35pub async fn event_service_list_workflow_event_bindings(configuration: &configuration::Configuration, namespace: &str, list_options_period_label_selector: Option<&str>, list_options_period_field_selector: Option<&str>, list_options_period_watch: Option<bool>, list_options_period_allow_watch_bookmarks: Option<bool>, list_options_period_resource_version: Option<&str>, list_options_period_resource_version_match: Option<&str>, list_options_period_timeout_seconds: Option<&str>, list_options_period_limit: Option<&str>, list_options_period_continue: Option<&str>) -> Result<crate::models::IoPeriodArgoprojPeriodWorkflowPeriodV1alpha1PeriodWorkflowEventBindingList, Error<EventServiceListWorkflowEventBindingsError>> {
36    let local_var_configuration = configuration;
37
38    let local_var_client = &local_var_configuration.client;
39
40    let local_var_uri_str = format!("{}/api/v1/workflow-event-bindings/{namespace}", local_var_configuration.base_path, namespace=crate::apis::urlencode(namespace));
41    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
42
43    if let Some(ref local_var_str) = list_options_period_label_selector {
44        local_var_req_builder = local_var_req_builder.query(&[("listOptions.labelSelector", &local_var_str.to_string())]);
45    }
46    if let Some(ref local_var_str) = list_options_period_field_selector {
47        local_var_req_builder = local_var_req_builder.query(&[("listOptions.fieldSelector", &local_var_str.to_string())]);
48    }
49    if let Some(ref local_var_str) = list_options_period_watch {
50        local_var_req_builder = local_var_req_builder.query(&[("listOptions.watch", &local_var_str.to_string())]);
51    }
52    if let Some(ref local_var_str) = list_options_period_allow_watch_bookmarks {
53        local_var_req_builder = local_var_req_builder.query(&[("listOptions.allowWatchBookmarks", &local_var_str.to_string())]);
54    }
55    if let Some(ref local_var_str) = list_options_period_resource_version {
56        local_var_req_builder = local_var_req_builder.query(&[("listOptions.resourceVersion", &local_var_str.to_string())]);
57    }
58    if let Some(ref local_var_str) = list_options_period_resource_version_match {
59        local_var_req_builder = local_var_req_builder.query(&[("listOptions.resourceVersionMatch", &local_var_str.to_string())]);
60    }
61    if let Some(ref local_var_str) = list_options_period_timeout_seconds {
62        local_var_req_builder = local_var_req_builder.query(&[("listOptions.timeoutSeconds", &local_var_str.to_string())]);
63    }
64    if let Some(ref local_var_str) = list_options_period_limit {
65        local_var_req_builder = local_var_req_builder.query(&[("listOptions.limit", &local_var_str.to_string())]);
66    }
67    if let Some(ref local_var_str) = list_options_period_continue {
68        local_var_req_builder = local_var_req_builder.query(&[("listOptions.continue", &local_var_str.to_string())]);
69    }
70    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
71        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
72    }
73    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
74        let local_var_key = local_var_apikey.key.clone();
75        let local_var_value = match local_var_apikey.prefix {
76            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
77            None => local_var_key,
78        };
79        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
80    };
81
82    let local_var_req = local_var_req_builder.build()?;
83    let local_var_resp = local_var_client.execute(local_var_req).await?;
84
85    let local_var_status = local_var_resp.status();
86    let local_var_content = local_var_resp.text().await?;
87
88    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
89        serde_json::from_str(&local_var_content).map_err(Error::from)
90    } else {
91        let local_var_entity: Option<EventServiceListWorkflowEventBindingsError> = serde_json::from_str(&local_var_content).ok();
92        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
93        Err(Error::ResponseError(local_var_error))
94    }
95}
96
97pub async fn event_service_receive_event(configuration: &configuration::Configuration, namespace: &str, discriminator: &str, body: serde_json::Value) -> Result<serde_json::Value, Error<EventServiceReceiveEventError>> {
98    let local_var_configuration = configuration;
99
100    let local_var_client = &local_var_configuration.client;
101
102    let local_var_uri_str = format!("{}/api/v1/events/{namespace}/{discriminator}", local_var_configuration.base_path, namespace=crate::apis::urlencode(namespace), discriminator=crate::apis::urlencode(discriminator));
103    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
104
105    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
106        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
107    }
108    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
109        let local_var_key = local_var_apikey.key.clone();
110        let local_var_value = match local_var_apikey.prefix {
111            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
112            None => local_var_key,
113        };
114        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
115    };
116    local_var_req_builder = local_var_req_builder.json(&body);
117
118    let local_var_req = local_var_req_builder.build()?;
119    let local_var_resp = local_var_client.execute(local_var_req).await?;
120
121    let local_var_status = local_var_resp.status();
122    let local_var_content = local_var_resp.text().await?;
123
124    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
125        serde_json::from_str(&local_var_content).map_err(Error::from)
126    } else {
127        let local_var_entity: Option<EventServiceReceiveEventError> = serde_json::from_str(&local_var_content).ok();
128        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
129        Err(Error::ResponseError(local_var_error))
130    }
131}
132