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

1// Generated from definition io.k8s.apimachinery.pkg.apis.meta.v1.ManagedFieldsEntry
2
3/// ManagedFieldsEntry is a workflow-id, a FieldSet and the group version of the resource that the fieldset applies to.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct ManagedFieldsEntry {
6    /// APIVersion defines the version of this resource that this field set applies to. The format is "group/version" just like the top-level APIVersion field. It is necessary to track the version of a field set because it cannot be automatically converted.
7    pub api_version: Option<std::string::String>,
8
9    /// FieldsType is the discriminator for the different fields format and version. There is currently only one possible value: "FieldsV1"
10    pub fields_type: Option<std::string::String>,
11
12    /// FieldsV1 holds the first JSON version format as described in the "FieldsV1" type.
13    pub fields_v1: Option<crate::apimachinery::pkg::apis::meta::v1::FieldsV1>,
14
15    /// Manager is an identifier of the workflow managing these fields.
16    pub manager: Option<std::string::String>,
17
18    /// Operation is the type of operation which lead to this ManagedFieldsEntry being created. The only valid values for this field are 'Apply' and 'Update'.
19    pub operation: Option<std::string::String>,
20
21    /// Subresource is the name of the subresource used to update that object, or empty string if the object was updated through the main resource. The value of this field is used to distinguish between managers, even if they share the same name. For example, a status update will be distinct from a regular update using the same manager name. Note that the APIVersion field is not related to the Subresource field and it always corresponds to the version of the main resource.
22    pub subresource: Option<std::string::String>,
23
24    /// Time is the timestamp of when the ManagedFields entry was added. The timestamp will also be updated if a field is added, the manager changes any of the owned fields value or removes a field. The timestamp does not update when a field is removed from the entry because another manager took it over.
25    pub time: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
26}
27
28impl crate::DeepMerge for ManagedFieldsEntry {
29    fn merge_from(&mut self, other: Self) {
30        crate::DeepMerge::merge_from(&mut self.api_version, other.api_version);
31        crate::DeepMerge::merge_from(&mut self.fields_type, other.fields_type);
32        crate::DeepMerge::merge_from(&mut self.fields_v1, other.fields_v1);
33        crate::DeepMerge::merge_from(&mut self.manager, other.manager);
34        crate::DeepMerge::merge_from(&mut self.operation, other.operation);
35        crate::DeepMerge::merge_from(&mut self.subresource, other.subresource);
36        crate::DeepMerge::merge_from(&mut self.time, other.time);
37    }
38}
39
40impl<'de> crate::serde::Deserialize<'de> for ManagedFieldsEntry {
41    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
42        #[allow(non_camel_case_types)]
43        enum Field {
44            Key_api_version,
45            Key_fields_type,
46            Key_fields_v1,
47            Key_manager,
48            Key_operation,
49            Key_subresource,
50            Key_time,
51            Other,
52        }
53
54        impl<'de> crate::serde::Deserialize<'de> for Field {
55            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
56                struct Visitor;
57
58                impl crate::serde::de::Visitor<'_> for Visitor {
59                    type Value = Field;
60
61                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
62                        f.write_str("field identifier")
63                    }
64
65                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
66                        Ok(match v {
67                            "apiVersion" => Field::Key_api_version,
68                            "fieldsType" => Field::Key_fields_type,
69                            "fieldsV1" => Field::Key_fields_v1,
70                            "manager" => Field::Key_manager,
71                            "operation" => Field::Key_operation,
72                            "subresource" => Field::Key_subresource,
73                            "time" => Field::Key_time,
74                            _ => Field::Other,
75                        })
76                    }
77                }
78
79                deserializer.deserialize_identifier(Visitor)
80            }
81        }
82
83        struct Visitor;
84
85        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
86            type Value = ManagedFieldsEntry;
87
88            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
89                f.write_str("ManagedFieldsEntry")
90            }
91
92            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
93                let mut value_api_version: Option<std::string::String> = None;
94                let mut value_fields_type: Option<std::string::String> = None;
95                let mut value_fields_v1: Option<crate::apimachinery::pkg::apis::meta::v1::FieldsV1> = None;
96                let mut value_manager: Option<std::string::String> = None;
97                let mut value_operation: Option<std::string::String> = None;
98                let mut value_subresource: Option<std::string::String> = None;
99                let mut value_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
100
101                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
102                    match key {
103                        Field::Key_api_version => value_api_version = crate::serde::de::MapAccess::next_value(&mut map)?,
104                        Field::Key_fields_type => value_fields_type = crate::serde::de::MapAccess::next_value(&mut map)?,
105                        Field::Key_fields_v1 => value_fields_v1 = crate::serde::de::MapAccess::next_value(&mut map)?,
106                        Field::Key_manager => value_manager = crate::serde::de::MapAccess::next_value(&mut map)?,
107                        Field::Key_operation => value_operation = crate::serde::de::MapAccess::next_value(&mut map)?,
108                        Field::Key_subresource => value_subresource = crate::serde::de::MapAccess::next_value(&mut map)?,
109                        Field::Key_time => value_time = crate::serde::de::MapAccess::next_value(&mut map)?,
110                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
111                    }
112                }
113
114                Ok(ManagedFieldsEntry {
115                    api_version: value_api_version,
116                    fields_type: value_fields_type,
117                    fields_v1: value_fields_v1,
118                    manager: value_manager,
119                    operation: value_operation,
120                    subresource: value_subresource,
121                    time: value_time,
122                })
123            }
124        }
125
126        deserializer.deserialize_struct(
127            "ManagedFieldsEntry",
128            &[
129                "apiVersion",
130                "fieldsType",
131                "fieldsV1",
132                "manager",
133                "operation",
134                "subresource",
135                "time",
136            ],
137            Visitor,
138        )
139    }
140}
141
142impl crate::serde::Serialize for ManagedFieldsEntry {
143    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
144        let mut state = serializer.serialize_struct(
145            "ManagedFieldsEntry",
146            self.api_version.as_ref().map_or(0, |_| 1) +
147            self.fields_type.as_ref().map_or(0, |_| 1) +
148            self.fields_v1.as_ref().map_or(0, |_| 1) +
149            self.manager.as_ref().map_or(0, |_| 1) +
150            self.operation.as_ref().map_or(0, |_| 1) +
151            self.subresource.as_ref().map_or(0, |_| 1) +
152            self.time.as_ref().map_or(0, |_| 1),
153        )?;
154        if let Some(value) = &self.api_version {
155            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", value)?;
156        }
157        if let Some(value) = &self.fields_type {
158            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "fieldsType", value)?;
159        }
160        if let Some(value) = &self.fields_v1 {
161            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "fieldsV1", value)?;
162        }
163        if let Some(value) = &self.manager {
164            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "manager", value)?;
165        }
166        if let Some(value) = &self.operation {
167            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "operation", value)?;
168        }
169        if let Some(value) = &self.subresource {
170            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "subresource", value)?;
171        }
172        if let Some(value) = &self.time {
173            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "time", value)?;
174        }
175        crate::serde::ser::SerializeStruct::end(state)
176    }
177}
178
179#[cfg(feature = "schemars")]
180impl crate::schemars::JsonSchema for ManagedFieldsEntry {
181    fn schema_name() -> std::borrow::Cow<'static, str> {
182        "io.k8s.apimachinery.pkg.apis.meta.v1.ManagedFieldsEntry".into()
183    }
184
185    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
186        crate::schemars::json_schema!({
187            "description": "ManagedFieldsEntry is a workflow-id, a FieldSet and the group version of the resource that the fieldset applies to.",
188            "type": "object",
189            "properties": {
190                "apiVersion": {
191                    "description": "APIVersion defines the version of this resource that this field set applies to. The format is \"group/version\" just like the top-level APIVersion field. It is necessary to track the version of a field set because it cannot be automatically converted.",
192                    "type": "string",
193                },
194                "fieldsType": {
195                    "description": "FieldsType is the discriminator for the different fields format and version. There is currently only one possible value: \"FieldsV1\"",
196                    "type": "string",
197                },
198                "fieldsV1": ({
199                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::FieldsV1>();
200                    schema_obj.ensure_object().insert("description".into(), "FieldsV1 holds the first JSON version format as described in the \"FieldsV1\" type.".into());
201                    schema_obj
202                }),
203                "manager": {
204                    "description": "Manager is an identifier of the workflow managing these fields.",
205                    "type": "string",
206                },
207                "operation": {
208                    "description": "Operation is the type of operation which lead to this ManagedFieldsEntry being created. The only valid values for this field are 'Apply' and 'Update'.",
209                    "type": "string",
210                },
211                "subresource": {
212                    "description": "Subresource is the name of the subresource used to update that object, or empty string if the object was updated through the main resource. The value of this field is used to distinguish between managers, even if they share the same name. For example, a status update will be distinct from a regular update using the same manager name. Note that the APIVersion field is not related to the Subresource field and it always corresponds to the version of the main resource.",
213                    "type": "string",
214                },
215                "time": ({
216                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
217                    schema_obj.ensure_object().insert("description".into(), "Time is the timestamp of when the ManagedFields entry was added. The timestamp will also be updated if a field is added, the manager changes any of the owned fields value or removes a field. The timestamp does not update when a field is removed from the entry because another manager took it over.".into());
218                    schema_obj
219                }),
220            },
221        })
222    }
223}