netbox_openapi/models/
custom_field_request.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/// CustomFieldRequest : 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 CustomFieldRequest {
15    #[serde(rename = "object_types")]
16    pub object_types: Vec<String>,
17    /// * `text` - Text * `longtext` - Text (long) * `integer` - Integer * `decimal` - Decimal * `boolean` - Boolean (true/false) * `date` - Date * `datetime` - Date & time * `url` - URL * `json` - JSON * `select` - Selection * `multiselect` - Multiple selection * `object` - Object * `multiobject` - Multiple objects
18    #[serde(rename = "type")]
19    pub r#type: RHashType,
20    #[serde(
21        rename = "related_object_type",
22        default,
23        with = "::serde_with::rust::double_option",
24        skip_serializing_if = "Option::is_none"
25    )]
26    pub related_object_type: Option<Option<String>>,
27    /// Internal field name
28    #[serde(rename = "name")]
29    pub name: String,
30    /// Name of the field as displayed to users (if not provided, 'the field's name will be used)
31    #[serde(rename = "label", skip_serializing_if = "Option::is_none")]
32    pub label: Option<String>,
33    /// Custom fields within the same group will be displayed together
34    #[serde(rename = "group_name", skip_serializing_if = "Option::is_none")]
35    pub group_name: Option<String>,
36    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
37    pub description: Option<String>,
38    /// This field is required when creating new objects or editing an existing object.
39    #[serde(rename = "required", skip_serializing_if = "Option::is_none")]
40    pub required: Option<bool>,
41    /// The value of this field must be unique for the assigned object
42    #[serde(rename = "unique", skip_serializing_if = "Option::is_none")]
43    pub unique: Option<bool>,
44    /// Weighting for search. Lower values are considered more important. Fields with a search weight of zero will be ignored.
45    #[serde(rename = "search_weight", skip_serializing_if = "Option::is_none")]
46    pub search_weight: Option<i32>,
47    /// * `disabled` - Disabled * `loose` - Loose * `exact` - Exact
48    #[serde(rename = "filter_logic", skip_serializing_if = "Option::is_none")]
49    pub filter_logic: Option<FilterLogic>,
50    /// * `always` - Always * `if-set` - If set * `hidden` - Hidden
51    #[serde(rename = "ui_visible", skip_serializing_if = "Option::is_none")]
52    pub ui_visible: Option<UiVisible>,
53    /// * `yes` - Yes * `no` - No * `hidden` - Hidden
54    #[serde(rename = "ui_editable", skip_serializing_if = "Option::is_none")]
55    pub ui_editable: Option<UiEditable>,
56    /// Replicate this value when cloning objects
57    #[serde(rename = "is_cloneable", skip_serializing_if = "Option::is_none")]
58    pub is_cloneable: Option<bool>,
59    /// Default value for the field (must be a JSON value). Encapsulate strings with double quotes (e.g. \"Foo\").
60    #[serde(
61        rename = "default",
62        default,
63        with = "::serde_with::rust::double_option",
64        skip_serializing_if = "Option::is_none"
65    )]
66    pub default: Option<Option<serde_json::Value>>,
67    /// Filter the object selection choices using a query_params dict (must be a JSON value).Encapsulate strings with double quotes (e.g. \"Foo\").
68    #[serde(
69        rename = "related_object_filter",
70        default,
71        with = "::serde_with::rust::double_option",
72        skip_serializing_if = "Option::is_none"
73    )]
74    pub related_object_filter: Option<Option<serde_json::Value>>,
75    /// Fields with higher weights appear lower in a form.
76    #[serde(rename = "weight", skip_serializing_if = "Option::is_none")]
77    pub weight: Option<i32>,
78    /// Minimum allowed value (for numeric fields)
79    #[serde(
80        rename = "validation_minimum",
81        default,
82        with = "::serde_with::rust::double_option",
83        skip_serializing_if = "Option::is_none"
84    )]
85    pub validation_minimum: Option<Option<f64>>,
86    /// Maximum allowed value (for numeric fields)
87    #[serde(
88        rename = "validation_maximum",
89        default,
90        with = "::serde_with::rust::double_option",
91        skip_serializing_if = "Option::is_none"
92    )]
93    pub validation_maximum: Option<Option<f64>>,
94    /// 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.
95    #[serde(rename = "validation_regex", skip_serializing_if = "Option::is_none")]
96    pub validation_regex: Option<String>,
97    #[serde(
98        rename = "choice_set",
99        default,
100        with = "::serde_with::rust::double_option",
101        skip_serializing_if = "Option::is_none"
102    )]
103    pub choice_set: Option<Option<Box<crate::models::CustomFieldRequestChoiceSet>>>,
104    #[serde(rename = "comments", skip_serializing_if = "Option::is_none")]
105    pub comments: Option<String>,
106}
107
108impl CustomFieldRequest {
109    /// 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>)
110    pub fn new(object_types: Vec<String>, r#type: RHashType, name: String) -> CustomFieldRequest {
111        CustomFieldRequest {
112            object_types,
113            r#type,
114            related_object_type: None,
115            name,
116            label: None,
117            group_name: None,
118            description: None,
119            required: None,
120            unique: None,
121            search_weight: None,
122            filter_logic: None,
123            ui_visible: None,
124            ui_editable: None,
125            is_cloneable: None,
126            default: None,
127            related_object_filter: None,
128            weight: None,
129            validation_minimum: None,
130            validation_maximum: None,
131            validation_regex: None,
132            choice_set: None,
133            comments: None,
134        }
135    }
136}
137
138/// * `text` - Text * `longtext` - Text (long) * `integer` - Integer * `decimal` - Decimal * `boolean` - Boolean (true/false) * `date` - Date * `datetime` - Date & time * `url` - URL * `json` - JSON * `select` - Selection * `multiselect` - Multiple selection * `object` - Object * `multiobject` - Multiple objects
139#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
140pub enum RHashType {
141    #[serde(rename = "text")]
142    Text,
143    #[serde(rename = "longtext")]
144    Longtext,
145    #[serde(rename = "integer")]
146    Integer,
147    #[serde(rename = "decimal")]
148    Decimal,
149    #[serde(rename = "boolean")]
150    Boolean,
151    #[serde(rename = "date")]
152    Date,
153    #[serde(rename = "datetime")]
154    Datetime,
155    #[serde(rename = "url")]
156    Url,
157    #[serde(rename = "json")]
158    Json,
159    #[serde(rename = "select")]
160    Select,
161    #[serde(rename = "multiselect")]
162    Multiselect,
163    #[serde(rename = "object")]
164    Object,
165    #[serde(rename = "multiobject")]
166    Multiobject,
167}
168
169impl Default for RHashType {
170    fn default() -> RHashType {
171        Self::Text
172    }
173}
174/// * `disabled` - Disabled * `loose` - Loose * `exact` - Exact
175#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
176pub enum FilterLogic {
177    #[serde(rename = "disabled")]
178    Disabled,
179    #[serde(rename = "loose")]
180    Loose,
181    #[serde(rename = "exact")]
182    Exact,
183}
184
185impl Default for FilterLogic {
186    fn default() -> FilterLogic {
187        Self::Disabled
188    }
189}
190/// * `always` - Always * `if-set` - If set * `hidden` - Hidden
191#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
192pub enum UiVisible {
193    #[serde(rename = "always")]
194    Always,
195    #[serde(rename = "if-set")]
196    IfSet,
197    #[serde(rename = "hidden")]
198    Hidden,
199}
200
201impl Default for UiVisible {
202    fn default() -> UiVisible {
203        Self::Always
204    }
205}
206/// * `yes` - Yes * `no` - No * `hidden` - Hidden
207#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
208pub enum UiEditable {
209    #[serde(rename = "yes")]
210    Yes,
211    #[serde(rename = "no")]
212    No,
213    #[serde(rename = "hidden")]
214    Hidden,
215}
216
217impl Default for UiEditable {
218    fn default() -> UiEditable {
219        Self::Yes
220    }
221}