harbor_api/apis/
webhook_api.rs

1/*
2 * Harbor API
3 *
4 * These APIs provide services for manipulating Harbor project.
5 *
6 * The version of the OpenAPI document: 2.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`create_webhook_policy_of_project`]
18#[derive(Clone, Debug)]
19pub struct CreateWebhookPolicyOfProjectParams {
20    /// The name or id of the project
21    pub project_name_or_id: String,
22    /// Properties \"targets\" and \"event_types\" needed.
23    pub policy: models::WebhookPolicy,
24    /// An unique ID for the request
25    pub x_request_id: Option<String>,
26    /// The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.
27    pub x_is_resource_name: Option<bool>
28}
29
30/// struct for passing parameters to the method [`delete_webhook_policy_of_project`]
31#[derive(Clone, Debug)]
32pub struct DeleteWebhookPolicyOfProjectParams {
33    /// The name or id of the project
34    pub project_name_or_id: String,
35    /// The ID of the webhook policy
36    pub webhook_policy_id: i64,
37    /// An unique ID for the request
38    pub x_request_id: Option<String>,
39    /// The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.
40    pub x_is_resource_name: Option<bool>
41}
42
43/// struct for passing parameters to the method [`get_logs_of_webhook_task`]
44#[derive(Clone, Debug)]
45pub struct GetLogsOfWebhookTaskParams {
46    /// The name or id of the project
47    pub project_name_or_id: String,
48    /// The ID of the webhook policy
49    pub webhook_policy_id: i64,
50    /// Execution ID
51    pub execution_id: i32,
52    /// Task ID
53    pub task_id: i32,
54    /// An unique ID for the request
55    pub x_request_id: Option<String>,
56    /// The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.
57    pub x_is_resource_name: Option<bool>
58}
59
60/// struct for passing parameters to the method [`get_supported_event_types`]
61#[derive(Clone, Debug)]
62pub struct GetSupportedEventTypesParams {
63    /// The name or id of the project
64    pub project_name_or_id: String,
65    /// An unique ID for the request
66    pub x_request_id: Option<String>,
67    /// The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.
68    pub x_is_resource_name: Option<bool>
69}
70
71/// struct for passing parameters to the method [`get_webhook_policy_of_project`]
72#[derive(Clone, Debug)]
73pub struct GetWebhookPolicyOfProjectParams {
74    /// The name or id of the project
75    pub project_name_or_id: String,
76    /// The ID of the webhook policy
77    pub webhook_policy_id: i64,
78    /// An unique ID for the request
79    pub x_request_id: Option<String>,
80    /// The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.
81    pub x_is_resource_name: Option<bool>
82}
83
84/// struct for passing parameters to the method [`last_trigger`]
85#[derive(Clone, Debug)]
86pub struct LastTriggerParams {
87    /// The name or id of the project
88    pub project_name_or_id: String,
89    /// An unique ID for the request
90    pub x_request_id: Option<String>,
91    /// The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.
92    pub x_is_resource_name: Option<bool>
93}
94
95/// struct for passing parameters to the method [`list_executions_of_webhook_policy`]
96#[derive(Clone, Debug)]
97pub struct ListExecutionsOfWebhookPolicyParams {
98    /// The name or id of the project
99    pub project_name_or_id: String,
100    /// The ID of the webhook policy
101    pub webhook_policy_id: i64,
102    /// An unique ID for the request
103    pub x_request_id: Option<String>,
104    /// The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.
105    pub x_is_resource_name: Option<bool>,
106    /// The page number
107    pub page: Option<i64>,
108    /// The size of per page
109    pub page_size: Option<i64>,
110    /// Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]
111    pub q: Option<String>,
112    /// Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with \"sort=field1,-field2\"
113    pub sort: Option<String>
114}
115
116/// struct for passing parameters to the method [`list_tasks_of_webhook_execution`]
117#[derive(Clone, Debug)]
118pub struct ListTasksOfWebhookExecutionParams {
119    /// The name or id of the project
120    pub project_name_or_id: String,
121    /// The ID of the webhook policy
122    pub webhook_policy_id: i64,
123    /// Execution ID
124    pub execution_id: i32,
125    /// An unique ID for the request
126    pub x_request_id: Option<String>,
127    /// The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.
128    pub x_is_resource_name: Option<bool>,
129    /// The page number
130    pub page: Option<i64>,
131    /// The size of per page
132    pub page_size: Option<i64>,
133    /// Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]
134    pub q: Option<String>,
135    /// Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with \"sort=field1,-field2\"
136    pub sort: Option<String>
137}
138
139/// struct for passing parameters to the method [`list_webhook_policies_of_project`]
140#[derive(Clone, Debug)]
141pub struct ListWebhookPoliciesOfProjectParams {
142    /// The name or id of the project
143    pub project_name_or_id: String,
144    /// An unique ID for the request
145    pub x_request_id: Option<String>,
146    /// The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.
147    pub x_is_resource_name: Option<bool>,
148    /// Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with \"sort=field1,-field2\"
149    pub sort: Option<String>,
150    /// Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]
151    pub q: Option<String>,
152    /// The page number
153    pub page: Option<i64>,
154    /// The size of per page
155    pub page_size: Option<i64>
156}
157
158/// struct for passing parameters to the method [`update_webhook_policy_of_project`]
159#[derive(Clone, Debug)]
160pub struct UpdateWebhookPolicyOfProjectParams {
161    /// The name or id of the project
162    pub project_name_or_id: String,
163    /// The ID of the webhook policy
164    pub webhook_policy_id: i64,
165    /// All properties needed except \"id\", \"project_id\", \"creation_time\", \"update_time\".
166    pub policy: models::WebhookPolicy,
167    /// An unique ID for the request
168    pub x_request_id: Option<String>,
169    /// The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.
170    pub x_is_resource_name: Option<bool>
171}
172
173
174/// struct for typed errors of method [`create_webhook_policy_of_project`]
175#[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/// struct for typed errors of method [`delete_webhook_policy_of_project`]
186#[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/// struct for typed errors of method [`get_logs_of_webhook_task`]
198#[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/// struct for typed errors of method [`get_supported_event_types`]
210#[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/// struct for typed errors of method [`get_webhook_policy_of_project`]
220#[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/// struct for typed errors of method [`last_trigger`]
232#[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/// struct for typed errors of method [`list_executions_of_webhook_policy`]
243#[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/// struct for typed errors of method [`list_tasks_of_webhook_execution`]
255#[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/// struct for typed errors of method [`list_webhook_policies_of_project`]
267#[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/// struct for typed errors of method [`update_webhook_policy_of_project`]
278#[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
290/// This endpoint create a webhook policy if the project does not have one. 
291pub 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(&params.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
324/// This endpoint is aimed to delete webhookpolicy of a project. 
325pub 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
357/// This endpoint returns the logs of a specific webhook task. 
358pub 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
401/// Get supported event types and notify types.
402pub 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
445/// This endpoint returns specified webhook policy of a project. 
446pub 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/// This endpoint returns last trigger information of project webhook policy. 
490#[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&lt;models::WebhookLastTrigger&gt;`"))),
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&lt;models::WebhookLastTrigger&gt;`")))),
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
534/// This endpoint returns the executions of a specific webhook policy. 
535pub 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", &param_value.to_string())]);
542    }
543    if let Some(ref param_value) = params.page_size {
544        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
545    }
546    if let Some(ref param_value) = params.q {
547        req_builder = req_builder.query(&[("q", &param_value.to_string())]);
548    }
549    if let Some(ref param_value) = params.sort {
550        req_builder = req_builder.query(&[("sort", &param_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&lt;models::Execution&gt;`"))),
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&lt;models::Execution&gt;`")))),
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
590/// This endpoint returns the tasks of a specific webhook execution. 
591pub 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", &param_value.to_string())]);
598    }
599    if let Some(ref param_value) = params.page_size {
600        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
601    }
602    if let Some(ref param_value) = params.q {
603        req_builder = req_builder.query(&[("q", &param_value.to_string())]);
604    }
605    if let Some(ref param_value) = params.sort {
606        req_builder = req_builder.query(&[("sort", &param_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&lt;models::Task&gt;`"))),
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&lt;models::Task&gt;`")))),
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
646/// This endpoint returns webhook policies of a project. 
647pub 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", &param_value.to_string())]);
654    }
655    if let Some(ref param_value) = params.q {
656        req_builder = req_builder.query(&[("q", &param_value.to_string())]);
657    }
658    if let Some(ref param_value) = params.page {
659        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
660    }
661    if let Some(ref param_value) = params.page_size {
662        req_builder = req_builder.query(&[("page_size", &param_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&lt;models::WebhookPolicy&gt;`"))),
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&lt;models::WebhookPolicy&gt;`")))),
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
702/// This endpoint is aimed to update the webhook policy of a project. 
703pub 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(&params.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