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.6.2 (4.6)
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    /// A JSON schema definition for validating the custom field value
104    #[serde(
105        rename = "validation_schema",
106        default,
107        with = "::serde_with::rust::double_option",
108        skip_serializing_if = "Option::is_none"
109    )]
110    pub validation_schema: Option<Option<serde_json::Value>>,
111    #[serde(
112        rename = "choice_set",
113        default,
114        with = "::serde_with::rust::double_option",
115        skip_serializing_if = "Option::is_none"
116    )]
117    pub choice_set: Option<Option<Box<crate::models::BriefCustomFieldChoiceSet>>>,
118    #[serde(
119        rename = "owner",
120        default,
121        with = "::serde_with::rust::double_option",
122        skip_serializing_if = "Option::is_none"
123    )]
124    pub owner: Option<Option<Box<crate::models::BriefOwner>>>,
125    #[serde(rename = "comments", skip_serializing_if = "Option::is_none")]
126    pub comments: Option<String>,
127    #[serde(
128        rename = "created",
129        default,
130        with = "::serde_with::rust::double_option",
131        skip_serializing_if = "Option::is_none"
132    )]
133    pub created: Option<Option<String>>,
134    #[serde(
135        rename = "last_updated",
136        default,
137        with = "::serde_with::rust::double_option",
138        skip_serializing_if = "Option::is_none"
139    )]
140    pub last_updated: Option<Option<String>>,
141}
142
143impl CustomField {
144    /// Adds an `owner` field for models which have a ForeignKey to users.Owner.
145    pub fn new(
146        object_types: Vec<String>,
147        r#type: crate::models::CustomFieldType,
148        name: String,
149    ) -> CustomField {
150        CustomField {
151            id: None,
152            url: None,
153            display_url: None,
154            display: None,
155            object_types,
156            r#type: Box::new(r#type),
157            related_object_type: None,
158            data_type: None,
159            name,
160            label: None,
161            group_name: None,
162            description: None,
163            required: None,
164            unique: None,
165            search_weight: None,
166            filter_logic: None,
167            ui_visible: None,
168            ui_editable: None,
169            is_cloneable: None,
170            default: None,
171            related_object_filter: None,
172            weight: None,
173            validation_minimum: None,
174            validation_maximum: None,
175            validation_regex: None,
176            validation_schema: None,
177            choice_set: None,
178            owner: None,
179            comments: None,
180            created: None,
181            last_updated: None,
182        }
183    }
184}