harbor_api/apis/
artifact_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 [`add_label`]
18#[derive(Clone, Debug)]
19pub struct AddLabelParams {
20    /// The name of the project
21    pub project_name: String,
22    /// The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb
23    pub repository_name: String,
24    /// The reference of the artifact, can be digest or tag
25    pub reference: String,
26    /// The label that added to the artifact. Only the ID property is needed.
27    pub label: models::Label,
28    /// An unique ID for the request
29    pub x_request_id: Option<String>
30}
31
32/// struct for passing parameters to the method [`copy_artifact`]
33#[derive(Clone, Debug)]
34pub struct CopyArtifactParams {
35    /// The name of the project
36    pub project_name: String,
37    /// The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb
38    pub repository_name: String,
39    /// The artifact from which the new artifact is copied from, the format should be \"project/repository:tag\" or \"project/repository@digest\".
40    pub from: String,
41    /// An unique ID for the request
42    pub x_request_id: Option<String>
43}
44
45/// struct for passing parameters to the method [`create_tag`]
46#[derive(Clone, Debug)]
47pub struct CreateTagParams {
48    /// The name of the project
49    pub project_name: String,
50    /// The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb
51    pub repository_name: String,
52    /// The reference of the artifact, can be digest or tag
53    pub reference: String,
54    /// The JSON object of tag.
55    pub tag: models::Tag,
56    /// An unique ID for the request
57    pub x_request_id: Option<String>
58}
59
60/// struct for passing parameters to the method [`delete_artifact`]
61#[derive(Clone, Debug)]
62pub struct DeleteArtifactParams {
63    /// The name of the project
64    pub project_name: String,
65    /// The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb
66    pub repository_name: String,
67    /// The reference of the artifact, can be digest or tag
68    pub reference: String,
69    /// An unique ID for the request
70    pub x_request_id: Option<String>
71}
72
73/// struct for passing parameters to the method [`delete_tag`]
74#[derive(Clone, Debug)]
75pub struct DeleteTagParams {
76    /// The name of the project
77    pub project_name: String,
78    /// The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb
79    pub repository_name: String,
80    /// The reference of the artifact, can be digest or tag
81    pub reference: String,
82    /// The name of the tag
83    pub tag_name: String,
84    /// An unique ID for the request
85    pub x_request_id: Option<String>
86}
87
88/// struct for passing parameters to the method [`get_addition`]
89#[derive(Clone, Debug)]
90pub struct GetAdditionParams {
91    /// The name of the project
92    pub project_name: String,
93    /// The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb
94    pub repository_name: String,
95    /// The reference of the artifact, can be digest or tag
96    pub reference: String,
97    /// The type of addition.
98    pub addition: String,
99    /// An unique ID for the request
100    pub x_request_id: Option<String>
101}
102
103/// struct for passing parameters to the method [`get_artifact`]
104#[derive(Clone, Debug)]
105pub struct GetArtifactParams {
106    /// The name of the project
107    pub project_name: String,
108    /// The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb
109    pub repository_name: String,
110    /// The reference of the artifact, can be digest or tag
111    pub reference: String,
112    /// An unique ID for the request
113    pub x_request_id: Option<String>,
114    /// The page number
115    pub page: Option<i64>,
116    /// The size of per page
117    pub page_size: Option<i64>,
118    /// 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'
119    pub x_accept_vulnerabilities: Option<String>,
120    /// Specify whether the tags are inclued inside the returning artifacts
121    pub with_tag: Option<bool>,
122    /// Specify whether the labels are inclued inside the returning artifacts
123    pub with_label: Option<bool>,
124    /// Specify whether the scan overview is inclued inside the returning artifacts
125    pub with_scan_overview: Option<bool>,
126    /// Specify whether the SBOM overview is included in returning artifact, when this option is true, the SBOM overview will be included in the response
127    pub with_sbom_overview: Option<bool>,
128    /// Specify whether the accessories are included of the returning artifacts.
129    pub with_accessory: Option<bool>,
130    /// Specify whether the signature is inclued inside the returning artifacts
131    pub with_signature: Option<bool>,
132    /// Specify whether the immutable status is inclued inside the tags of the returning artifacts.
133    pub with_immutable_status: Option<bool>
134}
135
136/// struct for passing parameters to the method [`get_vulnerabilities_addition`]
137#[derive(Clone, Debug)]
138pub struct GetVulnerabilitiesAdditionParams {
139    /// The name of the project
140    pub project_name: String,
141    /// The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb
142    pub repository_name: String,
143    /// The reference of the artifact, can be digest or tag
144    pub reference: String,
145    /// An unique ID for the request
146    pub x_request_id: Option<String>,
147    /// 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'
148    pub x_accept_vulnerabilities: Option<String>
149}
150
151/// struct for passing parameters to the method [`list_accessories`]
152#[derive(Clone, Debug)]
153pub struct ListAccessoriesParams {
154    /// The name of the project
155    pub project_name: String,
156    /// The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb
157    pub repository_name: String,
158    /// The reference of the artifact, can be digest or tag
159    pub reference: String,
160    /// An unique ID for the request
161    pub x_request_id: Option<String>,
162    /// 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]
163    pub q: Option<String>,
164    /// 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\"
165    pub sort: Option<String>,
166    /// The page number
167    pub page: Option<i64>,
168    /// The size of per page
169    pub page_size: Option<i64>
170}
171
172/// struct for passing parameters to the method [`list_artifacts`]
173#[derive(Clone, Debug)]
174pub struct ListArtifactsParams {
175    /// The name of the project
176    pub project_name: String,
177    /// The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb
178    pub repository_name: String,
179    /// An unique ID for the request
180    pub x_request_id: Option<String>,
181    /// 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]
182    pub q: Option<String>,
183    /// 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\"
184    pub sort: Option<String>,
185    /// The page number
186    pub page: Option<i64>,
187    /// The size of per page
188    pub page_size: Option<i64>,
189    /// 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'
190    pub x_accept_vulnerabilities: Option<String>,
191    /// Specify whether the tags are included inside the returning artifacts
192    pub with_tag: Option<bool>,
193    /// Specify whether the labels are included inside the returning artifacts
194    pub with_label: Option<bool>,
195    /// Specify whether the scan overview is included inside the returning artifacts
196    pub with_scan_overview: Option<bool>,
197    /// Specify whether the SBOM overview is included in returning artifacts, when this option is true, the SBOM overview will be included in the response
198    pub with_sbom_overview: Option<bool>,
199    /// Specify whether the signature is included inside the tags of the returning artifacts. Only works when setting \"with_tag=true\"
200    pub with_signature: Option<bool>,
201    /// Specify whether the immutable status is included inside the tags of the returning artifacts. Only works when setting \"with_immutable_status=true\"
202    pub with_immutable_status: Option<bool>,
203    /// Specify whether the accessories are included of the returning artifacts. Only works when setting \"with_accessory=true\"
204    pub with_accessory: Option<bool>
205}
206
207/// struct for passing parameters to the method [`list_tags`]
208#[derive(Clone, Debug)]
209pub struct ListTagsParams {
210    /// The name of the project
211    pub project_name: String,
212    /// The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb
213    pub repository_name: String,
214    /// The reference of the artifact, can be digest or tag
215    pub reference: String,
216    /// An unique ID for the request
217    pub x_request_id: Option<String>,
218    /// 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]
219    pub q: Option<String>,
220    /// 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\"
221    pub sort: Option<String>,
222    /// The page number
223    pub page: Option<i64>,
224    /// The size of per page
225    pub page_size: Option<i64>,
226    /// Specify whether the signature is included inside the returning tags
227    pub with_signature: Option<bool>,
228    /// Specify whether the immutable status is included inside the returning tags
229    pub with_immutable_status: Option<bool>
230}
231
232/// struct for passing parameters to the method [`remove_label`]
233#[derive(Clone, Debug)]
234pub struct RemoveLabelParams {
235    /// The name of the project
236    pub project_name: String,
237    /// The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb
238    pub repository_name: String,
239    /// The reference of the artifact, can be digest or tag
240    pub reference: String,
241    /// The ID of the label that removed from the artifact.
242    pub label_id: i64,
243    /// An unique ID for the request
244    pub x_request_id: Option<String>
245}
246
247
248/// struct for typed errors of method [`add_label`]
249#[derive(Debug, Clone, Serialize, Deserialize)]
250#[serde(untagged)]
251pub enum AddLabelError {
252    Status400(models::Errors),
253    Status401(models::Errors),
254    Status403(models::Errors),
255    Status404(models::Errors),
256    Status409(models::Errors),
257    Status500(models::Errors),
258    UnknownValue(serde_json::Value),
259}
260
261/// struct for typed errors of method [`copy_artifact`]
262#[derive(Debug, Clone, Serialize, Deserialize)]
263#[serde(untagged)]
264pub enum CopyArtifactError {
265    Status400(models::Errors),
266    Status401(models::Errors),
267    Status403(models::Errors),
268    Status404(models::Errors),
269    Status405(models::Errors),
270    Status500(models::Errors),
271    UnknownValue(serde_json::Value),
272}
273
274/// struct for typed errors of method [`create_tag`]
275#[derive(Debug, Clone, Serialize, Deserialize)]
276#[serde(untagged)]
277pub enum CreateTagError {
278    Status400(models::Errors),
279    Status401(models::Errors),
280    Status403(models::Errors),
281    Status404(models::Errors),
282    Status405(models::Errors),
283    Status409(models::Errors),
284    Status500(models::Errors),
285    UnknownValue(serde_json::Value),
286}
287
288/// struct for typed errors of method [`delete_artifact`]
289#[derive(Debug, Clone, Serialize, Deserialize)]
290#[serde(untagged)]
291pub enum DeleteArtifactError {
292    Status401(models::Errors),
293    Status403(models::Errors),
294    Status404(models::Errors),
295    Status500(models::Errors),
296    UnknownValue(serde_json::Value),
297}
298
299/// struct for typed errors of method [`delete_tag`]
300#[derive(Debug, Clone, Serialize, Deserialize)]
301#[serde(untagged)]
302pub enum DeleteTagError {
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 [`get_addition`]
311#[derive(Debug, Clone, Serialize, Deserialize)]
312#[serde(untagged)]
313pub enum GetAdditionError {
314    Status400(models::Errors),
315    Status401(models::Errors),
316    Status403(models::Errors),
317    Status404(models::Errors),
318    Status422(models::Errors),
319    Status500(models::Errors),
320    UnknownValue(serde_json::Value),
321}
322
323/// struct for typed errors of method [`get_artifact`]
324#[derive(Debug, Clone, Serialize, Deserialize)]
325#[serde(untagged)]
326pub enum GetArtifactError {
327    Status400(models::Errors),
328    Status401(models::Errors),
329    Status403(models::Errors),
330    Status404(models::Errors),
331    Status500(models::Errors),
332    UnknownValue(serde_json::Value),
333}
334
335/// struct for typed errors of method [`get_vulnerabilities_addition`]
336#[derive(Debug, Clone, Serialize, Deserialize)]
337#[serde(untagged)]
338pub enum GetVulnerabilitiesAdditionError {
339    Status400(models::Errors),
340    Status401(models::Errors),
341    Status403(models::Errors),
342    Status404(models::Errors),
343    Status500(models::Errors),
344    UnknownValue(serde_json::Value),
345}
346
347/// struct for typed errors of method [`list_accessories`]
348#[derive(Debug, Clone, Serialize, Deserialize)]
349#[serde(untagged)]
350pub enum ListAccessoriesError {
351    Status400(models::Errors),
352    Status401(models::Errors),
353    Status403(models::Errors),
354    Status404(models::Errors),
355    Status500(models::Errors),
356    UnknownValue(serde_json::Value),
357}
358
359/// struct for typed errors of method [`list_artifacts`]
360#[derive(Debug, Clone, Serialize, Deserialize)]
361#[serde(untagged)]
362pub enum ListArtifactsError {
363    Status400(models::Errors),
364    Status401(models::Errors),
365    Status403(models::Errors),
366    Status404(models::Errors),
367    Status500(models::Errors),
368    UnknownValue(serde_json::Value),
369}
370
371/// struct for typed errors of method [`list_tags`]
372#[derive(Debug, Clone, Serialize, Deserialize)]
373#[serde(untagged)]
374pub enum ListTagsError {
375    Status400(models::Errors),
376    Status401(models::Errors),
377    Status403(models::Errors),
378    Status404(models::Errors),
379    Status500(models::Errors),
380    UnknownValue(serde_json::Value),
381}
382
383/// struct for typed errors of method [`remove_label`]
384#[derive(Debug, Clone, Serialize, Deserialize)]
385#[serde(untagged)]
386pub enum RemoveLabelError {
387    Status401(models::Errors),
388    Status403(models::Errors),
389    Status404(models::Errors),
390    Status409(models::Errors),
391    Status500(models::Errors),
392    UnknownValue(serde_json::Value),
393}
394
395
396/// Add label to the specified artiact.
397pub async fn add_label(configuration: &configuration::Configuration, params: AddLabelParams) -> Result<(), Error<AddLabelError>> {
398
399    let uri_str = format!("{}/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/labels", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), repository_name=crate::apis::urlencode(params.repository_name), reference=crate::apis::urlencode(params.reference));
400    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
401
402    if let Some(ref user_agent) = configuration.user_agent {
403        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
404    }
405    if let Some(param_value) = params.x_request_id {
406        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
407    }
408    if let Some(ref auth_conf) = configuration.basic_auth {
409        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
410    };
411    req_builder = req_builder.json(&params.label);
412
413    let req = req_builder.build()?;
414    let resp = configuration.client.execute(req).await?;
415
416    let status = resp.status();
417
418    if !status.is_client_error() && !status.is_server_error() {
419        Ok(())
420    } else {
421        let content = resp.text().await?;
422        let entity: Option<AddLabelError> = serde_json::from_str(&content).ok();
423        Err(Error::ResponseError(ResponseContent { status, content, entity }))
424    }
425}
426
427/// Copy the artifact specified in the \"from\" parameter to the repository.
428pub async fn copy_artifact(configuration: &configuration::Configuration, params: CopyArtifactParams) -> Result<(), Error<CopyArtifactError>> {
429
430    let uri_str = format!("{}/projects/{project_name}/repositories/{repository_name}/artifacts", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), repository_name=crate::apis::urlencode(params.repository_name));
431    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
432
433    req_builder = req_builder.query(&[("from", &params.from.to_string())]);
434    if let Some(ref user_agent) = configuration.user_agent {
435        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
436    }
437    if let Some(param_value) = params.x_request_id {
438        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
439    }
440    if let Some(ref auth_conf) = configuration.basic_auth {
441        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
442    };
443
444    let req = req_builder.build()?;
445    let resp = configuration.client.execute(req).await?;
446
447    let status = resp.status();
448
449    if !status.is_client_error() && !status.is_server_error() {
450        Ok(())
451    } else {
452        let content = resp.text().await?;
453        let entity: Option<CopyArtifactError> = serde_json::from_str(&content).ok();
454        Err(Error::ResponseError(ResponseContent { status, content, entity }))
455    }
456}
457
458/// Create a tag for the specified artifact
459pub async fn create_tag(configuration: &configuration::Configuration, params: CreateTagParams) -> Result<(), Error<CreateTagError>> {
460
461    let uri_str = format!("{}/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/tags", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), repository_name=crate::apis::urlencode(params.repository_name), reference=crate::apis::urlencode(params.reference));
462    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
463
464    if let Some(ref user_agent) = configuration.user_agent {
465        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
466    }
467    if let Some(param_value) = params.x_request_id {
468        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
469    }
470    if let Some(ref auth_conf) = configuration.basic_auth {
471        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
472    };
473    req_builder = req_builder.json(&params.tag);
474
475    let req = req_builder.build()?;
476    let resp = configuration.client.execute(req).await?;
477
478    let status = resp.status();
479
480    if !status.is_client_error() && !status.is_server_error() {
481        Ok(())
482    } else {
483        let content = resp.text().await?;
484        let entity: Option<CreateTagError> = serde_json::from_str(&content).ok();
485        Err(Error::ResponseError(ResponseContent { status, content, entity }))
486    }
487}
488
489/// Delete the artifact specified by the reference under the project and repository. The reference can be digest or tag
490pub async fn delete_artifact(configuration: &configuration::Configuration, params: DeleteArtifactParams) -> Result<(), Error<DeleteArtifactError>> {
491
492    let uri_str = format!("{}/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), repository_name=crate::apis::urlencode(params.repository_name), reference=crate::apis::urlencode(params.reference));
493    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
494
495    if let Some(ref user_agent) = configuration.user_agent {
496        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
497    }
498    if let Some(param_value) = params.x_request_id {
499        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
500    }
501    if let Some(ref auth_conf) = configuration.basic_auth {
502        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
503    };
504
505    let req = req_builder.build()?;
506    let resp = configuration.client.execute(req).await?;
507
508    let status = resp.status();
509
510    if !status.is_client_error() && !status.is_server_error() {
511        Ok(())
512    } else {
513        let content = resp.text().await?;
514        let entity: Option<DeleteArtifactError> = serde_json::from_str(&content).ok();
515        Err(Error::ResponseError(ResponseContent { status, content, entity }))
516    }
517}
518
519/// Delete the tag of the specified artifact
520pub async fn delete_tag(configuration: &configuration::Configuration, params: DeleteTagParams) -> Result<(), Error<DeleteTagError>> {
521
522    let uri_str = format!("{}/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/tags/{tag_name}", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), repository_name=crate::apis::urlencode(params.repository_name), reference=crate::apis::urlencode(params.reference), tag_name=crate::apis::urlencode(params.tag_name));
523    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &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(ref auth_conf) = configuration.basic_auth {
532        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
533    };
534
535    let req = req_builder.build()?;
536    let resp = configuration.client.execute(req).await?;
537
538    let status = resp.status();
539
540    if !status.is_client_error() && !status.is_server_error() {
541        Ok(())
542    } else {
543        let content = resp.text().await?;
544        let entity: Option<DeleteTagError> = serde_json::from_str(&content).ok();
545        Err(Error::ResponseError(ResponseContent { status, content, entity }))
546    }
547}
548
549/// Get the addition of the artifact specified by the reference under the project and repository.
550pub async fn get_addition(configuration: &configuration::Configuration, params: GetAdditionParams) -> Result<String, Error<GetAdditionError>> {
551
552    let uri_str = format!("{}/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/additions/{addition}", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), repository_name=crate::apis::urlencode(params.repository_name), reference=crate::apis::urlencode(params.reference), addition=crate::apis::urlencode(params.addition));
553    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
554
555    if let Some(ref user_agent) = configuration.user_agent {
556        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
557    }
558    if let Some(param_value) = params.x_request_id {
559        req_builder = req_builder.header("X-Request-Id", 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 `String`"))),
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 `String`")))),
582        }
583    } else {
584        let content = resp.text().await?;
585        let entity: Option<GetAdditionError> = serde_json::from_str(&content).ok();
586        Err(Error::ResponseError(ResponseContent { status, content, entity }))
587    }
588}
589
590/// Get the artifact specified by the reference under the project and repository. The reference can be digest or tag.
591pub async fn get_artifact(configuration: &configuration::Configuration, params: GetArtifactParams) -> Result<models::Artifact, Error<GetArtifactError>> {
592
593    let uri_str = format!("{}/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), repository_name=crate::apis::urlencode(params.repository_name), reference=crate::apis::urlencode(params.reference));
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.with_tag {
603        req_builder = req_builder.query(&[("with_tag", &param_value.to_string())]);
604    }
605    if let Some(ref param_value) = params.with_label {
606        req_builder = req_builder.query(&[("with_label", &param_value.to_string())]);
607    }
608    if let Some(ref param_value) = params.with_scan_overview {
609        req_builder = req_builder.query(&[("with_scan_overview", &param_value.to_string())]);
610    }
611    if let Some(ref param_value) = params.with_sbom_overview {
612        req_builder = req_builder.query(&[("with_sbom_overview", &param_value.to_string())]);
613    }
614    if let Some(ref param_value) = params.with_accessory {
615        req_builder = req_builder.query(&[("with_accessory", &param_value.to_string())]);
616    }
617    if let Some(ref param_value) = params.with_signature {
618        req_builder = req_builder.query(&[("with_signature", &param_value.to_string())]);
619    }
620    if let Some(ref param_value) = params.with_immutable_status {
621        req_builder = req_builder.query(&[("with_immutable_status", &param_value.to_string())]);
622    }
623    if let Some(ref user_agent) = configuration.user_agent {
624        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
625    }
626    if let Some(param_value) = params.x_request_id {
627        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
628    }
629    if let Some(param_value) = params.x_accept_vulnerabilities {
630        req_builder = req_builder.header("X-Accept-Vulnerabilities", param_value.to_string());
631    }
632    if let Some(ref auth_conf) = configuration.basic_auth {
633        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
634    };
635
636    let req = req_builder.build()?;
637    let resp = configuration.client.execute(req).await?;
638
639    let status = resp.status();
640    let content_type = resp
641        .headers()
642        .get("content-type")
643        .and_then(|v| v.to_str().ok())
644        .unwrap_or("application/octet-stream");
645    let content_type = super::ContentType::from(content_type);
646
647    if !status.is_client_error() && !status.is_server_error() {
648        let content = resp.text().await?;
649        match content_type {
650            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
651            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Artifact`"))),
652            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::Artifact`")))),
653        }
654    } else {
655        let content = resp.text().await?;
656        let entity: Option<GetArtifactError> = serde_json::from_str(&content).ok();
657        Err(Error::ResponseError(ResponseContent { status, content, entity }))
658    }
659}
660
661/// Get the vulnerabilities addition of the artifact specified by the reference under the project and repository.
662pub async fn get_vulnerabilities_addition(configuration: &configuration::Configuration, params: GetVulnerabilitiesAdditionParams) -> Result<String, Error<GetVulnerabilitiesAdditionError>> {
663
664    let uri_str = format!("{}/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/additions/vulnerabilities", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), repository_name=crate::apis::urlencode(params.repository_name), reference=crate::apis::urlencode(params.reference));
665    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
666
667    if let Some(ref user_agent) = configuration.user_agent {
668        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
669    }
670    if let Some(param_value) = params.x_request_id {
671        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
672    }
673    if let Some(param_value) = params.x_accept_vulnerabilities {
674        req_builder = req_builder.header("X-Accept-Vulnerabilities", param_value.to_string());
675    }
676    if let Some(ref auth_conf) = configuration.basic_auth {
677        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
678    };
679
680    let req = req_builder.build()?;
681    let resp = configuration.client.execute(req).await?;
682
683    let status = resp.status();
684    let content_type = resp
685        .headers()
686        .get("content-type")
687        .and_then(|v| v.to_str().ok())
688        .unwrap_or("application/octet-stream");
689    let content_type = super::ContentType::from(content_type);
690
691    if !status.is_client_error() && !status.is_server_error() {
692        let content = resp.text().await?;
693        match content_type {
694            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
695            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
696            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`")))),
697        }
698    } else {
699        let content = resp.text().await?;
700        let entity: Option<GetVulnerabilitiesAdditionError> = serde_json::from_str(&content).ok();
701        Err(Error::ResponseError(ResponseContent { status, content, entity }))
702    }
703}
704
705/// List accessories of the specific artifact
706pub async fn list_accessories(configuration: &configuration::Configuration, params: ListAccessoriesParams) -> Result<Vec<models::Accessory>, Error<ListAccessoriesError>> {
707
708    let uri_str = format!("{}/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), repository_name=crate::apis::urlencode(params.repository_name), reference=crate::apis::urlencode(params.reference));
709    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
710
711    if let Some(ref param_value) = params.q {
712        req_builder = req_builder.query(&[("q", &param_value.to_string())]);
713    }
714    if let Some(ref param_value) = params.sort {
715        req_builder = req_builder.query(&[("sort", &param_value.to_string())]);
716    }
717    if let Some(ref param_value) = params.page {
718        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
719    }
720    if let Some(ref param_value) = params.page_size {
721        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
722    }
723    if let Some(ref user_agent) = configuration.user_agent {
724        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
725    }
726    if let Some(param_value) = params.x_request_id {
727        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
728    }
729    if let Some(ref auth_conf) = configuration.basic_auth {
730        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
731    };
732
733    let req = req_builder.build()?;
734    let resp = configuration.client.execute(req).await?;
735
736    let status = resp.status();
737    let content_type = resp
738        .headers()
739        .get("content-type")
740        .and_then(|v| v.to_str().ok())
741        .unwrap_or("application/octet-stream");
742    let content_type = super::ContentType::from(content_type);
743
744    if !status.is_client_error() && !status.is_server_error() {
745        let content = resp.text().await?;
746        match content_type {
747            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
748            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::Accessory&gt;`"))),
749            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::Accessory&gt;`")))),
750        }
751    } else {
752        let content = resp.text().await?;
753        let entity: Option<ListAccessoriesError> = serde_json::from_str(&content).ok();
754        Err(Error::ResponseError(ResponseContent { status, content, entity }))
755    }
756}
757
758/// List artifacts under the specific project and repository. Except the basic properties, the other supported queries in \"q\" includes \"tags=*\" to list only tagged artifacts, \"tags=nil\" to list only untagged artifacts, \"tags=~v\" to list artifacts whose tag fuzzy matches \"v\", \"tags=v\" to list artifact whose tag exactly matches \"v\", \"labels=(id1, id2)\" to list artifacts that both labels with id1 and id2 are added to
759pub async fn list_artifacts(configuration: &configuration::Configuration, params: ListArtifactsParams) -> Result<Vec<models::Artifact>, Error<ListArtifactsError>> {
760
761    let uri_str = format!("{}/projects/{project_name}/repositories/{repository_name}/artifacts", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), repository_name=crate::apis::urlencode(params.repository_name));
762    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
763
764    if let Some(ref param_value) = params.q {
765        req_builder = req_builder.query(&[("q", &param_value.to_string())]);
766    }
767    if let Some(ref param_value) = params.sort {
768        req_builder = req_builder.query(&[("sort", &param_value.to_string())]);
769    }
770    if let Some(ref param_value) = params.page {
771        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
772    }
773    if let Some(ref param_value) = params.page_size {
774        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
775    }
776    if let Some(ref param_value) = params.with_tag {
777        req_builder = req_builder.query(&[("with_tag", &param_value.to_string())]);
778    }
779    if let Some(ref param_value) = params.with_label {
780        req_builder = req_builder.query(&[("with_label", &param_value.to_string())]);
781    }
782    if let Some(ref param_value) = params.with_scan_overview {
783        req_builder = req_builder.query(&[("with_scan_overview", &param_value.to_string())]);
784    }
785    if let Some(ref param_value) = params.with_sbom_overview {
786        req_builder = req_builder.query(&[("with_sbom_overview", &param_value.to_string())]);
787    }
788    if let Some(ref param_value) = params.with_signature {
789        req_builder = req_builder.query(&[("with_signature", &param_value.to_string())]);
790    }
791    if let Some(ref param_value) = params.with_immutable_status {
792        req_builder = req_builder.query(&[("with_immutable_status", &param_value.to_string())]);
793    }
794    if let Some(ref param_value) = params.with_accessory {
795        req_builder = req_builder.query(&[("with_accessory", &param_value.to_string())]);
796    }
797    if let Some(ref user_agent) = configuration.user_agent {
798        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
799    }
800    if let Some(param_value) = params.x_request_id {
801        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
802    }
803    if let Some(param_value) = params.x_accept_vulnerabilities {
804        req_builder = req_builder.header("X-Accept-Vulnerabilities", param_value.to_string());
805    }
806    if let Some(ref auth_conf) = configuration.basic_auth {
807        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
808    };
809
810    let req = req_builder.build()?;
811    let resp = configuration.client.execute(req).await?;
812
813    let status = resp.status();
814    let content_type = resp
815        .headers()
816        .get("content-type")
817        .and_then(|v| v.to_str().ok())
818        .unwrap_or("application/octet-stream");
819    let content_type = super::ContentType::from(content_type);
820
821    if !status.is_client_error() && !status.is_server_error() {
822        let content = resp.text().await?;
823        match content_type {
824            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
825            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;`"))),
826            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;`")))),
827        }
828    } else {
829        let content = resp.text().await?;
830        let entity: Option<ListArtifactsError> = serde_json::from_str(&content).ok();
831        Err(Error::ResponseError(ResponseContent { status, content, entity }))
832    }
833}
834
835/// List tags of the specific artifact
836pub async fn list_tags(configuration: &configuration::Configuration, params: ListTagsParams) -> Result<Vec<models::Tag>, Error<ListTagsError>> {
837
838    let uri_str = format!("{}/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/tags", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), repository_name=crate::apis::urlencode(params.repository_name), reference=crate::apis::urlencode(params.reference));
839    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
840
841    if let Some(ref param_value) = params.q {
842        req_builder = req_builder.query(&[("q", &param_value.to_string())]);
843    }
844    if let Some(ref param_value) = params.sort {
845        req_builder = req_builder.query(&[("sort", &param_value.to_string())]);
846    }
847    if let Some(ref param_value) = params.page {
848        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
849    }
850    if let Some(ref param_value) = params.page_size {
851        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
852    }
853    if let Some(ref param_value) = params.with_signature {
854        req_builder = req_builder.query(&[("with_signature", &param_value.to_string())]);
855    }
856    if let Some(ref param_value) = params.with_immutable_status {
857        req_builder = req_builder.query(&[("with_immutable_status", &param_value.to_string())]);
858    }
859    if let Some(ref user_agent) = configuration.user_agent {
860        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
861    }
862    if let Some(param_value) = params.x_request_id {
863        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
864    }
865    if let Some(ref auth_conf) = configuration.basic_auth {
866        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
867    };
868
869    let req = req_builder.build()?;
870    let resp = configuration.client.execute(req).await?;
871
872    let status = resp.status();
873    let content_type = resp
874        .headers()
875        .get("content-type")
876        .and_then(|v| v.to_str().ok())
877        .unwrap_or("application/octet-stream");
878    let content_type = super::ContentType::from(content_type);
879
880    if !status.is_client_error() && !status.is_server_error() {
881        let content = resp.text().await?;
882        match content_type {
883            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
884            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::Tag&gt;`"))),
885            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::Tag&gt;`")))),
886        }
887    } else {
888        let content = resp.text().await?;
889        let entity: Option<ListTagsError> = serde_json::from_str(&content).ok();
890        Err(Error::ResponseError(ResponseContent { status, content, entity }))
891    }
892}
893
894/// Remove the label from the specified artiact.
895pub async fn remove_label(configuration: &configuration::Configuration, params: RemoveLabelParams) -> Result<(), Error<RemoveLabelError>> {
896
897    let uri_str = format!("{}/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/labels/{label_id}", configuration.base_path, project_name=crate::apis::urlencode(params.project_name), repository_name=crate::apis::urlencode(params.repository_name), reference=crate::apis::urlencode(params.reference), label_id=params.label_id);
898    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
899
900    if let Some(ref user_agent) = configuration.user_agent {
901        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
902    }
903    if let Some(param_value) = params.x_request_id {
904        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
905    }
906    if let Some(ref auth_conf) = configuration.basic_auth {
907        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
908    };
909
910    let req = req_builder.build()?;
911    let resp = configuration.client.execute(req).await?;
912
913    let status = resp.status();
914
915    if !status.is_client_error() && !status.is_server_error() {
916        Ok(())
917    } else {
918        let content = resp.text().await?;
919        let entity: Option<RemoveLabelError> = serde_json::from_str(&content).ok();
920        Err(Error::ResponseError(ResponseContent { status, content, entity }))
921    }
922}
923