1// Generated from definition io.k8s.api.admissionregistration.v1.RuleWithOperations
23/// RuleWithOperations is a tuple of Operations and Resources. It is recommended to make sure that all the tuple expansions are valid.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct RuleWithOperations {
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.
7pub api_groups: Option<std::vec::Vec<std::string::String>>,
89/// APIVersions is the API versions the resources belong to. '*' is all versions. If '*' is present, the length of the slice must be one. Required.
10pub api_versions: Option<std::vec::Vec<std::string::String>>,
1112/// 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.
13pub operations: Option<std::vec::Vec<std::string::String>>,
1415/// Resources is a list of resources this rule applies to.
16 ///
17 /// 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.
18 ///
19 /// If wildcard is present, the validation rule will ensure resources do not overlap with each other.
20 ///
21 /// Depending on the enclosing object, subresources might not be allowed. Required.
22pub resources: Option<std::vec::Vec<std::string::String>>,
2324/// 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 "*".
25pub scope: Option<std::string::String>,
26}
2728impl crate::DeepMerge for RuleWithOperations {
29fn merge_from(&mut self, other: Self) {
30crate::merge_strategies::list::atomic(&mut self.api_groups, other.api_groups);
31crate::merge_strategies::list::atomic(&mut self.api_versions, other.api_versions);
32crate::merge_strategies::list::atomic(&mut self.operations, other.operations);
33crate::merge_strategies::list::atomic(&mut self.resources, other.resources);
34crate::DeepMerge::merge_from(&mut self.scope, other.scope);
35 }
36}
3738impl<'de> crate::serde::Deserialize<'de> for RuleWithOperations {
39fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
40#[allow(non_camel_case_types)]
41enum Field {
42 Key_api_groups,
43 Key_api_versions,
44 Key_operations,
45 Key_resources,
46 Key_scope,
47 Other,
48 }
4950impl<'de> crate::serde::Deserialize<'de> for Field {
51fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
52struct Visitor;
5354impl crate::serde::de::Visitor<'_> for Visitor {
55type Value = Field;
5657fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
58 f.write_str("field identifier")
59 }
6061fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
62Ok(match v {
63"apiGroups" => Field::Key_api_groups,
64"apiVersions" => Field::Key_api_versions,
65"operations" => Field::Key_operations,
66"resources" => Field::Key_resources,
67"scope" => Field::Key_scope,
68_ => Field::Other,
69 })
70 }
71 }
7273 deserializer.deserialize_identifier(Visitor)
74 }
75 }
7677struct Visitor;
7879impl<'de> crate::serde::de::Visitor<'de> for Visitor {
80type Value = RuleWithOperations;
8182fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
83 f.write_str("RuleWithOperations")
84 }
8586fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
87let mut value_api_groups: Option<std::vec::Vec<std::string::String>> = None;
88let mut value_api_versions: Option<std::vec::Vec<std::string::String>> = None;
89let mut value_operations: Option<std::vec::Vec<std::string::String>> = None;
90let mut value_resources: Option<std::vec::Vec<std::string::String>> = None;
91let mut value_scope: Option<std::string::String> = None;
9293while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
94match key {
95 Field::Key_api_groups => value_api_groups = crate::serde::de::MapAccess::next_value(&mut map)?,
96 Field::Key_api_versions => value_api_versions = crate::serde::de::MapAccess::next_value(&mut map)?,
97 Field::Key_operations => value_operations = crate::serde::de::MapAccess::next_value(&mut map)?,
98 Field::Key_resources => value_resources = crate::serde::de::MapAccess::next_value(&mut map)?,
99 Field::Key_scope => value_scope = crate::serde::de::MapAccess::next_value(&mut map)?,
100 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
101 }
102 }
103104Ok(RuleWithOperations {
105 api_groups: value_api_groups,
106 api_versions: value_api_versions,
107 operations: value_operations,
108 resources: value_resources,
109 scope: value_scope,
110 })
111 }
112 }
113114 deserializer.deserialize_struct(
115"RuleWithOperations",
116&[
117"apiGroups",
118"apiVersions",
119"operations",
120"resources",
121"scope",
122 ],
123 Visitor,
124 )
125 }
126}
127128impl crate::serde::Serialize for RuleWithOperations {
129fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
130let mut state = serializer.serialize_struct(
131"RuleWithOperations",
132self.api_groups.as_ref().map_or(0, |_| 1) +
133self.api_versions.as_ref().map_or(0, |_| 1) +
134self.operations.as_ref().map_or(0, |_| 1) +
135self.resources.as_ref().map_or(0, |_| 1) +
136self.scope.as_ref().map_or(0, |_| 1),
137 )?;
138if let Some(value) = &self.api_groups {
139crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiGroups", value)?;
140 }
141if let Some(value) = &self.api_versions {
142crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersions", value)?;
143 }
144if let Some(value) = &self.operations {
145crate::serde::ser::SerializeStruct::serialize_field(&mut state, "operations", value)?;
146 }
147if let Some(value) = &self.resources {
148crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resources", value)?;
149 }
150if let Some(value) = &self.scope {
151crate::serde::ser::SerializeStruct::serialize_field(&mut state, "scope", value)?;
152 }
153crate::serde::ser::SerializeStruct::end(state)
154 }
155}
156157#[cfg(feature = "schemars")]
158impl crate::schemars::JsonSchema for RuleWithOperations {
159fn schema_name() -> std::string::String {
160"io.k8s.api.admissionregistration.v1.RuleWithOperations".into()
161 }
162163fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
164crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
165 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
166 description: Some("RuleWithOperations is a tuple of Operations and Resources. It is recommended to make sure that all the tuple expansions are valid.".into()),
167 ..Default::default()
168 })),
169 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
170 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
171 properties: [
172 (
173"apiGroups".into(),
174crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
175 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
176 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()),
177 ..Default::default()
178 })),
179 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Array))),
180 array: Some(std::boxed::Box::new(crate::schemars::schema::ArrayValidation {
181 items: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(
182crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
183 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
184 ..Default::default()
185 })
186 ))),
187 ..Default::default()
188 })),
189 ..Default::default()
190 }),
191 ),
192 (
193"apiVersions".into(),
194crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
195 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
196 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()),
197 ..Default::default()
198 })),
199 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Array))),
200 array: Some(std::boxed::Box::new(crate::schemars::schema::ArrayValidation {
201 items: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(
202crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
203 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
204 ..Default::default()
205 })
206 ))),
207 ..Default::default()
208 })),
209 ..Default::default()
210 }),
211 ),
212 (
213"operations".into(),
214crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
215 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
216 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()),
217 ..Default::default()
218 })),
219 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Array))),
220 array: Some(std::boxed::Box::new(crate::schemars::schema::ArrayValidation {
221 items: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(
222crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
223 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
224 ..Default::default()
225 })
226 ))),
227 ..Default::default()
228 })),
229 ..Default::default()
230 }),
231 ),
232 (
233"resources".into(),
234crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
235 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
236 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()),
237 ..Default::default()
238 })),
239 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Array))),
240 array: Some(std::boxed::Box::new(crate::schemars::schema::ArrayValidation {
241 items: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(
242crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
243 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
244 ..Default::default()
245 })
246 ))),
247 ..Default::default()
248 })),
249 ..Default::default()
250 }),
251 ),
252 (
253"scope".into(),
254crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
255 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
256 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()),
257 ..Default::default()
258 })),
259 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
260 ..Default::default()
261 }),
262 ),
263 ].into(),
264 ..Default::default()
265 })),
266 ..Default::default()
267 })
268 }
269}