/*
 * This is an auto-generated file.
 * Any manual changes may be overwritten without notice!
 */

use derive_builder::Builder;
use serde::{Deserialize, Serialize};

/// TaskCSIPluginConfig contains the data that is required to setup a task as a
/// CSI plugin. This will be used by the csi_plugin_supervisor_hook to configure
/// mounts for the plugin and initiate the connection to the plugin catalog.
///
/// This struct was generated based on the Go types of the official Nomad API.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Builder)]
pub struct TaskCsiPluginConfig {
    /// ID is the identifier of the plugin.
    /// Ideally this should be the FQDN of the plugin.
    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,

    /// CSIPluginType instructs Nomad on how to handle processing a plugin
    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
    pub r#type: Option<String>,

    /// MountDir is the directory (within its container) in which the plugin creates a
    /// socket (called CSISocketName) for communication with Nomad. Default is /csi.
    #[serde(rename = "mount_dir", skip_serializing_if = "Option::is_none")]
    pub mount_dir: Option<String>,

    /// StagePublishBaseDir is the base directory (within its container) in which the plugin
    /// mounts volumes being staged and bind mounts volumes being published.
    /// e.g. staging_target_path = {StagePublishBaseDir}/staging/{volume-id}/{usage-mode}
    /// e.g. target_path = {StagePublishBaseDir}/per-alloc/{alloc-id}/{volume-id}/{usage-mode}
    /// Default is /local/csi.
    #[serde(
        rename = "stage_publish_base_dir",
        skip_serializing_if = "Option::is_none"
    )]
    pub stage_publish_base_dir: Option<String>,

    /// HealthTimeout is the time after which the CSI plugin tasks will be killed
    /// if the CSI Plugin is not healthy.
    #[serde(
        rename = "health_timeout",
        skip_serializing_if = "Option::is_none",
        serialize_with = "crate::serialize_duration_option",
        deserialize_with = "crate::deserialize_duration_option",
        default
    )]
    pub health_timeout: Option<chrono::TimeDelta>,
}
