/*
 * Artifact Keeper API
 *
 * Enterprise artifact registry supporting 45+ package formats.
 *
 * The version of the OpenAPI document: 1.2.1
 * 
 * Generated by: https://openapi-generator.tech
 */

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct PermissionResponse {
    #[serde(rename = "actions")]
    pub actions: Vec<String>,
    #[serde(rename = "created_at")]
    pub created_at: String,
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    #[serde(rename = "principal_id")]
    pub principal_id: uuid::Uuid,
    #[serde(rename = "principal_name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub principal_name: Option<Option<String>>,
    #[serde(rename = "principal_type")]
    pub principal_type: String,
    #[serde(rename = "target_id")]
    pub target_id: uuid::Uuid,
    #[serde(rename = "target_name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub target_name: Option<Option<String>>,
    #[serde(rename = "target_type")]
    pub target_type: String,
    #[serde(rename = "updated_at")]
    pub updated_at: String,
}

impl PermissionResponse {
    pub fn new(actions: Vec<String>, created_at: String, id: uuid::Uuid, principal_id: uuid::Uuid, principal_type: String, target_id: uuid::Uuid, target_type: String, updated_at: String) -> PermissionResponse {
        PermissionResponse {
            actions,
            created_at,
            id,
            principal_id,
            principal_name: None,
            principal_type,
            target_id,
            target_name: None,
            target_type,
            updated_at,
        }
    }
}

