use serde::{Deserialize, Serialize};

/// OCI manifest
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OciManifest {
    #[serde(rename = "schemaVersion")]
    pub schema_version: u32,
    #[serde(rename = "mediaType")]
    pub media_type: String,
    pub config: OciDescriptor,
    pub layers: Vec<OciDescriptor>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub annotations: Option<std::collections::HashMap<String, String>>,
}

/// OCI descriptor
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OciDescriptor {
    #[serde(rename = "mediaType")]
    pub media_type: String,
    pub digest: String,
    pub size: u64,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub annotations: Option<std::collections::HashMap<String, String>>,
}

/// OCI catalog response
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OciCatalog {
    pub repositories: Vec<String>,
}

/// OCI tags list
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OciTagsList {
    pub name: String,
    pub tags: Vec<String>,
}

/// OCI authentication token
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OciAuthToken {
    pub token: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub access_token: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub expires_in: Option<u64>,
}
