k8s_openapi/v1_30/api/core/v1/
namespace_status.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct NamespaceStatus {
6 pub conditions: Option<std::vec::Vec<crate::api::core::v1::NamespaceCondition>>,
8
9 pub phase: Option<std::string::String>,
11}
12
13impl crate::DeepMerge for NamespaceStatus {
14 fn merge_from(&mut self, other: Self) {
15 crate::merge_strategies::list::map(
16 &mut self.conditions,
17 other.conditions,
18 &[|lhs, rhs| lhs.type_ == rhs.type_],
19 |current_item, other_item| {
20 crate::DeepMerge::merge_from(current_item, other_item);
21 },
22 );
23 crate::DeepMerge::merge_from(&mut self.phase, other.phase);
24 }
25}
26
27impl<'de> crate::serde::Deserialize<'de> for NamespaceStatus {
28 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
29 #[allow(non_camel_case_types)]
30 enum Field {
31 Key_conditions,
32 Key_phase,
33 Other,
34 }
35
36 impl<'de> crate::serde::Deserialize<'de> for Field {
37 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
38 struct Visitor;
39
40 impl crate::serde::de::Visitor<'_> for Visitor {
41 type Value = Field;
42
43 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
44 f.write_str("field identifier")
45 }
46
47 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
48 Ok(match v {
49 "conditions" => Field::Key_conditions,
50 "phase" => Field::Key_phase,
51 _ => Field::Other,
52 })
53 }
54 }
55
56 deserializer.deserialize_identifier(Visitor)
57 }
58 }
59
60 struct Visitor;
61
62 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
63 type Value = NamespaceStatus;
64
65 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
66 f.write_str("NamespaceStatus")
67 }
68
69 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
70 let mut value_conditions: Option<std::vec::Vec<crate::api::core::v1::NamespaceCondition>> = None;
71 let mut value_phase: Option<std::string::String> = None;
72
73 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
74 match key {
75 Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
76 Field::Key_phase => value_phase = crate::serde::de::MapAccess::next_value(&mut map)?,
77 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
78 }
79 }
80
81 Ok(NamespaceStatus {
82 conditions: value_conditions,
83 phase: value_phase,
84 })
85 }
86 }
87
88 deserializer.deserialize_struct(
89 "NamespaceStatus",
90 &[
91 "conditions",
92 "phase",
93 ],
94 Visitor,
95 )
96 }
97}
98
99impl crate::serde::Serialize for NamespaceStatus {
100 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
101 let mut state = serializer.serialize_struct(
102 "NamespaceStatus",
103 self.conditions.as_ref().map_or(0, |_| 1) +
104 self.phase.as_ref().map_or(0, |_| 1),
105 )?;
106 if let Some(value) = &self.conditions {
107 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
108 }
109 if let Some(value) = &self.phase {
110 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "phase", value)?;
111 }
112 crate::serde::ser::SerializeStruct::end(state)
113 }
114}
115
116#[cfg(feature = "schemars")]
117impl crate::schemars::JsonSchema for NamespaceStatus {
118 fn schema_name() -> std::borrow::Cow<'static, str> {
119 "io.k8s.api.core.v1.NamespaceStatus".into()
120 }
121
122 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
123 crate::schemars::json_schema!({
124 "description": "NamespaceStatus is information about the current status of a Namespace.",
125 "type": "object",
126 "properties": {
127 "conditions": {
128 "description": "Represents the latest available observations of a namespace's current state.",
129 "type": "array",
130 "items": (__gen.subschema_for::<crate::api::core::v1::NamespaceCondition>()),
131 },
132 "phase": {
133 "description": "Phase is the current lifecycle phase of the namespace. More info: https://kubernetes.io/docs/tasks/administer-cluster/namespaces/",
134 "type": "string",
135 },
136 },
137 })
138 }
139}