k8s_openapi/v1_33/api/resource/v1beta1/
device_request_allocation_result.rs

1// Generated from definition io.k8s.api.resource.v1beta1.DeviceRequestAllocationResult
2
3/// DeviceRequestAllocationResult contains the allocation result for one request.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct DeviceRequestAllocationResult {
6    /// AdminAccess indicates that this device was allocated for administrative access. See the corresponding request field for a definition of mode.
7    ///
8    /// This is an alpha field and requires enabling the DRAAdminAccess feature gate. Admin access is disabled if this field is unset or set to false, otherwise it is enabled.
9    pub admin_access: Option<bool>,
10
11    /// Device references one device instance via its name in the driver's resource pool. It must be a DNS label.
12    pub device: std::string::String,
13
14    /// Driver specifies the name of the DRA driver whose kubelet plugin should be invoked to process the allocation once the claim is needed on a node.
15    ///
16    /// Must be a DNS subdomain and should end with a DNS domain owned by the vendor of the driver.
17    pub driver: std::string::String,
18
19    /// This name together with the driver name and the device name field identify which device was allocated (`\<driver name\>/\<pool name\>/\<device name\>`).
20    ///
21    /// Must not be longer than 253 characters and may contain one or more DNS sub-domains separated by slashes.
22    pub pool: std::string::String,
23
24    /// Request is the name of the request in the claim which caused this device to be allocated. If it references a subrequest in the firstAvailable list on a DeviceRequest, this field must include both the name of the main request and the subrequest using the format \<main request\>/\<subrequest\>.
25    ///
26    /// Multiple devices may have been allocated per request.
27    pub request: std::string::String,
28
29    /// A copy of all tolerations specified in the request at the time when the device got allocated.
30    ///
31    /// The maximum number of tolerations is 16.
32    ///
33    /// This is an alpha field and requires enabling the DRADeviceTaints feature gate.
34    pub tolerations: Option<std::vec::Vec<crate::api::resource::v1beta1::DeviceToleration>>,
35}
36
37impl crate::DeepMerge for DeviceRequestAllocationResult {
38    fn merge_from(&mut self, other: Self) {
39        crate::DeepMerge::merge_from(&mut self.admin_access, other.admin_access);
40        crate::DeepMerge::merge_from(&mut self.device, other.device);
41        crate::DeepMerge::merge_from(&mut self.driver, other.driver);
42        crate::DeepMerge::merge_from(&mut self.pool, other.pool);
43        crate::DeepMerge::merge_from(&mut self.request, other.request);
44        crate::merge_strategies::list::atomic(&mut self.tolerations, other.tolerations);
45    }
46}
47
48impl<'de> crate::serde::Deserialize<'de> for DeviceRequestAllocationResult {
49    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
50        #[allow(non_camel_case_types)]
51        enum Field {
52            Key_admin_access,
53            Key_device,
54            Key_driver,
55            Key_pool,
56            Key_request,
57            Key_tolerations,
58            Other,
59        }
60
61        impl<'de> crate::serde::Deserialize<'de> for Field {
62            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
63                struct Visitor;
64
65                impl crate::serde::de::Visitor<'_> for Visitor {
66                    type Value = Field;
67
68                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
69                        f.write_str("field identifier")
70                    }
71
72                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
73                        Ok(match v {
74                            "adminAccess" => Field::Key_admin_access,
75                            "device" => Field::Key_device,
76                            "driver" => Field::Key_driver,
77                            "pool" => Field::Key_pool,
78                            "request" => Field::Key_request,
79                            "tolerations" => Field::Key_tolerations,
80                            _ => Field::Other,
81                        })
82                    }
83                }
84
85                deserializer.deserialize_identifier(Visitor)
86            }
87        }
88
89        struct Visitor;
90
91        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
92            type Value = DeviceRequestAllocationResult;
93
94            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
95                f.write_str("DeviceRequestAllocationResult")
96            }
97
98            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
99                let mut value_admin_access: Option<bool> = None;
100                let mut value_device: Option<std::string::String> = None;
101                let mut value_driver: Option<std::string::String> = None;
102                let mut value_pool: Option<std::string::String> = None;
103                let mut value_request: Option<std::string::String> = None;
104                let mut value_tolerations: Option<std::vec::Vec<crate::api::resource::v1beta1::DeviceToleration>> = None;
105
106                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
107                    match key {
108                        Field::Key_admin_access => value_admin_access = crate::serde::de::MapAccess::next_value(&mut map)?,
109                        Field::Key_device => value_device = crate::serde::de::MapAccess::next_value(&mut map)?,
110                        Field::Key_driver => value_driver = crate::serde::de::MapAccess::next_value(&mut map)?,
111                        Field::Key_pool => value_pool = crate::serde::de::MapAccess::next_value(&mut map)?,
112                        Field::Key_request => value_request = crate::serde::de::MapAccess::next_value(&mut map)?,
113                        Field::Key_tolerations => value_tolerations = crate::serde::de::MapAccess::next_value(&mut map)?,
114                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
115                    }
116                }
117
118                Ok(DeviceRequestAllocationResult {
119                    admin_access: value_admin_access,
120                    device: value_device.unwrap_or_default(),
121                    driver: value_driver.unwrap_or_default(),
122                    pool: value_pool.unwrap_or_default(),
123                    request: value_request.unwrap_or_default(),
124                    tolerations: value_tolerations,
125                })
126            }
127        }
128
129        deserializer.deserialize_struct(
130            "DeviceRequestAllocationResult",
131            &[
132                "adminAccess",
133                "device",
134                "driver",
135                "pool",
136                "request",
137                "tolerations",
138            ],
139            Visitor,
140        )
141    }
142}
143
144impl crate::serde::Serialize for DeviceRequestAllocationResult {
145    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
146        let mut state = serializer.serialize_struct(
147            "DeviceRequestAllocationResult",
148            4 +
149            self.admin_access.as_ref().map_or(0, |_| 1) +
150            self.tolerations.as_ref().map_or(0, |_| 1),
151        )?;
152        if let Some(value) = &self.admin_access {
153            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "adminAccess", value)?;
154        }
155        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "device", &self.device)?;
156        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "driver", &self.driver)?;
157        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "pool", &self.pool)?;
158        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "request", &self.request)?;
159        if let Some(value) = &self.tolerations {
160            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "tolerations", value)?;
161        }
162        crate::serde::ser::SerializeStruct::end(state)
163    }
164}
165
166#[cfg(feature = "schemars")]
167impl crate::schemars::JsonSchema for DeviceRequestAllocationResult {
168    fn schema_name() -> std::string::String {
169        "io.k8s.api.resource.v1beta1.DeviceRequestAllocationResult".into()
170    }
171
172    fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
173        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
174            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
175                description: Some("DeviceRequestAllocationResult contains the allocation result for one request.".into()),
176                ..Default::default()
177            })),
178            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
179            object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
180                properties: [
181                    (
182                        "adminAccess".into(),
183                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
184                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
185                                description: Some("AdminAccess indicates that this device was allocated for administrative access. See the corresponding request field for a definition of mode.\n\nThis is an alpha field and requires enabling the DRAAdminAccess feature gate. Admin access is disabled if this field is unset or set to false, otherwise it is enabled.".into()),
186                                ..Default::default()
187                            })),
188                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Boolean))),
189                            ..Default::default()
190                        }),
191                    ),
192                    (
193                        "device".into(),
194                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
195                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
196                                description: Some("Device references one device instance via its name in the driver's resource pool. It must be a DNS label.".into()),
197                                ..Default::default()
198                            })),
199                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
200                            ..Default::default()
201                        }),
202                    ),
203                    (
204                        "driver".into(),
205                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
206                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
207                                description: Some("Driver specifies the name of the DRA driver whose kubelet plugin should be invoked to process the allocation once the claim is needed on a node.\n\nMust be a DNS subdomain and should end with a DNS domain owned by the vendor of the driver.".into()),
208                                ..Default::default()
209                            })),
210                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
211                            ..Default::default()
212                        }),
213                    ),
214                    (
215                        "pool".into(),
216                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
217                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
218                                description: Some("This name together with the driver name and the device name field identify which device was allocated (`<driver name>/<pool name>/<device name>`).\n\nMust not be longer than 253 characters and may contain one or more DNS sub-domains separated by slashes.".into()),
219                                ..Default::default()
220                            })),
221                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
222                            ..Default::default()
223                        }),
224                    ),
225                    (
226                        "request".into(),
227                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
228                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
229                                description: Some("Request is the name of the request in the claim which caused this device to be allocated. If it references a subrequest in the firstAvailable list on a DeviceRequest, this field must include both the name of the main request and the subrequest using the format <main request>/<subrequest>.\n\nMultiple devices may have been allocated per request.".into()),
230                                ..Default::default()
231                            })),
232                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
233                            ..Default::default()
234                        }),
235                    ),
236                    (
237                        "tolerations".into(),
238                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
239                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
240                                description: Some("A copy of all tolerations specified in the request at the time when the device got allocated.\n\nThe maximum number of tolerations is 16.\n\nThis is an alpha field and requires enabling the DRADeviceTaints feature gate.".into()),
241                                ..Default::default()
242                            })),
243                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Array))),
244                            array: Some(std::boxed::Box::new(crate::schemars::schema::ArrayValidation {
245                                items: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::api::resource::v1beta1::DeviceToleration>()))),
246                                ..Default::default()
247                            })),
248                            ..Default::default()
249                        }),
250                    ),
251                ].into(),
252                required: [
253                    "device".into(),
254                    "driver".into(),
255                    "pool".into(),
256                    "request".into(),
257                ].into(),
258                ..Default::default()
259            })),
260            ..Default::default()
261        })
262    }
263}