netbox_openapi/models/
custom_field.rs

1/*
2 * NetBox REST API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 4.4.2-Docker-3.4.1 (4.4)
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11/// CustomField : 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 CustomField {
15    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
16    pub id: Option<i32>,
17    #[serde(rename = "url", skip_serializing_if = "Option::is_none")]
18    pub url: Option<String>,
19    #[serde(rename = "display_url", skip_serializing_if = "Option::is_none")]
20    pub display_url: Option<String>,
21    #[serde(rename = "display", skip_serializing_if = "Option::is_none")]
22    pub display: Option<String>,
23    #[serde(rename = "object_types")]
24    pub object_types: Vec<String>,
25    #[serde(rename = "type")]
26    pub r#type: Box<crate::models::CustomFieldType>,
27    #[serde(
28        rename = "related_object_type",
29        default,
30        with = "::serde_with::rust::double_option",
31        skip_serializing_if = "Option::is_none"
32    )]
33    pub related_object_type: Option<Option<String>>,
34    #[serde(rename = "data_type", skip_serializing_if = "Option::is_none")]
35    pub data_type: Option<String>,
36    /// Internal field name
37    #[serde(rename = "name")]
38    pub name: String,
39    /// Name of the field as displayed to users (if not provided, 'the field's name will be used)
40    #[serde(rename = "label", skip_serializing_if = "Option::is_none")]
41    pub label: Option<String>,
42    /// Custom fields within the same group will be displayed together
43    #[serde(rename = "group_name", skip_serializing_if = "Option::is_none")]
44    pub group_name: Option<String>,
45    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
46    pub description: Option<String>,
47    /// This field is required when creating new objects or editing an existing object.
48    #[serde(rename = "required", skip_serializing_if = "Option::is_none")]
49    pub required: Option<bool>,
50    /// The value of this field must be unique for the assigned object
51    #[serde(rename = "unique", skip_serializing_if = "Option::is_none")]
52    pub unique: Option<bool>,
53    /// Weighting for search. Lower values are considered more important. Fields with a search weight of zero will be ignored.
54    #[serde(rename = "search_weight", skip_serializing_if = "Option::is_none")]
55    pub search_weight: Option<i32>,
56    #[serde(rename = "filter_logic", skip_serializing_if = "Option::is_none")]
57    pub filter_logic: Option<Box<crate::models::CustomFieldFilterLogic>>,
58    #[serde(rename = "ui_visible", skip_serializing_if = "Option::is_none")]
59    pub ui_visible: Option<Box<crate::models::CustomFieldUiVisible>>,
60    #[serde(rename = "ui_editable", skip_serializing_if = "Option::is_none")]
61    pub ui_editable: Option<Box<crate::models::CustomFieldUiEditable>>,
62    /// Replicate this value when cloning objects
63    #[serde(rename = "is_cloneable", skip_serializing_if = "Option::is_none")]
64    pub is_cloneable: Option<bool>,
65    /// Default value for the field (must be a JSON value). Encapsulate strings with double quotes (e.g. \"Foo\").
66    #[serde(
67        rename = "default",
68        default,
69        with = "::serde_with::rust::double_option",
70        skip_serializing_if = "Option::is_none"
71    )]
72    pub default: Option<Option<serde_json::Value>>,
73    /// Filter the object selection choices using a query_params dict (must be a JSON value).Encapsulate strings with double quotes (e.g. \"Foo\").
74    #[serde(
75        rename = "related_object_filter",
76        default,
77        with = "::serde_with::rust::double_option",
78        skip_serializing_if = "Option::is_none"
79    )]
80    pub related_object_filter: Option<Option<serde_json::Value>>,
81    /// Fields with higher weights appear lower in a form.
82    #[serde(rename = "weight", skip_serializing_if = "Option::is_none")]
83    pub weight: Option<i32>,
84    /// Minimum allowed value (for numeric fields)
85    #[serde(
86        rename = "validation_minimum",
87        default,
88        with = "::serde_with::rust::double_option",
89        skip_serializing_if = "Option::is_none"
90    )]
91    pub validation_minimum: Option<Option<f64>>,
92    /// Maximum allowed value (for numeric fields)
93    #[serde(
94        rename = "validation_maximum",
95        default,
96        with = "::serde_with::rust::double_option",
97        skip_serializing_if = "Option::is_none"
98    )]
99    pub validation_maximum: Option<Option<f64>>,
100    /// Regular expression to enforce on text field values. Use ^ and $ to force matching of entire string. For example, <code>^[A-Z]{3}$</code> will limit values to exactly three uppercase letters.
101    #[serde(rename = "validation_regex", skip_serializing_if = "Option::is_none")]
102    pub validation_regex: Option<String>,
103    #[serde(
104        rename = "choice_set",
105        default,
106        with = "::serde_with::rust::double_option",
107        skip_serializing_if = "Option::is_none"
108    )]
109    pub choice_set: Option<Option<Box<crate::models::BriefCustomFieldChoiceSet>>>,
110    #[serde(rename = "comments", skip_serializing_if = "Option::is_none")]
111    pub comments: Option<String>,
112    #[serde(
113        rename = "created",
114        default,
115        with = "::serde_with::rust::double_option",
116        skip_serializing_if = "Option::is_none"
117    )]
118    pub created: Option<Option<String>>,
119    #[serde(
120        rename = "last_updated",
121        default,
122        with = "::serde_with::rust::double_option",
123        skip_serializing_if = "Option::is_none"
124    )]
125    pub last_updated: Option<Option<String>>,
126}
127
128impl CustomField {
129    /// 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>)
130    pub fn new(
131        object_types: Vec<String>,
132        r#type: crate::models::CustomFieldType,
133        name: String,
134    ) -> CustomField {
135        CustomField {
136            id: None,
137            url: None,
138            display_url: None,
139            display: None,
140            object_types,
141            r#type: Box::new(r#type),
142            related_object_type: None,
143            data_type: None,
144            name,
145            label: None,
146            group_name: None,
147            description: None,
148            required: None,
149            unique: None,
150            search_weight: None,
151            filter_logic: None,
152            ui_visible: None,
153            ui_editable: None,
154            is_cloneable: None,
155            default: None,
156            related_object_filter: None,
157            weight: None,
158            validation_minimum: None,
159            validation_maximum: None,
160            validation_regex: None,
161            choice_set: None,
162            comments: None,
163            created: None,
164            last_updated: None,
165        }
166    }
167}