Skip to main content

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.6.2 (4.6)
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11/// CustomFieldRequest : Adds an `owner` field for models which have a ForeignKey to users.Owner.
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    /// A JSON schema definition for validating the custom field value
98    #[serde(
99        rename = "validation_schema",
100        default,
101        with = "::serde_with::rust::double_option",
102        skip_serializing_if = "Option::is_none"
103    )]
104    pub validation_schema: Option<Option<serde_json::Value>>,
105    #[serde(
106        rename = "choice_set",
107        default,
108        with = "::serde_with::rust::double_option",
109        skip_serializing_if = "Option::is_none"
110    )]
111    pub choice_set: Option<Option<Box<crate::models::CustomFieldRequestChoiceSet>>>,
112    #[serde(
113        rename = "owner",
114        default,
115        with = "::serde_with::rust::double_option",
116        skip_serializing_if = "Option::is_none"
117    )]
118    pub owner: Option<Option<Box<crate::models::AsnRangeRequestOwner>>>,
119    #[serde(rename = "comments", skip_serializing_if = "Option::is_none")]
120    pub comments: Option<String>,
121}
122
123impl CustomFieldRequest {
124    /// Adds an `owner` field for models which have a ForeignKey to users.Owner.
125    pub fn new(object_types: Vec<String>, r#type: RHashType, name: String) -> CustomFieldRequest {
126        CustomFieldRequest {
127            object_types,
128            r#type,
129            related_object_type: None,
130            name,
131            label: None,
132            group_name: None,
133            description: None,
134            required: None,
135            unique: None,
136            search_weight: None,
137            filter_logic: None,
138            ui_visible: None,
139            ui_editable: None,
140            is_cloneable: None,
141            default: None,
142            related_object_filter: None,
143            weight: None,
144            validation_minimum: None,
145            validation_maximum: None,
146            validation_regex: None,
147            validation_schema: None,
148            choice_set: None,
149            owner: None,
150            comments: None,
151        }
152    }
153}
154
155/// * `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
156#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
157pub enum RHashType {
158    #[serde(rename = "text")]
159    Text,
160    #[serde(rename = "longtext")]
161    Longtext,
162    #[serde(rename = "integer")]
163    Integer,
164    #[serde(rename = "decimal")]
165    Decimal,
166    #[serde(rename = "boolean")]
167    Boolean,
168    #[serde(rename = "date")]
169    Date,
170    #[serde(rename = "datetime")]
171    Datetime,
172    #[serde(rename = "url")]
173    Url,
174    #[serde(rename = "json")]
175    Json,
176    #[serde(rename = "select")]
177    Select,
178    #[serde(rename = "multiselect")]
179    Multiselect,
180    #[serde(rename = "object")]
181    Object,
182    #[serde(rename = "multiobject")]
183    Multiobject,
184}
185
186impl Default for RHashType {
187    fn default() -> RHashType {
188        Self::Text
189    }
190}
191/// * `disabled` - Disabled * `loose` - Loose * `exact` - Exact
192#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
193pub enum FilterLogic {
194    #[serde(rename = "disabled")]
195    Disabled,
196    #[serde(rename = "loose")]
197    Loose,
198    #[serde(rename = "exact")]
199    Exact,
200}
201
202impl Default for FilterLogic {
203    fn default() -> FilterLogic {
204        Self::Disabled
205    }
206}
207/// * `always` - Always * `if-set` - If set * `hidden` - Hidden
208#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
209pub enum UiVisible {
210    #[serde(rename = "always")]
211    Always,
212    #[serde(rename = "if-set")]
213    IfSet,
214    #[serde(rename = "hidden")]
215    Hidden,
216}
217
218impl Default for UiVisible {
219    fn default() -> UiVisible {
220        Self::Always
221    }
222}
223/// * `yes` - Yes * `no` - No * `hidden` - Hidden
224#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
225pub enum UiEditable {
226    #[serde(rename = "yes")]
227    Yes,
228    #[serde(rename = "no")]
229    No,
230    #[serde(rename = "hidden")]
231    Hidden,
232}
233
234impl Default for UiEditable {
235    fn default() -> UiEditable {
236        Self::Yes
237    }
238}