openshift_openapi/v4_5/api/build/v1/
build_log.rs

1// Generated from definition com.github.openshift.api.build.v1.BuildLog
2
3/// BuildLog is the (unused) resource associated with the build log redirector
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct BuildLog {
6}
7
8// Begin build.openshift.io/v1/BuildLog
9
10// Generated from operation readBuildOpenshiftIoV1NamespacedBuildLog
11
12impl BuildLog {
13    /// read log of the specified Build
14    ///
15    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`ReadNamespacedBuildLogResponse`]`>` constructor, or [`ReadNamespacedBuildLogResponse`] directly, to parse the HTTP response.
16    ///
17    /// # Arguments
18    ///
19    /// * `name`
20    ///
21    ///     name of the BuildLog
22    ///
23    /// * `namespace`
24    ///
25    ///     object name and auth scope, such as for teams and projects
26    ///
27    /// * `optional`
28    ///
29    ///     Optional parameters. Use `Default::default()` to not pass any.
30    #[cfg(feature = "api")]
31    pub fn read_namespaced_build_log(
32        name: &str,
33        namespace: &str,
34        optional: ReadNamespacedBuildLogOptional<'_>,
35    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<ReadNamespacedBuildLogResponse>), k8s_openapi::RequestError> {
36        let ReadNamespacedBuildLogOptional {
37            container,
38            follow,
39            limit_bytes,
40            nowait,
41            pretty,
42            previous,
43            since_seconds,
44            tail_lines,
45            timestamps,
46            version,
47        } = optional;
48        let __url = format!("/apis/build.openshift.io/v1/namespaces/{namespace}/builds/{name}/log?",
49            name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
50            namespace = k8s_openapi::percent_encoding::percent_encode(namespace.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
51        );
52        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
53        if let Some(container) = container {
54            __query_pairs.append_pair("container", container);
55        }
56        if let Some(follow) = follow {
57            __query_pairs.append_pair("follow", &follow.to_string());
58        }
59        if let Some(limit_bytes) = limit_bytes {
60            __query_pairs.append_pair("limitBytes", &limit_bytes.to_string());
61        }
62        if let Some(nowait) = nowait {
63            __query_pairs.append_pair("nowait", &nowait.to_string());
64        }
65        if let Some(pretty) = pretty {
66            __query_pairs.append_pair("pretty", pretty);
67        }
68        if let Some(previous) = previous {
69            __query_pairs.append_pair("previous", &previous.to_string());
70        }
71        if let Some(since_seconds) = since_seconds {
72            __query_pairs.append_pair("sinceSeconds", &since_seconds.to_string());
73        }
74        if let Some(tail_lines) = tail_lines {
75            __query_pairs.append_pair("tailLines", &tail_lines.to_string());
76        }
77        if let Some(timestamps) = timestamps {
78            __query_pairs.append_pair("timestamps", &timestamps.to_string());
79        }
80        if let Some(version) = version {
81            __query_pairs.append_pair("version", &version.to_string());
82        }
83        let __url = __query_pairs.finish();
84
85        let __request = http::Request::get(__url);
86        let __body = vec![];
87        match __request.body(__body) {
88            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
89            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
90        }
91    }
92}
93
94/// Optional parameters of [`BuildLog::read_namespaced_build_log`]
95#[cfg(feature = "api")]
96#[derive(Clone, Copy, Debug, Default)]
97pub struct ReadNamespacedBuildLogOptional<'a> {
98    /// cointainer for which to stream logs. Defaults to only container if there is one container in the pod.
99    pub container: Option<&'a str>,
100    /// follow if true indicates that the build log should be streamed until the build terminates.
101    pub follow: Option<bool>,
102    /// limitBytes, If set, is the number of bytes to read from the server before terminating the log output. This may not display a complete final line of logging, and may return slightly more or slightly less than the specified limit.
103    pub limit_bytes: Option<i64>,
104    /// noWait if true causes the call to return immediately even if the build is not available yet. Otherwise the server will wait until the build has started.
105    pub nowait: Option<bool>,
106    /// If 'true', then the output is pretty printed.
107    pub pretty: Option<&'a str>,
108    /// previous returns previous build logs. Defaults to false.
109    pub previous: Option<bool>,
110    /// sinceSeconds is a relative time in seconds before the current time from which to show logs. If this value precedes the time a pod was started, only logs since the pod start will be returned. If this value is in the future, no logs will be returned. Only one of sinceSeconds or sinceTime may be specified.
111    pub since_seconds: Option<i64>,
112    /// tailLines, If set, is the number of lines from the end of the logs to show. If not specified, logs are shown from the creation of the container or sinceSeconds or sinceTime
113    pub tail_lines: Option<i64>,
114    /// timestamps, If true, add an RFC3339 or RFC3339Nano timestamp at the beginning of every line of log output. Defaults to false.
115    pub timestamps: Option<bool>,
116    /// version of the build for which to view logs.
117    pub version: Option<i64>,
118}
119
120/// Use `<ReadNamespacedBuildLogResponse as Response>::try_from_parts` to parse the HTTP response body of [`BuildLog::read_namespaced_build_log`]
121#[cfg(feature = "api")]
122#[derive(Debug)]
123pub enum ReadNamespacedBuildLogResponse {
124    Ok(crate::api::build::v1::BuildLog),
125    Other(Result<Option<serde_json::Value>, serde_json::Error>),
126}
127
128#[cfg(feature = "api")]
129impl k8s_openapi::Response for ReadNamespacedBuildLogResponse {
130    fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), k8s_openapi::ResponseError> {
131        match status_code {
132            http::StatusCode::OK => {
133                let result = match serde_json::from_slice(buf) {
134                    Ok(value) => value,
135                    Err(ref err) if err.is_eof() => return Err(k8s_openapi::ResponseError::NeedMoreData),
136                    Err(err) => return Err(k8s_openapi::ResponseError::Json(err)),
137                };
138                Ok((ReadNamespacedBuildLogResponse::Ok(result), buf.len()))
139            },
140            _ => {
141                let (result, read) =
142                    if buf.is_empty() {
143                        (Ok(None), 0)
144                    }
145                    else {
146                        match serde_json::from_slice(buf) {
147                            Ok(value) => (Ok(Some(value)), buf.len()),
148                            Err(ref err) if err.is_eof() => return Err(k8s_openapi::ResponseError::NeedMoreData),
149                            Err(err) => (Err(err), 0),
150                        }
151                    };
152                Ok((ReadNamespacedBuildLogResponse::Other(result), read))
153            },
154        }
155    }
156}
157
158// End build.openshift.io/v1/BuildLog
159
160impl k8s_openapi::Resource for BuildLog {
161    const API_VERSION: &'static str = "build.openshift.io/v1";
162    const GROUP: &'static str = "build.openshift.io";
163    const KIND: &'static str = "BuildLog";
164    const VERSION: &'static str = "v1";
165}
166
167impl<'de> serde::Deserialize<'de> for BuildLog {
168    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
169        #[allow(non_camel_case_types)]
170        enum Field {
171            Key_api_version,
172            Key_kind,
173            Other,
174        }
175
176        impl<'de> serde::Deserialize<'de> for Field {
177            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
178                struct Visitor;
179
180                impl<'de> serde::de::Visitor<'de> for Visitor {
181                    type Value = Field;
182
183                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
184                        f.write_str("field identifier")
185                    }
186
187                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
188                        Ok(match v {
189                            "apiVersion" => Field::Key_api_version,
190                            "kind" => Field::Key_kind,
191                            _ => Field::Other,
192                        })
193                    }
194                }
195
196                deserializer.deserialize_identifier(Visitor)
197            }
198        }
199
200        struct Visitor;
201
202        impl<'de> serde::de::Visitor<'de> for Visitor {
203            type Value = BuildLog;
204
205            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
206                f.write_str(<Self::Value as k8s_openapi::Resource>::KIND)
207            }
208
209            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
210
211                while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
212                    match key {
213                        Field::Key_api_version => {
214                            let value_api_version: String = serde::de::MapAccess::next_value(&mut map)?;
215                            if value_api_version != <Self::Value as k8s_openapi::Resource>::API_VERSION {
216                                return Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(&value_api_version), &<Self::Value as k8s_openapi::Resource>::API_VERSION));
217                            }
218                        },
219                        Field::Key_kind => {
220                            let value_kind: String = serde::de::MapAccess::next_value(&mut map)?;
221                            if value_kind != <Self::Value as k8s_openapi::Resource>::KIND {
222                                return Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(&value_kind), &<Self::Value as k8s_openapi::Resource>::KIND));
223                            }
224                        },
225                        Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
226                    }
227                }
228
229                Ok(BuildLog {
230                })
231            }
232        }
233
234        deserializer.deserialize_struct(
235            <Self as k8s_openapi::Resource>::KIND,
236            &[
237                "apiVersion",
238                "kind",
239            ],
240            Visitor,
241        )
242    }
243}
244
245impl serde::Serialize for BuildLog {
246    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
247        let mut state = serializer.serialize_struct(
248            <Self as k8s_openapi::Resource>::KIND,
249            2,
250        )?;
251        serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as k8s_openapi::Resource>::API_VERSION)?;
252        serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as k8s_openapi::Resource>::KIND)?;
253        serde::ser::SerializeStruct::end(state)
254    }
255}