use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
#[derive(Clone, Debug)]
pub struct CreateProjectParams {
pub project: models::ProjectReq,
pub x_request_id: Option<String>,
pub x_resource_name_in_location: Option<bool>
}
#[derive(Clone, Debug)]
pub struct DeleteProjectParams {
pub project_name_or_id: String,
pub x_request_id: Option<String>,
pub x_is_resource_name: Option<bool>
}
#[derive(Clone, Debug)]
pub struct GetLogsParams {
pub project_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>
}
#[derive(Clone, Debug)]
pub struct GetProjectParams {
pub project_name_or_id: String,
pub x_request_id: Option<String>,
pub x_is_resource_name: Option<bool>
}
#[derive(Clone, Debug)]
pub struct GetProjectDeletableParams {
pub project_name_or_id: String,
pub x_request_id: Option<String>,
pub x_is_resource_name: Option<bool>
}
#[derive(Clone, Debug)]
pub struct GetProjectSummaryParams {
pub project_name_or_id: String,
pub x_request_id: Option<String>,
pub x_is_resource_name: Option<bool>
}
#[derive(Clone, Debug)]
pub struct GetScannerOfProjectParams {
pub project_name_or_id: String,
pub x_request_id: Option<String>,
pub x_is_resource_name: Option<bool>
}
#[derive(Clone, Debug)]
pub struct HeadProjectParams {
pub project_name: String,
pub x_request_id: Option<String>
}
#[derive(Clone, Debug)]
pub struct ListArtifactsOfProjectParams {
pub project_name_or_id: String,
pub x_request_id: Option<String>,
pub x_is_resource_name: Option<bool>,
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_immutable_status: Option<bool>,
pub with_accessory: Option<bool>,
pub latest_in_repository: Option<bool>
}
#[derive(Clone, Debug)]
pub struct ListProjectsParams {
pub x_request_id: Option<String>,
pub q: Option<String>,
pub page: Option<i64>,
pub page_size: Option<i64>,
pub sort: Option<String>,
pub name: Option<String>,
pub public: Option<bool>,
pub owner: Option<String>,
pub with_detail: Option<bool>
}
#[derive(Clone, Debug)]
pub struct ListScannerCandidatesOfProjectParams {
pub project_name_or_id: String,
pub x_request_id: Option<String>,
pub x_is_resource_name: Option<bool>,
pub q: Option<String>,
pub sort: Option<String>,
pub page: Option<i64>,
pub page_size: Option<i64>
}
#[derive(Clone, Debug)]
pub struct SetScannerOfProjectParams {
pub project_name_or_id: String,
pub payload: models::ProjectScanner,
pub x_request_id: Option<String>,
pub x_is_resource_name: Option<bool>
}
#[derive(Clone, Debug)]
pub struct UpdateProjectParams {
pub project_name_or_id: String,
pub project: models::ProjectReq,
pub x_request_id: Option<String>,
pub x_is_resource_name: Option<bool>
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateProjectError {
Status400(models::Errors),
Status401(models::Errors),
Status409(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteProjectError {
Status400(models::Errors),
Status403(models::Errors),
Status404(models::Errors),
Status412(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetLogsError {
Status400(models::Errors),
Status401(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetProjectError {
Status401(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetProjectDeletableError {
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 GetProjectSummaryError {
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 GetScannerOfProjectError {
Status400(),
Status401(),
Status403(),
Status404(),
Status500(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum HeadProjectError {
Status404(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListArtifactsOfProjectError {
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 ListProjectsError {
Status401(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListScannerCandidatesOfProjectError {
Status400(models::Errors),
Status401(models::Errors),
Status403(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetScannerOfProjectError {
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 UpdateProjectError {
Status400(models::Errors),
Status401(models::Errors),
Status403(models::Errors),
Status404(models::Errors),
Status500(models::Errors),
UnknownValue(serde_json::Value),
}
pub async fn create_project(configuration: &configuration::Configuration, params: CreateProjectParams) -> Result<(), Error<CreateProjectError>> {
let uri_str = format!("{}/projects", configuration.base_path);
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(param_value) = params.x_resource_name_in_location {
req_builder = req_builder.header("X-Resource-Name-In-Location", 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.project);
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<CreateProjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn delete_project(configuration: &configuration::Configuration, params: DeleteProjectParams) -> Result<(), Error<DeleteProjectError>> {
let uri_str = format!("{}/projects/{project_name_or_id}", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_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(param_value) = params.x_is_resource_name {
req_builder = req_builder.header("X-Is-Resource-Name", 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<DeleteProjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_logs(configuration: &configuration::Configuration, params: GetLogsParams) -> Result<Vec<models::AuditLog>, Error<GetLogsError>> {
let uri_str = format!("{}/projects/{project_name}/logs", configuration.base_path, project_name=crate::apis::urlencode(params.project_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 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::AuditLog>`"))),
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::AuditLog>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetLogsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_project(configuration: &configuration::Configuration, params: GetProjectParams) -> Result<models::Project, Error<GetProjectError>> {
let uri_str = format!("{}/projects/{project_name_or_id}", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
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_is_resource_name {
req_builder = req_builder.header("X-Is-Resource-Name", 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::Project`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetProjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_project_deletable(configuration: &configuration::Configuration, params: GetProjectDeletableParams) -> Result<models::ProjectDeletable, Error<GetProjectDeletableError>> {
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));
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_is_resource_name {
req_builder = req_builder.header("X-Is-Resource-Name", 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::ProjectDeletable`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetProjectDeletableError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_project_summary(configuration: &configuration::Configuration, params: GetProjectSummaryParams) -> Result<models::ProjectSummary, Error<GetProjectSummaryError>> {
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));
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_is_resource_name {
req_builder = req_builder.header("X-Is-Resource-Name", 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::ProjectSummary`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetProjectSummaryError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_scanner_of_project(configuration: &configuration::Configuration, params: GetScannerOfProjectParams) -> Result<models::ScannerRegistration, Error<GetScannerOfProjectError>> {
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));
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_is_resource_name {
req_builder = req_builder.header("X-Is-Resource-Name", 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::ScannerRegistration`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetScannerOfProjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn head_project(configuration: &configuration::Configuration, params: HeadProjectParams) -> Result<(), Error<HeadProjectError>> {
let uri_str = format!("{}/projects", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::HEAD, &uri_str);
req_builder = req_builder.query(&[("project_name", ¶ms.project_name.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<HeadProjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn list_artifacts_of_project(configuration: &configuration::Configuration, params: ListArtifactsOfProjectParams) -> Result<Vec<models::Artifact>, Error<ListArtifactsOfProjectError>> {
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));
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_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 param_value) = params.latest_in_repository {
req_builder = req_builder.query(&[("latest_in_repository", ¶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_is_resource_name {
req_builder = req_builder.header("X-Is-Resource-Name", 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<ListArtifactsOfProjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn list_projects(configuration: &configuration::Configuration, params: ListProjectsParams) -> Result<Vec<models::Project>, Error<ListProjectsError>> {
let uri_str = format!("{}/projects", configuration.base_path);
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.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.sort {
req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.name {
req_builder = req_builder.query(&[("name", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.public {
req_builder = req_builder.query(&[("public", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.owner {
req_builder = req_builder.query(&[("owner", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.with_detail {
req_builder = req_builder.query(&[("with_detail", ¶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::Project>`"))),
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::Project>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListProjectsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn list_scanner_candidates_of_project(configuration: &configuration::Configuration, params: ListScannerCandidatesOfProjectParams) -> Result<Vec<models::ScannerRegistration>, Error<ListScannerCandidatesOfProjectError>> {
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));
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(param_value) = params.x_is_resource_name {
req_builder = req_builder.header("X-Is-Resource-Name", 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::ScannerRegistration>`"))),
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::ScannerRegistration>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListScannerCandidatesOfProjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn set_scanner_of_project(configuration: &configuration::Configuration, params: SetScannerOfProjectParams) -> Result<(), Error<SetScannerOfProjectError>> {
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));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &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_is_resource_name {
req_builder = req_builder.header("X-Is-Resource-Name", 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.payload);
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<SetScannerOfProjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn update_project(configuration: &configuration::Configuration, params: UpdateProjectParams) -> Result<(), Error<UpdateProjectError>> {
let uri_str = format!("{}/projects/{project_name_or_id}", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &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_is_resource_name {
req_builder = req_builder.header("X-Is-Resource-Name", 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.project);
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<UpdateProjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}