/*
 * 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
 */

/// ScheduledJob : This base serializer implements common fields and logic for all ModelSerializers.  Namely, it:  - defines the `display` field which exposes a human friendly value for the given object. - ensures that `id` field is always present on the serializer as well. - ensures that `created` and `last_updated` fields are always present if applicable to this model and serializer. - ensures that `object_type` field is always present on the serializer which represents the content-type of this   serializer's associated model (e.g. \"dcim.device\"). This is required as the OpenAPI schema, using the   PolymorphicProxySerializer class defined below, relies upon this field as a way to identify to the client   which of several possible serializers are in use for a given attribute. - supports `?depth` query parameter. It is passed in as `nested_depth` to the `build_nested_field()` function   to enable the dynamic generation of nested serializers.

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct ScheduledJob {
    #[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 = "queue", skip_serializing_if = "Option::is_none")]
    pub queue: Option<String>,
    #[serde(rename = "time_zone", skip_serializing_if = "Option::is_none")]
    pub time_zone: Option<String>,
    #[serde(rename = "state", skip_serializing_if = "Option::is_none")]
    pub state: Option<Box<crate::models::ScheduledJobState>>,
    /// Human-readable description of this scheduled task
    #[serde(rename = "name")]
    pub name: String,
    /// The name of the Celery task that should be run. (Example: \"proj.tasks.import_contacts\")
    #[serde(rename = "task")]
    pub task: String,
    #[serde(rename = "interval")]
    pub interval: crate::models::JobExecutionTypeIntervalChoices,
    /// Cronjob syntax string for custom scheduling
    #[serde(rename = "crontab", skip_serializing_if = "Option::is_none")]
    pub crontab: Option<String>,
    #[serde(
        rename = "args",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub args: Option<Option<serde_json::Value>>,
    #[serde(
        rename = "kwargs",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub kwargs: Option<Option<serde_json::Value>>,
    /// If True, the schedule will only run the task a single time
    #[serde(rename = "one_off", skip_serializing_if = "Option::is_none")]
    pub one_off: Option<bool>,
    /// Datetime when the schedule should begin triggering the task to run
    #[serde(rename = "start_time")]
    pub start_time: String,
    /// Set to False to disable the schedule
    #[serde(rename = "enabled", skip_serializing_if = "Option::is_none")]
    pub enabled: Option<bool>,
    /// Datetime that the schedule last triggered the task to run. Reset to None if enabled is set to False.
    #[serde(
        rename = "last_run_at",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub last_run_at: Option<Option<String>>,
    /// Running count of how many times the schedule has triggered the task
    #[serde(rename = "total_run_count", skip_serializing_if = "Option::is_none")]
    pub total_run_count: Option<i32>,
    /// Datetime that this scheduled job was last modified
    #[serde(rename = "date_changed", skip_serializing_if = "Option::is_none")]
    pub date_changed: Option<String>,
    /// Detailed description about the details of this scheduled job
    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    #[serde(
        rename = "celery_kwargs",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub celery_kwargs: Option<Option<serde_json::Value>>,
    /// Datetime that the schedule was approved or denied
    #[serde(
        rename = "decision_date",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub decision_date: Option<Option<String>>,
    #[serde(
        rename = "job_model",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub job_model: Option<Option<Box<crate::models::ApprovalWorkflowUser>>>,
    #[serde(
        rename = "job_queue",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub job_queue: Option<Option<Box<crate::models::JobQueueOverride>>>,
    #[serde(
        rename = "user",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub user: Option<Option<Box<crate::models::ScheduledJobUser>>>,
}

impl ScheduledJob {
    /// This base serializer implements common fields and logic for all ModelSerializers.  Namely, it:  - defines the `display` field which exposes a human friendly value for the given object. - ensures that `id` field is always present on the serializer as well. - ensures that `created` and `last_updated` fields are always present if applicable to this model and serializer. - ensures that `object_type` field is always present on the serializer which represents the content-type of this   serializer's associated model (e.g. \"dcim.device\"). This is required as the OpenAPI schema, using the   PolymorphicProxySerializer class defined below, relies upon this field as a way to identify to the client   which of several possible serializers are in use for a given attribute. - supports `?depth` query parameter. It is passed in as `nested_depth` to the `build_nested_field()` function   to enable the dynamic generation of nested serializers.
    pub fn new(
        name: String,
        task: String,
        interval: crate::models::JobExecutionTypeIntervalChoices,
        start_time: String,
    ) -> ScheduledJob {
        ScheduledJob {
            id: None,
            object_type: None,
            display: None,
            url: None,
            natural_slug: None,
            queue: None,
            time_zone: None,
            state: None,
            name,
            task,
            interval,
            crontab: None,
            args: None,
            kwargs: None,
            one_off: None,
            start_time,
            enabled: None,
            last_run_at: None,
            total_run_count: None,
            date_changed: None,
            description: None,
            celery_kwargs: None,
            decision_date: None,
            job_model: None,
            job_queue: None,
            user: None,
        }
    }
}
