netbox-openapi 0.5.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.0 (4.6)
 *
 * Generated by: https://openapi-generator.tech
 */

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

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct EventRule {
    #[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 = "name")]
    pub name: String,
    #[serde(rename = "enabled", skip_serializing_if = "Option::is_none")]
    pub enabled: Option<bool>,
    /// The types of event which will trigger this rule.
    #[serde(rename = "event_types")]
    pub event_types: Vec<EventTypes>,
    /// A set of conditions which determine whether the event will be generated.
    #[serde(
        rename = "conditions",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub conditions: Option<Option<serde_json::Value>>,
    #[serde(rename = "action_type")]
    pub action_type: Box<crate::models::EventRuleActionType>,
    #[serde(rename = "action_object_type")]
    pub action_object_type: String,
    #[serde(
        rename = "action_object_id",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub action_object_id: Option<Option<i64>>,
    #[serde(
        rename = "action_object",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub action_object: Option<Option<serde_json::Value>>,
    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    #[serde(rename = "custom_fields", skip_serializing_if = "Option::is_none")]
    pub custom_fields: Option<::std::collections::HashMap<String, serde_json::Value>>,
    #[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 = "tags", skip_serializing_if = "Option::is_none")]
    pub tags: Option<Vec<crate::models::NestedTag>>,
    #[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 EventRule {
    /// Adds an `owner` field for models which have a ForeignKey to users.Owner.
    pub fn new(
        object_types: Vec<String>,
        name: String,
        event_types: Vec<EventTypes>,
        action_type: crate::models::EventRuleActionType,
        action_object_type: String,
    ) -> EventRule {
        EventRule {
            id: None,
            url: None,
            display_url: None,
            display: None,
            object_types,
            name,
            enabled: None,
            event_types,
            conditions: None,
            action_type: Box::new(action_type),
            action_object_type,
            action_object_id: None,
            action_object: None,
            description: None,
            custom_fields: None,
            owner: None,
            tags: None,
            created: None,
            last_updated: None,
        }
    }
}

/// The types of event which will trigger this rule.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum EventTypes {
    #[serde(rename = "object_created")]
    ObjectCreated,
    #[serde(rename = "object_updated")]
    ObjectUpdated,
    #[serde(rename = "object_deleted")]
    ObjectDeleted,
    #[serde(rename = "job_started")]
    JobStarted,
    #[serde(rename = "job_completed")]
    JobCompleted,
    #[serde(rename = "job_failed")]
    JobFailed,
    #[serde(rename = "job_errored")]
    JobErrored,
}

impl Default for EventTypes {
    fn default() -> EventTypes {
        Self::ObjectCreated
    }
}