netbox-openapi 0.6.0

low level netbox bindings (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
Documentation
/*
 * NetBox REST API
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 4.6.2 (4.6)
 *
 * Generated by: https://openapi-generator.tech
 */

/// CustomField : Adds an `owner` field for models which have a ForeignKey to users.Owner.

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct CustomField {
    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
    pub id: Option<i32>,
    #[serde(rename = "url", skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,
    #[serde(rename = "display_url", skip_serializing_if = "Option::is_none")]
    pub display_url: Option<String>,
    #[serde(rename = "display", skip_serializing_if = "Option::is_none")]
    pub display: Option<String>,
    #[serde(rename = "object_types")]
    pub object_types: Vec<String>,
    #[serde(rename = "type")]
    pub r#type: Box<crate::models::CustomFieldType>,
    #[serde(
        rename = "related_object_type",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub related_object_type: Option<Option<String>>,
    #[serde(rename = "data_type", skip_serializing_if = "Option::is_none")]
    pub data_type: Option<String>,
    /// Internal field name
    #[serde(rename = "name")]
    pub name: String,
    /// Name of the field as displayed to users (if not provided, 'the field's name will be used)
    #[serde(rename = "label", skip_serializing_if = "Option::is_none")]
    pub label: Option<String>,
    /// Custom fields within the same group will be displayed together
    #[serde(rename = "group_name", skip_serializing_if = "Option::is_none")]
    pub group_name: Option<String>,
    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// 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>,
    /// The value of this field must be unique for the assigned object
    #[serde(rename = "unique", skip_serializing_if = "Option::is_none")]
    pub unique: Option<bool>,
    /// Weighting for search. Lower values are considered more important. Fields with a search weight of zero will be ignored.
    #[serde(rename = "search_weight", skip_serializing_if = "Option::is_none")]
    pub search_weight: Option<i32>,
    #[serde(rename = "filter_logic", skip_serializing_if = "Option::is_none")]
    pub filter_logic: Option<Box<crate::models::CustomFieldFilterLogic>>,
    #[serde(rename = "ui_visible", skip_serializing_if = "Option::is_none")]
    pub ui_visible: Option<Box<crate::models::CustomFieldUiVisible>>,
    #[serde(rename = "ui_editable", skip_serializing_if = "Option::is_none")]
    pub ui_editable: Option<Box<crate::models::CustomFieldUiEditable>>,
    /// Replicate this value when cloning objects
    #[serde(rename = "is_cloneable", skip_serializing_if = "Option::is_none")]
    pub is_cloneable: 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>>,
    /// Filter the object selection choices using a query_params dict (must be a JSON value).Encapsulate strings with double quotes (e.g. \"Foo\").
    #[serde(
        rename = "related_object_filter",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub related_object_filter: 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)
    #[serde(
        rename = "validation_minimum",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub validation_minimum: Option<Option<f64>>,
    /// Maximum allowed value (for numeric fields)
    #[serde(
        rename = "validation_maximum",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub validation_maximum: Option<Option<f64>>,
    /// 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.
    #[serde(rename = "validation_regex", skip_serializing_if = "Option::is_none")]
    pub validation_regex: Option<String>,
    /// A JSON schema definition for validating the custom field value
    #[serde(
        rename = "validation_schema",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub validation_schema: Option<Option<serde_json::Value>>,
    #[serde(
        rename = "choice_set",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub choice_set: Option<Option<Box<crate::models::BriefCustomFieldChoiceSet>>>,
    #[serde(
        rename = "owner",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub owner: Option<Option<Box<crate::models::BriefOwner>>>,
    #[serde(rename = "comments", skip_serializing_if = "Option::is_none")]
    pub comments: Option<String>,
    #[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>>,
}

impl CustomField {
    /// Adds an `owner` field for models which have a ForeignKey to users.Owner.
    pub fn new(
        object_types: Vec<String>,
        r#type: crate::models::CustomFieldType,
        name: String,
    ) -> CustomField {
        CustomField {
            id: None,
            url: None,
            display_url: None,
            display: None,
            object_types,
            r#type: Box::new(r#type),
            related_object_type: None,
            data_type: None,
            name,
            label: None,
            group_name: None,
            description: None,
            required: None,
            unique: None,
            search_weight: None,
            filter_logic: None,
            ui_visible: None,
            ui_editable: None,
            is_cloneable: None,
            default: None,
            related_object_filter: None,
            weight: None,
            validation_minimum: None,
            validation_maximum: None,
            validation_regex: None,
            validation_schema: None,
            choice_set: None,
            owner: None,
            comments: None,
            created: None,
            last_updated: None,
        }
    }
}