harbor_api/apis/
webhookjob_api.rs1use 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 ListWebhookJobsParams {
20 pub project_name_or_id: String,
22 pub policy_id: i64,
24 pub x_request_id: Option<String>,
26 pub x_is_resource_name: Option<bool>,
28 pub q: Option<String>,
30 pub sort: Option<String>,
32 pub page: Option<i64>,
34 pub page_size: Option<i64>,
36 pub status: Option<Vec<String>>
38}
39
40
41#[derive(Debug, Clone, Serialize, Deserialize)]
43#[serde(untagged)]
44pub enum ListWebhookJobsError {
45 Status400(models::Errors),
46 Status401(models::Errors),
47 Status403(models::Errors),
48 Status500(models::Errors),
49 UnknownValue(serde_json::Value),
50}
51
52
53#[deprecated]
55pub async fn list_webhook_jobs(configuration: &configuration::Configuration, params: ListWebhookJobsParams) -> Result<Vec<models::WebhookJob>, Error<ListWebhookJobsError>> {
56
57 let uri_str = format!("{}/projects/{project_name_or_id}/webhook/jobs", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
58 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
59
60 if let Some(ref param_value) = params.q {
61 req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
62 }
63 if let Some(ref param_value) = params.sort {
64 req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
65 }
66 if let Some(ref param_value) = params.page {
67 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
68 }
69 if let Some(ref param_value) = params.page_size {
70 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
71 }
72 req_builder = req_builder.query(&[("policy_id", ¶ms.policy_id.to_string())]);
73 if let Some(ref param_value) = params.status {
74 req_builder = match "csv" {
75 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
76 _ => req_builder.query(&[("status", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
77 };
78 }
79 if let Some(ref user_agent) = configuration.user_agent {
80 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
81 }
82 if let Some(param_value) = params.x_request_id {
83 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
84 }
85 if let Some(param_value) = params.x_is_resource_name {
86 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
87 }
88 if let Some(ref auth_conf) = configuration.basic_auth {
89 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
90 };
91
92 let req = req_builder.build()?;
93 let resp = configuration.client.execute(req).await?;
94
95 let status = resp.status();
96 let content_type = resp
97 .headers()
98 .get("content-type")
99 .and_then(|v| v.to_str().ok())
100 .unwrap_or("application/octet-stream");
101 let content_type = super::ContentType::from(content_type);
102
103 if !status.is_client_error() && !status.is_server_error() {
104 let content = resp.text().await?;
105 match content_type {
106 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
107 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::WebhookJob>`"))),
108 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::WebhookJob>`")))),
109 }
110 } else {
111 let content = resp.text().await?;
112 let entity: Option<ListWebhookJobsError> = serde_json::from_str(&content).ok();
113 Err(Error::ResponseError(ResponseContent { status, content, entity }))
114 }
115}
116