harbor_api/apis/
project_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_project`]
18#[derive(Clone, Debug)]
19pub struct CreateProjectParams {
20    /// New created project.
21    pub project: models::ProjectReq,
22    /// An unique ID for the request
23    pub x_request_id: Option<String>,
24    /// The flag to indicate whether to return the name of the resource in Location. When X-Resource-Name-In-Location is true, the Location will return the name of the resource.
25    pub x_resource_name_in_location: Option<bool>
26}
27
28/// struct for passing parameters to the method [`delete_project`]
29#[derive(Clone, Debug)]
30pub struct DeleteProjectParams {
31    /// The name or id of the project
32    pub project_name_or_id: String,
33    /// An unique ID for the request
34    pub x_request_id: Option<String>,
35    /// 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.
36    pub x_is_resource_name: Option<bool>
37}
38
39/// struct for passing parameters to the method [`get_logs`]
40#[derive(Clone, Debug)]
41pub struct GetLogsParams {
42    /// The name of the project
43    pub project_name: String,
44    /// An unique ID for the request
45    pub x_request_id: Option<String>,
46    /// 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]
47    pub q: Option<String>,
48    /// 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\"
49    pub sort: Option<String>,
50    /// The page number
51    pub page: Option<i64>,
52    /// The size of per page
53    pub page_size: Option<i64>
54}
55
56/// struct for passing parameters to the method [`get_project`]
57#[derive(Clone, Debug)]
58pub struct GetProjectParams {
59    /// The name or id of the project
60    pub project_name_or_id: String,
61    /// An unique ID for the request
62    pub x_request_id: Option<String>,
63    /// 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.
64    pub x_is_resource_name: Option<bool>
65}
66
67/// struct for passing parameters to the method [`get_project_deletable`]
68#[derive(Clone, Debug)]
69pub struct GetProjectDeletableParams {
70    /// The name or id of the project
71    pub project_name_or_id: String,
72    /// An unique ID for the request
73    pub x_request_id: Option<String>,
74    /// 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.
75    pub x_is_resource_name: Option<bool>
76}
77
78/// struct for passing parameters to the method [`get_project_summary`]
79#[derive(Clone, Debug)]
80pub struct GetProjectSummaryParams {
81    /// The name or id of the project
82    pub project_name_or_id: String,
83    /// An unique ID for the request
84    pub x_request_id: Option<String>,
85    /// 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.
86    pub x_is_resource_name: Option<bool>
87}
88
89/// struct for passing parameters to the method [`get_scanner_of_project`]
90#[derive(Clone, Debug)]
91pub struct GetScannerOfProjectParams {
92    /// The name or id of the project
93    pub project_name_or_id: String,
94    /// An unique ID for the request
95    pub x_request_id: Option<String>,
96    /// 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.
97    pub x_is_resource_name: Option<bool>
98}
99
100/// struct for passing parameters to the method [`head_project`]
101#[derive(Clone, Debug)]
102pub struct HeadProjectParams {
103    /// Project name for checking exists.
104    pub project_name: String,
105    /// An unique ID for the request
106    pub x_request_id: Option<String>
107}
108
109/// struct for passing parameters to the method [`list_artifacts_of_project`]
110#[derive(Clone, Debug)]
111pub struct ListArtifactsOfProjectParams {
112    /// The name or id of the project
113    pub project_name_or_id: String,
114    /// An unique ID for the request
115    pub x_request_id: Option<String>,
116    /// 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.
117    pub x_is_resource_name: Option<bool>,
118    /// 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]
119    pub q: Option<String>,
120    /// 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\"
121    pub sort: Option<String>,
122    /// The page number
123    pub page: Option<i64>,
124    /// The size of per page
125    pub page_size: Option<i64>,
126    /// A comma-separated lists of MIME types for the scan report or scan summary. The first mime type will be used when the report found for it. Currently the mime type supports 'application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0' and 'application/vnd.security.vulnerability.report; version=1.1'
127    pub x_accept_vulnerabilities: Option<String>,
128    /// Specify whether the tags are included inside the returning artifacts
129    pub with_tag: Option<bool>,
130    /// Specify whether the labels are included inside the returning artifacts
131    pub with_label: Option<bool>,
132    /// Specify whether the scan overview is included inside the returning artifacts
133    pub with_scan_overview: Option<bool>,
134    /// Specify whether the SBOM overview is included in returning artifacts, when this option is true, the SBOM overview will be included in the response
135    pub with_sbom_overview: Option<bool>,
136    /// Specify whether the immutable status is included inside the tags of the returning artifacts. Only works when setting \"with_immutable_status=true\"
137    pub with_immutable_status: Option<bool>,
138    /// Specify whether the accessories are included of the returning artifacts. Only works when setting \"with_accessory=true\"
139    pub with_accessory: Option<bool>,
140    /// Specify whether only the latest pushed artifact of each repository is included inside the returning artifacts. Only works when either artifact_type or media_type is included in the query.
141    pub latest_in_repository: Option<bool>
142}
143
144/// struct for passing parameters to the method [`list_projects`]
145#[derive(Clone, Debug)]
146pub struct ListProjectsParams {
147    /// An unique ID for the request
148    pub x_request_id: Option<String>,
149    /// 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]
150    pub q: Option<String>,
151    /// The page number
152    pub page: Option<i64>,
153    /// The size of per page
154    pub page_size: Option<i64>,
155    /// 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\"
156    pub sort: Option<String>,
157    /// The name of project.
158    pub name: Option<String>,
159    /// The project is public or private.
160    pub public: Option<bool>,
161    /// The name of project owner.
162    pub owner: Option<String>,
163    /// Bool value indicating whether return detailed information of the project
164    pub with_detail: Option<bool>
165}
166
167/// struct for passing parameters to the method [`list_scanner_candidates_of_project`]
168#[derive(Clone, Debug)]
169pub struct ListScannerCandidatesOfProjectParams {
170    /// The name or id of the project
171    pub project_name_or_id: String,
172    /// An unique ID for the request
173    pub x_request_id: Option<String>,
174    /// 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.
175    pub x_is_resource_name: Option<bool>,
176    /// 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]
177    pub q: Option<String>,
178    /// 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\"
179    pub sort: Option<String>,
180    /// The page number
181    pub page: Option<i64>,
182    /// The size of per page
183    pub page_size: Option<i64>
184}
185
186/// struct for passing parameters to the method [`set_scanner_of_project`]
187#[derive(Clone, Debug)]
188pub struct SetScannerOfProjectParams {
189    /// The name or id of the project
190    pub project_name_or_id: String,
191    pub payload: models::ProjectScanner,
192    /// An unique ID for the request
193    pub x_request_id: Option<String>,
194    /// 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.
195    pub x_is_resource_name: Option<bool>
196}
197
198/// struct for passing parameters to the method [`update_project`]
199#[derive(Clone, Debug)]
200pub struct UpdateProjectParams {
201    /// The name or id of the project
202    pub project_name_or_id: String,
203    /// Updates of project.
204    pub project: models::ProjectReq,
205    /// An unique ID for the request
206    pub x_request_id: Option<String>,
207    /// 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.
208    pub x_is_resource_name: Option<bool>
209}
210
211
212/// struct for typed errors of method [`create_project`]
213#[derive(Debug, Clone, Serialize, Deserialize)]
214#[serde(untagged)]
215pub enum CreateProjectError {
216    Status400(models::Errors),
217    Status401(models::Errors),
218    Status409(models::Errors),
219    Status500(models::Errors),
220    UnknownValue(serde_json::Value),
221}
222
223/// struct for typed errors of method [`delete_project`]
224#[derive(Debug, Clone, Serialize, Deserialize)]
225#[serde(untagged)]
226pub enum DeleteProjectError {
227    Status400(models::Errors),
228    Status403(models::Errors),
229    Status404(models::Errors),
230    Status412(models::Errors),
231    Status500(models::Errors),
232    UnknownValue(serde_json::Value),
233}
234
235/// struct for typed errors of method [`get_logs`]
236#[derive(Debug, Clone, Serialize, Deserialize)]
237#[serde(untagged)]
238pub enum GetLogsError {
239    Status400(models::Errors),
240    Status401(models::Errors),
241    Status500(models::Errors),
242    UnknownValue(serde_json::Value),
243}
244
245/// struct for typed errors of method [`get_project`]
246#[derive(Debug, Clone, Serialize, Deserialize)]
247#[serde(untagged)]
248pub enum GetProjectError {
249    Status401(models::Errors),
250    Status500(models::Errors),
251    UnknownValue(serde_json::Value),
252}
253
254/// struct for typed errors of method [`get_project_deletable`]
255#[derive(Debug, Clone, Serialize, Deserialize)]
256#[serde(untagged)]
257pub enum GetProjectDeletableError {
258    Status401(models::Errors),
259    Status403(models::Errors),
260    Status404(models::Errors),
261    Status500(models::Errors),
262    UnknownValue(serde_json::Value),
263}
264
265/// struct for typed errors of method [`get_project_summary`]
266#[derive(Debug, Clone, Serialize, Deserialize)]
267#[serde(untagged)]
268pub enum GetProjectSummaryError {
269    Status400(models::Errors),
270    Status401(models::Errors),
271    Status403(models::Errors),
272    Status404(models::Errors),
273    Status500(models::Errors),
274    UnknownValue(serde_json::Value),
275}
276
277/// struct for typed errors of method [`get_scanner_of_project`]
278#[derive(Debug, Clone, Serialize, Deserialize)]
279#[serde(untagged)]
280pub enum GetScannerOfProjectError {
281    Status400(),
282    Status401(),
283    Status403(),
284    Status404(),
285    Status500(),
286    UnknownValue(serde_json::Value),
287}
288
289/// struct for typed errors of method [`head_project`]
290#[derive(Debug, Clone, Serialize, Deserialize)]
291#[serde(untagged)]
292pub enum HeadProjectError {
293    Status404(models::Errors),
294    Status500(models::Errors),
295    UnknownValue(serde_json::Value),
296}
297
298/// struct for typed errors of method [`list_artifacts_of_project`]
299#[derive(Debug, Clone, Serialize, Deserialize)]
300#[serde(untagged)]
301pub enum ListArtifactsOfProjectError {
302    Status400(models::Errors),
303    Status401(models::Errors),
304    Status403(models::Errors),
305    Status404(models::Errors),
306    Status500(models::Errors),
307    UnknownValue(serde_json::Value),
308}
309
310/// struct for typed errors of method [`list_projects`]
311#[derive(Debug, Clone, Serialize, Deserialize)]
312#[serde(untagged)]
313pub enum ListProjectsError {
314    Status401(models::Errors),
315    Status500(models::Errors),
316    UnknownValue(serde_json::Value),
317}
318
319/// struct for typed errors of method [`list_scanner_candidates_of_project`]
320#[derive(Debug, Clone, Serialize, Deserialize)]
321#[serde(untagged)]
322pub enum ListScannerCandidatesOfProjectError {
323    Status400(models::Errors),
324    Status401(models::Errors),
325    Status403(models::Errors),
326    Status500(models::Errors),
327    UnknownValue(serde_json::Value),
328}
329
330/// struct for typed errors of method [`set_scanner_of_project`]
331#[derive(Debug, Clone, Serialize, Deserialize)]
332#[serde(untagged)]
333pub enum SetScannerOfProjectError {
334    Status400(models::Errors),
335    Status401(models::Errors),
336    Status403(models::Errors),
337    Status404(models::Errors),
338    Status500(models::Errors),
339    UnknownValue(serde_json::Value),
340}
341
342/// struct for typed errors of method [`update_project`]
343#[derive(Debug, Clone, Serialize, Deserialize)]
344#[serde(untagged)]
345pub enum UpdateProjectError {
346    Status400(models::Errors),
347    Status401(models::Errors),
348    Status403(models::Errors),
349    Status404(models::Errors),
350    Status500(models::Errors),
351    UnknownValue(serde_json::Value),
352}
353
354
355/// This endpoint is for user to create a new project.
356pub async fn create_project(configuration: &configuration::Configuration, params: CreateProjectParams) -> Result<(), Error<CreateProjectError>> {
357
358    let uri_str = format!("{}/projects", configuration.base_path);
359    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
360
361    if let Some(ref user_agent) = configuration.user_agent {
362        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
363    }
364    if let Some(param_value) = params.x_request_id {
365        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
366    }
367    if let Some(param_value) = params.x_resource_name_in_location {
368        req_builder = req_builder.header("X-Resource-Name-In-Location", param_value.to_string());
369    }
370    if let Some(ref auth_conf) = configuration.basic_auth {
371        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
372    };
373    req_builder = req_builder.json(&params.project);
374
375    let req = req_builder.build()?;
376    let resp = configuration.client.execute(req).await?;
377
378    let status = resp.status();
379
380    if !status.is_client_error() && !status.is_server_error() {
381        Ok(())
382    } else {
383        let content = resp.text().await?;
384        let entity: Option<CreateProjectError> = serde_json::from_str(&content).ok();
385        Err(Error::ResponseError(ResponseContent { status, content, entity }))
386    }
387}
388
389/// This endpoint is aimed to delete project by project ID.
390pub async fn delete_project(configuration: &configuration::Configuration, params: DeleteProjectParams) -> Result<(), Error<DeleteProjectError>> {
391
392    let uri_str = format!("{}/projects/{project_name_or_id}", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
393    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
394
395    if let Some(ref user_agent) = configuration.user_agent {
396        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
397    }
398    if let Some(param_value) = params.x_request_id {
399        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
400    }
401    if let Some(param_value) = params.x_is_resource_name {
402        req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
403    }
404    if let Some(ref auth_conf) = configuration.basic_auth {
405        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
406    };
407
408    let req = req_builder.build()?;
409    let resp = configuration.client.execute(req).await?;
410
411    let status = resp.status();
412
413    if !status.is_client_error() && !status.is_server_error() {
414        Ok(())
415    } else {
416        let content = resp.text().await?;
417        let entity: Option<DeleteProjectError> = serde_json::from_str(&content).ok();
418        Err(Error::ResponseError(ResponseContent { status, content, entity }))
419    }
420}
421
422/// Get recent logs of the projects
423pub async fn get_logs(configuration: &configuration::Configuration, params: GetLogsParams) -> Result<Vec<models::AuditLog>, Error<GetLogsError>> {
424
425    let uri_str = format!("{}/projects/{project_name}/logs", configuration.base_path, project_name=crate::apis::urlencode(params.project_name));
426    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
427
428    if let Some(ref param_value) = params.q {
429        req_builder = req_builder.query(&[("q", &param_value.to_string())]);
430    }
431    if let Some(ref param_value) = params.sort {
432        req_builder = req_builder.query(&[("sort", &param_value.to_string())]);
433    }
434    if let Some(ref param_value) = params.page {
435        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
436    }
437    if let Some(ref param_value) = params.page_size {
438        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
439    }
440    if let Some(ref user_agent) = configuration.user_agent {
441        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
442    }
443    if let Some(param_value) = params.x_request_id {
444        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
445    }
446    if let Some(ref auth_conf) = configuration.basic_auth {
447        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
448    };
449
450    let req = req_builder.build()?;
451    let resp = configuration.client.execute(req).await?;
452
453    let status = resp.status();
454    let content_type = resp
455        .headers()
456        .get("content-type")
457        .and_then(|v| v.to_str().ok())
458        .unwrap_or("application/octet-stream");
459    let content_type = super::ContentType::from(content_type);
460
461    if !status.is_client_error() && !status.is_server_error() {
462        let content = resp.text().await?;
463        match content_type {
464            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
465            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::AuditLog&gt;`"))),
466            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::AuditLog&gt;`")))),
467        }
468    } else {
469        let content = resp.text().await?;
470        let entity: Option<GetLogsError> = serde_json::from_str(&content).ok();
471        Err(Error::ResponseError(ResponseContent { status, content, entity }))
472    }
473}
474
475/// This endpoint returns specific project information by project ID.
476pub async fn get_project(configuration: &configuration::Configuration, params: GetProjectParams) -> Result<models::Project, Error<GetProjectError>> {
477
478    let uri_str = format!("{}/projects/{project_name_or_id}", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
479    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
480
481    if let Some(ref user_agent) = configuration.user_agent {
482        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
483    }
484    if let Some(param_value) = params.x_request_id {
485        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
486    }
487    if let Some(param_value) = params.x_is_resource_name {
488        req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
489    }
490    if let Some(ref auth_conf) = configuration.basic_auth {
491        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
492    };
493
494    let req = req_builder.build()?;
495    let resp = configuration.client.execute(req).await?;
496
497    let status = resp.status();
498    let content_type = resp
499        .headers()
500        .get("content-type")
501        .and_then(|v| v.to_str().ok())
502        .unwrap_or("application/octet-stream");
503    let content_type = super::ContentType::from(content_type);
504
505    if !status.is_client_error() && !status.is_server_error() {
506        let content = resp.text().await?;
507        match content_type {
508            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
509            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Project`"))),
510            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::Project`")))),
511        }
512    } else {
513        let content = resp.text().await?;
514        let entity: Option<GetProjectError> = serde_json::from_str(&content).ok();
515        Err(Error::ResponseError(ResponseContent { status, content, entity }))
516    }
517}
518
519/// Get the deletable status of the project
520pub async fn get_project_deletable(configuration: &configuration::Configuration, params: GetProjectDeletableParams) -> Result<models::ProjectDeletable, Error<GetProjectDeletableError>> {
521
522    let uri_str = format!("{}/projects/{project_name_or_id}/_deletable", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
523    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
524
525    if let Some(ref user_agent) = configuration.user_agent {
526        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
527    }
528    if let Some(param_value) = params.x_request_id {
529        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
530    }
531    if let Some(param_value) = params.x_is_resource_name {
532        req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
533    }
534    if let Some(ref auth_conf) = configuration.basic_auth {
535        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
536    };
537
538    let req = req_builder.build()?;
539    let resp = configuration.client.execute(req).await?;
540
541    let status = resp.status();
542    let content_type = resp
543        .headers()
544        .get("content-type")
545        .and_then(|v| v.to_str().ok())
546        .unwrap_or("application/octet-stream");
547    let content_type = super::ContentType::from(content_type);
548
549    if !status.is_client_error() && !status.is_server_error() {
550        let content = resp.text().await?;
551        match content_type {
552            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
553            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectDeletable`"))),
554            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::ProjectDeletable`")))),
555        }
556    } else {
557        let content = resp.text().await?;
558        let entity: Option<GetProjectDeletableError> = serde_json::from_str(&content).ok();
559        Err(Error::ResponseError(ResponseContent { status, content, entity }))
560    }
561}
562
563/// Get summary of the project.
564pub async fn get_project_summary(configuration: &configuration::Configuration, params: GetProjectSummaryParams) -> Result<models::ProjectSummary, Error<GetProjectSummaryError>> {
565
566    let uri_str = format!("{}/projects/{project_name_or_id}/summary", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
567    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
568
569    if let Some(ref user_agent) = configuration.user_agent {
570        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
571    }
572    if let Some(param_value) = params.x_request_id {
573        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
574    }
575    if let Some(param_value) = params.x_is_resource_name {
576        req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
577    }
578    if let Some(ref auth_conf) = configuration.basic_auth {
579        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
580    };
581
582    let req = req_builder.build()?;
583    let resp = configuration.client.execute(req).await?;
584
585    let status = resp.status();
586    let content_type = resp
587        .headers()
588        .get("content-type")
589        .and_then(|v| v.to_str().ok())
590        .unwrap_or("application/octet-stream");
591    let content_type = super::ContentType::from(content_type);
592
593    if !status.is_client_error() && !status.is_server_error() {
594        let content = resp.text().await?;
595        match content_type {
596            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
597            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectSummary`"))),
598            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::ProjectSummary`")))),
599        }
600    } else {
601        let content = resp.text().await?;
602        let entity: Option<GetProjectSummaryError> = serde_json::from_str(&content).ok();
603        Err(Error::ResponseError(ResponseContent { status, content, entity }))
604    }
605}
606
607/// Get the scanner registration of the specified project. If no scanner registration is configured for the specified project, the system default scanner registration will be returned.
608pub async fn get_scanner_of_project(configuration: &configuration::Configuration, params: GetScannerOfProjectParams) -> Result<models::ScannerRegistration, Error<GetScannerOfProjectError>> {
609
610    let uri_str = format!("{}/projects/{project_name_or_id}/scanner", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
611    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
612
613    if let Some(ref user_agent) = configuration.user_agent {
614        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
615    }
616    if let Some(param_value) = params.x_request_id {
617        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
618    }
619    if let Some(param_value) = params.x_is_resource_name {
620        req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
621    }
622    if let Some(ref auth_conf) = configuration.basic_auth {
623        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
624    };
625
626    let req = req_builder.build()?;
627    let resp = configuration.client.execute(req).await?;
628
629    let status = resp.status();
630    let content_type = resp
631        .headers()
632        .get("content-type")
633        .and_then(|v| v.to_str().ok())
634        .unwrap_or("application/octet-stream");
635    let content_type = super::ContentType::from(content_type);
636
637    if !status.is_client_error() && !status.is_server_error() {
638        let content = resp.text().await?;
639        match content_type {
640            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
641            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ScannerRegistration`"))),
642            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::ScannerRegistration`")))),
643        }
644    } else {
645        let content = resp.text().await?;
646        let entity: Option<GetScannerOfProjectError> = serde_json::from_str(&content).ok();
647        Err(Error::ResponseError(ResponseContent { status, content, entity }))
648    }
649}
650
651/// This endpoint is used to check if the project name provided already exist.
652pub async fn head_project(configuration: &configuration::Configuration, params: HeadProjectParams) -> Result<(), Error<HeadProjectError>> {
653
654    let uri_str = format!("{}/projects", configuration.base_path);
655    let mut req_builder = configuration.client.request(reqwest::Method::HEAD, &uri_str);
656
657    req_builder = req_builder.query(&[("project_name", &params.project_name.to_string())]);
658    if let Some(ref user_agent) = configuration.user_agent {
659        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
660    }
661    if let Some(param_value) = params.x_request_id {
662        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
663    }
664    if let Some(ref auth_conf) = configuration.basic_auth {
665        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
666    };
667
668    let req = req_builder.build()?;
669    let resp = configuration.client.execute(req).await?;
670
671    let status = resp.status();
672
673    if !status.is_client_error() && !status.is_server_error() {
674        Ok(())
675    } else {
676        let content = resp.text().await?;
677        let entity: Option<HeadProjectError> = serde_json::from_str(&content).ok();
678        Err(Error::ResponseError(ResponseContent { status, content, entity }))
679    }
680}
681
682/// List artifacts of the specified project
683pub async fn list_artifacts_of_project(configuration: &configuration::Configuration, params: ListArtifactsOfProjectParams) -> Result<Vec<models::Artifact>, Error<ListArtifactsOfProjectError>> {
684
685    let uri_str = format!("{}/projects/{project_name_or_id}/artifacts", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
686    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
687
688    if let Some(ref param_value) = params.q {
689        req_builder = req_builder.query(&[("q", &param_value.to_string())]);
690    }
691    if let Some(ref param_value) = params.sort {
692        req_builder = req_builder.query(&[("sort", &param_value.to_string())]);
693    }
694    if let Some(ref param_value) = params.page {
695        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
696    }
697    if let Some(ref param_value) = params.page_size {
698        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
699    }
700    if let Some(ref param_value) = params.with_tag {
701        req_builder = req_builder.query(&[("with_tag", &param_value.to_string())]);
702    }
703    if let Some(ref param_value) = params.with_label {
704        req_builder = req_builder.query(&[("with_label", &param_value.to_string())]);
705    }
706    if let Some(ref param_value) = params.with_scan_overview {
707        req_builder = req_builder.query(&[("with_scan_overview", &param_value.to_string())]);
708    }
709    if let Some(ref param_value) = params.with_sbom_overview {
710        req_builder = req_builder.query(&[("with_sbom_overview", &param_value.to_string())]);
711    }
712    if let Some(ref param_value) = params.with_immutable_status {
713        req_builder = req_builder.query(&[("with_immutable_status", &param_value.to_string())]);
714    }
715    if let Some(ref param_value) = params.with_accessory {
716        req_builder = req_builder.query(&[("with_accessory", &param_value.to_string())]);
717    }
718    if let Some(ref param_value) = params.latest_in_repository {
719        req_builder = req_builder.query(&[("latest_in_repository", &param_value.to_string())]);
720    }
721    if let Some(ref user_agent) = configuration.user_agent {
722        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
723    }
724    if let Some(param_value) = params.x_request_id {
725        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
726    }
727    if let Some(param_value) = params.x_is_resource_name {
728        req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
729    }
730    if let Some(param_value) = params.x_accept_vulnerabilities {
731        req_builder = req_builder.header("X-Accept-Vulnerabilities", param_value.to_string());
732    }
733    if let Some(ref auth_conf) = configuration.basic_auth {
734        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
735    };
736
737    let req = req_builder.build()?;
738    let resp = configuration.client.execute(req).await?;
739
740    let status = resp.status();
741    let content_type = resp
742        .headers()
743        .get("content-type")
744        .and_then(|v| v.to_str().ok())
745        .unwrap_or("application/octet-stream");
746    let content_type = super::ContentType::from(content_type);
747
748    if !status.is_client_error() && !status.is_server_error() {
749        let content = resp.text().await?;
750        match content_type {
751            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
752            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::Artifact&gt;`"))),
753            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::Artifact&gt;`")))),
754        }
755    } else {
756        let content = resp.text().await?;
757        let entity: Option<ListArtifactsOfProjectError> = serde_json::from_str(&content).ok();
758        Err(Error::ResponseError(ResponseContent { status, content, entity }))
759    }
760}
761
762/// This endpoint returns projects created by Harbor.
763pub async fn list_projects(configuration: &configuration::Configuration, params: ListProjectsParams) -> Result<Vec<models::Project>, Error<ListProjectsError>> {
764
765    let uri_str = format!("{}/projects", configuration.base_path);
766    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
767
768    if let Some(ref param_value) = params.q {
769        req_builder = req_builder.query(&[("q", &param_value.to_string())]);
770    }
771    if let Some(ref param_value) = params.page {
772        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
773    }
774    if let Some(ref param_value) = params.page_size {
775        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
776    }
777    if let Some(ref param_value) = params.sort {
778        req_builder = req_builder.query(&[("sort", &param_value.to_string())]);
779    }
780    if let Some(ref param_value) = params.name {
781        req_builder = req_builder.query(&[("name", &param_value.to_string())]);
782    }
783    if let Some(ref param_value) = params.public {
784        req_builder = req_builder.query(&[("public", &param_value.to_string())]);
785    }
786    if let Some(ref param_value) = params.owner {
787        req_builder = req_builder.query(&[("owner", &param_value.to_string())]);
788    }
789    if let Some(ref param_value) = params.with_detail {
790        req_builder = req_builder.query(&[("with_detail", &param_value.to_string())]);
791    }
792    if let Some(ref user_agent) = configuration.user_agent {
793        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
794    }
795    if let Some(param_value) = params.x_request_id {
796        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
797    }
798    if let Some(ref auth_conf) = configuration.basic_auth {
799        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
800    };
801
802    let req = req_builder.build()?;
803    let resp = configuration.client.execute(req).await?;
804
805    let status = resp.status();
806    let content_type = resp
807        .headers()
808        .get("content-type")
809        .and_then(|v| v.to_str().ok())
810        .unwrap_or("application/octet-stream");
811    let content_type = super::ContentType::from(content_type);
812
813    if !status.is_client_error() && !status.is_server_error() {
814        let content = resp.text().await?;
815        match content_type {
816            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
817            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::Project&gt;`"))),
818            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::Project&gt;`")))),
819        }
820    } else {
821        let content = resp.text().await?;
822        let entity: Option<ListProjectsError> = serde_json::from_str(&content).ok();
823        Err(Error::ResponseError(ResponseContent { status, content, entity }))
824    }
825}
826
827/// Retrieve the system configured scanner registrations as candidates of setting project level scanner.
828pub async fn list_scanner_candidates_of_project(configuration: &configuration::Configuration, params: ListScannerCandidatesOfProjectParams) -> Result<Vec<models::ScannerRegistration>, Error<ListScannerCandidatesOfProjectError>> {
829
830    let uri_str = format!("{}/projects/{project_name_or_id}/scanner/candidates", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
831    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
832
833    if let Some(ref param_value) = params.q {
834        req_builder = req_builder.query(&[("q", &param_value.to_string())]);
835    }
836    if let Some(ref param_value) = params.sort {
837        req_builder = req_builder.query(&[("sort", &param_value.to_string())]);
838    }
839    if let Some(ref param_value) = params.page {
840        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
841    }
842    if let Some(ref param_value) = params.page_size {
843        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
844    }
845    if let Some(ref user_agent) = configuration.user_agent {
846        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
847    }
848    if let Some(param_value) = params.x_request_id {
849        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
850    }
851    if let Some(param_value) = params.x_is_resource_name {
852        req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
853    }
854    if let Some(ref auth_conf) = configuration.basic_auth {
855        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
856    };
857
858    let req = req_builder.build()?;
859    let resp = configuration.client.execute(req).await?;
860
861    let status = resp.status();
862    let content_type = resp
863        .headers()
864        .get("content-type")
865        .and_then(|v| v.to_str().ok())
866        .unwrap_or("application/octet-stream");
867    let content_type = super::ContentType::from(content_type);
868
869    if !status.is_client_error() && !status.is_server_error() {
870        let content = resp.text().await?;
871        match content_type {
872            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
873            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::ScannerRegistration&gt;`"))),
874            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::ScannerRegistration&gt;`")))),
875        }
876    } else {
877        let content = resp.text().await?;
878        let entity: Option<ListScannerCandidatesOfProjectError> = serde_json::from_str(&content).ok();
879        Err(Error::ResponseError(ResponseContent { status, content, entity }))
880    }
881}
882
883/// Set one of the system configured scanner registration as the indepndent scanner of the specified project.
884pub async fn set_scanner_of_project(configuration: &configuration::Configuration, params: SetScannerOfProjectParams) -> Result<(), Error<SetScannerOfProjectError>> {
885
886    let uri_str = format!("{}/projects/{project_name_or_id}/scanner", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
887    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
888
889    if let Some(ref user_agent) = configuration.user_agent {
890        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
891    }
892    if let Some(param_value) = params.x_request_id {
893        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
894    }
895    if let Some(param_value) = params.x_is_resource_name {
896        req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
897    }
898    if let Some(ref auth_conf) = configuration.basic_auth {
899        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
900    };
901    req_builder = req_builder.json(&params.payload);
902
903    let req = req_builder.build()?;
904    let resp = configuration.client.execute(req).await?;
905
906    let status = resp.status();
907
908    if !status.is_client_error() && !status.is_server_error() {
909        Ok(())
910    } else {
911        let content = resp.text().await?;
912        let entity: Option<SetScannerOfProjectError> = serde_json::from_str(&content).ok();
913        Err(Error::ResponseError(ResponseContent { status, content, entity }))
914    }
915}
916
917/// This endpoint is aimed to update the properties of a project.
918pub async fn update_project(configuration: &configuration::Configuration, params: UpdateProjectParams) -> Result<(), Error<UpdateProjectError>> {
919
920    let uri_str = format!("{}/projects/{project_name_or_id}", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
921    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
922
923    if let Some(ref user_agent) = configuration.user_agent {
924        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
925    }
926    if let Some(param_value) = params.x_request_id {
927        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
928    }
929    if let Some(param_value) = params.x_is_resource_name {
930        req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
931    }
932    if let Some(ref auth_conf) = configuration.basic_auth {
933        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
934    };
935    req_builder = req_builder.json(&params.project);
936
937    let req = req_builder.build()?;
938    let resp = configuration.client.execute(req).await?;
939
940    let status = resp.status();
941
942    if !status.is_client_error() && !status.is_server_error() {
943        Ok(())
944    } else {
945        let content = resp.text().await?;
946        let entity: Option<UpdateProjectError> = serde_json::from_str(&content).ok();
947        Err(Error::ResponseError(ResponseContent { status, content, entity }))
948    }
949}
950