#[derive(
    Clone,
    Default,
    PartialEq,
    serde::Deserialize,
    serde::Serialize,
    std::fmt::Debug
)]
/// ISCSIPersistentVolumeSource represents an ISCSI disk. ISCSI volumes can only be mounted as read/write once. ISCSI volumes support ownership management and SELinux relabeling.
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct ISCSIPersistentVolumeSourceAc {
    /// chapAuthDiscovery defines whether support iSCSI Discovery CHAP authentication
    #[serde(skip_serializing_if = "Option::is_none")]
    pub chap_auth_discovery: Option<bool>,
    /// chapAuthSession defines whether support iSCSI Session CHAP authentication
    #[serde(skip_serializing_if = "Option::is_none")]
    pub chap_auth_session: Option<bool>,
    /// fsType is the filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#iscsi
    #[serde(skip_serializing_if = "Option::is_none")]
    pub fs_type: Option<std::string::String>,
    /// initiatorName is the custom iSCSI Initiator Name. If initiatorName is specified with iscsiInterface simultaneously, new iSCSI interface \<target portal\>:\<volume name\> will be created for the connection.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub initiator_name: Option<std::string::String>,
    /// iqn is Target iSCSI Qualified Name.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub iqn: Option<std::string::String>,
    /// iscsiInterface is the interface Name that uses an iSCSI transport. Defaults to 'default' (tcp).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub iscsi_interface: Option<std::string::String>,
    /// lun is iSCSI Target Lun number.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub lun: Option<i32>,
    /// portals is the iSCSI Target Portal List. The Portal is either an IP or ip_addr:port if the port is other than default (typically TCP ports 860 and 3260).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub portals: Option<std::vec::Vec<std::string::String>>,
    /// readOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub read_only: Option<bool>,
    /// secretRef is the CHAP Secret for iSCSI target and initiator authentication
    #[serde(skip_serializing_if = "Option::is_none")]
    pub secret_ref: Option<
        <::k8s_openapi028::api::core::v1::SecretReference as crate::Optionable>::Optioned,
    >,
    /// targetPortal is iSCSI Target Portal. The Portal is either an IP or ip_addr:port if the port is other than default (typically TCP ports 860 and 3260).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub target_portal: Option<std::string::String>,
}
#[automatically_derived]
impl crate::Optionable for k8s_openapi028::api::core::v1::ISCSIPersistentVolumeSource {
    type Optioned = ISCSIPersistentVolumeSourceAc;
}
#[automatically_derived]
impl crate::Optionable for ISCSIPersistentVolumeSourceAc {
    type Optioned = ISCSIPersistentVolumeSourceAc;
}
#[automatically_derived]
#[cfg(feature = "k8s_openapi_convert")]
impl crate::OptionableConvert
for k8s_openapi028::api::core::v1::ISCSIPersistentVolumeSource {
    fn into_optioned(self) -> ISCSIPersistentVolumeSourceAc {
        ISCSIPersistentVolumeSourceAc {
            chap_auth_discovery: self.chap_auth_discovery,
            chap_auth_session: self.chap_auth_session,
            fs_type: self.fs_type,
            initiator_name: self.initiator_name,
            iqn: Some(self.iqn),
            iscsi_interface: self.iscsi_interface,
            lun: Some(self.lun),
            portals: self.portals,
            read_only: self.read_only,
            secret_ref: crate::OptionableConvert::into_optioned(self.secret_ref),
            target_portal: Some(self.target_portal),
        }
    }
    fn try_from_optioned(
        value: ISCSIPersistentVolumeSourceAc,
    ) -> Result<Self, crate::Error> {
        Ok(Self {
            chap_auth_discovery: value.chap_auth_discovery,
            chap_auth_session: value.chap_auth_session,
            fs_type: value.fs_type,
            initiator_name: value.initiator_name,
            iqn: value
                .iqn
                .ok_or(crate::Error {
                    missing_field: "iqn",
                })?,
            iscsi_interface: value.iscsi_interface,
            lun: value
                .lun
                .ok_or(crate::Error {
                    missing_field: "lun",
                })?,
            portals: value.portals,
            read_only: value.read_only,
            secret_ref: crate::OptionableConvert::try_from_optioned(value.secret_ref)?,
            target_portal: value
                .target_portal
                .ok_or(crate::Error {
                    missing_field: "target_portal",
                })?,
        })
    }
    fn merge(
        &mut self,
        other: ISCSIPersistentVolumeSourceAc,
    ) -> Result<(), crate::Error> {
        if self.chap_auth_discovery.is_none() {
            self.chap_auth_discovery = crate::OptionableConvert::try_from_optioned(
                other.chap_auth_discovery,
            )?;
        } else if let Some(self_value) = self.chap_auth_discovery.as_mut()
            && let Some(other_value) = other.chap_auth_discovery
        {
            crate::OptionableConvert::merge(self_value, other_value)?;
        }
        if self.chap_auth_session.is_none() {
            self.chap_auth_session = crate::OptionableConvert::try_from_optioned(
                other.chap_auth_session,
            )?;
        } else if let Some(self_value) = self.chap_auth_session.as_mut()
            && let Some(other_value) = other.chap_auth_session
        {
            crate::OptionableConvert::merge(self_value, other_value)?;
        }
        if self.fs_type.is_none() {
            self.fs_type = crate::OptionableConvert::try_from_optioned(other.fs_type)?;
        } else if let Some(self_value) = self.fs_type.as_mut()
            && let Some(other_value) = other.fs_type
        {
            crate::OptionableConvert::merge(self_value, other_value)?;
        }
        if self.initiator_name.is_none() {
            self.initiator_name = crate::OptionableConvert::try_from_optioned(
                other.initiator_name,
            )?;
        } else if let Some(self_value) = self.initiator_name.as_mut()
            && let Some(other_value) = other.initiator_name
        {
            crate::OptionableConvert::merge(self_value, other_value)?;
        }
        if let Some(other_value) = other.iqn {
            self.iqn = crate::OptionableConvert::try_from_optioned(other_value)?;
        }
        if self.iscsi_interface.is_none() {
            self.iscsi_interface = crate::OptionableConvert::try_from_optioned(
                other.iscsi_interface,
            )?;
        } else if let Some(self_value) = self.iscsi_interface.as_mut()
            && let Some(other_value) = other.iscsi_interface
        {
            crate::OptionableConvert::merge(self_value, other_value)?;
        }
        if let Some(other_value) = other.lun {
            self.lun = crate::OptionableConvert::try_from_optioned(other_value)?;
        }
        if self.portals.is_none() {
            self.portals = crate::OptionableConvert::try_from_optioned(other.portals)?;
        } else if let Some(self_value) = self.portals.as_mut()
            && let Some(other_value) = other.portals
        {
            *self_value = crate::OptionableConvert::try_from_optioned(other_value)?;
        }
        if self.read_only.is_none() {
            self.read_only = crate::OptionableConvert::try_from_optioned(
                other.read_only,
            )?;
        } else if let Some(self_value) = self.read_only.as_mut()
            && let Some(other_value) = other.read_only
        {
            crate::OptionableConvert::merge(self_value, other_value)?;
        }
        if self.secret_ref.is_none() {
            self.secret_ref = crate::OptionableConvert::try_from_optioned(
                other.secret_ref,
            )?;
        } else if let Some(self_value) = self.secret_ref.as_mut()
            && let Some(other_value) = other.secret_ref
        {
            *self_value = crate::OptionableConvert::try_from_optioned(other_value)?;
        }
        if let Some(other_value) = other.target_portal {
            self.target_portal = crate::OptionableConvert::try_from_optioned(
                other_value,
            )?;
        }
        Ok(())
    }
}
#[automatically_derived]
#[cfg(feature = "k8s_openapi_convert")]
impl crate::OptionedConvert<k8s_openapi028::api::core::v1::ISCSIPersistentVolumeSource>
for ISCSIPersistentVolumeSourceAc {
    fn from_optionable(
        value: k8s_openapi028::api::core::v1::ISCSIPersistentVolumeSource,
    ) -> Self {
        crate::OptionableConvert::into_optioned(value)
    }
    fn try_into_optionable(
        self,
    ) -> Result<
        k8s_openapi028::api::core::v1::ISCSIPersistentVolumeSource,
        crate::Error,
    > {
        crate::OptionableConvert::try_from_optioned(self)
    }
    fn merge_into(
        self,
        other: &mut k8s_openapi028::api::core::v1::ISCSIPersistentVolumeSource,
    ) -> Result<(), crate::Error> {
        crate::OptionableConvert::merge(other, self)
    }
}
impl k8s_openapi028::DeepMerge for ISCSIPersistentVolumeSourceAc {
    fn merge_from(&mut self, other: Self) {
        k8s_openapi028::DeepMerge::merge_from(
            &mut self.chap_auth_discovery,
            other.chap_auth_discovery,
        );
        k8s_openapi028::DeepMerge::merge_from(
            &mut self.chap_auth_session,
            other.chap_auth_session,
        );
        k8s_openapi028::DeepMerge::merge_from(&mut self.fs_type, other.fs_type);
        k8s_openapi028::DeepMerge::merge_from(
            &mut self.initiator_name,
            other.initiator_name,
        );
        k8s_openapi028::DeepMerge::merge_from(&mut self.iqn, other.iqn);
        k8s_openapi028::DeepMerge::merge_from(
            &mut self.iscsi_interface,
            other.iscsi_interface,
        );
        k8s_openapi028::DeepMerge::merge_from(&mut self.lun, other.lun);
        self.portals = other.portals;
        k8s_openapi028::DeepMerge::merge_from(&mut self.read_only, other.read_only);
        self.secret_ref = other.secret_ref;
        k8s_openapi028::DeepMerge::merge_from(
            &mut self.target_portal,
            other.target_portal,
        );
    }
}
