1// Generated from definition io.k8s.api.resource.v1beta1.DeviceRequestAllocationResult
23/// 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.
9pub admin_access: Option<bool>,
1011/// Device references one device instance via its name in the driver's resource pool. It must be a DNS label.
12pub device: std::string::String,
1314/// 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.
17pub driver: std::string::String,
1819/// 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.
22pub pool: std::string::String,
2324/// 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.
27pub request: std::string::String,
2829/// 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.
34pub tolerations: Option<std::vec::Vec<crate::api::resource::v1beta1::DeviceToleration>>,
35}
3637impl crate::DeepMerge for DeviceRequestAllocationResult {
38fn merge_from(&mut self, other: Self) {
39crate::DeepMerge::merge_from(&mut self.admin_access, other.admin_access);
40crate::DeepMerge::merge_from(&mut self.device, other.device);
41crate::DeepMerge::merge_from(&mut self.driver, other.driver);
42crate::DeepMerge::merge_from(&mut self.pool, other.pool);
43crate::DeepMerge::merge_from(&mut self.request, other.request);
44crate::merge_strategies::list::atomic(&mut self.tolerations, other.tolerations);
45 }
46}
4748impl<'de> crate::serde::Deserialize<'de> for DeviceRequestAllocationResult {
49fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
50#[allow(non_camel_case_types)]
51enum Field {
52 Key_admin_access,
53 Key_device,
54 Key_driver,
55 Key_pool,
56 Key_request,
57 Key_tolerations,
58 Other,
59 }
6061impl<'de> crate::serde::Deserialize<'de> for Field {
62fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
63struct Visitor;
6465impl crate::serde::de::Visitor<'_> for Visitor {
66type Value = Field;
6768fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
69 f.write_str("field identifier")
70 }
7172fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
73Ok(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 }
8485 deserializer.deserialize_identifier(Visitor)
86 }
87 }
8889struct Visitor;
9091impl<'de> crate::serde::de::Visitor<'de> for Visitor {
92type Value = DeviceRequestAllocationResult;
9394fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
95 f.write_str("DeviceRequestAllocationResult")
96 }
9798fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
99let mut value_admin_access: Option<bool> = None;
100let mut value_device: Option<std::string::String> = None;
101let mut value_driver: Option<std::string::String> = None;
102let mut value_pool: Option<std::string::String> = None;
103let mut value_request: Option<std::string::String> = None;
104let mut value_tolerations: Option<std::vec::Vec<crate::api::resource::v1beta1::DeviceToleration>> = None;
105106while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
107match 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 }
117118Ok(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 }
128129 deserializer.deserialize_struct(
130"DeviceRequestAllocationResult",
131&[
132"adminAccess",
133"device",
134"driver",
135"pool",
136"request",
137"tolerations",
138 ],
139 Visitor,
140 )
141 }
142}
143144impl crate::serde::Serialize for DeviceRequestAllocationResult {
145fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
146let mut state = serializer.serialize_struct(
147"DeviceRequestAllocationResult",
1484 +
149self.admin_access.as_ref().map_or(0, |_| 1) +
150self.tolerations.as_ref().map_or(0, |_| 1),
151 )?;
152if let Some(value) = &self.admin_access {
153crate::serde::ser::SerializeStruct::serialize_field(&mut state, "adminAccess", value)?;
154 }
155crate::serde::ser::SerializeStruct::serialize_field(&mut state, "device", &self.device)?;
156crate::serde::ser::SerializeStruct::serialize_field(&mut state, "driver", &self.driver)?;
157crate::serde::ser::SerializeStruct::serialize_field(&mut state, "pool", &self.pool)?;
158crate::serde::ser::SerializeStruct::serialize_field(&mut state, "request", &self.request)?;
159if let Some(value) = &self.tolerations {
160crate::serde::ser::SerializeStruct::serialize_field(&mut state, "tolerations", value)?;
161 }
162crate::serde::ser::SerializeStruct::end(state)
163 }
164}
165166#[cfg(feature = "schemars")]
167impl crate::schemars::JsonSchema for DeviceRequestAllocationResult {
168fn schema_name() -> std::string::String {
169"io.k8s.api.resource.v1beta1.DeviceRequestAllocationResult".into()
170 }
171172fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
173crate::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(),
183crate::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(),
194crate::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(),
205crate::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(),
216crate::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(),
227crate::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(),
238crate::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}