use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
pub struct Spec {
    #[serde(rename = "ociVersion")]
    pub version: String,
    pub process: Option<Process>,
    pub root: Option<Root>,
    pub hostname: String,
    pub mounts: Vec<Mount>,
}

#[derive(Serialize, Deserialize)]
pub struct Process {
    terminal: bool,
    console_size: Option<Box>,
    user: User,
    args: Vec<String>,
    env: Vec<String>,
    cwd: String,
    capabilities: Option<Capabilities>,
    rlimits: Vec<RLimit>,
    #[serde(rename = "apparmorProfile")]
    apparmor_profile: String,
    #[serde(rename = "oomScoreAdj")]
    oom_score_adj: u64,
    #[serde(rename = "selinuxLabel")]
    selinux_label: String,
    #[serde(rename = "noNewPrivileges")]
    no_new_privileges: bool,
}

#[derive(Serialize, Deserialize)]
pub struct User {
    uid: u64,
    gid: u64,
    additional_gids: Option<Vec<u64>>,
}

#[derive(Serialize, Deserialize)]
pub struct Root {
    path: String,
    readonly: bool,
}

#[derive(Serialize, Deserialize)]
pub struct Box {
    height: u64,
    width: u64,
}

#[derive(Serialize, Deserialize)]
pub struct Capabilities {
    bounding: Vec<String>,
    permitted: Vec<String>,
    inheritable: Vec<String>,
    effective: Vec<String>,
    ambient: Vec<String>,
}

#[derive(Serialize, Deserialize)]
pub struct Mount {
    destination: String,
    #[serde(rename = "type")]
    fs_type: String,
    source: String,
    options: Option<Vec<String>>,
}

#[derive(Serialize, Deserialize)]
pub struct RLimit {
    #[serde(rename = "type")]
    typ: String,
    soft: u64,
    hard: u64,
}
