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, get_draft: Option<bool>) -> Result<models::GetGcpTrigger200Response, 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_str) = get_draft {
227 local_var_req_builder = local_var_req_builder.query(&[("get_draft", &local_var_str.to_string())]);
228 }
229 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
230 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
231 }
232 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
233 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
234 };
235
236 let local_var_req = local_var_req_builder.build()?;
237 let local_var_resp = local_var_client.execute(local_var_req).await?;
238
239 let local_var_status = local_var_resp.status();
240 let local_var_content = local_var_resp.text().await?;
241
242 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
243 crate::from_str_patched(&local_var_content).map_err(Error::from)
244 } else {
245 let local_var_entity: Option<GetGcpTriggerError> = crate::from_str_patched(&local_var_content).ok();
246 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
247 Err(Error::ResponseError(local_var_error))
248 }
249}
250
251pub 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>> {
252 let local_var_configuration = configuration;
253
254 let local_var_client = &local_var_configuration.client;
255
256 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));
257 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
258
259 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
260 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
261 }
262 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
263 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
264 };
265 local_var_req_builder = local_var_req_builder.json(&get_all_topic_subscription);
266
267 let local_var_req = local_var_req_builder.build()?;
268 let local_var_resp = local_var_client.execute(local_var_req).await?;
269
270 let local_var_status = local_var_resp.status();
271 let local_var_content = local_var_resp.text().await?;
272
273 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
274 crate::from_str_patched(&local_var_content).map_err(Error::from)
275 } else {
276 let local_var_entity: Option<ListAllTGoogleTopicSubscriptionsError> = crate::from_str_patched(&local_var_content).ok();
277 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
278 Err(Error::ResponseError(local_var_error))
279 }
280}
281
282pub 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>, include_draft_only: Option<bool>) -> Result<Vec<models::GcpTrigger>, Error<ListGcpTriggersError>> {
283 let local_var_configuration = configuration;
284
285 let local_var_client = &local_var_configuration.client;
286
287 let local_var_uri_str = format!("{}/w/{workspace}/gcp_triggers/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
288 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
289
290 if let Some(ref local_var_str) = page {
291 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
292 }
293 if let Some(ref local_var_str) = per_page {
294 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
295 }
296 if let Some(ref local_var_str) = path {
297 local_var_req_builder = local_var_req_builder.query(&[("path", &local_var_str.to_string())]);
298 }
299 if let Some(ref local_var_str) = is_flow {
300 local_var_req_builder = local_var_req_builder.query(&[("is_flow", &local_var_str.to_string())]);
301 }
302 if let Some(ref local_var_str) = path_start {
303 local_var_req_builder = local_var_req_builder.query(&[("path_start", &local_var_str.to_string())]);
304 }
305 if let Some(ref local_var_str) = label {
306 local_var_req_builder = local_var_req_builder.query(&[("label", &local_var_str.to_string())]);
307 }
308 if let Some(ref local_var_str) = include_draft_only {
309 local_var_req_builder = local_var_req_builder.query(&[("include_draft_only", &local_var_str.to_string())]);
310 }
311 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
312 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
313 }
314 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
315 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
316 };
317
318 let local_var_req = local_var_req_builder.build()?;
319 let local_var_resp = local_var_client.execute(local_var_req).await?;
320
321 let local_var_status = local_var_resp.status();
322 let local_var_content = local_var_resp.text().await?;
323
324 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
325 crate::from_str_patched(&local_var_content).map_err(Error::from)
326 } else {
327 let local_var_entity: Option<ListGcpTriggersError> = crate::from_str_patched(&local_var_content).ok();
328 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
329 Err(Error::ResponseError(local_var_error))
330 }
331}
332
333pub async fn list_google_topics(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<Vec<String>, Error<ListGoogleTopicsError>> {
334 let local_var_configuration = configuration;
335
336 let local_var_client = &local_var_configuration.client;
337
338 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));
339 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
340
341 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
342 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
343 }
344 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
345 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
346 };
347
348 let local_var_req = local_var_req_builder.build()?;
349 let local_var_resp = local_var_client.execute(local_var_req).await?;
350
351 let local_var_status = local_var_resp.status();
352 let local_var_content = local_var_resp.text().await?;
353
354 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
355 crate::from_str_patched(&local_var_content).map_err(Error::from)
356 } else {
357 let local_var_entity: Option<ListGoogleTopicsError> = crate::from_str_patched(&local_var_content).ok();
358 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
359 Err(Error::ResponseError(local_var_error))
360 }
361}
362
363pub async fn set_gcp_trigger_mode(configuration: &configuration::Configuration, workspace: &str, path: &str, set_http_trigger_mode_request: models::SetHttpTriggerModeRequest) -> Result<String, Error<SetGcpTriggerModeError>> {
364 let local_var_configuration = configuration;
365
366 let local_var_client = &local_var_configuration.client;
367
368 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));
369 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
370
371 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
372 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
373 }
374 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
375 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
376 };
377 local_var_req_builder = local_var_req_builder.json(&set_http_trigger_mode_request);
378
379 let local_var_req = local_var_req_builder.build()?;
380 let local_var_resp = local_var_client.execute(local_var_req).await?;
381
382 let local_var_status = local_var_resp.status();
383 let local_var_content = local_var_resp.text().await?;
384
385 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
386 crate::from_str_patched(&local_var_content).map_err(Error::from)
387 } else {
388 let local_var_entity: Option<SetGcpTriggerModeError> = crate::from_str_patched(&local_var_content).ok();
389 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
390 Err(Error::ResponseError(local_var_error))
391 }
392}
393
394pub async fn test_gcp_connection(configuration: &configuration::Configuration, workspace: &str, test_kafka_connection_request: models::TestKafkaConnectionRequest) -> Result<String, Error<TestGcpConnectionError>> {
395 let local_var_configuration = configuration;
396
397 let local_var_client = &local_var_configuration.client;
398
399 let local_var_uri_str = format!("{}/w/{workspace}/gcp_triggers/test", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
400 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
401
402 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
403 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
404 }
405 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
406 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
407 };
408 local_var_req_builder = local_var_req_builder.json(&test_kafka_connection_request);
409
410 let local_var_req = local_var_req_builder.build()?;
411 let local_var_resp = local_var_client.execute(local_var_req).await?;
412
413 let local_var_status = local_var_resp.status();
414 let local_var_content = local_var_resp.text().await?;
415
416 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
417 crate::from_str_patched(&local_var_content).map_err(Error::from)
418 } else {
419 let local_var_entity: Option<TestGcpConnectionError> = crate::from_str_patched(&local_var_content).ok();
420 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
421 Err(Error::ResponseError(local_var_error))
422 }
423}
424
425pub async fn update_gcp_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str, gcp_trigger_data: models::GcpTriggerData) -> Result<String, Error<UpdateGcpTriggerError>> {
426 let local_var_configuration = configuration;
427
428 let local_var_client = &local_var_configuration.client;
429
430 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));
431 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
432
433 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
434 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
435 }
436 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
437 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
438 };
439 local_var_req_builder = local_var_req_builder.json(&gcp_trigger_data);
440
441 let local_var_req = local_var_req_builder.build()?;
442 let local_var_resp = local_var_client.execute(local_var_req).await?;
443
444 let local_var_status = local_var_resp.status();
445 let local_var_content = local_var_resp.text().await?;
446
447 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
448 crate::from_str_patched(&local_var_content).map_err(Error::from)
449 } else {
450 let local_var_entity: Option<UpdateGcpTriggerError> = crate::from_str_patched(&local_var_content).ok();
451 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
452 Err(Error::ResponseError(local_var_error))
453 }
454}
455