1// Generated from definition io.k8s.api.flowcontrol.v1beta3.NonResourcePolicyRule
23/// NonResourcePolicyRule is a predicate that matches non-resource requests according to their verb and the target non-resource URL. A NonResourcePolicyRule matches a request if and only if both (a) at least one member of verbs matches the request and (b) at least one member of nonResourceURLs matches the request.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct NonResourcePolicyRule {
6/// `nonResourceURLs` is a set of url prefixes that a user should have access to and may not be empty. For example:
7 /// - "/healthz" is legal
8 /// - "/hea*" is illegal
9 /// - "/hea" is legal but matches nothing
10 /// - "/hea/*" also matches nothing
11 /// - "/healthz/*" matches all per-component health checks.
12 /// "*" matches all non-resource urls. if it is present, it must be the only entry. Required.
13pub non_resource_urls: Vec<String>,
1415/// `verbs` is a list of matching verbs and may not be empty. "*" matches all verbs. If it is present, it must be the only entry. Required.
16pub verbs: Vec<String>,
17}
1819impl crate::DeepMerge for NonResourcePolicyRule {
20fn merge_from(&mut self, other: Self) {
21crate::merge_strategies::list::set(&mut self.non_resource_urls, other.non_resource_urls);
22crate::merge_strategies::list::set(&mut self.verbs, other.verbs);
23 }
24}
2526impl<'de> crate::serde::Deserialize<'de> for NonResourcePolicyRule {
27fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
28#[allow(non_camel_case_types)]
29enum Field {
30 Key_non_resource_urls,
31 Key_verbs,
32 Other,
33 }
3435impl<'de> crate::serde::Deserialize<'de> for Field {
36fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
37struct Visitor;
3839impl<'de> crate::serde::de::Visitor<'de> for Visitor {
40type Value = Field;
4142fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
43 f.write_str("field identifier")
44 }
4546fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
47Ok(match v {
48"nonResourceURLs" => Field::Key_non_resource_urls,
49"verbs" => Field::Key_verbs,
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 = NonResourcePolicyRule;
6364fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
65 f.write_str("NonResourcePolicyRule")
66 }
6768fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
69let mut value_non_resource_urls: Option<Vec<String>> = None;
70let mut value_verbs: Option<Vec<String>> = None;
7172while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
73match key {
74 Field::Key_non_resource_urls => value_non_resource_urls = crate::serde::de::MapAccess::next_value(&mut map)?,
75 Field::Key_verbs => value_verbs = crate::serde::de::MapAccess::next_value(&mut map)?,
76 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
77 }
78 }
7980Ok(NonResourcePolicyRule {
81 non_resource_urls: value_non_resource_urls.unwrap_or_default(),
82 verbs: value_verbs.unwrap_or_default(),
83 })
84 }
85 }
8687 deserializer.deserialize_struct(
88"NonResourcePolicyRule",
89&[
90"nonResourceURLs",
91"verbs",
92 ],
93 Visitor,
94 )
95 }
96}
9798impl crate::serde::Serialize for NonResourcePolicyRule {
99fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
100let mut state = serializer.serialize_struct(
101"NonResourcePolicyRule",
1022,
103 )?;
104crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nonResourceURLs", &self.non_resource_urls)?;
105crate::serde::ser::SerializeStruct::serialize_field(&mut state, "verbs", &self.verbs)?;
106crate::serde::ser::SerializeStruct::end(state)
107 }
108}
109110#[cfg(feature = "schemars")]
111impl crate::schemars::JsonSchema for NonResourcePolicyRule {
112fn schema_name() -> String {
113"io.k8s.api.flowcontrol.v1beta3.NonResourcePolicyRule".to_owned()
114 }
115116fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
117crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
118 metadata: Some(Box::new(crate::schemars::schema::Metadata {
119 description: Some("NonResourcePolicyRule is a predicate that matches non-resource requests according to their verb and the target non-resource URL. A NonResourcePolicyRule matches a request if and only if both (a) at least one member of verbs matches the request and (b) at least one member of nonResourceURLs matches the request.".to_owned()),
120 ..Default::default()
121 })),
122 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
123 object: Some(Box::new(crate::schemars::schema::ObjectValidation {
124 properties: [
125 (
126"nonResourceURLs".to_owned(),
127crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
128 metadata: Some(Box::new(crate::schemars::schema::Metadata {
129 description: Some("`nonResourceURLs` is a set of url prefixes that a user should have access to and may not be empty. For example:\n - \"/healthz\" is legal\n - \"/hea*\" is illegal\n - \"/hea\" is legal but matches nothing\n - \"/hea/*\" also matches nothing\n - \"/healthz/*\" matches all per-component health checks.\n\"*\" matches all non-resource urls. if it is present, it must be the only entry. Required.".to_owned()),
130 ..Default::default()
131 })),
132 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Array))),
133 array: Some(Box::new(crate::schemars::schema::ArrayValidation {
134 items: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(
135crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
136 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
137 ..Default::default()
138 })
139 ))),
140 ..Default::default()
141 })),
142 ..Default::default()
143 }),
144 ),
145 (
146"verbs".to_owned(),
147crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
148 metadata: Some(Box::new(crate::schemars::schema::Metadata {
149 description: Some("`verbs` is a list of matching verbs and may not be empty. \"*\" matches all verbs. If it is present, it must be the only entry. Required.".to_owned()),
150 ..Default::default()
151 })),
152 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Array))),
153 array: Some(Box::new(crate::schemars::schema::ArrayValidation {
154 items: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(
155crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
156 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
157 ..Default::default()
158 })
159 ))),
160 ..Default::default()
161 })),
162 ..Default::default()
163 }),
164 ),
165 ].into(),
166 required: [
167"nonResourceURLs".to_owned(),
168"verbs".to_owned(),
169 ].into(),
170 ..Default::default()
171 })),
172 ..Default::default()
173 })
174 }
175}