1// Generated from definition io.k8s.api.networking.v1.HTTPIngressPath
23/// HTTPIngressPath associates a path with a backend. Incoming urls matching the path are forwarded to the backend.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct HTTPIngressPath {
6/// backend defines the referenced service endpoint to which the traffic will be forwarded to.
7pub backend: crate::api::networking::v1::IngressBackend,
89/// path is matched against the path of an incoming request. Currently it can contain characters disallowed from the conventional "path" part of a URL as defined by RFC 3986. Paths must begin with a '/' and must be present when using PathType with value "Exact" or "Prefix".
10pub path: Option<std::string::String>,
1112/// pathType determines the interpretation of the path matching. PathType can be one of the following values: * Exact: Matches the URL path exactly. * Prefix: Matches based on a URL path prefix split by '/'. Matching is
13 /// done on a path element by element basis. A path element refers is the
14 /// list of labels in the path split by the '/' separator. A request is a
15 /// match for path p if every p is an element-wise prefix of p of the
16 /// request path. Note that if the last element of the path is a substring
17 /// of the last element in request path, it is not a match (e.g. /foo/bar
18 /// matches /foo/bar/baz, but does not match /foo/barbaz).
19 /// * ImplementationSpecific: Interpretation of the Path matching is up to
20 /// the IngressClass. Implementations can treat this as a separate PathType
21 /// or treat it identically to Prefix or Exact path types.
22 /// Implementations are required to support all path types.
23pub path_type: std::string::String,
24}
2526impl crate::DeepMerge for HTTPIngressPath {
27fn merge_from(&mut self, other: Self) {
28crate::DeepMerge::merge_from(&mut self.backend, other.backend);
29crate::DeepMerge::merge_from(&mut self.path, other.path);
30crate::DeepMerge::merge_from(&mut self.path_type, other.path_type);
31 }
32}
3334impl<'de> crate::serde::Deserialize<'de> for HTTPIngressPath {
35fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
36#[allow(non_camel_case_types)]
37enum Field {
38 Key_backend,
39 Key_path,
40 Key_path_type,
41 Other,
42 }
4344impl<'de> crate::serde::Deserialize<'de> for Field {
45fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
46struct Visitor;
4748impl crate::serde::de::Visitor<'_> for Visitor {
49type Value = Field;
5051fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
52 f.write_str("field identifier")
53 }
5455fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
56Ok(match v {
57"backend" => Field::Key_backend,
58"path" => Field::Key_path,
59"pathType" => Field::Key_path_type,
60_ => Field::Other,
61 })
62 }
63 }
6465 deserializer.deserialize_identifier(Visitor)
66 }
67 }
6869struct Visitor;
7071impl<'de> crate::serde::de::Visitor<'de> for Visitor {
72type Value = HTTPIngressPath;
7374fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
75 f.write_str("HTTPIngressPath")
76 }
7778fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
79let mut value_backend: Option<crate::api::networking::v1::IngressBackend> = None;
80let mut value_path: Option<std::string::String> = None;
81let mut value_path_type: Option<std::string::String> = None;
8283while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
84match key {
85 Field::Key_backend => value_backend = crate::serde::de::MapAccess::next_value(&mut map)?,
86 Field::Key_path => value_path = crate::serde::de::MapAccess::next_value(&mut map)?,
87 Field::Key_path_type => value_path_type = 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 }
9192Ok(HTTPIngressPath {
93 backend: value_backend.unwrap_or_default(),
94 path: value_path,
95 path_type: value_path_type.unwrap_or_default(),
96 })
97 }
98 }
99100 deserializer.deserialize_struct(
101"HTTPIngressPath",
102&[
103"backend",
104"path",
105"pathType",
106 ],
107 Visitor,
108 )
109 }
110}
111112impl crate::serde::Serialize for HTTPIngressPath {
113fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
114let mut state = serializer.serialize_struct(
115"HTTPIngressPath",
1162 +
117self.path.as_ref().map_or(0, |_| 1),
118 )?;
119crate::serde::ser::SerializeStruct::serialize_field(&mut state, "backend", &self.backend)?;
120if let Some(value) = &self.path {
121crate::serde::ser::SerializeStruct::serialize_field(&mut state, "path", value)?;
122 }
123crate::serde::ser::SerializeStruct::serialize_field(&mut state, "pathType", &self.path_type)?;
124crate::serde::ser::SerializeStruct::end(state)
125 }
126}
127128#[cfg(feature = "schemars")]
129impl crate::schemars::JsonSchema for HTTPIngressPath {
130fn schema_name() -> std::string::String {
131"io.k8s.api.networking.v1.HTTPIngressPath".into()
132 }
133134fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
135crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
136 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
137 description: Some("HTTPIngressPath associates a path with a backend. Incoming urls matching the path are forwarded to the backend.".into()),
138 ..Default::default()
139 })),
140 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
141 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
142 properties: [
143 (
144"backend".into(),
145 {
146let mut schema_obj = __gen.subschema_for::<crate::api::networking::v1::IngressBackend>().into_object();
147 schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
148 description: Some("backend defines the referenced service endpoint to which the traffic will be forwarded to.".into()),
149 ..Default::default()
150 }));
151crate::schemars::schema::Schema::Object(schema_obj)
152 },
153 ),
154 (
155"path".into(),
156crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
157 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
158 description: Some("path is matched against the path of an incoming request. Currently it can contain characters disallowed from the conventional \"path\" part of a URL as defined by RFC 3986. Paths must begin with a '/' and must be present when using PathType with value \"Exact\" or \"Prefix\".".into()),
159 ..Default::default()
160 })),
161 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
162 ..Default::default()
163 }),
164 ),
165 (
166"pathType".into(),
167crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
168 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
169 description: Some("pathType determines the interpretation of the path matching. PathType can be one of the following values: * Exact: Matches the URL path exactly. * Prefix: Matches based on a URL path prefix split by '/'. Matching is\n done on a path element by element basis. A path element refers is the\n list of labels in the path split by the '/' separator. A request is a\n match for path p if every p is an element-wise prefix of p of the\n request path. Note that if the last element of the path is a substring\n of the last element in request path, it is not a match (e.g. /foo/bar\n matches /foo/bar/baz, but does not match /foo/barbaz).\n* ImplementationSpecific: Interpretation of the Path matching is up to\n the IngressClass. Implementations can treat this as a separate PathType\n or treat it identically to Prefix or Exact path types.\nImplementations are required to support all path types.".into()),
170 ..Default::default()
171 })),
172 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
173 ..Default::default()
174 }),
175 ),
176 ].into(),
177 required: [
178"backend".into(),
179"pathType".into(),
180 ].into(),
181 ..Default::default()
182 })),
183 ..Default::default()
184 })
185 }
186}