1// Generated from definition io.k8s.api.resource.v1alpha2.ResourceClaimParametersReference
23/// ResourceClaimParametersReference contains enough information to let you locate the parameters for a ResourceClaim. The object must be in the same namespace as the ResourceClaim.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct ResourceClaimParametersReference {
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.
7pub api_group: Option<String>,
89/// Kind is the type of resource being referenced. This is the same value as in the parameter object's metadata, for example "ConfigMap".
10pub kind: String,
1112/// Name is the name of resource being referenced.
13pub name: String,
14}
1516impl crate::DeepMerge for ResourceClaimParametersReference {
17fn merge_from(&mut self, other: Self) {
18crate::DeepMerge::merge_from(&mut self.api_group, other.api_group);
19crate::DeepMerge::merge_from(&mut self.kind, other.kind);
20crate::DeepMerge::merge_from(&mut self.name, other.name);
21 }
22}
2324impl<'de> crate::serde::Deserialize<'de> for ResourceClaimParametersReference {
25fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
26#[allow(non_camel_case_types)]
27enum Field {
28 Key_api_group,
29 Key_kind,
30 Key_name,
31 Other,
32 }
3334impl<'de> crate::serde::Deserialize<'de> for Field {
35fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
36struct Visitor;
3738impl<'de> crate::serde::de::Visitor<'de> for Visitor {
39type Value = Field;
4041fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42 f.write_str("field identifier")
43 }
4445fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
46Ok(match v {
47"apiGroup" => Field::Key_api_group,
48"kind" => Field::Key_kind,
49"name" => Field::Key_name,
50_ => Field::Other,
51 })
52 }
53 }
5455 deserializer.deserialize_identifier(Visitor)
56 }
57 }
5859struct Visitor;
6061impl<'de> crate::serde::de::Visitor<'de> for Visitor {
62type Value = ResourceClaimParametersReference;
6364fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
65 f.write_str("ResourceClaimParametersReference")
66 }
6768fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
69let mut value_api_group: Option<String> = None;
70let mut value_kind: Option<String> = None;
71let mut value_name: Option<String> = None;
7273while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
74match key {
75 Field::Key_api_group => value_api_group = crate::serde::de::MapAccess::next_value(&mut map)?,
76 Field::Key_kind => value_kind = crate::serde::de::MapAccess::next_value(&mut map)?,
77 Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
78 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
79 }
80 }
8182Ok(ResourceClaimParametersReference {
83 api_group: value_api_group,
84 kind: value_kind.unwrap_or_default(),
85 name: value_name.unwrap_or_default(),
86 })
87 }
88 }
8990 deserializer.deserialize_struct(
91"ResourceClaimParametersReference",
92&[
93"apiGroup",
94"kind",
95"name",
96 ],
97 Visitor,
98 )
99 }
100}
101102impl crate::serde::Serialize for ResourceClaimParametersReference {
103fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
104let mut state = serializer.serialize_struct(
105"ResourceClaimParametersReference",
1062 +
107self.api_group.as_ref().map_or(0, |_| 1),
108 )?;
109if let Some(value) = &self.api_group {
110crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiGroup", value)?;
111 }
112crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", &self.kind)?;
113crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
114crate::serde::ser::SerializeStruct::end(state)
115 }
116}
117118#[cfg(feature = "schemars")]
119impl crate::schemars::JsonSchema for ResourceClaimParametersReference {
120fn schema_name() -> String {
121"io.k8s.api.resource.v1alpha2.ResourceClaimParametersReference".to_owned()
122 }
123124fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
125crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
126 metadata: Some(Box::new(crate::schemars::schema::Metadata {
127 description: Some("ResourceClaimParametersReference contains enough information to let you locate the parameters for a ResourceClaim. The object must be in the same namespace as the ResourceClaim.".to_owned()),
128 ..Default::default()
129 })),
130 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
131 object: Some(Box::new(crate::schemars::schema::ObjectValidation {
132 properties: [
133 (
134"apiGroup".to_owned(),
135crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
136 metadata: Some(Box::new(crate::schemars::schema::Metadata {
137 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.".to_owned()),
138 ..Default::default()
139 })),
140 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
141 ..Default::default()
142 }),
143 ),
144 (
145"kind".to_owned(),
146crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
147 metadata: Some(Box::new(crate::schemars::schema::Metadata {
148 description: Some("Kind is the type of resource being referenced. This is the same value as in the parameter object's metadata, for example \"ConfigMap\".".to_owned()),
149 ..Default::default()
150 })),
151 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
152 ..Default::default()
153 }),
154 ),
155 (
156"name".to_owned(),
157crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
158 metadata: Some(Box::new(crate::schemars::schema::Metadata {
159 description: Some("Name is the name of resource being referenced.".to_owned()),
160 ..Default::default()
161 })),
162 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
163 ..Default::default()
164 }),
165 ),
166 ].into(),
167 required: [
168"kind".to_owned(),
169"name".to_owned(),
170 ].into(),
171 ..Default::default()
172 })),
173 ..Default::default()
174 })
175 }
176}