Skip to main content

k8s_openapi/v1_36/api/scheduling/v1alpha2/
pod_group_resource_claim.rs

1// Generated from definition io.k8s.api.scheduling.v1alpha2.PodGroupResourceClaim
2
3/// PodGroupResourceClaim references exactly one ResourceClaim, either directly or by naming a ResourceClaimTemplate which is then turned into a ResourceClaim for the PodGroup.
4///
5/// It adds a name to it that uniquely identifies the ResourceClaim inside the PodGroup. Pods that need access to the ResourceClaim define a matching reference in its own Spec.ResourceClaims. The Pod's claim must match all fields of the PodGroup's claim exactly.
6#[derive(Clone, Debug, Default, PartialEq)]
7pub struct PodGroupResourceClaim {
8    /// Name uniquely identifies this resource claim inside the PodGroup. This must be a DNS_LABEL.
9    pub name: std::string::String,
10
11    /// ResourceClaimName is the name of a ResourceClaim object in the same namespace as this PodGroup. The ResourceClaim will be reserved for the PodGroup instead of its individual pods.
12    ///
13    /// Exactly one of ResourceClaimName and ResourceClaimTemplateName must be set.
14    pub resource_claim_name: Option<std::string::String>,
15
16    /// ResourceClaimTemplateName is the name of a ResourceClaimTemplate object in the same namespace as this PodGroup.
17    ///
18    /// The template will be used to create a new ResourceClaim, which will be bound to this PodGroup. When this PodGroup is deleted, the ResourceClaim will also be deleted. The PodGroup name and resource name, along with a generated component, will be used to form a unique name for the ResourceClaim, which will be recorded in podgroup.status.resourceClaimStatuses.
19    ///
20    /// This field is immutable and no changes will be made to the corresponding ResourceClaim by the control plane after creating the ResourceClaim.
21    ///
22    /// Exactly one of ResourceClaimName and ResourceClaimTemplateName must be set.
23    pub resource_claim_template_name: Option<std::string::String>,
24}
25
26impl crate::DeepMerge for PodGroupResourceClaim {
27    fn merge_from(&mut self, other: Self) {
28        crate::DeepMerge::merge_from(&mut self.name, other.name);
29        crate::DeepMerge::merge_from(&mut self.resource_claim_name, other.resource_claim_name);
30        crate::DeepMerge::merge_from(&mut self.resource_claim_template_name, other.resource_claim_template_name);
31    }
32}
33
34impl<'de> crate::serde::Deserialize<'de> for PodGroupResourceClaim {
35    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
36        #[allow(non_camel_case_types)]
37        enum Field {
38            Key_name,
39            Key_resource_claim_name,
40            Key_resource_claim_template_name,
41            Other,
42        }
43
44        impl<'de> crate::serde::Deserialize<'de> for Field {
45            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
46                struct Visitor;
47
48                impl crate::serde::de::Visitor<'_> for Visitor {
49                    type Value = Field;
50
51                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
52                        f.write_str("field identifier")
53                    }
54
55                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
56                        Ok(match v {
57                            "name" => Field::Key_name,
58                            "resourceClaimName" => Field::Key_resource_claim_name,
59                            "resourceClaimTemplateName" => Field::Key_resource_claim_template_name,
60                            _ => Field::Other,
61                        })
62                    }
63                }
64
65                deserializer.deserialize_identifier(Visitor)
66            }
67        }
68
69        struct Visitor;
70
71        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
72            type Value = PodGroupResourceClaim;
73
74            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
75                f.write_str("PodGroupResourceClaim")
76            }
77
78            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
79                let mut value_name: Option<std::string::String> = None;
80                let mut value_resource_claim_name: Option<std::string::String> = None;
81                let mut value_resource_claim_template_name: Option<std::string::String> = None;
82
83                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
84                    match key {
85                        Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
86                        Field::Key_resource_claim_name => value_resource_claim_name = crate::serde::de::MapAccess::next_value(&mut map)?,
87                        Field::Key_resource_claim_template_name => value_resource_claim_template_name = crate::serde::de::MapAccess::next_value(&mut map)?,
88                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
89                    }
90                }
91
92                Ok(PodGroupResourceClaim {
93                    name: value_name.unwrap_or_default(),
94                    resource_claim_name: value_resource_claim_name,
95                    resource_claim_template_name: value_resource_claim_template_name,
96                })
97            }
98        }
99
100        deserializer.deserialize_struct(
101            "PodGroupResourceClaim",
102            &[
103                "name",
104                "resourceClaimName",
105                "resourceClaimTemplateName",
106            ],
107            Visitor,
108        )
109    }
110}
111
112impl crate::serde::Serialize for PodGroupResourceClaim {
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            "PodGroupResourceClaim",
116            1 +
117            self.resource_claim_name.as_ref().map_or(0, |_| 1) +
118            self.resource_claim_template_name.as_ref().map_or(0, |_| 1),
119        )?;
120        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
121        if let Some(value) = &self.resource_claim_name {
122            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resourceClaimName", value)?;
123        }
124        if let Some(value) = &self.resource_claim_template_name {
125            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resourceClaimTemplateName", value)?;
126        }
127        crate::serde::ser::SerializeStruct::end(state)
128    }
129}
130
131#[cfg(feature = "schemars")]
132impl crate::schemars::JsonSchema for PodGroupResourceClaim {
133    fn schema_name() -> std::borrow::Cow<'static, str> {
134        "io.k8s.api.scheduling.v1alpha2.PodGroupResourceClaim".into()
135    }
136
137    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
138        crate::schemars::json_schema!({
139            "description": "PodGroupResourceClaim references exactly one ResourceClaim, either directly or by naming a ResourceClaimTemplate which is then turned into a ResourceClaim for the PodGroup.\n\nIt adds a name to it that uniquely identifies the ResourceClaim inside the PodGroup. Pods that need access to the ResourceClaim define a matching reference in its own Spec.ResourceClaims. The Pod's claim must match all fields of the PodGroup's claim exactly.",
140            "type": "object",
141            "properties": {
142                "name": {
143                    "description": "Name uniquely identifies this resource claim inside the PodGroup. This must be a DNS_LABEL.",
144                    "type": "string",
145                },
146                "resourceClaimName": {
147                    "description": "ResourceClaimName is the name of a ResourceClaim object in the same namespace as this PodGroup. The ResourceClaim will be reserved for the PodGroup instead of its individual pods.\n\nExactly one of ResourceClaimName and ResourceClaimTemplateName must be set.",
148                    "type": "string",
149                },
150                "resourceClaimTemplateName": {
151                    "description": "ResourceClaimTemplateName is the name of a ResourceClaimTemplate object in the same namespace as this PodGroup.\n\nThe template will be used to create a new ResourceClaim, which will be bound to this PodGroup. When this PodGroup is deleted, the ResourceClaim will also be deleted. The PodGroup name and resource name, along with a generated component, will be used to form a unique name for the ResourceClaim, which will be recorded in podgroup.status.resourceClaimStatuses.\n\nThis field is immutable and no changes will be made to the corresponding ResourceClaim by the control plane after creating the ResourceClaim.\n\nExactly one of ResourceClaimName and ResourceClaimTemplateName must be set.",
152                    "type": "string",
153                },
154            },
155            "required": [
156                "name",
157            ],
158        })
159    }
160}
161
162#[cfg(feature = "schemars08")]
163impl crate::schemars08::JsonSchema for PodGroupResourceClaim {
164    fn schema_name() -> std::string::String {
165        "io.k8s.api.scheduling.v1alpha2.PodGroupResourceClaim".into()
166    }
167
168    fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
169        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
170            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
171                description: Some("PodGroupResourceClaim references exactly one ResourceClaim, either directly or by naming a ResourceClaimTemplate which is then turned into a ResourceClaim for the PodGroup.\n\nIt adds a name to it that uniquely identifies the ResourceClaim inside the PodGroup. Pods that need access to the ResourceClaim define a matching reference in its own Spec.ResourceClaims. The Pod's claim must match all fields of the PodGroup's claim exactly.".into()),
172                ..Default::default()
173            })),
174            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
175            object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
176                properties: [
177                    (
178                        "name".into(),
179                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
180                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
181                                description: Some("Name uniquely identifies this resource claim inside the PodGroup. This must be a DNS_LABEL.".into()),
182                                ..Default::default()
183                            })),
184                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
185                            ..Default::default()
186                        }),
187                    ),
188                    (
189                        "resourceClaimName".into(),
190                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
191                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
192                                description: Some("ResourceClaimName is the name of a ResourceClaim object in the same namespace as this PodGroup. The ResourceClaim will be reserved for the PodGroup instead of its individual pods.\n\nExactly one of ResourceClaimName and ResourceClaimTemplateName must be set.".into()),
193                                ..Default::default()
194                            })),
195                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
196                            ..Default::default()
197                        }),
198                    ),
199                    (
200                        "resourceClaimTemplateName".into(),
201                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
202                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
203                                description: Some("ResourceClaimTemplateName is the name of a ResourceClaimTemplate object in the same namespace as this PodGroup.\n\nThe template will be used to create a new ResourceClaim, which will be bound to this PodGroup. When this PodGroup is deleted, the ResourceClaim will also be deleted. The PodGroup name and resource name, along with a generated component, will be used to form a unique name for the ResourceClaim, which will be recorded in podgroup.status.resourceClaimStatuses.\n\nThis field is immutable and no changes will be made to the corresponding ResourceClaim by the control plane after creating the ResourceClaim.\n\nExactly one of ResourceClaimName and ResourceClaimTemplateName must be set.".into()),
204                                ..Default::default()
205                            })),
206                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
207                            ..Default::default()
208                        }),
209                    ),
210                ].into(),
211                required: [
212                    "name".into(),
213                ].into(),
214                ..Default::default()
215            })),
216            ..Default::default()
217        })
218    }
219}