Skip to main content

k8s_openapi/v1_36/api/resource/v1beta1/
resource_claim_consumer_reference.rs

1// Generated from definition io.k8s.api.resource.v1beta1.ResourceClaimConsumerReference
2
3/// ResourceClaimConsumerReference contains enough information to let you locate the consumer of a ResourceClaim. The user must be a resource in the same namespace as the ResourceClaim.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct ResourceClaimConsumerReference {
6    /// APIGroup is the group for the resource being referenced. It is empty for the core API. This matches the group in the APIVersion that is used when creating the resources.
7    pub api_group: Option<std::string::String>,
8
9    /// Name is the name of resource being referenced.
10    pub name: std::string::String,
11
12    /// Resource is the type of resource being referenced, for example "pods".
13    pub resource: std::string::String,
14
15    /// UID identifies exactly one incarnation of the resource.
16    pub uid: std::string::String,
17}
18
19impl crate::DeepMerge for ResourceClaimConsumerReference {
20    fn merge_from(&mut self, other: Self) {
21        crate::DeepMerge::merge_from(&mut self.api_group, other.api_group);
22        crate::DeepMerge::merge_from(&mut self.name, other.name);
23        crate::DeepMerge::merge_from(&mut self.resource, other.resource);
24        crate::DeepMerge::merge_from(&mut self.uid, other.uid);
25    }
26}
27
28impl<'de> crate::serde::Deserialize<'de> for ResourceClaimConsumerReference {
29    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
30        #[allow(non_camel_case_types)]
31        enum Field {
32            Key_api_group,
33            Key_name,
34            Key_resource,
35            Key_uid,
36            Other,
37        }
38
39        impl<'de> crate::serde::Deserialize<'de> for Field {
40            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
41                struct Visitor;
42
43                impl crate::serde::de::Visitor<'_> for Visitor {
44                    type Value = Field;
45
46                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
47                        f.write_str("field identifier")
48                    }
49
50                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
51                        Ok(match v {
52                            "apiGroup" => Field::Key_api_group,
53                            "name" => Field::Key_name,
54                            "resource" => Field::Key_resource,
55                            "uid" => Field::Key_uid,
56                            _ => Field::Other,
57                        })
58                    }
59                }
60
61                deserializer.deserialize_identifier(Visitor)
62            }
63        }
64
65        struct Visitor;
66
67        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
68            type Value = ResourceClaimConsumerReference;
69
70            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
71                f.write_str("ResourceClaimConsumerReference")
72            }
73
74            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
75                let mut value_api_group: Option<std::string::String> = None;
76                let mut value_name: Option<std::string::String> = None;
77                let mut value_resource: Option<std::string::String> = None;
78                let mut value_uid: Option<std::string::String> = None;
79
80                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
81                    match key {
82                        Field::Key_api_group => value_api_group = crate::serde::de::MapAccess::next_value(&mut map)?,
83                        Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
84                        Field::Key_resource => value_resource = crate::serde::de::MapAccess::next_value(&mut map)?,
85                        Field::Key_uid => value_uid = crate::serde::de::MapAccess::next_value(&mut map)?,
86                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
87                    }
88                }
89
90                Ok(ResourceClaimConsumerReference {
91                    api_group: value_api_group,
92                    name: value_name.unwrap_or_default(),
93                    resource: value_resource.unwrap_or_default(),
94                    uid: value_uid.unwrap_or_default(),
95                })
96            }
97        }
98
99        deserializer.deserialize_struct(
100            "ResourceClaimConsumerReference",
101            &[
102                "apiGroup",
103                "name",
104                "resource",
105                "uid",
106            ],
107            Visitor,
108        )
109    }
110}
111
112impl crate::serde::Serialize for ResourceClaimConsumerReference {
113    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
114        let mut state = serializer.serialize_struct(
115            "ResourceClaimConsumerReference",
116            3 +
117            self.api_group.as_ref().map_or(0, |_| 1),
118        )?;
119        if let Some(value) = &self.api_group {
120            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiGroup", value)?;
121        }
122        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
123        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resource", &self.resource)?;
124        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "uid", &self.uid)?;
125        crate::serde::ser::SerializeStruct::end(state)
126    }
127}
128
129#[cfg(feature = "schemars")]
130impl crate::schemars::JsonSchema for ResourceClaimConsumerReference {
131    fn schema_name() -> std::borrow::Cow<'static, str> {
132        "io.k8s.api.resource.v1beta1.ResourceClaimConsumerReference".into()
133    }
134
135    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
136        crate::schemars::json_schema!({
137            "description": "ResourceClaimConsumerReference contains enough information to let you locate the consumer of a ResourceClaim. The user must be a resource in the same namespace as the ResourceClaim.",
138            "type": "object",
139            "properties": {
140                "apiGroup": {
141                    "description": "APIGroup is the group for the resource being referenced. It is empty for the core API. This matches the group in the APIVersion that is used when creating the resources.",
142                    "type": "string",
143                },
144                "name": {
145                    "description": "Name is the name of resource being referenced.",
146                    "type": "string",
147                },
148                "resource": {
149                    "description": "Resource is the type of resource being referenced, for example \"pods\".",
150                    "type": "string",
151                },
152                "uid": {
153                    "description": "UID identifies exactly one incarnation of the resource.",
154                    "type": "string",
155                },
156            },
157            "required": [
158                "name",
159                "resource",
160                "uid",
161            ],
162        })
163    }
164}
165
166#[cfg(feature = "schemars08")]
167impl crate::schemars08::JsonSchema for ResourceClaimConsumerReference {
168    fn schema_name() -> std::string::String {
169        "io.k8s.api.resource.v1beta1.ResourceClaimConsumerReference".into()
170    }
171
172    fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
173        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
174            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
175                description: Some("ResourceClaimConsumerReference contains enough information to let you locate the consumer of a ResourceClaim. The user must be a resource in the same namespace as the ResourceClaim.".into()),
176                ..Default::default()
177            })),
178            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
179            object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
180                properties: [
181                    (
182                        "apiGroup".into(),
183                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
184                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
185                                description: Some("APIGroup is the group for the resource being referenced. It is empty for the core API. This matches the group in the APIVersion that is used when creating the resources.".into()),
186                                ..Default::default()
187                            })),
188                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
189                            ..Default::default()
190                        }),
191                    ),
192                    (
193                        "name".into(),
194                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
195                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
196                                description: Some("Name is the name of resource being referenced.".into()),
197                                ..Default::default()
198                            })),
199                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
200                            ..Default::default()
201                        }),
202                    ),
203                    (
204                        "resource".into(),
205                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
206                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
207                                description: Some("Resource is the type of resource being referenced, for example \"pods\".".into()),
208                                ..Default::default()
209                            })),
210                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
211                            ..Default::default()
212                        }),
213                    ),
214                    (
215                        "uid".into(),
216                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
217                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
218                                description: Some("UID identifies exactly one incarnation of the resource.".into()),
219                                ..Default::default()
220                            })),
221                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
222                            ..Default::default()
223                        }),
224                    ),
225                ].into(),
226                required: [
227                    "name".into(),
228                    "resource".into(),
229                    "uid".into(),
230                ].into(),
231                ..Default::default()
232            })),
233            ..Default::default()
234        })
235    }
236}