1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17#[derive(Clone, Debug)]
19pub struct CreateWebhookPolicyOfProjectParams {
20 pub project_name_or_id: String,
22 pub policy: models::WebhookPolicy,
24 pub x_request_id: Option<String>,
26 pub x_is_resource_name: Option<bool>
28}
29
30#[derive(Clone, Debug)]
32pub struct DeleteWebhookPolicyOfProjectParams {
33 pub project_name_or_id: String,
35 pub webhook_policy_id: i64,
37 pub x_request_id: Option<String>,
39 pub x_is_resource_name: Option<bool>
41}
42
43#[derive(Clone, Debug)]
45pub struct GetLogsOfWebhookTaskParams {
46 pub project_name_or_id: String,
48 pub webhook_policy_id: i64,
50 pub execution_id: i32,
52 pub task_id: i32,
54 pub x_request_id: Option<String>,
56 pub x_is_resource_name: Option<bool>
58}
59
60#[derive(Clone, Debug)]
62pub struct GetSupportedEventTypesParams {
63 pub project_name_or_id: String,
65 pub x_request_id: Option<String>,
67 pub x_is_resource_name: Option<bool>
69}
70
71#[derive(Clone, Debug)]
73pub struct GetWebhookPolicyOfProjectParams {
74 pub project_name_or_id: String,
76 pub webhook_policy_id: i64,
78 pub x_request_id: Option<String>,
80 pub x_is_resource_name: Option<bool>
82}
83
84#[derive(Clone, Debug)]
86pub struct LastTriggerParams {
87 pub project_name_or_id: String,
89 pub x_request_id: Option<String>,
91 pub x_is_resource_name: Option<bool>
93}
94
95#[derive(Clone, Debug)]
97pub struct ListExecutionsOfWebhookPolicyParams {
98 pub project_name_or_id: String,
100 pub webhook_policy_id: i64,
102 pub x_request_id: Option<String>,
104 pub x_is_resource_name: Option<bool>,
106 pub page: Option<i64>,
108 pub page_size: Option<i64>,
110 pub q: Option<String>,
112 pub sort: Option<String>
114}
115
116#[derive(Clone, Debug)]
118pub struct ListTasksOfWebhookExecutionParams {
119 pub project_name_or_id: String,
121 pub webhook_policy_id: i64,
123 pub execution_id: i32,
125 pub x_request_id: Option<String>,
127 pub x_is_resource_name: Option<bool>,
129 pub page: Option<i64>,
131 pub page_size: Option<i64>,
133 pub q: Option<String>,
135 pub sort: Option<String>
137}
138
139#[derive(Clone, Debug)]
141pub struct ListWebhookPoliciesOfProjectParams {
142 pub project_name_or_id: String,
144 pub x_request_id: Option<String>,
146 pub x_is_resource_name: Option<bool>,
148 pub sort: Option<String>,
150 pub q: Option<String>,
152 pub page: Option<i64>,
154 pub page_size: Option<i64>
156}
157
158#[derive(Clone, Debug)]
160pub struct UpdateWebhookPolicyOfProjectParams {
161 pub project_name_or_id: String,
163 pub webhook_policy_id: i64,
165 pub policy: models::WebhookPolicy,
167 pub x_request_id: Option<String>,
169 pub x_is_resource_name: Option<bool>
171}
172
173
174#[derive(Debug, Clone, Serialize, Deserialize)]
176#[serde(untagged)]
177pub enum CreateWebhookPolicyOfProjectError {
178 Status400(models::Errors),
179 Status401(models::Errors),
180 Status403(models::Errors),
181 Status500(models::Errors),
182 UnknownValue(serde_json::Value),
183}
184
185#[derive(Debug, Clone, Serialize, Deserialize)]
187#[serde(untagged)]
188pub enum DeleteWebhookPolicyOfProjectError {
189 Status400(models::Errors),
190 Status401(models::Errors),
191 Status403(models::Errors),
192 Status404(models::Errors),
193 Status500(models::Errors),
194 UnknownValue(serde_json::Value),
195}
196
197#[derive(Debug, Clone, Serialize, Deserialize)]
199#[serde(untagged)]
200pub enum GetLogsOfWebhookTaskError {
201 Status400(models::Errors),
202 Status401(models::Errors),
203 Status403(models::Errors),
204 Status404(models::Errors),
205 Status500(models::Errors),
206 UnknownValue(serde_json::Value),
207}
208
209#[derive(Debug, Clone, Serialize, Deserialize)]
211#[serde(untagged)]
212pub enum GetSupportedEventTypesError {
213 Status401(models::Errors),
214 Status403(models::Errors),
215 Status500(models::Errors),
216 UnknownValue(serde_json::Value),
217}
218
219#[derive(Debug, Clone, Serialize, Deserialize)]
221#[serde(untagged)]
222pub enum GetWebhookPolicyOfProjectError {
223 Status400(models::Errors),
224 Status401(models::Errors),
225 Status403(models::Errors),
226 Status404(models::Errors),
227 Status500(models::Errors),
228 UnknownValue(serde_json::Value),
229}
230
231#[derive(Debug, Clone, Serialize, Deserialize)]
233#[serde(untagged)]
234pub enum LastTriggerError {
235 Status400(models::Errors),
236 Status401(models::Errors),
237 Status403(models::Errors),
238 Status500(models::Errors),
239 UnknownValue(serde_json::Value),
240}
241
242#[derive(Debug, Clone, Serialize, Deserialize)]
244#[serde(untagged)]
245pub enum ListExecutionsOfWebhookPolicyError {
246 Status400(models::Errors),
247 Status401(models::Errors),
248 Status403(models::Errors),
249 Status404(models::Errors),
250 Status500(models::Errors),
251 UnknownValue(serde_json::Value),
252}
253
254#[derive(Debug, Clone, Serialize, Deserialize)]
256#[serde(untagged)]
257pub enum ListTasksOfWebhookExecutionError {
258 Status400(models::Errors),
259 Status401(models::Errors),
260 Status403(models::Errors),
261 Status404(models::Errors),
262 Status500(models::Errors),
263 UnknownValue(serde_json::Value),
264}
265
266#[derive(Debug, Clone, Serialize, Deserialize)]
268#[serde(untagged)]
269pub enum ListWebhookPoliciesOfProjectError {
270 Status400(models::Errors),
271 Status401(models::Errors),
272 Status403(models::Errors),
273 Status500(models::Errors),
274 UnknownValue(serde_json::Value),
275}
276
277#[derive(Debug, Clone, Serialize, Deserialize)]
279#[serde(untagged)]
280pub enum UpdateWebhookPolicyOfProjectError {
281 Status400(models::Errors),
282 Status401(models::Errors),
283 Status403(models::Errors),
284 Status404(models::Errors),
285 Status500(models::Errors),
286 UnknownValue(serde_json::Value),
287}
288
289
290pub async fn create_webhook_policy_of_project(configuration: &configuration::Configuration, params: CreateWebhookPolicyOfProjectParams) -> Result<(), Error<CreateWebhookPolicyOfProjectError>> {
292
293 let uri_str = format!("{}/projects/{project_name_or_id}/webhook/policies", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
294 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
295
296 if let Some(ref user_agent) = configuration.user_agent {
297 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
298 }
299 if let Some(param_value) = params.x_request_id {
300 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
301 }
302 if let Some(param_value) = params.x_is_resource_name {
303 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
304 }
305 if let Some(ref auth_conf) = configuration.basic_auth {
306 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
307 };
308 req_builder = req_builder.json(¶ms.policy);
309
310 let req = req_builder.build()?;
311 let resp = configuration.client.execute(req).await?;
312
313 let status = resp.status();
314
315 if !status.is_client_error() && !status.is_server_error() {
316 Ok(())
317 } else {
318 let content = resp.text().await?;
319 let entity: Option<CreateWebhookPolicyOfProjectError> = serde_json::from_str(&content).ok();
320 Err(Error::ResponseError(ResponseContent { status, content, entity }))
321 }
322}
323
324pub async fn delete_webhook_policy_of_project(configuration: &configuration::Configuration, params: DeleteWebhookPolicyOfProjectParams) -> Result<(), Error<DeleteWebhookPolicyOfProjectError>> {
326
327 let uri_str = format!("{}/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id), webhook_policy_id=params.webhook_policy_id);
328 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
329
330 if let Some(ref user_agent) = configuration.user_agent {
331 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
332 }
333 if let Some(param_value) = params.x_request_id {
334 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
335 }
336 if let Some(param_value) = params.x_is_resource_name {
337 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
338 }
339 if let Some(ref auth_conf) = configuration.basic_auth {
340 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
341 };
342
343 let req = req_builder.build()?;
344 let resp = configuration.client.execute(req).await?;
345
346 let status = resp.status();
347
348 if !status.is_client_error() && !status.is_server_error() {
349 Ok(())
350 } else {
351 let content = resp.text().await?;
352 let entity: Option<DeleteWebhookPolicyOfProjectError> = serde_json::from_str(&content).ok();
353 Err(Error::ResponseError(ResponseContent { status, content, entity }))
354 }
355}
356
357pub async fn get_logs_of_webhook_task(configuration: &configuration::Configuration, params: GetLogsOfWebhookTaskParams) -> Result<String, Error<GetLogsOfWebhookTaskError>> {
359
360 let uri_str = format!("{}/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks/{task_id}/log", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id), webhook_policy_id=params.webhook_policy_id, execution_id=params.execution_id, task_id=params.task_id);
361 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
362
363 if let Some(ref user_agent) = configuration.user_agent {
364 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
365 }
366 if let Some(param_value) = params.x_request_id {
367 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
368 }
369 if let Some(param_value) = params.x_is_resource_name {
370 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
371 }
372 if let Some(ref auth_conf) = configuration.basic_auth {
373 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
374 };
375
376 let req = req_builder.build()?;
377 let resp = configuration.client.execute(req).await?;
378
379 let status = resp.status();
380 let content_type = resp
381 .headers()
382 .get("content-type")
383 .and_then(|v| v.to_str().ok())
384 .unwrap_or("application/octet-stream");
385 let content_type = super::ContentType::from(content_type);
386
387 if !status.is_client_error() && !status.is_server_error() {
388 let content = resp.text().await?;
389 match content_type {
390 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
391 ContentType::Text => return Ok(content),
392 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
393 }
394 } else {
395 let content = resp.text().await?;
396 let entity: Option<GetLogsOfWebhookTaskError> = serde_json::from_str(&content).ok();
397 Err(Error::ResponseError(ResponseContent { status, content, entity }))
398 }
399}
400
401pub async fn get_supported_event_types(configuration: &configuration::Configuration, params: GetSupportedEventTypesParams) -> Result<models::SupportedWebhookEventTypes, Error<GetSupportedEventTypesError>> {
403
404 let uri_str = format!("{}/projects/{project_name_or_id}/webhook/events", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
405 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
406
407 if let Some(ref user_agent) = configuration.user_agent {
408 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
409 }
410 if let Some(param_value) = params.x_request_id {
411 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
412 }
413 if let Some(param_value) = params.x_is_resource_name {
414 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
415 }
416 if let Some(ref auth_conf) = configuration.basic_auth {
417 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
418 };
419
420 let req = req_builder.build()?;
421 let resp = configuration.client.execute(req).await?;
422
423 let status = resp.status();
424 let content_type = resp
425 .headers()
426 .get("content-type")
427 .and_then(|v| v.to_str().ok())
428 .unwrap_or("application/octet-stream");
429 let content_type = super::ContentType::from(content_type);
430
431 if !status.is_client_error() && !status.is_server_error() {
432 let content = resp.text().await?;
433 match content_type {
434 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
435 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SupportedWebhookEventTypes`"))),
436 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SupportedWebhookEventTypes`")))),
437 }
438 } else {
439 let content = resp.text().await?;
440 let entity: Option<GetSupportedEventTypesError> = serde_json::from_str(&content).ok();
441 Err(Error::ResponseError(ResponseContent { status, content, entity }))
442 }
443}
444
445pub async fn get_webhook_policy_of_project(configuration: &configuration::Configuration, params: GetWebhookPolicyOfProjectParams) -> Result<models::WebhookPolicy, Error<GetWebhookPolicyOfProjectError>> {
447
448 let uri_str = format!("{}/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id), webhook_policy_id=params.webhook_policy_id);
449 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
450
451 if let Some(ref user_agent) = configuration.user_agent {
452 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
453 }
454 if let Some(param_value) = params.x_request_id {
455 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
456 }
457 if let Some(param_value) = params.x_is_resource_name {
458 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
459 }
460 if let Some(ref auth_conf) = configuration.basic_auth {
461 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
462 };
463
464 let req = req_builder.build()?;
465 let resp = configuration.client.execute(req).await?;
466
467 let status = resp.status();
468 let content_type = resp
469 .headers()
470 .get("content-type")
471 .and_then(|v| v.to_str().ok())
472 .unwrap_or("application/octet-stream");
473 let content_type = super::ContentType::from(content_type);
474
475 if !status.is_client_error() && !status.is_server_error() {
476 let content = resp.text().await?;
477 match content_type {
478 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
479 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WebhookPolicy`"))),
480 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::WebhookPolicy`")))),
481 }
482 } else {
483 let content = resp.text().await?;
484 let entity: Option<GetWebhookPolicyOfProjectError> = serde_json::from_str(&content).ok();
485 Err(Error::ResponseError(ResponseContent { status, content, entity }))
486 }
487}
488
489#[deprecated]
491pub async fn last_trigger(configuration: &configuration::Configuration, params: LastTriggerParams) -> Result<Vec<models::WebhookLastTrigger>, Error<LastTriggerError>> {
492
493 let uri_str = format!("{}/projects/{project_name_or_id}/webhook/lasttrigger", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
494 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
495
496 if let Some(ref user_agent) = configuration.user_agent {
497 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
498 }
499 if let Some(param_value) = params.x_request_id {
500 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
501 }
502 if let Some(param_value) = params.x_is_resource_name {
503 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
504 }
505 if let Some(ref auth_conf) = configuration.basic_auth {
506 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
507 };
508
509 let req = req_builder.build()?;
510 let resp = configuration.client.execute(req).await?;
511
512 let status = resp.status();
513 let content_type = resp
514 .headers()
515 .get("content-type")
516 .and_then(|v| v.to_str().ok())
517 .unwrap_or("application/octet-stream");
518 let content_type = super::ContentType::from(content_type);
519
520 if !status.is_client_error() && !status.is_server_error() {
521 let content = resp.text().await?;
522 match content_type {
523 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
524 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::WebhookLastTrigger>`"))),
525 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::WebhookLastTrigger>`")))),
526 }
527 } else {
528 let content = resp.text().await?;
529 let entity: Option<LastTriggerError> = serde_json::from_str(&content).ok();
530 Err(Error::ResponseError(ResponseContent { status, content, entity }))
531 }
532}
533
534pub async fn list_executions_of_webhook_policy(configuration: &configuration::Configuration, params: ListExecutionsOfWebhookPolicyParams) -> Result<Vec<models::Execution>, Error<ListExecutionsOfWebhookPolicyError>> {
536
537 let uri_str = format!("{}/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id), webhook_policy_id=params.webhook_policy_id);
538 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
539
540 if let Some(ref param_value) = params.page {
541 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
542 }
543 if let Some(ref param_value) = params.page_size {
544 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
545 }
546 if let Some(ref param_value) = params.q {
547 req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
548 }
549 if let Some(ref param_value) = params.sort {
550 req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
551 }
552 if let Some(ref user_agent) = configuration.user_agent {
553 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
554 }
555 if let Some(param_value) = params.x_request_id {
556 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
557 }
558 if let Some(param_value) = params.x_is_resource_name {
559 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
560 }
561 if let Some(ref auth_conf) = configuration.basic_auth {
562 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
563 };
564
565 let req = req_builder.build()?;
566 let resp = configuration.client.execute(req).await?;
567
568 let status = resp.status();
569 let content_type = resp
570 .headers()
571 .get("content-type")
572 .and_then(|v| v.to_str().ok())
573 .unwrap_or("application/octet-stream");
574 let content_type = super::ContentType::from(content_type);
575
576 if !status.is_client_error() && !status.is_server_error() {
577 let content = resp.text().await?;
578 match content_type {
579 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
580 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Execution>`"))),
581 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Execution>`")))),
582 }
583 } else {
584 let content = resp.text().await?;
585 let entity: Option<ListExecutionsOfWebhookPolicyError> = serde_json::from_str(&content).ok();
586 Err(Error::ResponseError(ResponseContent { status, content, entity }))
587 }
588}
589
590pub async fn list_tasks_of_webhook_execution(configuration: &configuration::Configuration, params: ListTasksOfWebhookExecutionParams) -> Result<Vec<models::Task>, Error<ListTasksOfWebhookExecutionError>> {
592
593 let uri_str = format!("{}/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id), webhook_policy_id=params.webhook_policy_id, execution_id=params.execution_id);
594 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
595
596 if let Some(ref param_value) = params.page {
597 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
598 }
599 if let Some(ref param_value) = params.page_size {
600 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
601 }
602 if let Some(ref param_value) = params.q {
603 req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
604 }
605 if let Some(ref param_value) = params.sort {
606 req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
607 }
608 if let Some(ref user_agent) = configuration.user_agent {
609 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
610 }
611 if let Some(param_value) = params.x_request_id {
612 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
613 }
614 if let Some(param_value) = params.x_is_resource_name {
615 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
616 }
617 if let Some(ref auth_conf) = configuration.basic_auth {
618 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
619 };
620
621 let req = req_builder.build()?;
622 let resp = configuration.client.execute(req).await?;
623
624 let status = resp.status();
625 let content_type = resp
626 .headers()
627 .get("content-type")
628 .and_then(|v| v.to_str().ok())
629 .unwrap_or("application/octet-stream");
630 let content_type = super::ContentType::from(content_type);
631
632 if !status.is_client_error() && !status.is_server_error() {
633 let content = resp.text().await?;
634 match content_type {
635 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
636 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Task>`"))),
637 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Task>`")))),
638 }
639 } else {
640 let content = resp.text().await?;
641 let entity: Option<ListTasksOfWebhookExecutionError> = serde_json::from_str(&content).ok();
642 Err(Error::ResponseError(ResponseContent { status, content, entity }))
643 }
644}
645
646pub async fn list_webhook_policies_of_project(configuration: &configuration::Configuration, params: ListWebhookPoliciesOfProjectParams) -> Result<Vec<models::WebhookPolicy>, Error<ListWebhookPoliciesOfProjectError>> {
648
649 let uri_str = format!("{}/projects/{project_name_or_id}/webhook/policies", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
650 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
651
652 if let Some(ref param_value) = params.sort {
653 req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
654 }
655 if let Some(ref param_value) = params.q {
656 req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
657 }
658 if let Some(ref param_value) = params.page {
659 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
660 }
661 if let Some(ref param_value) = params.page_size {
662 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
663 }
664 if let Some(ref user_agent) = configuration.user_agent {
665 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
666 }
667 if let Some(param_value) = params.x_request_id {
668 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
669 }
670 if let Some(param_value) = params.x_is_resource_name {
671 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
672 }
673 if let Some(ref auth_conf) = configuration.basic_auth {
674 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
675 };
676
677 let req = req_builder.build()?;
678 let resp = configuration.client.execute(req).await?;
679
680 let status = resp.status();
681 let content_type = resp
682 .headers()
683 .get("content-type")
684 .and_then(|v| v.to_str().ok())
685 .unwrap_or("application/octet-stream");
686 let content_type = super::ContentType::from(content_type);
687
688 if !status.is_client_error() && !status.is_server_error() {
689 let content = resp.text().await?;
690 match content_type {
691 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
692 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::WebhookPolicy>`"))),
693 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::WebhookPolicy>`")))),
694 }
695 } else {
696 let content = resp.text().await?;
697 let entity: Option<ListWebhookPoliciesOfProjectError> = serde_json::from_str(&content).ok();
698 Err(Error::ResponseError(ResponseContent { status, content, entity }))
699 }
700}
701
702pub async fn update_webhook_policy_of_project(configuration: &configuration::Configuration, params: UpdateWebhookPolicyOfProjectParams) -> Result<(), Error<UpdateWebhookPolicyOfProjectError>> {
704
705 let uri_str = format!("{}/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id), webhook_policy_id=params.webhook_policy_id);
706 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
707
708 if let Some(ref user_agent) = configuration.user_agent {
709 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
710 }
711 if let Some(param_value) = params.x_request_id {
712 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
713 }
714 if let Some(param_value) = params.x_is_resource_name {
715 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
716 }
717 if let Some(ref auth_conf) = configuration.basic_auth {
718 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
719 };
720 req_builder = req_builder.json(¶ms.policy);
721
722 let req = req_builder.build()?;
723 let resp = configuration.client.execute(req).await?;
724
725 let status = resp.status();
726
727 if !status.is_client_error() && !status.is_server_error() {
728 Ok(())
729 } else {
730 let content = resp.text().await?;
731 let entity: Option<UpdateWebhookPolicyOfProjectError> = serde_json::from_str(&content).ok();
732 Err(Error::ResponseError(ResponseContent { status, content, entity }))
733 }
734}
735