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