k8s_openapi/v1_30/apimachinery/pkg/apis/meta/v1/
status_details.rs

1// Generated from definition io.k8s.apimachinery.pkg.apis.meta.v1.StatusDetails
2
3/// StatusDetails is a set of additional properties that MAY be set by the server to provide additional information about a response. The Reason field of a Status object defines what attributes will be set. Clients must ignore fields that do not match the defined type of each attribute, and should assume that any attribute may be empty, invalid, or under defined.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct StatusDetails {
6    /// The Causes array includes more details associated with the StatusReason failure. Not all StatusReasons may provide detailed causes.
7    pub causes: Option<Vec<crate::apimachinery::pkg::apis::meta::v1::StatusCause>>,
8
9    /// The group attribute of the resource associated with the status StatusReason.
10    pub group: Option<String>,
11
12    /// The kind attribute of the resource associated with the status StatusReason. On some operations may differ from the requested resource Kind. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
13    pub kind: Option<String>,
14
15    /// The name attribute of the resource associated with the status StatusReason (when there is a single name which can be described).
16    pub name: Option<String>,
17
18    /// If specified, the time in seconds before the operation should be retried. Some errors may indicate the client must take an alternate action - for those errors this field may indicate how long to wait before taking the alternate action.
19    pub retry_after_seconds: Option<i32>,
20
21    /// UID of the resource. (when there is a single resource which can be described). More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids
22    pub uid: Option<String>,
23}
24
25impl crate::DeepMerge for StatusDetails {
26    fn merge_from(&mut self, other: Self) {
27        crate::merge_strategies::list::atomic(&mut self.causes, other.causes);
28        crate::DeepMerge::merge_from(&mut self.group, other.group);
29        crate::DeepMerge::merge_from(&mut self.kind, other.kind);
30        crate::DeepMerge::merge_from(&mut self.name, other.name);
31        crate::DeepMerge::merge_from(&mut self.retry_after_seconds, other.retry_after_seconds);
32        crate::DeepMerge::merge_from(&mut self.uid, other.uid);
33    }
34}
35
36impl<'de> crate::serde::Deserialize<'de> for StatusDetails {
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_causes,
41            Key_group,
42            Key_kind,
43            Key_name,
44            Key_retry_after_seconds,
45            Key_uid,
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<'de> crate::serde::de::Visitor<'de> for Visitor {
54                    type Value = Field;
55
56                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::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                            "causes" => Field::Key_causes,
63                            "group" => Field::Key_group,
64                            "kind" => Field::Key_kind,
65                            "name" => Field::Key_name,
66                            "retryAfterSeconds" => Field::Key_retry_after_seconds,
67                            "uid" => Field::Key_uid,
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 = StatusDetails;
81
82            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
83                f.write_str("StatusDetails")
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_causes: Option<Vec<crate::apimachinery::pkg::apis::meta::v1::StatusCause>> = None;
88                let mut value_group: Option<String> = None;
89                let mut value_kind: Option<String> = None;
90                let mut value_name: Option<String> = None;
91                let mut value_retry_after_seconds: Option<i32> = None;
92                let mut value_uid: Option<String> = None;
93
94                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
95                    match key {
96                        Field::Key_causes => value_causes = crate::serde::de::MapAccess::next_value(&mut map)?,
97                        Field::Key_group => value_group = crate::serde::de::MapAccess::next_value(&mut map)?,
98                        Field::Key_kind => value_kind = 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_retry_after_seconds => value_retry_after_seconds = crate::serde::de::MapAccess::next_value(&mut map)?,
101                        Field::Key_uid => value_uid = 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(StatusDetails {
107                    causes: value_causes,
108                    group: value_group,
109                    kind: value_kind,
110                    name: value_name,
111                    retry_after_seconds: value_retry_after_seconds,
112                    uid: value_uid,
113                })
114            }
115        }
116
117        deserializer.deserialize_struct(
118            "StatusDetails",
119            &[
120                "causes",
121                "group",
122                "kind",
123                "name",
124                "retryAfterSeconds",
125                "uid",
126            ],
127            Visitor,
128        )
129    }
130}
131
132impl crate::serde::Serialize for StatusDetails {
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            "StatusDetails",
136            self.causes.as_ref().map_or(0, |_| 1) +
137            self.group.as_ref().map_or(0, |_| 1) +
138            self.kind.as_ref().map_or(0, |_| 1) +
139            self.name.as_ref().map_or(0, |_| 1) +
140            self.retry_after_seconds.as_ref().map_or(0, |_| 1) +
141            self.uid.as_ref().map_or(0, |_| 1),
142        )?;
143        if let Some(value) = &self.causes {
144            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "causes", value)?;
145        }
146        if let Some(value) = &self.group {
147            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "group", value)?;
148        }
149        if let Some(value) = &self.kind {
150            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", value)?;
151        }
152        if let Some(value) = &self.name {
153            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", value)?;
154        }
155        if let Some(value) = &self.retry_after_seconds {
156            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "retryAfterSeconds", value)?;
157        }
158        if let Some(value) = &self.uid {
159            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "uid", value)?;
160        }
161        crate::serde::ser::SerializeStruct::end(state)
162    }
163}
164
165#[cfg(feature = "schemars")]
166impl crate::schemars::JsonSchema for StatusDetails {
167    fn schema_name() -> String {
168        "io.k8s.apimachinery.pkg.apis.meta.v1.StatusDetails".to_owned()
169    }
170
171    fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
172        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
173            metadata: Some(Box::new(crate::schemars::schema::Metadata {
174                description: Some("StatusDetails is a set of additional properties that MAY be set by the server to provide additional information about a response. The Reason field of a Status object defines what attributes will be set. Clients must ignore fields that do not match the defined type of each attribute, and should assume that any attribute may be empty, invalid, or under defined.".to_owned()),
175                ..Default::default()
176            })),
177            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
178            object: Some(Box::new(crate::schemars::schema::ObjectValidation {
179                properties: [
180                    (
181                        "causes".to_owned(),
182                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
183                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
184                                description: Some("The Causes array includes more details associated with the StatusReason failure. Not all StatusReasons may provide detailed causes.".to_owned()),
185                                ..Default::default()
186                            })),
187                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Array))),
188                            array: Some(Box::new(crate::schemars::schema::ArrayValidation {
189                                items: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(__gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::StatusCause>()))),
190                                ..Default::default()
191                            })),
192                            ..Default::default()
193                        }),
194                    ),
195                    (
196                        "group".to_owned(),
197                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
198                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
199                                description: Some("The group attribute of the resource associated with the status StatusReason.".to_owned()),
200                                ..Default::default()
201                            })),
202                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
203                            ..Default::default()
204                        }),
205                    ),
206                    (
207                        "kind".to_owned(),
208                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
209                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
210                                description: Some("The kind attribute of the resource associated with the status StatusReason. On some operations may differ from the requested resource Kind. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds".to_owned()),
211                                ..Default::default()
212                            })),
213                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
214                            ..Default::default()
215                        }),
216                    ),
217                    (
218                        "name".to_owned(),
219                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
220                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
221                                description: Some("The name attribute of the resource associated with the status StatusReason (when there is a single name which can be described).".to_owned()),
222                                ..Default::default()
223                            })),
224                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
225                            ..Default::default()
226                        }),
227                    ),
228                    (
229                        "retryAfterSeconds".to_owned(),
230                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
231                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
232                                description: Some("If specified, the time in seconds before the operation should be retried. Some errors may indicate the client must take an alternate action - for those errors this field may indicate how long to wait before taking the alternate action.".to_owned()),
233                                ..Default::default()
234                            })),
235                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
236                            format: Some("int32".to_owned()),
237                            ..Default::default()
238                        }),
239                    ),
240                    (
241                        "uid".to_owned(),
242                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
243                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
244                                description: Some("UID of the resource. (when there is a single resource which can be described). More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids".to_owned()),
245                                ..Default::default()
246                            })),
247                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
248                            ..Default::default()
249                        }),
250                    ),
251                ].into(),
252                ..Default::default()
253            })),
254            ..Default::default()
255        })
256    }
257}