/*
 * 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 LicensePolicyResponse {
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    /// Repository this policy is scoped to. Null for global policies.
    #[serde(rename = "repository_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub repository_id: Option<Option<uuid::Uuid>>,
    /// Human-readable policy name.
    #[serde(rename = "name")]
    pub name: String,
    /// Optional description of the policy intent.
    #[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub description: Option<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 artifacts with unrecognised licenses are permitted.
    #[serde(rename = "allow_unknown")]
    pub allow_unknown: bool,
    /// Enforcement action on violation (e.g. warn, block).
    #[serde(rename = "action")]
    pub action: String,
    /// Whether the policy is currently active.
    #[serde(rename = "is_enabled")]
    pub is_enabled: bool,
    #[serde(rename = "created_at")]
    pub created_at: String,
    #[serde(rename = "updated_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub updated_at: Option<Option<String>>,
}

impl LicensePolicyResponse {
    pub fn new(id: uuid::Uuid, name: String, allowed_licenses: Vec<String>, denied_licenses: Vec<String>, allow_unknown: bool, action: String, is_enabled: bool, created_at: String) -> LicensePolicyResponse {
        LicensePolicyResponse {
            id,
            repository_id: None,
            name,
            description: None,
            allowed_licenses,
            denied_licenses,
            allow_unknown,
            action,
            is_enabled,
            created_at,
            updated_at: None,
        }
    }
}

