k8s_openapi/v1_34/api/networking/v1/
http_ingress_path.rs

1// Generated from definition io.k8s.api.networking.v1.HTTPIngressPath
2
3/// 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.
7    pub backend: crate::api::networking::v1::IngressBackend,
8
9    /// 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".
10    pub path: Option<std::string::String>,
11
12    /// 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.
23    pub path_type: std::string::String,
24}
25
26impl crate::DeepMerge for HTTPIngressPath {
27    fn merge_from(&mut self, other: Self) {
28        crate::DeepMerge::merge_from(&mut self.backend, other.backend);
29        crate::DeepMerge::merge_from(&mut self.path, other.path);
30        crate::DeepMerge::merge_from(&mut self.path_type, other.path_type);
31    }
32}
33
34impl<'de> crate::serde::Deserialize<'de> for HTTPIngressPath {
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_backend,
39            Key_path,
40            Key_path_type,
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                            "backend" => Field::Key_backend,
58                            "path" => Field::Key_path,
59                            "pathType" => Field::Key_path_type,
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 = HTTPIngressPath;
73
74            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
75                f.write_str("HTTPIngressPath")
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_backend: Option<crate::api::networking::v1::IngressBackend> = None;
80                let mut value_path: Option<std::string::String> = None;
81                let mut value_path_type: 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_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                }
91
92                Ok(HTTPIngressPath {
93                    backend: value_backend.unwrap_or_default(),
94                    path: value_path,
95                    path_type: value_path_type.unwrap_or_default(),
96                })
97            }
98        }
99
100        deserializer.deserialize_struct(
101            "HTTPIngressPath",
102            &[
103                "backend",
104                "path",
105                "pathType",
106            ],
107            Visitor,
108        )
109    }
110}
111
112impl crate::serde::Serialize for HTTPIngressPath {
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            "HTTPIngressPath",
116            2 +
117            self.path.as_ref().map_or(0, |_| 1),
118        )?;
119        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "backend", &self.backend)?;
120        if let Some(value) = &self.path {
121            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "path", value)?;
122        }
123        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "pathType", &self.path_type)?;
124        crate::serde::ser::SerializeStruct::end(state)
125    }
126}
127
128#[cfg(feature = "schemars")]
129impl crate::schemars::JsonSchema for HTTPIngressPath {
130    fn schema_name() -> std::borrow::Cow<'static, str> {
131        "io.k8s.api.networking.v1.HTTPIngressPath".into()
132    }
133
134    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
135        crate::schemars::json_schema!({
136            "description": "HTTPIngressPath associates a path with a backend. Incoming urls matching the path are forwarded to the backend.",
137            "type": "object",
138            "properties": {
139                "backend": ({
140                    let mut schema_obj = __gen.subschema_for::<crate::api::networking::v1::IngressBackend>();
141                    schema_obj.ensure_object().insert("description".into(), "backend defines the referenced service endpoint to which the traffic will be forwarded to.".into());
142                    schema_obj
143                }),
144                "path": {
145                    "description": "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\".",
146                    "type": "string",
147                },
148                "pathType": {
149                    "description": "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.",
150                    "type": "string",
151                },
152            },
153            "required": [
154                "backend",
155                "pathType",
156            ],
157        })
158    }
159}