1pub struct Content<Body>
10{
11 body: Body,
12 content_type_value: Option<::std::borrow::Cow<'static, [u8]>>,
13}
14
15impl<Body> Content<Body> {
16 pub fn new(body: Body) -> Self {
17 Self { body, content_type_value: None }
18 }
19
20 #[must_use]
21 pub fn with_content_type(mut self, content_type: impl Into<::std::borrow::Cow<'static, [u8]>>) -> Self {
22 self.content_type_value = Some(content_type.into());
23 self
24 }
25
26 fn content_type(&self) -> Option<&[u8]> {
27 self.content_type_value.as_deref()
28 }
29
30 fn into_body(self) -> Body {
31 self.body
32 }
33}
34
35fn url_string(
36 base_url: &str,
37 p_owner: &str,
38 p_repo: &str,
39 p_check_run_id: i64,
40) -> Result<String, crate::v1_1_4::ApiError> {
41 let trimmed = if base_url.is_empty() {
42 "https://api.github.com"
43 } else {
44 base_url.trim_end_matches('/')
45 };
46 let mut url = String::with_capacity(trimmed.len() + 39);
47 url.push_str(trimmed);
48 url.push_str("/repos/");
49 ::querylizer::Simple::extend(&mut url, &p_owner, false, &::querylizer::encode_path)?;
50 url.push('/');
51 ::querylizer::Simple::extend(&mut url, &p_repo, false, &::querylizer::encode_path)?;
52 url.push_str("/check-runs/");
53 ::querylizer::Simple::extend(&mut url, &p_check_run_id, false, &::querylizer::encode_path)?;
54 Ok(url)
55}
56
57#[cfg(feature = "hyper")]
58pub fn http_builder(
59 base_url: &str,
60 p_owner: &str,
61 p_repo: &str,
62 p_check_run_id: i64,
63 h_user_agent: &str,
64 h_accept: ::std::option::Option<&str>,
65) -> Result<::http::request::Builder, crate::v1_1_4::ApiError> {
66 let url = url_string(
67 base_url,
68 p_owner,
69 p_repo,
70 p_check_run_id,
71 )?;
72 let mut builder = ::http::request::Request::patch(url);
73 builder = builder.header(
74 "User-Agent",
75 &::querylizer::Simple::to_string(&h_user_agent, false, &::querylizer::passthrough)?
76 );
77 if let Some(value) = &h_accept {
78 builder = builder.header(
79 "Accept",
80 &::querylizer::Simple::to_string(value, false, &::querylizer::passthrough)?
81 );
82 }
83 Ok(builder)
84}
85
86#[cfg(feature = "hyper")]
87pub fn hyper_request(
88 mut builder: ::http::request::Builder,
89 content: Content<::hyper::Body>,
90) -> Result<::http::request::Request<::hyper::Body>, crate::v1_1_4::ApiError>
91{
92 if let Some(content_type) = content.content_type() {
93 builder = builder.header(::http::header::CONTENT_TYPE, content_type);
94 }
95 Ok(builder.body(content.into_body())?)
96}
97
98#[cfg(feature = "hyper")]
99impl From<::hyper::Body> for Content<::hyper::Body> {
100 fn from(body: ::hyper::Body) -> Self {
101 Self::new(body)
102 }
103}
104
105#[cfg(feature = "reqwest")]
106pub fn reqwest_builder(
107 base_url: &str,
108 p_owner: &str,
109 p_repo: &str,
110 p_check_run_id: i64,
111 h_user_agent: &str,
112 h_accept: ::std::option::Option<&str>,
113) -> Result<::reqwest::Request, crate::v1_1_4::ApiError> {
114 let url = url_string(
115 base_url,
116 p_owner,
117 p_repo,
118 p_check_run_id,
119 )?;
120 let reqwest_url = ::reqwest::Url::parse(&url)?;
121 let mut request = ::reqwest::Request::new(::reqwest::Method::PATCH, reqwest_url);
122 let headers = request.headers_mut();
123 headers.append(
124 "User-Agent",
125 ::querylizer::Simple::to_string(&h_user_agent, false, &::querylizer::passthrough)?.try_into()?
126 );
127 if let Some(value) = &h_accept {
128 headers.append(
129 "Accept",
130 ::querylizer::Simple::to_string(value, false, &::querylizer::passthrough)?.try_into()?
131 );
132 }
133 Ok(request)
134}
135
136#[cfg(feature = "reqwest")]
137pub fn reqwest_request(
138 mut builder: ::reqwest::Request,
139 content: Content<::reqwest::Body>,
140) -> Result<::reqwest::Request, crate::v1_1_4::ApiError> {
141 if let Some(content_type) = content.content_type() {
142 builder.headers_mut().append(
143 ::reqwest::header::HeaderName::from_static("content-type"),
144 ::reqwest::header::HeaderValue::try_from(content_type)?,
145 );
146 }
147 *builder.body_mut() = Some(content.into_body());
148 Ok(builder)
149}
150
151#[cfg(feature = "reqwest")]
152impl From<::reqwest::Body> for Content<::reqwest::Body> {
153 fn from(body: ::reqwest::Body) -> Self {
154 Self::new(body)
155 }
156}
157
158#[cfg(feature = "reqwest-blocking")]
159pub fn reqwest_blocking_builder(
160 base_url: &str,
161 p_owner: &str,
162 p_repo: &str,
163 p_check_run_id: i64,
164 h_user_agent: &str,
165 h_accept: ::std::option::Option<&str>,
166) -> Result<::reqwest::blocking::Request, crate::v1_1_4::ApiError> {
167 let url = url_string(
168 base_url,
169 p_owner,
170 p_repo,
171 p_check_run_id,
172 )?;
173 let reqwest_url = ::reqwest::Url::parse(&url)?;
174 let mut request = ::reqwest::blocking::Request::new(::reqwest::Method::PATCH, reqwest_url);
175 let headers = request.headers_mut();
176 headers.append(
177 "User-Agent",
178 ::querylizer::Simple::to_string(&h_user_agent, false, &::querylizer::passthrough)?.try_into()?
179 );
180 if let Some(value) = &h_accept {
181 headers.append(
182 "Accept",
183 ::querylizer::Simple::to_string(value, false, &::querylizer::passthrough)?.try_into()?
184 );
185 }
186 Ok(request)
187}
188
189#[cfg(feature = "reqwest-blocking")]
190pub fn reqwest_blocking_request(
191 mut builder: ::reqwest::blocking::Request,
192 content: Content<::reqwest::blocking::Body>,
193) -> Result<::reqwest::blocking::Request, crate::v1_1_4::ApiError> {
194 if let Some(content_type) = content.content_type() {
195 builder.headers_mut().append(
196 ::reqwest::header::HeaderName::from_static("content-type"),
197 ::reqwest::header::HeaderValue::try_from(content_type)?,
198 );
199 }
200 *builder.body_mut() = Some(content.into_body());
201 Ok(builder)
202}
203
204#[cfg(feature = "reqwest-blocking")]
205impl From<::reqwest::blocking::Body> for Content<::reqwest::blocking::Body> {
206 fn from(body: ::reqwest::blocking::Body) -> Self {
207 Self::new(body)
208 }
209}
210
211pub mod body {
213 #[allow(non_snake_case)]
214 #[derive(Clone, Eq, PartialEq, Debug, Default, ::serde::Serialize, ::serde::Deserialize)]
215 pub struct Json<'a> {
216 #[serde(skip_serializing_if = "Option::is_none", default)]
218 pub name: ::std::option::Option<::std::borrow::Cow<'a, str>>,
219
220 #[serde(skip_serializing_if = "Option::is_none", default)]
222 pub details_url: ::std::option::Option<::std::borrow::Cow<'a, str>>,
223
224 #[serde(skip_serializing_if = "Option::is_none", default)]
226 pub external_id: ::std::option::Option<::std::borrow::Cow<'a, str>>,
227
228 #[serde(skip_serializing_if = "Option::is_none", default)]
230 pub started_at: ::std::option::Option<::std::borrow::Cow<'a, str>>,
231
232 #[serde(skip_serializing_if = "Option::is_none", default)]
234 pub status: ::std::option::Option<::std::borrow::Cow<'a, str>>,
235
236 #[serde(skip_serializing_if = "Option::is_none", default)]
239 pub conclusion: ::std::option::Option<::std::borrow::Cow<'a, str>>,
240
241 #[serde(skip_serializing_if = "Option::is_none", default)]
243 pub completed_at: ::std::option::Option<::std::borrow::Cow<'a, str>>,
244
245 #[serde(skip_serializing_if = "Option::is_none", default)]
246 pub output: ::std::option::Option<crate::v1_1_4::request::checks_update::body::json::Output<'a>>,
247
248 #[serde(skip_serializing_if = "Option::is_none", default)]
250 pub actions: ::std::option::Option<::std::borrow::Cow<'a, [crate::v1_1_4::request::checks_update::body::json::Actions<'a>]>>,
251
252 #[serde(flatten)]
253 pub additionalProperties: ::std::collections::HashMap<::std::borrow::Cow<'a, str>, ::serde_json::value::Value>
254 }
255
256 pub mod json {
258 #[allow(non_snake_case)]
260 #[derive(Clone, Eq, PartialEq, Debug, Default, ::serde::Serialize, ::serde::Deserialize)]
261 pub struct Output<'a> {
262 #[serde(skip_serializing_if = "Option::is_none", default)]
264 pub title: ::std::option::Option<::std::borrow::Cow<'a, str>>,
265
266 pub summary: ::std::borrow::Cow<'a, str>,
268
269 #[serde(skip_serializing_if = "Option::is_none", default)]
271 pub text: ::std::option::Option<::std::borrow::Cow<'a, str>>,
272
273 #[serde(skip_serializing_if = "Option::is_none", default)]
275 pub annotations: ::std::option::Option<::std::borrow::Cow<'a, [crate::v1_1_4::request::checks_update::body::json::output::Annotations<'a>]>>,
276
277 #[serde(skip_serializing_if = "Option::is_none", default)]
279 pub images: ::std::option::Option<::std::borrow::Cow<'a, [crate::v1_1_4::request::checks_update::body::json::output::Images<'a>]>>,
280
281 #[serde(flatten)]
282 pub additionalProperties: ::std::collections::HashMap<::std::borrow::Cow<'a, str>, ::serde_json::value::Value>
283 }
284
285 pub mod output {
287 #[allow(non_snake_case)]
288 #[derive(Clone, Eq, PartialEq, Debug, Default, ::serde::Serialize, ::serde::Deserialize)]
289 pub struct Annotations<'a> {
290 pub path: ::std::borrow::Cow<'a, str>,
292
293 pub start_line: i64,
295
296 pub end_line: i64,
298
299 #[serde(skip_serializing_if = "Option::is_none", default)]
301 pub start_column: ::std::option::Option<i64>,
302
303 #[serde(skip_serializing_if = "Option::is_none", default)]
305 pub end_column: ::std::option::Option<i64>,
306
307 pub annotation_level: ::std::borrow::Cow<'a, str>,
309
310 pub message: ::std::borrow::Cow<'a, str>,
312
313 #[serde(skip_serializing_if = "Option::is_none", default)]
315 pub title: ::std::option::Option<::std::borrow::Cow<'a, str>>,
316
317 #[serde(skip_serializing_if = "Option::is_none", default)]
319 pub raw_details: ::std::option::Option<::std::borrow::Cow<'a, str>>,
320
321 #[serde(flatten)]
322 pub additionalProperties: ::std::collections::HashMap<::std::borrow::Cow<'a, str>, ::serde_json::value::Value>
323 }
324
325 #[allow(non_snake_case)]
326 #[derive(Clone, Eq, PartialEq, Debug, Default, ::serde::Serialize, ::serde::Deserialize)]
327 pub struct Images<'a> {
328 pub alt: ::std::borrow::Cow<'a, str>,
330
331 pub image_url: ::std::borrow::Cow<'a, str>,
333
334 #[serde(skip_serializing_if = "Option::is_none", default)]
336 pub caption: ::std::option::Option<::std::borrow::Cow<'a, str>>,
337
338 #[serde(flatten)]
339 pub additionalProperties: ::std::collections::HashMap<::std::borrow::Cow<'a, str>, ::serde_json::value::Value>
340 }
341 }
342
343 #[allow(non_snake_case)]
344 #[derive(Clone, Eq, PartialEq, Debug, Default, ::serde::Serialize, ::serde::Deserialize)]
345 pub struct Actions<'a> {
346 pub label: ::std::borrow::Cow<'a, str>,
348
349 pub description: ::std::borrow::Cow<'a, str>,
351
352 pub identifier: ::std::borrow::Cow<'a, str>,
354
355 #[serde(flatten)]
356 pub additionalProperties: ::std::collections::HashMap<::std::borrow::Cow<'a, str>, ::serde_json::value::Value>
357 }
358 }
359
360 #[cfg(feature = "hyper")]
361 impl<'a> TryFrom<&Json<'a>> for super::Content<::hyper::Body> {
362 type Error = crate::v1_1_4::ApiError;
363
364 fn try_from(value: &Json<'a>) -> Result<Self, Self::Error> {
365 Ok(
366 Self::new(::serde_json::to_vec(value)?.into())
367 .with_content_type(&b"application/json"[..])
368 )
369 }
370 }
371
372 #[cfg(feature = "reqwest")]
373 impl<'a> TryFrom<&Json<'a>> for super::Content<::reqwest::Body> {
374 type Error = crate::v1_1_4::ApiError;
375
376 fn try_from(value: &Json<'a>) -> Result<Self, Self::Error> {
377 Ok(
378 Self::new(::serde_json::to_vec(value)?.into())
379 .with_content_type(&b"application/json"[..])
380 )
381 }
382 }
383
384 #[cfg(feature = "reqwest-blocking")]
385 impl<'a> TryFrom<&Json<'a>> for super::Content<::reqwest::blocking::Body> {
386 type Error = crate::v1_1_4::ApiError;
387
388 fn try_from(value: &Json<'a>) -> Result<Self, Self::Error> {
389 Ok(
390 Self::new(::serde_json::to_vec(value)?.into())
391 .with_content_type(&b"application/json"[..])
392 )
393 }
394 }
395}