Skip to main content

k8s_openapi/v1_36/api/scheduling/v1alpha2/
pod_group_status.rs

1// Generated from definition io.k8s.api.scheduling.v1alpha2.PodGroupStatus
2
3/// PodGroupStatus represents information about the status of a pod group.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct PodGroupStatus {
6    /// Conditions represent the latest observations of the PodGroup's state.
7    ///
8    /// Known condition types: - "PodGroupScheduled": Indicates whether the scheduling requirement has been satisfied. - "DisruptionTarget": Indicates whether the PodGroup is about to be terminated
9    ///   due to disruption such as preemption.
10    ///
11    /// Known reasons for the PodGroupScheduled condition: - "Unschedulable": The PodGroup cannot be scheduled due to resource constraints,
12    ///   affinity/anti-affinity rules, or insufficient capacity for the gang.
13    /// - "SchedulerError": The PodGroup cannot be scheduled due to some internal error
14    ///   that happened during scheduling, for example due to nodeAffinity parsing errors.
15    ///
16    /// Known reasons for the DisruptionTarget condition: - "PreemptionByScheduler": The PodGroup was preempted by the scheduler to make room for
17    ///   higher-priority PodGroups or Pods.
18    pub conditions: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::Condition>>,
19
20    /// Status of resource claims.
21    pub resource_claim_statuses: Option<std::vec::Vec<crate::api::scheduling::v1alpha2::PodGroupResourceClaimStatus>>,
22}
23
24impl crate::DeepMerge for PodGroupStatus {
25    fn merge_from(&mut self, other: Self) {
26        crate::merge_strategies::list::map(
27            &mut self.conditions,
28            other.conditions,
29            &[|lhs, rhs| lhs.type_ == rhs.type_],
30            |current_item, other_item| {
31                crate::DeepMerge::merge_from(current_item, other_item);
32            },
33        );
34        crate::merge_strategies::list::map(
35            &mut self.resource_claim_statuses,
36            other.resource_claim_statuses,
37            &[|lhs, rhs| lhs.name == rhs.name],
38            |current_item, other_item| {
39                crate::DeepMerge::merge_from(current_item, other_item);
40            },
41        );
42    }
43}
44
45impl<'de> crate::serde::Deserialize<'de> for PodGroupStatus {
46    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
47        #[allow(non_camel_case_types)]
48        enum Field {
49            Key_conditions,
50            Key_resource_claim_statuses,
51            Other,
52        }
53
54        impl<'de> crate::serde::Deserialize<'de> for Field {
55            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
56                struct Visitor;
57
58                impl crate::serde::de::Visitor<'_> for Visitor {
59                    type Value = Field;
60
61                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
62                        f.write_str("field identifier")
63                    }
64
65                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
66                        Ok(match v {
67                            "conditions" => Field::Key_conditions,
68                            "resourceClaimStatuses" => Field::Key_resource_claim_statuses,
69                            _ => Field::Other,
70                        })
71                    }
72                }
73
74                deserializer.deserialize_identifier(Visitor)
75            }
76        }
77
78        struct Visitor;
79
80        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
81            type Value = PodGroupStatus;
82
83            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
84                f.write_str("PodGroupStatus")
85            }
86
87            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
88                let mut value_conditions: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::Condition>> = None;
89                let mut value_resource_claim_statuses: Option<std::vec::Vec<crate::api::scheduling::v1alpha2::PodGroupResourceClaimStatus>> = None;
90
91                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
92                    match key {
93                        Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
94                        Field::Key_resource_claim_statuses => value_resource_claim_statuses = crate::serde::de::MapAccess::next_value(&mut map)?,
95                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
96                    }
97                }
98
99                Ok(PodGroupStatus {
100                    conditions: value_conditions,
101                    resource_claim_statuses: value_resource_claim_statuses,
102                })
103            }
104        }
105
106        deserializer.deserialize_struct(
107            "PodGroupStatus",
108            &[
109                "conditions",
110                "resourceClaimStatuses",
111            ],
112            Visitor,
113        )
114    }
115}
116
117impl crate::serde::Serialize for PodGroupStatus {
118    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
119        let mut state = serializer.serialize_struct(
120            "PodGroupStatus",
121            self.conditions.as_ref().map_or(0, |_| 1) +
122            self.resource_claim_statuses.as_ref().map_or(0, |_| 1),
123        )?;
124        if let Some(value) = &self.conditions {
125            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
126        }
127        if let Some(value) = &self.resource_claim_statuses {
128            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resourceClaimStatuses", value)?;
129        }
130        crate::serde::ser::SerializeStruct::end(state)
131    }
132}
133
134#[cfg(feature = "schemars")]
135impl crate::schemars::JsonSchema for PodGroupStatus {
136    fn schema_name() -> std::borrow::Cow<'static, str> {
137        "io.k8s.api.scheduling.v1alpha2.PodGroupStatus".into()
138    }
139
140    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
141        crate::schemars::json_schema!({
142            "description": "PodGroupStatus represents information about the status of a pod group.",
143            "type": "object",
144            "properties": {
145                "conditions": {
146                    "description": "Conditions represent the latest observations of the PodGroup's state.\n\nKnown condition types: - \"PodGroupScheduled\": Indicates whether the scheduling requirement has been satisfied. - \"DisruptionTarget\": Indicates whether the PodGroup is about to be terminated\n  due to disruption such as preemption.\n\nKnown reasons for the PodGroupScheduled condition: - \"Unschedulable\": The PodGroup cannot be scheduled due to resource constraints,\n  affinity/anti-affinity rules, or insufficient capacity for the gang.\n- \"SchedulerError\": The PodGroup cannot be scheduled due to some internal error\n  that happened during scheduling, for example due to nodeAffinity parsing errors.\n\nKnown reasons for the DisruptionTarget condition: - \"PreemptionByScheduler\": The PodGroup was preempted by the scheduler to make room for\n  higher-priority PodGroups or Pods.",
147                    "type": "array",
148                    "items": (__gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Condition>()),
149                },
150                "resourceClaimStatuses": {
151                    "description": "Status of resource claims.",
152                    "type": "array",
153                    "items": (__gen.subschema_for::<crate::api::scheduling::v1alpha2::PodGroupResourceClaimStatus>()),
154                },
155            },
156        })
157    }
158}
159
160#[cfg(feature = "schemars08")]
161impl crate::schemars08::JsonSchema for PodGroupStatus {
162    fn schema_name() -> std::string::String {
163        "io.k8s.api.scheduling.v1alpha2.PodGroupStatus".into()
164    }
165
166    fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
167        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
168            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
169                description: Some("PodGroupStatus represents information about the status of a pod group.".into()),
170                ..Default::default()
171            })),
172            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
173            object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
174                properties: [
175                    (
176                        "conditions".into(),
177                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
178                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
179                                description: Some("Conditions represent the latest observations of the PodGroup's state.\n\nKnown condition types: - \"PodGroupScheduled\": Indicates whether the scheduling requirement has been satisfied. - \"DisruptionTarget\": Indicates whether the PodGroup is about to be terminated\n  due to disruption such as preemption.\n\nKnown reasons for the PodGroupScheduled condition: - \"Unschedulable\": The PodGroup cannot be scheduled due to resource constraints,\n  affinity/anti-affinity rules, or insufficient capacity for the gang.\n- \"SchedulerError\": The PodGroup cannot be scheduled due to some internal error\n  that happened during scheduling, for example due to nodeAffinity parsing errors.\n\nKnown reasons for the DisruptionTarget condition: - \"PreemptionByScheduler\": The PodGroup was preempted by the scheduler to make room for\n  higher-priority PodGroups or Pods.".into()),
180                                ..Default::default()
181                            })),
182                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
183                            array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
184                                items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Condition>()))),
185                                ..Default::default()
186                            })),
187                            ..Default::default()
188                        }),
189                    ),
190                    (
191                        "resourceClaimStatuses".into(),
192                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
193                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
194                                description: Some("Status of resource claims.".into()),
195                                ..Default::default()
196                            })),
197                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
198                            array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
199                                items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::api::scheduling::v1alpha2::PodGroupResourceClaimStatus>()))),
200                                ..Default::default()
201                            })),
202                            ..Default::default()
203                        }),
204                    ),
205                ].into(),
206                ..Default::default()
207            })),
208            ..Default::default()
209        })
210    }
211}