1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct Event {
6 pub action: Option<std::string::String>,
8
9 pub deprecated_count: Option<i32>,
11
12 pub deprecated_first_timestamp: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
14
15 pub deprecated_last_timestamp: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
17
18 pub deprecated_source: Option<crate::api::core::v1::EventSource>,
20
21 pub event_time: Option<crate::apimachinery::pkg::apis::meta::v1::MicroTime>,
23
24 pub metadata: crate::apimachinery::pkg::apis::meta::v1::ObjectMeta,
26
27 pub note: Option<std::string::String>,
29
30 pub reason: Option<std::string::String>,
32
33 pub regarding: Option<crate::api::core::v1::ObjectReference>,
35
36 pub related: Option<crate::api::core::v1::ObjectReference>,
38
39 pub reporting_controller: Option<std::string::String>,
41
42 pub reporting_instance: Option<std::string::String>,
44
45 pub series: Option<crate::api::events::v1::EventSeries>,
47
48 pub type_: Option<std::string::String>,
50}
51
52impl crate::Resource for Event {
53 const API_VERSION: &'static str = "events.k8s.io/v1";
54 const GROUP: &'static str = "events.k8s.io";
55 const KIND: &'static str = "Event";
56 const VERSION: &'static str = "v1";
57 const URL_PATH_SEGMENT: &'static str = "events";
58 type Scope = crate::NamespaceResourceScope;
59}
60
61impl crate::ListableResource for Event {
62 const LIST_KIND: &'static str = "EventList";
63}
64
65impl crate::Metadata for Event {
66 type Ty = crate::apimachinery::pkg::apis::meta::v1::ObjectMeta;
67
68 fn metadata(&self) -> &<Self as crate::Metadata>::Ty {
69 &self.metadata
70 }
71
72 fn metadata_mut(&mut self) -> &mut<Self as crate::Metadata>::Ty {
73 &mut self.metadata
74 }
75}
76
77impl crate::DeepMerge for Event {
78 fn merge_from(&mut self, other: Self) {
79 crate::DeepMerge::merge_from(&mut self.action, other.action);
80 crate::DeepMerge::merge_from(&mut self.deprecated_count, other.deprecated_count);
81 crate::DeepMerge::merge_from(&mut self.deprecated_first_timestamp, other.deprecated_first_timestamp);
82 crate::DeepMerge::merge_from(&mut self.deprecated_last_timestamp, other.deprecated_last_timestamp);
83 crate::DeepMerge::merge_from(&mut self.deprecated_source, other.deprecated_source);
84 crate::DeepMerge::merge_from(&mut self.event_time, other.event_time);
85 crate::DeepMerge::merge_from(&mut self.metadata, other.metadata);
86 crate::DeepMerge::merge_from(&mut self.note, other.note);
87 crate::DeepMerge::merge_from(&mut self.reason, other.reason);
88 crate::DeepMerge::merge_from(&mut self.regarding, other.regarding);
89 crate::DeepMerge::merge_from(&mut self.related, other.related);
90 crate::DeepMerge::merge_from(&mut self.reporting_controller, other.reporting_controller);
91 crate::DeepMerge::merge_from(&mut self.reporting_instance, other.reporting_instance);
92 crate::DeepMerge::merge_from(&mut self.series, other.series);
93 crate::DeepMerge::merge_from(&mut self.type_, other.type_);
94 }
95}
96
97impl<'de> crate::serde::Deserialize<'de> for Event {
98 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
99 #[allow(non_camel_case_types)]
100 enum Field {
101 Key_api_version,
102 Key_kind,
103 Key_action,
104 Key_deprecated_count,
105 Key_deprecated_first_timestamp,
106 Key_deprecated_last_timestamp,
107 Key_deprecated_source,
108 Key_event_time,
109 Key_metadata,
110 Key_note,
111 Key_reason,
112 Key_regarding,
113 Key_related,
114 Key_reporting_controller,
115 Key_reporting_instance,
116 Key_series,
117 Key_type_,
118 Other,
119 }
120
121 impl<'de> crate::serde::Deserialize<'de> for Field {
122 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
123 struct Visitor;
124
125 impl crate::serde::de::Visitor<'_> for Visitor {
126 type Value = Field;
127
128 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
129 f.write_str("field identifier")
130 }
131
132 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
133 Ok(match v {
134 "apiVersion" => Field::Key_api_version,
135 "kind" => Field::Key_kind,
136 "action" => Field::Key_action,
137 "deprecatedCount" => Field::Key_deprecated_count,
138 "deprecatedFirstTimestamp" => Field::Key_deprecated_first_timestamp,
139 "deprecatedLastTimestamp" => Field::Key_deprecated_last_timestamp,
140 "deprecatedSource" => Field::Key_deprecated_source,
141 "eventTime" => Field::Key_event_time,
142 "metadata" => Field::Key_metadata,
143 "note" => Field::Key_note,
144 "reason" => Field::Key_reason,
145 "regarding" => Field::Key_regarding,
146 "related" => Field::Key_related,
147 "reportingController" => Field::Key_reporting_controller,
148 "reportingInstance" => Field::Key_reporting_instance,
149 "series" => Field::Key_series,
150 "type" => Field::Key_type_,
151 _ => Field::Other,
152 })
153 }
154 }
155
156 deserializer.deserialize_identifier(Visitor)
157 }
158 }
159
160 struct Visitor;
161
162 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
163 type Value = Event;
164
165 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
166 f.write_str(<Self::Value as crate::Resource>::KIND)
167 }
168
169 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
170 let mut value_action: Option<std::string::String> = None;
171 let mut value_deprecated_count: Option<i32> = None;
172 let mut value_deprecated_first_timestamp: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
173 let mut value_deprecated_last_timestamp: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
174 let mut value_deprecated_source: Option<crate::api::core::v1::EventSource> = None;
175 let mut value_event_time: Option<crate::apimachinery::pkg::apis::meta::v1::MicroTime> = None;
176 let mut value_metadata: Option<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
177 let mut value_note: Option<std::string::String> = None;
178 let mut value_reason: Option<std::string::String> = None;
179 let mut value_regarding: Option<crate::api::core::v1::ObjectReference> = None;
180 let mut value_related: Option<crate::api::core::v1::ObjectReference> = None;
181 let mut value_reporting_controller: Option<std::string::String> = None;
182 let mut value_reporting_instance: Option<std::string::String> = None;
183 let mut value_series: Option<crate::api::events::v1::EventSeries> = None;
184 let mut value_type_: Option<std::string::String> = None;
185
186 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
187 match key {
188 Field::Key_api_version => {
189 let value_api_version: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
190 if value_api_version != <Self::Value as crate::Resource>::API_VERSION {
191 return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_api_version), &<Self::Value as crate::Resource>::API_VERSION));
192 }
193 },
194 Field::Key_kind => {
195 let value_kind: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
196 if value_kind != <Self::Value as crate::Resource>::KIND {
197 return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_kind), &<Self::Value as crate::Resource>::KIND));
198 }
199 },
200 Field::Key_action => value_action = crate::serde::de::MapAccess::next_value(&mut map)?,
201 Field::Key_deprecated_count => value_deprecated_count = crate::serde::de::MapAccess::next_value(&mut map)?,
202 Field::Key_deprecated_first_timestamp => value_deprecated_first_timestamp = crate::serde::de::MapAccess::next_value(&mut map)?,
203 Field::Key_deprecated_last_timestamp => value_deprecated_last_timestamp = crate::serde::de::MapAccess::next_value(&mut map)?,
204 Field::Key_deprecated_source => value_deprecated_source = crate::serde::de::MapAccess::next_value(&mut map)?,
205 Field::Key_event_time => value_event_time = crate::serde::de::MapAccess::next_value(&mut map)?,
206 Field::Key_metadata => value_metadata = crate::serde::de::MapAccess::next_value(&mut map)?,
207 Field::Key_note => value_note = crate::serde::de::MapAccess::next_value(&mut map)?,
208 Field::Key_reason => value_reason = crate::serde::de::MapAccess::next_value(&mut map)?,
209 Field::Key_regarding => value_regarding = crate::serde::de::MapAccess::next_value(&mut map)?,
210 Field::Key_related => value_related = crate::serde::de::MapAccess::next_value(&mut map)?,
211 Field::Key_reporting_controller => value_reporting_controller = crate::serde::de::MapAccess::next_value(&mut map)?,
212 Field::Key_reporting_instance => value_reporting_instance = crate::serde::de::MapAccess::next_value(&mut map)?,
213 Field::Key_series => value_series = crate::serde::de::MapAccess::next_value(&mut map)?,
214 Field::Key_type_ => value_type_ = crate::serde::de::MapAccess::next_value(&mut map)?,
215 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
216 }
217 }
218
219 Ok(Event {
220 action: value_action,
221 deprecated_count: value_deprecated_count,
222 deprecated_first_timestamp: value_deprecated_first_timestamp,
223 deprecated_last_timestamp: value_deprecated_last_timestamp,
224 deprecated_source: value_deprecated_source,
225 event_time: value_event_time,
226 metadata: value_metadata.unwrap_or_default(),
227 note: value_note,
228 reason: value_reason,
229 regarding: value_regarding,
230 related: value_related,
231 reporting_controller: value_reporting_controller,
232 reporting_instance: value_reporting_instance,
233 series: value_series,
234 type_: value_type_,
235 })
236 }
237 }
238
239 deserializer.deserialize_struct(
240 <Self as crate::Resource>::KIND,
241 &[
242 "apiVersion",
243 "kind",
244 "action",
245 "deprecatedCount",
246 "deprecatedFirstTimestamp",
247 "deprecatedLastTimestamp",
248 "deprecatedSource",
249 "eventTime",
250 "metadata",
251 "note",
252 "reason",
253 "regarding",
254 "related",
255 "reportingController",
256 "reportingInstance",
257 "series",
258 "type",
259 ],
260 Visitor,
261 )
262 }
263}
264
265impl crate::serde::Serialize for Event {
266 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
267 let mut state = serializer.serialize_struct(
268 <Self as crate::Resource>::KIND,
269 3 +
270 self.action.as_ref().map_or(0, |_| 1) +
271 self.deprecated_count.as_ref().map_or(0, |_| 1) +
272 self.deprecated_first_timestamp.as_ref().map_or(0, |_| 1) +
273 self.deprecated_last_timestamp.as_ref().map_or(0, |_| 1) +
274 self.deprecated_source.as_ref().map_or(0, |_| 1) +
275 self.event_time.as_ref().map_or(0, |_| 1) +
276 self.note.as_ref().map_or(0, |_| 1) +
277 self.reason.as_ref().map_or(0, |_| 1) +
278 self.regarding.as_ref().map_or(0, |_| 1) +
279 self.related.as_ref().map_or(0, |_| 1) +
280 self.reporting_controller.as_ref().map_or(0, |_| 1) +
281 self.reporting_instance.as_ref().map_or(0, |_| 1) +
282 self.series.as_ref().map_or(0, |_| 1) +
283 self.type_.as_ref().map_or(0, |_| 1),
284 )?;
285 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as crate::Resource>::API_VERSION)?;
286 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as crate::Resource>::KIND)?;
287 if let Some(value) = &self.action {
288 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "action", value)?;
289 }
290 if let Some(value) = &self.deprecated_count {
291 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "deprecatedCount", value)?;
292 }
293 if let Some(value) = &self.deprecated_first_timestamp {
294 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "deprecatedFirstTimestamp", value)?;
295 }
296 if let Some(value) = &self.deprecated_last_timestamp {
297 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "deprecatedLastTimestamp", value)?;
298 }
299 if let Some(value) = &self.deprecated_source {
300 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "deprecatedSource", value)?;
301 }
302 if let Some(value) = &self.event_time {
303 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "eventTime", value)?;
304 }
305 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
306 if let Some(value) = &self.note {
307 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "note", value)?;
308 }
309 if let Some(value) = &self.reason {
310 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "reason", value)?;
311 }
312 if let Some(value) = &self.regarding {
313 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "regarding", value)?;
314 }
315 if let Some(value) = &self.related {
316 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "related", value)?;
317 }
318 if let Some(value) = &self.reporting_controller {
319 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "reportingController", value)?;
320 }
321 if let Some(value) = &self.reporting_instance {
322 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "reportingInstance", value)?;
323 }
324 if let Some(value) = &self.series {
325 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "series", value)?;
326 }
327 if let Some(value) = &self.type_ {
328 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "type", value)?;
329 }
330 crate::serde::ser::SerializeStruct::end(state)
331 }
332}
333
334#[cfg(feature = "schemars")]
335impl crate::schemars::JsonSchema for Event {
336 fn schema_name() -> std::borrow::Cow<'static, str> {
337 "io.k8s.api.events.v1.Event".into()
338 }
339
340 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
341 crate::schemars::json_schema!({
342 "description": "Event is a report of an event somewhere in the cluster. It generally denotes some state change in the system. Events have a limited retention time and triggers and messages may evolve with time. Event consumers should not rely on the timing of an event with a given Reason reflecting a consistent underlying trigger, or the continued existence of events with that Reason. Events should be treated as informative, best-effort, supplemental data.",
343 "type": "object",
344 "properties": {
345 "action": {
346 "description": "action is what action was taken/failed regarding to the regarding object. It is machine-readable. This field cannot be empty for new Events and it can have at most 128 characters.",
347 "type": "string",
348 },
349 "apiVersion": {
350 "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",
351 "type": "string",
352 },
353 "deprecatedCount": {
354 "description": "deprecatedCount is the deprecated field assuring backward compatibility with core.v1 Event type.",
355 "type": "integer",
356 "format": "int32",
357 },
358 "deprecatedFirstTimestamp": ({
359 let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
360 schema_obj.ensure_object().insert("description".into(), "deprecatedFirstTimestamp is the deprecated field assuring backward compatibility with core.v1 Event type.".into());
361 schema_obj
362 }),
363 "deprecatedLastTimestamp": ({
364 let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
365 schema_obj.ensure_object().insert("description".into(), "deprecatedLastTimestamp is the deprecated field assuring backward compatibility with core.v1 Event type.".into());
366 schema_obj
367 }),
368 "deprecatedSource": ({
369 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::EventSource>();
370 schema_obj.ensure_object().insert("description".into(), "deprecatedSource is the deprecated field assuring backward compatibility with core.v1 Event type.".into());
371 schema_obj
372 }),
373 "eventTime": ({
374 let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::MicroTime>();
375 schema_obj.ensure_object().insert("description".into(), "eventTime is the time when this Event was first observed. It is required.".into());
376 schema_obj
377 }),
378 "kind": {
379 "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",
380 "type": "string",
381 },
382 "metadata": ({
383 let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta>();
384 schema_obj.ensure_object().insert("description".into(), "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata".into());
385 schema_obj
386 }),
387 "note": {
388 "description": "note is a human-readable description of the status of this operation. Maximal length of the note is 1kB, but libraries should be prepared to handle values up to 64kB.",
389 "type": "string",
390 },
391 "reason": {
392 "description": "reason is why the action was taken. It is human-readable. This field cannot be empty for new Events and it can have at most 128 characters.",
393 "type": "string",
394 },
395 "regarding": ({
396 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ObjectReference>();
397 schema_obj.ensure_object().insert("description".into(), "regarding contains the object this Event is about. In most cases it's an Object reporting controller implements, e.g. ReplicaSetController implements ReplicaSets and this event is emitted because it acts on some changes in a ReplicaSet object.".into());
398 schema_obj
399 }),
400 "related": ({
401 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ObjectReference>();
402 schema_obj.ensure_object().insert("description".into(), "related is the optional secondary object for more complex actions. E.g. when regarding object triggers a creation or deletion of related object.".into());
403 schema_obj
404 }),
405 "reportingController": {
406 "description": "reportingController is the name of the controller that emitted this Event, e.g. `kubernetes.io/kubelet`. This field cannot be empty for new Events.",
407 "type": "string",
408 },
409 "reportingInstance": {
410 "description": "reportingInstance is the ID of the controller instance, e.g. `kubelet-xyzf`. This field cannot be empty for new Events and it can have at most 128 characters.",
411 "type": "string",
412 },
413 "series": ({
414 let mut schema_obj = __gen.subschema_for::<crate::api::events::v1::EventSeries>();
415 schema_obj.ensure_object().insert("description".into(), "series is data about the Event series this event represents or nil if it's a singleton Event.".into());
416 schema_obj
417 }),
418 "type": {
419 "description": "type is the type of this event (Normal, Warning), new types could be added in the future. It is machine-readable. This field cannot be empty for new Events.",
420 "type": "string",
421 },
422 },
423 "required": [
424 "metadata",
425 ],
426 })
427 }
428}