openapi-github 0.1.0

OpenAPI specs from https://github.com/github/rest-api-description with the 'x-octokit' extension required by the Octokit SDKs
Documentation
/*
 * GitHub's official OpenAPI spec + Octokit extension
 *
 * OpenAPI specs from https://github.com/github/rest-api-description with the 'x-octokit' extension required by the Octokit SDKs
 *
 * The version of the OpenAPI document: 16.6.0
 * 
 * Generated by: https://openapi-generator.tech
 */

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

/// GlobalAdvisory : A GitHub Security Advisory.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct GlobalAdvisory {
    /// The GitHub Security Advisory ID.
    #[serde(rename = "ghsa_id")]
    pub ghsa_id: String,
    /// The Common Vulnerabilities and Exposures (CVE) ID.
    #[serde(rename = "cve_id", deserialize_with = "Option::deserialize")]
    pub cve_id: Option<String>,
    /// The API URL for the advisory.
    #[serde(rename = "url")]
    pub url: String,
    /// The URL for the advisory.
    #[serde(rename = "html_url")]
    pub html_url: String,
    /// The API URL for the repository advisory.
    #[serde(rename = "repository_advisory_url", deserialize_with = "Option::deserialize")]
    pub repository_advisory_url: Option<String>,
    /// A short summary of the advisory.
    #[serde(rename = "summary")]
    pub summary: String,
    /// A detailed description of what the advisory entails.
    #[serde(rename = "description", deserialize_with = "Option::deserialize")]
    pub description: Option<String>,
    /// The type of advisory.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The severity of the advisory.
    #[serde(rename = "severity")]
    pub severity: Severity,
    /// The URL of the advisory's source code.
    #[serde(rename = "source_code_location", deserialize_with = "Option::deserialize")]
    pub source_code_location: Option<String>,
    #[serde(rename = "identifiers", deserialize_with = "Option::deserialize")]
    pub identifiers: Option<Vec<models::GlobalAdvisoryIdentifiersInner>>,
    #[serde(rename = "references", deserialize_with = "Option::deserialize")]
    pub references: Option<Vec<String>>,
    /// The date and time of when the advisory was published, in ISO 8601 format.
    #[serde(rename = "published_at")]
    pub published_at: String,
    /// The date and time of when the advisory was last updated, in ISO 8601 format.
    #[serde(rename = "updated_at")]
    pub updated_at: String,
    /// The date and time of when the advisory was reviewed by GitHub, in ISO 8601 format.
    #[serde(rename = "github_reviewed_at", deserialize_with = "Option::deserialize")]
    pub github_reviewed_at: Option<String>,
    /// The date and time when the advisory was published in the National Vulnerability Database, in ISO 8601 format. This field is only populated when the advisory is imported from the National Vulnerability Database.
    #[serde(rename = "nvd_published_at", deserialize_with = "Option::deserialize")]
    pub nvd_published_at: Option<String>,
    /// The date and time of when the advisory was withdrawn, in ISO 8601 format.
    #[serde(rename = "withdrawn_at", deserialize_with = "Option::deserialize")]
    pub withdrawn_at: Option<String>,
    /// The products and respective version ranges affected by the advisory.
    #[serde(rename = "vulnerabilities", deserialize_with = "Option::deserialize")]
    pub vulnerabilities: Option<Vec<models::Vulnerability>>,
    #[serde(rename = "cvss", deserialize_with = "Option::deserialize")]
    pub cvss: Option<Box<models::GlobalAdvisoryCvss>>,
    #[serde(rename = "cwes", deserialize_with = "Option::deserialize")]
    pub cwes: Option<Vec<models::GlobalAdvisoryCwesInner>>,
    /// The users who contributed to the advisory.
    #[serde(rename = "credits", deserialize_with = "Option::deserialize")]
    pub credits: Option<Vec<models::GlobalAdvisoryCreditsInner>>,
}

impl GlobalAdvisory {
    /// A GitHub Security Advisory.
    pub fn new(ghsa_id: String, cve_id: Option<String>, url: String, html_url: String, repository_advisory_url: Option<String>, summary: String, description: Option<String>, r#type: Type, severity: Severity, source_code_location: Option<String>, identifiers: Option<Vec<models::GlobalAdvisoryIdentifiersInner>>, references: Option<Vec<String>>, published_at: String, updated_at: String, github_reviewed_at: Option<String>, nvd_published_at: Option<String>, withdrawn_at: Option<String>, vulnerabilities: Option<Vec<models::Vulnerability>>, cvss: Option<models::GlobalAdvisoryCvss>, cwes: Option<Vec<models::GlobalAdvisoryCwesInner>>, credits: Option<Vec<models::GlobalAdvisoryCreditsInner>>) -> GlobalAdvisory {
        GlobalAdvisory {
            ghsa_id,
            cve_id,
            url,
            html_url,
            repository_advisory_url,
            summary,
            description,
            r#type,
            severity,
            source_code_location,
            identifiers,
            references,
            published_at,
            updated_at,
            github_reviewed_at,
            nvd_published_at,
            withdrawn_at,
            vulnerabilities,
            cvss: cvss.map(Box::new),
            cwes,
            credits,
        }
    }
}
/// The type of advisory.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "reviewed")]
    Reviewed,
    #[serde(rename = "unreviewed")]
    Unreviewed,
    #[serde(rename = "malware")]
    Malware,
}

impl Default for Type {
    fn default() -> Type {
        Self::Reviewed
    }
}
/// The severity of the advisory.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Severity {
    #[serde(rename = "critical")]
    Critical,
    #[serde(rename = "high")]
    High,
    #[serde(rename = "medium")]
    Medium,
    #[serde(rename = "low")]
    Low,
    #[serde(rename = "unknown")]
    Unknown,
}

impl Default for Severity {
    fn default() -> Severity {
        Self::Critical
    }
}