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

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct TokenInfoResponse {
    #[serde(rename = "created_at")]
    pub created_at: String,
    #[serde(rename = "expires_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub expires_at: Option<Option<String>>,
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    #[serde(rename = "is_expired")]
    pub is_expired: bool,
    #[serde(rename = "last_used_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub last_used_at: Option<Option<String>>,
    #[serde(rename = "name")]
    pub name: String,
    /// Dynamic repository selector, if configured.
    #[serde(rename = "repo_selector", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub repo_selector: Option<Option<serde_json::Value>>,
    /// Explicit repository IDs this token is restricted to (from join table).
    #[serde(rename = "repository_ids")]
    pub repository_ids: Vec<uuid::Uuid>,
    #[serde(rename = "scopes")]
    pub scopes: Vec<String>,
    #[serde(rename = "token_prefix")]
    pub token_prefix: String,
}

impl TokenInfoResponse {
    pub fn new(created_at: String, id: uuid::Uuid, is_expired: bool, name: String, repository_ids: Vec<uuid::Uuid>, scopes: Vec<String>, token_prefix: String) -> TokenInfoResponse {
        TokenInfoResponse {
            created_at,
            expires_at: None,
            id,
            is_expired,
            last_used_at: None,
            name,
            repo_selector: None,
            repository_ids,
            scopes,
            token_prefix,
        }
    }
}

