Skip to main content

nautobot_openapi/models/
custom_link_request.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/// CustomLinkRequest : 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 CustomLinkRequest {
15    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
16    pub id: Option<uuid::Uuid>,
17    #[serde(rename = "content_type")]
18    pub content_type: String,
19    #[serde(rename = "name")]
20    pub name: String,
21    /// 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.
22    #[serde(rename = "text")]
23    pub text: String,
24    /// Jinja2 template code for link URL. Reference the object as <code>{{ obj }}</code> such as <code>{{ obj.platform.name }}</code>.
25    #[serde(rename = "target_url")]
26    pub target_url: String,
27    #[serde(rename = "weight", skip_serializing_if = "Option::is_none")]
28    pub weight: Option<i32>,
29    /// Links with the same group will appear as a dropdown menu
30    #[serde(rename = "group_name", skip_serializing_if = "Option::is_none")]
31    pub group_name: Option<String>,
32    #[serde(rename = "button_class", skip_serializing_if = "Option::is_none")]
33    pub button_class: Option<crate::models::ButtonClassEnum>,
34    /// Force link to open in a new window
35    #[serde(rename = "new_window")]
36    pub new_window: bool,
37}
38
39impl CustomLinkRequest {
40    /// 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>)
41    pub fn new(
42        content_type: String,
43        name: String,
44        text: String,
45        target_url: String,
46        new_window: bool,
47    ) -> CustomLinkRequest {
48        CustomLinkRequest {
49            id: None,
50            content_type,
51            name,
52            text,
53            target_url,
54            weight: None,
55            group_name: None,
56            button_class: None,
57            new_window,
58        }
59    }
60}