nautobot-openapi 0.4.0

low level nautobot bindings (generated by openapi-generator)
Documentation
/*
 * API Documentation
 *
 * Source of truth and network automation platform
 *
 * The version of the OpenAPI document: 3.1.0 (3.1)
 *
 * Generated by: https://openapi-generator.tech
 */

/// CustomField : 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>)

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct CustomField {
    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
    pub id: Option<uuid::Uuid>,
    #[serde(rename = "object_type", skip_serializing_if = "Option::is_none")]
    pub object_type: Option<String>,
    /// Human friendly display value
    #[serde(rename = "display", skip_serializing_if = "Option::is_none")]
    pub display: Option<String>,
    #[serde(rename = "url", skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,
    #[serde(rename = "natural_slug", skip_serializing_if = "Option::is_none")]
    pub natural_slug: Option<String>,
    #[serde(rename = "content_types")]
    pub content_types: Vec<String>,
    #[serde(rename = "type")]
    pub r#type: Box<crate::models::CustomFieldType>,
    #[serde(rename = "filter_logic", skip_serializing_if = "Option::is_none")]
    pub filter_logic: Option<Box<crate::models::CustomFieldFilterLogic>>,
    #[serde(rename = "label")]
    pub label: String,
    /// Human-readable grouping that this custom field belongs to.
    #[serde(rename = "grouping", skip_serializing_if = "Option::is_none")]
    pub grouping: Option<String>,
    /// Internal field name. Please use underscores rather than dashes in this key.
    #[serde(rename = "key", skip_serializing_if = "Option::is_none")]
    pub key: Option<String>,
    /// A helpful description for this field.
    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// If true, this field is required when creating new objects or editing an existing object.
    #[serde(rename = "required", skip_serializing_if = "Option::is_none")]
    pub required: Option<bool>,
    /// Default value for the field (must be a JSON value). Encapsulate strings with double quotes (e.g. \"Foo\").
    #[serde(
        rename = "default",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub default: Option<Option<serde_json::Value>>,
    /// Fields with higher weights appear lower in a form.
    #[serde(rename = "weight", skip_serializing_if = "Option::is_none")]
    pub weight: Option<i32>,
    /// Minimum allowed value (for numeric fields) or length (for text fields).
    #[serde(
        rename = "validation_minimum",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub validation_minimum: Option<Option<i64>>,
    /// Maximum allowed value (for numeric fields) or length (for text fields).
    #[serde(
        rename = "validation_maximum",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub validation_maximum: Option<Option<i64>>,
    /// 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.
    #[serde(rename = "validation_regex", skip_serializing_if = "Option::is_none")]
    pub validation_regex: Option<String>,
    /// Hide this field from the object's primary information tab. It will appear in the \"Advanced\" tab instead.
    #[serde(rename = "advanced_ui", skip_serializing_if = "Option::is_none")]
    pub advanced_ui: Option<bool>,
    /// A JSON-encoded dictionary of filter parameters defining possible objects that can use this custom field.
    #[serde(
        rename = "scope_filter",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub scope_filter: Option<Option<serde_json::Value>>,
    #[serde(
        rename = "created",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub created: Option<Option<String>>,
    #[serde(
        rename = "last_updated",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub last_updated: Option<Option<String>>,
    #[serde(rename = "notes_url", skip_serializing_if = "Option::is_none")]
    pub notes_url: Option<String>,
}

impl CustomField {
    /// 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>)
    pub fn new(
        content_types: Vec<String>,
        r#type: crate::models::CustomFieldType,
        label: String,
    ) -> CustomField {
        CustomField {
            id: None,
            object_type: None,
            display: None,
            url: None,
            natural_slug: None,
            content_types,
            r#type: Box::new(r#type),
            filter_logic: None,
            label,
            grouping: None,
            key: None,
            description: None,
            required: None,
            default: None,
            weight: None,
            validation_minimum: None,
            validation_maximum: None,
            validation_regex: None,
            advanced_ui: None,
            scope_filter: None,
            created: None,
            last_updated: None,
            notes_url: None,
        }
    }
}