Skip to main content

nautobot_openapi/models/
writable_custom_field_request.rs

1/*
2 * API Documentation
3 *
4 * Source of truth and network automation platform
5 *
6 * The version of the OpenAPI document: 3.1.0 (3.1)
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11/// WritableCustomFieldRequest : 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 WritableCustomFieldRequest {
15    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
16    pub id: Option<uuid::Uuid>,
17    #[serde(rename = "content_types")]
18    pub content_types: Vec<String>,
19    #[serde(rename = "label")]
20    pub label: String,
21    /// Human-readable grouping that this custom field belongs to.
22    #[serde(rename = "grouping", skip_serializing_if = "Option::is_none")]
23    pub grouping: Option<String>,
24    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
25    pub r#type: Option<crate::models::CustomFieldTypeChoices>,
26    /// Internal field name. Please use underscores rather than dashes in this key.
27    #[serde(rename = "key", skip_serializing_if = "Option::is_none")]
28    pub key: Option<String>,
29    /// A helpful description for this field.
30    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
31    pub description: Option<String>,
32    /// If true, this field is required when creating new objects or editing an existing object.
33    #[serde(rename = "required", skip_serializing_if = "Option::is_none")]
34    pub required: Option<bool>,
35    #[serde(rename = "filter_logic", skip_serializing_if = "Option::is_none")]
36    pub filter_logic: Option<crate::models::FilterLogicEnum>,
37    /// Default value for the field (must be a JSON value). Encapsulate strings with double quotes (e.g. \"Foo\").
38    #[serde(
39        rename = "default",
40        default,
41        with = "::serde_with::rust::double_option",
42        skip_serializing_if = "Option::is_none"
43    )]
44    pub default: Option<Option<serde_json::Value>>,
45    /// Fields with higher weights appear lower in a form.
46    #[serde(rename = "weight", skip_serializing_if = "Option::is_none")]
47    pub weight: Option<i32>,
48    /// Minimum allowed value (for numeric fields) or length (for text fields).
49    #[serde(
50        rename = "validation_minimum",
51        default,
52        with = "::serde_with::rust::double_option",
53        skip_serializing_if = "Option::is_none"
54    )]
55    pub validation_minimum: Option<Option<i64>>,
56    /// Maximum allowed value (for numeric fields) or length (for text fields).
57    #[serde(
58        rename = "validation_maximum",
59        default,
60        with = "::serde_with::rust::double_option",
61        skip_serializing_if = "Option::is_none"
62    )]
63    pub validation_maximum: Option<Option<i64>>,
64    /// 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. Regular expression on select and multi-select will be applied at <code>Custom Field Choices</code> definition.
65    #[serde(rename = "validation_regex", skip_serializing_if = "Option::is_none")]
66    pub validation_regex: Option<String>,
67    /// Hide this field from the object's primary information tab. It will appear in the \"Advanced\" tab instead.
68    #[serde(rename = "advanced_ui", skip_serializing_if = "Option::is_none")]
69    pub advanced_ui: Option<bool>,
70    /// A JSON-encoded dictionary of filter parameters defining possible objects that can use this custom field.
71    #[serde(
72        rename = "scope_filter",
73        default,
74        with = "::serde_with::rust::double_option",
75        skip_serializing_if = "Option::is_none"
76    )]
77    pub scope_filter: Option<Option<serde_json::Value>>,
78}
79
80impl WritableCustomFieldRequest {
81    /// 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>)
82    pub fn new(content_types: Vec<String>, label: String) -> WritableCustomFieldRequest {
83        WritableCustomFieldRequest {
84            id: None,
85            content_types,
86            label,
87            grouping: None,
88            r#type: None,
89            key: None,
90            description: None,
91            required: None,
92            filter_logic: None,
93            default: None,
94            weight: None,
95            validation_minimum: None,
96            validation_maximum: None,
97            validation_regex: None,
98            advanced_ui: None,
99            scope_filter: None,
100        }
101    }
102}