Skip to main content

nautobot_openapi/models/
computed_field_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/// ComputedFieldRequest : 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 ComputedFieldRequest {
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    /// Internal field name. Please use underscores rather than dashes in this key.
20    #[serde(rename = "key", skip_serializing_if = "Option::is_none")]
21    pub key: Option<String>,
22    /// Human-readable grouping that this computed field belongs to.
23    #[serde(rename = "grouping", skip_serializing_if = "Option::is_none")]
24    pub grouping: Option<String>,
25    /// Name of the field as displayed to users
26    #[serde(rename = "label")]
27    pub label: String,
28    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
29    pub description: Option<String>,
30    /// Jinja2 template code for field value
31    #[serde(rename = "template")]
32    pub template: String,
33    /// Fallback value (if any) to be output for the field in the case of a template rendering error.
34    #[serde(rename = "fallback_value", skip_serializing_if = "Option::is_none")]
35    pub fallback_value: Option<String>,
36    #[serde(rename = "weight", skip_serializing_if = "Option::is_none")]
37    pub weight: Option<i32>,
38    /// Hide this field from the object's primary information tab. It will appear in the \"Advanced\" tab instead.
39    #[serde(rename = "advanced_ui", skip_serializing_if = "Option::is_none")]
40    pub advanced_ui: Option<bool>,
41}
42
43impl ComputedFieldRequest {
44    /// 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>)
45    pub fn new(content_type: String, label: String, template: String) -> ComputedFieldRequest {
46        ComputedFieldRequest {
47            id: None,
48            content_type,
49            key: None,
50            grouping: None,
51            label,
52            description: None,
53            template,
54            fallback_value: None,
55            weight: None,
56            advanced_ui: None,
57        }
58    }
59}