k8s_openapi/v1_33/api/networking/v1/
http_ingress_path.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct HTTPIngressPath {
6 pub backend: crate::api::networking::v1::IngressBackend,
8
9 pub path: Option<std::string::String>,
11
12 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::string::String {
131 "io.k8s.api.networking.v1.HTTPIngressPath".into()
132 }
133
134 fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
135 crate::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 {
146 let 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 }));
151 crate::schemars::schema::Schema::Object(schema_obj)
152 },
153 ),
154 (
155 "path".into(),
156 crate::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(),
167 crate::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}