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 CreatePostgresPublicationError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum CreatePostgresReplicationSlotError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum CreatePostgresTriggerError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum CreateTemplateScriptError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum DeletePostgresPublicationError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum DeletePostgresReplicationSlotError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum DeletePostgresTriggerError {
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum ExistsPostgresTriggerError {
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum GetPostgresPublicationError {
78 UnknownValue(serde_json::Value),
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum GetPostgresTriggerError {
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum GetPostgresVersionError {
92 UnknownValue(serde_json::Value),
93}
94
95#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum GetTemplateScriptError {
99 UnknownValue(serde_json::Value),
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum IsValidPostgresConfigurationError {
106 UnknownValue(serde_json::Value),
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum ListPostgresPublicationError {
113 UnknownValue(serde_json::Value),
114}
115
116#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum ListPostgresReplicationSlotError {
120 UnknownValue(serde_json::Value),
121}
122
123#[derive(Debug, Clone, Serialize, Deserialize)]
125#[serde(untagged)]
126pub enum ListPostgresTriggersError {
127 UnknownValue(serde_json::Value),
128}
129
130#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum SetPostgresTriggerEnabledError {
134 UnknownValue(serde_json::Value),
135}
136
137#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum TestPostgresConnectionError {
141 UnknownValue(serde_json::Value),
142}
143
144#[derive(Debug, Clone, Serialize, Deserialize)]
146#[serde(untagged)]
147pub enum UpdatePostgresPublicationError {
148 UnknownValue(serde_json::Value),
149}
150
151#[derive(Debug, Clone, Serialize, Deserialize)]
153#[serde(untagged)]
154pub enum UpdatePostgresTriggerError {
155 UnknownValue(serde_json::Value),
156}
157
158
159pub async fn create_postgres_publication(configuration: &configuration::Configuration, workspace: &str, path: &str, publication: &str, publication_data: models::PublicationData) -> Result<String, Error<CreatePostgresPublicationError>> {
160 let local_var_configuration = configuration;
161
162 let local_var_client = &local_var_configuration.client;
163
164 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/publication/create/{publication}/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path), publication=crate::apis::urlencode(publication));
165 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
166
167 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
168 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
169 }
170 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
171 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
172 };
173 local_var_req_builder = local_var_req_builder.json(&publication_data);
174
175 let local_var_req = local_var_req_builder.build()?;
176 let local_var_resp = local_var_client.execute(local_var_req).await?;
177
178 let local_var_status = local_var_resp.status();
179 let local_var_content = local_var_resp.text().await?;
180
181 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
182 crate::from_str_patched(&local_var_content).map_err(Error::from)
183 } else {
184 let local_var_entity: Option<CreatePostgresPublicationError> = crate::from_str_patched(&local_var_content).ok();
185 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
186 Err(Error::ResponseError(local_var_error))
187 }
188}
189
190pub async fn create_postgres_replication_slot(configuration: &configuration::Configuration, workspace: &str, path: &str, slot: models::Slot) -> Result<String, Error<CreatePostgresReplicationSlotError>> {
191 let local_var_configuration = configuration;
192
193 let local_var_client = &local_var_configuration.client;
194
195 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/slot/create/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
196 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
197
198 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
199 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
200 }
201 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
202 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
203 };
204 local_var_req_builder = local_var_req_builder.json(&slot);
205
206 let local_var_req = local_var_req_builder.build()?;
207 let local_var_resp = local_var_client.execute(local_var_req).await?;
208
209 let local_var_status = local_var_resp.status();
210 let local_var_content = local_var_resp.text().await?;
211
212 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
213 crate::from_str_patched(&local_var_content).map_err(Error::from)
214 } else {
215 let local_var_entity: Option<CreatePostgresReplicationSlotError> = crate::from_str_patched(&local_var_content).ok();
216 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
217 Err(Error::ResponseError(local_var_error))
218 }
219}
220
221pub async fn create_postgres_trigger(configuration: &configuration::Configuration, workspace: &str, new_postgres_trigger: models::NewPostgresTrigger) -> Result<String, Error<CreatePostgresTriggerError>> {
222 let local_var_configuration = configuration;
223
224 let local_var_client = &local_var_configuration.client;
225
226 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
227 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
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 local_var_req_builder = local_var_req_builder.json(&new_postgres_trigger);
236
237 let local_var_req = local_var_req_builder.build()?;
238 let local_var_resp = local_var_client.execute(local_var_req).await?;
239
240 let local_var_status = local_var_resp.status();
241 let local_var_content = local_var_resp.text().await?;
242
243 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
244 crate::from_str_patched(&local_var_content).map_err(Error::from)
245 } else {
246 let local_var_entity: Option<CreatePostgresTriggerError> = crate::from_str_patched(&local_var_content).ok();
247 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
248 Err(Error::ResponseError(local_var_error))
249 }
250}
251
252pub async fn create_template_script(configuration: &configuration::Configuration, workspace: &str, template_script: models::TemplateScript) -> Result<String, Error<CreateTemplateScriptError>> {
253 let local_var_configuration = configuration;
254
255 let local_var_client = &local_var_configuration.client;
256
257 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/create_template_script", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
258 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
259
260 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
261 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
262 }
263 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
264 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
265 };
266 local_var_req_builder = local_var_req_builder.json(&template_script);
267
268 let local_var_req = local_var_req_builder.build()?;
269 let local_var_resp = local_var_client.execute(local_var_req).await?;
270
271 let local_var_status = local_var_resp.status();
272 let local_var_content = local_var_resp.text().await?;
273
274 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
275 crate::from_str_patched(&local_var_content).map_err(Error::from)
276 } else {
277 let local_var_entity: Option<CreateTemplateScriptError> = crate::from_str_patched(&local_var_content).ok();
278 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
279 Err(Error::ResponseError(local_var_error))
280 }
281}
282
283pub async fn delete_postgres_publication(configuration: &configuration::Configuration, workspace: &str, path: &str, publication: &str) -> Result<String, Error<DeletePostgresPublicationError>> {
284 let local_var_configuration = configuration;
285
286 let local_var_client = &local_var_configuration.client;
287
288 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/publication/delete/{publication}/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path), publication=crate::apis::urlencode(publication));
289 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
290
291 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
292 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
293 }
294 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
295 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
296 };
297
298 let local_var_req = local_var_req_builder.build()?;
299 let local_var_resp = local_var_client.execute(local_var_req).await?;
300
301 let local_var_status = local_var_resp.status();
302 let local_var_content = local_var_resp.text().await?;
303
304 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
305 crate::from_str_patched(&local_var_content).map_err(Error::from)
306 } else {
307 let local_var_entity: Option<DeletePostgresPublicationError> = crate::from_str_patched(&local_var_content).ok();
308 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
309 Err(Error::ResponseError(local_var_error))
310 }
311}
312
313pub async fn delete_postgres_replication_slot(configuration: &configuration::Configuration, workspace: &str, path: &str, slot: models::Slot) -> Result<String, Error<DeletePostgresReplicationSlotError>> {
314 let local_var_configuration = configuration;
315
316 let local_var_client = &local_var_configuration.client;
317
318 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/slot/delete/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
319 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
320
321 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
322 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
323 }
324 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
325 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
326 };
327 local_var_req_builder = local_var_req_builder.json(&slot);
328
329 let local_var_req = local_var_req_builder.build()?;
330 let local_var_resp = local_var_client.execute(local_var_req).await?;
331
332 let local_var_status = local_var_resp.status();
333 let local_var_content = local_var_resp.text().await?;
334
335 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
336 crate::from_str_patched(&local_var_content).map_err(Error::from)
337 } else {
338 let local_var_entity: Option<DeletePostgresReplicationSlotError> = crate::from_str_patched(&local_var_content).ok();
339 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
340 Err(Error::ResponseError(local_var_error))
341 }
342}
343
344pub async fn delete_postgres_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<String, Error<DeletePostgresTriggerError>> {
345 let local_var_configuration = configuration;
346
347 let local_var_client = &local_var_configuration.client;
348
349 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/delete/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
350 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
351
352 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
353 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
354 }
355 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
356 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
357 };
358
359 let local_var_req = local_var_req_builder.build()?;
360 let local_var_resp = local_var_client.execute(local_var_req).await?;
361
362 let local_var_status = local_var_resp.status();
363 let local_var_content = local_var_resp.text().await?;
364
365 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
366 crate::from_str_patched(&local_var_content).map_err(Error::from)
367 } else {
368 let local_var_entity: Option<DeletePostgresTriggerError> = crate::from_str_patched(&local_var_content).ok();
369 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
370 Err(Error::ResponseError(local_var_error))
371 }
372}
373
374pub async fn exists_postgres_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<bool, Error<ExistsPostgresTriggerError>> {
375 let local_var_configuration = configuration;
376
377 let local_var_client = &local_var_configuration.client;
378
379 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/exists/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
380 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
381
382 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
383 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
384 }
385 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
386 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
387 };
388
389 let local_var_req = local_var_req_builder.build()?;
390 let local_var_resp = local_var_client.execute(local_var_req).await?;
391
392 let local_var_status = local_var_resp.status();
393 let local_var_content = local_var_resp.text().await?;
394
395 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
396 crate::from_str_patched(&local_var_content).map_err(Error::from)
397 } else {
398 let local_var_entity: Option<ExistsPostgresTriggerError> = crate::from_str_patched(&local_var_content).ok();
399 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
400 Err(Error::ResponseError(local_var_error))
401 }
402}
403
404pub async fn get_postgres_publication(configuration: &configuration::Configuration, workspace: &str, path: &str, publication: &str) -> Result<models::PublicationData, Error<GetPostgresPublicationError>> {
405 let local_var_configuration = configuration;
406
407 let local_var_client = &local_var_configuration.client;
408
409 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/publication/get/{publication}/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path), publication=crate::apis::urlencode(publication));
410 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
411
412 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
413 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
414 }
415 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
416 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
417 };
418
419 let local_var_req = local_var_req_builder.build()?;
420 let local_var_resp = local_var_client.execute(local_var_req).await?;
421
422 let local_var_status = local_var_resp.status();
423 let local_var_content = local_var_resp.text().await?;
424
425 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
426 crate::from_str_patched(&local_var_content).map_err(Error::from)
427 } else {
428 let local_var_entity: Option<GetPostgresPublicationError> = crate::from_str_patched(&local_var_content).ok();
429 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
430 Err(Error::ResponseError(local_var_error))
431 }
432}
433
434pub async fn get_postgres_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<models::PostgresTrigger, Error<GetPostgresTriggerError>> {
435 let local_var_configuration = configuration;
436
437 let local_var_client = &local_var_configuration.client;
438
439 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/get/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
440 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
441
442 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
443 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
444 }
445 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
446 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
447 };
448
449 let local_var_req = local_var_req_builder.build()?;
450 let local_var_resp = local_var_client.execute(local_var_req).await?;
451
452 let local_var_status = local_var_resp.status();
453 let local_var_content = local_var_resp.text().await?;
454
455 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
456 crate::from_str_patched(&local_var_content).map_err(Error::from)
457 } else {
458 let local_var_entity: Option<GetPostgresTriggerError> = crate::from_str_patched(&local_var_content).ok();
459 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
460 Err(Error::ResponseError(local_var_error))
461 }
462}
463
464pub async fn get_postgres_version(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<String, Error<GetPostgresVersionError>> {
465 let local_var_configuration = configuration;
466
467 let local_var_client = &local_var_configuration.client;
468
469 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/postgres/version/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
470 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
471
472 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
473 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
474 }
475 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
476 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
477 };
478
479 let local_var_req = local_var_req_builder.build()?;
480 let local_var_resp = local_var_client.execute(local_var_req).await?;
481
482 let local_var_status = local_var_resp.status();
483 let local_var_content = local_var_resp.text().await?;
484
485 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
486 crate::from_str_patched(&local_var_content).map_err(Error::from)
487 } else {
488 let local_var_entity: Option<GetPostgresVersionError> = crate::from_str_patched(&local_var_content).ok();
489 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
490 Err(Error::ResponseError(local_var_error))
491 }
492}
493
494pub async fn get_template_script(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<String, Error<GetTemplateScriptError>> {
495 let local_var_configuration = configuration;
496
497 let local_var_client = &local_var_configuration.client;
498
499 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/get_template_script/{id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
500 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
501
502 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
503 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
504 }
505 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
506 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
507 };
508
509 let local_var_req = local_var_req_builder.build()?;
510 let local_var_resp = local_var_client.execute(local_var_req).await?;
511
512 let local_var_status = local_var_resp.status();
513 let local_var_content = local_var_resp.text().await?;
514
515 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
516 crate::from_str_patched(&local_var_content).map_err(Error::from)
517 } else {
518 let local_var_entity: Option<GetTemplateScriptError> = crate::from_str_patched(&local_var_content).ok();
519 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
520 Err(Error::ResponseError(local_var_error))
521 }
522}
523
524pub async fn is_valid_postgres_configuration(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<bool, Error<IsValidPostgresConfigurationError>> {
525 let local_var_configuration = configuration;
526
527 let local_var_client = &local_var_configuration.client;
528
529 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/is_valid_postgres_configuration/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
530 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
531
532 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
533 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
534 }
535 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
536 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
537 };
538
539 let local_var_req = local_var_req_builder.build()?;
540 let local_var_resp = local_var_client.execute(local_var_req).await?;
541
542 let local_var_status = local_var_resp.status();
543 let local_var_content = local_var_resp.text().await?;
544
545 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
546 crate::from_str_patched(&local_var_content).map_err(Error::from)
547 } else {
548 let local_var_entity: Option<IsValidPostgresConfigurationError> = crate::from_str_patched(&local_var_content).ok();
549 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
550 Err(Error::ResponseError(local_var_error))
551 }
552}
553
554pub async fn list_postgres_publication(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<Vec<String>, Error<ListPostgresPublicationError>> {
555 let local_var_configuration = configuration;
556
557 let local_var_client = &local_var_configuration.client;
558
559 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/publication/list/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
560 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
561
562 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
563 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
564 }
565 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
566 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
567 };
568
569 let local_var_req = local_var_req_builder.build()?;
570 let local_var_resp = local_var_client.execute(local_var_req).await?;
571
572 let local_var_status = local_var_resp.status();
573 let local_var_content = local_var_resp.text().await?;
574
575 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
576 crate::from_str_patched(&local_var_content).map_err(Error::from)
577 } else {
578 let local_var_entity: Option<ListPostgresPublicationError> = crate::from_str_patched(&local_var_content).ok();
579 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
580 Err(Error::ResponseError(local_var_error))
581 }
582}
583
584pub async fn list_postgres_replication_slot(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<Vec<models::SlotList>, Error<ListPostgresReplicationSlotError>> {
585 let local_var_configuration = configuration;
586
587 let local_var_client = &local_var_configuration.client;
588
589 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/slot/list/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
590 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
591
592 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
593 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
594 }
595 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
596 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
597 };
598
599 let local_var_req = local_var_req_builder.build()?;
600 let local_var_resp = local_var_client.execute(local_var_req).await?;
601
602 let local_var_status = local_var_resp.status();
603 let local_var_content = local_var_resp.text().await?;
604
605 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
606 crate::from_str_patched(&local_var_content).map_err(Error::from)
607 } else {
608 let local_var_entity: Option<ListPostgresReplicationSlotError> = crate::from_str_patched(&local_var_content).ok();
609 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
610 Err(Error::ResponseError(local_var_error))
611 }
612}
613
614pub async fn list_postgres_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::PostgresTrigger>, Error<ListPostgresTriggersError>> {
615 let local_var_configuration = configuration;
616
617 let local_var_client = &local_var_configuration.client;
618
619 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
620 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
621
622 if let Some(ref local_var_str) = page {
623 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
624 }
625 if let Some(ref local_var_str) = per_page {
626 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
627 }
628 if let Some(ref local_var_str) = path {
629 local_var_req_builder = local_var_req_builder.query(&[("path", &local_var_str.to_string())]);
630 }
631 if let Some(ref local_var_str) = is_flow {
632 local_var_req_builder = local_var_req_builder.query(&[("is_flow", &local_var_str.to_string())]);
633 }
634 if let Some(ref local_var_str) = path_start {
635 local_var_req_builder = local_var_req_builder.query(&[("path_start", &local_var_str.to_string())]);
636 }
637 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
638 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
639 }
640 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
641 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
642 };
643
644 let local_var_req = local_var_req_builder.build()?;
645 let local_var_resp = local_var_client.execute(local_var_req).await?;
646
647 let local_var_status = local_var_resp.status();
648 let local_var_content = local_var_resp.text().await?;
649
650 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
651 crate::from_str_patched(&local_var_content).map_err(Error::from)
652 } else {
653 let local_var_entity: Option<ListPostgresTriggersError> = crate::from_str_patched(&local_var_content).ok();
654 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
655 Err(Error::ResponseError(local_var_error))
656 }
657}
658
659pub async fn set_postgres_trigger_enabled(configuration: &configuration::Configuration, workspace: &str, path: &str, set_schedule_enabled_request: models::SetScheduleEnabledRequest) -> Result<String, Error<SetPostgresTriggerEnabledError>> {
660 let local_var_configuration = configuration;
661
662 let local_var_client = &local_var_configuration.client;
663
664 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/setenabled/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
665 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
666
667 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
668 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
669 }
670 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
671 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
672 };
673 local_var_req_builder = local_var_req_builder.json(&set_schedule_enabled_request);
674
675 let local_var_req = local_var_req_builder.build()?;
676 let local_var_resp = local_var_client.execute(local_var_req).await?;
677
678 let local_var_status = local_var_resp.status();
679 let local_var_content = local_var_resp.text().await?;
680
681 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
682 crate::from_str_patched(&local_var_content).map_err(Error::from)
683 } else {
684 let local_var_entity: Option<SetPostgresTriggerEnabledError> = crate::from_str_patched(&local_var_content).ok();
685 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
686 Err(Error::ResponseError(local_var_error))
687 }
688}
689
690pub async fn test_postgres_connection(configuration: &configuration::Configuration, workspace: &str, test_postgres_connection_request: models::TestPostgresConnectionRequest) -> Result<String, Error<TestPostgresConnectionError>> {
691 let local_var_configuration = configuration;
692
693 let local_var_client = &local_var_configuration.client;
694
695 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/test", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
696 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
697
698 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
699 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
700 }
701 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
702 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
703 };
704 local_var_req_builder = local_var_req_builder.json(&test_postgres_connection_request);
705
706 let local_var_req = local_var_req_builder.build()?;
707 let local_var_resp = local_var_client.execute(local_var_req).await?;
708
709 let local_var_status = local_var_resp.status();
710 let local_var_content = local_var_resp.text().await?;
711
712 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
713 crate::from_str_patched(&local_var_content).map_err(Error::from)
714 } else {
715 let local_var_entity: Option<TestPostgresConnectionError> = crate::from_str_patched(&local_var_content).ok();
716 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
717 Err(Error::ResponseError(local_var_error))
718 }
719}
720
721pub async fn update_postgres_publication(configuration: &configuration::Configuration, workspace: &str, path: &str, publication: &str, publication_data: models::PublicationData) -> Result<String, Error<UpdatePostgresPublicationError>> {
722 let local_var_configuration = configuration;
723
724 let local_var_client = &local_var_configuration.client;
725
726 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/publication/update/{publication}/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path), publication=crate::apis::urlencode(publication));
727 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
728
729 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
730 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
731 }
732 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
733 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
734 };
735 local_var_req_builder = local_var_req_builder.json(&publication_data);
736
737 let local_var_req = local_var_req_builder.build()?;
738 let local_var_resp = local_var_client.execute(local_var_req).await?;
739
740 let local_var_status = local_var_resp.status();
741 let local_var_content = local_var_resp.text().await?;
742
743 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
744 crate::from_str_patched(&local_var_content).map_err(Error::from)
745 } else {
746 let local_var_entity: Option<UpdatePostgresPublicationError> = crate::from_str_patched(&local_var_content).ok();
747 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
748 Err(Error::ResponseError(local_var_error))
749 }
750}
751
752pub async fn update_postgres_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str, edit_postgres_trigger: models::EditPostgresTrigger) -> Result<String, Error<UpdatePostgresTriggerError>> {
753 let local_var_configuration = configuration;
754
755 let local_var_client = &local_var_configuration.client;
756
757 let local_var_uri_str = format!("{}/w/{workspace}/postgres_triggers/update/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
758 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
759
760 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
761 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
762 }
763 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
764 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
765 };
766 local_var_req_builder = local_var_req_builder.json(&edit_postgres_trigger);
767
768 let local_var_req = local_var_req_builder.build()?;
769 let local_var_resp = local_var_client.execute(local_var_req).await?;
770
771 let local_var_status = local_var_resp.status();
772 let local_var_content = local_var_resp.text().await?;
773
774 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
775 crate::from_str_patched(&local_var_content).map_err(Error::from)
776 } else {
777 let local_var_entity: Option<UpdatePostgresTriggerError> = crate::from_str_patched(&local_var_content).ok();
778 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
779 Err(Error::ResponseError(local_var_error))
780 }
781}
782