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 CreateGcpTriggerError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum DeleteGcpSubscriptionError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum DeleteGcpTriggerError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ExistsGcpTriggerError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetGcpTriggerError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum ListAllTGoogleTopicSubscriptionsError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ListGcpTriggersError {
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum ListGoogleTopicsError {
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum SetGcpTriggerEnabledError {
78 UnknownValue(serde_json::Value),
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum TestGcpConnectionError {
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum UpdateGcpTriggerError {
92 UnknownValue(serde_json::Value),
93}
94
95
96pub async fn create_gcp_trigger(configuration: &configuration::Configuration, workspace: &str, gcp_trigger_data: models::GcpTriggerData) -> Result<String, Error<CreateGcpTriggerError>> {
97 let local_var_configuration = configuration;
98
99 let local_var_client = &local_var_configuration.client;
100
101 let local_var_uri_str = format!("{}/w/{workspace}/gcp_triggers/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
102 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
103
104 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
105 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
106 }
107 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
108 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
109 };
110 local_var_req_builder = local_var_req_builder.json(&gcp_trigger_data);
111
112 let local_var_req = local_var_req_builder.build()?;
113 let local_var_resp = local_var_client.execute(local_var_req).await?;
114
115 let local_var_status = local_var_resp.status();
116 let local_var_content = local_var_resp.text().await?;
117
118 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
119 crate::from_str_patched(&local_var_content).map_err(Error::from)
120 } else {
121 let local_var_entity: Option<CreateGcpTriggerError> = crate::from_str_patched(&local_var_content).ok();
122 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
123 Err(Error::ResponseError(local_var_error))
124 }
125}
126
127pub async fn delete_gcp_subscription(configuration: &configuration::Configuration, workspace: &str, path: &str, delete_gcp_subscription: models::DeleteGcpSubscription) -> Result<String, Error<DeleteGcpSubscriptionError>> {
128 let local_var_configuration = configuration;
129
130 let local_var_client = &local_var_configuration.client;
131
132 let local_var_uri_str = format!("{}/w/{workspace}/gcp_triggers/subscriptions/delete/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
133 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
134
135 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
136 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
137 }
138 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
139 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
140 };
141 local_var_req_builder = local_var_req_builder.json(&delete_gcp_subscription);
142
143 let local_var_req = local_var_req_builder.build()?;
144 let local_var_resp = local_var_client.execute(local_var_req).await?;
145
146 let local_var_status = local_var_resp.status();
147 let local_var_content = local_var_resp.text().await?;
148
149 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
150 crate::from_str_patched(&local_var_content).map_err(Error::from)
151 } else {
152 let local_var_entity: Option<DeleteGcpSubscriptionError> = crate::from_str_patched(&local_var_content).ok();
153 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
154 Err(Error::ResponseError(local_var_error))
155 }
156}
157
158pub async fn delete_gcp_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<String, Error<DeleteGcpTriggerError>> {
159 let local_var_configuration = configuration;
160
161 let local_var_client = &local_var_configuration.client;
162
163 let local_var_uri_str = format!("{}/w/{workspace}/gcp_triggers/delete/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
164 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
165
166 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
167 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
168 }
169 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
170 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
171 };
172
173 let local_var_req = local_var_req_builder.build()?;
174 let local_var_resp = local_var_client.execute(local_var_req).await?;
175
176 let local_var_status = local_var_resp.status();
177 let local_var_content = local_var_resp.text().await?;
178
179 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
180 crate::from_str_patched(&local_var_content).map_err(Error::from)
181 } else {
182 let local_var_entity: Option<DeleteGcpTriggerError> = crate::from_str_patched(&local_var_content).ok();
183 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
184 Err(Error::ResponseError(local_var_error))
185 }
186}
187
188pub async fn exists_gcp_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<bool, Error<ExistsGcpTriggerError>> {
189 let local_var_configuration = configuration;
190
191 let local_var_client = &local_var_configuration.client;
192
193 let local_var_uri_str = format!("{}/w/{workspace}/gcp_triggers/exists/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
194 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
195
196 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
197 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
198 }
199 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
200 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
201 };
202
203 let local_var_req = local_var_req_builder.build()?;
204 let local_var_resp = local_var_client.execute(local_var_req).await?;
205
206 let local_var_status = local_var_resp.status();
207 let local_var_content = local_var_resp.text().await?;
208
209 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
210 crate::from_str_patched(&local_var_content).map_err(Error::from)
211 } else {
212 let local_var_entity: Option<ExistsGcpTriggerError> = crate::from_str_patched(&local_var_content).ok();
213 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
214 Err(Error::ResponseError(local_var_error))
215 }
216}
217
218pub async fn get_gcp_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<models::GcpTrigger, Error<GetGcpTriggerError>> {
219 let local_var_configuration = configuration;
220
221 let local_var_client = &local_var_configuration.client;
222
223 let local_var_uri_str = format!("{}/w/{workspace}/gcp_triggers/get/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
224 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
225
226 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
227 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
228 }
229 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
230 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
231 };
232
233 let local_var_req = local_var_req_builder.build()?;
234 let local_var_resp = local_var_client.execute(local_var_req).await?;
235
236 let local_var_status = local_var_resp.status();
237 let local_var_content = local_var_resp.text().await?;
238
239 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
240 crate::from_str_patched(&local_var_content).map_err(Error::from)
241 } else {
242 let local_var_entity: Option<GetGcpTriggerError> = crate::from_str_patched(&local_var_content).ok();
243 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
244 Err(Error::ResponseError(local_var_error))
245 }
246}
247
248pub async fn list_all_t_google_topic_subscriptions(configuration: &configuration::Configuration, workspace: &str, path: &str, get_all_topic_subscription: models::GetAllTopicSubscription) -> Result<Vec<String>, Error<ListAllTGoogleTopicSubscriptionsError>> {
249 let local_var_configuration = configuration;
250
251 let local_var_client = &local_var_configuration.client;
252
253 let local_var_uri_str = format!("{}/w/{workspace}/gcp_triggers/subscriptions/list/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
254 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
255
256 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
257 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
258 }
259 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
260 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
261 };
262 local_var_req_builder = local_var_req_builder.json(&get_all_topic_subscription);
263
264 let local_var_req = local_var_req_builder.build()?;
265 let local_var_resp = local_var_client.execute(local_var_req).await?;
266
267 let local_var_status = local_var_resp.status();
268 let local_var_content = local_var_resp.text().await?;
269
270 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
271 crate::from_str_patched(&local_var_content).map_err(Error::from)
272 } else {
273 let local_var_entity: Option<ListAllTGoogleTopicSubscriptionsError> = crate::from_str_patched(&local_var_content).ok();
274 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
275 Err(Error::ResponseError(local_var_error))
276 }
277}
278
279pub async fn list_gcp_triggers(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>, path: Option<&str>, is_flow: Option<bool>, path_start: Option<&str>) -> Result<Vec<models::GcpTrigger>, Error<ListGcpTriggersError>> {
280 let local_var_configuration = configuration;
281
282 let local_var_client = &local_var_configuration.client;
283
284 let local_var_uri_str = format!("{}/w/{workspace}/gcp_triggers/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
285 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
286
287 if let Some(ref local_var_str) = page {
288 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
289 }
290 if let Some(ref local_var_str) = per_page {
291 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
292 }
293 if let Some(ref local_var_str) = path {
294 local_var_req_builder = local_var_req_builder.query(&[("path", &local_var_str.to_string())]);
295 }
296 if let Some(ref local_var_str) = is_flow {
297 local_var_req_builder = local_var_req_builder.query(&[("is_flow", &local_var_str.to_string())]);
298 }
299 if let Some(ref local_var_str) = path_start {
300 local_var_req_builder = local_var_req_builder.query(&[("path_start", &local_var_str.to_string())]);
301 }
302 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
303 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
304 }
305 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
306 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
307 };
308
309 let local_var_req = local_var_req_builder.build()?;
310 let local_var_resp = local_var_client.execute(local_var_req).await?;
311
312 let local_var_status = local_var_resp.status();
313 let local_var_content = local_var_resp.text().await?;
314
315 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
316 crate::from_str_patched(&local_var_content).map_err(Error::from)
317 } else {
318 let local_var_entity: Option<ListGcpTriggersError> = crate::from_str_patched(&local_var_content).ok();
319 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
320 Err(Error::ResponseError(local_var_error))
321 }
322}
323
324pub async fn list_google_topics(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<Vec<String>, Error<ListGoogleTopicsError>> {
325 let local_var_configuration = configuration;
326
327 let local_var_client = &local_var_configuration.client;
328
329 let local_var_uri_str = format!("{}/w/{workspace}/gcp_triggers/topics/list/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
330 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
331
332 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
333 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
334 }
335 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
336 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
337 };
338
339 let local_var_req = local_var_req_builder.build()?;
340 let local_var_resp = local_var_client.execute(local_var_req).await?;
341
342 let local_var_status = local_var_resp.status();
343 let local_var_content = local_var_resp.text().await?;
344
345 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
346 crate::from_str_patched(&local_var_content).map_err(Error::from)
347 } else {
348 let local_var_entity: Option<ListGoogleTopicsError> = crate::from_str_patched(&local_var_content).ok();
349 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
350 Err(Error::ResponseError(local_var_error))
351 }
352}
353
354pub async fn set_gcp_trigger_enabled(configuration: &configuration::Configuration, workspace: &str, path: &str, set_schedule_enabled_request: models::SetScheduleEnabledRequest) -> Result<String, Error<SetGcpTriggerEnabledError>> {
355 let local_var_configuration = configuration;
356
357 let local_var_client = &local_var_configuration.client;
358
359 let local_var_uri_str = format!("{}/w/{workspace}/gcp_triggers/setenabled/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
360 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
361
362 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
363 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
364 }
365 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
366 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
367 };
368 local_var_req_builder = local_var_req_builder.json(&set_schedule_enabled_request);
369
370 let local_var_req = local_var_req_builder.build()?;
371 let local_var_resp = local_var_client.execute(local_var_req).await?;
372
373 let local_var_status = local_var_resp.status();
374 let local_var_content = local_var_resp.text().await?;
375
376 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
377 crate::from_str_patched(&local_var_content).map_err(Error::from)
378 } else {
379 let local_var_entity: Option<SetGcpTriggerEnabledError> = crate::from_str_patched(&local_var_content).ok();
380 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
381 Err(Error::ResponseError(local_var_error))
382 }
383}
384
385pub async fn test_gcp_connection(configuration: &configuration::Configuration, workspace: &str, test_kafka_connection_request: models::TestKafkaConnectionRequest) -> Result<String, Error<TestGcpConnectionError>> {
386 let local_var_configuration = configuration;
387
388 let local_var_client = &local_var_configuration.client;
389
390 let local_var_uri_str = format!("{}/w/{workspace}/gcp_triggers/test", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
391 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
392
393 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
394 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
395 }
396 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
397 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
398 };
399 local_var_req_builder = local_var_req_builder.json(&test_kafka_connection_request);
400
401 let local_var_req = local_var_req_builder.build()?;
402 let local_var_resp = local_var_client.execute(local_var_req).await?;
403
404 let local_var_status = local_var_resp.status();
405 let local_var_content = local_var_resp.text().await?;
406
407 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
408 crate::from_str_patched(&local_var_content).map_err(Error::from)
409 } else {
410 let local_var_entity: Option<TestGcpConnectionError> = crate::from_str_patched(&local_var_content).ok();
411 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
412 Err(Error::ResponseError(local_var_error))
413 }
414}
415
416pub async fn update_gcp_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str, gcp_trigger_data: models::GcpTriggerData) -> Result<String, Error<UpdateGcpTriggerError>> {
417 let local_var_configuration = configuration;
418
419 let local_var_client = &local_var_configuration.client;
420
421 let local_var_uri_str = format!("{}/w/{workspace}/gcp_triggers/update/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
422 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
423
424 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
425 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
426 }
427 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
428 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
429 };
430 local_var_req_builder = local_var_req_builder.json(&gcp_trigger_data);
431
432 let local_var_req = local_var_req_builder.build()?;
433 let local_var_resp = local_var_client.execute(local_var_req).await?;
434
435 let local_var_status = local_var_resp.status();
436 let local_var_content = local_var_resp.text().await?;
437
438 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
439 crate::from_str_patched(&local_var_content).map_err(Error::from)
440 } else {
441 let local_var_entity: Option<UpdateGcpTriggerError> = crate::from_str_patched(&local_var_content).ok();
442 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
443 Err(Error::ResponseError(local_var_error))
444 }
445}
446