k8s_openapi/v1_34/api/core/v1/
event.rs

1// Generated from definition io.k8s.api.core.v1.Event
2
3/// Event is a report of an event somewhere in the cluster.  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.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct Event {
6    /// What action was taken/failed regarding to the Regarding object.
7    pub action: Option<std::string::String>,
8
9    /// The number of times this event has occurred.
10    pub count: Option<i32>,
11
12    /// Time when this Event was first observed.
13    pub event_time: Option<crate::apimachinery::pkg::apis::meta::v1::MicroTime>,
14
15    /// The time at which the event was first recorded. (Time of server receipt is in TypeMeta.)
16    pub first_timestamp: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
17
18    /// The object that this event is about.
19    pub involved_object: crate::api::core::v1::ObjectReference,
20
21    /// The time at which the most recent occurrence of this event was recorded.
22    pub last_timestamp: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
23
24    /// A human-readable description of the status of this operation.
25    pub message: Option<std::string::String>,
26
27    /// Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
28    pub metadata: crate::apimachinery::pkg::apis::meta::v1::ObjectMeta,
29
30    /// This should be a short, machine understandable string that gives the reason for the transition into the object's current status.
31    pub reason: Option<std::string::String>,
32
33    /// Optional secondary object for more complex actions.
34    pub related: Option<crate::api::core::v1::ObjectReference>,
35
36    /// Name of the controller that emitted this Event, e.g. `kubernetes.io/kubelet`.
37    pub reporting_component: Option<std::string::String>,
38
39    /// ID of the controller instance, e.g. `kubelet-xyzf`.
40    pub reporting_instance: Option<std::string::String>,
41
42    /// Data about the Event series this event represents or nil if it's a singleton Event.
43    pub series: Option<crate::api::core::v1::EventSeries>,
44
45    /// The component reporting this event. Should be a short machine understandable string.
46    pub source: Option<crate::api::core::v1::EventSource>,
47
48    /// Type of this event (Normal, Warning), new types could be added in the future
49    pub type_: Option<std::string::String>,
50}
51
52impl crate::Resource for Event {
53    const API_VERSION: &'static str = "v1";
54    const GROUP: &'static str = "";
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.count, other.count);
81        crate::DeepMerge::merge_from(&mut self.event_time, other.event_time);
82        crate::DeepMerge::merge_from(&mut self.first_timestamp, other.first_timestamp);
83        crate::DeepMerge::merge_from(&mut self.involved_object, other.involved_object);
84        crate::DeepMerge::merge_from(&mut self.last_timestamp, other.last_timestamp);
85        crate::DeepMerge::merge_from(&mut self.message, other.message);
86        crate::DeepMerge::merge_from(&mut self.metadata, other.metadata);
87        crate::DeepMerge::merge_from(&mut self.reason, other.reason);
88        crate::DeepMerge::merge_from(&mut self.related, other.related);
89        crate::DeepMerge::merge_from(&mut self.reporting_component, other.reporting_component);
90        crate::DeepMerge::merge_from(&mut self.reporting_instance, other.reporting_instance);
91        crate::DeepMerge::merge_from(&mut self.series, other.series);
92        crate::DeepMerge::merge_from(&mut self.source, other.source);
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_count,
105            Key_event_time,
106            Key_first_timestamp,
107            Key_involved_object,
108            Key_last_timestamp,
109            Key_message,
110            Key_metadata,
111            Key_reason,
112            Key_related,
113            Key_reporting_component,
114            Key_reporting_instance,
115            Key_series,
116            Key_source,
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                            "count" => Field::Key_count,
138                            "eventTime" => Field::Key_event_time,
139                            "firstTimestamp" => Field::Key_first_timestamp,
140                            "involvedObject" => Field::Key_involved_object,
141                            "lastTimestamp" => Field::Key_last_timestamp,
142                            "message" => Field::Key_message,
143                            "metadata" => Field::Key_metadata,
144                            "reason" => Field::Key_reason,
145                            "related" => Field::Key_related,
146                            "reportingComponent" => Field::Key_reporting_component,
147                            "reportingInstance" => Field::Key_reporting_instance,
148                            "series" => Field::Key_series,
149                            "source" => Field::Key_source,
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_count: Option<i32> = None;
172                let mut value_event_time: Option<crate::apimachinery::pkg::apis::meta::v1::MicroTime> = None;
173                let mut value_first_timestamp: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
174                let mut value_involved_object: Option<crate::api::core::v1::ObjectReference> = None;
175                let mut value_last_timestamp: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
176                let mut value_message: Option<std::string::String> = None;
177                let mut value_metadata: Option<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
178                let mut value_reason: Option<std::string::String> = None;
179                let mut value_related: Option<crate::api::core::v1::ObjectReference> = None;
180                let mut value_reporting_component: Option<std::string::String> = None;
181                let mut value_reporting_instance: Option<std::string::String> = None;
182                let mut value_series: Option<crate::api::core::v1::EventSeries> = None;
183                let mut value_source: Option<crate::api::core::v1::EventSource> = 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_count => value_count = crate::serde::de::MapAccess::next_value(&mut map)?,
202                        Field::Key_event_time => value_event_time = crate::serde::de::MapAccess::next_value(&mut map)?,
203                        Field::Key_first_timestamp => value_first_timestamp = crate::serde::de::MapAccess::next_value(&mut map)?,
204                        Field::Key_involved_object => value_involved_object = crate::serde::de::MapAccess::next_value(&mut map)?,
205                        Field::Key_last_timestamp => value_last_timestamp = crate::serde::de::MapAccess::next_value(&mut map)?,
206                        Field::Key_message => value_message = crate::serde::de::MapAccess::next_value(&mut map)?,
207                        Field::Key_metadata => value_metadata = 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_related => value_related = crate::serde::de::MapAccess::next_value(&mut map)?,
210                        Field::Key_reporting_component => value_reporting_component = crate::serde::de::MapAccess::next_value(&mut map)?,
211                        Field::Key_reporting_instance => value_reporting_instance = crate::serde::de::MapAccess::next_value(&mut map)?,
212                        Field::Key_series => value_series = crate::serde::de::MapAccess::next_value(&mut map)?,
213                        Field::Key_source => value_source = 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                    count: value_count,
222                    event_time: value_event_time,
223                    first_timestamp: value_first_timestamp,
224                    involved_object: value_involved_object.unwrap_or_default(),
225                    last_timestamp: value_last_timestamp,
226                    message: value_message,
227                    metadata: value_metadata.unwrap_or_default(),
228                    reason: value_reason,
229                    related: value_related,
230                    reporting_component: value_reporting_component,
231                    reporting_instance: value_reporting_instance,
232                    series: value_series,
233                    source: value_source,
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                "count",
246                "eventTime",
247                "firstTimestamp",
248                "involvedObject",
249                "lastTimestamp",
250                "message",
251                "metadata",
252                "reason",
253                "related",
254                "reportingComponent",
255                "reportingInstance",
256                "series",
257                "source",
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            4 +
270            self.action.as_ref().map_or(0, |_| 1) +
271            self.count.as_ref().map_or(0, |_| 1) +
272            self.event_time.as_ref().map_or(0, |_| 1) +
273            self.first_timestamp.as_ref().map_or(0, |_| 1) +
274            self.last_timestamp.as_ref().map_or(0, |_| 1) +
275            self.message.as_ref().map_or(0, |_| 1) +
276            self.reason.as_ref().map_or(0, |_| 1) +
277            self.related.as_ref().map_or(0, |_| 1) +
278            self.reporting_component.as_ref().map_or(0, |_| 1) +
279            self.reporting_instance.as_ref().map_or(0, |_| 1) +
280            self.series.as_ref().map_or(0, |_| 1) +
281            self.source.as_ref().map_or(0, |_| 1) +
282            self.type_.as_ref().map_or(0, |_| 1),
283        )?;
284        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as crate::Resource>::API_VERSION)?;
285        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as crate::Resource>::KIND)?;
286        if let Some(value) = &self.action {
287            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "action", value)?;
288        }
289        if let Some(value) = &self.count {
290            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "count", value)?;
291        }
292        if let Some(value) = &self.event_time {
293            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "eventTime", value)?;
294        }
295        if let Some(value) = &self.first_timestamp {
296            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "firstTimestamp", value)?;
297        }
298        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "involvedObject", &self.involved_object)?;
299        if let Some(value) = &self.last_timestamp {
300            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "lastTimestamp", value)?;
301        }
302        if let Some(value) = &self.message {
303            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "message", value)?;
304        }
305        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
306        if let Some(value) = &self.reason {
307            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "reason", value)?;
308        }
309        if let Some(value) = &self.related {
310            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "related", value)?;
311        }
312        if let Some(value) = &self.reporting_component {
313            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "reportingComponent", value)?;
314        }
315        if let Some(value) = &self.reporting_instance {
316            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "reportingInstance", value)?;
317        }
318        if let Some(value) = &self.series {
319            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "series", value)?;
320        }
321        if let Some(value) = &self.source {
322            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "source", value)?;
323        }
324        if let Some(value) = &self.type_ {
325            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "type", value)?;
326        }
327        crate::serde::ser::SerializeStruct::end(state)
328    }
329}
330
331#[cfg(feature = "schemars")]
332impl crate::schemars::JsonSchema for Event {
333    fn schema_name() -> std::borrow::Cow<'static, str> {
334        "io.k8s.api.core.v1.Event".into()
335    }
336
337    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
338        crate::schemars::json_schema!({
339            "description": "Event is a report of an event somewhere in the cluster.  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.",
340            "type": "object",
341            "properties": {
342                "action": {
343                    "description": "What action was taken/failed regarding to the Regarding object.",
344                    "type": "string",
345                },
346                "apiVersion": {
347                    "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",
348                    "type": "string",
349                },
350                "count": {
351                    "description": "The number of times this event has occurred.",
352                    "type": "integer",
353                    "format": "int32",
354                },
355                "eventTime": ({
356                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::MicroTime>();
357                    schema_obj.ensure_object().insert("description".into(), "Time when this Event was first observed.".into());
358                    schema_obj
359                }),
360                "firstTimestamp": ({
361                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
362                    schema_obj.ensure_object().insert("description".into(), "The time at which the event was first recorded. (Time of server receipt is in TypeMeta.)".into());
363                    schema_obj
364                }),
365                "involvedObject": ({
366                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ObjectReference>();
367                    schema_obj.ensure_object().insert("description".into(), "The object that this event is about.".into());
368                    schema_obj
369                }),
370                "kind": {
371                    "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",
372                    "type": "string",
373                },
374                "lastTimestamp": ({
375                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
376                    schema_obj.ensure_object().insert("description".into(), "The time at which the most recent occurrence of this event was recorded.".into());
377                    schema_obj
378                }),
379                "message": {
380                    "description": "A human-readable description of the status of this operation.",
381                    "type": "string",
382                },
383                "metadata": ({
384                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta>();
385                    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());
386                    schema_obj
387                }),
388                "reason": {
389                    "description": "This should be a short, machine understandable string that gives the reason for the transition into the object's current status.",
390                    "type": "string",
391                },
392                "related": ({
393                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ObjectReference>();
394                    schema_obj.ensure_object().insert("description".into(), "Optional secondary object for more complex actions.".into());
395                    schema_obj
396                }),
397                "reportingComponent": {
398                    "description": "Name of the controller that emitted this Event, e.g. `kubernetes.io/kubelet`.",
399                    "type": "string",
400                },
401                "reportingInstance": {
402                    "description": "ID of the controller instance, e.g. `kubelet-xyzf`.",
403                    "type": "string",
404                },
405                "series": ({
406                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::EventSeries>();
407                    schema_obj.ensure_object().insert("description".into(), "Data about the Event series this event represents or nil if it's a singleton Event.".into());
408                    schema_obj
409                }),
410                "source": ({
411                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::EventSource>();
412                    schema_obj.ensure_object().insert("description".into(), "The component reporting this event. Should be a short machine understandable string.".into());
413                    schema_obj
414                }),
415                "type": {
416                    "description": "Type of this event (Normal, Warning), new types could be added in the future",
417                    "type": "string",
418                },
419            },
420            "required": [
421                "involvedObject",
422                "metadata",
423            ],
424        })
425    }
426}