/*
 * API Documentation
 *
 * Source of truth and network automation platform
 *
 * The version of the OpenAPI document: 3.1.0 (3.1)
 *
 * Generated by: https://openapi-generator.tech
 */

/// CustomLink : Extends the built-in ModelSerializer to enforce calling full_clean() on a copy of the associated instance during validation. (DRF does not do this by default; see <https://github.com/encode/django-rest-framework/issues/3144>)

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct CustomLink {
    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
    pub id: Option<uuid::Uuid>,
    #[serde(rename = "object_type", skip_serializing_if = "Option::is_none")]
    pub object_type: Option<String>,
    /// Human friendly display value
    #[serde(rename = "display", skip_serializing_if = "Option::is_none")]
    pub display: Option<String>,
    #[serde(rename = "url", skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,
    #[serde(rename = "natural_slug", skip_serializing_if = "Option::is_none")]
    pub natural_slug: Option<String>,
    #[serde(rename = "content_type")]
    pub content_type: String,
    #[serde(rename = "name")]
    pub name: String,
    /// Jinja2 template code for link text. Reference the object as <code>{{ obj }}</code> such as <code>{{ obj.platform.name }}</code>. Links which render as empty text will not be displayed.
    #[serde(rename = "text")]
    pub text: String,
    /// Jinja2 template code for link URL. Reference the object as <code>{{ obj }}</code> such as <code>{{ obj.platform.name }}</code>.
    #[serde(rename = "target_url")]
    pub target_url: String,
    #[serde(rename = "weight", skip_serializing_if = "Option::is_none")]
    pub weight: Option<i32>,
    /// Links with the same group will appear as a dropdown menu
    #[serde(rename = "group_name", skip_serializing_if = "Option::is_none")]
    pub group_name: Option<String>,
    #[serde(rename = "button_class", skip_serializing_if = "Option::is_none")]
    pub button_class: Option<crate::models::ButtonClassEnum>,
    /// Force link to open in a new window
    #[serde(rename = "new_window")]
    pub new_window: bool,
    #[serde(
        rename = "created",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub created: Option<Option<String>>,
    #[serde(
        rename = "last_updated",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub last_updated: Option<Option<String>>,
    #[serde(rename = "notes_url", skip_serializing_if = "Option::is_none")]
    pub notes_url: Option<String>,
}

impl CustomLink {
    /// Extends the built-in ModelSerializer to enforce calling full_clean() on a copy of the associated instance during validation. (DRF does not do this by default; see <https://github.com/encode/django-rest-framework/issues/3144>)
    pub fn new(
        content_type: String,
        name: String,
        text: String,
        target_url: String,
        new_window: bool,
    ) -> CustomLink {
        CustomLink {
            id: None,
            object_type: None,
            display: None,
            url: None,
            natural_slug: None,
            content_type,
            name,
            text,
            target_url,
            weight: None,
            group_name: None,
            button_class: None,
            new_window,
            created: None,
            last_updated: None,
            notes_url: None,
        }
    }
}
