openshift_openapi/v4_5/api/build/v1/
build_log.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct BuildLog {
6}
7
8impl BuildLog {
13 #[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", ×tamps.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#[cfg(feature = "api")]
96#[derive(Clone, Copy, Debug, Default)]
97pub struct ReadNamespacedBuildLogOptional<'a> {
98 pub container: Option<&'a str>,
100 pub follow: Option<bool>,
102 pub limit_bytes: Option<i64>,
104 pub nowait: Option<bool>,
106 pub pretty: Option<&'a str>,
108 pub previous: Option<bool>,
110 pub since_seconds: Option<i64>,
112 pub tail_lines: Option<i64>,
114 pub timestamps: Option<bool>,
116 pub version: Option<i64>,
118}
119
120#[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
158impl 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}