#[derive(
    Clone,
    Default,
    PartialEq,
    serde::Deserialize,
    serde::Serialize,
    std::fmt::Debug
)]
/// ContainerStatus contains details for the current status of this container.
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct ContainerStatusAc {
    /// AllocatedResources represents the compute resources allocated for this container by the node. Kubelet sets this value to Container.Resources.Requests upon successful pod admission and after successfully admitting desired pod resize.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub allocated_resources: Option<
        std::collections::BTreeMap<
            std::string::String,
            <::k8s_openapi028::apimachinery::pkg::api::resource::Quantity as crate::Optionable>::Optioned,
        >,
    >,
    /// AllocatedResourcesStatus represents the status of various resources allocated for this Pod.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub allocated_resources_status: Option<
        std::vec::Vec<
            <::k8s_openapi028::api::core::v1::ResourceStatus as crate::Optionable>::Optioned,
        >,
    >,
    /// ContainerID is the ID of the container in the format '\<type\>://\<container_id\>'. Where type is a container runtime identifier, returned from Version call of CRI API (for example "containerd").
    #[serde(rename = "containerID")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub container_id: Option<std::string::String>,
    /// Image is the name of container image that the container is running. The container image may not match the image used in the PodSpec, as it may have been resolved by the runtime. More info: https://kubernetes.io/docs/concepts/containers/images.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub image: Option<std::string::String>,
    /// ImageID is the image ID of the container's image. The image ID may not match the image ID of the image used in the PodSpec, as it may have been resolved by the runtime.
    #[serde(rename = "imageID")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub image_id: Option<std::string::String>,
    /// LastTerminationState holds the last termination state of the container to help debug container crashes and restarts. This field is not populated if the container is still running and RestartCount is 0.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub last_state: Option<
        <::k8s_openapi028::api::core::v1::ContainerState as crate::Optionable>::Optioned,
    >,
    /// Name is a DNS_LABEL representing the unique name of the container. Each container in a pod must have a unique name across all container types. Cannot be updated.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<std::string::String>,
    /// Ready specifies whether the container is currently passing its readiness check. The value will change as readiness probes keep executing. If no readiness probes are specified, this field defaults to true once the container is fully started (see Started field).
    ///
    /// The value is typically used to determine whether a container is ready to accept traffic.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ready: Option<bool>,
    /// Resources represents the compute resource requests and limits that have been successfully enacted on the running container after it has been started or has been successfully resized.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub resources: Option<
        <::k8s_openapi028::api::core::v1::ResourceRequirements as crate::Optionable>::Optioned,
    >,
    /// RestartCount holds the number of times the container has been restarted. Kubelet makes an effort to always increment the value, but there are cases when the state may be lost due to node restarts and then the value may be reset to 0. The value is never negative.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub restart_count: Option<i32>,
    /// Started indicates whether the container has finished its postStart lifecycle hook and passed its startup probe. Initialized as false, becomes true after startupProbe is considered successful. Resets to false when the container is restarted, or if kubelet loses state temporarily. In both cases, startup probes will run again. Is always true when no startupProbe is defined and container is running and has passed the postStart lifecycle hook. The null value must be treated the same as false.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub started: Option<bool>,
    /// State holds details about the container's current condition.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub state: Option<
        <::k8s_openapi028::api::core::v1::ContainerState as crate::Optionable>::Optioned,
    >,
    /// StopSignal reports the effective stop signal for this container
    #[serde(skip_serializing_if = "Option::is_none")]
    pub stop_signal: Option<std::string::String>,
    /// User represents user identity information initially attached to the first process of the container
    #[serde(skip_serializing_if = "Option::is_none")]
    pub user: Option<
        <::k8s_openapi028::api::core::v1::ContainerUser as crate::Optionable>::Optioned,
    >,
    /// Status of volume mounts.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub volume_mounts: Option<
        std::vec::Vec<
            <::k8s_openapi028::api::core::v1::VolumeMountStatus as crate::Optionable>::Optioned,
        >,
    >,
}
#[automatically_derived]
impl crate::Optionable for k8s_openapi028::api::core::v1::ContainerStatus {
    type Optioned = ContainerStatusAc;
}
#[automatically_derived]
impl crate::Optionable for ContainerStatusAc {
    type Optioned = ContainerStatusAc;
}
#[automatically_derived]
#[cfg(feature = "k8s_openapi_convert")]
impl crate::OptionableConvert for k8s_openapi028::api::core::v1::ContainerStatus {
    fn into_optioned(self) -> ContainerStatusAc {
        ContainerStatusAc {
            allocated_resources: crate::OptionableConvert::into_optioned(
                self.allocated_resources,
            ),
            allocated_resources_status: crate::OptionableConvert::into_optioned(
                self.allocated_resources_status,
            ),
            container_id: self.container_id,
            image: Some(self.image),
            image_id: Some(self.image_id),
            last_state: crate::OptionableConvert::into_optioned(self.last_state),
            name: Some(self.name),
            ready: Some(self.ready),
            resources: crate::OptionableConvert::into_optioned(self.resources),
            restart_count: Some(self.restart_count),
            started: self.started,
            state: crate::OptionableConvert::into_optioned(self.state),
            stop_signal: self.stop_signal,
            user: crate::OptionableConvert::into_optioned(self.user),
            volume_mounts: crate::OptionableConvert::into_optioned(self.volume_mounts),
        }
    }
    fn try_from_optioned(value: ContainerStatusAc) -> Result<Self, crate::Error> {
        Ok(Self {
            allocated_resources: crate::OptionableConvert::try_from_optioned(
                value.allocated_resources,
            )?,
            allocated_resources_status: crate::OptionableConvert::try_from_optioned(
                value.allocated_resources_status,
            )?,
            container_id: value.container_id,
            image: value
                .image
                .ok_or(crate::Error {
                    missing_field: "image",
                })?,
            image_id: value
                .image_id
                .ok_or(crate::Error {
                    missing_field: "image_id",
                })?,
            last_state: crate::OptionableConvert::try_from_optioned(value.last_state)?,
            name: value
                .name
                .ok_or(crate::Error {
                    missing_field: "name",
                })?,
            ready: value
                .ready
                .ok_or(crate::Error {
                    missing_field: "ready",
                })?,
            resources: crate::OptionableConvert::try_from_optioned(value.resources)?,
            restart_count: value
                .restart_count
                .ok_or(crate::Error {
                    missing_field: "restart_count",
                })?,
            started: value.started,
            state: crate::OptionableConvert::try_from_optioned(value.state)?,
            stop_signal: value.stop_signal,
            user: crate::OptionableConvert::try_from_optioned(value.user)?,
            volume_mounts: crate::OptionableConvert::try_from_optioned(
                value.volume_mounts,
            )?,
        })
    }
    fn merge(&mut self, other: ContainerStatusAc) -> Result<(), crate::Error> {
        if self.allocated_resources.is_none() {
            self.allocated_resources = crate::OptionableConvert::try_from_optioned(
                other.allocated_resources,
            )?;
        } else if let Some(self_value) = self.allocated_resources.as_mut()
            && let Some(other_value) = other.allocated_resources
        {
            crate::OptionableConvert::merge(self_value, other_value)?;
        }
        if self.allocated_resources_status.is_none() {
            self.allocated_resources_status = crate::OptionableConvert::try_from_optioned(
                other.allocated_resources_status,
            )?;
        } else if let Some(self_value) = self.allocated_resources_status.as_mut()
            && let Some(other_value) = other.allocated_resources_status
        {
            crate::merge::try_merge_optioned_map(self_value, other_value)?;
        }
        if self.container_id.is_none() {
            self.container_id = crate::OptionableConvert::try_from_optioned(
                other.container_id,
            )?;
        } else if let Some(self_value) = self.container_id.as_mut()
            && let Some(other_value) = other.container_id
        {
            crate::OptionableConvert::merge(self_value, other_value)?;
        }
        if let Some(other_value) = other.image {
            self.image = crate::OptionableConvert::try_from_optioned(other_value)?;
        }
        if let Some(other_value) = other.image_id {
            self.image_id = crate::OptionableConvert::try_from_optioned(other_value)?;
        }
        if self.last_state.is_none() {
            self.last_state = crate::OptionableConvert::try_from_optioned(
                other.last_state,
            )?;
        } else if let Some(self_value) = self.last_state.as_mut()
            && let Some(other_value) = other.last_state
        {
            crate::OptionableConvert::merge(self_value, other_value)?;
        }
        if let Some(other_value) = other.name {
            self.name = crate::OptionableConvert::try_from_optioned(other_value)?;
        }
        if let Some(other_value) = other.ready {
            self.ready = crate::OptionableConvert::try_from_optioned(other_value)?;
        }
        if self.resources.is_none() {
            self.resources = crate::OptionableConvert::try_from_optioned(
                other.resources,
            )?;
        } else if let Some(self_value) = self.resources.as_mut()
            && let Some(other_value) = other.resources
        {
            crate::OptionableConvert::merge(self_value, other_value)?;
        }
        if let Some(other_value) = other.restart_count {
            self.restart_count = crate::OptionableConvert::try_from_optioned(
                other_value,
            )?;
        }
        if self.started.is_none() {
            self.started = crate::OptionableConvert::try_from_optioned(other.started)?;
        } else if let Some(self_value) = self.started.as_mut()
            && let Some(other_value) = other.started
        {
            crate::OptionableConvert::merge(self_value, other_value)?;
        }
        if self.state.is_none() {
            self.state = crate::OptionableConvert::try_from_optioned(other.state)?;
        } else if let Some(self_value) = self.state.as_mut()
            && let Some(other_value) = other.state
        {
            crate::OptionableConvert::merge(self_value, other_value)?;
        }
        if self.stop_signal.is_none() {
            self.stop_signal = crate::OptionableConvert::try_from_optioned(
                other.stop_signal,
            )?;
        } else if let Some(self_value) = self.stop_signal.as_mut()
            && let Some(other_value) = other.stop_signal
        {
            crate::OptionableConvert::merge(self_value, other_value)?;
        }
        if self.user.is_none() {
            self.user = crate::OptionableConvert::try_from_optioned(other.user)?;
        } else if let Some(self_value) = self.user.as_mut()
            && let Some(other_value) = other.user
        {
            crate::OptionableConvert::merge(self_value, other_value)?;
        }
        if self.volume_mounts.is_none() {
            self.volume_mounts = crate::OptionableConvert::try_from_optioned(
                other.volume_mounts,
            )?;
        } else if let Some(self_value) = self.volume_mounts.as_mut()
            && let Some(other_value) = other.volume_mounts
        {
            crate::merge::try_merge_optioned_map(self_value, other_value)?;
        }
        Ok(())
    }
}
#[automatically_derived]
#[cfg(feature = "k8s_openapi_convert")]
impl crate::OptionedConvert<k8s_openapi028::api::core::v1::ContainerStatus>
for ContainerStatusAc {
    fn from_optionable(value: k8s_openapi028::api::core::v1::ContainerStatus) -> Self {
        crate::OptionableConvert::into_optioned(value)
    }
    fn try_into_optionable(
        self,
    ) -> Result<k8s_openapi028::api::core::v1::ContainerStatus, crate::Error> {
        crate::OptionableConvert::try_from_optioned(self)
    }
    fn merge_into(
        self,
        other: &mut k8s_openapi028::api::core::v1::ContainerStatus,
    ) -> Result<(), crate::Error> {
        crate::OptionableConvert::merge(other, self)
    }
}
impl k8s_openapi028::DeepMerge for ContainerStatusAc {
    fn merge_from(&mut self, other: Self) {
        crate::k8s_openapi::merge::merge_granular_option_wrapped(
            &mut self.allocated_resources,
            other.allocated_resources,
        );
        crate::k8s_openapi::merge::merge_map_option_wrapped(
            &mut self.allocated_resources_status,
            other.allocated_resources_status,
        );
        k8s_openapi028::DeepMerge::merge_from(
            &mut self.container_id,
            other.container_id,
        );
        k8s_openapi028::DeepMerge::merge_from(&mut self.image, other.image);
        k8s_openapi028::DeepMerge::merge_from(&mut self.image_id, other.image_id);
        k8s_openapi028::DeepMerge::merge_from(&mut self.last_state, other.last_state);
        k8s_openapi028::DeepMerge::merge_from(&mut self.name, other.name);
        k8s_openapi028::DeepMerge::merge_from(&mut self.ready, other.ready);
        k8s_openapi028::DeepMerge::merge_from(&mut self.resources, other.resources);
        k8s_openapi028::DeepMerge::merge_from(
            &mut self.restart_count,
            other.restart_count,
        );
        k8s_openapi028::DeepMerge::merge_from(&mut self.started, other.started);
        k8s_openapi028::DeepMerge::merge_from(&mut self.state, other.state);
        k8s_openapi028::DeepMerge::merge_from(&mut self.stop_signal, other.stop_signal);
        k8s_openapi028::DeepMerge::merge_from(&mut self.user, other.user);
        crate::k8s_openapi::merge::merge_map_option_wrapped(
            &mut self.volume_mounts,
            other.volume_mounts,
        );
    }
}
