jinxapi_github/v1_1_4/request/
repos_list_commits.rs

1//! List commits
2//! 
3//! **Signature verification object**
4//! 
5//! The response will include a `verification` object that describes the result of verifying the commit's signature. The following fields are included in the `verification` object:
6//! 
7//! | Name | Type | Description |
8//! | ---- | ---- | ----------- |
9//! | `verified` | `boolean` | Indicates whether GitHub considers the signature in this commit to be verified. |
10//! | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in table below. |
11//! | `signature` | `string` | The signature that was extracted from the commit. |
12//! | `payload` | `string` | The value that was signed. |
13//! 
14//! These are the possible values for `reason` in the `verification` object:
15//! 
16//! | Value | Description |
17//! | ----- | ----------- |
18//! | `expired_key` | The key that made the signature is expired. |
19//! | `not_signing_key` | The "signing" flag is not among the usage flags in the GPG key that made the signature. |
20//! | `gpgverify_error` | There was an error communicating with the signature verification service. |
21//! | `gpgverify_unavailable` | The signature verification service is currently unavailable. |
22//! | `unsigned` | The object does not include a signature. |
23//! | `unknown_signature_type` | A non-PGP signature was found in the commit. |
24//! | `no_user` | No user was associated with the `committer` email address in the commit. |
25//! | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on her/his account. |
26//! | `bad_email` | The `committer` email address in the commit is not included in the identities of the PGP key that made the signature. |
27//! | `unknown_key` | The key that made the signature has not been registered with any user's account. |
28//! | `malformed_signature` | There was an error parsing the signature. |
29//! | `invalid` | The signature could not be cryptographically verified using the key whose key-id was found in the signature. |
30//! | `valid` | None of the above errors applied, so the signature is considered to be verified. |
31//! 
32//! [API method documentation](https://docs.github.com/rest/reference/repos#list-commits)
33
34
35#[allow(clippy::too_many_arguments)]
36fn url_string(
37    base_url: &str,
38    p_owner: &str,
39    p_repo: &str,
40    q_sha: ::std::option::Option<&str>,
41    q_path: ::std::option::Option<&str>,
42    q_author: ::std::option::Option<&str>,
43    q_since: ::std::option::Option<&str>,
44    q_until: ::std::option::Option<&str>,
45    q_per_page: ::std::option::Option<i64>,
46    q_page: ::std::option::Option<i64>,
47) -> Result<String, crate::v1_1_4::ApiError> {
48    let trimmed = if base_url.is_empty() {
49        "https://api.github.com"
50    } else {
51        base_url.trim_end_matches('/')
52    };
53    let mut url = String::with_capacity(trimmed.len() + 34);
54    url.push_str(trimmed);
55    url.push_str("/repos/");
56    ::querylizer::Simple::extend(&mut url, &p_owner, false, &::querylizer::encode_path)?;
57    url.push('/');
58    ::querylizer::Simple::extend(&mut url, &p_repo, false, &::querylizer::encode_path)?;
59    url.push_str("/commits");
60    let mut prefix = '?';
61    if let Some(value) = &q_sha {
62        url.push(::std::mem::replace(&mut prefix, '&'));
63        ::querylizer::Form::extend(&mut url, "sha", value, false, &::querylizer::encode_query)?;
64    }
65    if let Some(value) = &q_path {
66        url.push(::std::mem::replace(&mut prefix, '&'));
67        ::querylizer::Form::extend(&mut url, "path", value, false, &::querylizer::encode_query)?;
68    }
69    if let Some(value) = &q_author {
70        url.push(::std::mem::replace(&mut prefix, '&'));
71        ::querylizer::Form::extend(&mut url, "author", value, false, &::querylizer::encode_query)?;
72    }
73    if let Some(value) = &q_since {
74        url.push(::std::mem::replace(&mut prefix, '&'));
75        ::querylizer::Form::extend(&mut url, "since", value, false, &::querylizer::encode_query)?;
76    }
77    if let Some(value) = &q_until {
78        url.push(::std::mem::replace(&mut prefix, '&'));
79        ::querylizer::Form::extend(&mut url, "until", value, false, &::querylizer::encode_query)?;
80    }
81    if let Some(value) = &q_per_page {
82        url.push(::std::mem::replace(&mut prefix, '&'));
83        ::querylizer::Form::extend(&mut url, "per_page", value, false, &::querylizer::encode_query)?;
84    }
85    if let Some(value) = &q_page {
86        url.push(::std::mem::replace(&mut prefix, '&'));
87        ::querylizer::Form::extend(&mut url, "page", value, false, &::querylizer::encode_query)?;
88    }
89    Ok(url)
90}
91
92#[cfg(feature = "hyper")]
93#[allow(clippy::too_many_arguments)]
94pub fn http_builder(
95    base_url: &str,
96    p_owner: &str,
97    p_repo: &str,
98    q_sha: ::std::option::Option<&str>,
99    q_path: ::std::option::Option<&str>,
100    q_author: ::std::option::Option<&str>,
101    q_since: ::std::option::Option<&str>,
102    q_until: ::std::option::Option<&str>,
103    q_per_page: ::std::option::Option<i64>,
104    q_page: ::std::option::Option<i64>,
105    h_user_agent: &str,
106    h_accept: ::std::option::Option<&str>,
107) -> Result<::http::request::Builder, crate::v1_1_4::ApiError> {
108    let url = url_string(
109        base_url,
110        p_owner,
111        p_repo,
112        q_sha,
113        q_path,
114        q_author,
115        q_since,
116        q_until,
117        q_per_page,
118        q_page,
119    )?;
120    let mut builder = ::http::request::Request::get(url);
121    builder = builder.header(
122        "User-Agent",
123        &::querylizer::Simple::to_string(&h_user_agent, false, &::querylizer::passthrough)?
124    );
125    if let Some(value) = &h_accept {
126        builder = builder.header(
127            "Accept",
128            &::querylizer::Simple::to_string(value, false, &::querylizer::passthrough)?
129        );
130    }
131    Ok(builder)
132}
133
134#[cfg(feature = "hyper")]
135#[inline]
136pub fn hyper_request(
137    builder: ::http::request::Builder,
138) -> Result<::http::request::Request<::hyper::Body>, crate::v1_1_4::ApiError> {
139    Ok(builder.body(::hyper::Body::empty())?)
140}
141
142#[cfg(feature = "reqwest")]
143#[allow(clippy::too_many_arguments)]
144pub fn reqwest_builder(
145    base_url: &str,
146    p_owner: &str,
147    p_repo: &str,
148    q_sha: ::std::option::Option<&str>,
149    q_path: ::std::option::Option<&str>,
150    q_author: ::std::option::Option<&str>,
151    q_since: ::std::option::Option<&str>,
152    q_until: ::std::option::Option<&str>,
153    q_per_page: ::std::option::Option<i64>,
154    q_page: ::std::option::Option<i64>,
155    h_user_agent: &str,
156    h_accept: ::std::option::Option<&str>,
157) -> Result<::reqwest::Request, crate::v1_1_4::ApiError> {
158    let url = url_string(
159        base_url,
160        p_owner,
161        p_repo,
162        q_sha,
163        q_path,
164        q_author,
165        q_since,
166        q_until,
167        q_per_page,
168        q_page,
169    )?;
170    let reqwest_url = ::reqwest::Url::parse(&url)?;
171    let mut request = ::reqwest::Request::new(::reqwest::Method::GET, reqwest_url);
172    let headers = request.headers_mut();
173    headers.append(
174        "User-Agent",
175        ::querylizer::Simple::to_string(&h_user_agent, false, &::querylizer::passthrough)?.try_into()?
176    );
177    if let Some(value) = &h_accept {
178        headers.append(
179            "Accept",
180            ::querylizer::Simple::to_string(value, false, &::querylizer::passthrough)?.try_into()?
181        );
182    }
183    Ok(request)
184}
185
186#[cfg(feature = "reqwest")]
187#[inline(always)]
188pub fn reqwest_request(
189    builder: ::reqwest::Request,
190) -> Result<::reqwest::Request, crate::v1_1_4::ApiError>
191{
192    Ok(builder)
193}
194
195#[cfg(feature = "reqwest-blocking")]
196#[allow(clippy::too_many_arguments)]
197pub fn reqwest_blocking_builder(
198    base_url: &str,
199    p_owner: &str,
200    p_repo: &str,
201    q_sha: ::std::option::Option<&str>,
202    q_path: ::std::option::Option<&str>,
203    q_author: ::std::option::Option<&str>,
204    q_since: ::std::option::Option<&str>,
205    q_until: ::std::option::Option<&str>,
206    q_per_page: ::std::option::Option<i64>,
207    q_page: ::std::option::Option<i64>,
208    h_user_agent: &str,
209    h_accept: ::std::option::Option<&str>,
210) -> Result<::reqwest::blocking::Request, crate::v1_1_4::ApiError> {
211    let url = url_string(
212        base_url,
213        p_owner,
214        p_repo,
215        q_sha,
216        q_path,
217        q_author,
218        q_since,
219        q_until,
220        q_per_page,
221        q_page,
222    )?;
223    let reqwest_url = ::reqwest::Url::parse(&url)?;
224    let mut request = ::reqwest::blocking::Request::new(::reqwest::Method::GET, reqwest_url);
225    let headers = request.headers_mut();
226    headers.append(
227        "User-Agent",
228        ::querylizer::Simple::to_string(&h_user_agent, false, &::querylizer::passthrough)?.try_into()?
229    );
230    if let Some(value) = &h_accept {
231        headers.append(
232            "Accept",
233            ::querylizer::Simple::to_string(value, false, &::querylizer::passthrough)?.try_into()?
234        );
235    }
236    Ok(request)
237}
238
239#[cfg(feature = "reqwest-blocking")]
240#[inline(always)]
241pub fn reqwest_blocking_request(
242    builder: ::reqwest::blocking::Request,
243) -> Result<::reqwest::blocking::Request, crate::v1_1_4::ApiError>
244{
245    Ok(builder)
246}