k8s_openapi/v1_36/api/resource/v1alpha3/
device_taint_rule.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct DeviceTaintRule {
6 pub metadata: crate::apimachinery::pkg::apis::meta::v1::ObjectMeta,
8
9 pub spec: crate::api::resource::v1alpha3::DeviceTaintRuleSpec,
13
14 pub status: Option<crate::api::resource::v1alpha3::DeviceTaintRuleStatus>,
16}
17
18impl crate::Resource for DeviceTaintRule {
19 const API_VERSION: &'static str = "resource.k8s.io/v1alpha3";
20 const GROUP: &'static str = "resource.k8s.io";
21 const KIND: &'static str = "DeviceTaintRule";
22 const VERSION: &'static str = "v1alpha3";
23 const URL_PATH_SEGMENT: &'static str = "devicetaintrules";
24 type Scope = crate::ClusterResourceScope;
25}
26
27impl crate::ListableResource for DeviceTaintRule {
28 const LIST_KIND: &'static str = "DeviceTaintRuleList";
29}
30
31impl crate::Metadata for DeviceTaintRule {
32 type Ty = crate::apimachinery::pkg::apis::meta::v1::ObjectMeta;
33
34 fn metadata(&self) -> &<Self as crate::Metadata>::Ty {
35 &self.metadata
36 }
37
38 fn metadata_mut(&mut self) -> &mut<Self as crate::Metadata>::Ty {
39 &mut self.metadata
40 }
41}
42
43impl crate::DeepMerge for DeviceTaintRule {
44 fn merge_from(&mut self, other: Self) {
45 crate::DeepMerge::merge_from(&mut self.metadata, other.metadata);
46 crate::DeepMerge::merge_from(&mut self.spec, other.spec);
47 crate::DeepMerge::merge_from(&mut self.status, other.status);
48 }
49}
50
51impl<'de> crate::serde::Deserialize<'de> for DeviceTaintRule {
52 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
53 #[allow(non_camel_case_types)]
54 enum Field {
55 Key_api_version,
56 Key_kind,
57 Key_metadata,
58 Key_spec,
59 Key_status,
60 Other,
61 }
62
63 impl<'de> crate::serde::Deserialize<'de> for Field {
64 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
65 struct Visitor;
66
67 impl crate::serde::de::Visitor<'_> for Visitor {
68 type Value = Field;
69
70 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
71 f.write_str("field identifier")
72 }
73
74 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
75 Ok(match v {
76 "apiVersion" => Field::Key_api_version,
77 "kind" => Field::Key_kind,
78 "metadata" => Field::Key_metadata,
79 "spec" => Field::Key_spec,
80 "status" => Field::Key_status,
81 _ => Field::Other,
82 })
83 }
84 }
85
86 deserializer.deserialize_identifier(Visitor)
87 }
88 }
89
90 struct Visitor;
91
92 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
93 type Value = DeviceTaintRule;
94
95 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
96 f.write_str(<Self::Value as crate::Resource>::KIND)
97 }
98
99 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
100 let mut value_metadata: Option<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
101 let mut value_spec: Option<crate::api::resource::v1alpha3::DeviceTaintRuleSpec> = None;
102 let mut value_status: Option<crate::api::resource::v1alpha3::DeviceTaintRuleStatus> = None;
103
104 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
105 match key {
106 Field::Key_api_version => {
107 let value_api_version: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
108 if value_api_version != <Self::Value as crate::Resource>::API_VERSION {
109 return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_api_version), &<Self::Value as crate::Resource>::API_VERSION));
110 }
111 },
112 Field::Key_kind => {
113 let value_kind: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
114 if value_kind != <Self::Value as crate::Resource>::KIND {
115 return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_kind), &<Self::Value as crate::Resource>::KIND));
116 }
117 },
118 Field::Key_metadata => value_metadata = crate::serde::de::MapAccess::next_value(&mut map)?,
119 Field::Key_spec => value_spec = crate::serde::de::MapAccess::next_value(&mut map)?,
120 Field::Key_status => value_status = crate::serde::de::MapAccess::next_value(&mut map)?,
121 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
122 }
123 }
124
125 Ok(DeviceTaintRule {
126 metadata: value_metadata.unwrap_or_default(),
127 spec: value_spec.unwrap_or_default(),
128 status: value_status,
129 })
130 }
131 }
132
133 deserializer.deserialize_struct(
134 <Self as crate::Resource>::KIND,
135 &[
136 "apiVersion",
137 "kind",
138 "metadata",
139 "spec",
140 "status",
141 ],
142 Visitor,
143 )
144 }
145}
146
147impl crate::serde::Serialize for DeviceTaintRule {
148 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
149 let mut state = serializer.serialize_struct(
150 <Self as crate::Resource>::KIND,
151 4 +
152 self.status.as_ref().map_or(0, |_| 1),
153 )?;
154 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as crate::Resource>::API_VERSION)?;
155 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as crate::Resource>::KIND)?;
156 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
157 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "spec", &self.spec)?;
158 if let Some(value) = &self.status {
159 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "status", value)?;
160 }
161 crate::serde::ser::SerializeStruct::end(state)
162 }
163}
164
165#[cfg(feature = "schemars")]
166impl crate::schemars::JsonSchema for DeviceTaintRule {
167 fn schema_name() -> std::borrow::Cow<'static, str> {
168 "io.k8s.api.resource.v1alpha3.DeviceTaintRule".into()
169 }
170
171 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
172 crate::schemars::json_schema!({
173 "description": "DeviceTaintRule adds one taint to all devices which match the selector. This has the same effect as if the taint was specified directly in the ResourceSlice by the DRA driver.",
174 "type": "object",
175 "properties": {
176 "apiVersion": {
177 "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
178 "type": "string",
179 },
180 "kind": {
181 "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
182 "type": "string",
183 },
184 "metadata": ({
185 let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta>();
186 schema_obj.ensure_object().insert("description".into(), "Standard object metadata".into());
187 schema_obj
188 }),
189 "spec": ({
190 let mut schema_obj = __gen.subschema_for::<crate::api::resource::v1alpha3::DeviceTaintRuleSpec>();
191 schema_obj.ensure_object().insert("description".into(), "Spec specifies the selector and one taint.\n\nChanging the spec automatically increments the metadata.generation number.".into());
192 schema_obj
193 }),
194 "status": ({
195 let mut schema_obj = __gen.subschema_for::<crate::api::resource::v1alpha3::DeviceTaintRuleStatus>();
196 schema_obj.ensure_object().insert("description".into(), "Status provides information about what was requested in the spec.".into());
197 schema_obj
198 }),
199 },
200 "required": [
201 "metadata",
202 "spec",
203 ],
204 })
205 }
206}
207
208#[cfg(feature = "schemars08")]
209impl crate::schemars08::JsonSchema for DeviceTaintRule {
210 fn schema_name() -> std::string::String {
211 "io.k8s.api.resource.v1alpha3.DeviceTaintRule".into()
212 }
213
214 fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
215 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
216 metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
217 description: Some("DeviceTaintRule adds one taint to all devices which match the selector. This has the same effect as if the taint was specified directly in the ResourceSlice by the DRA driver.".into()),
218 ..Default::default()
219 })),
220 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
221 object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
222 properties: [
223 (
224 "apiVersion".into(),
225 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
226 metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
227 description: Some("APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources".into()),
228 ..Default::default()
229 })),
230 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
231 ..Default::default()
232 }),
233 ),
234 (
235 "kind".into(),
236 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
237 metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
238 description: Some("Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds".into()),
239 ..Default::default()
240 })),
241 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
242 ..Default::default()
243 }),
244 ),
245 (
246 "metadata".into(),
247 {
248 let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta>().into_object();
249 schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
250 description: Some("Standard object metadata".into()),
251 ..Default::default()
252 }));
253 crate::schemars08::schema::Schema::Object(schema_obj)
254 },
255 ),
256 (
257 "spec".into(),
258 {
259 let mut schema_obj = __gen.subschema_for::<crate::api::resource::v1alpha3::DeviceTaintRuleSpec>().into_object();
260 schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
261 description: Some("Spec specifies the selector and one taint.\n\nChanging the spec automatically increments the metadata.generation number.".into()),
262 ..Default::default()
263 }));
264 crate::schemars08::schema::Schema::Object(schema_obj)
265 },
266 ),
267 (
268 "status".into(),
269 {
270 let mut schema_obj = __gen.subschema_for::<crate::api::resource::v1alpha3::DeviceTaintRuleStatus>().into_object();
271 schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
272 description: Some("Status provides information about what was requested in the spec.".into()),
273 ..Default::default()
274 }));
275 crate::schemars08::schema::Schema::Object(schema_obj)
276 },
277 ),
278 ].into(),
279 required: [
280 "metadata".into(),
281 "spec".into(),
282 ].into(),
283 ..Default::default()
284 })),
285 ..Default::default()
286 })
287 }
288}