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 SetGcpTriggerModeError {
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>, label: 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_str) = label {
303 local_var_req_builder = local_var_req_builder.query(&[("label", &local_var_str.to_string())]);
304 }
305 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
306 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
307 }
308 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
309 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
310 };
311
312 let local_var_req = local_var_req_builder.build()?;
313 let local_var_resp = local_var_client.execute(local_var_req).await?;
314
315 let local_var_status = local_var_resp.status();
316 let local_var_content = local_var_resp.text().await?;
317
318 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
319 crate::from_str_patched(&local_var_content).map_err(Error::from)
320 } else {
321 let local_var_entity: Option<ListGcpTriggersError> = crate::from_str_patched(&local_var_content).ok();
322 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
323 Err(Error::ResponseError(local_var_error))
324 }
325}
326
327pub async fn list_google_topics(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<Vec<String>, Error<ListGoogleTopicsError>> {
328 let local_var_configuration = configuration;
329
330 let local_var_client = &local_var_configuration.client;
331
332 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));
333 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
334
335 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
336 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
337 }
338 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
339 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
340 };
341
342 let local_var_req = local_var_req_builder.build()?;
343 let local_var_resp = local_var_client.execute(local_var_req).await?;
344
345 let local_var_status = local_var_resp.status();
346 let local_var_content = local_var_resp.text().await?;
347
348 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
349 crate::from_str_patched(&local_var_content).map_err(Error::from)
350 } else {
351 let local_var_entity: Option<ListGoogleTopicsError> = crate::from_str_patched(&local_var_content).ok();
352 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
353 Err(Error::ResponseError(local_var_error))
354 }
355}
356
357pub async fn set_gcp_trigger_mode(configuration: &configuration::Configuration, workspace: &str, path: &str, set_http_trigger_mode_request: models::SetHttpTriggerModeRequest) -> Result<String, Error<SetGcpTriggerModeError>> {
358 let local_var_configuration = configuration;
359
360 let local_var_client = &local_var_configuration.client;
361
362 let local_var_uri_str = format!("{}/w/{workspace}/gcp_triggers/setmode/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
363 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
364
365 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
366 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
367 }
368 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
369 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
370 };
371 local_var_req_builder = local_var_req_builder.json(&set_http_trigger_mode_request);
372
373 let local_var_req = local_var_req_builder.build()?;
374 let local_var_resp = local_var_client.execute(local_var_req).await?;
375
376 let local_var_status = local_var_resp.status();
377 let local_var_content = local_var_resp.text().await?;
378
379 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
380 crate::from_str_patched(&local_var_content).map_err(Error::from)
381 } else {
382 let local_var_entity: Option<SetGcpTriggerModeError> = crate::from_str_patched(&local_var_content).ok();
383 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
384 Err(Error::ResponseError(local_var_error))
385 }
386}
387
388pub async fn test_gcp_connection(configuration: &configuration::Configuration, workspace: &str, test_kafka_connection_request: models::TestKafkaConnectionRequest) -> Result<String, Error<TestGcpConnectionError>> {
389 let local_var_configuration = configuration;
390
391 let local_var_client = &local_var_configuration.client;
392
393 let local_var_uri_str = format!("{}/w/{workspace}/gcp_triggers/test", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
394 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
395
396 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
397 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
398 }
399 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
400 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
401 };
402 local_var_req_builder = local_var_req_builder.json(&test_kafka_connection_request);
403
404 let local_var_req = local_var_req_builder.build()?;
405 let local_var_resp = local_var_client.execute(local_var_req).await?;
406
407 let local_var_status = local_var_resp.status();
408 let local_var_content = local_var_resp.text().await?;
409
410 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
411 crate::from_str_patched(&local_var_content).map_err(Error::from)
412 } else {
413 let local_var_entity: Option<TestGcpConnectionError> = crate::from_str_patched(&local_var_content).ok();
414 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
415 Err(Error::ResponseError(local_var_error))
416 }
417}
418
419pub async fn update_gcp_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str, gcp_trigger_data: models::GcpTriggerData) -> Result<String, Error<UpdateGcpTriggerError>> {
420 let local_var_configuration = configuration;
421
422 let local_var_client = &local_var_configuration.client;
423
424 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));
425 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
426
427 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
428 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
429 }
430 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
431 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
432 };
433 local_var_req_builder = local_var_req_builder.json(&gcp_trigger_data);
434
435 let local_var_req = local_var_req_builder.build()?;
436 let local_var_resp = local_var_client.execute(local_var_req).await?;
437
438 let local_var_status = local_var_resp.status();
439 let local_var_content = local_var_resp.text().await?;
440
441 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
442 crate::from_str_patched(&local_var_content).map_err(Error::from)
443 } else {
444 let local_var_entity: Option<UpdateGcpTriggerError> = crate::from_str_patched(&local_var_content).ok();
445 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
446 Err(Error::ResponseError(local_var_error))
447 }
448}
449