Skip to main content

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