k8s_openapi/v1_35/apiextensions_apiserver/pkg/apis/apiextensions/v1/
custom_resource_column_definition.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct CustomResourceColumnDefinition {
6 pub description: Option<std::string::String>,
8
9 pub format: Option<std::string::String>,
11
12 pub json_path: std::string::String,
14
15 pub name: std::string::String,
17
18 pub priority: Option<i32>,
20
21 pub type_: std::string::String,
23}
24
25impl crate::DeepMerge for CustomResourceColumnDefinition {
26 fn merge_from(&mut self, other: Self) {
27 crate::DeepMerge::merge_from(&mut self.description, other.description);
28 crate::DeepMerge::merge_from(&mut self.format, other.format);
29 crate::DeepMerge::merge_from(&mut self.json_path, other.json_path);
30 crate::DeepMerge::merge_from(&mut self.name, other.name);
31 crate::DeepMerge::merge_from(&mut self.priority, other.priority);
32 crate::DeepMerge::merge_from(&mut self.type_, other.type_);
33 }
34}
35
36impl<'de> crate::serde::Deserialize<'de> for CustomResourceColumnDefinition {
37 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
38 #[allow(non_camel_case_types)]
39 enum Field {
40 Key_description,
41 Key_format,
42 Key_json_path,
43 Key_name,
44 Key_priority,
45 Key_type_,
46 Other,
47 }
48
49 impl<'de> crate::serde::Deserialize<'de> for Field {
50 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
51 struct Visitor;
52
53 impl crate::serde::de::Visitor<'_> for Visitor {
54 type Value = Field;
55
56 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
57 f.write_str("field identifier")
58 }
59
60 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
61 Ok(match v {
62 "description" => Field::Key_description,
63 "format" => Field::Key_format,
64 "jsonPath" => Field::Key_json_path,
65 "name" => Field::Key_name,
66 "priority" => Field::Key_priority,
67 "type" => Field::Key_type_,
68 _ => Field::Other,
69 })
70 }
71 }
72
73 deserializer.deserialize_identifier(Visitor)
74 }
75 }
76
77 struct Visitor;
78
79 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
80 type Value = CustomResourceColumnDefinition;
81
82 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
83 f.write_str("CustomResourceColumnDefinition")
84 }
85
86 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
87 let mut value_description: Option<std::string::String> = None;
88 let mut value_format: Option<std::string::String> = None;
89 let mut value_json_path: Option<std::string::String> = None;
90 let mut value_name: Option<std::string::String> = None;
91 let mut value_priority: Option<i32> = None;
92 let mut value_type_: Option<std::string::String> = None;
93
94 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
95 match key {
96 Field::Key_description => value_description = crate::serde::de::MapAccess::next_value(&mut map)?,
97 Field::Key_format => value_format = crate::serde::de::MapAccess::next_value(&mut map)?,
98 Field::Key_json_path => value_json_path = crate::serde::de::MapAccess::next_value(&mut map)?,
99 Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
100 Field::Key_priority => value_priority = crate::serde::de::MapAccess::next_value(&mut map)?,
101 Field::Key_type_ => value_type_ = crate::serde::de::MapAccess::next_value(&mut map)?,
102 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
103 }
104 }
105
106 Ok(CustomResourceColumnDefinition {
107 description: value_description,
108 format: value_format,
109 json_path: value_json_path.unwrap_or_default(),
110 name: value_name.unwrap_or_default(),
111 priority: value_priority,
112 type_: value_type_.unwrap_or_default(),
113 })
114 }
115 }
116
117 deserializer.deserialize_struct(
118 "CustomResourceColumnDefinition",
119 &[
120 "description",
121 "format",
122 "jsonPath",
123 "name",
124 "priority",
125 "type",
126 ],
127 Visitor,
128 )
129 }
130}
131
132impl crate::serde::Serialize for CustomResourceColumnDefinition {
133 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
134 let mut state = serializer.serialize_struct(
135 "CustomResourceColumnDefinition",
136 3 +
137 self.description.as_ref().map_or(0, |_| 1) +
138 self.format.as_ref().map_or(0, |_| 1) +
139 self.priority.as_ref().map_or(0, |_| 1),
140 )?;
141 if let Some(value) = &self.description {
142 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "description", value)?;
143 }
144 if let Some(value) = &self.format {
145 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "format", value)?;
146 }
147 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "jsonPath", &self.json_path)?;
148 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
149 if let Some(value) = &self.priority {
150 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "priority", value)?;
151 }
152 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "type", &self.type_)?;
153 crate::serde::ser::SerializeStruct::end(state)
154 }
155}
156
157#[cfg(feature = "schemars")]
158impl crate::schemars::JsonSchema for CustomResourceColumnDefinition {
159 fn schema_name() -> std::borrow::Cow<'static, str> {
160 "io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.CustomResourceColumnDefinition".into()
161 }
162
163 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
164 crate::schemars::json_schema!({
165 "description": "CustomResourceColumnDefinition specifies a column for server side printing.",
166 "type": "object",
167 "properties": {
168 "description": {
169 "description": "description is a human readable description of this column.",
170 "type": "string",
171 },
172 "format": {
173 "description": "format is an optional OpenAPI type definition for this column. The 'name' format is applied to the primary identifier column to assist in clients identifying column is the resource name. See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for details.",
174 "type": "string",
175 },
176 "jsonPath": {
177 "description": "jsonPath is a simple JSON path (i.e. with array notation) which is evaluated against each custom resource to produce the value for this column.",
178 "type": "string",
179 },
180 "name": {
181 "description": "name is a human readable name for the column.",
182 "type": "string",
183 },
184 "priority": {
185 "description": "priority is an integer defining the relative importance of this column compared to others. Lower numbers are considered higher priority. Columns that may be omitted in limited space scenarios should be given a priority greater than 0.",
186 "type": "integer",
187 "format": "int32",
188 },
189 "type": {
190 "description": "type is an OpenAPI type definition for this column. See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for details.",
191 "type": "string",
192 },
193 },
194 "required": [
195 "jsonPath",
196 "name",
197 "type",
198 ],
199 })
200 }
201}