1// Generated from definition io.k8s.apimachinery.pkg.apis.meta.v1.StatusCause
23/// StatusCause provides more information about an api.Status failure, including cases when multiple errors are encountered.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct StatusCause {
6/// The field of the resource that has caused this error, as named by its JSON serialization. May include dot and postfix notation for nested attributes. Arrays are zero-indexed. Fields may appear more than once in an array of causes due to fields having multiple errors. Optional.
7 ///
8 /// Examples:
9 /// "name" - the field "name" on the current resource
10 /// "items\[0\].name" - the field "name" on the first array entry in "items"
11pub field: Option<String>,
1213/// A human-readable description of the cause of the error. This field may be presented as-is to a reader.
14pub message: Option<String>,
1516/// A machine-readable description of the cause of the error. If this value is empty there is no information available.
17pub reason: Option<String>,
18}
1920impl crate::DeepMerge for StatusCause {
21fn merge_from(&mut self, other: Self) {
22crate::DeepMerge::merge_from(&mut self.field, other.field);
23crate::DeepMerge::merge_from(&mut self.message, other.message);
24crate::DeepMerge::merge_from(&mut self.reason, other.reason);
25 }
26}
2728impl<'de> crate::serde::Deserialize<'de> for StatusCause {
29fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
30#[allow(non_camel_case_types)]
31enum Field {
32 Key_field,
33 Key_message,
34 Key_reason,
35 Other,
36 }
3738impl<'de> crate::serde::Deserialize<'de> for Field {
39fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
40struct Visitor;
4142impl<'de> crate::serde::de::Visitor<'de> for Visitor {
43type Value = Field;
4445fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
46 f.write_str("field identifier")
47 }
4849fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
50Ok(match v {
51"field" => Field::Key_field,
52"message" => Field::Key_message,
53"reason" => Field::Key_reason,
54_ => Field::Other,
55 })
56 }
57 }
5859 deserializer.deserialize_identifier(Visitor)
60 }
61 }
6263struct Visitor;
6465impl<'de> crate::serde::de::Visitor<'de> for Visitor {
66type Value = StatusCause;
6768fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
69 f.write_str("StatusCause")
70 }
7172fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
73let mut value_field: Option<String> = None;
74let mut value_message: Option<String> = None;
75let mut value_reason: Option<String> = None;
7677while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
78match key {
79 Field::Key_field => value_field = crate::serde::de::MapAccess::next_value(&mut map)?,
80 Field::Key_message => value_message = crate::serde::de::MapAccess::next_value(&mut map)?,
81 Field::Key_reason => value_reason = crate::serde::de::MapAccess::next_value(&mut map)?,
82 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
83 }
84 }
8586Ok(StatusCause {
87 field: value_field,
88 message: value_message,
89 reason: value_reason,
90 })
91 }
92 }
9394 deserializer.deserialize_struct(
95"StatusCause",
96&[
97"field",
98"message",
99"reason",
100 ],
101 Visitor,
102 )
103 }
104}
105106impl crate::serde::Serialize for StatusCause {
107fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
108let mut state = serializer.serialize_struct(
109"StatusCause",
110self.field.as_ref().map_or(0, |_| 1) +
111self.message.as_ref().map_or(0, |_| 1) +
112self.reason.as_ref().map_or(0, |_| 1),
113 )?;
114if let Some(value) = &self.field {
115crate::serde::ser::SerializeStruct::serialize_field(&mut state, "field", value)?;
116 }
117if let Some(value) = &self.message {
118crate::serde::ser::SerializeStruct::serialize_field(&mut state, "message", value)?;
119 }
120if let Some(value) = &self.reason {
121crate::serde::ser::SerializeStruct::serialize_field(&mut state, "reason", value)?;
122 }
123crate::serde::ser::SerializeStruct::end(state)
124 }
125}
126127#[cfg(feature = "schemars")]
128impl crate::schemars::JsonSchema for StatusCause {
129fn schema_name() -> String {
130"io.k8s.apimachinery.pkg.apis.meta.v1.StatusCause".to_owned()
131 }
132133fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
134crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
135 metadata: Some(Box::new(crate::schemars::schema::Metadata {
136 description: Some("StatusCause provides more information about an api.Status failure, including cases when multiple errors are encountered.".to_owned()),
137 ..Default::default()
138 })),
139 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
140 object: Some(Box::new(crate::schemars::schema::ObjectValidation {
141 properties: [
142 (
143"field".to_owned(),
144crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
145 metadata: Some(Box::new(crate::schemars::schema::Metadata {
146 description: Some("The field of the resource that has caused this error, as named by its JSON serialization. May include dot and postfix notation for nested attributes. Arrays are zero-indexed. Fields may appear more than once in an array of causes due to fields having multiple errors. Optional.\n\nExamples:\n \"name\" - the field \"name\" on the current resource\n \"items[0].name\" - the field \"name\" on the first array entry in \"items\"".to_owned()),
147 ..Default::default()
148 })),
149 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
150 ..Default::default()
151 }),
152 ),
153 (
154"message".to_owned(),
155crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
156 metadata: Some(Box::new(crate::schemars::schema::Metadata {
157 description: Some("A human-readable description of the cause of the error. This field may be presented as-is to a reader.".to_owned()),
158 ..Default::default()
159 })),
160 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
161 ..Default::default()
162 }),
163 ),
164 (
165"reason".to_owned(),
166crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
167 metadata: Some(Box::new(crate::schemars::schema::Metadata {
168 description: Some("A machine-readable description of the cause of the error. If this value is empty there is no information available.".to_owned()),
169 ..Default::default()
170 })),
171 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
172 ..Default::default()
173 }),
174 ),
175 ].into(),
176 ..Default::default()
177 })),
178 ..Default::default()
179 })
180 }
181}