/*
 * Artifact Keeper API
 *
 * Enterprise artifact registry supporting 45+ package formats.  ## Authentication  The JSON management API under `/api/v1/_*` accepts **API tokens only as `Authorization: Bearer <token>`**. This is the canonical scheme for programmatic access; JWTs issued by the login flow also use `Bearer`. HTTP Basic credentials on `/api/v1/_*` are validated *only* as a real `username:password` login — the password half is **not** retried as an API token. A request to `/api/v1/_*` that sends an API token in the password field of Basic auth therefore returns `401 AUTH_ERROR`; switch to `Authorization: Bearer <token>`.  Format (package-manager) endpoints such as `/v2/_*` (OCI), `/incus/_*`, `/debian/_*`, and the language registries are intentionally more permissive for client compatibility: in addition to Bearer, they accept HTTP **Basic** auth with the API token supplied in the *password* field (any username), matching the `pip` netrc / Artifactory-style `token:<api_token>` convention used by package managers that cannot send a Bearer header. This Basic-with-token fallback applies to format endpoints only, never to `/api/v1/_*`.
 *
 * The version of the OpenAPI document: 1.4.1
 * 
 * Generated by: https://openapi-generator.tech
 */

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

/// SigningKeyPublic : Public view of a signing key (no private material).
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct SigningKeyPublic {
    #[serde(rename = "algorithm")]
    pub algorithm: String,
    #[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 = "fingerprint", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub fingerprint: Option<Option<String>>,
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    #[serde(rename = "is_active")]
    pub is_active: bool,
    #[serde(rename = "key_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub key_id: Option<Option<String>>,
    #[serde(rename = "key_type")]
    pub key_type: String,
    #[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,
    #[serde(rename = "public_key_pem")]
    pub public_key_pem: String,
    #[serde(rename = "repository_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub repository_id: Option<Option<uuid::Uuid>>,
    #[serde(rename = "uid_email", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub uid_email: Option<Option<String>>,
    #[serde(rename = "uid_name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub uid_name: Option<Option<String>>,
}

impl SigningKeyPublic {
    /// Public view of a signing key (no private material).
    pub fn new(algorithm: String, created_at: String, id: uuid::Uuid, is_active: bool, key_type: String, name: String, public_key_pem: String) -> SigningKeyPublic {
        SigningKeyPublic {
            algorithm,
            created_at,
            expires_at: None,
            fingerprint: None,
            id,
            is_active,
            key_id: None,
            key_type,
            last_used_at: None,
            name,
            public_key_pem,
            repository_id: None,
            uid_email: None,
            uid_name: None,
        }
    }
}

