1use 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 DeleteConcurrencyGroupError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetConcurrencyKeyError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ListConcurrencyGroupsError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ListExtendedJobsError {
43 UnknownValue(serde_json::Value),
44}
45
46
47pub async fn delete_concurrency_group(configuration: &configuration::Configuration, concurrency_id: &str) -> Result<serde_json::Value, Error<DeleteConcurrencyGroupError>> {
48 let local_var_configuration = configuration;
49
50 let local_var_client = &local_var_configuration.client;
51
52 let local_var_uri_str = format!("{}/concurrency_groups/prune/{concurrency_id}", local_var_configuration.base_path, concurrency_id=crate::apis::urlencode(concurrency_id));
53 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, 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(&local_var_content).map_err(Error::from)
70 } else {
71 let local_var_entity: Option<DeleteConcurrencyGroupError> = crate::from_str_patched(&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_concurrency_key(configuration: &configuration::Configuration, id: &str) -> Result<String, Error<GetConcurrencyKeyError>> {
78 let local_var_configuration = configuration;
79
80 let local_var_client = &local_var_configuration.client;
81
82 let local_var_uri_str = format!("{}/concurrency_groups/{id}/key", local_var_configuration.base_path, id=crate::apis::urlencode(id));
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(&local_var_content).map_err(Error::from)
100 } else {
101 let local_var_entity: Option<GetConcurrencyKeyError> = crate::from_str_patched(&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 list_concurrency_groups(configuration: &configuration::Configuration, ) -> Result<Vec<models::ConcurrencyGroup>, Error<ListConcurrencyGroupsError>> {
108 let local_var_configuration = configuration;
109
110 let local_var_client = &local_var_configuration.client;
111
112 let local_var_uri_str = format!("{}/concurrency_groups/list", local_var_configuration.base_path);
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(&local_var_content).map_err(Error::from)
130 } else {
131 let local_var_entity: Option<ListConcurrencyGroupsError> = crate::from_str_patched(&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 list_extended_jobs(configuration: &configuration::Configuration, workspace: &str, concurrency_key: Option<&str>, row_limit: Option<f64>, created_by: Option<&str>, label: Option<&str>, parent_job: Option<&str>, script_path_exact: Option<&str>, script_path_start: Option<&str>, schedule_path: Option<&str>, script_hash: Option<&str>, started_before: Option<String>, started_after: Option<String>, created_or_started_before: Option<String>, running: Option<bool>, scheduled_for_before_now: Option<bool>, created_or_started_after: Option<String>, created_or_started_after_completed_jobs: Option<String>, job_kinds: Option<&str>, args: Option<&str>, tag: Option<&str>, result: Option<&str>, allow_wildcards: Option<bool>, page: Option<i32>, per_page: Option<i32>, is_skipped: Option<bool>, is_flow_step: Option<bool>, has_null_parent: Option<bool>, success: Option<bool>, all_workspaces: Option<bool>, is_not_schedule: Option<bool>) -> Result<models::ExtendedJobs, Error<ListExtendedJobsError>> {
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}/concurrency_groups/list_jobs", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
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) = concurrency_key {
146 local_var_req_builder = local_var_req_builder.query(&[("concurrency_key", &local_var_str.to_string())]);
147 }
148 if let Some(ref local_var_str) = row_limit {
149 local_var_req_builder = local_var_req_builder.query(&[("row_limit", &local_var_str.to_string())]);
150 }
151 if let Some(ref local_var_str) = created_by {
152 local_var_req_builder = local_var_req_builder.query(&[("created_by", &local_var_str.to_string())]);
153 }
154 if let Some(ref local_var_str) = label {
155 local_var_req_builder = local_var_req_builder.query(&[("label", &local_var_str.to_string())]);
156 }
157 if let Some(ref local_var_str) = parent_job {
158 local_var_req_builder = local_var_req_builder.query(&[("parent_job", &local_var_str.to_string())]);
159 }
160 if let Some(ref local_var_str) = script_path_exact {
161 local_var_req_builder = local_var_req_builder.query(&[("script_path_exact", &local_var_str.to_string())]);
162 }
163 if let Some(ref local_var_str) = script_path_start {
164 local_var_req_builder = local_var_req_builder.query(&[("script_path_start", &local_var_str.to_string())]);
165 }
166 if let Some(ref local_var_str) = schedule_path {
167 local_var_req_builder = local_var_req_builder.query(&[("schedule_path", &local_var_str.to_string())]);
168 }
169 if let Some(ref local_var_str) = script_hash {
170 local_var_req_builder = local_var_req_builder.query(&[("script_hash", &local_var_str.to_string())]);
171 }
172 if let Some(ref local_var_str) = started_before {
173 local_var_req_builder = local_var_req_builder.query(&[("started_before", &local_var_str.to_string())]);
174 }
175 if let Some(ref local_var_str) = started_after {
176 local_var_req_builder = local_var_req_builder.query(&[("started_after", &local_var_str.to_string())]);
177 }
178 if let Some(ref local_var_str) = created_or_started_before {
179 local_var_req_builder = local_var_req_builder.query(&[("created_or_started_before", &local_var_str.to_string())]);
180 }
181 if let Some(ref local_var_str) = running {
182 local_var_req_builder = local_var_req_builder.query(&[("running", &local_var_str.to_string())]);
183 }
184 if let Some(ref local_var_str) = scheduled_for_before_now {
185 local_var_req_builder = local_var_req_builder.query(&[("scheduled_for_before_now", &local_var_str.to_string())]);
186 }
187 if let Some(ref local_var_str) = created_or_started_after {
188 local_var_req_builder = local_var_req_builder.query(&[("created_or_started_after", &local_var_str.to_string())]);
189 }
190 if let Some(ref local_var_str) = created_or_started_after_completed_jobs {
191 local_var_req_builder = local_var_req_builder.query(&[("created_or_started_after_completed_jobs", &local_var_str.to_string())]);
192 }
193 if let Some(ref local_var_str) = job_kinds {
194 local_var_req_builder = local_var_req_builder.query(&[("job_kinds", &local_var_str.to_string())]);
195 }
196 if let Some(ref local_var_str) = args {
197 local_var_req_builder = local_var_req_builder.query(&[("args", &local_var_str.to_string())]);
198 }
199 if let Some(ref local_var_str) = tag {
200 local_var_req_builder = local_var_req_builder.query(&[("tag", &local_var_str.to_string())]);
201 }
202 if let Some(ref local_var_str) = result {
203 local_var_req_builder = local_var_req_builder.query(&[("result", &local_var_str.to_string())]);
204 }
205 if let Some(ref local_var_str) = allow_wildcards {
206 local_var_req_builder = local_var_req_builder.query(&[("allow_wildcards", &local_var_str.to_string())]);
207 }
208 if let Some(ref local_var_str) = page {
209 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
210 }
211 if let Some(ref local_var_str) = per_page {
212 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
213 }
214 if let Some(ref local_var_str) = is_skipped {
215 local_var_req_builder = local_var_req_builder.query(&[("is_skipped", &local_var_str.to_string())]);
216 }
217 if let Some(ref local_var_str) = is_flow_step {
218 local_var_req_builder = local_var_req_builder.query(&[("is_flow_step", &local_var_str.to_string())]);
219 }
220 if let Some(ref local_var_str) = has_null_parent {
221 local_var_req_builder = local_var_req_builder.query(&[("has_null_parent", &local_var_str.to_string())]);
222 }
223 if let Some(ref local_var_str) = success {
224 local_var_req_builder = local_var_req_builder.query(&[("success", &local_var_str.to_string())]);
225 }
226 if let Some(ref local_var_str) = all_workspaces {
227 local_var_req_builder = local_var_req_builder.query(&[("all_workspaces", &local_var_str.to_string())]);
228 }
229 if let Some(ref local_var_str) = is_not_schedule {
230 local_var_req_builder = local_var_req_builder.query(&[("is_not_schedule", &local_var_str.to_string())]);
231 }
232 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
233 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
234 }
235 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
236 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
237 };
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(&local_var_content).map_err(Error::from)
247 } else {
248 let local_var_entity: Option<ListExtendedJobsError> = crate::from_str_patched(&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