Skip to main content

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.5.9-Docker-4.0.2 (4.5)
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11/// CustomField : Adds an `owner` field for models which have a ForeignKey to users.Owner.
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(
111        rename = "owner",
112        default,
113        with = "::serde_with::rust::double_option",
114        skip_serializing_if = "Option::is_none"
115    )]
116    pub owner: Option<Option<Box<crate::models::BriefOwner>>>,
117    #[serde(rename = "comments", skip_serializing_if = "Option::is_none")]
118    pub comments: Option<String>,
119    #[serde(
120        rename = "created",
121        default,
122        with = "::serde_with::rust::double_option",
123        skip_serializing_if = "Option::is_none"
124    )]
125    pub created: Option<Option<String>>,
126    #[serde(
127        rename = "last_updated",
128        default,
129        with = "::serde_with::rust::double_option",
130        skip_serializing_if = "Option::is_none"
131    )]
132    pub last_updated: Option<Option<String>>,
133}
134
135impl CustomField {
136    /// Adds an `owner` field for models which have a ForeignKey to users.Owner.
137    pub fn new(
138        object_types: Vec<String>,
139        r#type: crate::models::CustomFieldType,
140        name: String,
141    ) -> CustomField {
142        CustomField {
143            id: None,
144            url: None,
145            display_url: None,
146            display: None,
147            object_types,
148            r#type: Box::new(r#type),
149            related_object_type: None,
150            data_type: None,
151            name,
152            label: None,
153            group_name: None,
154            description: None,
155            required: None,
156            unique: None,
157            search_weight: None,
158            filter_logic: None,
159            ui_visible: None,
160            ui_editable: None,
161            is_cloneable: None,
162            default: None,
163            related_object_filter: None,
164            weight: None,
165            validation_minimum: None,
166            validation_maximum: None,
167            validation_regex: None,
168            choice_set: None,
169            owner: None,
170            comments: None,
171            created: None,
172            last_updated: None,
173        }
174    }
175}