Skip to main content

k8s_openapi/v1_37/api/lifecycle/v1alpha1/
responder_status.rs

1// Generated from definition io.k8s.api.lifecycle.v1alpha1.ResponderStatus
2
3/// ResponderStatus represents the last observed status of the eviction process of the responder. It should be only updated by the designated responder whose name is .name field.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct ResponderStatus {
6    /// completionTime tracks the time at which the Responder stopped processing the eviction request. Completion means that the responders has either fully or partially completed the eviction process, which may have resulted in target eviction (e.g. pod termination). It should reflect the present time when set. This field becomes immutable once set.
7    pub completion_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
8
9    /// expectedCompletionTime is the time at which the eviction process step is expected to end for the responder. The time cannot be set to the past. May be omitted if no estimate can be made.
10    pub expected_completion_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
11
12    /// heartbeatTime is the last time at which the eviction process was reported to be in progress by the responder. It should reflect the present time when set. Responders should avoid heartbeats more frequent than 20 seconds to avoid overloading the control-plane.
13    pub heartbeat_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
14
15    /// message provides human-readable details about the state of the responder and the eviction process. Maximum length is 4000 characters.
16    pub message: Option<std::string::String>,
17
18    /// name allows you to identify the responder reacting to the Eviction.
19    ///
20    /// It must be a valid domain-prefixed key (such as "acme.io/foo"). This field is initialized by Kubernetes and must be unique for each responder. This field is required.
21    pub name: std::string::String,
22
23    /// startTime tracks the time at which this responder was designated as active and should start processing the eviction request. It should reflect the present time when set. This field is initialized by Kubernetes when this responder becomes active. This field becomes immutable once set.
24    pub start_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
25}
26
27impl crate::DeepMerge for ResponderStatus {
28    fn merge_from(&mut self, other: Self) {
29        crate::DeepMerge::merge_from(&mut self.completion_time, other.completion_time);
30        crate::DeepMerge::merge_from(&mut self.expected_completion_time, other.expected_completion_time);
31        crate::DeepMerge::merge_from(&mut self.heartbeat_time, other.heartbeat_time);
32        crate::DeepMerge::merge_from(&mut self.message, other.message);
33        crate::DeepMerge::merge_from(&mut self.name, other.name);
34        crate::DeepMerge::merge_from(&mut self.start_time, other.start_time);
35    }
36}
37
38impl<'de> crate::serde::Deserialize<'de> for ResponderStatus {
39    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
40        #[allow(non_camel_case_types)]
41        enum Field {
42            Key_completion_time,
43            Key_expected_completion_time,
44            Key_heartbeat_time,
45            Key_message,
46            Key_name,
47            Key_start_time,
48            Other,
49        }
50
51        impl<'de> crate::serde::Deserialize<'de> for Field {
52            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
53                struct Visitor;
54
55                impl crate::serde::de::Visitor<'_> for Visitor {
56                    type Value = Field;
57
58                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
59                        f.write_str("field identifier")
60                    }
61
62                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
63                        Ok(match v {
64                            "completionTime" => Field::Key_completion_time,
65                            "expectedCompletionTime" => Field::Key_expected_completion_time,
66                            "heartbeatTime" => Field::Key_heartbeat_time,
67                            "message" => Field::Key_message,
68                            "name" => Field::Key_name,
69                            "startTime" => Field::Key_start_time,
70                            _ => Field::Other,
71                        })
72                    }
73                }
74
75                deserializer.deserialize_identifier(Visitor)
76            }
77        }
78
79        struct Visitor;
80
81        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
82            type Value = ResponderStatus;
83
84            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
85                f.write_str("ResponderStatus")
86            }
87
88            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
89                let mut value_completion_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
90                let mut value_expected_completion_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
91                let mut value_heartbeat_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
92                let mut value_message: Option<std::string::String> = None;
93                let mut value_name: Option<std::string::String> = None;
94                let mut value_start_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
95
96                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
97                    match key {
98                        Field::Key_completion_time => value_completion_time = crate::serde::de::MapAccess::next_value(&mut map)?,
99                        Field::Key_expected_completion_time => value_expected_completion_time = crate::serde::de::MapAccess::next_value(&mut map)?,
100                        Field::Key_heartbeat_time => value_heartbeat_time = crate::serde::de::MapAccess::next_value(&mut map)?,
101                        Field::Key_message => value_message = crate::serde::de::MapAccess::next_value(&mut map)?,
102                        Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
103                        Field::Key_start_time => value_start_time = crate::serde::de::MapAccess::next_value(&mut map)?,
104                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
105                    }
106                }
107
108                Ok(ResponderStatus {
109                    completion_time: value_completion_time,
110                    expected_completion_time: value_expected_completion_time,
111                    heartbeat_time: value_heartbeat_time,
112                    message: value_message,
113                    name: value_name.unwrap_or_default(),
114                    start_time: value_start_time,
115                })
116            }
117        }
118
119        deserializer.deserialize_struct(
120            "ResponderStatus",
121            &[
122                "completionTime",
123                "expectedCompletionTime",
124                "heartbeatTime",
125                "message",
126                "name",
127                "startTime",
128            ],
129            Visitor,
130        )
131    }
132}
133
134impl crate::serde::Serialize for ResponderStatus {
135    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
136        let mut state = serializer.serialize_struct(
137            "ResponderStatus",
138            1 +
139            self.completion_time.as_ref().map_or(0, |_| 1) +
140            self.expected_completion_time.as_ref().map_or(0, |_| 1) +
141            self.heartbeat_time.as_ref().map_or(0, |_| 1) +
142            self.message.as_ref().map_or(0, |_| 1) +
143            self.start_time.as_ref().map_or(0, |_| 1),
144        )?;
145        if let Some(value) = &self.completion_time {
146            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "completionTime", value)?;
147        }
148        if let Some(value) = &self.expected_completion_time {
149            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "expectedCompletionTime", value)?;
150        }
151        if let Some(value) = &self.heartbeat_time {
152            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "heartbeatTime", value)?;
153        }
154        if let Some(value) = &self.message {
155            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "message", value)?;
156        }
157        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
158        if let Some(value) = &self.start_time {
159            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "startTime", value)?;
160        }
161        crate::serde::ser::SerializeStruct::end(state)
162    }
163}
164
165#[cfg(feature = "schemars")]
166impl crate::schemars::JsonSchema for ResponderStatus {
167    fn schema_name() -> std::borrow::Cow<'static, str> {
168        "io.k8s.api.lifecycle.v1alpha1.ResponderStatus".into()
169    }
170
171    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
172        crate::schemars::json_schema!({
173            "description": "ResponderStatus represents the last observed status of the eviction process of the responder. It should be only updated by the designated responder whose name is .name field.",
174            "type": "object",
175            "properties": {
176                "completionTime": ({
177                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
178                    schema_obj.ensure_object().insert("description".into(), "completionTime tracks the time at which the Responder stopped processing the eviction request. Completion means that the responders has either fully or partially completed the eviction process, which may have resulted in target eviction (e.g. pod termination). It should reflect the present time when set. This field becomes immutable once set.".into());
179                    schema_obj
180                }),
181                "expectedCompletionTime": ({
182                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
183                    schema_obj.ensure_object().insert("description".into(), "expectedCompletionTime is the time at which the eviction process step is expected to end for the responder. The time cannot be set to the past. May be omitted if no estimate can be made.".into());
184                    schema_obj
185                }),
186                "heartbeatTime": ({
187                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
188                    schema_obj.ensure_object().insert("description".into(), "heartbeatTime is the last time at which the eviction process was reported to be in progress by the responder. It should reflect the present time when set. Responders should avoid heartbeats more frequent than 20 seconds to avoid overloading the control-plane.".into());
189                    schema_obj
190                }),
191                "message": {
192                    "description": "message provides human-readable details about the state of the responder and the eviction process. Maximum length is 4000 characters.",
193                    "type": "string",
194                },
195                "name": {
196                    "description": "name allows you to identify the responder reacting to the Eviction.\n\nIt must be a valid domain-prefixed key (such as \"acme.io/foo\"). This field is initialized by Kubernetes and must be unique for each responder. This field is required.",
197                    "type": "string",
198                },
199                "startTime": ({
200                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
201                    schema_obj.ensure_object().insert("description".into(), "startTime tracks the time at which this responder was designated as active and should start processing the eviction request. It should reflect the present time when set. This field is initialized by Kubernetes when this responder becomes active. This field becomes immutable once set.".into());
202                    schema_obj
203                }),
204            },
205            "required": [
206                "name",
207            ],
208        })
209    }
210}