// @generated DO NOT EDIT.
//
// Generated from the CNB OpenAPI specification by `cnb-codegen`.
// Run `cargo run -p cnb-codegen --manifest-path codegen/Cargo.toml \
//      -- --spec codegen/spec/swagger.json --out src` to refresh.

#![allow(clippy::all)]
#![allow(missing_docs)]
#![allow(unused_imports)]
#![allow(unused_mut)]

use reqwest::Method;
use serde::Serialize;

use crate::error::{ApiError, Result};
use crate::http::HttpInner;
use crate::models;

// `Security` resource client (generated, 1 operations).

/// Resource client.
#[derive(Debug, Clone)]
pub struct SecurityClient {
    inner: HttpInner,
}

impl SecurityClient {
    /// Construct a new resource client. Normally obtained
    /// via [`crate::ApiClient`] rather than directly.
    pub fn new(inner: HttpInner) -> Self {
        Self { inner }
    }

    /// 查询仓库安全模块概览数据。Query the security overview data of a repository
    ///
    /// `GET /{repo}/-/security/overview`
    pub async fn get_repo_security_overview(
        &self,
        repo: String,
        query: &GetRepoSecurityOverviewQuery,
    ) -> Result<crate::models::RepoSecurityOverview> {
        let path = format!("/{}/-/security/overview", repo);
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(ref v) = query.types {
                pairs.append_pair("types", v);
            }
            if let Some(ref v) = query.tab {
                pairs.append_pair("tab", v);
            }
            drop(pairs);
        }
        self.inner
            .execute::<crate::models::RepoSecurityOverview>(Method::GET, url)
            .await
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetRepoSecurityOverviewQuery {
    /// 类型，多个类型用逗号分隔code_sensitive,code_vulnerability,code_issue,code_license 为空默认查询所有类型
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub types: Option<String>,
    /// 查询类型下开启或忽略的各风险类型概览数量,可选值：open,ignore,all，默认all
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub tab: Option<String>,
}

impl GetRepoSecurityOverviewQuery {
    /// Construct an empty query.
    pub fn new() -> Self {
        Self::default()
    }
    /// Set `types` query parameter.
    pub fn types(mut self, v: impl Into<String>) -> Self {
        self.types = Some(v.into());
        self
    }
    /// Set `tab` query parameter.
    pub fn tab(mut self, v: impl Into<String>) -> Self {
        self.tab = Some(v.into());
        self
    }
}
