k8s_openapi/v1_35/api/core/v1/
http_get_action.rs

1// Generated from definition io.k8s.api.core.v1.HTTPGetAction
2
3/// HTTPGetAction describes an action based on HTTP Get requests.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct HTTPGetAction {
6    /// Host name to connect to, defaults to the pod IP. You probably want to set "Host" in httpHeaders instead.
7    pub host: Option<std::string::String>,
8
9    /// Custom headers to set in the request. HTTP allows repeated headers.
10    pub http_headers: Option<std::vec::Vec<crate::api::core::v1::HTTPHeader>>,
11
12    /// Path to access on the HTTP server.
13    pub path: Option<std::string::String>,
14
15    /// Name or number of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME.
16    pub port: crate::apimachinery::pkg::util::intstr::IntOrString,
17
18    /// Scheme to use for connecting to the host. Defaults to HTTP.
19    pub scheme: Option<std::string::String>,
20}
21
22impl crate::DeepMerge for HTTPGetAction {
23    fn merge_from(&mut self, other: Self) {
24        crate::DeepMerge::merge_from(&mut self.host, other.host);
25        crate::merge_strategies::list::atomic(&mut self.http_headers, other.http_headers);
26        crate::DeepMerge::merge_from(&mut self.path, other.path);
27        crate::DeepMerge::merge_from(&mut self.port, other.port);
28        crate::DeepMerge::merge_from(&mut self.scheme, other.scheme);
29    }
30}
31
32impl<'de> crate::serde::Deserialize<'de> for HTTPGetAction {
33    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
34        #[allow(non_camel_case_types)]
35        enum Field {
36            Key_host,
37            Key_http_headers,
38            Key_path,
39            Key_port,
40            Key_scheme,
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                            "host" => Field::Key_host,
58                            "httpHeaders" => Field::Key_http_headers,
59                            "path" => Field::Key_path,
60                            "port" => Field::Key_port,
61                            "scheme" => Field::Key_scheme,
62                            _ => Field::Other,
63                        })
64                    }
65                }
66
67                deserializer.deserialize_identifier(Visitor)
68            }
69        }
70
71        struct Visitor;
72
73        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
74            type Value = HTTPGetAction;
75
76            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
77                f.write_str("HTTPGetAction")
78            }
79
80            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
81                let mut value_host: Option<std::string::String> = None;
82                let mut value_http_headers: Option<std::vec::Vec<crate::api::core::v1::HTTPHeader>> = None;
83                let mut value_path: Option<std::string::String> = None;
84                let mut value_port: Option<crate::apimachinery::pkg::util::intstr::IntOrString> = None;
85                let mut value_scheme: Option<std::string::String> = None;
86
87                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
88                    match key {
89                        Field::Key_host => value_host = crate::serde::de::MapAccess::next_value(&mut map)?,
90                        Field::Key_http_headers => value_http_headers = crate::serde::de::MapAccess::next_value(&mut map)?,
91                        Field::Key_path => value_path = crate::serde::de::MapAccess::next_value(&mut map)?,
92                        Field::Key_port => value_port = crate::serde::de::MapAccess::next_value(&mut map)?,
93                        Field::Key_scheme => value_scheme = crate::serde::de::MapAccess::next_value(&mut map)?,
94                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
95                    }
96                }
97
98                Ok(HTTPGetAction {
99                    host: value_host,
100                    http_headers: value_http_headers,
101                    path: value_path,
102                    port: value_port.unwrap_or_default(),
103                    scheme: value_scheme,
104                })
105            }
106        }
107
108        deserializer.deserialize_struct(
109            "HTTPGetAction",
110            &[
111                "host",
112                "httpHeaders",
113                "path",
114                "port",
115                "scheme",
116            ],
117            Visitor,
118        )
119    }
120}
121
122impl crate::serde::Serialize for HTTPGetAction {
123    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
124        let mut state = serializer.serialize_struct(
125            "HTTPGetAction",
126            1 +
127            self.host.as_ref().map_or(0, |_| 1) +
128            self.http_headers.as_ref().map_or(0, |_| 1) +
129            self.path.as_ref().map_or(0, |_| 1) +
130            self.scheme.as_ref().map_or(0, |_| 1),
131        )?;
132        if let Some(value) = &self.host {
133            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "host", value)?;
134        }
135        if let Some(value) = &self.http_headers {
136            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "httpHeaders", value)?;
137        }
138        if let Some(value) = &self.path {
139            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "path", value)?;
140        }
141        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "port", &self.port)?;
142        if let Some(value) = &self.scheme {
143            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "scheme", value)?;
144        }
145        crate::serde::ser::SerializeStruct::end(state)
146    }
147}
148
149#[cfg(feature = "schemars")]
150impl crate::schemars::JsonSchema for HTTPGetAction {
151    fn schema_name() -> std::borrow::Cow<'static, str> {
152        "io.k8s.api.core.v1.HTTPGetAction".into()
153    }
154
155    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
156        crate::schemars::json_schema!({
157            "description": "HTTPGetAction describes an action based on HTTP Get requests.",
158            "type": "object",
159            "properties": {
160                "host": {
161                    "description": "Host name to connect to, defaults to the pod IP. You probably want to set \"Host\" in httpHeaders instead.",
162                    "type": "string",
163                },
164                "httpHeaders": {
165                    "description": "Custom headers to set in the request. HTTP allows repeated headers.",
166                    "type": "array",
167                    "items": (__gen.subschema_for::<crate::api::core::v1::HTTPHeader>()),
168                },
169                "path": {
170                    "description": "Path to access on the HTTP server.",
171                    "type": "string",
172                },
173                "port": ({
174                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::util::intstr::IntOrString>();
175                    schema_obj.ensure_object().insert("description".into(), "Name or number of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME.".into());
176                    schema_obj
177                }),
178                "scheme": {
179                    "description": "Scheme to use for connecting to the host. Defaults to HTTP.",
180                    "type": "string",
181                },
182            },
183            "required": [
184                "port",
185            ],
186        })
187    }
188}