1// Generated from definition io.k8s.api.scheduling.v1.PriorityClass
23/// PriorityClass defines mapping from a priority class name to the priority integer value. The value can be any valid integer.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct PriorityClass {
6/// description is an arbitrary string that usually provides guidelines on when this priority class should be used.
7pub description: Option<std::string::String>,
89/// globalDefault specifies whether this PriorityClass should be considered as the default priority for pods that do not have any priority class. Only one PriorityClass can be marked as `globalDefault`. However, if more than one PriorityClasses exists with their `globalDefault` field set to true, the smallest value of such global default PriorityClasses will be used as the default priority.
10pub global_default: Option<bool>,
1112/// Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
13pub metadata: crate::apimachinery::pkg::apis::meta::v1::ObjectMeta,
1415/// preemptionPolicy is the Policy for preempting pods with lower priority. One of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset.
16pub preemption_policy: Option<std::string::String>,
1718/// value represents the integer value of this priority class. This is the actual priority that pods receive when they have the name of this class in their pod spec.
19pub value: i32,
20}
2122impl crate::Resource for PriorityClass {
23const API_VERSION: &'static str = "scheduling.k8s.io/v1";
24const GROUP: &'static str = "scheduling.k8s.io";
25const KIND: &'static str = "PriorityClass";
26const VERSION: &'static str = "v1";
27const URL_PATH_SEGMENT: &'static str = "priorityclasses";
28type Scope = crate::ClusterResourceScope;
29}
3031impl crate::ListableResource for PriorityClass {
32const LIST_KIND: &'static str = "PriorityClassList";
33}
3435impl crate::Metadata for PriorityClass {
36type Ty = crate::apimachinery::pkg::apis::meta::v1::ObjectMeta;
3738fn metadata(&self) -> &<Self as crate::Metadata>::Ty {
39&self.metadata
40 }
4142fn metadata_mut(&mut self) -> &mut<Self as crate::Metadata>::Ty {
43&mut self.metadata
44 }
45}
4647impl crate::DeepMerge for PriorityClass {
48fn merge_from(&mut self, other: Self) {
49crate::DeepMerge::merge_from(&mut self.description, other.description);
50crate::DeepMerge::merge_from(&mut self.global_default, other.global_default);
51crate::DeepMerge::merge_from(&mut self.metadata, other.metadata);
52crate::DeepMerge::merge_from(&mut self.preemption_policy, other.preemption_policy);
53crate::DeepMerge::merge_from(&mut self.value, other.value);
54 }
55}
5657impl<'de> crate::serde::Deserialize<'de> for PriorityClass {
58fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
59#[allow(non_camel_case_types)]
60enum Field {
61 Key_api_version,
62 Key_kind,
63 Key_description,
64 Key_global_default,
65 Key_metadata,
66 Key_preemption_policy,
67 Key_value,
68 Other,
69 }
7071impl<'de> crate::serde::Deserialize<'de> for Field {
72fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
73struct Visitor;
7475impl crate::serde::de::Visitor<'_> for Visitor {
76type Value = Field;
7778fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
79 f.write_str("field identifier")
80 }
8182fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
83Ok(match v {
84"apiVersion" => Field::Key_api_version,
85"kind" => Field::Key_kind,
86"description" => Field::Key_description,
87"globalDefault" => Field::Key_global_default,
88"metadata" => Field::Key_metadata,
89"preemptionPolicy" => Field::Key_preemption_policy,
90"value" => Field::Key_value,
91_ => Field::Other,
92 })
93 }
94 }
9596 deserializer.deserialize_identifier(Visitor)
97 }
98 }
99100struct Visitor;
101102impl<'de> crate::serde::de::Visitor<'de> for Visitor {
103type Value = PriorityClass;
104105fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
106 f.write_str(<Self::Value as crate::Resource>::KIND)
107 }
108109fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
110let mut value_description: Option<std::string::String> = None;
111let mut value_global_default: Option<bool> = None;
112let mut value_metadata: Option<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
113let mut value_preemption_policy: Option<std::string::String> = None;
114let mut value_value: Option<i32> = None;
115116while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
117match key {
118 Field::Key_api_version => {
119let value_api_version: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
120if value_api_version != <Self::Value as crate::Resource>::API_VERSION {
121return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_api_version), &<Self::Value as crate::Resource>::API_VERSION));
122 }
123 },
124 Field::Key_kind => {
125let value_kind: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
126if value_kind != <Self::Value as crate::Resource>::KIND {
127return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_kind), &<Self::Value as crate::Resource>::KIND));
128 }
129 },
130 Field::Key_description => value_description = crate::serde::de::MapAccess::next_value(&mut map)?,
131 Field::Key_global_default => value_global_default = crate::serde::de::MapAccess::next_value(&mut map)?,
132 Field::Key_metadata => value_metadata = crate::serde::de::MapAccess::next_value(&mut map)?,
133 Field::Key_preemption_policy => value_preemption_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
134 Field::Key_value => value_value = crate::serde::de::MapAccess::next_value(&mut map)?,
135 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
136 }
137 }
138139Ok(PriorityClass {
140 description: value_description,
141 global_default: value_global_default,
142 metadata: value_metadata.unwrap_or_default(),
143 preemption_policy: value_preemption_policy,
144 value: value_value.unwrap_or_default(),
145 })
146 }
147 }
148149 deserializer.deserialize_struct(
150 <Self as crate::Resource>::KIND,
151&[
152"apiVersion",
153"kind",
154"description",
155"globalDefault",
156"metadata",
157"preemptionPolicy",
158"value",
159 ],
160 Visitor,
161 )
162 }
163}
164165impl crate::serde::Serialize for PriorityClass {
166fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
167let mut state = serializer.serialize_struct(
168 <Self as crate::Resource>::KIND,
1694 +
170self.description.as_ref().map_or(0, |_| 1) +
171self.global_default.as_ref().map_or(0, |_| 1) +
172self.preemption_policy.as_ref().map_or(0, |_| 1),
173 )?;
174crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as crate::Resource>::API_VERSION)?;
175crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as crate::Resource>::KIND)?;
176if let Some(value) = &self.description {
177crate::serde::ser::SerializeStruct::serialize_field(&mut state, "description", value)?;
178 }
179if let Some(value) = &self.global_default {
180crate::serde::ser::SerializeStruct::serialize_field(&mut state, "globalDefault", value)?;
181 }
182crate::serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
183if let Some(value) = &self.preemption_policy {
184crate::serde::ser::SerializeStruct::serialize_field(&mut state, "preemptionPolicy", value)?;
185 }
186crate::serde::ser::SerializeStruct::serialize_field(&mut state, "value", &self.value)?;
187crate::serde::ser::SerializeStruct::end(state)
188 }
189}
190191#[cfg(feature = "schemars")]
192impl crate::schemars::JsonSchema for PriorityClass {
193fn schema_name() -> std::string::String {
194"io.k8s.api.scheduling.v1.PriorityClass".into()
195 }
196197fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
198crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
199 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
200 description: Some("PriorityClass defines mapping from a priority class name to the priority integer value. The value can be any valid integer.".into()),
201 ..Default::default()
202 })),
203 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
204 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
205 properties: [
206 (
207"apiVersion".into(),
208crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
209 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
210 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()),
211 ..Default::default()
212 })),
213 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
214 ..Default::default()
215 }),
216 ),
217 (
218"description".into(),
219crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
220 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
221 description: Some("description is an arbitrary string that usually provides guidelines on when this priority class should be used.".into()),
222 ..Default::default()
223 })),
224 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
225 ..Default::default()
226 }),
227 ),
228 (
229"globalDefault".into(),
230crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
231 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
232 description: Some("globalDefault specifies whether this PriorityClass should be considered as the default priority for pods that do not have any priority class. Only one PriorityClass can be marked as `globalDefault`. However, if more than one PriorityClasses exists with their `globalDefault` field set to true, the smallest value of such global default PriorityClasses will be used as the default priority.".into()),
233 ..Default::default()
234 })),
235 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Boolean))),
236 ..Default::default()
237 }),
238 ),
239 (
240"kind".into(),
241crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
242 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
243 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()),
244 ..Default::default()
245 })),
246 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
247 ..Default::default()
248 }),
249 ),
250 (
251"metadata".into(),
252 {
253let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta>().into_object();
254 schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
255 description: Some("Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata".into()),
256 ..Default::default()
257 }));
258crate::schemars::schema::Schema::Object(schema_obj)
259 },
260 ),
261 (
262"preemptionPolicy".into(),
263crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
264 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
265 description: Some("preemptionPolicy is the Policy for preempting pods with lower priority. One of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset.".into()),
266 ..Default::default()
267 })),
268 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
269 ..Default::default()
270 }),
271 ),
272 (
273"value".into(),
274crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
275 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
276 description: Some("value represents the integer value of this priority class. This is the actual priority that pods receive when they have the name of this class in their pod spec.".into()),
277 ..Default::default()
278 })),
279 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
280 format: Some("int32".into()),
281 ..Default::default()
282 }),
283 ),
284 ].into(),
285 required: [
286"metadata".into(),
287"value".into(),
288 ].into(),
289 ..Default::default()
290 })),
291 ..Default::default()
292 })
293 }
294}