Skip to main content

nautobot_openapi/models/
custom_link.rs

1/*
2 * API Documentation
3 *
4 * Source of truth and network automation platform
5 *
6 * The version of the OpenAPI document: 3.1.0 (3.1)
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11/// 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>)
12
13#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
14pub struct CustomLink {
15    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
16    pub id: Option<uuid::Uuid>,
17    #[serde(rename = "object_type", skip_serializing_if = "Option::is_none")]
18    pub object_type: Option<String>,
19    /// Human friendly display value
20    #[serde(rename = "display", skip_serializing_if = "Option::is_none")]
21    pub display: Option<String>,
22    #[serde(rename = "url", skip_serializing_if = "Option::is_none")]
23    pub url: Option<String>,
24    #[serde(rename = "natural_slug", skip_serializing_if = "Option::is_none")]
25    pub natural_slug: Option<String>,
26    #[serde(rename = "content_type")]
27    pub content_type: String,
28    #[serde(rename = "name")]
29    pub name: String,
30    /// 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.
31    #[serde(rename = "text")]
32    pub text: String,
33    /// Jinja2 template code for link URL. Reference the object as <code>{{ obj }}</code> such as <code>{{ obj.platform.name }}</code>.
34    #[serde(rename = "target_url")]
35    pub target_url: String,
36    #[serde(rename = "weight", skip_serializing_if = "Option::is_none")]
37    pub weight: Option<i32>,
38    /// Links with the same group will appear as a dropdown menu
39    #[serde(rename = "group_name", skip_serializing_if = "Option::is_none")]
40    pub group_name: Option<String>,
41    #[serde(rename = "button_class", skip_serializing_if = "Option::is_none")]
42    pub button_class: Option<crate::models::ButtonClassEnum>,
43    /// Force link to open in a new window
44    #[serde(rename = "new_window")]
45    pub new_window: bool,
46    #[serde(
47        rename = "created",
48        default,
49        with = "::serde_with::rust::double_option",
50        skip_serializing_if = "Option::is_none"
51    )]
52    pub created: Option<Option<String>>,
53    #[serde(
54        rename = "last_updated",
55        default,
56        with = "::serde_with::rust::double_option",
57        skip_serializing_if = "Option::is_none"
58    )]
59    pub last_updated: Option<Option<String>>,
60    #[serde(rename = "notes_url", skip_serializing_if = "Option::is_none")]
61    pub notes_url: Option<String>,
62}
63
64impl CustomLink {
65    /// 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>)
66    pub fn new(
67        content_type: String,
68        name: String,
69        text: String,
70        target_url: String,
71        new_window: bool,
72    ) -> CustomLink {
73        CustomLink {
74            id: None,
75            object_type: None,
76            display: None,
77            url: None,
78            natural_slug: None,
79            content_type,
80            name,
81            text,
82            target_url,
83            weight: None,
84            group_name: None,
85            button_class: None,
86            new_window,
87            created: None,
88            last_updated: None,
89            notes_url: None,
90        }
91    }
92}