/*
 * Artifact Keeper API
 *
 * REST API for Artifact Keeper, an open-source universal artifact registry. Covers user management, repositories, artifacts, search, security scanning, SBOM, dependency tracking, SSO, analytics, monitoring, telemetry, lifecycle policies, plugins, edge nodes, migration, and administration. Format-specific protocol endpoints (npm, PyPI, Maven, Docker/OCI, etc.) are not included; those follow their respective upstream specifications.
 *
 * The version of the OpenAPI document: 1.0.0-a2
 * 
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct UpsertLicensePolicyRequest {
    /// Scope the policy to a specific repository. Null for global policies.
    #[serde(rename = "repository_id", skip_serializing_if = "Option::is_none")]
    pub repository_id: Option<uuid::Uuid>,
    /// Human-readable policy name.
    #[serde(rename = "name")]
    pub name: String,
    /// Optional description of the policy intent.
    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// SPDX license identifiers that are explicitly permitted.
    #[serde(rename = "allowed_licenses")]
    pub allowed_licenses: Vec<String>,
    /// SPDX license identifiers that are explicitly prohibited.
    #[serde(rename = "denied_licenses")]
    pub denied_licenses: Vec<String>,
    /// Whether to permit artifacts with unrecognised licenses.
    #[serde(rename = "allow_unknown")]
    pub allow_unknown: bool,
    /// Enforcement action when a violation is detected (e.g. warn, block).
    #[serde(rename = "action")]
    pub action: String,
    /// Whether the policy is currently active.
    #[serde(rename = "is_enabled")]
    pub is_enabled: bool,
}

impl UpsertLicensePolicyRequest {
    pub fn new(name: String, allowed_licenses: Vec<String>, denied_licenses: Vec<String>, allow_unknown: bool, action: String, is_enabled: bool) -> UpsertLicensePolicyRequest {
        UpsertLicensePolicyRequest {
            repository_id: None,
            name,
            description: None,
            allowed_licenses,
            denied_licenses,
            allow_unknown,
            action,
            is_enabled,
        }
    }
}

