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

1// Generated from definition io.k8s.apimachinery.pkg.apis.meta.v1.Status
2
3/// Status is a return value for calls that don't return other objects.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct Status {
6    /// Suggested HTTP return code for this status, 0 if not set.
7    pub code: Option<i32>,
8
9    /// Extended data associated with the reason.  Each reason may define its own extended details. This field is optional and the data returned is not guaranteed to conform to any schema except that defined by the reason type.
10    pub details: Option<crate::apimachinery::pkg::apis::meta::v1::StatusDetails>,
11
12    /// A human-readable description of the status of this operation.
13    pub message: Option<String>,
14
15    /// Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
16    pub metadata: crate::apimachinery::pkg::apis::meta::v1::ListMeta,
17
18    /// A machine-readable description of why this operation is in the "Failure" status. If this value is empty there is no information available. A Reason clarifies an HTTP status code but does not override it.
19    pub reason: Option<String>,
20
21    /// Status of the operation. One of: "Success" or "Failure". More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
22    pub status: Option<String>,
23}
24
25impl crate::Resource for Status {
26    const API_VERSION: &'static str = "v1";
27    const GROUP: &'static str = "";
28    const KIND: &'static str = "Status";
29    const VERSION: &'static str = "v1";
30    const URL_PATH_SEGMENT: &'static str = "status";
31    type Scope = crate::SubResourceScope;
32}
33
34impl crate::Metadata for Status {
35    type Ty = crate::apimachinery::pkg::apis::meta::v1::ListMeta;
36
37    fn metadata(&self) -> &<Self as crate::Metadata>::Ty {
38        &self.metadata
39    }
40
41    fn metadata_mut(&mut self) -> &mut<Self as crate::Metadata>::Ty {
42        &mut self.metadata
43    }
44}
45
46impl crate::DeepMerge for Status {
47    fn merge_from(&mut self, other: Self) {
48        crate::DeepMerge::merge_from(&mut self.code, other.code);
49        crate::DeepMerge::merge_from(&mut self.details, other.details);
50        crate::DeepMerge::merge_from(&mut self.message, other.message);
51        crate::DeepMerge::merge_from(&mut self.metadata, other.metadata);
52        crate::DeepMerge::merge_from(&mut self.reason, other.reason);
53        crate::DeepMerge::merge_from(&mut self.status, other.status);
54    }
55}
56
57impl<'de> crate::serde::Deserialize<'de> for Status {
58    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
59        #[allow(non_camel_case_types)]
60        enum Field {
61            Key_api_version,
62            Key_kind,
63            Key_code,
64            Key_details,
65            Key_message,
66            Key_metadata,
67            Key_reason,
68            Key_status,
69            Other,
70        }
71
72        impl<'de> crate::serde::Deserialize<'de> for Field {
73            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
74                struct Visitor;
75
76                impl<'de> crate::serde::de::Visitor<'de> for Visitor {
77                    type Value = Field;
78
79                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
80                        f.write_str("field identifier")
81                    }
82
83                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
84                        Ok(match v {
85                            "apiVersion" => Field::Key_api_version,
86                            "kind" => Field::Key_kind,
87                            "code" => Field::Key_code,
88                            "details" => Field::Key_details,
89                            "message" => Field::Key_message,
90                            "metadata" => Field::Key_metadata,
91                            "reason" => Field::Key_reason,
92                            "status" => Field::Key_status,
93                            _ => Field::Other,
94                        })
95                    }
96                }
97
98                deserializer.deserialize_identifier(Visitor)
99            }
100        }
101
102        struct Visitor;
103
104        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
105            type Value = Status;
106
107            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
108                f.write_str(<Self::Value as crate::Resource>::KIND)
109            }
110
111            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
112                let mut value_code: Option<i32> = None;
113                let mut value_details: Option<crate::apimachinery::pkg::apis::meta::v1::StatusDetails> = None;
114                let mut value_message: Option<String> = None;
115                let mut value_metadata: Option<crate::apimachinery::pkg::apis::meta::v1::ListMeta> = None;
116                let mut value_reason: Option<String> = None;
117                let mut value_status: Option<String> = None;
118
119                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
120                    match key {
121                        Field::Key_api_version => {
122                            let value_api_version: String = crate::serde::de::MapAccess::next_value(&mut map)?;
123                            if value_api_version != <Self::Value as crate::Resource>::API_VERSION {
124                                return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_api_version), &<Self::Value as crate::Resource>::API_VERSION));
125                            }
126                        },
127                        Field::Key_kind => {
128                            let value_kind: String = crate::serde::de::MapAccess::next_value(&mut map)?;
129                            if value_kind != <Self::Value as crate::Resource>::KIND {
130                                return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_kind), &<Self::Value as crate::Resource>::KIND));
131                            }
132                        },
133                        Field::Key_code => value_code = crate::serde::de::MapAccess::next_value(&mut map)?,
134                        Field::Key_details => value_details = crate::serde::de::MapAccess::next_value(&mut map)?,
135                        Field::Key_message => value_message = crate::serde::de::MapAccess::next_value(&mut map)?,
136                        Field::Key_metadata => value_metadata = crate::serde::de::MapAccess::next_value(&mut map)?,
137                        Field::Key_reason => value_reason = crate::serde::de::MapAccess::next_value(&mut map)?,
138                        Field::Key_status => value_status = crate::serde::de::MapAccess::next_value(&mut map)?,
139                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
140                    }
141                }
142
143                Ok(Status {
144                    code: value_code,
145                    details: value_details,
146                    message: value_message,
147                    metadata: value_metadata.unwrap_or_default(),
148                    reason: value_reason,
149                    status: value_status,
150                })
151            }
152        }
153
154        deserializer.deserialize_struct(
155            <Self as crate::Resource>::KIND,
156            &[
157                "apiVersion",
158                "kind",
159                "code",
160                "details",
161                "message",
162                "metadata",
163                "reason",
164                "status",
165            ],
166            Visitor,
167        )
168    }
169}
170
171impl crate::serde::Serialize for Status {
172    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
173        let mut state = serializer.serialize_struct(
174            <Self as crate::Resource>::KIND,
175            3 +
176            self.code.as_ref().map_or(0, |_| 1) +
177            self.details.as_ref().map_or(0, |_| 1) +
178            self.message.as_ref().map_or(0, |_| 1) +
179            self.reason.as_ref().map_or(0, |_| 1) +
180            self.status.as_ref().map_or(0, |_| 1),
181        )?;
182        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as crate::Resource>::API_VERSION)?;
183        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as crate::Resource>::KIND)?;
184        if let Some(value) = &self.code {
185            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "code", value)?;
186        }
187        if let Some(value) = &self.details {
188            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "details", value)?;
189        }
190        if let Some(value) = &self.message {
191            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "message", value)?;
192        }
193        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
194        if let Some(value) = &self.reason {
195            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "reason", value)?;
196        }
197        if let Some(value) = &self.status {
198            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "status", value)?;
199        }
200        crate::serde::ser::SerializeStruct::end(state)
201    }
202}
203
204#[cfg(feature = "schemars")]
205impl crate::schemars::JsonSchema for Status {
206    fn schema_name() -> String {
207        "io.k8s.apimachinery.pkg.apis.meta.v1.Status".to_owned()
208    }
209
210    fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
211        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
212            metadata: Some(Box::new(crate::schemars::schema::Metadata {
213                description: Some("Status is a return value for calls that don't return other objects.".to_owned()),
214                ..Default::default()
215            })),
216            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
217            object: Some(Box::new(crate::schemars::schema::ObjectValidation {
218                properties: [
219                    (
220                        "apiVersion".to_owned(),
221                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
222                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
223                                description: Some("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".to_owned()),
224                                ..Default::default()
225                            })),
226                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
227                            ..Default::default()
228                        }),
229                    ),
230                    (
231                        "code".to_owned(),
232                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
233                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
234                                description: Some("Suggested HTTP return code for this status, 0 if not set.".to_owned()),
235                                ..Default::default()
236                            })),
237                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
238                            format: Some("int32".to_owned()),
239                            ..Default::default()
240                        }),
241                    ),
242                    (
243                        "details".to_owned(),
244                        {
245                            let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::StatusDetails>().into_object();
246                            schema_obj.metadata = Some(Box::new(crate::schemars::schema::Metadata {
247                                description: Some("Extended data associated with the reason.  Each reason may define its own extended details. This field is optional and the data returned is not guaranteed to conform to any schema except that defined by the reason type.".to_owned()),
248                                ..Default::default()
249                            }));
250                            crate::schemars::schema::Schema::Object(schema_obj)
251                        },
252                    ),
253                    (
254                        "kind".to_owned(),
255                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
256                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
257                                description: Some("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".to_owned()),
258                                ..Default::default()
259                            })),
260                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
261                            ..Default::default()
262                        }),
263                    ),
264                    (
265                        "message".to_owned(),
266                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
267                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
268                                description: Some("A human-readable description of the status of this operation.".to_owned()),
269                                ..Default::default()
270                            })),
271                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
272                            ..Default::default()
273                        }),
274                    ),
275                    (
276                        "metadata".to_owned(),
277                        {
278                            let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::ListMeta>().into_object();
279                            schema_obj.metadata = Some(Box::new(crate::schemars::schema::Metadata {
280                                description: Some("Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds".to_owned()),
281                                ..Default::default()
282                            }));
283                            crate::schemars::schema::Schema::Object(schema_obj)
284                        },
285                    ),
286                    (
287                        "reason".to_owned(),
288                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
289                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
290                                description: Some("A machine-readable description of why this operation is in the \"Failure\" status. If this value is empty there is no information available. A Reason clarifies an HTTP status code but does not override it.".to_owned()),
291                                ..Default::default()
292                            })),
293                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
294                            ..Default::default()
295                        }),
296                    ),
297                    (
298                        "status".to_owned(),
299                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
300                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
301                                description: Some("Status of the operation. One of: \"Success\" or \"Failure\". More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status".to_owned()),
302                                ..Default::default()
303                            })),
304                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
305                            ..Default::default()
306                        }),
307                    ),
308                ].into(),
309                required: [
310                    "metadata".to_owned(),
311                ].into(),
312                ..Default::default()
313            })),
314            ..Default::default()
315        })
316    }
317}