Skip to main content

nautobot_openapi/models/
bulk_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/// BulkWritableCustomFieldRequest : 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 BulkWritableCustomFieldRequest {
15    #[serde(rename = "id")]
16    pub id: uuid::Uuid,
17    #[serde(rename = "content_types")]
18    pub content_types: Vec<String>,
19    #[serde(rename = "type")]
20    pub r#type: crate::models::CustomFieldTypeChoices,
21    #[serde(rename = "filter_logic", skip_serializing_if = "Option::is_none")]
22    pub filter_logic: Option<crate::models::FilterLogicEnum>,
23    #[serde(rename = "label")]
24    pub label: String,
25    /// Human-readable grouping that this custom field belongs to.
26    #[serde(rename = "grouping", skip_serializing_if = "Option::is_none")]
27    pub grouping: Option<String>,
28    /// Internal field name. Please use underscores rather than dashes in this key.
29    #[serde(rename = "key", skip_serializing_if = "Option::is_none")]
30    pub key: Option<String>,
31    /// A helpful description for this field.
32    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
33    pub description: Option<String>,
34    /// If true, this field is required when creating new objects or editing an existing object.
35    #[serde(rename = "required", skip_serializing_if = "Option::is_none")]
36    pub required: Option<bool>,
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 BulkWritableCustomFieldRequest {
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(
83        id: uuid::Uuid,
84        content_types: Vec<String>,
85        r#type: crate::models::CustomFieldTypeChoices,
86        label: String,
87    ) -> BulkWritableCustomFieldRequest {
88        BulkWritableCustomFieldRequest {
89            id,
90            content_types,
91            r#type,
92            filter_logic: None,
93            label,
94            grouping: None,
95            key: None,
96            description: None,
97            required: None,
98            default: None,
99            weight: None,
100            validation_minimum: None,
101            validation_maximum: None,
102            validation_regex: None,
103            advanced_ui: None,
104            scope_filter: None,
105        }
106    }
107}