use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
#[derive(Clone, Debug)]
pub struct AddLabelParams {
pub project_name: String,
pub repository_name: String,
pub reference: String,
pub label: models::Label,
pub x_request_id: Option<String>
}
#[derive(Clone, Debug)]
pub struct CopyArtifactParams {
pub project_name: String,
pub repository_name: String,
pub from: String,
pub x_request_id: Option<String>
}
#[derive(Clone, Debug)]
pub struct CreateTagParams {
pub project_name: String,
pub repository_name: String,
pub reference: String,
pub tag: models::Tag,
pub x_request_id: Option<String>
}
#[derive(Clone, Debug)]
pub struct DeleteArtifactParams {
pub project_name: String,
pub repository_name: String,
pub reference: String,
pub x_request_id: Option<String>
}
#[derive(Clone, Debug)]
pub struct DeleteTagParams {
pub project_name: String,
pub repository_name: String,
pub reference: String,
pub tag_name: String,
pub x_request_id: Option<String>
}
#[derive(Clone, Debug)]
pub struct GetAdditionParams {
pub project_name: String,
pub repository_name: String,
pub reference: String,
pub addition: String,
pub x_request_id: Option<String>
}
#[derive(Clone, Debug)]
pub struct GetArtifactParams {
pub project_name: String,
pub repository_name: String,
pub reference: String,
pub x_request_id: Option<String>,
pub page: Option<i64>,
pub page_size: Option<i64>,
pub x_accept_vulnerabilities: Option<String>,
pub with_tag: Option<bool>,
pub with_label: Option<bool>,
pub with_scan_overview: Option<bool>,
pub with_sbom_overview: Option<bool>,
pub with_accessory: Option<bool>,
pub with_signature: Option<bool>,
pub with_immutable_status: Option<bool>
}
#[derive(Clone, Debug)]
pub struct GetVulnerabilitiesAdditionParams {
pub project_name: String,
pub repository_name: String,
pub reference: String,
pub x_request_id: Option<String>,
pub x_accept_vulnerabilities: Option<String>
}
#[derive(Clone, Debug)]
pub struct ListAccessoriesParams {
pub project_name: String,
pub repository_name: String,
pub reference: String,
pub x_request_id: Option<String>,
pub q: Option<String>,
pub sort: Option<String>,
pub page: Option<i64>,
pub page_size: Option<i64>
}
#[derive(Clone, Debug)]
pub struct ListArtifactsParams {
pub project_name: String,
pub repository_name: String,
pub x_request_id: Option<String>,
pub q: Option<String>,
pub sort: Option<String>,
pub page: Option<i64>,
pub page_size: Option<i64>,
pub x_accept_vulnerabilities: Option<String>,
pub with_tag: Option<bool>,
pub with_label: Option<bool>,
pub with_scan_overview: Option<bool>,
pub with_sbom_overview: Option<bool>,
pub with_signature: Option<bool>,
pub with_immutable_status: Option<bool>,
pub with_accessory: Option<bool>
}
#[derive(Clone, Debug)]
pub struct ListTagsParams {
pub project_name: String,
pub repository_name: String,
pub reference: String,
pub x_request_id: Option<String>,
pub q: Option<String>,
pub sort: Option<String>,
pub page: Option<i64>,
pub page_size: Option<i64>,
pub with_signature: Option<bool>,
pub with_immutable_status: Option<bool>
}
#[derive(Clone, Debug)]
pub struct RemoveLabelParams {
pub project_name: String,
pub repository_name: String,
pub reference: String,
pub label_id: i64,
pub x_request_id: Option<String>
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddLabelError {
Status400(models::Errors),
Status401(models::Errors),
Status403(models::Errors),
Status404(models::Errors),
Status409(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CopyArtifactError {
Status400(models::Errors),
Status401(models::Errors),
Status403(models::Errors),
Status404(models::Errors),
Status405(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateTagError {
Status400(models::Errors),
Status401(models::Errors),
Status403(models::Errors),
Status404(models::Errors),
Status405(models::Errors),
Status409(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteArtifactError {
Status401(models::Errors),
Status403(models::Errors),
Status404(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteTagError {
Status401(models::Errors),
Status403(models::Errors),
Status404(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAdditionError {
Status400(models::Errors),
Status401(models::Errors),
Status403(models::Errors),
Status404(models::Errors),
Status422(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetArtifactError {
Status400(models::Errors),
Status401(models::Errors),
Status403(models::Errors),
Status404(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetVulnerabilitiesAdditionError {
Status400(models::Errors),
Status401(models::Errors),
Status403(models::Errors),
Status404(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAccessoriesError {
Status400(models::Errors),
Status401(models::Errors),
Status403(models::Errors),
Status404(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListArtifactsError {
Status400(models::Errors),
Status401(models::Errors),
Status403(models::Errors),
Status404(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListTagsError {
Status400(models::Errors),
Status401(models::Errors),
Status403(models::Errors),
Status404(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RemoveLabelError {
Status401(models::Errors),
Status403(models::Errors),
Status404(models::Errors),
Status409(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
pub async fn add_label(configuration: &configuration::Configuration, params: AddLabelParams) -> Result<(), Error<AddLabelError>> {
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));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = params.x_request_id {
req_builder = req_builder.header("X-Request-Id", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
req_builder = req_builder.json(¶ms.label);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<AddLabelError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn copy_artifact(configuration: &configuration::Configuration, params: CopyArtifactParams) -> Result<(), Error<CopyArtifactError>> {
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));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("from", ¶ms.from.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = params.x_request_id {
req_builder = req_builder.header("X-Request-Id", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<CopyArtifactError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_tag(configuration: &configuration::Configuration, params: CreateTagParams) -> Result<(), Error<CreateTagError>> {
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));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = params.x_request_id {
req_builder = req_builder.header("X-Request-Id", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
req_builder = req_builder.json(¶ms.tag);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<CreateTagError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn delete_artifact(configuration: &configuration::Configuration, params: DeleteArtifactParams) -> Result<(), Error<DeleteArtifactError>> {
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));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = params.x_request_id {
req_builder = req_builder.header("X-Request-Id", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<DeleteArtifactError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn delete_tag(configuration: &configuration::Configuration, params: DeleteTagParams) -> Result<(), Error<DeleteTagError>> {
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));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = params.x_request_id {
req_builder = req_builder.header("X-Request-Id", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<DeleteTagError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_addition(configuration: &configuration::Configuration, params: GetAdditionParams) -> Result<String, Error<GetAdditionError>> {
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));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = params.x_request_id {
req_builder = req_builder.header("X-Request-Id", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetAdditionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_artifact(configuration: &configuration::Configuration, params: GetArtifactParams) -> Result<models::Artifact, Error<GetArtifactError>> {
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));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = params.page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.page_size {
req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.with_tag {
req_builder = req_builder.query(&[("with_tag", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.with_label {
req_builder = req_builder.query(&[("with_label", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.with_scan_overview {
req_builder = req_builder.query(&[("with_scan_overview", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.with_sbom_overview {
req_builder = req_builder.query(&[("with_sbom_overview", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.with_accessory {
req_builder = req_builder.query(&[("with_accessory", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.with_signature {
req_builder = req_builder.query(&[("with_signature", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.with_immutable_status {
req_builder = req_builder.query(&[("with_immutable_status", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = params.x_request_id {
req_builder = req_builder.header("X-Request-Id", param_value.to_string());
}
if let Some(param_value) = params.x_accept_vulnerabilities {
req_builder = req_builder.header("X-Accept-Vulnerabilities", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Artifact`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetArtifactError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_vulnerabilities_addition(configuration: &configuration::Configuration, params: GetVulnerabilitiesAdditionParams) -> Result<String, Error<GetVulnerabilitiesAdditionError>> {
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));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = params.x_request_id {
req_builder = req_builder.header("X-Request-Id", param_value.to_string());
}
if let Some(param_value) = params.x_accept_vulnerabilities {
req_builder = req_builder.header("X-Accept-Vulnerabilities", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetVulnerabilitiesAdditionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn list_accessories(configuration: &configuration::Configuration, params: ListAccessoriesParams) -> Result<Vec<models::Accessory>, Error<ListAccessoriesError>> {
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));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = params.q {
req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.sort {
req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.page_size {
req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = params.x_request_id {
req_builder = req_builder.header("X-Request-Id", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Accessory>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Accessory>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAccessoriesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn list_artifacts(configuration: &configuration::Configuration, params: ListArtifactsParams) -> Result<Vec<models::Artifact>, Error<ListArtifactsError>> {
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));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = params.q {
req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.sort {
req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.page_size {
req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.with_tag {
req_builder = req_builder.query(&[("with_tag", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.with_label {
req_builder = req_builder.query(&[("with_label", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.with_scan_overview {
req_builder = req_builder.query(&[("with_scan_overview", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.with_sbom_overview {
req_builder = req_builder.query(&[("with_sbom_overview", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.with_signature {
req_builder = req_builder.query(&[("with_signature", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.with_immutable_status {
req_builder = req_builder.query(&[("with_immutable_status", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.with_accessory {
req_builder = req_builder.query(&[("with_accessory", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = params.x_request_id {
req_builder = req_builder.header("X-Request-Id", param_value.to_string());
}
if let Some(param_value) = params.x_accept_vulnerabilities {
req_builder = req_builder.header("X-Accept-Vulnerabilities", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Artifact>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Artifact>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListArtifactsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn list_tags(configuration: &configuration::Configuration, params: ListTagsParams) -> Result<Vec<models::Tag>, Error<ListTagsError>> {
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));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = params.q {
req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.sort {
req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.page_size {
req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.with_signature {
req_builder = req_builder.query(&[("with_signature", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.with_immutable_status {
req_builder = req_builder.query(&[("with_immutable_status", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = params.x_request_id {
req_builder = req_builder.header("X-Request-Id", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Tag>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Tag>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListTagsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn remove_label(configuration: &configuration::Configuration, params: RemoveLabelParams) -> Result<(), Error<RemoveLabelError>> {
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);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = params.x_request_id {
req_builder = req_builder.header("X-Request-Id", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<RemoveLabelError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}