Skip to main content

k8s_openapi/v1_36/api/admissionregistration/v1beta1/
named_rule_with_operations.rs

1// Generated from definition io.k8s.api.admissionregistration.v1beta1.NamedRuleWithOperations
2
3/// NamedRuleWithOperations is a tuple of Operations and Resources with ResourceNames.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct NamedRuleWithOperations {
6    /// apiGroups is the API groups the resources belong to. '*' is all groups. If '*' is present, the length of the slice must be one. Required.
7    pub api_groups: Option<std::vec::Vec<std::string::String>>,
8
9    /// apiVersions is the API versions the resources belong to. '*' is all versions. If '*' is present, the length of the slice must be one. Required.
10    pub api_versions: Option<std::vec::Vec<std::string::String>>,
11
12    /// operations is the operations the admission hook cares about - CREATE, UPDATE, DELETE, CONNECT or * for all of those operations and any future admission operations that are added. If '*' is present, the length of the slice must be one. Required.
13    pub operations: Option<std::vec::Vec<std::string::String>>,
14
15    /// resourceNames is an optional white list of names that the rule applies to.  An empty set means that everything is allowed.
16    pub resource_names: Option<std::vec::Vec<std::string::String>>,
17
18    /// resources is a list of resources this rule applies to.
19    ///
20    /// For example: 'pods' means pods. 'pods/log' means the log subresource of pods. '*' means all resources, but not subresources. 'pods/*' means all subresources of pods. '*/scale' means all scale subresources. '*/*' means all resources and their subresources.
21    ///
22    /// If wildcard is present, the validation rule will ensure resources do not overlap with each other.
23    ///
24    /// Depending on the enclosing object, subresources might not be allowed. Required.
25    pub resources: Option<std::vec::Vec<std::string::String>>,
26
27    /// scope specifies the scope of this rule. Valid values are "Cluster", "Namespaced", and "*" "Cluster" means that only cluster-scoped resources will match this rule. Namespace API objects are cluster-scoped. "Namespaced" means that only namespaced resources will match this rule. "*" means that there are no scope restrictions. Subresources match the scope of their parent resource. Default is "*".
28    pub scope: Option<std::string::String>,
29}
30
31impl crate::DeepMerge for NamedRuleWithOperations {
32    fn merge_from(&mut self, other: Self) {
33        crate::merge_strategies::list::atomic(&mut self.api_groups, other.api_groups);
34        crate::merge_strategies::list::atomic(&mut self.api_versions, other.api_versions);
35        crate::merge_strategies::list::atomic(&mut self.operations, other.operations);
36        crate::merge_strategies::list::atomic(&mut self.resource_names, other.resource_names);
37        crate::merge_strategies::list::atomic(&mut self.resources, other.resources);
38        crate::DeepMerge::merge_from(&mut self.scope, other.scope);
39    }
40}
41
42impl<'de> crate::serde::Deserialize<'de> for NamedRuleWithOperations {
43    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
44        #[allow(non_camel_case_types)]
45        enum Field {
46            Key_api_groups,
47            Key_api_versions,
48            Key_operations,
49            Key_resource_names,
50            Key_resources,
51            Key_scope,
52            Other,
53        }
54
55        impl<'de> crate::serde::Deserialize<'de> for Field {
56            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
57                struct Visitor;
58
59                impl crate::serde::de::Visitor<'_> for Visitor {
60                    type Value = Field;
61
62                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
63                        f.write_str("field identifier")
64                    }
65
66                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
67                        Ok(match v {
68                            "apiGroups" => Field::Key_api_groups,
69                            "apiVersions" => Field::Key_api_versions,
70                            "operations" => Field::Key_operations,
71                            "resourceNames" => Field::Key_resource_names,
72                            "resources" => Field::Key_resources,
73                            "scope" => Field::Key_scope,
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 = NamedRuleWithOperations;
87
88            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
89                f.write_str("NamedRuleWithOperations")
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_groups: Option<std::vec::Vec<std::string::String>> = None;
94                let mut value_api_versions: Option<std::vec::Vec<std::string::String>> = None;
95                let mut value_operations: Option<std::vec::Vec<std::string::String>> = None;
96                let mut value_resource_names: Option<std::vec::Vec<std::string::String>> = None;
97                let mut value_resources: Option<std::vec::Vec<std::string::String>> = None;
98                let mut value_scope: Option<std::string::String> = None;
99
100                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
101                    match key {
102                        Field::Key_api_groups => value_api_groups = crate::serde::de::MapAccess::next_value(&mut map)?,
103                        Field::Key_api_versions => value_api_versions = crate::serde::de::MapAccess::next_value(&mut map)?,
104                        Field::Key_operations => value_operations = crate::serde::de::MapAccess::next_value(&mut map)?,
105                        Field::Key_resource_names => value_resource_names = crate::serde::de::MapAccess::next_value(&mut map)?,
106                        Field::Key_resources => value_resources = crate::serde::de::MapAccess::next_value(&mut map)?,
107                        Field::Key_scope => value_scope = crate::serde::de::MapAccess::next_value(&mut map)?,
108                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
109                    }
110                }
111
112                Ok(NamedRuleWithOperations {
113                    api_groups: value_api_groups,
114                    api_versions: value_api_versions,
115                    operations: value_operations,
116                    resource_names: value_resource_names,
117                    resources: value_resources,
118                    scope: value_scope,
119                })
120            }
121        }
122
123        deserializer.deserialize_struct(
124            "NamedRuleWithOperations",
125            &[
126                "apiGroups",
127                "apiVersions",
128                "operations",
129                "resourceNames",
130                "resources",
131                "scope",
132            ],
133            Visitor,
134        )
135    }
136}
137
138impl crate::serde::Serialize for NamedRuleWithOperations {
139    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
140        let mut state = serializer.serialize_struct(
141            "NamedRuleWithOperations",
142            self.api_groups.as_ref().map_or(0, |_| 1) +
143            self.api_versions.as_ref().map_or(0, |_| 1) +
144            self.operations.as_ref().map_or(0, |_| 1) +
145            self.resource_names.as_ref().map_or(0, |_| 1) +
146            self.resources.as_ref().map_or(0, |_| 1) +
147            self.scope.as_ref().map_or(0, |_| 1),
148        )?;
149        if let Some(value) = &self.api_groups {
150            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiGroups", value)?;
151        }
152        if let Some(value) = &self.api_versions {
153            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersions", value)?;
154        }
155        if let Some(value) = &self.operations {
156            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "operations", value)?;
157        }
158        if let Some(value) = &self.resource_names {
159            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resourceNames", value)?;
160        }
161        if let Some(value) = &self.resources {
162            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resources", value)?;
163        }
164        if let Some(value) = &self.scope {
165            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "scope", value)?;
166        }
167        crate::serde::ser::SerializeStruct::end(state)
168    }
169}
170
171#[cfg(feature = "schemars")]
172impl crate::schemars::JsonSchema for NamedRuleWithOperations {
173    fn schema_name() -> std::borrow::Cow<'static, str> {
174        "io.k8s.api.admissionregistration.v1beta1.NamedRuleWithOperations".into()
175    }
176
177    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
178        crate::schemars::json_schema!({
179            "description": "NamedRuleWithOperations is a tuple of Operations and Resources with ResourceNames.",
180            "type": "object",
181            "properties": {
182                "apiGroups": {
183                    "description": "apiGroups is the API groups the resources belong to. '*' is all groups. If '*' is present, the length of the slice must be one. Required.",
184                    "type": "array",
185                    "items": {
186                        "type": "string",
187                    },
188                },
189                "apiVersions": {
190                    "description": "apiVersions is the API versions the resources belong to. '*' is all versions. If '*' is present, the length of the slice must be one. Required.",
191                    "type": "array",
192                    "items": {
193                        "type": "string",
194                    },
195                },
196                "operations": {
197                    "description": "operations is the operations the admission hook cares about - CREATE, UPDATE, DELETE, CONNECT or * for all of those operations and any future admission operations that are added. If '*' is present, the length of the slice must be one. Required.",
198                    "type": "array",
199                    "items": {
200                        "type": "string",
201                    },
202                },
203                "resourceNames": {
204                    "description": "resourceNames is an optional white list of names that the rule applies to.  An empty set means that everything is allowed.",
205                    "type": "array",
206                    "items": {
207                        "type": "string",
208                    },
209                },
210                "resources": {
211                    "description": "resources is a list of resources this rule applies to.\n\nFor example: 'pods' means pods. 'pods/log' means the log subresource of pods. '*' means all resources, but not subresources. 'pods/*' means all subresources of pods. '*/scale' means all scale subresources. '*/*' means all resources and their subresources.\n\nIf wildcard is present, the validation rule will ensure resources do not overlap with each other.\n\nDepending on the enclosing object, subresources might not be allowed. Required.",
212                    "type": "array",
213                    "items": {
214                        "type": "string",
215                    },
216                },
217                "scope": {
218                    "description": "scope specifies the scope of this rule. Valid values are \"Cluster\", \"Namespaced\", and \"*\" \"Cluster\" means that only cluster-scoped resources will match this rule. Namespace API objects are cluster-scoped. \"Namespaced\" means that only namespaced resources will match this rule. \"*\" means that there are no scope restrictions. Subresources match the scope of their parent resource. Default is \"*\".",
219                    "type": "string",
220                },
221            },
222        })
223    }
224}
225
226#[cfg(feature = "schemars08")]
227impl crate::schemars08::JsonSchema for NamedRuleWithOperations {
228    fn schema_name() -> std::string::String {
229        "io.k8s.api.admissionregistration.v1beta1.NamedRuleWithOperations".into()
230    }
231
232    fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
233        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
234            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
235                description: Some("NamedRuleWithOperations is a tuple of Operations and Resources with ResourceNames.".into()),
236                ..Default::default()
237            })),
238            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
239            object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
240                properties: [
241                    (
242                        "apiGroups".into(),
243                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
244                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
245                                description: Some("apiGroups is the API groups the resources belong to. '*' is all groups. If '*' is present, the length of the slice must be one. Required.".into()),
246                                ..Default::default()
247                            })),
248                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
249                            array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
250                                items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(
251                                    crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
252                                        instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
253                                        ..Default::default()
254                                    })
255                                ))),
256                                ..Default::default()
257                            })),
258                            ..Default::default()
259                        }),
260                    ),
261                    (
262                        "apiVersions".into(),
263                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
264                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
265                                description: Some("apiVersions is the API versions the resources belong to. '*' is all versions. If '*' is present, the length of the slice must be one. Required.".into()),
266                                ..Default::default()
267                            })),
268                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
269                            array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
270                                items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(
271                                    crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
272                                        instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
273                                        ..Default::default()
274                                    })
275                                ))),
276                                ..Default::default()
277                            })),
278                            ..Default::default()
279                        }),
280                    ),
281                    (
282                        "operations".into(),
283                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
284                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
285                                description: Some("operations is the operations the admission hook cares about - CREATE, UPDATE, DELETE, CONNECT or * for all of those operations and any future admission operations that are added. If '*' is present, the length of the slice must be one. Required.".into()),
286                                ..Default::default()
287                            })),
288                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
289                            array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
290                                items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(
291                                    crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
292                                        instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
293                                        ..Default::default()
294                                    })
295                                ))),
296                                ..Default::default()
297                            })),
298                            ..Default::default()
299                        }),
300                    ),
301                    (
302                        "resourceNames".into(),
303                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
304                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
305                                description: Some("resourceNames is an optional white list of names that the rule applies to.  An empty set means that everything is allowed.".into()),
306                                ..Default::default()
307                            })),
308                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
309                            array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
310                                items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(
311                                    crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
312                                        instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
313                                        ..Default::default()
314                                    })
315                                ))),
316                                ..Default::default()
317                            })),
318                            ..Default::default()
319                        }),
320                    ),
321                    (
322                        "resources".into(),
323                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
324                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
325                                description: Some("resources is a list of resources this rule applies to.\n\nFor example: 'pods' means pods. 'pods/log' means the log subresource of pods. '*' means all resources, but not subresources. 'pods/*' means all subresources of pods. '*/scale' means all scale subresources. '*/*' means all resources and their subresources.\n\nIf wildcard is present, the validation rule will ensure resources do not overlap with each other.\n\nDepending on the enclosing object, subresources might not be allowed. Required.".into()),
326                                ..Default::default()
327                            })),
328                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
329                            array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
330                                items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(
331                                    crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
332                                        instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
333                                        ..Default::default()
334                                    })
335                                ))),
336                                ..Default::default()
337                            })),
338                            ..Default::default()
339                        }),
340                    ),
341                    (
342                        "scope".into(),
343                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
344                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
345                                description: Some("scope specifies the scope of this rule. Valid values are \"Cluster\", \"Namespaced\", and \"*\" \"Cluster\" means that only cluster-scoped resources will match this rule. Namespace API objects are cluster-scoped. \"Namespaced\" means that only namespaced resources will match this rule. \"*\" means that there are no scope restrictions. Subresources match the scope of their parent resource. Default is \"*\".".into()),
346                                ..Default::default()
347                            })),
348                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
349                            ..Default::default()
350                        }),
351                    ),
352                ].into(),
353                ..Default::default()
354            })),
355            ..Default::default()
356        })
357    }
358}