Skip to main content

k8s_openapi/v1_36/api/resource/v1alpha3/
pool_status.rs

1// Generated from definition io.k8s.api.resource.v1alpha3.PoolStatus
2
3/// PoolStatus contains status information for a single resource pool.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct PoolStatus {
6    /// AllocatedDevices is the number of devices currently allocated to claims. A value of 0 means no devices are allocated. May be unset when validationError is set.
7    pub allocated_devices: Option<i32>,
8
9    /// AvailableDevices is the number of devices available for allocation. This equals TotalDevices - AllocatedDevices - UnavailableDevices. A value of 0 means no devices are currently available. May be unset when validationError is set.
10    pub available_devices: Option<i32>,
11
12    /// Driver is the DRA driver name for this pool. Must be a DNS subdomain (e.g., "gpu.example.com").
13    pub driver: std::string::String,
14
15    /// Generation is the pool generation observed across all ResourceSlices in this pool. Only the latest generation is reported. During a generation rollout, if not all slices at the latest generation have been published, the pool is included with a validationError and device counts unset.
16    pub generation: i64,
17
18    /// NodeName is the node this pool is associated with. When omitted, the pool is not associated with a specific node. Must be a valid DNS subdomain name (RFC1123).
19    pub node_name: Option<std::string::String>,
20
21    /// PoolName is the name of the pool. Must be a valid resource pool name (DNS subdomains separated by "/").
22    pub pool_name: std::string::String,
23
24    /// ResourceSliceCount is the number of ResourceSlices that make up this pool. May be unset when validationError is set.
25    pub resource_slice_count: Option<i32>,
26
27    /// TotalDevices is the total number of devices in the pool across all slices. A value of 0 means the pool has no devices. May be unset when validationError is set.
28    pub total_devices: Option<i32>,
29
30    /// UnavailableDevices is the number of devices that are not available due to taints or other conditions, but are not allocated. A value of 0 means all unallocated devices are available. May be unset when validationError is set.
31    pub unavailable_devices: Option<i32>,
32
33    /// ValidationError is set when the pool's data could not be fully validated (e.g., incomplete slice publication). When set, device count fields and ResourceSliceCount may be unset.
34    pub validation_error: Option<std::string::String>,
35}
36
37impl crate::DeepMerge for PoolStatus {
38    fn merge_from(&mut self, other: Self) {
39        crate::DeepMerge::merge_from(&mut self.allocated_devices, other.allocated_devices);
40        crate::DeepMerge::merge_from(&mut self.available_devices, other.available_devices);
41        crate::DeepMerge::merge_from(&mut self.driver, other.driver);
42        crate::DeepMerge::merge_from(&mut self.generation, other.generation);
43        crate::DeepMerge::merge_from(&mut self.node_name, other.node_name);
44        crate::DeepMerge::merge_from(&mut self.pool_name, other.pool_name);
45        crate::DeepMerge::merge_from(&mut self.resource_slice_count, other.resource_slice_count);
46        crate::DeepMerge::merge_from(&mut self.total_devices, other.total_devices);
47        crate::DeepMerge::merge_from(&mut self.unavailable_devices, other.unavailable_devices);
48        crate::DeepMerge::merge_from(&mut self.validation_error, other.validation_error);
49    }
50}
51
52impl<'de> crate::serde::Deserialize<'de> for PoolStatus {
53    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
54        #[allow(non_camel_case_types)]
55        enum Field {
56            Key_allocated_devices,
57            Key_available_devices,
58            Key_driver,
59            Key_generation,
60            Key_node_name,
61            Key_pool_name,
62            Key_resource_slice_count,
63            Key_total_devices,
64            Key_unavailable_devices,
65            Key_validation_error,
66            Other,
67        }
68
69        impl<'de> crate::serde::Deserialize<'de> for Field {
70            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
71                struct Visitor;
72
73                impl crate::serde::de::Visitor<'_> for Visitor {
74                    type Value = Field;
75
76                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
77                        f.write_str("field identifier")
78                    }
79
80                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
81                        Ok(match v {
82                            "allocatedDevices" => Field::Key_allocated_devices,
83                            "availableDevices" => Field::Key_available_devices,
84                            "driver" => Field::Key_driver,
85                            "generation" => Field::Key_generation,
86                            "nodeName" => Field::Key_node_name,
87                            "poolName" => Field::Key_pool_name,
88                            "resourceSliceCount" => Field::Key_resource_slice_count,
89                            "totalDevices" => Field::Key_total_devices,
90                            "unavailableDevices" => Field::Key_unavailable_devices,
91                            "validationError" => Field::Key_validation_error,
92                            _ => Field::Other,
93                        })
94                    }
95                }
96
97                deserializer.deserialize_identifier(Visitor)
98            }
99        }
100
101        struct Visitor;
102
103        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
104            type Value = PoolStatus;
105
106            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
107                f.write_str("PoolStatus")
108            }
109
110            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
111                let mut value_allocated_devices: Option<i32> = None;
112                let mut value_available_devices: Option<i32> = None;
113                let mut value_driver: Option<std::string::String> = None;
114                let mut value_generation: Option<i64> = None;
115                let mut value_node_name: Option<std::string::String> = None;
116                let mut value_pool_name: Option<std::string::String> = None;
117                let mut value_resource_slice_count: Option<i32> = None;
118                let mut value_total_devices: Option<i32> = None;
119                let mut value_unavailable_devices: Option<i32> = None;
120                let mut value_validation_error: Option<std::string::String> = None;
121
122                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
123                    match key {
124                        Field::Key_allocated_devices => value_allocated_devices = crate::serde::de::MapAccess::next_value(&mut map)?,
125                        Field::Key_available_devices => value_available_devices = crate::serde::de::MapAccess::next_value(&mut map)?,
126                        Field::Key_driver => value_driver = crate::serde::de::MapAccess::next_value(&mut map)?,
127                        Field::Key_generation => value_generation = crate::serde::de::MapAccess::next_value(&mut map)?,
128                        Field::Key_node_name => value_node_name = crate::serde::de::MapAccess::next_value(&mut map)?,
129                        Field::Key_pool_name => value_pool_name = crate::serde::de::MapAccess::next_value(&mut map)?,
130                        Field::Key_resource_slice_count => value_resource_slice_count = crate::serde::de::MapAccess::next_value(&mut map)?,
131                        Field::Key_total_devices => value_total_devices = crate::serde::de::MapAccess::next_value(&mut map)?,
132                        Field::Key_unavailable_devices => value_unavailable_devices = crate::serde::de::MapAccess::next_value(&mut map)?,
133                        Field::Key_validation_error => value_validation_error = crate::serde::de::MapAccess::next_value(&mut map)?,
134                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
135                    }
136                }
137
138                Ok(PoolStatus {
139                    allocated_devices: value_allocated_devices,
140                    available_devices: value_available_devices,
141                    driver: value_driver.unwrap_or_default(),
142                    generation: value_generation.unwrap_or_default(),
143                    node_name: value_node_name,
144                    pool_name: value_pool_name.unwrap_or_default(),
145                    resource_slice_count: value_resource_slice_count,
146                    total_devices: value_total_devices,
147                    unavailable_devices: value_unavailable_devices,
148                    validation_error: value_validation_error,
149                })
150            }
151        }
152
153        deserializer.deserialize_struct(
154            "PoolStatus",
155            &[
156                "allocatedDevices",
157                "availableDevices",
158                "driver",
159                "generation",
160                "nodeName",
161                "poolName",
162                "resourceSliceCount",
163                "totalDevices",
164                "unavailableDevices",
165                "validationError",
166            ],
167            Visitor,
168        )
169    }
170}
171
172impl crate::serde::Serialize for PoolStatus {
173    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
174        let mut state = serializer.serialize_struct(
175            "PoolStatus",
176            3 +
177            self.allocated_devices.as_ref().map_or(0, |_| 1) +
178            self.available_devices.as_ref().map_or(0, |_| 1) +
179            self.node_name.as_ref().map_or(0, |_| 1) +
180            self.resource_slice_count.as_ref().map_or(0, |_| 1) +
181            self.total_devices.as_ref().map_or(0, |_| 1) +
182            self.unavailable_devices.as_ref().map_or(0, |_| 1) +
183            self.validation_error.as_ref().map_or(0, |_| 1),
184        )?;
185        if let Some(value) = &self.allocated_devices {
186            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "allocatedDevices", value)?;
187        }
188        if let Some(value) = &self.available_devices {
189            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "availableDevices", value)?;
190        }
191        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "driver", &self.driver)?;
192        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "generation", &self.generation)?;
193        if let Some(value) = &self.node_name {
194            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nodeName", value)?;
195        }
196        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "poolName", &self.pool_name)?;
197        if let Some(value) = &self.resource_slice_count {
198            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resourceSliceCount", value)?;
199        }
200        if let Some(value) = &self.total_devices {
201            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "totalDevices", value)?;
202        }
203        if let Some(value) = &self.unavailable_devices {
204            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "unavailableDevices", value)?;
205        }
206        if let Some(value) = &self.validation_error {
207            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "validationError", value)?;
208        }
209        crate::serde::ser::SerializeStruct::end(state)
210    }
211}
212
213#[cfg(feature = "schemars")]
214impl crate::schemars::JsonSchema for PoolStatus {
215    fn schema_name() -> std::borrow::Cow<'static, str> {
216        "io.k8s.api.resource.v1alpha3.PoolStatus".into()
217    }
218
219    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
220        crate::schemars::json_schema!({
221            "description": "PoolStatus contains status information for a single resource pool.",
222            "type": "object",
223            "properties": {
224                "allocatedDevices": {
225                    "description": "AllocatedDevices is the number of devices currently allocated to claims. A value of 0 means no devices are allocated. May be unset when validationError is set.",
226                    "type": "integer",
227                    "format": "int32",
228                },
229                "availableDevices": {
230                    "description": "AvailableDevices is the number of devices available for allocation. This equals TotalDevices - AllocatedDevices - UnavailableDevices. A value of 0 means no devices are currently available. May be unset when validationError is set.",
231                    "type": "integer",
232                    "format": "int32",
233                },
234                "driver": {
235                    "description": "Driver is the DRA driver name for this pool. Must be a DNS subdomain (e.g., \"gpu.example.com\").",
236                    "type": "string",
237                },
238                "generation": {
239                    "description": "Generation is the pool generation observed across all ResourceSlices in this pool. Only the latest generation is reported. During a generation rollout, if not all slices at the latest generation have been published, the pool is included with a validationError and device counts unset.",
240                    "type": "integer",
241                    "format": "int64",
242                },
243                "nodeName": {
244                    "description": "NodeName is the node this pool is associated with. When omitted, the pool is not associated with a specific node. Must be a valid DNS subdomain name (RFC1123).",
245                    "type": "string",
246                },
247                "poolName": {
248                    "description": "PoolName is the name of the pool. Must be a valid resource pool name (DNS subdomains separated by \"/\").",
249                    "type": "string",
250                },
251                "resourceSliceCount": {
252                    "description": "ResourceSliceCount is the number of ResourceSlices that make up this pool. May be unset when validationError is set.",
253                    "type": "integer",
254                    "format": "int32",
255                },
256                "totalDevices": {
257                    "description": "TotalDevices is the total number of devices in the pool across all slices. A value of 0 means the pool has no devices. May be unset when validationError is set.",
258                    "type": "integer",
259                    "format": "int32",
260                },
261                "unavailableDevices": {
262                    "description": "UnavailableDevices is the number of devices that are not available due to taints or other conditions, but are not allocated. A value of 0 means all unallocated devices are available. May be unset when validationError is set.",
263                    "type": "integer",
264                    "format": "int32",
265                },
266                "validationError": {
267                    "description": "ValidationError is set when the pool's data could not be fully validated (e.g., incomplete slice publication). When set, device count fields and ResourceSliceCount may be unset.",
268                    "type": "string",
269                },
270            },
271            "required": [
272                "driver",
273                "generation",
274                "poolName",
275            ],
276        })
277    }
278}
279
280#[cfg(feature = "schemars08")]
281impl crate::schemars08::JsonSchema for PoolStatus {
282    fn schema_name() -> std::string::String {
283        "io.k8s.api.resource.v1alpha3.PoolStatus".into()
284    }
285
286    fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
287        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
288            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
289                description: Some("PoolStatus contains status information for a single resource pool.".into()),
290                ..Default::default()
291            })),
292            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
293            object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
294                properties: [
295                    (
296                        "allocatedDevices".into(),
297                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
298                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
299                                description: Some("AllocatedDevices is the number of devices currently allocated to claims. A value of 0 means no devices are allocated. May be unset when validationError is set.".into()),
300                                ..Default::default()
301                            })),
302                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
303                            format: Some("int32".into()),
304                            ..Default::default()
305                        }),
306                    ),
307                    (
308                        "availableDevices".into(),
309                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
310                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
311                                description: Some("AvailableDevices is the number of devices available for allocation. This equals TotalDevices - AllocatedDevices - UnavailableDevices. A value of 0 means no devices are currently available. May be unset when validationError is set.".into()),
312                                ..Default::default()
313                            })),
314                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
315                            format: Some("int32".into()),
316                            ..Default::default()
317                        }),
318                    ),
319                    (
320                        "driver".into(),
321                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
322                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
323                                description: Some("Driver is the DRA driver name for this pool. Must be a DNS subdomain (e.g., \"gpu.example.com\").".into()),
324                                ..Default::default()
325                            })),
326                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
327                            ..Default::default()
328                        }),
329                    ),
330                    (
331                        "generation".into(),
332                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
333                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
334                                description: Some("Generation is the pool generation observed across all ResourceSlices in this pool. Only the latest generation is reported. During a generation rollout, if not all slices at the latest generation have been published, the pool is included with a validationError and device counts unset.".into()),
335                                ..Default::default()
336                            })),
337                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
338                            format: Some("int64".into()),
339                            ..Default::default()
340                        }),
341                    ),
342                    (
343                        "nodeName".into(),
344                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
345                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
346                                description: Some("NodeName is the node this pool is associated with. When omitted, the pool is not associated with a specific node. Must be a valid DNS subdomain name (RFC1123).".into()),
347                                ..Default::default()
348                            })),
349                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
350                            ..Default::default()
351                        }),
352                    ),
353                    (
354                        "poolName".into(),
355                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
356                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
357                                description: Some("PoolName is the name of the pool. Must be a valid resource pool name (DNS subdomains separated by \"/\").".into()),
358                                ..Default::default()
359                            })),
360                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
361                            ..Default::default()
362                        }),
363                    ),
364                    (
365                        "resourceSliceCount".into(),
366                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
367                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
368                                description: Some("ResourceSliceCount is the number of ResourceSlices that make up this pool. May be unset when validationError is set.".into()),
369                                ..Default::default()
370                            })),
371                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
372                            format: Some("int32".into()),
373                            ..Default::default()
374                        }),
375                    ),
376                    (
377                        "totalDevices".into(),
378                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
379                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
380                                description: Some("TotalDevices is the total number of devices in the pool across all slices. A value of 0 means the pool has no devices. May be unset when validationError is set.".into()),
381                                ..Default::default()
382                            })),
383                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
384                            format: Some("int32".into()),
385                            ..Default::default()
386                        }),
387                    ),
388                    (
389                        "unavailableDevices".into(),
390                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
391                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
392                                description: Some("UnavailableDevices is the number of devices that are not available due to taints or other conditions, but are not allocated. A value of 0 means all unallocated devices are available. May be unset when validationError is set.".into()),
393                                ..Default::default()
394                            })),
395                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
396                            format: Some("int32".into()),
397                            ..Default::default()
398                        }),
399                    ),
400                    (
401                        "validationError".into(),
402                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
403                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
404                                description: Some("ValidationError is set when the pool's data could not be fully validated (e.g., incomplete slice publication). When set, device count fields and ResourceSliceCount may be unset.".into()),
405                                ..Default::default()
406                            })),
407                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
408                            ..Default::default()
409                        }),
410                    ),
411                ].into(),
412                required: [
413                    "driver".into(),
414                    "generation".into(),
415                    "poolName".into(),
416                ].into(),
417                ..Default::default()
418            })),
419            ..Default::default()
420        })
421    }
422}