Skip to main content

nautobot_openapi/models/
computed_field.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/// ComputedField : 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 ComputedField {
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    /// Internal field name. Please use underscores rather than dashes in this key.
29    #[serde(rename = "key", skip_serializing_if = "Option::is_none")]
30    pub key: Option<String>,
31    /// Human-readable grouping that this computed field belongs to.
32    #[serde(rename = "grouping", skip_serializing_if = "Option::is_none")]
33    pub grouping: Option<String>,
34    /// Name of the field as displayed to users
35    #[serde(rename = "label")]
36    pub label: String,
37    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
38    pub description: Option<String>,
39    /// Jinja2 template code for field value
40    #[serde(rename = "template")]
41    pub template: String,
42    /// Fallback value (if any) to be output for the field in the case of a template rendering error.
43    #[serde(rename = "fallback_value", skip_serializing_if = "Option::is_none")]
44    pub fallback_value: Option<String>,
45    #[serde(rename = "weight", skip_serializing_if = "Option::is_none")]
46    pub weight: Option<i32>,
47    /// Hide this field from the object's primary information tab. It will appear in the \"Advanced\" tab instead.
48    #[serde(rename = "advanced_ui", skip_serializing_if = "Option::is_none")]
49    pub advanced_ui: Option<bool>,
50    #[serde(
51        rename = "created",
52        default,
53        with = "::serde_with::rust::double_option",
54        skip_serializing_if = "Option::is_none"
55    )]
56    pub created: Option<Option<String>>,
57    #[serde(
58        rename = "last_updated",
59        default,
60        with = "::serde_with::rust::double_option",
61        skip_serializing_if = "Option::is_none"
62    )]
63    pub last_updated: Option<Option<String>>,
64    #[serde(rename = "notes_url", skip_serializing_if = "Option::is_none")]
65    pub notes_url: Option<String>,
66}
67
68impl ComputedField {
69    /// 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>)
70    pub fn new(content_type: String, label: String, template: String) -> ComputedField {
71        ComputedField {
72            id: None,
73            object_type: None,
74            display: None,
75            url: None,
76            natural_slug: None,
77            content_type,
78            key: None,
79            grouping: None,
80            label,
81            description: None,
82            template,
83            fallback_value: None,
84            weight: None,
85            advanced_ui: None,
86            created: None,
87            last_updated: None,
88            notes_url: None,
89        }
90    }
91}