Rust API for Gitea, automatically generated https://git.exmods.org/swagger.v1.json
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

8420 lines
329KB

  1. /*
  2. * Gitea API.
  3. *
  4. * This documentation describes the Gitea API.
  5. *
  6. * OpenAPI spec version: 1.1.1
  7. *
  8. * Generated by: https://github.com/swagger-api/swagger-codegen.git
  9. */
  10. use std::rc::Rc;
  11. use std::borrow::Borrow;
  12. use std::borrow::Cow;
  13. use std::collections::HashMap;
  14. use hyper;
  15. use serde_json;
  16. use futures;
  17. use futures::{Future, Stream};
  18. use hyper::header::UserAgent;
  19. use super::{Error, configuration};
  20. pub struct RepositoryApiClient<C: hyper::client::Connect> {
  21. configuration: Rc<configuration::Configuration<C>>,
  22. }
  23. impl<C: hyper::client::Connect> RepositoryApiClient<C> {
  24. pub fn new(configuration: Rc<configuration::Configuration<C>>) -> RepositoryApiClient<C> {
  25. RepositoryApiClient {
  26. configuration: configuration,
  27. }
  28. }
  29. }
  30. pub trait RepositoryApi {
  31. fn create_current_user_repo(&self, body: ::models::CreateRepoOption) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>>;
  32. fn create_fork(&self, owner: &str, repo: &str, body: ::models::CreateForkOption) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>>;
  33. fn get_blob(&self, owner: &str, repo: &str, sha: &str) -> Box<Future<Item = ::models::GitBlobResponse, Error = Error<serde_json::Value>>>;
  34. fn get_tag(&self, owner: &str, repo: &str, sha: &str) -> Box<Future<Item = ::models::AnnotatedTag, Error = Error<serde_json::Value>>>;
  35. fn get_tree(&self, owner: &str, repo: &str, sha: &str, recursive: bool, page: i32, per_page: i32) -> Box<Future<Item = ::models::GitTreeResponse, Error = Error<serde_json::Value>>>;
  36. fn list_forks(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Repository>, Error = Error<serde_json::Value>>>;
  37. fn repo_add_collaborator(&self, owner: &str, repo: &str, collaborator: &str, body: ::models::AddCollaboratorOption) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  38. fn repo_add_topc(&self, owner: &str, repo: &str, topic: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  39. fn repo_check_collaborator(&self, owner: &str, repo: &str, collaborator: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  40. fn repo_create_file(&self, owner: &str, repo: &str, filepath: &str, body: ::models::CreateFileOptions) -> Box<Future<Item = ::models::FileResponse, Error = Error<serde_json::Value>>>;
  41. fn repo_create_hook(&self, owner: &str, repo: &str, body: ::models::CreateHookOption) -> Box<Future<Item = ::models::Hook, Error = Error<serde_json::Value>>>;
  42. fn repo_create_key(&self, owner: &str, repo: &str, body: ::models::CreateKeyOption) -> Box<Future<Item = ::models::DeployKey, Error = Error<serde_json::Value>>>;
  43. fn repo_create_pull_request(&self, owner: &str, repo: &str, body: ::models::CreatePullRequestOption) -> Box<Future<Item = ::models::PullRequest, Error = Error<serde_json::Value>>>;
  44. fn repo_create_release(&self, owner: &str, repo: &str, body: ::models::CreateReleaseOption) -> Box<Future<Item = ::models::Release, Error = Error<serde_json::Value>>>;
  45. fn repo_create_release_attachment(&self, owner: &str, repo: &str, id: i64, attachment: ::models::File, name: &str) -> Box<Future<Item = ::models::Attachment, Error = Error<serde_json::Value>>>;
  46. fn repo_create_status(&self, owner: &str, repo: &str, sha: &str, body: ::models::CreateStatusOption) -> Box<Future<Item = ::models::Status, Error = Error<serde_json::Value>>>;
  47. fn repo_delete(&self, owner: &str, repo: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  48. fn repo_delete_collaborator(&self, owner: &str, repo: &str, collaborator: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  49. fn repo_delete_file(&self, owner: &str, repo: &str, filepath: &str, body: ::models::DeleteFileOptions) -> Box<Future<Item = ::models::FileDeleteResponse, Error = Error<serde_json::Value>>>;
  50. fn repo_delete_git_hook(&self, owner: &str, repo: &str, id: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  51. fn repo_delete_hook(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  52. fn repo_delete_key(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  53. fn repo_delete_release(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  54. fn repo_delete_release_attachment(&self, owner: &str, repo: &str, id: i64, attachment_id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  55. fn repo_delete_topic(&self, owner: &str, repo: &str, topic: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  56. fn repo_edit(&self, owner: &str, repo: &str, body: ::models::EditRepoOption) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>>;
  57. fn repo_edit_git_hook(&self, owner: &str, repo: &str, id: &str, body: ::models::EditGitHookOption) -> Box<Future<Item = ::models::GitHook, Error = Error<serde_json::Value>>>;
  58. fn repo_edit_hook(&self, owner: &str, repo: &str, id: i64, body: ::models::EditHookOption) -> Box<Future<Item = ::models::Hook, Error = Error<serde_json::Value>>>;
  59. fn repo_edit_pull_request(&self, owner: &str, repo: &str, index: i64, body: ::models::EditPullRequestOption) -> Box<Future<Item = ::models::PullRequest, Error = Error<serde_json::Value>>>;
  60. fn repo_edit_release(&self, owner: &str, repo: &str, id: i64, body: ::models::EditReleaseOption) -> Box<Future<Item = ::models::Release, Error = Error<serde_json::Value>>>;
  61. fn repo_edit_release_attachment(&self, owner: &str, repo: &str, id: i64, attachment_id: i64, body: ::models::EditAttachmentOptions) -> Box<Future<Item = ::models::Attachment, Error = Error<serde_json::Value>>>;
  62. fn repo_get(&self, owner: &str, repo: &str) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>>;
  63. fn repo_get_all_commits(&self, owner: &str, repo: &str, sha: &str, page: i32) -> Box<Future<Item = Vec<::models::Commit>, Error = Error<serde_json::Value>>>;
  64. fn repo_get_archive(&self, owner: &str, repo: &str, archive: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  65. fn repo_get_branch(&self, owner: &str, repo: &str, branch: &str) -> Box<Future<Item = ::models::Branch, Error = Error<serde_json::Value>>>;
  66. fn repo_get_by_id(&self, id: i64) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>>;
  67. fn repo_get_combined_status_by_ref(&self, owner: &str, repo: &str, _ref: &str, page: i32) -> Box<Future<Item = ::models::Status, Error = Error<serde_json::Value>>>;
  68. fn repo_get_contents(&self, owner: &str, repo: &str, filepath: &str, _ref: &str) -> Box<Future<Item = ::models::ContentsResponse, Error = Error<serde_json::Value>>>;
  69. fn repo_get_contents_list(&self, owner: &str, repo: &str, _ref: &str) -> Box<Future<Item = Vec<::models::ContentsResponse>, Error = Error<serde_json::Value>>>;
  70. fn repo_get_editor_config(&self, owner: &str, repo: &str, filepath: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  71. fn repo_get_git_hook(&self, owner: &str, repo: &str, id: &str) -> Box<Future<Item = ::models::GitHook, Error = Error<serde_json::Value>>>;
  72. fn repo_get_hook(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = ::models::Hook, Error = Error<serde_json::Value>>>;
  73. fn repo_get_key(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = ::models::DeployKey, Error = Error<serde_json::Value>>>;
  74. fn repo_get_pull_request(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = ::models::PullRequest, Error = Error<serde_json::Value>>>;
  75. fn repo_get_raw_file(&self, owner: &str, repo: &str, filepath: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  76. fn repo_get_release(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = ::models::Release, Error = Error<serde_json::Value>>>;
  77. fn repo_get_release_attachment(&self, owner: &str, repo: &str, id: i64, attachment_id: i64) -> Box<Future<Item = ::models::Attachment, Error = Error<serde_json::Value>>>;
  78. fn repo_get_single_commit(&self, owner: &str, repo: &str, sha: &str) -> Box<Future<Item = ::models::Commit, Error = Error<serde_json::Value>>>;
  79. fn repo_list_all_git_refs(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Reference>, Error = Error<serde_json::Value>>>;
  80. fn repo_list_branches(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Branch>, Error = Error<serde_json::Value>>>;
  81. fn repo_list_collaborators(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>>;
  82. fn repo_list_git_hooks(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::GitHook>, Error = Error<serde_json::Value>>>;
  83. fn repo_list_git_refs(&self, owner: &str, repo: &str, _ref: &str) -> Box<Future<Item = Vec<::models::Reference>, Error = Error<serde_json::Value>>>;
  84. fn repo_list_hooks(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Hook>, Error = Error<serde_json::Value>>>;
  85. fn repo_list_keys(&self, owner: &str, repo: &str, key_id: i32, fingerprint: &str) -> Box<Future<Item = Vec<::models::DeployKey>, Error = Error<serde_json::Value>>>;
  86. fn repo_list_pull_requests(&self, owner: &str, repo: &str, page: i32, state: &str, sort: &str, milestone: i64, labels: Vec<i64>) -> Box<Future<Item = Vec<::models::PullRequest>, Error = Error<serde_json::Value>>>;
  87. fn repo_list_release_attachments(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = Vec<::models::Attachment>, Error = Error<serde_json::Value>>>;
  88. fn repo_list_releases(&self, owner: &str, repo: &str, page: i32, per_page: i32) -> Box<Future<Item = Vec<::models::Release>, Error = Error<serde_json::Value>>>;
  89. fn repo_list_stargazers(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>>;
  90. fn repo_list_statuses(&self, owner: &str, repo: &str, sha: &str, page: i32, sort: &str, state: &str) -> Box<Future<Item = Vec<::models::Status>, Error = Error<serde_json::Value>>>;
  91. fn repo_list_subscribers(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>>;
  92. fn repo_list_tags(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Tag>, Error = Error<serde_json::Value>>>;
  93. fn repo_list_topics(&self, owner: &str, repo: &str) -> Box<Future<Item = ::models::TopicName, Error = Error<serde_json::Value>>>;
  94. fn repo_merge_pull_request(&self, owner: &str, repo: &str, index: i64, body: ::models::MergePullRequestOption) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  95. fn repo_migrate(&self, body: ::models::MigrateRepoForm) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>>;
  96. fn repo_mirror_sync(&self, owner: &str, repo: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  97. fn repo_pull_request_is_merged(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  98. fn repo_search(&self, q: &str, topic: bool, include_desc: bool, uid: i64, priority_owner_id: i64, starred_by: i64, private: bool, template: bool, page: i32, limit: i32, mode: &str, exclusive: bool, sort: &str, order: &str) -> Box<Future<Item = ::models::SearchResults, Error = Error<serde_json::Value>>>;
  99. fn repo_signing_key(&self, owner: &str, repo: &str) -> Box<Future<Item = String, Error = Error<serde_json::Value>>>;
  100. fn repo_test_hook(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  101. fn repo_tracked_times(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::TrackedTime>, Error = Error<serde_json::Value>>>;
  102. fn repo_update_file(&self, owner: &str, repo: &str, filepath: &str, body: ::models::UpdateFileOptions) -> Box<Future<Item = ::models::FileResponse, Error = Error<serde_json::Value>>>;
  103. fn repo_update_topics(&self, owner: &str, repo: &str, body: ::models::RepoTopicOptions) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  104. fn topic_search(&self, q: &str) -> Box<Future<Item = Vec<::models::TopicResponse>, Error = Error<serde_json::Value>>>;
  105. fn user_current_check_subscription(&self, owner: &str, repo: &str) -> Box<Future<Item = ::models::WatchInfo, Error = Error<serde_json::Value>>>;
  106. fn user_current_delete_subscription(&self, owner: &str, repo: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  107. fn user_current_put_subscription(&self, owner: &str, repo: &str) -> Box<Future<Item = ::models::WatchInfo, Error = Error<serde_json::Value>>>;
  108. }
  109. impl<C: hyper::client::Connect>RepositoryApi for RepositoryApiClient<C> {
  110. fn create_current_user_repo(&self, body: ::models::CreateRepoOption) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>> {
  111. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  112. let mut auth_headers = HashMap::<String, String>::new();
  113. let mut auth_query = HashMap::<String, String>::new();
  114. if let Some(ref apikey) = configuration.api_key {
  115. let key = apikey.key.clone();
  116. let val = match apikey.prefix {
  117. Some(ref prefix) => format!("{} {}", prefix, key),
  118. None => key,
  119. };
  120. auth_query.insert("access_token".to_owned(), val);
  121. };
  122. if let Some(ref apikey) = configuration.api_key {
  123. let key = apikey.key.clone();
  124. let val = match apikey.prefix {
  125. Some(ref prefix) => format!("{} {}", prefix, key),
  126. None => key,
  127. };
  128. auth_headers.insert("Authorization".to_owned(), val);
  129. };
  130. if let Some(ref auth_conf) = configuration.basic_auth {
  131. let auth = hyper::header::Authorization(
  132. hyper::header::Basic {
  133. username: auth_conf.0.to_owned(),
  134. password: auth_conf.1.to_owned(),
  135. }
  136. );
  137. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  138. };
  139. if let Some(ref apikey) = configuration.api_key {
  140. let key = apikey.key.clone();
  141. let val = match apikey.prefix {
  142. Some(ref prefix) => format!("{} {}", prefix, key),
  143. None => key,
  144. };
  145. auth_headers.insert("Sudo".to_owned(), val);
  146. };
  147. if let Some(ref apikey) = configuration.api_key {
  148. let key = apikey.key.clone();
  149. let val = match apikey.prefix {
  150. Some(ref prefix) => format!("{} {}", prefix, key),
  151. None => key,
  152. };
  153. auth_query.insert("sudo".to_owned(), val);
  154. };
  155. if let Some(ref apikey) = configuration.api_key {
  156. let key = apikey.key.clone();
  157. let val = match apikey.prefix {
  158. Some(ref prefix) => format!("{} {}", prefix, key),
  159. None => key,
  160. };
  161. auth_query.insert("token".to_owned(), val);
  162. };
  163. let method = hyper::Method::Post;
  164. let query_string = {
  165. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  166. for (key, val) in &auth_query {
  167. query.append_pair(key, val);
  168. }
  169. query.finish()
  170. };
  171. let uri_str = format!("{}/user/repos?{}", configuration.base_path, query_string);
  172. // TODO(farcaller): handle error
  173. // if let Err(e) = uri {
  174. // return Box::new(futures::future::err(e));
  175. // }
  176. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  177. let mut req = hyper::Request::new(method, uri);
  178. if let Some(ref user_agent) = configuration.user_agent {
  179. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  180. }
  181. for (key, val) in auth_headers {
  182. req.headers_mut().set_raw(key, val);
  183. }
  184. let serialized = serde_json::to_string(&body).unwrap();
  185. req.headers_mut().set(hyper::header::ContentType::json());
  186. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  187. req.set_body(serialized);
  188. // send request
  189. Box::new(
  190. configuration.client.request(req)
  191. .map_err(|e| Error::from(e))
  192. .and_then(|resp| {
  193. let status = resp.status();
  194. resp.body().concat2()
  195. .and_then(move |body| Ok((status, body)))
  196. .map_err(|e| Error::from(e))
  197. })
  198. .and_then(|(status, body)| {
  199. if status.is_success() {
  200. Ok(body)
  201. } else {
  202. Err(Error::from((status, &*body)))
  203. }
  204. })
  205. .and_then(|body| {
  206. let parsed: Result<::models::Repository, _> = serde_json::from_slice(&body);
  207. parsed.map_err(|e| Error::from(e))
  208. })
  209. )
  210. }
  211. fn create_fork(&self, owner: &str, repo: &str, body: ::models::CreateForkOption) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>> {
  212. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  213. let mut auth_headers = HashMap::<String, String>::new();
  214. let mut auth_query = HashMap::<String, String>::new();
  215. if let Some(ref apikey) = configuration.api_key {
  216. let key = apikey.key.clone();
  217. let val = match apikey.prefix {
  218. Some(ref prefix) => format!("{} {}", prefix, key),
  219. None => key,
  220. };
  221. auth_query.insert("access_token".to_owned(), val);
  222. };
  223. if let Some(ref apikey) = configuration.api_key {
  224. let key = apikey.key.clone();
  225. let val = match apikey.prefix {
  226. Some(ref prefix) => format!("{} {}", prefix, key),
  227. None => key,
  228. };
  229. auth_headers.insert("Authorization".to_owned(), val);
  230. };
  231. if let Some(ref auth_conf) = configuration.basic_auth {
  232. let auth = hyper::header::Authorization(
  233. hyper::header::Basic {
  234. username: auth_conf.0.to_owned(),
  235. password: auth_conf.1.to_owned(),
  236. }
  237. );
  238. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  239. };
  240. if let Some(ref apikey) = configuration.api_key {
  241. let key = apikey.key.clone();
  242. let val = match apikey.prefix {
  243. Some(ref prefix) => format!("{} {}", prefix, key),
  244. None => key,
  245. };
  246. auth_headers.insert("Sudo".to_owned(), val);
  247. };
  248. if let Some(ref apikey) = configuration.api_key {
  249. let key = apikey.key.clone();
  250. let val = match apikey.prefix {
  251. Some(ref prefix) => format!("{} {}", prefix, key),
  252. None => key,
  253. };
  254. auth_query.insert("sudo".to_owned(), val);
  255. };
  256. if let Some(ref apikey) = configuration.api_key {
  257. let key = apikey.key.clone();
  258. let val = match apikey.prefix {
  259. Some(ref prefix) => format!("{} {}", prefix, key),
  260. None => key,
  261. };
  262. auth_query.insert("token".to_owned(), val);
  263. };
  264. let method = hyper::Method::Post;
  265. let query_string = {
  266. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  267. for (key, val) in &auth_query {
  268. query.append_pair(key, val);
  269. }
  270. query.finish()
  271. };
  272. let uri_str = format!("{}/repos/{owner}/{repo}/forks?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  273. // TODO(farcaller): handle error
  274. // if let Err(e) = uri {
  275. // return Box::new(futures::future::err(e));
  276. // }
  277. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  278. let mut req = hyper::Request::new(method, uri);
  279. if let Some(ref user_agent) = configuration.user_agent {
  280. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  281. }
  282. for (key, val) in auth_headers {
  283. req.headers_mut().set_raw(key, val);
  284. }
  285. let serialized = serde_json::to_string(&body).unwrap();
  286. req.headers_mut().set(hyper::header::ContentType::json());
  287. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  288. req.set_body(serialized);
  289. // send request
  290. Box::new(
  291. configuration.client.request(req)
  292. .map_err(|e| Error::from(e))
  293. .and_then(|resp| {
  294. let status = resp.status();
  295. resp.body().concat2()
  296. .and_then(move |body| Ok((status, body)))
  297. .map_err(|e| Error::from(e))
  298. })
  299. .and_then(|(status, body)| {
  300. if status.is_success() {
  301. Ok(body)
  302. } else {
  303. Err(Error::from((status, &*body)))
  304. }
  305. })
  306. .and_then(|body| {
  307. let parsed: Result<::models::Repository, _> = serde_json::from_slice(&body);
  308. parsed.map_err(|e| Error::from(e))
  309. })
  310. )
  311. }
  312. fn get_blob(&self, owner: &str, repo: &str, sha: &str) -> Box<Future<Item = ::models::GitBlobResponse, Error = Error<serde_json::Value>>> {
  313. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  314. let mut auth_headers = HashMap::<String, String>::new();
  315. let mut auth_query = HashMap::<String, String>::new();
  316. if let Some(ref apikey) = configuration.api_key {
  317. let key = apikey.key.clone();
  318. let val = match apikey.prefix {
  319. Some(ref prefix) => format!("{} {}", prefix, key),
  320. None => key,
  321. };
  322. auth_query.insert("access_token".to_owned(), val);
  323. };
  324. if let Some(ref apikey) = configuration.api_key {
  325. let key = apikey.key.clone();
  326. let val = match apikey.prefix {
  327. Some(ref prefix) => format!("{} {}", prefix, key),
  328. None => key,
  329. };
  330. auth_headers.insert("Authorization".to_owned(), val);
  331. };
  332. if let Some(ref auth_conf) = configuration.basic_auth {
  333. let auth = hyper::header::Authorization(
  334. hyper::header::Basic {
  335. username: auth_conf.0.to_owned(),
  336. password: auth_conf.1.to_owned(),
  337. }
  338. );
  339. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  340. };
  341. if let Some(ref apikey) = configuration.api_key {
  342. let key = apikey.key.clone();
  343. let val = match apikey.prefix {
  344. Some(ref prefix) => format!("{} {}", prefix, key),
  345. None => key,
  346. };
  347. auth_headers.insert("Sudo".to_owned(), val);
  348. };
  349. if let Some(ref apikey) = configuration.api_key {
  350. let key = apikey.key.clone();
  351. let val = match apikey.prefix {
  352. Some(ref prefix) => format!("{} {}", prefix, key),
  353. None => key,
  354. };
  355. auth_query.insert("sudo".to_owned(), val);
  356. };
  357. if let Some(ref apikey) = configuration.api_key {
  358. let key = apikey.key.clone();
  359. let val = match apikey.prefix {
  360. Some(ref prefix) => format!("{} {}", prefix, key),
  361. None => key,
  362. };
  363. auth_query.insert("token".to_owned(), val);
  364. };
  365. let method = hyper::Method::Get;
  366. let query_string = {
  367. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  368. for (key, val) in &auth_query {
  369. query.append_pair(key, val);
  370. }
  371. query.finish()
  372. };
  373. let uri_str = format!("{}/repos/{owner}/{repo}/git/blobs/{sha}?{}", configuration.base_path, query_string, owner=owner, repo=repo, sha=sha);
  374. // TODO(farcaller): handle error
  375. // if let Err(e) = uri {
  376. // return Box::new(futures::future::err(e));
  377. // }
  378. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  379. let mut req = hyper::Request::new(method, uri);
  380. if let Some(ref user_agent) = configuration.user_agent {
  381. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  382. }
  383. for (key, val) in auth_headers {
  384. req.headers_mut().set_raw(key, val);
  385. }
  386. // send request
  387. Box::new(
  388. configuration.client.request(req)
  389. .map_err(|e| Error::from(e))
  390. .and_then(|resp| {
  391. let status = resp.status();
  392. resp.body().concat2()
  393. .and_then(move |body| Ok((status, body)))
  394. .map_err(|e| Error::from(e))
  395. })
  396. .and_then(|(status, body)| {
  397. if status.is_success() {
  398. Ok(body)
  399. } else {
  400. Err(Error::from((status, &*body)))
  401. }
  402. })
  403. .and_then(|body| {
  404. let parsed: Result<::models::GitBlobResponse, _> = serde_json::from_slice(&body);
  405. parsed.map_err(|e| Error::from(e))
  406. })
  407. )
  408. }
  409. fn get_tag(&self, owner: &str, repo: &str, sha: &str) -> Box<Future<Item = ::models::AnnotatedTag, Error = Error<serde_json::Value>>> {
  410. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  411. let mut auth_headers = HashMap::<String, String>::new();
  412. let mut auth_query = HashMap::<String, String>::new();
  413. if let Some(ref apikey) = configuration.api_key {
  414. let key = apikey.key.clone();
  415. let val = match apikey.prefix {
  416. Some(ref prefix) => format!("{} {}", prefix, key),
  417. None => key,
  418. };
  419. auth_query.insert("access_token".to_owned(), val);
  420. };
  421. if let Some(ref apikey) = configuration.api_key {
  422. let key = apikey.key.clone();
  423. let val = match apikey.prefix {
  424. Some(ref prefix) => format!("{} {}", prefix, key),
  425. None => key,
  426. };
  427. auth_headers.insert("Authorization".to_owned(), val);
  428. };
  429. if let Some(ref auth_conf) = configuration.basic_auth {
  430. let auth = hyper::header::Authorization(
  431. hyper::header::Basic {
  432. username: auth_conf.0.to_owned(),
  433. password: auth_conf.1.to_owned(),
  434. }
  435. );
  436. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  437. };
  438. if let Some(ref apikey) = configuration.api_key {
  439. let key = apikey.key.clone();
  440. let val = match apikey.prefix {
  441. Some(ref prefix) => format!("{} {}", prefix, key),
  442. None => key,
  443. };
  444. auth_headers.insert("Sudo".to_owned(), val);
  445. };
  446. if let Some(ref apikey) = configuration.api_key {
  447. let key = apikey.key.clone();
  448. let val = match apikey.prefix {
  449. Some(ref prefix) => format!("{} {}", prefix, key),
  450. None => key,
  451. };
  452. auth_query.insert("sudo".to_owned(), val);
  453. };
  454. if let Some(ref apikey) = configuration.api_key {
  455. let key = apikey.key.clone();
  456. let val = match apikey.prefix {
  457. Some(ref prefix) => format!("{} {}", prefix, key),
  458. None => key,
  459. };
  460. auth_query.insert("token".to_owned(), val);
  461. };
  462. let method = hyper::Method::Get;
  463. let query_string = {
  464. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  465. for (key, val) in &auth_query {
  466. query.append_pair(key, val);
  467. }
  468. query.finish()
  469. };
  470. let uri_str = format!("{}/repos/{owner}/{repo}/git/tags/{sha}?{}", configuration.base_path, query_string, owner=owner, repo=repo, sha=sha);
  471. // TODO(farcaller): handle error
  472. // if let Err(e) = uri {
  473. // return Box::new(futures::future::err(e));
  474. // }
  475. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  476. let mut req = hyper::Request::new(method, uri);
  477. if let Some(ref user_agent) = configuration.user_agent {
  478. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  479. }
  480. for (key, val) in auth_headers {
  481. req.headers_mut().set_raw(key, val);
  482. }
  483. // send request
  484. Box::new(
  485. configuration.client.request(req)
  486. .map_err(|e| Error::from(e))
  487. .and_then(|resp| {
  488. let status = resp.status();
  489. resp.body().concat2()
  490. .and_then(move |body| Ok((status, body)))
  491. .map_err(|e| Error::from(e))
  492. })
  493. .and_then(|(status, body)| {
  494. if status.is_success() {
  495. Ok(body)
  496. } else {
  497. Err(Error::from((status, &*body)))
  498. }
  499. })
  500. .and_then(|body| {
  501. let parsed: Result<::models::AnnotatedTag, _> = serde_json::from_slice(&body);
  502. parsed.map_err(|e| Error::from(e))
  503. })
  504. )
  505. }
  506. fn get_tree(&self, owner: &str, repo: &str, sha: &str, recursive: bool, page: i32, per_page: i32) -> Box<Future<Item = ::models::GitTreeResponse, Error = Error<serde_json::Value>>> {
  507. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  508. let mut auth_headers = HashMap::<String, String>::new();
  509. let mut auth_query = HashMap::<String, String>::new();
  510. if let Some(ref apikey) = configuration.api_key {
  511. let key = apikey.key.clone();
  512. let val = match apikey.prefix {
  513. Some(ref prefix) => format!("{} {}", prefix, key),
  514. None => key,
  515. };
  516. auth_query.insert("access_token".to_owned(), val);
  517. };
  518. if let Some(ref apikey) = configuration.api_key {
  519. let key = apikey.key.clone();
  520. let val = match apikey.prefix {
  521. Some(ref prefix) => format!("{} {}", prefix, key),
  522. None => key,
  523. };
  524. auth_headers.insert("Authorization".to_owned(), val);
  525. };
  526. if let Some(ref auth_conf) = configuration.basic_auth {
  527. let auth = hyper::header::Authorization(
  528. hyper::header::Basic {
  529. username: auth_conf.0.to_owned(),
  530. password: auth_conf.1.to_owned(),
  531. }
  532. );
  533. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  534. };
  535. if let Some(ref apikey) = configuration.api_key {
  536. let key = apikey.key.clone();
  537. let val = match apikey.prefix {
  538. Some(ref prefix) => format!("{} {}", prefix, key),
  539. None => key,
  540. };
  541. auth_headers.insert("Sudo".to_owned(), val);
  542. };
  543. if let Some(ref apikey) = configuration.api_key {
  544. let key = apikey.key.clone();
  545. let val = match apikey.prefix {
  546. Some(ref prefix) => format!("{} {}", prefix, key),
  547. None => key,
  548. };
  549. auth_query.insert("sudo".to_owned(), val);
  550. };
  551. if let Some(ref apikey) = configuration.api_key {
  552. let key = apikey.key.clone();
  553. let val = match apikey.prefix {
  554. Some(ref prefix) => format!("{} {}", prefix, key),
  555. None => key,
  556. };
  557. auth_query.insert("token".to_owned(), val);
  558. };
  559. let method = hyper::Method::Get;
  560. let query_string = {
  561. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  562. query.append_pair("recursive", &recursive.to_string());
  563. query.append_pair("page", &page.to_string());
  564. query.append_pair("per_page", &per_page.to_string());
  565. for (key, val) in &auth_query {
  566. query.append_pair(key, val);
  567. }
  568. query.finish()
  569. };
  570. let uri_str = format!("{}/repos/{owner}/{repo}/git/trees/{sha}?{}", configuration.base_path, query_string, owner=owner, repo=repo, sha=sha);
  571. // TODO(farcaller): handle error
  572. // if let Err(e) = uri {
  573. // return Box::new(futures::future::err(e));
  574. // }
  575. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  576. let mut req = hyper::Request::new(method, uri);
  577. if let Some(ref user_agent) = configuration.user_agent {
  578. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  579. }
  580. for (key, val) in auth_headers {
  581. req.headers_mut().set_raw(key, val);
  582. }
  583. // send request
  584. Box::new(
  585. configuration.client.request(req)
  586. .map_err(|e| Error::from(e))
  587. .and_then(|resp| {
  588. let status = resp.status();
  589. resp.body().concat2()
  590. .and_then(move |body| Ok((status, body)))
  591. .map_err(|e| Error::from(e))
  592. })
  593. .and_then(|(status, body)| {
  594. if status.is_success() {
  595. Ok(body)
  596. } else {
  597. Err(Error::from((status, &*body)))
  598. }
  599. })
  600. .and_then(|body| {
  601. let parsed: Result<::models::GitTreeResponse, _> = serde_json::from_slice(&body);
  602. parsed.map_err(|e| Error::from(e))
  603. })
  604. )
  605. }
  606. fn list_forks(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Repository>, Error = Error<serde_json::Value>>> {
  607. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  608. let mut auth_headers = HashMap::<String, String>::new();
  609. let mut auth_query = HashMap::<String, String>::new();
  610. if let Some(ref apikey) = configuration.api_key {
  611. let key = apikey.key.clone();
  612. let val = match apikey.prefix {
  613. Some(ref prefix) => format!("{} {}", prefix, key),
  614. None => key,
  615. };
  616. auth_query.insert("access_token".to_owned(), val);
  617. };
  618. if let Some(ref apikey) = configuration.api_key {
  619. let key = apikey.key.clone();
  620. let val = match apikey.prefix {
  621. Some(ref prefix) => format!("{} {}", prefix, key),
  622. None => key,
  623. };
  624. auth_headers.insert("Authorization".to_owned(), val);
  625. };
  626. if let Some(ref auth_conf) = configuration.basic_auth {
  627. let auth = hyper::header::Authorization(
  628. hyper::header::Basic {
  629. username: auth_conf.0.to_owned(),
  630. password: auth_conf.1.to_owned(),
  631. }
  632. );
  633. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  634. };
  635. if let Some(ref apikey) = configuration.api_key {
  636. let key = apikey.key.clone();
  637. let val = match apikey.prefix {
  638. Some(ref prefix) => format!("{} {}", prefix, key),
  639. None => key,
  640. };
  641. auth_headers.insert("Sudo".to_owned(), val);
  642. };
  643. if let Some(ref apikey) = configuration.api_key {
  644. let key = apikey.key.clone();
  645. let val = match apikey.prefix {
  646. Some(ref prefix) => format!("{} {}", prefix, key),
  647. None => key,
  648. };
  649. auth_query.insert("sudo".to_owned(), val);
  650. };
  651. if let Some(ref apikey) = configuration.api_key {
  652. let key = apikey.key.clone();
  653. let val = match apikey.prefix {
  654. Some(ref prefix) => format!("{} {}", prefix, key),
  655. None => key,
  656. };
  657. auth_query.insert("token".to_owned(), val);
  658. };
  659. let method = hyper::Method::Get;
  660. let query_string = {
  661. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  662. for (key, val) in &auth_query {
  663. query.append_pair(key, val);
  664. }
  665. query.finish()
  666. };
  667. let uri_str = format!("{}/repos/{owner}/{repo}/forks?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  668. // TODO(farcaller): handle error
  669. // if let Err(e) = uri {
  670. // return Box::new(futures::future::err(e));
  671. // }
  672. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  673. let mut req = hyper::Request::new(method, uri);
  674. if let Some(ref user_agent) = configuration.user_agent {
  675. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  676. }
  677. for (key, val) in auth_headers {
  678. req.headers_mut().set_raw(key, val);
  679. }
  680. // send request
  681. Box::new(
  682. configuration.client.request(req)
  683. .map_err(|e| Error::from(e))
  684. .and_then(|resp| {
  685. let status = resp.status();
  686. resp.body().concat2()
  687. .and_then(move |body| Ok((status, body)))
  688. .map_err(|e| Error::from(e))
  689. })
  690. .and_then(|(status, body)| {
  691. if status.is_success() {
  692. Ok(body)
  693. } else {
  694. Err(Error::from((status, &*body)))
  695. }
  696. })
  697. .and_then(|body| {
  698. let parsed: Result<Vec<::models::Repository>, _> = serde_json::from_slice(&body);
  699. parsed.map_err(|e| Error::from(e))
  700. })
  701. )
  702. }
  703. fn repo_add_collaborator(&self, owner: &str, repo: &str, collaborator: &str, body: ::models::AddCollaboratorOption) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  704. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  705. let mut auth_headers = HashMap::<String, String>::new();
  706. let mut auth_query = HashMap::<String, String>::new();
  707. if let Some(ref apikey) = configuration.api_key {
  708. let key = apikey.key.clone();
  709. let val = match apikey.prefix {
  710. Some(ref prefix) => format!("{} {}", prefix, key),
  711. None => key,
  712. };
  713. auth_query.insert("access_token".to_owned(), val);
  714. };
  715. if let Some(ref apikey) = configuration.api_key {
  716. let key = apikey.key.clone();
  717. let val = match apikey.prefix {
  718. Some(ref prefix) => format!("{} {}", prefix, key),
  719. None => key,
  720. };
  721. auth_headers.insert("Authorization".to_owned(), val);
  722. };
  723. if let Some(ref auth_conf) = configuration.basic_auth {
  724. let auth = hyper::header::Authorization(
  725. hyper::header::Basic {
  726. username: auth_conf.0.to_owned(),
  727. password: auth_conf.1.to_owned(),
  728. }
  729. );
  730. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  731. };
  732. if let Some(ref apikey) = configuration.api_key {
  733. let key = apikey.key.clone();
  734. let val = match apikey.prefix {
  735. Some(ref prefix) => format!("{} {}", prefix, key),
  736. None => key,
  737. };
  738. auth_headers.insert("Sudo".to_owned(), val);
  739. };
  740. if let Some(ref apikey) = configuration.api_key {
  741. let key = apikey.key.clone();
  742. let val = match apikey.prefix {
  743. Some(ref prefix) => format!("{} {}", prefix, key),
  744. None => key,
  745. };
  746. auth_query.insert("sudo".to_owned(), val);
  747. };
  748. if let Some(ref apikey) = configuration.api_key {
  749. let key = apikey.key.clone();
  750. let val = match apikey.prefix {
  751. Some(ref prefix) => format!("{} {}", prefix, key),
  752. None => key,
  753. };
  754. auth_query.insert("token".to_owned(), val);
  755. };
  756. let method = hyper::Method::Put;
  757. let query_string = {
  758. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  759. for (key, val) in &auth_query {
  760. query.append_pair(key, val);
  761. }
  762. query.finish()
  763. };
  764. let uri_str = format!("{}/repos/{owner}/{repo}/collaborators/{collaborator}?{}", configuration.base_path, query_string, owner=owner, repo=repo, collaborator=collaborator);
  765. // TODO(farcaller): handle error
  766. // if let Err(e) = uri {
  767. // return Box::new(futures::future::err(e));
  768. // }
  769. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  770. let mut req = hyper::Request::new(method, uri);
  771. if let Some(ref user_agent) = configuration.user_agent {
  772. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  773. }
  774. for (key, val) in auth_headers {
  775. req.headers_mut().set_raw(key, val);
  776. }
  777. let serialized = serde_json::to_string(&body).unwrap();
  778. req.headers_mut().set(hyper::header::ContentType::json());
  779. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  780. req.set_body(serialized);
  781. // send request
  782. Box::new(
  783. configuration.client.request(req)
  784. .map_err(|e| Error::from(e))
  785. .and_then(|resp| {
  786. let status = resp.status();
  787. resp.body().concat2()
  788. .and_then(move |body| Ok((status, body)))
  789. .map_err(|e| Error::from(e))
  790. })
  791. .and_then(|(status, body)| {
  792. if status.is_success() {
  793. Ok(body)
  794. } else {
  795. Err(Error::from((status, &*body)))
  796. }
  797. })
  798. .and_then(|_| futures::future::ok(()))
  799. )
  800. }
  801. fn repo_add_topc(&self, owner: &str, repo: &str, topic: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  802. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  803. let mut auth_headers = HashMap::<String, String>::new();
  804. let mut auth_query = HashMap::<String, String>::new();
  805. if let Some(ref apikey) = configuration.api_key {
  806. let key = apikey.key.clone();
  807. let val = match apikey.prefix {
  808. Some(ref prefix) => format!("{} {}", prefix, key),
  809. None => key,
  810. };
  811. auth_query.insert("access_token".to_owned(), val);
  812. };
  813. if let Some(ref apikey) = configuration.api_key {
  814. let key = apikey.key.clone();
  815. let val = match apikey.prefix {
  816. Some(ref prefix) => format!("{} {}", prefix, key),
  817. None => key,
  818. };
  819. auth_headers.insert("Authorization".to_owned(), val);
  820. };
  821. if let Some(ref auth_conf) = configuration.basic_auth {
  822. let auth = hyper::header::Authorization(
  823. hyper::header::Basic {
  824. username: auth_conf.0.to_owned(),
  825. password: auth_conf.1.to_owned(),
  826. }
  827. );
  828. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  829. };
  830. if let Some(ref apikey) = configuration.api_key {
  831. let key = apikey.key.clone();
  832. let val = match apikey.prefix {
  833. Some(ref prefix) => format!("{} {}", prefix, key),
  834. None => key,
  835. };
  836. auth_headers.insert("Sudo".to_owned(), val);
  837. };
  838. if let Some(ref apikey) = configuration.api_key {
  839. let key = apikey.key.clone();
  840. let val = match apikey.prefix {
  841. Some(ref prefix) => format!("{} {}", prefix, key),
  842. None => key,
  843. };
  844. auth_query.insert("sudo".to_owned(), val);
  845. };
  846. if let Some(ref apikey) = configuration.api_key {
  847. let key = apikey.key.clone();
  848. let val = match apikey.prefix {
  849. Some(ref prefix) => format!("{} {}", prefix, key),
  850. None => key,
  851. };
  852. auth_query.insert("token".to_owned(), val);
  853. };
  854. let method = hyper::Method::Put;
  855. let query_string = {
  856. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  857. for (key, val) in &auth_query {
  858. query.append_pair(key, val);
  859. }
  860. query.finish()
  861. };
  862. let uri_str = format!("{}/repos/{owner}/{repo}/topics/{topic}?{}", configuration.base_path, query_string, owner=owner, repo=repo, topic=topic);
  863. // TODO(farcaller): handle error
  864. // if let Err(e) = uri {
  865. // return Box::new(futures::future::err(e));
  866. // }
  867. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  868. let mut req = hyper::Request::new(method, uri);
  869. if let Some(ref user_agent) = configuration.user_agent {
  870. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  871. }
  872. for (key, val) in auth_headers {
  873. req.headers_mut().set_raw(key, val);
  874. }
  875. // send request
  876. Box::new(
  877. configuration.client.request(req)
  878. .map_err(|e| Error::from(e))
  879. .and_then(|resp| {
  880. let status = resp.status();
  881. resp.body().concat2()
  882. .and_then(move |body| Ok((status, body)))
  883. .map_err(|e| Error::from(e))
  884. })
  885. .and_then(|(status, body)| {
  886. if status.is_success() {
  887. Ok(body)
  888. } else {
  889. Err(Error::from((status, &*body)))
  890. }
  891. })
  892. .and_then(|_| futures::future::ok(()))
  893. )
  894. }
  895. fn repo_check_collaborator(&self, owner: &str, repo: &str, collaborator: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  896. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  897. let mut auth_headers = HashMap::<String, String>::new();
  898. let mut auth_query = HashMap::<String, String>::new();
  899. if let Some(ref apikey) = configuration.api_key {
  900. let key = apikey.key.clone();
  901. let val = match apikey.prefix {
  902. Some(ref prefix) => format!("{} {}", prefix, key),
  903. None => key,
  904. };
  905. auth_query.insert("access_token".to_owned(), val);
  906. };
  907. if let Some(ref apikey) = configuration.api_key {
  908. let key = apikey.key.clone();
  909. let val = match apikey.prefix {
  910. Some(ref prefix) => format!("{} {}", prefix, key),
  911. None => key,
  912. };
  913. auth_headers.insert("Authorization".to_owned(), val);
  914. };
  915. if let Some(ref auth_conf) = configuration.basic_auth {
  916. let auth = hyper::header::Authorization(
  917. hyper::header::Basic {
  918. username: auth_conf.0.to_owned(),
  919. password: auth_conf.1.to_owned(),
  920. }
  921. );
  922. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  923. };
  924. if let Some(ref apikey) = configuration.api_key {
  925. let key = apikey.key.clone();
  926. let val = match apikey.prefix {
  927. Some(ref prefix) => format!("{} {}", prefix, key),
  928. None => key,
  929. };
  930. auth_headers.insert("Sudo".to_owned(), val);
  931. };
  932. if let Some(ref apikey) = configuration.api_key {
  933. let key = apikey.key.clone();
  934. let val = match apikey.prefix {
  935. Some(ref prefix) => format!("{} {}", prefix, key),
  936. None => key,
  937. };
  938. auth_query.insert("sudo".to_owned(), val);
  939. };
  940. if let Some(ref apikey) = configuration.api_key {
  941. let key = apikey.key.clone();
  942. let val = match apikey.prefix {
  943. Some(ref prefix) => format!("{} {}", prefix, key),
  944. None => key,
  945. };
  946. auth_query.insert("token".to_owned(), val);
  947. };
  948. let method = hyper::Method::Get;
  949. let query_string = {
  950. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  951. for (key, val) in &auth_query {
  952. query.append_pair(key, val);
  953. }
  954. query.finish()
  955. };
  956. let uri_str = format!("{}/repos/{owner}/{repo}/collaborators/{collaborator}?{}", configuration.base_path, query_string, owner=owner, repo=repo, collaborator=collaborator);
  957. // TODO(farcaller): handle error
  958. // if let Err(e) = uri {
  959. // return Box::new(futures::future::err(e));
  960. // }
  961. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  962. let mut req = hyper::Request::new(method, uri);
  963. if let Some(ref user_agent) = configuration.user_agent {
  964. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  965. }
  966. for (key, val) in auth_headers {
  967. req.headers_mut().set_raw(key, val);
  968. }
  969. // send request
  970. Box::new(
  971. configuration.client.request(req)
  972. .map_err(|e| Error::from(e))
  973. .and_then(|resp| {
  974. let status = resp.status();
  975. resp.body().concat2()
  976. .and_then(move |body| Ok((status, body)))
  977. .map_err(|e| Error::from(e))
  978. })
  979. .and_then(|(status, body)| {
  980. if status.is_success() {
  981. Ok(body)
  982. } else {
  983. Err(Error::from((status, &*body)))
  984. }
  985. })
  986. .and_then(|_| futures::future::ok(()))
  987. )
  988. }
  989. fn repo_create_file(&self, owner: &str, repo: &str, filepath: &str, body: ::models::CreateFileOptions) -> Box<Future<Item = ::models::FileResponse, Error = Error<serde_json::Value>>> {
  990. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  991. let mut auth_headers = HashMap::<String, String>::new();
  992. let mut auth_query = HashMap::<String, String>::new();
  993. if let Some(ref apikey) = configuration.api_key {
  994. let key = apikey.key.clone();
  995. let val = match apikey.prefix {
  996. Some(ref prefix) => format!("{} {}", prefix, key),
  997. None => key,
  998. };
  999. auth_query.insert("access_token".to_owned(), val);
  1000. };
  1001. if let Some(ref apikey) = configuration.api_key {
  1002. let key = apikey.key.clone();
  1003. let val = match apikey.prefix {
  1004. Some(ref prefix) => format!("{} {}", prefix, key),
  1005. None => key,
  1006. };
  1007. auth_headers.insert("Authorization".to_owned(), val);
  1008. };
  1009. if let Some(ref auth_conf) = configuration.basic_auth {
  1010. let auth = hyper::header::Authorization(
  1011. hyper::header::Basic {
  1012. username: auth_conf.0.to_owned(),
  1013. password: auth_conf.1.to_owned(),
  1014. }
  1015. );
  1016. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1017. };
  1018. if let Some(ref apikey) = configuration.api_key {
  1019. let key = apikey.key.clone();
  1020. let val = match apikey.prefix {
  1021. Some(ref prefix) => format!("{} {}", prefix, key),
  1022. None => key,
  1023. };
  1024. auth_headers.insert("Sudo".to_owned(), val);
  1025. };
  1026. if let Some(ref apikey) = configuration.api_key {
  1027. let key = apikey.key.clone();
  1028. let val = match apikey.prefix {
  1029. Some(ref prefix) => format!("{} {}", prefix, key),
  1030. None => key,
  1031. };
  1032. auth_query.insert("sudo".to_owned(), val);
  1033. };
  1034. if let Some(ref apikey) = configuration.api_key {
  1035. let key = apikey.key.clone();
  1036. let val = match apikey.prefix {
  1037. Some(ref prefix) => format!("{} {}", prefix, key),
  1038. None => key,
  1039. };
  1040. auth_query.insert("token".to_owned(), val);
  1041. };
  1042. let method = hyper::Method::Post;
  1043. let query_string = {
  1044. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1045. for (key, val) in &auth_query {
  1046. query.append_pair(key, val);
  1047. }
  1048. query.finish()
  1049. };
  1050. let uri_str = format!("{}/repos/{owner}/{repo}/contents/{filepath}?{}", configuration.base_path, query_string, owner=owner, repo=repo, filepath=filepath);
  1051. // TODO(farcaller): handle error
  1052. // if let Err(e) = uri {
  1053. // return Box::new(futures::future::err(e));
  1054. // }
  1055. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1056. let mut req = hyper::Request::new(method, uri);
  1057. if let Some(ref user_agent) = configuration.user_agent {
  1058. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1059. }
  1060. for (key, val) in auth_headers {
  1061. req.headers_mut().set_raw(key, val);
  1062. }
  1063. let serialized = serde_json::to_string(&body).unwrap();
  1064. req.headers_mut().set(hyper::header::ContentType::json());
  1065. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  1066. req.set_body(serialized);
  1067. // send request
  1068. Box::new(
  1069. configuration.client.request(req)
  1070. .map_err(|e| Error::from(e))
  1071. .and_then(|resp| {
  1072. let status = resp.status();
  1073. resp.body().concat2()
  1074. .and_then(move |body| Ok((status, body)))
  1075. .map_err(|e| Error::from(e))
  1076. })
  1077. .and_then(|(status, body)| {
  1078. if status.is_success() {
  1079. Ok(body)
  1080. } else {
  1081. Err(Error::from((status, &*body)))
  1082. }
  1083. })
  1084. .and_then(|body| {
  1085. let parsed: Result<::models::FileResponse, _> = serde_json::from_slice(&body);
  1086. parsed.map_err(|e| Error::from(e))
  1087. })
  1088. )
  1089. }
  1090. fn repo_create_hook(&self, owner: &str, repo: &str, body: ::models::CreateHookOption) -> Box<Future<Item = ::models::Hook, Error = Error<serde_json::Value>>> {
  1091. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1092. let mut auth_headers = HashMap::<String, String>::new();
  1093. let mut auth_query = HashMap::<String, String>::new();
  1094. if let Some(ref apikey) = configuration.api_key {
  1095. let key = apikey.key.clone();
  1096. let val = match apikey.prefix {
  1097. Some(ref prefix) => format!("{} {}", prefix, key),
  1098. None => key,
  1099. };
  1100. auth_query.insert("access_token".to_owned(), val);
  1101. };
  1102. if let Some(ref apikey) = configuration.api_key {
  1103. let key = apikey.key.clone();
  1104. let val = match apikey.prefix {
  1105. Some(ref prefix) => format!("{} {}", prefix, key),
  1106. None => key,
  1107. };
  1108. auth_headers.insert("Authorization".to_owned(), val);
  1109. };
  1110. if let Some(ref auth_conf) = configuration.basic_auth {
  1111. let auth = hyper::header::Authorization(
  1112. hyper::header::Basic {
  1113. username: auth_conf.0.to_owned(),
  1114. password: auth_conf.1.to_owned(),
  1115. }
  1116. );
  1117. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1118. };
  1119. if let Some(ref apikey) = configuration.api_key {
  1120. let key = apikey.key.clone();
  1121. let val = match apikey.prefix {
  1122. Some(ref prefix) => format!("{} {}", prefix, key),
  1123. None => key,
  1124. };
  1125. auth_headers.insert("Sudo".to_owned(), val);
  1126. };
  1127. if let Some(ref apikey) = configuration.api_key {
  1128. let key = apikey.key.clone();
  1129. let val = match apikey.prefix {
  1130. Some(ref prefix) => format!("{} {}", prefix, key),
  1131. None => key,
  1132. };
  1133. auth_query.insert("sudo".to_owned(), val);
  1134. };
  1135. if let Some(ref apikey) = configuration.api_key {
  1136. let key = apikey.key.clone();
  1137. let val = match apikey.prefix {
  1138. Some(ref prefix) => format!("{} {}", prefix, key),
  1139. None => key,
  1140. };
  1141. auth_query.insert("token".to_owned(), val);
  1142. };
  1143. let method = hyper::Method::Post;
  1144. let query_string = {
  1145. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1146. for (key, val) in &auth_query {
  1147. query.append_pair(key, val);
  1148. }
  1149. query.finish()
  1150. };
  1151. let uri_str = format!("{}/repos/{owner}/{repo}/hooks?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  1152. // TODO(farcaller): handle error
  1153. // if let Err(e) = uri {
  1154. // return Box::new(futures::future::err(e));
  1155. // }
  1156. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1157. let mut req = hyper::Request::new(method, uri);
  1158. if let Some(ref user_agent) = configuration.user_agent {
  1159. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1160. }
  1161. for (key, val) in auth_headers {
  1162. req.headers_mut().set_raw(key, val);
  1163. }
  1164. let serialized = serde_json::to_string(&body).unwrap();
  1165. req.headers_mut().set(hyper::header::ContentType::json());
  1166. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  1167. req.set_body(serialized);
  1168. // send request
  1169. Box::new(
  1170. configuration.client.request(req)
  1171. .map_err(|e| Error::from(e))
  1172. .and_then(|resp| {
  1173. let status = resp.status();
  1174. resp.body().concat2()
  1175. .and_then(move |body| Ok((status, body)))
  1176. .map_err(|e| Error::from(e))
  1177. })
  1178. .and_then(|(status, body)| {
  1179. if status.is_success() {
  1180. Ok(body)
  1181. } else {
  1182. Err(Error::from((status, &*body)))
  1183. }
  1184. })
  1185. .and_then(|body| {
  1186. let parsed: Result<::models::Hook, _> = serde_json::from_slice(&body);
  1187. parsed.map_err(|e| Error::from(e))
  1188. })
  1189. )
  1190. }
  1191. fn repo_create_key(&self, owner: &str, repo: &str, body: ::models::CreateKeyOption) -> Box<Future<Item = ::models::DeployKey, Error = Error<serde_json::Value>>> {
  1192. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1193. let mut auth_headers = HashMap::<String, String>::new();
  1194. let mut auth_query = HashMap::<String, String>::new();
  1195. if let Some(ref apikey) = configuration.api_key {
  1196. let key = apikey.key.clone();
  1197. let val = match apikey.prefix {
  1198. Some(ref prefix) => format!("{} {}", prefix, key),
  1199. None => key,
  1200. };
  1201. auth_query.insert("access_token".to_owned(), val);
  1202. };
  1203. if let Some(ref apikey) = configuration.api_key {
  1204. let key = apikey.key.clone();
  1205. let val = match apikey.prefix {
  1206. Some(ref prefix) => format!("{} {}", prefix, key),
  1207. None => key,
  1208. };
  1209. auth_headers.insert("Authorization".to_owned(), val);
  1210. };
  1211. if let Some(ref auth_conf) = configuration.basic_auth {
  1212. let auth = hyper::header::Authorization(
  1213. hyper::header::Basic {
  1214. username: auth_conf.0.to_owned(),
  1215. password: auth_conf.1.to_owned(),
  1216. }
  1217. );
  1218. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1219. };
  1220. if let Some(ref apikey) = configuration.api_key {
  1221. let key = apikey.key.clone();
  1222. let val = match apikey.prefix {
  1223. Some(ref prefix) => format!("{} {}", prefix, key),
  1224. None => key,
  1225. };
  1226. auth_headers.insert("Sudo".to_owned(), val);
  1227. };
  1228. if let Some(ref apikey) = configuration.api_key {
  1229. let key = apikey.key.clone();
  1230. let val = match apikey.prefix {
  1231. Some(ref prefix) => format!("{} {}", prefix, key),
  1232. None => key,
  1233. };
  1234. auth_query.insert("sudo".to_owned(), val);
  1235. };
  1236. if let Some(ref apikey) = configuration.api_key {
  1237. let key = apikey.key.clone();
  1238. let val = match apikey.prefix {
  1239. Some(ref prefix) => format!("{} {}", prefix, key),
  1240. None => key,
  1241. };
  1242. auth_query.insert("token".to_owned(), val);
  1243. };
  1244. let method = hyper::Method::Post;
  1245. let query_string = {
  1246. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1247. for (key, val) in &auth_query {
  1248. query.append_pair(key, val);
  1249. }
  1250. query.finish()
  1251. };
  1252. let uri_str = format!("{}/repos/{owner}/{repo}/keys?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  1253. // TODO(farcaller): handle error
  1254. // if let Err(e) = uri {
  1255. // return Box::new(futures::future::err(e));
  1256. // }
  1257. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1258. let mut req = hyper::Request::new(method, uri);
  1259. if let Some(ref user_agent) = configuration.user_agent {
  1260. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1261. }
  1262. for (key, val) in auth_headers {
  1263. req.headers_mut().set_raw(key, val);
  1264. }
  1265. let serialized = serde_json::to_string(&body).unwrap();
  1266. req.headers_mut().set(hyper::header::ContentType::json());
  1267. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  1268. req.set_body(serialized);
  1269. // send request
  1270. Box::new(
  1271. configuration.client.request(req)
  1272. .map_err(|e| Error::from(e))
  1273. .and_then(|resp| {
  1274. let status = resp.status();
  1275. resp.body().concat2()
  1276. .and_then(move |body| Ok((status, body)))
  1277. .map_err(|e| Error::from(e))
  1278. })
  1279. .and_then(|(status, body)| {
  1280. if status.is_success() {
  1281. Ok(body)
  1282. } else {
  1283. Err(Error::from((status, &*body)))
  1284. }
  1285. })
  1286. .and_then(|body| {
  1287. let parsed: Result<::models::DeployKey, _> = serde_json::from_slice(&body);
  1288. parsed.map_err(|e| Error::from(e))
  1289. })
  1290. )
  1291. }
  1292. fn repo_create_pull_request(&self, owner: &str, repo: &str, body: ::models::CreatePullRequestOption) -> Box<Future<Item = ::models::PullRequest, Error = Error<serde_json::Value>>> {
  1293. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1294. let mut auth_headers = HashMap::<String, String>::new();
  1295. let mut auth_query = HashMap::<String, String>::new();
  1296. if let Some(ref apikey) = configuration.api_key {
  1297. let key = apikey.key.clone();
  1298. let val = match apikey.prefix {
  1299. Some(ref prefix) => format!("{} {}", prefix, key),
  1300. None => key,
  1301. };
  1302. auth_query.insert("access_token".to_owned(), val);
  1303. };
  1304. if let Some(ref apikey) = configuration.api_key {
  1305. let key = apikey.key.clone();
  1306. let val = match apikey.prefix {
  1307. Some(ref prefix) => format!("{} {}", prefix, key),
  1308. None => key,
  1309. };
  1310. auth_headers.insert("Authorization".to_owned(), val);
  1311. };
  1312. if let Some(ref auth_conf) = configuration.basic_auth {
  1313. let auth = hyper::header::Authorization(
  1314. hyper::header::Basic {
  1315. username: auth_conf.0.to_owned(),
  1316. password: auth_conf.1.to_owned(),
  1317. }
  1318. );
  1319. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1320. };
  1321. if let Some(ref apikey) = configuration.api_key {
  1322. let key = apikey.key.clone();
  1323. let val = match apikey.prefix {
  1324. Some(ref prefix) => format!("{} {}", prefix, key),
  1325. None => key,
  1326. };
  1327. auth_headers.insert("Sudo".to_owned(), val);
  1328. };
  1329. if let Some(ref apikey) = configuration.api_key {
  1330. let key = apikey.key.clone();
  1331. let val = match apikey.prefix {
  1332. Some(ref prefix) => format!("{} {}", prefix, key),
  1333. None => key,
  1334. };
  1335. auth_query.insert("sudo".to_owned(), val);
  1336. };
  1337. if let Some(ref apikey) = configuration.api_key {
  1338. let key = apikey.key.clone();
  1339. let val = match apikey.prefix {
  1340. Some(ref prefix) => format!("{} {}", prefix, key),
  1341. None => key,
  1342. };
  1343. auth_query.insert("token".to_owned(), val);
  1344. };
  1345. let method = hyper::Method::Post;
  1346. let query_string = {
  1347. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1348. for (key, val) in &auth_query {
  1349. query.append_pair(key, val);
  1350. }
  1351. query.finish()
  1352. };
  1353. let uri_str = format!("{}/repos/{owner}/{repo}/pulls?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  1354. // TODO(farcaller): handle error
  1355. // if let Err(e) = uri {
  1356. // return Box::new(futures::future::err(e));
  1357. // }
  1358. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1359. let mut req = hyper::Request::new(method, uri);
  1360. if let Some(ref user_agent) = configuration.user_agent {
  1361. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1362. }
  1363. for (key, val) in auth_headers {
  1364. req.headers_mut().set_raw(key, val);
  1365. }
  1366. let serialized = serde_json::to_string(&body).unwrap();
  1367. req.headers_mut().set(hyper::header::ContentType::json());
  1368. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  1369. req.set_body(serialized);
  1370. // send request
  1371. Box::new(
  1372. configuration.client.request(req)
  1373. .map_err(|e| Error::from(e))
  1374. .and_then(|resp| {
  1375. let status = resp.status();
  1376. resp.body().concat2()
  1377. .and_then(move |body| Ok((status, body)))
  1378. .map_err(|e| Error::from(e))
  1379. })
  1380. .and_then(|(status, body)| {
  1381. if status.is_success() {
  1382. Ok(body)
  1383. } else {
  1384. Err(Error::from((status, &*body)))
  1385. }
  1386. })
  1387. .and_then(|body| {
  1388. let parsed: Result<::models::PullRequest, _> = serde_json::from_slice(&body);
  1389. parsed.map_err(|e| Error::from(e))
  1390. })
  1391. )
  1392. }
  1393. fn repo_create_release(&self, owner: &str, repo: &str, body: ::models::CreateReleaseOption) -> Box<Future<Item = ::models::Release, Error = Error<serde_json::Value>>> {
  1394. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1395. let mut auth_headers = HashMap::<String, String>::new();
  1396. let mut auth_query = HashMap::<String, String>::new();
  1397. if let Some(ref apikey) = configuration.api_key {
  1398. let key = apikey.key.clone();
  1399. let val = match apikey.prefix {
  1400. Some(ref prefix) => format!("{} {}", prefix, key),
  1401. None => key,
  1402. };
  1403. auth_query.insert("access_token".to_owned(), val);
  1404. };
  1405. if let Some(ref apikey) = configuration.api_key {
  1406. let key = apikey.key.clone();
  1407. let val = match apikey.prefix {
  1408. Some(ref prefix) => format!("{} {}", prefix, key),
  1409. None => key,
  1410. };
  1411. auth_headers.insert("Authorization".to_owned(), val);
  1412. };
  1413. if let Some(ref auth_conf) = configuration.basic_auth {
  1414. let auth = hyper::header::Authorization(
  1415. hyper::header::Basic {
  1416. username: auth_conf.0.to_owned(),
  1417. password: auth_conf.1.to_owned(),
  1418. }
  1419. );
  1420. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1421. };
  1422. if let Some(ref apikey) = configuration.api_key {
  1423. let key = apikey.key.clone();
  1424. let val = match apikey.prefix {
  1425. Some(ref prefix) => format!("{} {}", prefix, key),
  1426. None => key,
  1427. };
  1428. auth_headers.insert("Sudo".to_owned(), val);
  1429. };
  1430. if let Some(ref apikey) = configuration.api_key {
  1431. let key = apikey.key.clone();
  1432. let val = match apikey.prefix {
  1433. Some(ref prefix) => format!("{} {}", prefix, key),
  1434. None => key,
  1435. };
  1436. auth_query.insert("sudo".to_owned(), val);
  1437. };
  1438. if let Some(ref apikey) = configuration.api_key {
  1439. let key = apikey.key.clone();
  1440. let val = match apikey.prefix {
  1441. Some(ref prefix) => format!("{} {}", prefix, key),
  1442. None => key,
  1443. };
  1444. auth_query.insert("token".to_owned(), val);
  1445. };
  1446. let method = hyper::Method::Post;
  1447. let query_string = {
  1448. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1449. for (key, val) in &auth_query {
  1450. query.append_pair(key, val);
  1451. }
  1452. query.finish()
  1453. };
  1454. let uri_str = format!("{}/repos/{owner}/{repo}/releases?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  1455. // TODO(farcaller): handle error
  1456. // if let Err(e) = uri {
  1457. // return Box::new(futures::future::err(e));
  1458. // }
  1459. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1460. let mut req = hyper::Request::new(method, uri);
  1461. if let Some(ref user_agent) = configuration.user_agent {
  1462. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1463. }
  1464. for (key, val) in auth_headers {
  1465. req.headers_mut().set_raw(key, val);
  1466. }
  1467. let serialized = serde_json::to_string(&body).unwrap();
  1468. req.headers_mut().set(hyper::header::ContentType::json());
  1469. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  1470. req.set_body(serialized);
  1471. // send request
  1472. Box::new(
  1473. configuration.client.request(req)
  1474. .map_err(|e| Error::from(e))
  1475. .and_then(|resp| {
  1476. let status = resp.status();
  1477. resp.body().concat2()
  1478. .and_then(move |body| Ok((status, body)))
  1479. .map_err(|e| Error::from(e))
  1480. })
  1481. .and_then(|(status, body)| {
  1482. if status.is_success() {
  1483. Ok(body)
  1484. } else {
  1485. Err(Error::from((status, &*body)))
  1486. }
  1487. })
  1488. .and_then(|body| {
  1489. let parsed: Result<::models::Release, _> = serde_json::from_slice(&body);
  1490. parsed.map_err(|e| Error::from(e))
  1491. })
  1492. )
  1493. }
  1494. fn repo_create_release_attachment(&self, owner: &str, repo: &str, id: i64, attachment: ::models::File, name: &str) -> Box<Future<Item = ::models::Attachment, Error = Error<serde_json::Value>>> {
  1495. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1496. let mut auth_headers = HashMap::<String, String>::new();
  1497. let mut auth_query = HashMap::<String, String>::new();
  1498. if let Some(ref apikey) = configuration.api_key {
  1499. let key = apikey.key.clone();
  1500. let val = match apikey.prefix {
  1501. Some(ref prefix) => format!("{} {}", prefix, key),
  1502. None => key,
  1503. };
  1504. auth_query.insert("access_token".to_owned(), val);
  1505. };
  1506. if let Some(ref apikey) = configuration.api_key {
  1507. let key = apikey.key.clone();
  1508. let val = match apikey.prefix {
  1509. Some(ref prefix) => format!("{} {}", prefix, key),
  1510. None => key,
  1511. };
  1512. auth_headers.insert("Authorization".to_owned(), val);
  1513. };
  1514. if let Some(ref auth_conf) = configuration.basic_auth {
  1515. let auth = hyper::header::Authorization(
  1516. hyper::header::Basic {
  1517. username: auth_conf.0.to_owned(),
  1518. password: auth_conf.1.to_owned(),
  1519. }
  1520. );
  1521. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1522. };
  1523. if let Some(ref apikey) = configuration.api_key {
  1524. let key = apikey.key.clone();
  1525. let val = match apikey.prefix {
  1526. Some(ref prefix) => format!("{} {}", prefix, key),
  1527. None => key,
  1528. };
  1529. auth_headers.insert("Sudo".to_owned(), val);
  1530. };
  1531. if let Some(ref apikey) = configuration.api_key {
  1532. let key = apikey.key.clone();
  1533. let val = match apikey.prefix {
  1534. Some(ref prefix) => format!("{} {}", prefix, key),
  1535. None => key,
  1536. };
  1537. auth_query.insert("sudo".to_owned(), val);
  1538. };
  1539. if let Some(ref apikey) = configuration.api_key {
  1540. let key = apikey.key.clone();
  1541. let val = match apikey.prefix {
  1542. Some(ref prefix) => format!("{} {}", prefix, key),
  1543. None => key,
  1544. };
  1545. auth_query.insert("token".to_owned(), val);
  1546. };
  1547. let method = hyper::Method::Post;
  1548. let query_string = {
  1549. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1550. query.append_pair("name", &name.to_string());
  1551. for (key, val) in &auth_query {
  1552. query.append_pair(key, val);
  1553. }
  1554. query.finish()
  1555. };
  1556. let uri_str = format!("{}/repos/{owner}/{repo}/releases/{id}/assets?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  1557. // TODO(farcaller): handle error
  1558. // if let Err(e) = uri {
  1559. // return Box::new(futures::future::err(e));
  1560. // }
  1561. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1562. let mut req = hyper::Request::new(method, uri);
  1563. if let Some(ref user_agent) = configuration.user_agent {
  1564. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1565. }
  1566. for (key, val) in auth_headers {
  1567. req.headers_mut().set_raw(key, val);
  1568. }
  1569. // send request
  1570. Box::new(
  1571. configuration.client.request(req)
  1572. .map_err(|e| Error::from(e))
  1573. .and_then(|resp| {
  1574. let status = resp.status();
  1575. resp.body().concat2()
  1576. .and_then(move |body| Ok((status, body)))
  1577. .map_err(|e| Error::from(e))
  1578. })
  1579. .and_then(|(status, body)| {
  1580. if status.is_success() {
  1581. Ok(body)
  1582. } else {
  1583. Err(Error::from((status, &*body)))
  1584. }
  1585. })
  1586. .and_then(|body| {
  1587. let parsed: Result<::models::Attachment, _> = serde_json::from_slice(&body);
  1588. parsed.map_err(|e| Error::from(e))
  1589. })
  1590. )
  1591. }
  1592. fn repo_create_status(&self, owner: &str, repo: &str, sha: &str, body: ::models::CreateStatusOption) -> Box<Future<Item = ::models::Status, Error = Error<serde_json::Value>>> {
  1593. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1594. let mut auth_headers = HashMap::<String, String>::new();
  1595. let mut auth_query = HashMap::<String, String>::new();
  1596. if let Some(ref apikey) = configuration.api_key {
  1597. let key = apikey.key.clone();
  1598. let val = match apikey.prefix {
  1599. Some(ref prefix) => format!("{} {}", prefix, key),
  1600. None => key,
  1601. };
  1602. auth_query.insert("access_token".to_owned(), val);
  1603. };
  1604. if let Some(ref apikey) = configuration.api_key {
  1605. let key = apikey.key.clone();
  1606. let val = match apikey.prefix {
  1607. Some(ref prefix) => format!("{} {}", prefix, key),
  1608. None => key,
  1609. };
  1610. auth_headers.insert("Authorization".to_owned(), val);
  1611. };
  1612. if let Some(ref auth_conf) = configuration.basic_auth {
  1613. let auth = hyper::header::Authorization(
  1614. hyper::header::Basic {
  1615. username: auth_conf.0.to_owned(),
  1616. password: auth_conf.1.to_owned(),
  1617. }
  1618. );
  1619. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1620. };
  1621. if let Some(ref apikey) = configuration.api_key {
  1622. let key = apikey.key.clone();
  1623. let val = match apikey.prefix {
  1624. Some(ref prefix) => format!("{} {}", prefix, key),
  1625. None => key,
  1626. };
  1627. auth_headers.insert("Sudo".to_owned(), val);
  1628. };
  1629. if let Some(ref apikey) = configuration.api_key {
  1630. let key = apikey.key.clone();
  1631. let val = match apikey.prefix {
  1632. Some(ref prefix) => format!("{} {}", prefix, key),
  1633. None => key,
  1634. };
  1635. auth_query.insert("sudo".to_owned(), val);
  1636. };
  1637. if let Some(ref apikey) = configuration.api_key {
  1638. let key = apikey.key.clone();
  1639. let val = match apikey.prefix {
  1640. Some(ref prefix) => format!("{} {}", prefix, key),
  1641. None => key,
  1642. };
  1643. auth_query.insert("token".to_owned(), val);
  1644. };
  1645. let method = hyper::Method::Post;
  1646. let query_string = {
  1647. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1648. for (key, val) in &auth_query {
  1649. query.append_pair(key, val);
  1650. }
  1651. query.finish()
  1652. };
  1653. let uri_str = format!("{}/repos/{owner}/{repo}/statuses/{sha}?{}", configuration.base_path, query_string, owner=owner, repo=repo, sha=sha);
  1654. // TODO(farcaller): handle error
  1655. // if let Err(e) = uri {
  1656. // return Box::new(futures::future::err(e));
  1657. // }
  1658. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1659. let mut req = hyper::Request::new(method, uri);
  1660. if let Some(ref user_agent) = configuration.user_agent {
  1661. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1662. }
  1663. for (key, val) in auth_headers {
  1664. req.headers_mut().set_raw(key, val);
  1665. }
  1666. let serialized = serde_json::to_string(&body).unwrap();
  1667. req.headers_mut().set(hyper::header::ContentType::json());
  1668. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  1669. req.set_body(serialized);
  1670. // send request
  1671. Box::new(
  1672. configuration.client.request(req)
  1673. .map_err(|e| Error::from(e))
  1674. .and_then(|resp| {
  1675. let status = resp.status();
  1676. resp.body().concat2()
  1677. .and_then(move |body| Ok((status, body)))
  1678. .map_err(|e| Error::from(e))
  1679. })
  1680. .and_then(|(status, body)| {
  1681. if status.is_success() {
  1682. Ok(body)
  1683. } else {
  1684. Err(Error::from((status, &*body)))
  1685. }
  1686. })
  1687. .and_then(|body| {
  1688. let parsed: Result<::models::Status, _> = serde_json::from_slice(&body);
  1689. parsed.map_err(|e| Error::from(e))
  1690. })
  1691. )
  1692. }
  1693. fn repo_delete(&self, owner: &str, repo: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  1694. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1695. let mut auth_headers = HashMap::<String, String>::new();
  1696. let mut auth_query = HashMap::<String, String>::new();
  1697. if let Some(ref apikey) = configuration.api_key {
  1698. let key = apikey.key.clone();
  1699. let val = match apikey.prefix {
  1700. Some(ref prefix) => format!("{} {}", prefix, key),
  1701. None => key,
  1702. };
  1703. auth_query.insert("access_token".to_owned(), val);
  1704. };
  1705. if let Some(ref apikey) = configuration.api_key {
  1706. let key = apikey.key.clone();
  1707. let val = match apikey.prefix {
  1708. Some(ref prefix) => format!("{} {}", prefix, key),
  1709. None => key,
  1710. };
  1711. auth_headers.insert("Authorization".to_owned(), val);
  1712. };
  1713. if let Some(ref auth_conf) = configuration.basic_auth {
  1714. let auth = hyper::header::Authorization(
  1715. hyper::header::Basic {
  1716. username: auth_conf.0.to_owned(),
  1717. password: auth_conf.1.to_owned(),
  1718. }
  1719. );
  1720. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1721. };
  1722. if let Some(ref apikey) = configuration.api_key {
  1723. let key = apikey.key.clone();
  1724. let val = match apikey.prefix {
  1725. Some(ref prefix) => format!("{} {}", prefix, key),
  1726. None => key,
  1727. };
  1728. auth_headers.insert("Sudo".to_owned(), val);
  1729. };
  1730. if let Some(ref apikey) = configuration.api_key {
  1731. let key = apikey.key.clone();
  1732. let val = match apikey.prefix {
  1733. Some(ref prefix) => format!("{} {}", prefix, key),
  1734. None => key,
  1735. };
  1736. auth_query.insert("sudo".to_owned(), val);
  1737. };
  1738. if let Some(ref apikey) = configuration.api_key {
  1739. let key = apikey.key.clone();
  1740. let val = match apikey.prefix {
  1741. Some(ref prefix) => format!("{} {}", prefix, key),
  1742. None => key,
  1743. };
  1744. auth_query.insert("token".to_owned(), val);
  1745. };
  1746. let method = hyper::Method::Delete;
  1747. let query_string = {
  1748. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1749. for (key, val) in &auth_query {
  1750. query.append_pair(key, val);
  1751. }
  1752. query.finish()
  1753. };
  1754. let uri_str = format!("{}/repos/{owner}/{repo}?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  1755. // TODO(farcaller): handle error
  1756. // if let Err(e) = uri {
  1757. // return Box::new(futures::future::err(e));
  1758. // }
  1759. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1760. let mut req = hyper::Request::new(method, uri);
  1761. if let Some(ref user_agent) = configuration.user_agent {
  1762. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1763. }
  1764. for (key, val) in auth_headers {
  1765. req.headers_mut().set_raw(key, val);
  1766. }
  1767. // send request
  1768. Box::new(
  1769. configuration.client.request(req)
  1770. .map_err(|e| Error::from(e))
  1771. .and_then(|resp| {
  1772. let status = resp.status();
  1773. resp.body().concat2()
  1774. .and_then(move |body| Ok((status, body)))
  1775. .map_err(|e| Error::from(e))
  1776. })
  1777. .and_then(|(status, body)| {
  1778. if status.is_success() {
  1779. Ok(body)
  1780. } else {
  1781. Err(Error::from((status, &*body)))
  1782. }
  1783. })
  1784. .and_then(|_| futures::future::ok(()))
  1785. )
  1786. }
  1787. fn repo_delete_collaborator(&self, owner: &str, repo: &str, collaborator: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  1788. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1789. let mut auth_headers = HashMap::<String, String>::new();
  1790. let mut auth_query = HashMap::<String, String>::new();
  1791. if let Some(ref apikey) = configuration.api_key {
  1792. let key = apikey.key.clone();
  1793. let val = match apikey.prefix {
  1794. Some(ref prefix) => format!("{} {}", prefix, key),
  1795. None => key,
  1796. };
  1797. auth_query.insert("access_token".to_owned(), val);
  1798. };
  1799. if let Some(ref apikey) = configuration.api_key {
  1800. let key = apikey.key.clone();
  1801. let val = match apikey.prefix {
  1802. Some(ref prefix) => format!("{} {}", prefix, key),
  1803. None => key,
  1804. };
  1805. auth_headers.insert("Authorization".to_owned(), val);
  1806. };
  1807. if let Some(ref auth_conf) = configuration.basic_auth {
  1808. let auth = hyper::header::Authorization(
  1809. hyper::header::Basic {
  1810. username: auth_conf.0.to_owned(),
  1811. password: auth_conf.1.to_owned(),
  1812. }
  1813. );
  1814. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1815. };
  1816. if let Some(ref apikey) = configuration.api_key {
  1817. let key = apikey.key.clone();
  1818. let val = match apikey.prefix {
  1819. Some(ref prefix) => format!("{} {}", prefix, key),
  1820. None => key,
  1821. };
  1822. auth_headers.insert("Sudo".to_owned(), val);
  1823. };
  1824. if let Some(ref apikey) = configuration.api_key {
  1825. let key = apikey.key.clone();
  1826. let val = match apikey.prefix {
  1827. Some(ref prefix) => format!("{} {}", prefix, key),
  1828. None => key,
  1829. };
  1830. auth_query.insert("sudo".to_owned(), val);
  1831. };
  1832. if let Some(ref apikey) = configuration.api_key {
  1833. let key = apikey.key.clone();
  1834. let val = match apikey.prefix {
  1835. Some(ref prefix) => format!("{} {}", prefix, key),
  1836. None => key,
  1837. };
  1838. auth_query.insert("token".to_owned(), val);
  1839. };
  1840. let method = hyper::Method::Delete;
  1841. let query_string = {
  1842. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1843. for (key, val) in &auth_query {
  1844. query.append_pair(key, val);
  1845. }
  1846. query.finish()
  1847. };
  1848. let uri_str = format!("{}/repos/{owner}/{repo}/collaborators/{collaborator}?{}", configuration.base_path, query_string, owner=owner, repo=repo, collaborator=collaborator);
  1849. // TODO(farcaller): handle error
  1850. // if let Err(e) = uri {
  1851. // return Box::new(futures::future::err(e));
  1852. // }
  1853. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1854. let mut req = hyper::Request::new(method, uri);
  1855. if let Some(ref user_agent) = configuration.user_agent {
  1856. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1857. }
  1858. for (key, val) in auth_headers {
  1859. req.headers_mut().set_raw(key, val);
  1860. }
  1861. // send request
  1862. Box::new(
  1863. configuration.client.request(req)
  1864. .map_err(|e| Error::from(e))
  1865. .and_then(|resp| {
  1866. let status = resp.status();
  1867. resp.body().concat2()
  1868. .and_then(move |body| Ok((status, body)))
  1869. .map_err(|e| Error::from(e))
  1870. })
  1871. .and_then(|(status, body)| {
  1872. if status.is_success() {
  1873. Ok(body)
  1874. } else {
  1875. Err(Error::from((status, &*body)))
  1876. }
  1877. })
  1878. .and_then(|_| futures::future::ok(()))
  1879. )
  1880. }
  1881. fn repo_delete_file(&self, owner: &str, repo: &str, filepath: &str, body: ::models::DeleteFileOptions) -> Box<Future<Item = ::models::FileDeleteResponse, Error = Error<serde_json::Value>>> {
  1882. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1883. let mut auth_headers = HashMap::<String, String>::new();
  1884. let mut auth_query = HashMap::<String, String>::new();
  1885. if let Some(ref apikey) = configuration.api_key {
  1886. let key = apikey.key.clone();
  1887. let val = match apikey.prefix {
  1888. Some(ref prefix) => format!("{} {}", prefix, key),
  1889. None => key,
  1890. };
  1891. auth_query.insert("access_token".to_owned(), val);
  1892. };
  1893. if let Some(ref apikey) = configuration.api_key {
  1894. let key = apikey.key.clone();
  1895. let val = match apikey.prefix {
  1896. Some(ref prefix) => format!("{} {}", prefix, key),
  1897. None => key,
  1898. };
  1899. auth_headers.insert("Authorization".to_owned(), val);
  1900. };
  1901. if let Some(ref auth_conf) = configuration.basic_auth {
  1902. let auth = hyper::header::Authorization(
  1903. hyper::header::Basic {
  1904. username: auth_conf.0.to_owned(),
  1905. password: auth_conf.1.to_owned(),
  1906. }
  1907. );
  1908. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1909. };
  1910. if let Some(ref apikey) = configuration.api_key {
  1911. let key = apikey.key.clone();
  1912. let val = match apikey.prefix {
  1913. Some(ref prefix) => format!("{} {}", prefix, key),
  1914. None => key,
  1915. };
  1916. auth_headers.insert("Sudo".to_owned(), val);
  1917. };
  1918. if let Some(ref apikey) = configuration.api_key {
  1919. let key = apikey.key.clone();
  1920. let val = match apikey.prefix {
  1921. Some(ref prefix) => format!("{} {}", prefix, key),
  1922. None => key,
  1923. };
  1924. auth_query.insert("sudo".to_owned(), val);
  1925. };
  1926. if let Some(ref apikey) = configuration.api_key {
  1927. let key = apikey.key.clone();
  1928. let val = match apikey.prefix {
  1929. Some(ref prefix) => format!("{} {}", prefix, key),
  1930. None => key,
  1931. };
  1932. auth_query.insert("token".to_owned(), val);
  1933. };
  1934. let method = hyper::Method::Delete;
  1935. let query_string = {
  1936. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1937. for (key, val) in &auth_query {
  1938. query.append_pair(key, val);
  1939. }
  1940. query.finish()
  1941. };
  1942. let uri_str = format!("{}/repos/{owner}/{repo}/contents/{filepath}?{}", configuration.base_path, query_string, owner=owner, repo=repo, filepath=filepath);
  1943. // TODO(farcaller): handle error
  1944. // if let Err(e) = uri {
  1945. // return Box::new(futures::future::err(e));
  1946. // }
  1947. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1948. let mut req = hyper::Request::new(method, uri);
  1949. if let Some(ref user_agent) = configuration.user_agent {
  1950. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1951. }
  1952. for (key, val) in auth_headers {
  1953. req.headers_mut().set_raw(key, val);
  1954. }
  1955. let serialized = serde_json::to_string(&body).unwrap();
  1956. req.headers_mut().set(hyper::header::ContentType::json());
  1957. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  1958. req.set_body(serialized);
  1959. // send request
  1960. Box::new(
  1961. configuration.client.request(req)
  1962. .map_err(|e| Error::from(e))
  1963. .and_then(|resp| {
  1964. let status = resp.status();
  1965. resp.body().concat2()
  1966. .and_then(move |body| Ok((status, body)))
  1967. .map_err(|e| Error::from(e))
  1968. })
  1969. .and_then(|(status, body)| {
  1970. if status.is_success() {
  1971. Ok(body)
  1972. } else {
  1973. Err(Error::from((status, &*body)))
  1974. }
  1975. })
  1976. .and_then(|body| {
  1977. let parsed: Result<::models::FileDeleteResponse, _> = serde_json::from_slice(&body);
  1978. parsed.map_err(|e| Error::from(e))
  1979. })
  1980. )
  1981. }
  1982. fn repo_delete_git_hook(&self, owner: &str, repo: &str, id: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  1983. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1984. let mut auth_headers = HashMap::<String, String>::new();
  1985. let mut auth_query = HashMap::<String, String>::new();
  1986. if let Some(ref apikey) = configuration.api_key {
  1987. let key = apikey.key.clone();
  1988. let val = match apikey.prefix {
  1989. Some(ref prefix) => format!("{} {}", prefix, key),
  1990. None => key,
  1991. };
  1992. auth_query.insert("access_token".to_owned(), val);
  1993. };
  1994. if let Some(ref apikey) = configuration.api_key {
  1995. let key = apikey.key.clone();
  1996. let val = match apikey.prefix {
  1997. Some(ref prefix) => format!("{} {}", prefix, key),
  1998. None => key,
  1999. };
  2000. auth_headers.insert("Authorization".to_owned(), val);
  2001. };
  2002. if let Some(ref auth_conf) = configuration.basic_auth {
  2003. let auth = hyper::header::Authorization(
  2004. hyper::header::Basic {
  2005. username: auth_conf.0.to_owned(),
  2006. password: auth_conf.1.to_owned(),
  2007. }
  2008. );
  2009. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2010. };
  2011. if let Some(ref apikey) = configuration.api_key {
  2012. let key = apikey.key.clone();
  2013. let val = match apikey.prefix {
  2014. Some(ref prefix) => format!("{} {}", prefix, key),
  2015. None => key,
  2016. };
  2017. auth_headers.insert("Sudo".to_owned(), val);
  2018. };
  2019. if let Some(ref apikey) = configuration.api_key {
  2020. let key = apikey.key.clone();
  2021. let val = match apikey.prefix {
  2022. Some(ref prefix) => format!("{} {}", prefix, key),
  2023. None => key,
  2024. };
  2025. auth_query.insert("sudo".to_owned(), val);
  2026. };
  2027. if let Some(ref apikey) = configuration.api_key {
  2028. let key = apikey.key.clone();
  2029. let val = match apikey.prefix {
  2030. Some(ref prefix) => format!("{} {}", prefix, key),
  2031. None => key,
  2032. };
  2033. auth_query.insert("token".to_owned(), val);
  2034. };
  2035. let method = hyper::Method::Delete;
  2036. let query_string = {
  2037. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2038. for (key, val) in &auth_query {
  2039. query.append_pair(key, val);
  2040. }
  2041. query.finish()
  2042. };
  2043. let uri_str = format!("{}/repos/{owner}/{repo}/hooks/git/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  2044. // TODO(farcaller): handle error
  2045. // if let Err(e) = uri {
  2046. // return Box::new(futures::future::err(e));
  2047. // }
  2048. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2049. let mut req = hyper::Request::new(method, uri);
  2050. if let Some(ref user_agent) = configuration.user_agent {
  2051. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2052. }
  2053. for (key, val) in auth_headers {
  2054. req.headers_mut().set_raw(key, val);
  2055. }
  2056. // send request
  2057. Box::new(
  2058. configuration.client.request(req)
  2059. .map_err(|e| Error::from(e))
  2060. .and_then(|resp| {
  2061. let status = resp.status();
  2062. resp.body().concat2()
  2063. .and_then(move |body| Ok((status, body)))
  2064. .map_err(|e| Error::from(e))
  2065. })
  2066. .and_then(|(status, body)| {
  2067. if status.is_success() {
  2068. Ok(body)
  2069. } else {
  2070. Err(Error::from((status, &*body)))
  2071. }
  2072. })
  2073. .and_then(|_| futures::future::ok(()))
  2074. )
  2075. }
  2076. fn repo_delete_hook(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  2077. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2078. let mut auth_headers = HashMap::<String, String>::new();
  2079. let mut auth_query = HashMap::<String, String>::new();
  2080. if let Some(ref apikey) = configuration.api_key {
  2081. let key = apikey.key.clone();
  2082. let val = match apikey.prefix {
  2083. Some(ref prefix) => format!("{} {}", prefix, key),
  2084. None => key,
  2085. };
  2086. auth_query.insert("access_token".to_owned(), val);
  2087. };
  2088. if let Some(ref apikey) = configuration.api_key {
  2089. let key = apikey.key.clone();
  2090. let val = match apikey.prefix {
  2091. Some(ref prefix) => format!("{} {}", prefix, key),
  2092. None => key,
  2093. };
  2094. auth_headers.insert("Authorization".to_owned(), val);
  2095. };
  2096. if let Some(ref auth_conf) = configuration.basic_auth {
  2097. let auth = hyper::header::Authorization(
  2098. hyper::header::Basic {
  2099. username: auth_conf.0.to_owned(),
  2100. password: auth_conf.1.to_owned(),
  2101. }
  2102. );
  2103. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2104. };
  2105. if let Some(ref apikey) = configuration.api_key {
  2106. let key = apikey.key.clone();
  2107. let val = match apikey.prefix {
  2108. Some(ref prefix) => format!("{} {}", prefix, key),
  2109. None => key,
  2110. };
  2111. auth_headers.insert("Sudo".to_owned(), val);
  2112. };
  2113. if let Some(ref apikey) = configuration.api_key {
  2114. let key = apikey.key.clone();
  2115. let val = match apikey.prefix {
  2116. Some(ref prefix) => format!("{} {}", prefix, key),
  2117. None => key,
  2118. };
  2119. auth_query.insert("sudo".to_owned(), val);
  2120. };
  2121. if let Some(ref apikey) = configuration.api_key {
  2122. let key = apikey.key.clone();
  2123. let val = match apikey.prefix {
  2124. Some(ref prefix) => format!("{} {}", prefix, key),
  2125. None => key,
  2126. };
  2127. auth_query.insert("token".to_owned(), val);
  2128. };
  2129. let method = hyper::Method::Delete;
  2130. let query_string = {
  2131. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2132. for (key, val) in &auth_query {
  2133. query.append_pair(key, val);
  2134. }
  2135. query.finish()
  2136. };
  2137. let uri_str = format!("{}/repos/{owner}/{repo}/hooks/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  2138. // TODO(farcaller): handle error
  2139. // if let Err(e) = uri {
  2140. // return Box::new(futures::future::err(e));
  2141. // }
  2142. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2143. let mut req = hyper::Request::new(method, uri);
  2144. if let Some(ref user_agent) = configuration.user_agent {
  2145. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2146. }
  2147. for (key, val) in auth_headers {
  2148. req.headers_mut().set_raw(key, val);
  2149. }
  2150. // send request
  2151. Box::new(
  2152. configuration.client.request(req)
  2153. .map_err(|e| Error::from(e))
  2154. .and_then(|resp| {
  2155. let status = resp.status();
  2156. resp.body().concat2()
  2157. .and_then(move |body| Ok((status, body)))
  2158. .map_err(|e| Error::from(e))
  2159. })
  2160. .and_then(|(status, body)| {
  2161. if status.is_success() {
  2162. Ok(body)
  2163. } else {
  2164. Err(Error::from((status, &*body)))
  2165. }
  2166. })
  2167. .and_then(|_| futures::future::ok(()))
  2168. )
  2169. }
  2170. fn repo_delete_key(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  2171. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2172. let mut auth_headers = HashMap::<String, String>::new();
  2173. let mut auth_query = HashMap::<String, String>::new();
  2174. if let Some(ref apikey) = configuration.api_key {
  2175. let key = apikey.key.clone();
  2176. let val = match apikey.prefix {
  2177. Some(ref prefix) => format!("{} {}", prefix, key),
  2178. None => key,
  2179. };
  2180. auth_query.insert("access_token".to_owned(), val);
  2181. };
  2182. if let Some(ref apikey) = configuration.api_key {
  2183. let key = apikey.key.clone();
  2184. let val = match apikey.prefix {
  2185. Some(ref prefix) => format!("{} {}", prefix, key),
  2186. None => key,
  2187. };
  2188. auth_headers.insert("Authorization".to_owned(), val);
  2189. };
  2190. if let Some(ref auth_conf) = configuration.basic_auth {
  2191. let auth = hyper::header::Authorization(
  2192. hyper::header::Basic {
  2193. username: auth_conf.0.to_owned(),
  2194. password: auth_conf.1.to_owned(),
  2195. }
  2196. );
  2197. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2198. };
  2199. if let Some(ref apikey) = configuration.api_key {
  2200. let key = apikey.key.clone();
  2201. let val = match apikey.prefix {
  2202. Some(ref prefix) => format!("{} {}", prefix, key),
  2203. None => key,
  2204. };
  2205. auth_headers.insert("Sudo".to_owned(), val);
  2206. };
  2207. if let Some(ref apikey) = configuration.api_key {
  2208. let key = apikey.key.clone();
  2209. let val = match apikey.prefix {
  2210. Some(ref prefix) => format!("{} {}", prefix, key),
  2211. None => key,
  2212. };
  2213. auth_query.insert("sudo".to_owned(), val);
  2214. };
  2215. if let Some(ref apikey) = configuration.api_key {
  2216. let key = apikey.key.clone();
  2217. let val = match apikey.prefix {
  2218. Some(ref prefix) => format!("{} {}", prefix, key),
  2219. None => key,
  2220. };
  2221. auth_query.insert("token".to_owned(), val);
  2222. };
  2223. let method = hyper::Method::Delete;
  2224. let query_string = {
  2225. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2226. for (key, val) in &auth_query {
  2227. query.append_pair(key, val);
  2228. }
  2229. query.finish()
  2230. };
  2231. let uri_str = format!("{}/repos/{owner}/{repo}/keys/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  2232. // TODO(farcaller): handle error
  2233. // if let Err(e) = uri {
  2234. // return Box::new(futures::future::err(e));
  2235. // }
  2236. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2237. let mut req = hyper::Request::new(method, uri);
  2238. if let Some(ref user_agent) = configuration.user_agent {
  2239. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2240. }
  2241. for (key, val) in auth_headers {
  2242. req.headers_mut().set_raw(key, val);
  2243. }
  2244. // send request
  2245. Box::new(
  2246. configuration.client.request(req)
  2247. .map_err(|e| Error::from(e))
  2248. .and_then(|resp| {
  2249. let status = resp.status();
  2250. resp.body().concat2()
  2251. .and_then(move |body| Ok((status, body)))
  2252. .map_err(|e| Error::from(e))
  2253. })
  2254. .and_then(|(status, body)| {
  2255. if status.is_success() {
  2256. Ok(body)
  2257. } else {
  2258. Err(Error::from((status, &*body)))
  2259. }
  2260. })
  2261. .and_then(|_| futures::future::ok(()))
  2262. )
  2263. }
  2264. fn repo_delete_release(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  2265. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2266. let mut auth_headers = HashMap::<String, String>::new();
  2267. let mut auth_query = HashMap::<String, String>::new();
  2268. if let Some(ref apikey) = configuration.api_key {
  2269. let key = apikey.key.clone();
  2270. let val = match apikey.prefix {
  2271. Some(ref prefix) => format!("{} {}", prefix, key),
  2272. None => key,
  2273. };
  2274. auth_query.insert("access_token".to_owned(), val);
  2275. };
  2276. if let Some(ref apikey) = configuration.api_key {
  2277. let key = apikey.key.clone();
  2278. let val = match apikey.prefix {
  2279. Some(ref prefix) => format!("{} {}", prefix, key),
  2280. None => key,
  2281. };
  2282. auth_headers.insert("Authorization".to_owned(), val);
  2283. };
  2284. if let Some(ref auth_conf) = configuration.basic_auth {
  2285. let auth = hyper::header::Authorization(
  2286. hyper::header::Basic {
  2287. username: auth_conf.0.to_owned(),
  2288. password: auth_conf.1.to_owned(),
  2289. }
  2290. );
  2291. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2292. };
  2293. if let Some(ref apikey) = configuration.api_key {
  2294. let key = apikey.key.clone();
  2295. let val = match apikey.prefix {
  2296. Some(ref prefix) => format!("{} {}", prefix, key),
  2297. None => key,
  2298. };
  2299. auth_headers.insert("Sudo".to_owned(), val);
  2300. };
  2301. if let Some(ref apikey) = configuration.api_key {
  2302. let key = apikey.key.clone();
  2303. let val = match apikey.prefix {
  2304. Some(ref prefix) => format!("{} {}", prefix, key),
  2305. None => key,
  2306. };
  2307. auth_query.insert("sudo".to_owned(), val);
  2308. };
  2309. if let Some(ref apikey) = configuration.api_key {
  2310. let key = apikey.key.clone();
  2311. let val = match apikey.prefix {
  2312. Some(ref prefix) => format!("{} {}", prefix, key),
  2313. None => key,
  2314. };
  2315. auth_query.insert("token".to_owned(), val);
  2316. };
  2317. let method = hyper::Method::Delete;
  2318. let query_string = {
  2319. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2320. for (key, val) in &auth_query {
  2321. query.append_pair(key, val);
  2322. }
  2323. query.finish()
  2324. };
  2325. let uri_str = format!("{}/repos/{owner}/{repo}/releases/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  2326. // TODO(farcaller): handle error
  2327. // if let Err(e) = uri {
  2328. // return Box::new(futures::future::err(e));
  2329. // }
  2330. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2331. let mut req = hyper::Request::new(method, uri);
  2332. if let Some(ref user_agent) = configuration.user_agent {
  2333. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2334. }
  2335. for (key, val) in auth_headers {
  2336. req.headers_mut().set_raw(key, val);
  2337. }
  2338. // send request
  2339. Box::new(
  2340. configuration.client.request(req)
  2341. .map_err(|e| Error::from(e))
  2342. .and_then(|resp| {
  2343. let status = resp.status();
  2344. resp.body().concat2()
  2345. .and_then(move |body| Ok((status, body)))
  2346. .map_err(|e| Error::from(e))
  2347. })
  2348. .and_then(|(status, body)| {
  2349. if status.is_success() {
  2350. Ok(body)
  2351. } else {
  2352. Err(Error::from((status, &*body)))
  2353. }
  2354. })
  2355. .and_then(|_| futures::future::ok(()))
  2356. )
  2357. }
  2358. fn repo_delete_release_attachment(&self, owner: &str, repo: &str, id: i64, attachment_id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  2359. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2360. let mut auth_headers = HashMap::<String, String>::new();
  2361. let mut auth_query = HashMap::<String, String>::new();
  2362. if let Some(ref apikey) = configuration.api_key {
  2363. let key = apikey.key.clone();
  2364. let val = match apikey.prefix {
  2365. Some(ref prefix) => format!("{} {}", prefix, key),
  2366. None => key,
  2367. };
  2368. auth_query.insert("access_token".to_owned(), val);
  2369. };
  2370. if let Some(ref apikey) = configuration.api_key {
  2371. let key = apikey.key.clone();
  2372. let val = match apikey.prefix {
  2373. Some(ref prefix) => format!("{} {}", prefix, key),
  2374. None => key,
  2375. };
  2376. auth_headers.insert("Authorization".to_owned(), val);
  2377. };
  2378. if let Some(ref auth_conf) = configuration.basic_auth {
  2379. let auth = hyper::header::Authorization(
  2380. hyper::header::Basic {
  2381. username: auth_conf.0.to_owned(),
  2382. password: auth_conf.1.to_owned(),
  2383. }
  2384. );
  2385. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2386. };
  2387. if let Some(ref apikey) = configuration.api_key {
  2388. let key = apikey.key.clone();
  2389. let val = match apikey.prefix {
  2390. Some(ref prefix) => format!("{} {}", prefix, key),
  2391. None => key,
  2392. };
  2393. auth_headers.insert("Sudo".to_owned(), val);
  2394. };
  2395. if let Some(ref apikey) = configuration.api_key {
  2396. let key = apikey.key.clone();
  2397. let val = match apikey.prefix {
  2398. Some(ref prefix) => format!("{} {}", prefix, key),
  2399. None => key,
  2400. };
  2401. auth_query.insert("sudo".to_owned(), val);
  2402. };
  2403. if let Some(ref apikey) = configuration.api_key {
  2404. let key = apikey.key.clone();
  2405. let val = match apikey.prefix {
  2406. Some(ref prefix) => format!("{} {}", prefix, key),
  2407. None => key,
  2408. };
  2409. auth_query.insert("token".to_owned(), val);
  2410. };
  2411. let method = hyper::Method::Delete;
  2412. let query_string = {
  2413. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2414. for (key, val) in &auth_query {
  2415. query.append_pair(key, val);
  2416. }
  2417. query.finish()
  2418. };
  2419. let uri_str = format!("{}/repos/{owner}/{repo}/releases/{id}/assets/{attachment_id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id, attachment_id=attachment_id);
  2420. // TODO(farcaller): handle error
  2421. // if let Err(e) = uri {
  2422. // return Box::new(futures::future::err(e));
  2423. // }
  2424. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2425. let mut req = hyper::Request::new(method, uri);
  2426. if let Some(ref user_agent) = configuration.user_agent {
  2427. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2428. }
  2429. for (key, val) in auth_headers {
  2430. req.headers_mut().set_raw(key, val);
  2431. }
  2432. // send request
  2433. Box::new(
  2434. configuration.client.request(req)
  2435. .map_err(|e| Error::from(e))
  2436. .and_then(|resp| {
  2437. let status = resp.status();
  2438. resp.body().concat2()
  2439. .and_then(move |body| Ok((status, body)))
  2440. .map_err(|e| Error::from(e))
  2441. })
  2442. .and_then(|(status, body)| {
  2443. if status.is_success() {
  2444. Ok(body)
  2445. } else {
  2446. Err(Error::from((status, &*body)))
  2447. }
  2448. })
  2449. .and_then(|_| futures::future::ok(()))
  2450. )
  2451. }
  2452. fn repo_delete_topic(&self, owner: &str, repo: &str, topic: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  2453. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2454. let mut auth_headers = HashMap::<String, String>::new();
  2455. let mut auth_query = HashMap::<String, String>::new();
  2456. if let Some(ref apikey) = configuration.api_key {
  2457. let key = apikey.key.clone();
  2458. let val = match apikey.prefix {
  2459. Some(ref prefix) => format!("{} {}", prefix, key),
  2460. None => key,
  2461. };
  2462. auth_query.insert("access_token".to_owned(), val);
  2463. };
  2464. if let Some(ref apikey) = configuration.api_key {
  2465. let key = apikey.key.clone();
  2466. let val = match apikey.prefix {
  2467. Some(ref prefix) => format!("{} {}", prefix, key),
  2468. None => key,
  2469. };
  2470. auth_headers.insert("Authorization".to_owned(), val);
  2471. };
  2472. if let Some(ref auth_conf) = configuration.basic_auth {
  2473. let auth = hyper::header::Authorization(
  2474. hyper::header::Basic {
  2475. username: auth_conf.0.to_owned(),
  2476. password: auth_conf.1.to_owned(),
  2477. }
  2478. );
  2479. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2480. };
  2481. if let Some(ref apikey) = configuration.api_key {
  2482. let key = apikey.key.clone();
  2483. let val = match apikey.prefix {
  2484. Some(ref prefix) => format!("{} {}", prefix, key),
  2485. None => key,
  2486. };
  2487. auth_headers.insert("Sudo".to_owned(), val);
  2488. };
  2489. if let Some(ref apikey) = configuration.api_key {
  2490. let key = apikey.key.clone();
  2491. let val = match apikey.prefix {
  2492. Some(ref prefix) => format!("{} {}", prefix, key),
  2493. None => key,
  2494. };
  2495. auth_query.insert("sudo".to_owned(), val);
  2496. };
  2497. if let Some(ref apikey) = configuration.api_key {
  2498. let key = apikey.key.clone();
  2499. let val = match apikey.prefix {
  2500. Some(ref prefix) => format!("{} {}", prefix, key),
  2501. None => key,
  2502. };
  2503. auth_query.insert("token".to_owned(), val);
  2504. };
  2505. let method = hyper::Method::Delete;
  2506. let query_string = {
  2507. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2508. for (key, val) in &auth_query {
  2509. query.append_pair(key, val);
  2510. }
  2511. query.finish()
  2512. };
  2513. let uri_str = format!("{}/repos/{owner}/{repo}/topics/{topic}?{}", configuration.base_path, query_string, owner=owner, repo=repo, topic=topic);
  2514. // TODO(farcaller): handle error
  2515. // if let Err(e) = uri {
  2516. // return Box::new(futures::future::err(e));
  2517. // }
  2518. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2519. let mut req = hyper::Request::new(method, uri);
  2520. if let Some(ref user_agent) = configuration.user_agent {
  2521. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2522. }
  2523. for (key, val) in auth_headers {
  2524. req.headers_mut().set_raw(key, val);
  2525. }
  2526. // send request
  2527. Box::new(
  2528. configuration.client.request(req)
  2529. .map_err(|e| Error::from(e))
  2530. .and_then(|resp| {
  2531. let status = resp.status();
  2532. resp.body().concat2()
  2533. .and_then(move |body| Ok((status, body)))
  2534. .map_err(|e| Error::from(e))
  2535. })
  2536. .and_then(|(status, body)| {
  2537. if status.is_success() {
  2538. Ok(body)
  2539. } else {
  2540. Err(Error::from((status, &*body)))
  2541. }
  2542. })
  2543. .and_then(|_| futures::future::ok(()))
  2544. )
  2545. }
  2546. fn repo_edit(&self, owner: &str, repo: &str, body: ::models::EditRepoOption) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>> {
  2547. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2548. let mut auth_headers = HashMap::<String, String>::new();
  2549. let mut auth_query = HashMap::<String, String>::new();
  2550. if let Some(ref apikey) = configuration.api_key {
  2551. let key = apikey.key.clone();
  2552. let val = match apikey.prefix {
  2553. Some(ref prefix) => format!("{} {}", prefix, key),
  2554. None => key,
  2555. };
  2556. auth_query.insert("access_token".to_owned(), val);
  2557. };
  2558. if let Some(ref apikey) = configuration.api_key {
  2559. let key = apikey.key.clone();
  2560. let val = match apikey.prefix {
  2561. Some(ref prefix) => format!("{} {}", prefix, key),
  2562. None => key,
  2563. };
  2564. auth_headers.insert("Authorization".to_owned(), val);
  2565. };
  2566. if let Some(ref auth_conf) = configuration.basic_auth {
  2567. let auth = hyper::header::Authorization(
  2568. hyper::header::Basic {
  2569. username: auth_conf.0.to_owned(),
  2570. password: auth_conf.1.to_owned(),
  2571. }
  2572. );
  2573. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2574. };
  2575. if let Some(ref apikey) = configuration.api_key {
  2576. let key = apikey.key.clone();
  2577. let val = match apikey.prefix {
  2578. Some(ref prefix) => format!("{} {}", prefix, key),
  2579. None => key,
  2580. };
  2581. auth_headers.insert("Sudo".to_owned(), val);
  2582. };
  2583. if let Some(ref apikey) = configuration.api_key {
  2584. let key = apikey.key.clone();
  2585. let val = match apikey.prefix {
  2586. Some(ref prefix) => format!("{} {}", prefix, key),
  2587. None => key,
  2588. };
  2589. auth_query.insert("sudo".to_owned(), val);
  2590. };
  2591. if let Some(ref apikey) = configuration.api_key {
  2592. let key = apikey.key.clone();
  2593. let val = match apikey.prefix {
  2594. Some(ref prefix) => format!("{} {}", prefix, key),
  2595. None => key,
  2596. };
  2597. auth_query.insert("token".to_owned(), val);
  2598. };
  2599. let method = hyper::Method::Patch;
  2600. let query_string = {
  2601. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2602. for (key, val) in &auth_query {
  2603. query.append_pair(key, val);
  2604. }
  2605. query.finish()
  2606. };
  2607. let uri_str = format!("{}/repos/{owner}/{repo}?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  2608. // TODO(farcaller): handle error
  2609. // if let Err(e) = uri {
  2610. // return Box::new(futures::future::err(e));
  2611. // }
  2612. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2613. let mut req = hyper::Request::new(method, uri);
  2614. if let Some(ref user_agent) = configuration.user_agent {
  2615. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2616. }
  2617. for (key, val) in auth_headers {
  2618. req.headers_mut().set_raw(key, val);
  2619. }
  2620. let serialized = serde_json::to_string(&body).unwrap();
  2621. req.headers_mut().set(hyper::header::ContentType::json());
  2622. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  2623. req.set_body(serialized);
  2624. // send request
  2625. Box::new(
  2626. configuration.client.request(req)
  2627. .map_err(|e| Error::from(e))
  2628. .and_then(|resp| {
  2629. let status = resp.status();
  2630. resp.body().concat2()
  2631. .and_then(move |body| Ok((status, body)))
  2632. .map_err(|e| Error::from(e))
  2633. })
  2634. .and_then(|(status, body)| {
  2635. if status.is_success() {
  2636. Ok(body)
  2637. } else {
  2638. Err(Error::from((status, &*body)))
  2639. }
  2640. })
  2641. .and_then(|body| {
  2642. let parsed: Result<::models::Repository, _> = serde_json::from_slice(&body);
  2643. parsed.map_err(|e| Error::from(e))
  2644. })
  2645. )
  2646. }
  2647. fn repo_edit_git_hook(&self, owner: &str, repo: &str, id: &str, body: ::models::EditGitHookOption) -> Box<Future<Item = ::models::GitHook, Error = Error<serde_json::Value>>> {
  2648. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2649. let mut auth_headers = HashMap::<String, String>::new();
  2650. let mut auth_query = HashMap::<String, String>::new();
  2651. if let Some(ref apikey) = configuration.api_key {
  2652. let key = apikey.key.clone();
  2653. let val = match apikey.prefix {
  2654. Some(ref prefix) => format!("{} {}", prefix, key),
  2655. None => key,
  2656. };
  2657. auth_query.insert("access_token".to_owned(), val);
  2658. };
  2659. if let Some(ref apikey) = configuration.api_key {
  2660. let key = apikey.key.clone();
  2661. let val = match apikey.prefix {
  2662. Some(ref prefix) => format!("{} {}", prefix, key),
  2663. None => key,
  2664. };
  2665. auth_headers.insert("Authorization".to_owned(), val);
  2666. };
  2667. if let Some(ref auth_conf) = configuration.basic_auth {
  2668. let auth = hyper::header::Authorization(
  2669. hyper::header::Basic {
  2670. username: auth_conf.0.to_owned(),
  2671. password: auth_conf.1.to_owned(),
  2672. }
  2673. );
  2674. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2675. };
  2676. if let Some(ref apikey) = configuration.api_key {
  2677. let key = apikey.key.clone();
  2678. let val = match apikey.prefix {
  2679. Some(ref prefix) => format!("{} {}", prefix, key),
  2680. None => key,
  2681. };
  2682. auth_headers.insert("Sudo".to_owned(), val);
  2683. };
  2684. if let Some(ref apikey) = configuration.api_key {
  2685. let key = apikey.key.clone();
  2686. let val = match apikey.prefix {
  2687. Some(ref prefix) => format!("{} {}", prefix, key),
  2688. None => key,
  2689. };
  2690. auth_query.insert("sudo".to_owned(), val);
  2691. };
  2692. if let Some(ref apikey) = configuration.api_key {
  2693. let key = apikey.key.clone();
  2694. let val = match apikey.prefix {
  2695. Some(ref prefix) => format!("{} {}", prefix, key),
  2696. None => key,
  2697. };
  2698. auth_query.insert("token".to_owned(), val);
  2699. };
  2700. let method = hyper::Method::Patch;
  2701. let query_string = {
  2702. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2703. for (key, val) in &auth_query {
  2704. query.append_pair(key, val);
  2705. }
  2706. query.finish()
  2707. };
  2708. let uri_str = format!("{}/repos/{owner}/{repo}/hooks/git/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  2709. // TODO(farcaller): handle error
  2710. // if let Err(e) = uri {
  2711. // return Box::new(futures::future::err(e));
  2712. // }
  2713. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2714. let mut req = hyper::Request::new(method, uri);
  2715. if let Some(ref user_agent) = configuration.user_agent {
  2716. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2717. }
  2718. for (key, val) in auth_headers {
  2719. req.headers_mut().set_raw(key, val);
  2720. }
  2721. let serialized = serde_json::to_string(&body).unwrap();
  2722. req.headers_mut().set(hyper::header::ContentType::json());
  2723. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  2724. req.set_body(serialized);
  2725. // send request
  2726. Box::new(
  2727. configuration.client.request(req)
  2728. .map_err(|e| Error::from(e))
  2729. .and_then(|resp| {
  2730. let status = resp.status();
  2731. resp.body().concat2()
  2732. .and_then(move |body| Ok((status, body)))
  2733. .map_err(|e| Error::from(e))
  2734. })
  2735. .and_then(|(status, body)| {
  2736. if status.is_success() {
  2737. Ok(body)
  2738. } else {
  2739. Err(Error::from((status, &*body)))
  2740. }
  2741. })
  2742. .and_then(|body| {
  2743. let parsed: Result<::models::GitHook, _> = serde_json::from_slice(&body);
  2744. parsed.map_err(|e| Error::from(e))
  2745. })
  2746. )
  2747. }
  2748. fn repo_edit_hook(&self, owner: &str, repo: &str, id: i64, body: ::models::EditHookOption) -> Box<Future<Item = ::models::Hook, Error = Error<serde_json::Value>>> {
  2749. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2750. let mut auth_headers = HashMap::<String, String>::new();
  2751. let mut auth_query = HashMap::<String, String>::new();
  2752. if let Some(ref apikey) = configuration.api_key {
  2753. let key = apikey.key.clone();
  2754. let val = match apikey.prefix {
  2755. Some(ref prefix) => format!("{} {}", prefix, key),
  2756. None => key,
  2757. };
  2758. auth_query.insert("access_token".to_owned(), val);
  2759. };
  2760. if let Some(ref apikey) = configuration.api_key {
  2761. let key = apikey.key.clone();
  2762. let val = match apikey.prefix {
  2763. Some(ref prefix) => format!("{} {}", prefix, key),
  2764. None => key,
  2765. };
  2766. auth_headers.insert("Authorization".to_owned(), val);
  2767. };
  2768. if let Some(ref auth_conf) = configuration.basic_auth {
  2769. let auth = hyper::header::Authorization(
  2770. hyper::header::Basic {
  2771. username: auth_conf.0.to_owned(),
  2772. password: auth_conf.1.to_owned(),
  2773. }
  2774. );
  2775. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2776. };
  2777. if let Some(ref apikey) = configuration.api_key {
  2778. let key = apikey.key.clone();
  2779. let val = match apikey.prefix {
  2780. Some(ref prefix) => format!("{} {}", prefix, key),
  2781. None => key,
  2782. };
  2783. auth_headers.insert("Sudo".to_owned(), val);
  2784. };
  2785. if let Some(ref apikey) = configuration.api_key {
  2786. let key = apikey.key.clone();
  2787. let val = match apikey.prefix {
  2788. Some(ref prefix) => format!("{} {}", prefix, key),
  2789. None => key,
  2790. };
  2791. auth_query.insert("sudo".to_owned(), val);
  2792. };
  2793. if let Some(ref apikey) = configuration.api_key {
  2794. let key = apikey.key.clone();
  2795. let val = match apikey.prefix {
  2796. Some(ref prefix) => format!("{} {}", prefix, key),
  2797. None => key,
  2798. };
  2799. auth_query.insert("token".to_owned(), val);
  2800. };
  2801. let method = hyper::Method::Patch;
  2802. let query_string = {
  2803. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2804. for (key, val) in &auth_query {
  2805. query.append_pair(key, val);
  2806. }
  2807. query.finish()
  2808. };
  2809. let uri_str = format!("{}/repos/{owner}/{repo}/hooks/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  2810. // TODO(farcaller): handle error
  2811. // if let Err(e) = uri {
  2812. // return Box::new(futures::future::err(e));
  2813. // }
  2814. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2815. let mut req = hyper::Request::new(method, uri);
  2816. if let Some(ref user_agent) = configuration.user_agent {
  2817. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2818. }
  2819. for (key, val) in auth_headers {
  2820. req.headers_mut().set_raw(key, val);
  2821. }
  2822. let serialized = serde_json::to_string(&body).unwrap();
  2823. req.headers_mut().set(hyper::header::ContentType::json());
  2824. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  2825. req.set_body(serialized);
  2826. // send request
  2827. Box::new(
  2828. configuration.client.request(req)
  2829. .map_err(|e| Error::from(e))
  2830. .and_then(|resp| {
  2831. let status = resp.status();
  2832. resp.body().concat2()
  2833. .and_then(move |body| Ok((status, body)))
  2834. .map_err(|e| Error::from(e))
  2835. })
  2836. .and_then(|(status, body)| {
  2837. if status.is_success() {
  2838. Ok(body)
  2839. } else {
  2840. Err(Error::from((status, &*body)))
  2841. }
  2842. })
  2843. .and_then(|body| {
  2844. let parsed: Result<::models::Hook, _> = serde_json::from_slice(&body);
  2845. parsed.map_err(|e| Error::from(e))
  2846. })
  2847. )
  2848. }
  2849. fn repo_edit_pull_request(&self, owner: &str, repo: &str, index: i64, body: ::models::EditPullRequestOption) -> Box<Future<Item = ::models::PullRequest, Error = Error<serde_json::Value>>> {
  2850. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2851. let mut auth_headers = HashMap::<String, String>::new();
  2852. let mut auth_query = HashMap::<String, String>::new();
  2853. if let Some(ref apikey) = configuration.api_key {
  2854. let key = apikey.key.clone();
  2855. let val = match apikey.prefix {
  2856. Some(ref prefix) => format!("{} {}", prefix, key),
  2857. None => key,
  2858. };
  2859. auth_query.insert("access_token".to_owned(), val);
  2860. };
  2861. if let Some(ref apikey) = configuration.api_key {
  2862. let key = apikey.key.clone();
  2863. let val = match apikey.prefix {
  2864. Some(ref prefix) => format!("{} {}", prefix, key),
  2865. None => key,
  2866. };
  2867. auth_headers.insert("Authorization".to_owned(), val);
  2868. };
  2869. if let Some(ref auth_conf) = configuration.basic_auth {
  2870. let auth = hyper::header::Authorization(
  2871. hyper::header::Basic {
  2872. username: auth_conf.0.to_owned(),
  2873. password: auth_conf.1.to_owned(),
  2874. }
  2875. );
  2876. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2877. };
  2878. if let Some(ref apikey) = configuration.api_key {
  2879. let key = apikey.key.clone();
  2880. let val = match apikey.prefix {
  2881. Some(ref prefix) => format!("{} {}", prefix, key),
  2882. None => key,
  2883. };
  2884. auth_headers.insert("Sudo".to_owned(), val);
  2885. };
  2886. if let Some(ref apikey) = configuration.api_key {
  2887. let key = apikey.key.clone();
  2888. let val = match apikey.prefix {
  2889. Some(ref prefix) => format!("{} {}", prefix, key),
  2890. None => key,
  2891. };
  2892. auth_query.insert("sudo".to_owned(), val);
  2893. };
  2894. if let Some(ref apikey) = configuration.api_key {
  2895. let key = apikey.key.clone();
  2896. let val = match apikey.prefix {
  2897. Some(ref prefix) => format!("{} {}", prefix, key),
  2898. None => key,
  2899. };
  2900. auth_query.insert("token".to_owned(), val);
  2901. };
  2902. let method = hyper::Method::Patch;
  2903. let query_string = {
  2904. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2905. for (key, val) in &auth_query {
  2906. query.append_pair(key, val);
  2907. }
  2908. query.finish()
  2909. };
  2910. let uri_str = format!("{}/repos/{owner}/{repo}/pulls/{index}?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  2911. // TODO(farcaller): handle error
  2912. // if let Err(e) = uri {
  2913. // return Box::new(futures::future::err(e));
  2914. // }
  2915. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2916. let mut req = hyper::Request::new(method, uri);
  2917. if let Some(ref user_agent) = configuration.user_agent {
  2918. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2919. }
  2920. for (key, val) in auth_headers {
  2921. req.headers_mut().set_raw(key, val);
  2922. }
  2923. let serialized = serde_json::to_string(&body).unwrap();
  2924. req.headers_mut().set(hyper::header::ContentType::json());
  2925. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  2926. req.set_body(serialized);
  2927. // send request
  2928. Box::new(
  2929. configuration.client.request(req)
  2930. .map_err(|e| Error::from(e))
  2931. .and_then(|resp| {
  2932. let status = resp.status();
  2933. resp.body().concat2()
  2934. .and_then(move |body| Ok((status, body)))
  2935. .map_err(|e| Error::from(e))
  2936. })
  2937. .and_then(|(status, body)| {
  2938. if status.is_success() {
  2939. Ok(body)
  2940. } else {
  2941. Err(Error::from((status, &*body)))
  2942. }
  2943. })
  2944. .and_then(|body| {
  2945. let parsed: Result<::models::PullRequest, _> = serde_json::from_slice(&body);
  2946. parsed.map_err(|e| Error::from(e))
  2947. })
  2948. )
  2949. }
  2950. fn repo_edit_release(&self, owner: &str, repo: &str, id: i64, body: ::models::EditReleaseOption) -> Box<Future<Item = ::models::Release, Error = Error<serde_json::Value>>> {
  2951. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2952. let mut auth_headers = HashMap::<String, String>::new();
  2953. let mut auth_query = HashMap::<String, String>::new();
  2954. if let Some(ref apikey) = configuration.api_key {
  2955. let key = apikey.key.clone();
  2956. let val = match apikey.prefix {
  2957. Some(ref prefix) => format!("{} {}", prefix, key),
  2958. None => key,
  2959. };
  2960. auth_query.insert("access_token".to_owned(), val);
  2961. };
  2962. if let Some(ref apikey) = configuration.api_key {
  2963. let key = apikey.key.clone();
  2964. let val = match apikey.prefix {
  2965. Some(ref prefix) => format!("{} {}", prefix, key),
  2966. None => key,
  2967. };
  2968. auth_headers.insert("Authorization".to_owned(), val);
  2969. };
  2970. if let Some(ref auth_conf) = configuration.basic_auth {
  2971. let auth = hyper::header::Authorization(
  2972. hyper::header::Basic {
  2973. username: auth_conf.0.to_owned(),
  2974. password: auth_conf.1.to_owned(),
  2975. }
  2976. );
  2977. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2978. };
  2979. if let Some(ref apikey) = configuration.api_key {
  2980. let key = apikey.key.clone();
  2981. let val = match apikey.prefix {
  2982. Some(ref prefix) => format!("{} {}", prefix, key),
  2983. None => key,
  2984. };
  2985. auth_headers.insert("Sudo".to_owned(), val);
  2986. };
  2987. if let Some(ref apikey) = configuration.api_key {
  2988. let key = apikey.key.clone();
  2989. let val = match apikey.prefix {
  2990. Some(ref prefix) => format!("{} {}", prefix, key),
  2991. None => key,
  2992. };
  2993. auth_query.insert("sudo".to_owned(), val);
  2994. };
  2995. if let Some(ref apikey) = configuration.api_key {
  2996. let key = apikey.key.clone();
  2997. let val = match apikey.prefix {
  2998. Some(ref prefix) => format!("{} {}", prefix, key),
  2999. None => key,
  3000. };
  3001. auth_query.insert("token".to_owned(), val);
  3002. };
  3003. let method = hyper::Method::Patch;
  3004. let query_string = {
  3005. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3006. for (key, val) in &auth_query {
  3007. query.append_pair(key, val);
  3008. }
  3009. query.finish()
  3010. };
  3011. let uri_str = format!("{}/repos/{owner}/{repo}/releases/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  3012. // TODO(farcaller): handle error
  3013. // if let Err(e) = uri {
  3014. // return Box::new(futures::future::err(e));
  3015. // }
  3016. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3017. let mut req = hyper::Request::new(method, uri);
  3018. if let Some(ref user_agent) = configuration.user_agent {
  3019. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3020. }
  3021. for (key, val) in auth_headers {
  3022. req.headers_mut().set_raw(key, val);
  3023. }
  3024. let serialized = serde_json::to_string(&body).unwrap();
  3025. req.headers_mut().set(hyper::header::ContentType::json());
  3026. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  3027. req.set_body(serialized);
  3028. // send request
  3029. Box::new(
  3030. configuration.client.request(req)
  3031. .map_err(|e| Error::from(e))
  3032. .and_then(|resp| {
  3033. let status = resp.status();
  3034. resp.body().concat2()
  3035. .and_then(move |body| Ok((status, body)))
  3036. .map_err(|e| Error::from(e))
  3037. })
  3038. .and_then(|(status, body)| {
  3039. if status.is_success() {
  3040. Ok(body)
  3041. } else {
  3042. Err(Error::from((status, &*body)))
  3043. }
  3044. })
  3045. .and_then(|body| {
  3046. let parsed: Result<::models::Release, _> = serde_json::from_slice(&body);
  3047. parsed.map_err(|e| Error::from(e))
  3048. })
  3049. )
  3050. }
  3051. fn repo_edit_release_attachment(&self, owner: &str, repo: &str, id: i64, attachment_id: i64, body: ::models::EditAttachmentOptions) -> Box<Future<Item = ::models::Attachment, Error = Error<serde_json::Value>>> {
  3052. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3053. let mut auth_headers = HashMap::<String, String>::new();
  3054. let mut auth_query = HashMap::<String, String>::new();
  3055. if let Some(ref apikey) = configuration.api_key {
  3056. let key = apikey.key.clone();
  3057. let val = match apikey.prefix {
  3058. Some(ref prefix) => format!("{} {}", prefix, key),
  3059. None => key,
  3060. };
  3061. auth_query.insert("access_token".to_owned(), val);
  3062. };
  3063. if let Some(ref apikey) = configuration.api_key {
  3064. let key = apikey.key.clone();
  3065. let val = match apikey.prefix {
  3066. Some(ref prefix) => format!("{} {}", prefix, key),
  3067. None => key,
  3068. };
  3069. auth_headers.insert("Authorization".to_owned(), val);
  3070. };
  3071. if let Some(ref auth_conf) = configuration.basic_auth {
  3072. let auth = hyper::header::Authorization(
  3073. hyper::header::Basic {
  3074. username: auth_conf.0.to_owned(),
  3075. password: auth_conf.1.to_owned(),
  3076. }
  3077. );
  3078. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3079. };
  3080. if let Some(ref apikey) = configuration.api_key {
  3081. let key = apikey.key.clone();
  3082. let val = match apikey.prefix {
  3083. Some(ref prefix) => format!("{} {}", prefix, key),
  3084. None => key,
  3085. };
  3086. auth_headers.insert("Sudo".to_owned(), val);
  3087. };
  3088. if let Some(ref apikey) = configuration.api_key {
  3089. let key = apikey.key.clone();
  3090. let val = match apikey.prefix {
  3091. Some(ref prefix) => format!("{} {}", prefix, key),
  3092. None => key,
  3093. };
  3094. auth_query.insert("sudo".to_owned(), val);
  3095. };
  3096. if let Some(ref apikey) = configuration.api_key {
  3097. let key = apikey.key.clone();
  3098. let val = match apikey.prefix {
  3099. Some(ref prefix) => format!("{} {}", prefix, key),
  3100. None => key,
  3101. };
  3102. auth_query.insert("token".to_owned(), val);
  3103. };
  3104. let method = hyper::Method::Patch;
  3105. let query_string = {
  3106. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3107. for (key, val) in &auth_query {
  3108. query.append_pair(key, val);
  3109. }
  3110. query.finish()
  3111. };
  3112. let uri_str = format!("{}/repos/{owner}/{repo}/releases/{id}/assets/{attachment_id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id, attachment_id=attachment_id);
  3113. // TODO(farcaller): handle error
  3114. // if let Err(e) = uri {
  3115. // return Box::new(futures::future::err(e));
  3116. // }
  3117. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3118. let mut req = hyper::Request::new(method, uri);
  3119. if let Some(ref user_agent) = configuration.user_agent {
  3120. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3121. }
  3122. for (key, val) in auth_headers {
  3123. req.headers_mut().set_raw(key, val);
  3124. }
  3125. let serialized = serde_json::to_string(&body).unwrap();
  3126. req.headers_mut().set(hyper::header::ContentType::json());
  3127. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  3128. req.set_body(serialized);
  3129. // send request
  3130. Box::new(
  3131. configuration.client.request(req)
  3132. .map_err(|e| Error::from(e))
  3133. .and_then(|resp| {
  3134. let status = resp.status();
  3135. resp.body().concat2()
  3136. .and_then(move |body| Ok((status, body)))
  3137. .map_err(|e| Error::from(e))
  3138. })
  3139. .and_then(|(status, body)| {
  3140. if status.is_success() {
  3141. Ok(body)
  3142. } else {
  3143. Err(Error::from((status, &*body)))
  3144. }
  3145. })
  3146. .and_then(|body| {
  3147. let parsed: Result<::models::Attachment, _> = serde_json::from_slice(&body);
  3148. parsed.map_err(|e| Error::from(e))
  3149. })
  3150. )
  3151. }
  3152. fn repo_get(&self, owner: &str, repo: &str) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>> {
  3153. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3154. let mut auth_headers = HashMap::<String, String>::new();
  3155. let mut auth_query = HashMap::<String, String>::new();
  3156. if let Some(ref apikey) = configuration.api_key {
  3157. let key = apikey.key.clone();
  3158. let val = match apikey.prefix {
  3159. Some(ref prefix) => format!("{} {}", prefix, key),
  3160. None => key,
  3161. };
  3162. auth_query.insert("access_token".to_owned(), val);
  3163. };
  3164. if let Some(ref apikey) = configuration.api_key {
  3165. let key = apikey.key.clone();
  3166. let val = match apikey.prefix {
  3167. Some(ref prefix) => format!("{} {}", prefix, key),
  3168. None => key,
  3169. };
  3170. auth_headers.insert("Authorization".to_owned(), val);
  3171. };
  3172. if let Some(ref auth_conf) = configuration.basic_auth {
  3173. let auth = hyper::header::Authorization(
  3174. hyper::header::Basic {
  3175. username: auth_conf.0.to_owned(),
  3176. password: auth_conf.1.to_owned(),
  3177. }
  3178. );
  3179. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3180. };
  3181. if let Some(ref apikey) = configuration.api_key {
  3182. let key = apikey.key.clone();
  3183. let val = match apikey.prefix {
  3184. Some(ref prefix) => format!("{} {}", prefix, key),
  3185. None => key,
  3186. };
  3187. //auth_headers.insert("Sudo".to_owned(), val);
  3188. };
  3189. if let Some(ref apikey) = configuration.api_key {
  3190. let key = apikey.key.clone();
  3191. let val = match apikey.prefix {
  3192. Some(ref prefix) => format!("{} {}", prefix, key),
  3193. None => key,
  3194. };
  3195. //auth_query.insert("sudo".to_owned(), val);
  3196. };
  3197. if let Some(ref apikey) = configuration.api_key {
  3198. let key = apikey.key.clone();
  3199. let val = match apikey.prefix {
  3200. Some(ref prefix) => format!("{} {}", prefix, key),
  3201. None => key,
  3202. };
  3203. auth_query.insert("token".to_owned(), val);
  3204. };
  3205. let method = hyper::Method::Get;
  3206. let query_string = {
  3207. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3208. for (key, val) in &auth_query {
  3209. query.append_pair(key, val);
  3210. }
  3211. query.finish()
  3212. };
  3213. let uri_str = format!("{}/repos/{owner}/{repo}?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  3214. // TODO(farcaller): handle error
  3215. // if let Err(e) = uri {
  3216. // return Box::new(futures::future::err(e));
  3217. // }
  3218. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3219. let mut req = hyper::Request::new(method, uri);
  3220. if let Some(ref user_agent) = configuration.user_agent {
  3221. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3222. }
  3223. for (key, val) in auth_headers {
  3224. req.headers_mut().set_raw(key, val);
  3225. }
  3226. // send request
  3227. Box::new(
  3228. configuration.client.request(req)
  3229. .map_err(|e| Error::from(e))
  3230. .and_then(|resp| {
  3231. let status = resp.status();
  3232. resp.body().concat2()
  3233. .and_then(move |body| Ok((status, body)))
  3234. .map_err(|e| Error::from(e))
  3235. })
  3236. .and_then(|(status, body)| {
  3237. if status.is_success() {
  3238. Ok(body)
  3239. } else {
  3240. Err(Error::from((status, &*body)))
  3241. }
  3242. })
  3243. .and_then(|body| {
  3244. let parsed: Result<::models::Repository, _> = serde_json::from_slice(&body);
  3245. parsed.map_err(|e| Error::from(e))
  3246. })
  3247. )
  3248. }
  3249. fn repo_get_all_commits(&self, owner: &str, repo: &str, sha: &str, page: i32) -> Box<Future<Item = Vec<::models::Commit>, Error = Error<serde_json::Value>>> {
  3250. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3251. let mut auth_headers = HashMap::<String, String>::new();
  3252. let mut auth_query = HashMap::<String, String>::new();
  3253. if let Some(ref apikey) = configuration.api_key {
  3254. let key = apikey.key.clone();
  3255. let val = match apikey.prefix {
  3256. Some(ref prefix) => format!("{} {}", prefix, key),
  3257. None => key,
  3258. };
  3259. auth_query.insert("access_token".to_owned(), val);
  3260. };
  3261. if let Some(ref apikey) = configuration.api_key {
  3262. let key = apikey.key.clone();
  3263. let val = match apikey.prefix {
  3264. Some(ref prefix) => format!("{} {}", prefix, key),
  3265. None => key,
  3266. };
  3267. auth_headers.insert("Authorization".to_owned(), val);
  3268. };
  3269. if let Some(ref auth_conf) = configuration.basic_auth {
  3270. let auth = hyper::header::Authorization(
  3271. hyper::header::Basic {
  3272. username: auth_conf.0.to_owned(),
  3273. password: auth_conf.1.to_owned(),
  3274. }
  3275. );
  3276. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3277. };
  3278. if let Some(ref apikey) = configuration.api_key {
  3279. let key = apikey.key.clone();
  3280. let val = match apikey.prefix {
  3281. Some(ref prefix) => format!("{} {}", prefix, key),
  3282. None => key,
  3283. };
  3284. auth_headers.insert("Sudo".to_owned(), val);
  3285. };
  3286. if let Some(ref apikey) = configuration.api_key {
  3287. let key = apikey.key.clone();
  3288. let val = match apikey.prefix {
  3289. Some(ref prefix) => format!("{} {}", prefix, key),
  3290. None => key,
  3291. };
  3292. auth_query.insert("sudo".to_owned(), val);
  3293. };
  3294. if let Some(ref apikey) = configuration.api_key {
  3295. let key = apikey.key.clone();
  3296. let val = match apikey.prefix {
  3297. Some(ref prefix) => format!("{} {}", prefix, key),
  3298. None => key,
  3299. };
  3300. auth_query.insert("token".to_owned(), val);
  3301. };
  3302. let method = hyper::Method::Get;
  3303. let query_string = {
  3304. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3305. query.append_pair("sha", &sha.to_string());
  3306. query.append_pair("page", &page.to_string());
  3307. for (key, val) in &auth_query {
  3308. query.append_pair(key, val);
  3309. }
  3310. query.finish()
  3311. };
  3312. let uri_str = format!("{}/repos/{owner}/{repo}/commits?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  3313. // TODO(farcaller): handle error
  3314. // if let Err(e) = uri {
  3315. // return Box::new(futures::future::err(e));
  3316. // }
  3317. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3318. let mut req = hyper::Request::new(method, uri);
  3319. if let Some(ref user_agent) = configuration.user_agent {
  3320. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3321. }
  3322. for (key, val) in auth_headers {
  3323. req.headers_mut().set_raw(key, val);
  3324. }
  3325. // send request
  3326. Box::new(
  3327. configuration.client.request(req)
  3328. .map_err(|e| Error::from(e))
  3329. .and_then(|resp| {
  3330. let status = resp.status();
  3331. resp.body().concat2()
  3332. .and_then(move |body| Ok((status, body)))
  3333. .map_err(|e| Error::from(e))
  3334. })
  3335. .and_then(|(status, body)| {
  3336. if status.is_success() {
  3337. Ok(body)
  3338. } else {
  3339. Err(Error::from((status, &*body)))
  3340. }
  3341. })
  3342. .and_then(|body| {
  3343. let parsed: Result<Vec<::models::Commit>, _> = serde_json::from_slice(&body);
  3344. parsed.map_err(|e| Error::from(e))
  3345. })
  3346. )
  3347. }
  3348. fn repo_get_archive(&self, owner: &str, repo: &str, archive: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  3349. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3350. let mut auth_headers = HashMap::<String, String>::new();
  3351. let mut auth_query = HashMap::<String, String>::new();
  3352. if let Some(ref apikey) = configuration.api_key {
  3353. let key = apikey.key.clone();
  3354. let val = match apikey.prefix {
  3355. Some(ref prefix) => format!("{} {}", prefix, key),
  3356. None => key,
  3357. };
  3358. auth_query.insert("access_token".to_owned(), val);
  3359. };
  3360. if let Some(ref apikey) = configuration.api_key {
  3361. let key = apikey.key.clone();
  3362. let val = match apikey.prefix {
  3363. Some(ref prefix) => format!("{} {}", prefix, key),
  3364. None => key,
  3365. };
  3366. auth_headers.insert("Authorization".to_owned(), val);
  3367. };
  3368. if let Some(ref auth_conf) = configuration.basic_auth {
  3369. let auth = hyper::header::Authorization(
  3370. hyper::header::Basic {
  3371. username: auth_conf.0.to_owned(),
  3372. password: auth_conf.1.to_owned(),
  3373. }
  3374. );
  3375. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3376. };
  3377. if let Some(ref apikey) = configuration.api_key {
  3378. let key = apikey.key.clone();
  3379. let val = match apikey.prefix {
  3380. Some(ref prefix) => format!("{} {}", prefix, key),
  3381. None => key,
  3382. };
  3383. auth_headers.insert("Sudo".to_owned(), val);
  3384. };
  3385. if let Some(ref apikey) = configuration.api_key {
  3386. let key = apikey.key.clone();
  3387. let val = match apikey.prefix {
  3388. Some(ref prefix) => format!("{} {}", prefix, key),
  3389. None => key,
  3390. };
  3391. auth_query.insert("sudo".to_owned(), val);
  3392. };
  3393. if let Some(ref apikey) = configuration.api_key {
  3394. let key = apikey.key.clone();
  3395. let val = match apikey.prefix {
  3396. Some(ref prefix) => format!("{} {}", prefix, key),
  3397. None => key,
  3398. };
  3399. auth_query.insert("token".to_owned(), val);
  3400. };
  3401. let method = hyper::Method::Get;
  3402. let query_string = {
  3403. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3404. for (key, val) in &auth_query {
  3405. query.append_pair(key, val);
  3406. }
  3407. query.finish()
  3408. };
  3409. let uri_str = format!("{}/repos/{owner}/{repo}/archive/{archive}?{}", configuration.base_path, query_string, owner=owner, repo=repo, archive=archive);
  3410. // TODO(farcaller): handle error
  3411. // if let Err(e) = uri {
  3412. // return Box::new(futures::future::err(e));
  3413. // }
  3414. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3415. let mut req = hyper::Request::new(method, uri);
  3416. if let Some(ref user_agent) = configuration.user_agent {
  3417. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3418. }
  3419. for (key, val) in auth_headers {
  3420. req.headers_mut().set_raw(key, val);
  3421. }
  3422. // send request
  3423. Box::new(
  3424. configuration.client.request(req)
  3425. .map_err(|e| Error::from(e))
  3426. .and_then(|resp| {
  3427. let status = resp.status();
  3428. resp.body().concat2()
  3429. .and_then(move |body| Ok((status, body)))
  3430. .map_err(|e| Error::from(e))
  3431. })
  3432. .and_then(|(status, body)| {
  3433. if status.is_success() {
  3434. Ok(body)
  3435. } else {
  3436. Err(Error::from((status, &*body)))
  3437. }
  3438. })
  3439. .and_then(|_| futures::future::ok(()))
  3440. )
  3441. }
  3442. fn repo_get_branch(&self, owner: &str, repo: &str, branch: &str) -> Box<Future<Item = ::models::Branch, Error = Error<serde_json::Value>>> {
  3443. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3444. let mut auth_headers = HashMap::<String, String>::new();
  3445. let mut auth_query = HashMap::<String, String>::new();
  3446. if let Some(ref apikey) = configuration.api_key {
  3447. let key = apikey.key.clone();
  3448. let val = match apikey.prefix {
  3449. Some(ref prefix) => format!("{} {}", prefix, key),
  3450. None => key,
  3451. };
  3452. auth_query.insert("access_token".to_owned(), val);
  3453. };
  3454. if let Some(ref apikey) = configuration.api_key {
  3455. let key = apikey.key.clone();
  3456. let val = match apikey.prefix {
  3457. Some(ref prefix) => format!("{} {}", prefix, key),
  3458. None => key,
  3459. };
  3460. auth_headers.insert("Authorization".to_owned(), val);
  3461. };
  3462. if let Some(ref auth_conf) = configuration.basic_auth {
  3463. let auth = hyper::header::Authorization(
  3464. hyper::header::Basic {
  3465. username: auth_conf.0.to_owned(),
  3466. password: auth_conf.1.to_owned(),
  3467. }
  3468. );
  3469. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3470. };
  3471. if let Some(ref apikey) = configuration.api_key {
  3472. let key = apikey.key.clone();
  3473. let val = match apikey.prefix {
  3474. Some(ref prefix) => format!("{} {}", prefix, key),
  3475. None => key,
  3476. };
  3477. auth_headers.insert("Sudo".to_owned(), val);
  3478. };
  3479. if let Some(ref apikey) = configuration.api_key {
  3480. let key = apikey.key.clone();
  3481. let val = match apikey.prefix {
  3482. Some(ref prefix) => format!("{} {}", prefix, key),
  3483. None => key,
  3484. };
  3485. auth_query.insert("sudo".to_owned(), val);
  3486. };
  3487. if let Some(ref apikey) = configuration.api_key {
  3488. let key = apikey.key.clone();
  3489. let val = match apikey.prefix {
  3490. Some(ref prefix) => format!("{} {}", prefix, key),
  3491. None => key,
  3492. };
  3493. auth_query.insert("token".to_owned(), val);
  3494. };
  3495. let method = hyper::Method::Get;
  3496. let query_string = {
  3497. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3498. for (key, val) in &auth_query {
  3499. query.append_pair(key, val);
  3500. }
  3501. query.finish()
  3502. };
  3503. let uri_str = format!("{}/repos/{owner}/{repo}/branches/{branch}?{}", configuration.base_path, query_string, owner=owner, repo=repo, branch=branch);
  3504. // TODO(farcaller): handle error
  3505. // if let Err(e) = uri {
  3506. // return Box::new(futures::future::err(e));
  3507. // }
  3508. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3509. let mut req = hyper::Request::new(method, uri);
  3510. if let Some(ref user_agent) = configuration.user_agent {
  3511. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3512. }
  3513. for (key, val) in auth_headers {
  3514. req.headers_mut().set_raw(key, val);
  3515. }
  3516. // send request
  3517. Box::new(
  3518. configuration.client.request(req)
  3519. .map_err(|e| Error::from(e))
  3520. .and_then(|resp| {
  3521. let status = resp.status();
  3522. resp.body().concat2()
  3523. .and_then(move |body| Ok((status, body)))
  3524. .map_err(|e| Error::from(e))
  3525. })
  3526. .and_then(|(status, body)| {
  3527. if status.is_success() {
  3528. Ok(body)
  3529. } else {
  3530. Err(Error::from((status, &*body)))
  3531. }
  3532. })
  3533. .and_then(|body| {
  3534. let parsed: Result<::models::Branch, _> = serde_json::from_slice(&body);
  3535. parsed.map_err(|e| Error::from(e))
  3536. })
  3537. )
  3538. }
  3539. fn repo_get_by_id(&self, id: i64) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>> {
  3540. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3541. let mut auth_headers = HashMap::<String, String>::new();
  3542. let mut auth_query = HashMap::<String, String>::new();
  3543. if let Some(ref apikey) = configuration.api_key {
  3544. let key = apikey.key.clone();
  3545. let val = match apikey.prefix {
  3546. Some(ref prefix) => format!("{} {}", prefix, key),
  3547. None => key,
  3548. };
  3549. auth_query.insert("access_token".to_owned(), val);
  3550. };
  3551. if let Some(ref apikey) = configuration.api_key {
  3552. let key = apikey.key.clone();
  3553. let val = match apikey.prefix {
  3554. Some(ref prefix) => format!("{} {}", prefix, key),
  3555. None => key,
  3556. };
  3557. auth_headers.insert("Authorization".to_owned(), val);
  3558. };
  3559. if let Some(ref auth_conf) = configuration.basic_auth {
  3560. let auth = hyper::header::Authorization(
  3561. hyper::header::Basic {
  3562. username: auth_conf.0.to_owned(),
  3563. password: auth_conf.1.to_owned(),
  3564. }
  3565. );
  3566. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3567. };
  3568. if let Some(ref apikey) = configuration.api_key {
  3569. let key = apikey.key.clone();
  3570. let val = match apikey.prefix {
  3571. Some(ref prefix) => format!("{} {}", prefix, key),
  3572. None => key,
  3573. };
  3574. auth_headers.insert("Sudo".to_owned(), val);
  3575. };
  3576. if let Some(ref apikey) = configuration.api_key {
  3577. let key = apikey.key.clone();
  3578. let val = match apikey.prefix {
  3579. Some(ref prefix) => format!("{} {}", prefix, key),
  3580. None => key,
  3581. };
  3582. auth_query.insert("sudo".to_owned(), val);
  3583. };
  3584. if let Some(ref apikey) = configuration.api_key {
  3585. let key = apikey.key.clone();
  3586. let val = match apikey.prefix {
  3587. Some(ref prefix) => format!("{} {}", prefix, key),
  3588. None => key,
  3589. };
  3590. auth_query.insert("token".to_owned(), val);
  3591. };
  3592. let method = hyper::Method::Get;
  3593. let query_string = {
  3594. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3595. for (key, val) in &auth_query {
  3596. query.append_pair(key, val);
  3597. }
  3598. query.finish()
  3599. };
  3600. let uri_str = format!("{}/repositories/{id}?{}", configuration.base_path, query_string, id=id);
  3601. // TODO(farcaller): handle error
  3602. // if let Err(e) = uri {
  3603. // return Box::new(futures::future::err(e));
  3604. // }
  3605. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3606. let mut req = hyper::Request::new(method, uri);
  3607. if let Some(ref user_agent) = configuration.user_agent {
  3608. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3609. }
  3610. for (key, val) in auth_headers {
  3611. req.headers_mut().set_raw(key, val);
  3612. }
  3613. // send request
  3614. Box::new(
  3615. configuration.client.request(req)
  3616. .map_err(|e| Error::from(e))
  3617. .and_then(|resp| {
  3618. let status = resp.status();
  3619. resp.body().concat2()
  3620. .and_then(move |body| Ok((status, body)))
  3621. .map_err(|e| Error::from(e))
  3622. })
  3623. .and_then(|(status, body)| {
  3624. if status.is_success() {
  3625. Ok(body)
  3626. } else {
  3627. Err(Error::from((status, &*body)))
  3628. }
  3629. })
  3630. .and_then(|body| {
  3631. let parsed: Result<::models::Repository, _> = serde_json::from_slice(&body);
  3632. parsed.map_err(|e| Error::from(e))
  3633. })
  3634. )
  3635. }
  3636. fn repo_get_combined_status_by_ref(&self, owner: &str, repo: &str, _ref: &str, page: i32) -> Box<Future<Item = ::models::Status, Error = Error<serde_json::Value>>> {
  3637. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3638. let mut auth_headers = HashMap::<String, String>::new();
  3639. let mut auth_query = HashMap::<String, String>::new();
  3640. if let Some(ref apikey) = configuration.api_key {
  3641. let key = apikey.key.clone();
  3642. let val = match apikey.prefix {
  3643. Some(ref prefix) => format!("{} {}", prefix, key),
  3644. None => key,
  3645. };
  3646. auth_query.insert("access_token".to_owned(), val);
  3647. };
  3648. if let Some(ref apikey) = configuration.api_key {
  3649. let key = apikey.key.clone();
  3650. let val = match apikey.prefix {
  3651. Some(ref prefix) => format!("{} {}", prefix, key),
  3652. None => key,
  3653. };
  3654. auth_headers.insert("Authorization".to_owned(), val);
  3655. };
  3656. if let Some(ref auth_conf) = configuration.basic_auth {
  3657. let auth = hyper::header::Authorization(
  3658. hyper::header::Basic {
  3659. username: auth_conf.0.to_owned(),
  3660. password: auth_conf.1.to_owned(),
  3661. }
  3662. );
  3663. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3664. };
  3665. if let Some(ref apikey) = configuration.api_key {
  3666. let key = apikey.key.clone();
  3667. let val = match apikey.prefix {
  3668. Some(ref prefix) => format!("{} {}", prefix, key),
  3669. None => key,
  3670. };
  3671. auth_headers.insert("Sudo".to_owned(), val);
  3672. };
  3673. if let Some(ref apikey) = configuration.api_key {
  3674. let key = apikey.key.clone();
  3675. let val = match apikey.prefix {
  3676. Some(ref prefix) => format!("{} {}", prefix, key),
  3677. None => key,
  3678. };
  3679. auth_query.insert("sudo".to_owned(), val);
  3680. };
  3681. if let Some(ref apikey) = configuration.api_key {
  3682. let key = apikey.key.clone();
  3683. let val = match apikey.prefix {
  3684. Some(ref prefix) => format!("{} {}", prefix, key),
  3685. None => key,
  3686. };
  3687. auth_query.insert("token".to_owned(), val);
  3688. };
  3689. let method = hyper::Method::Get;
  3690. let query_string = {
  3691. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3692. query.append_pair("page", &page.to_string());
  3693. for (key, val) in &auth_query {
  3694. query.append_pair(key, val);
  3695. }
  3696. query.finish()
  3697. };
  3698. let uri_str = format!("{}/repos/{owner}/{repo}/commits/{ref}/statuses?{}", configuration.base_path, query_string, owner=owner, repo=repo, ref=_ref);
  3699. // TODO(farcaller): handle error
  3700. // if let Err(e) = uri {
  3701. // return Box::new(futures::future::err(e));
  3702. // }
  3703. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3704. let mut req = hyper::Request::new(method, uri);
  3705. if let Some(ref user_agent) = configuration.user_agent {
  3706. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3707. }
  3708. for (key, val) in auth_headers {
  3709. req.headers_mut().set_raw(key, val);
  3710. }
  3711. // send request
  3712. Box::new(
  3713. configuration.client.request(req)
  3714. .map_err(|e| Error::from(e))
  3715. .and_then(|resp| {
  3716. let status = resp.status();
  3717. resp.body().concat2()
  3718. .and_then(move |body| Ok((status, body)))
  3719. .map_err(|e| Error::from(e))
  3720. })
  3721. .and_then(|(status, body)| {
  3722. if status.is_success() {
  3723. Ok(body)
  3724. } else {
  3725. Err(Error::from((status, &*body)))
  3726. }
  3727. })
  3728. .and_then(|body| {
  3729. let parsed: Result<::models::Status, _> = serde_json::from_slice(&body);
  3730. parsed.map_err(|e| Error::from(e))
  3731. })
  3732. )
  3733. }
  3734. fn repo_get_contents(&self, owner: &str, repo: &str, filepath: &str, _ref: &str) -> Box<Future<Item = ::models::ContentsResponse, Error = Error<serde_json::Value>>> {
  3735. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3736. let mut auth_headers = HashMap::<String, String>::new();
  3737. let mut auth_query = HashMap::<String, String>::new();
  3738. if let Some(ref apikey) = configuration.api_key {
  3739. let key = apikey.key.clone();
  3740. let val = match apikey.prefix {
  3741. Some(ref prefix) => format!("{} {}", prefix, key),
  3742. None => key,
  3743. };
  3744. auth_query.insert("access_token".to_owned(), val);
  3745. };
  3746. if let Some(ref apikey) = configuration.api_key {
  3747. let key = apikey.key.clone();
  3748. let val = match apikey.prefix {
  3749. Some(ref prefix) => format!("{} {}", prefix, key),
  3750. None => key,
  3751. };
  3752. auth_headers.insert("Authorization".to_owned(), val);
  3753. };
  3754. if let Some(ref auth_conf) = configuration.basic_auth {
  3755. let auth = hyper::header::Authorization(
  3756. hyper::header::Basic {
  3757. username: auth_conf.0.to_owned(),
  3758. password: auth_conf.1.to_owned(),
  3759. }
  3760. );
  3761. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3762. };
  3763. if let Some(ref apikey) = configuration.api_key {
  3764. let key = apikey.key.clone();
  3765. let val = match apikey.prefix {
  3766. Some(ref prefix) => format!("{} {}", prefix, key),
  3767. None => key,
  3768. };
  3769. auth_headers.insert("Sudo".to_owned(), val);
  3770. };
  3771. if let Some(ref apikey) = configuration.api_key {
  3772. let key = apikey.key.clone();
  3773. let val = match apikey.prefix {
  3774. Some(ref prefix) => format!("{} {}", prefix, key),
  3775. None => key,
  3776. };
  3777. auth_query.insert("sudo".to_owned(), val);
  3778. };
  3779. if let Some(ref apikey) = configuration.api_key {
  3780. let key = apikey.key.clone();
  3781. let val = match apikey.prefix {
  3782. Some(ref prefix) => format!("{} {}", prefix, key),
  3783. None => key,
  3784. };
  3785. auth_query.insert("token".to_owned(), val);
  3786. };
  3787. let method = hyper::Method::Get;
  3788. let query_string = {
  3789. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3790. query.append_pair("ref", &_ref.to_string());
  3791. for (key, val) in &auth_query {
  3792. query.append_pair(key, val);
  3793. }
  3794. query.finish()
  3795. };
  3796. let uri_str = format!("{}/repos/{owner}/{repo}/contents/{filepath}?{}", configuration.base_path, query_string, owner=owner, repo=repo, filepath=filepath);
  3797. // TODO(farcaller): handle error
  3798. // if let Err(e) = uri {
  3799. // return Box::new(futures::future::err(e));
  3800. // }
  3801. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3802. let mut req = hyper::Request::new(method, uri);
  3803. if let Some(ref user_agent) = configuration.user_agent {
  3804. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3805. }
  3806. for (key, val) in auth_headers {
  3807. req.headers_mut().set_raw(key, val);
  3808. }
  3809. // send request
  3810. Box::new(
  3811. configuration.client.request(req)
  3812. .map_err(|e| Error::from(e))
  3813. .and_then(|resp| {
  3814. let status = resp.status();
  3815. resp.body().concat2()
  3816. .and_then(move |body| Ok((status, body)))
  3817. .map_err(|e| Error::from(e))
  3818. })
  3819. .and_then(|(status, body)| {
  3820. if status.is_success() {
  3821. Ok(body)
  3822. } else {
  3823. Err(Error::from((status, &*body)))
  3824. }
  3825. })
  3826. .and_then(|body| {
  3827. let parsed: Result<::models::ContentsResponse, _> = serde_json::from_slice(&body);
  3828. parsed.map_err(|e| Error::from(e))
  3829. })
  3830. )
  3831. }
  3832. fn repo_get_contents_list(&self, owner: &str, repo: &str, _ref: &str) -> Box<Future<Item = Vec<::models::ContentsResponse>, Error = Error<serde_json::Value>>> {
  3833. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3834. let mut auth_headers = HashMap::<String, String>::new();
  3835. let mut auth_query = HashMap::<String, String>::new();
  3836. if let Some(ref apikey) = configuration.api_key {
  3837. let key = apikey.key.clone();
  3838. let val = match apikey.prefix {
  3839. Some(ref prefix) => format!("{} {}", prefix, key),
  3840. None => key,
  3841. };
  3842. auth_query.insert("access_token".to_owned(), val);
  3843. };
  3844. if let Some(ref apikey) = configuration.api_key {
  3845. let key = apikey.key.clone();
  3846. let val = match apikey.prefix {
  3847. Some(ref prefix) => format!("{} {}", prefix, key),
  3848. None => key,
  3849. };
  3850. auth_headers.insert("Authorization".to_owned(), val);
  3851. };
  3852. if let Some(ref auth_conf) = configuration.basic_auth {
  3853. let auth = hyper::header::Authorization(
  3854. hyper::header::Basic {
  3855. username: auth_conf.0.to_owned(),
  3856. password: auth_conf.1.to_owned(),
  3857. }
  3858. );
  3859. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3860. };
  3861. if let Some(ref apikey) = configuration.api_key {
  3862. let key = apikey.key.clone();
  3863. let val = match apikey.prefix {
  3864. Some(ref prefix) => format!("{} {}", prefix, key),
  3865. None => key,
  3866. };
  3867. auth_headers.insert("Sudo".to_owned(), val);
  3868. };
  3869. if let Some(ref apikey) = configuration.api_key {
  3870. let key = apikey.key.clone();
  3871. let val = match apikey.prefix {
  3872. Some(ref prefix) => format!("{} {}", prefix, key),
  3873. None => key,
  3874. };
  3875. auth_query.insert("sudo".to_owned(), val);
  3876. };
  3877. if let Some(ref apikey) = configuration.api_key {
  3878. let key = apikey.key.clone();
  3879. let val = match apikey.prefix {
  3880. Some(ref prefix) => format!("{} {}", prefix, key),
  3881. None => key,
  3882. };
  3883. auth_query.insert("token".to_owned(), val);
  3884. };
  3885. let method = hyper::Method::Get;
  3886. let query_string = {
  3887. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3888. query.append_pair("ref", &_ref.to_string());
  3889. for (key, val) in &auth_query {
  3890. query.append_pair(key, val);
  3891. }
  3892. query.finish()
  3893. };
  3894. let uri_str = format!("{}/repos/{owner}/{repo}/contents?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  3895. // TODO(farcaller): handle error
  3896. // if let Err(e) = uri {
  3897. // return Box::new(futures::future::err(e));
  3898. // }
  3899. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3900. let mut req = hyper::Request::new(method, uri);
  3901. if let Some(ref user_agent) = configuration.user_agent {
  3902. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3903. }
  3904. for (key, val) in auth_headers {
  3905. req.headers_mut().set_raw(key, val);
  3906. }
  3907. // send request
  3908. Box::new(
  3909. configuration.client.request(req)
  3910. .map_err(|e| Error::from(e))
  3911. .and_then(|resp| {
  3912. let status = resp.status();
  3913. resp.body().concat2()
  3914. .and_then(move |body| Ok((status, body)))
  3915. .map_err(|e| Error::from(e))
  3916. })
  3917. .and_then(|(status, body)| {
  3918. if status.is_success() {
  3919. Ok(body)
  3920. } else {
  3921. Err(Error::from((status, &*body)))
  3922. }
  3923. })
  3924. .and_then(|body| {
  3925. let parsed: Result<Vec<::models::ContentsResponse>, _> = serde_json::from_slice(&body);
  3926. parsed.map_err(|e| Error::from(e))
  3927. })
  3928. )
  3929. }
  3930. fn repo_get_editor_config(&self, owner: &str, repo: &str, filepath: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  3931. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3932. let mut auth_headers = HashMap::<String, String>::new();
  3933. let mut auth_query = HashMap::<String, String>::new();
  3934. if let Some(ref apikey) = configuration.api_key {
  3935. let key = apikey.key.clone();
  3936. let val = match apikey.prefix {
  3937. Some(ref prefix) => format!("{} {}", prefix, key),
  3938. None => key,
  3939. };
  3940. auth_query.insert("access_token".to_owned(), val);
  3941. };
  3942. if let Some(ref apikey) = configuration.api_key {
  3943. let key = apikey.key.clone();
  3944. let val = match apikey.prefix {
  3945. Some(ref prefix) => format!("{} {}", prefix, key),
  3946. None => key,
  3947. };
  3948. auth_headers.insert("Authorization".to_owned(), val);
  3949. };
  3950. if let Some(ref auth_conf) = configuration.basic_auth {
  3951. let auth = hyper::header::Authorization(
  3952. hyper::header::Basic {
  3953. username: auth_conf.0.to_owned(),
  3954. password: auth_conf.1.to_owned(),
  3955. }
  3956. );
  3957. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3958. };
  3959. if let Some(ref apikey) = configuration.api_key {
  3960. let key = apikey.key.clone();
  3961. let val = match apikey.prefix {
  3962. Some(ref prefix) => format!("{} {}", prefix, key),
  3963. None => key,
  3964. };
  3965. auth_headers.insert("Sudo".to_owned(), val);
  3966. };
  3967. if let Some(ref apikey) = configuration.api_key {
  3968. let key = apikey.key.clone();
  3969. let val = match apikey.prefix {
  3970. Some(ref prefix) => format!("{} {}", prefix, key),
  3971. None => key,
  3972. };
  3973. auth_query.insert("sudo".to_owned(), val);
  3974. };
  3975. if let Some(ref apikey) = configuration.api_key {
  3976. let key = apikey.key.clone();
  3977. let val = match apikey.prefix {
  3978. Some(ref prefix) => format!("{} {}", prefix, key),
  3979. None => key,
  3980. };
  3981. auth_query.insert("token".to_owned(), val);
  3982. };
  3983. let method = hyper::Method::Get;
  3984. let query_string = {
  3985. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3986. for (key, val) in &auth_query {
  3987. query.append_pair(key, val);
  3988. }
  3989. query.finish()
  3990. };
  3991. let uri_str = format!("{}/repos/{owner}/{repo}/editorconfig/{filepath}?{}", configuration.base_path, query_string, owner=owner, repo=repo, filepath=filepath);
  3992. // TODO(farcaller): handle error
  3993. // if let Err(e) = uri {
  3994. // return Box::new(futures::future::err(e));
  3995. // }
  3996. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3997. let mut req = hyper::Request::new(method, uri);
  3998. if let Some(ref user_agent) = configuration.user_agent {
  3999. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  4000. }
  4001. for (key, val) in auth_headers {
  4002. req.headers_mut().set_raw(key, val);
  4003. }
  4004. // send request
  4005. Box::new(
  4006. configuration.client.request(req)
  4007. .map_err(|e| Error::from(e))
  4008. .and_then(|resp| {
  4009. let status = resp.status();
  4010. resp.body().concat2()
  4011. .and_then(move |body| Ok((status, body)))
  4012. .map_err(|e| Error::from(e))
  4013. })
  4014. .and_then(|(status, body)| {
  4015. if status.is_success() {
  4016. Ok(body)
  4017. } else {
  4018. Err(Error::from((status, &*body)))
  4019. }
  4020. })
  4021. .and_then(|_| futures::future::ok(()))
  4022. )
  4023. }
  4024. fn repo_get_git_hook(&self, owner: &str, repo: &str, id: &str) -> Box<Future<Item = ::models::GitHook, Error = Error<serde_json::Value>>> {
  4025. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  4026. let mut auth_headers = HashMap::<String, String>::new();
  4027. let mut auth_query = HashMap::<String, String>::new();
  4028. if let Some(ref apikey) = configuration.api_key {
  4029. let key = apikey.key.clone();
  4030. let val = match apikey.prefix {
  4031. Some(ref prefix) => format!("{} {}", prefix, key),
  4032. None => key,
  4033. };
  4034. auth_query.insert("access_token".to_owned(), val);
  4035. };
  4036. if let Some(ref apikey) = configuration.api_key {
  4037. let key = apikey.key.clone();
  4038. let val = match apikey.prefix {
  4039. Some(ref prefix) => format!("{} {}", prefix, key),
  4040. None => key,
  4041. };
  4042. auth_headers.insert("Authorization".to_owned(), val);
  4043. };
  4044. if let Some(ref auth_conf) = configuration.basic_auth {
  4045. let auth = hyper::header::Authorization(
  4046. hyper::header::Basic {
  4047. username: auth_conf.0.to_owned(),
  4048. password: auth_conf.1.to_owned(),
  4049. }
  4050. );
  4051. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  4052. };
  4053. if let Some(ref apikey) = configuration.api_key {
  4054. let key = apikey.key.clone();
  4055. let val = match apikey.prefix {
  4056. Some(ref prefix) => format!("{} {}", prefix, key),
  4057. None => key,
  4058. };
  4059. auth_headers.insert("Sudo".to_owned(), val);
  4060. };
  4061. if let Some(ref apikey) = configuration.api_key {
  4062. let key = apikey.key.clone();
  4063. let val = match apikey.prefix {
  4064. Some(ref prefix) => format!("{} {}", prefix, key),
  4065. None => key,
  4066. };
  4067. auth_query.insert("sudo".to_owned(), val);
  4068. };
  4069. if let Some(ref apikey) = configuration.api_key {
  4070. let key = apikey.key.clone();
  4071. let val = match apikey.prefix {
  4072. Some(ref prefix) => format!("{} {}", prefix, key),
  4073. None => key,
  4074. };
  4075. auth_query.insert("token".to_owned(), val);
  4076. };
  4077. let method = hyper::Method::Get;
  4078. let query_string = {
  4079. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  4080. for (key, val) in &auth_query {
  4081. query.append_pair(key, val);
  4082. }
  4083. query.finish()
  4084. };
  4085. let uri_str = format!("{}/repos/{owner}/{repo}/hooks/git/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  4086. // TODO(farcaller): handle error
  4087. // if let Err(e) = uri {
  4088. // return Box::new(futures::future::err(e));
  4089. // }
  4090. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  4091. let mut req = hyper::Request::new(method, uri);
  4092. if let Some(ref user_agent) = configuration.user_agent {
  4093. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  4094. }
  4095. for (key, val) in auth_headers {
  4096. req.headers_mut().set_raw(key, val);
  4097. }
  4098. // send request
  4099. Box::new(
  4100. configuration.client.request(req)
  4101. .map_err(|e| Error::from(e))
  4102. .and_then(|resp| {
  4103. let status = resp.status();
  4104. resp.body().concat2()
  4105. .and_then(move |body| Ok((status, body)))
  4106. .map_err(|e| Error::from(e))
  4107. })
  4108. .and_then(|(status, body)| {
  4109. if status.is_success() {
  4110. Ok(body)
  4111. } else {
  4112. Err(Error::from((status, &*body)))
  4113. }
  4114. })
  4115. .and_then(|body| {
  4116. let parsed: Result<::models::GitHook, _> = serde_json::from_slice(&body);
  4117. parsed.map_err(|e| Error::from(e))
  4118. })
  4119. )
  4120. }
  4121. fn repo_get_hook(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = ::models::Hook, Error = Error<serde_json::Value>>> {
  4122. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  4123. let mut auth_headers = HashMap::<String, String>::new();
  4124. let mut auth_query = HashMap::<String, String>::new();
  4125. if let Some(ref apikey) = configuration.api_key {
  4126. let key = apikey.key.clone();
  4127. let val = match apikey.prefix {
  4128. Some(ref prefix) => format!("{} {}", prefix, key),
  4129. None => key,
  4130. };
  4131. auth_query.insert("access_token".to_owned(), val);
  4132. };
  4133. if let Some(ref apikey) = configuration.api_key {
  4134. let key = apikey.key.clone();
  4135. let val = match apikey.prefix {
  4136. Some(ref prefix) => format!("{} {}", prefix, key),
  4137. None => key,
  4138. };
  4139. auth_headers.insert("Authorization".to_owned(), val);
  4140. };
  4141. if let Some(ref auth_conf) = configuration.basic_auth {
  4142. let auth = hyper::header::Authorization(
  4143. hyper::header::Basic {
  4144. username: auth_conf.0.to_owned(),
  4145. password: auth_conf.1.to_owned(),
  4146. }
  4147. );
  4148. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  4149. };
  4150. if let Some(ref apikey) = configuration.api_key {
  4151. let key = apikey.key.clone();
  4152. let val = match apikey.prefix {
  4153. Some(ref prefix) => format!("{} {}", prefix, key),
  4154. None => key,
  4155. };
  4156. auth_headers.insert("Sudo".to_owned(), val);
  4157. };
  4158. if let Some(ref apikey) = configuration.api_key {
  4159. let key = apikey.key.clone();
  4160. let val = match apikey.prefix {
  4161. Some(ref prefix) => format!("{} {}", prefix, key),
  4162. None => key,
  4163. };
  4164. auth_query.insert("sudo".to_owned(), val);
  4165. };
  4166. if let Some(ref apikey) = configuration.api_key {
  4167. let key = apikey.key.clone();
  4168. let val = match apikey.prefix {
  4169. Some(ref prefix) => format!("{} {}", prefix, key),
  4170. None => key,
  4171. };
  4172. auth_query.insert("token".to_owned(), val);
  4173. };
  4174. let method = hyper::Method::Get;
  4175. let query_string = {
  4176. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  4177. for (key, val) in &auth_query {
  4178. query.append_pair(key, val);
  4179. }
  4180. query.finish()
  4181. };
  4182. let uri_str = format!("{}/repos/{owner}/{repo}/hooks/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  4183. // TODO(farcaller): handle error
  4184. // if let Err(e) = uri {
  4185. // return Box::new(futures::future::err(e));
  4186. // }
  4187. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  4188. let mut req = hyper::Request::new(method, uri);
  4189. if let Some(ref user_agent) = configuration.user_agent {
  4190. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  4191. }
  4192. for (key, val) in auth_headers {
  4193. req.headers_mut().set_raw(key, val);
  4194. }
  4195. // send request
  4196. Box::new(
  4197. configuration.client.request(req)
  4198. .map_err(|e| Error::from(e))
  4199. .and_then(|resp| {
  4200. let status = resp.status();
  4201. resp.body().concat2()
  4202. .and_then(move |body| Ok((status, body)))
  4203. .map_err(|e| Error::from(e))
  4204. })
  4205. .and_then(|(status, body)| {
  4206. if status.is_success() {
  4207. Ok(body)
  4208. } else {
  4209. Err(Error::from((status, &*body)))
  4210. }
  4211. })
  4212. .and_then(|body| {
  4213. let parsed: Result<::models::Hook, _> = serde_json::from_slice(&body);
  4214. parsed.map_err(|e| Error::from(e))
  4215. })
  4216. )
  4217. }
  4218. fn repo_get_key(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = ::models::DeployKey, Error = Error<serde_json::Value>>> {
  4219. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  4220. let mut auth_headers = HashMap::<String, String>::new();
  4221. let mut auth_query = HashMap::<String, String>::new();
  4222. if let Some(ref apikey) = configuration.api_key {
  4223. let key = apikey.key.clone();
  4224. let val = match apikey.prefix {
  4225. Some(ref prefix) => format!("{} {}", prefix, key),
  4226. None => key,
  4227. };
  4228. auth_query.insert("access_token".to_owned(), val);
  4229. };
  4230. if let Some(ref apikey) = configuration.api_key {
  4231. let key = apikey.key.clone();
  4232. let val = match apikey.prefix {
  4233. Some(ref prefix) => format!("{} {}", prefix, key),
  4234. None => key,
  4235. };
  4236. auth_headers.insert("Authorization".to_owned(), val);
  4237. };
  4238. if let Some(ref auth_conf) = configuration.basic_auth {
  4239. let auth = hyper::header::Authorization(
  4240. hyper::header::Basic {
  4241. username: auth_conf.0.to_owned(),
  4242. password: auth_conf.1.to_owned(),
  4243. }
  4244. );
  4245. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  4246. };
  4247. if let Some(ref apikey) = configuration.api_key {
  4248. let key = apikey.key.clone();
  4249. let val = match apikey.prefix {
  4250. Some(ref prefix) => format!("{} {}", prefix, key),
  4251. None => key,
  4252. };
  4253. auth_headers.insert("Sudo".to_owned(), val);
  4254. };
  4255. if let Some(ref apikey) = configuration.api_key {
  4256. let key = apikey.key.clone();
  4257. let val = match apikey.prefix {
  4258. Some(ref prefix) => format!("{} {}", prefix, key),
  4259. None => key,
  4260. };
  4261. auth_query.insert("sudo".to_owned(), val);
  4262. };
  4263. if let Some(ref apikey) = configuration.api_key {
  4264. let key = apikey.key.clone();
  4265. let val = match apikey.prefix {
  4266. Some(ref prefix) => format!("{} {}", prefix, key),
  4267. None => key,
  4268. };
  4269. auth_query.insert("token".to_owned(), val);
  4270. };
  4271. let method = hyper::Method::Get;
  4272. let query_string = {
  4273. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  4274. for (key, val) in &auth_query {
  4275. query.append_pair(key, val);
  4276. }
  4277. query.finish()
  4278. };
  4279. let uri_str = format!("{}/repos/{owner}/{repo}/keys/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  4280. // TODO(farcaller): handle error
  4281. // if let Err(e) = uri {
  4282. // return Box::new(futures::future::err(e));
  4283. // }
  4284. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  4285. let mut req = hyper::Request::new(method, uri);
  4286. if let Some(ref user_agent) = configuration.user_agent {
  4287. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  4288. }
  4289. for (key, val) in auth_headers {
  4290. req.headers_mut().set_raw(key, val);
  4291. }
  4292. // send request
  4293. Box::new(
  4294. configuration.client.request(req)
  4295. .map_err(|e| Error::from(e))
  4296. .and_then(|resp| {
  4297. let status = resp.status();
  4298. resp.body().concat2()
  4299. .and_then(move |body| Ok((status, body)))
  4300. .map_err(|e| Error::from(e))
  4301. })
  4302. .and_then(|(status, body)| {
  4303. if status.is_success() {
  4304. Ok(body)
  4305. } else {
  4306. Err(Error::from((status, &*body)))
  4307. }
  4308. })
  4309. .and_then(|body| {
  4310. let parsed: Result<::models::DeployKey, _> = serde_json::from_slice(&body);
  4311. parsed.map_err(|e| Error::from(e))
  4312. })
  4313. )
  4314. }
  4315. fn repo_get_pull_request(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = ::models::PullRequest, Error = Error<serde_json::Value>>> {
  4316. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  4317. let mut auth_headers = HashMap::<String, String>::new();
  4318. let mut auth_query = HashMap::<String, String>::new();
  4319. if let Some(ref apikey) = configuration.api_key {
  4320. let key = apikey.key.clone();
  4321. let val = match apikey.prefix {
  4322. Some(ref prefix) => format!("{} {}", prefix, key),
  4323. None => key,
  4324. };
  4325. auth_query.insert("access_token".to_owned(), val);
  4326. };
  4327. if let Some(ref apikey) = configuration.api_key {
  4328. let key = apikey.key.clone();
  4329. let val = match apikey.prefix {
  4330. Some(ref prefix) => format!("{} {}", prefix, key),
  4331. None => key,
  4332. };
  4333. auth_headers.insert("Authorization".to_owned(), val);
  4334. };
  4335. if let Some(ref auth_conf) = configuration.basic_auth {
  4336. let auth = hyper::header::Authorization(
  4337. hyper::header::Basic {
  4338. username: auth_conf.0.to_owned(),
  4339. password: auth_conf.1.to_owned(),
  4340. }
  4341. );
  4342. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  4343. };
  4344. if let Some(ref apikey) = configuration.api_key {
  4345. let key = apikey.key.clone();
  4346. let val = match apikey.prefix {
  4347. Some(ref prefix) => format!("{} {}", prefix, key),
  4348. None => key,
  4349. };
  4350. auth_headers.insert("Sudo".to_owned(), val);
  4351. };
  4352. if let Some(ref apikey) = configuration.api_key {
  4353. let key = apikey.key.clone();
  4354. let val = match apikey.prefix {
  4355. Some(ref prefix) => format!("{} {}", prefix, key),
  4356. None => key,
  4357. };
  4358. auth_query.insert("sudo".to_owned(), val);
  4359. };
  4360. if let Some(ref apikey) = configuration.api_key {
  4361. let key = apikey.key.clone();
  4362. let val = match apikey.prefix {
  4363. Some(ref prefix) => format!("{} {}", prefix, key),
  4364. None => key,
  4365. };
  4366. auth_query.insert("token".to_owned(), val);
  4367. };
  4368. let method = hyper::Method::Get;
  4369. let query_string = {
  4370. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  4371. for (key, val) in &auth_query {
  4372. query.append_pair(key, val);
  4373. }
  4374. query.finish()
  4375. };
  4376. let uri_str = format!("{}/repos/{owner}/{repo}/pulls/{index}?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  4377. // TODO(farcaller): handle error
  4378. // if let Err(e) = uri {
  4379. // return Box::new(futures::future::err(e));
  4380. // }
  4381. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  4382. let mut req = hyper::Request::new(method, uri);
  4383. if let Some(ref user_agent) = configuration.user_agent {
  4384. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  4385. }
  4386. for (key, val) in auth_headers {
  4387. req.headers_mut().set_raw(key, val);
  4388. }
  4389. // send request
  4390. Box::new(
  4391. configuration.client.request(req)
  4392. .map_err(|e| Error::from(e))
  4393. .and_then(|resp| {
  4394. let status = resp.status();
  4395. resp.body().concat2()
  4396. .and_then(move |body| Ok((status, body)))
  4397. .map_err(|e| Error::from(e))
  4398. })
  4399. .and_then(|(status, body)| {
  4400. if status.is_success() {
  4401. Ok(body)
  4402. } else {
  4403. Err(Error::from((status, &*body)))
  4404. }
  4405. })
  4406. .and_then(|body| {
  4407. let parsed: Result<::models::PullRequest, _> = serde_json::from_slice(&body);
  4408. parsed.map_err(|e| Error::from(e))
  4409. })
  4410. )
  4411. }
  4412. fn repo_get_raw_file(&self, owner: &str, repo: &str, filepath: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  4413. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  4414. let mut auth_headers = HashMap::<String, String>::new();
  4415. let mut auth_query = HashMap::<String, String>::new();
  4416. if let Some(ref apikey) = configuration.api_key {
  4417. let key = apikey.key.clone();
  4418. let val = match apikey.prefix {
  4419. Some(ref prefix) => format!("{} {}", prefix, key),
  4420. None => key,
  4421. };
  4422. auth_query.insert("access_token".to_owned(), val);
  4423. };
  4424. if let Some(ref apikey) = configuration.api_key {
  4425. let key = apikey.key.clone();
  4426. let val = match apikey.prefix {
  4427. Some(ref prefix) => format!("{} {}", prefix, key),
  4428. None => key,
  4429. };
  4430. auth_headers.insert("Authorization".to_owned(), val);
  4431. };
  4432. if let Some(ref auth_conf) = configuration.basic_auth {
  4433. let auth = hyper::header::Authorization(
  4434. hyper::header::Basic {
  4435. username: auth_conf.0.to_owned(),
  4436. password: auth_conf.1.to_owned(),
  4437. }
  4438. );
  4439. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  4440. };
  4441. if let Some(ref apikey) = configuration.api_key {
  4442. let key = apikey.key.clone();
  4443. let val = match apikey.prefix {
  4444. Some(ref prefix) => format!("{} {}", prefix, key),
  4445. None => key,
  4446. };
  4447. auth_headers.insert("Sudo".to_owned(), val);
  4448. };
  4449. if let Some(ref apikey) = configuration.api_key {
  4450. let key = apikey.key.clone();
  4451. let val = match apikey.prefix {
  4452. Some(ref prefix) => format!("{} {}", prefix, key),
  4453. None => key,
  4454. };
  4455. auth_query.insert("sudo".to_owned(), val);
  4456. };
  4457. if let Some(ref apikey) = configuration.api_key {
  4458. let key = apikey.key.clone();
  4459. let val = match apikey.prefix {
  4460. Some(ref prefix) => format!("{} {}", prefix, key),
  4461. None => key,
  4462. };
  4463. auth_query.insert("token".to_owned(), val);
  4464. };
  4465. let method = hyper::Method::Get;
  4466. let query_string = {
  4467. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  4468. for (key, val) in &auth_query {
  4469. query.append_pair(key, val);
  4470. }
  4471. query.finish()
  4472. };
  4473. let uri_str = format!("{}/repos/{owner}/{repo}/raw/{filepath}?{}", configuration.base_path, query_string, owner=owner, repo=repo, filepath=filepath);
  4474. // TODO(farcaller): handle error
  4475. // if let Err(e) = uri {
  4476. // return Box::new(futures::future::err(e));
  4477. // }
  4478. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  4479. let mut req = hyper::Request::new(method, uri);
  4480. if let Some(ref user_agent) = configuration.user_agent {
  4481. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  4482. }
  4483. for (key, val) in auth_headers {
  4484. req.headers_mut().set_raw(key, val);
  4485. }
  4486. // send request
  4487. Box::new(
  4488. configuration.client.request(req)
  4489. .map_err(|e| Error::from(e))
  4490. .and_then(|resp| {
  4491. let status = resp.status();
  4492. resp.body().concat2()
  4493. .and_then(move |body| Ok((status, body)))
  4494. .map_err(|e| Error::from(e))
  4495. })
  4496. .and_then(|(status, body)| {
  4497. if status.is_success() {
  4498. Ok(body)
  4499. } else {
  4500. Err(Error::from((status, &*body)))
  4501. }
  4502. })
  4503. .and_then(|_| futures::future::ok(()))
  4504. )
  4505. }
  4506. fn repo_get_release(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = ::models::Release, Error = Error<serde_json::Value>>> {
  4507. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  4508. let mut auth_headers = HashMap::<String, String>::new();
  4509. let mut auth_query = HashMap::<String, String>::new();
  4510. if let Some(ref apikey) = configuration.api_key {
  4511. let key = apikey.key.clone();
  4512. let val = match apikey.prefix {
  4513. Some(ref prefix) => format!("{} {}", prefix, key),
  4514. None => key,
  4515. };
  4516. auth_query.insert("access_token".to_owned(), val);
  4517. };
  4518. if let Some(ref apikey) = configuration.api_key {
  4519. let key = apikey.key.clone();
  4520. let val = match apikey.prefix {
  4521. Some(ref prefix) => format!("{} {}", prefix, key),
  4522. None => key,
  4523. };
  4524. auth_headers.insert("Authorization".to_owned(), val);
  4525. };
  4526. if let Some(ref auth_conf) = configuration.basic_auth {
  4527. let auth = hyper::header::Authorization(
  4528. hyper::header::Basic {
  4529. username: auth_conf.0.to_owned(),
  4530. password: auth_conf.1.to_owned(),
  4531. }
  4532. );
  4533. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  4534. };
  4535. if let Some(ref apikey) = configuration.api_key {
  4536. let key = apikey.key.clone();
  4537. let val = match apikey.prefix {
  4538. Some(ref prefix) => format!("{} {}", prefix, key),
  4539. None => key,
  4540. };
  4541. auth_headers.insert("Sudo".to_owned(), val);
  4542. };
  4543. if let Some(ref apikey) = configuration.api_key {
  4544. let key = apikey.key.clone();
  4545. let val = match apikey.prefix {
  4546. Some(ref prefix) => format!("{} {}", prefix, key),
  4547. None => key,
  4548. };
  4549. auth_query.insert("sudo".to_owned(), val);
  4550. };
  4551. if let Some(ref apikey) = configuration.api_key {
  4552. let key = apikey.key.clone();
  4553. let val = match apikey.prefix {
  4554. Some(ref prefix) => format!("{} {}", prefix, key),
  4555. None => key,
  4556. };
  4557. auth_query.insert("token".to_owned(), val);
  4558. };
  4559. let method = hyper::Method::Get;
  4560. let query_string = {
  4561. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  4562. for (key, val) in &auth_query {
  4563. query.append_pair(key, val);
  4564. }
  4565. query.finish()
  4566. };
  4567. let uri_str = format!("{}/repos/{owner}/{repo}/releases/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  4568. // TODO(farcaller): handle error
  4569. // if let Err(e) = uri {
  4570. // return Box::new(futures::future::err(e));
  4571. // }
  4572. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  4573. let mut req = hyper::Request::new(method, uri);
  4574. if let Some(ref user_agent) = configuration.user_agent {
  4575. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  4576. }
  4577. for (key, val) in auth_headers {
  4578. req.headers_mut().set_raw(key, val);
  4579. }
  4580. // send request
  4581. Box::new(
  4582. configuration.client.request(req)
  4583. .map_err(|e| Error::from(e))
  4584. .and_then(|resp| {
  4585. let status = resp.status();
  4586. resp.body().concat2()
  4587. .and_then(move |body| Ok((status, body)))
  4588. .map_err(|e| Error::from(e))
  4589. })
  4590. .and_then(|(status, body)| {
  4591. if status.is_success() {
  4592. Ok(body)
  4593. } else {
  4594. Err(Error::from((status, &*body)))
  4595. }
  4596. })
  4597. .and_then(|body| {
  4598. let parsed: Result<::models::Release, _> = serde_json::from_slice(&body);
  4599. parsed.map_err(|e| Error::from(e))
  4600. })
  4601. )
  4602. }
  4603. fn repo_get_release_attachment(&self, owner: &str, repo: &str, id: i64, attachment_id: i64) -> Box<Future<Item = ::models::Attachment, Error = Error<serde_json::Value>>> {
  4604. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  4605. let mut auth_headers = HashMap::<String, String>::new();
  4606. let mut auth_query = HashMap::<String, String>::new();
  4607. if let Some(ref apikey) = configuration.api_key {
  4608. let key = apikey.key.clone();
  4609. let val = match apikey.prefix {
  4610. Some(ref prefix) => format!("{} {}", prefix, key),
  4611. None => key,
  4612. };
  4613. auth_query.insert("access_token".to_owned(), val);
  4614. };
  4615. if let Some(ref apikey) = configuration.api_key {
  4616. let key = apikey.key.clone();
  4617. let val = match apikey.prefix {
  4618. Some(ref prefix) => format!("{} {}", prefix, key),
  4619. None => key,
  4620. };
  4621. auth_headers.insert("Authorization".to_owned(), val);
  4622. };
  4623. if let Some(ref auth_conf) = configuration.basic_auth {
  4624. let auth = hyper::header::Authorization(
  4625. hyper::header::Basic {
  4626. username: auth_conf.0.to_owned(),
  4627. password: auth_conf.1.to_owned(),
  4628. }
  4629. );
  4630. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  4631. };
  4632. if let Some(ref apikey) = configuration.api_key {
  4633. let key = apikey.key.clone();
  4634. let val = match apikey.prefix {
  4635. Some(ref prefix) => format!("{} {}", prefix, key),
  4636. None => key,
  4637. };
  4638. auth_headers.insert("Sudo".to_owned(), val);
  4639. };
  4640. if let Some(ref apikey) = configuration.api_key {
  4641. let key = apikey.key.clone();
  4642. let val = match apikey.prefix {
  4643. Some(ref prefix) => format!("{} {}", prefix, key),
  4644. None => key,
  4645. };
  4646. auth_query.insert("sudo".to_owned(), val);
  4647. };
  4648. if let Some(ref apikey) = configuration.api_key {
  4649. let key = apikey.key.clone();
  4650. let val = match apikey.prefix {
  4651. Some(ref prefix) => format!("{} {}", prefix, key),
  4652. None => key,
  4653. };
  4654. auth_query.insert("token".to_owned(), val);
  4655. };
  4656. let method = hyper::Method::Get;
  4657. let query_string = {
  4658. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  4659. for (key, val) in &auth_query {
  4660. query.append_pair(key, val);
  4661. }
  4662. query.finish()
  4663. };
  4664. let uri_str = format!("{}/repos/{owner}/{repo}/releases/{id}/assets/{attachment_id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id, attachment_id=attachment_id);
  4665. // TODO(farcaller): handle error
  4666. // if let Err(e) = uri {
  4667. // return Box::new(futures::future::err(e));
  4668. // }
  4669. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  4670. let mut req = hyper::Request::new(method, uri);
  4671. if let Some(ref user_agent) = configuration.user_agent {
  4672. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  4673. }
  4674. for (key, val) in auth_headers {
  4675. req.headers_mut().set_raw(key, val);
  4676. }
  4677. // send request
  4678. Box::new(
  4679. configuration.client.request(req)
  4680. .map_err(|e| Error::from(e))
  4681. .and_then(|resp| {
  4682. let status = resp.status();
  4683. resp.body().concat2()
  4684. .and_then(move |body| Ok((status, body)))
  4685. .map_err(|e| Error::from(e))
  4686. })
  4687. .and_then(|(status, body)| {
  4688. if status.is_success() {
  4689. Ok(body)
  4690. } else {
  4691. Err(Error::from((status, &*body)))
  4692. }
  4693. })
  4694. .and_then(|body| {
  4695. let parsed: Result<::models::Attachment, _> = serde_json::from_slice(&body);
  4696. parsed.map_err(|e| Error::from(e))
  4697. })
  4698. )
  4699. }
  4700. fn repo_get_single_commit(&self, owner: &str, repo: &str, sha: &str) -> Box<Future<Item = ::models::Commit, Error = Error<serde_json::Value>>> {
  4701. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  4702. let mut auth_headers = HashMap::<String, String>::new();
  4703. let mut auth_query = HashMap::<String, String>::new();
  4704. if let Some(ref apikey) = configuration.api_key {
  4705. let key = apikey.key.clone();
  4706. let val = match apikey.prefix {
  4707. Some(ref prefix) => format!("{} {}", prefix, key),
  4708. None => key,
  4709. };
  4710. auth_query.insert("access_token".to_owned(), val);
  4711. };
  4712. if let Some(ref apikey) = configuration.api_key {
  4713. let key = apikey.key.clone();
  4714. let val = match apikey.prefix {
  4715. Some(ref prefix) => format!("{} {}", prefix, key),
  4716. None => key,
  4717. };
  4718. auth_headers.insert("Authorization".to_owned(), val);
  4719. };
  4720. if let Some(ref auth_conf) = configuration.basic_auth {
  4721. let auth = hyper::header::Authorization(
  4722. hyper::header::Basic {
  4723. username: auth_conf.0.to_owned(),
  4724. password: auth_conf.1.to_owned(),
  4725. }
  4726. );
  4727. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  4728. };
  4729. if let Some(ref apikey) = configuration.api_key {
  4730. let key = apikey.key.clone();
  4731. let val = match apikey.prefix {
  4732. Some(ref prefix) => format!("{} {}", prefix, key),
  4733. None => key,
  4734. };
  4735. auth_headers.insert("Sudo".to_owned(), val);
  4736. };
  4737. if let Some(ref apikey) = configuration.api_key {
  4738. let key = apikey.key.clone();
  4739. let val = match apikey.prefix {
  4740. Some(ref prefix) => format!("{} {}", prefix, key),
  4741. None => key,
  4742. };
  4743. auth_query.insert("sudo".to_owned(), val);
  4744. };
  4745. if let Some(ref apikey) = configuration.api_key {
  4746. let key = apikey.key.clone();
  4747. let val = match apikey.prefix {
  4748. Some(ref prefix) => format!("{} {}", prefix, key),
  4749. None => key,
  4750. };
  4751. auth_query.insert("token".to_owned(), val);
  4752. };
  4753. let method = hyper::Method::Get;
  4754. let query_string = {
  4755. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  4756. for (key, val) in &auth_query {
  4757. query.append_pair(key, val);
  4758. }
  4759. query.finish()
  4760. };
  4761. let uri_str = format!("{}/repos/{owner}/{repo}/git/commits/{sha}?{}", configuration.base_path, query_string, owner=owner, repo=repo, sha=sha);
  4762. // TODO(farcaller): handle error
  4763. // if let Err(e) = uri {
  4764. // return Box::new(futures::future::err(e));
  4765. // }
  4766. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  4767. let mut req = hyper::Request::new(method, uri);
  4768. if let Some(ref user_agent) = configuration.user_agent {
  4769. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  4770. }
  4771. for (key, val) in auth_headers {
  4772. req.headers_mut().set_raw(key, val);
  4773. }
  4774. // send request
  4775. Box::new(
  4776. configuration.client.request(req)
  4777. .map_err(|e| Error::from(e))
  4778. .and_then(|resp| {
  4779. let status = resp.status();
  4780. resp.body().concat2()
  4781. .and_then(move |body| Ok((status, body)))
  4782. .map_err(|e| Error::from(e))
  4783. })
  4784. .and_then(|(status, body)| {
  4785. if status.is_success() {
  4786. Ok(body)
  4787. } else {
  4788. Err(Error::from((status, &*body)))
  4789. }
  4790. })
  4791. .and_then(|body| {
  4792. let parsed: Result<::models::Commit, _> = serde_json::from_slice(&body);
  4793. parsed.map_err(|e| Error::from(e))
  4794. })
  4795. )
  4796. }
  4797. fn repo_list_all_git_refs(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Reference>, Error = Error<serde_json::Value>>> {
  4798. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  4799. let mut auth_headers = HashMap::<String, String>::new();
  4800. let mut auth_query = HashMap::<String, String>::new();
  4801. if let Some(ref apikey) = configuration.api_key {
  4802. let key = apikey.key.clone();
  4803. let val = match apikey.prefix {
  4804. Some(ref prefix) => format!("{} {}", prefix, key),
  4805. None => key,
  4806. };
  4807. auth_query.insert("access_token".to_owned(), val);
  4808. };
  4809. if let Some(ref apikey) = configuration.api_key {
  4810. let key = apikey.key.clone();
  4811. let val = match apikey.prefix {
  4812. Some(ref prefix) => format!("{} {}", prefix, key),
  4813. None => key,
  4814. };
  4815. auth_headers.insert("Authorization".to_owned(), val);
  4816. };
  4817. if let Some(ref auth_conf) = configuration.basic_auth {
  4818. let auth = hyper::header::Authorization(
  4819. hyper::header::Basic {
  4820. username: auth_conf.0.to_owned(),
  4821. password: auth_conf.1.to_owned(),
  4822. }
  4823. );
  4824. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  4825. };
  4826. if let Some(ref apikey) = configuration.api_key {
  4827. let key = apikey.key.clone();
  4828. let val = match apikey.prefix {
  4829. Some(ref prefix) => format!("{} {}", prefix, key),
  4830. None => key,
  4831. };
  4832. auth_headers.insert("Sudo".to_owned(), val);
  4833. };
  4834. if let Some(ref apikey) = configuration.api_key {
  4835. let key = apikey.key.clone();
  4836. let val = match apikey.prefix {
  4837. Some(ref prefix) => format!("{} {}", prefix, key),
  4838. None => key,
  4839. };
  4840. auth_query.insert("sudo".to_owned(), val);
  4841. };
  4842. if let Some(ref apikey) = configuration.api_key {
  4843. let key = apikey.key.clone();
  4844. let val = match apikey.prefix {
  4845. Some(ref prefix) => format!("{} {}", prefix, key),
  4846. None => key,
  4847. };
  4848. auth_query.insert("token".to_owned(), val);
  4849. };
  4850. let method = hyper::Method::Get;
  4851. let query_string = {
  4852. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  4853. for (key, val) in &auth_query {
  4854. query.append_pair(key, val);
  4855. }
  4856. query.finish()
  4857. };
  4858. let uri_str = format!("{}/repos/{owner}/{repo}/git/refs?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  4859. // TODO(farcaller): handle error
  4860. // if let Err(e) = uri {
  4861. // return Box::new(futures::future::err(e));
  4862. // }
  4863. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  4864. let mut req = hyper::Request::new(method, uri);
  4865. if let Some(ref user_agent) = configuration.user_agent {
  4866. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  4867. }
  4868. for (key, val) in auth_headers {
  4869. req.headers_mut().set_raw(key, val);
  4870. }
  4871. // send request
  4872. Box::new(
  4873. configuration.client.request(req)
  4874. .map_err(|e| Error::from(e))
  4875. .and_then(|resp| {
  4876. let status = resp.status();
  4877. resp.body().concat2()
  4878. .and_then(move |body| Ok((status, body)))
  4879. .map_err(|e| Error::from(e))
  4880. })
  4881. .and_then(|(status, body)| {
  4882. if status.is_success() {
  4883. Ok(body)
  4884. } else {
  4885. Err(Error::from((status, &*body)))
  4886. }
  4887. })
  4888. .and_then(|body| {
  4889. let parsed: Result<Vec<::models::Reference>, _> = serde_json::from_slice(&body);
  4890. parsed.map_err(|e| Error::from(e))
  4891. })
  4892. )
  4893. }
  4894. fn repo_list_branches(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Branch>, Error = Error<serde_json::Value>>> {
  4895. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  4896. let mut auth_headers = HashMap::<String, String>::new();
  4897. let mut auth_query = HashMap::<String, String>::new();
  4898. if let Some(ref apikey) = configuration.api_key {
  4899. let key = apikey.key.clone();
  4900. let val = match apikey.prefix {
  4901. Some(ref prefix) => format!("{} {}", prefix, key),
  4902. None => key,
  4903. };
  4904. auth_query.insert("access_token".to_owned(), val);
  4905. };
  4906. if let Some(ref apikey) = configuration.api_key {
  4907. let key = apikey.key.clone();
  4908. let val = match apikey.prefix {
  4909. Some(ref prefix) => format!("{} {}", prefix, key),
  4910. None => key,
  4911. };
  4912. auth_headers.insert("Authorization".to_owned(), val);
  4913. };
  4914. if let Some(ref auth_conf) = configuration.basic_auth {
  4915. let auth = hyper::header::Authorization(
  4916. hyper::header::Basic {
  4917. username: auth_conf.0.to_owned(),
  4918. password: auth_conf.1.to_owned(),
  4919. }
  4920. );
  4921. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  4922. };
  4923. if let Some(ref apikey) = configuration.api_key {
  4924. let key = apikey.key.clone();
  4925. let val = match apikey.prefix {
  4926. Some(ref prefix) => format!("{} {}", prefix, key),
  4927. None => key,
  4928. };
  4929. auth_headers.insert("Sudo".to_owned(), val);
  4930. };
  4931. if let Some(ref apikey) = configuration.api_key {
  4932. let key = apikey.key.clone();
  4933. let val = match apikey.prefix {
  4934. Some(ref prefix) => format!("{} {}", prefix, key),
  4935. None => key,
  4936. };
  4937. auth_query.insert("sudo".to_owned(), val);
  4938. };
  4939. if let Some(ref apikey) = configuration.api_key {
  4940. let key = apikey.key.clone();
  4941. let val = match apikey.prefix {
  4942. Some(ref prefix) => format!("{} {}", prefix, key),
  4943. None => key,
  4944. };
  4945. auth_query.insert("token".to_owned(), val);
  4946. };
  4947. let method = hyper::Method::Get;
  4948. let query_string = {
  4949. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  4950. for (key, val) in &auth_query {
  4951. query.append_pair(key, val);
  4952. }
  4953. query.finish()
  4954. };
  4955. let uri_str = format!("{}/repos/{owner}/{repo}/branches?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  4956. // TODO(farcaller): handle error
  4957. // if let Err(e) = uri {
  4958. // return Box::new(futures::future::err(e));
  4959. // }
  4960. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  4961. let mut req = hyper::Request::new(method, uri);
  4962. if let Some(ref user_agent) = configuration.user_agent {
  4963. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  4964. }
  4965. for (key, val) in auth_headers {
  4966. req.headers_mut().set_raw(key, val);
  4967. }
  4968. // send request
  4969. Box::new(
  4970. configuration.client.request(req)
  4971. .map_err(|e| Error::from(e))
  4972. .and_then(|resp| {
  4973. let status = resp.status();
  4974. resp.body().concat2()
  4975. .and_then(move |body| Ok((status, body)))
  4976. .map_err(|e| Error::from(e))
  4977. })
  4978. .and_then(|(status, body)| {
  4979. if status.is_success() {
  4980. Ok(body)
  4981. } else {
  4982. Err(Error::from((status, &*body)))
  4983. }
  4984. })
  4985. .and_then(|body| {
  4986. let parsed: Result<Vec<::models::Branch>, _> = serde_json::from_slice(&body);
  4987. parsed.map_err(|e| Error::from(e))
  4988. })
  4989. )
  4990. }
  4991. fn repo_list_collaborators(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>> {
  4992. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  4993. let mut auth_headers = HashMap::<String, String>::new();
  4994. let mut auth_query = HashMap::<String, String>::new();
  4995. if let Some(ref apikey) = configuration.api_key {
  4996. let key = apikey.key.clone();
  4997. let val = match apikey.prefix {
  4998. Some(ref prefix) => format!("{} {}", prefix, key),
  4999. None => key,
  5000. };
  5001. auth_query.insert("access_token".to_owned(), val);
  5002. };
  5003. if let Some(ref apikey) = configuration.api_key {
  5004. let key = apikey.key.clone();
  5005. let val = match apikey.prefix {
  5006. Some(ref prefix) => format!("{} {}", prefix, key),
  5007. None => key,
  5008. };
  5009. auth_headers.insert("Authorization".to_owned(), val);
  5010. };
  5011. if let Some(ref auth_conf) = configuration.basic_auth {
  5012. let auth = hyper::header::Authorization(
  5013. hyper::header::Basic {
  5014. username: auth_conf.0.to_owned(),
  5015. password: auth_conf.1.to_owned(),
  5016. }
  5017. );
  5018. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  5019. };
  5020. if let Some(ref apikey) = configuration.api_key {
  5021. let key = apikey.key.clone();
  5022. let val = match apikey.prefix {
  5023. Some(ref prefix) => format!("{} {}", prefix, key),
  5024. None => key,
  5025. };
  5026. auth_headers.insert("Sudo".to_owned(), val);
  5027. };
  5028. if let Some(ref apikey) = configuration.api_key {
  5029. let key = apikey.key.clone();
  5030. let val = match apikey.prefix {
  5031. Some(ref prefix) => format!("{} {}", prefix, key),
  5032. None => key,
  5033. };
  5034. auth_query.insert("sudo".to_owned(), val);
  5035. };
  5036. if let Some(ref apikey) = configuration.api_key {
  5037. let key = apikey.key.clone();
  5038. let val = match apikey.prefix {
  5039. Some(ref prefix) => format!("{} {}", prefix, key),
  5040. None => key,
  5041. };
  5042. auth_query.insert("token".to_owned(), val);
  5043. };
  5044. let method = hyper::Method::Get;
  5045. let query_string = {
  5046. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  5047. for (key, val) in &auth_query {
  5048. query.append_pair(key, val);
  5049. }
  5050. query.finish()
  5051. };
  5052. let uri_str = format!("{}/repos/{owner}/{repo}/collaborators?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  5053. // TODO(farcaller): handle error
  5054. // if let Err(e) = uri {
  5055. // return Box::new(futures::future::err(e));
  5056. // }
  5057. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  5058. let mut req = hyper::Request::new(method, uri);
  5059. if let Some(ref user_agent) = configuration.user_agent {
  5060. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  5061. }
  5062. for (key, val) in auth_headers {
  5063. req.headers_mut().set_raw(key, val);
  5064. }
  5065. // send request
  5066. Box::new(
  5067. configuration.client.request(req)
  5068. .map_err(|e| Error::from(e))
  5069. .and_then(|resp| {
  5070. let status = resp.status();
  5071. resp.body().concat2()
  5072. .and_then(move |body| Ok((status, body)))
  5073. .map_err(|e| Error::from(e))
  5074. })
  5075. .and_then(|(status, body)| {
  5076. if status.is_success() {
  5077. Ok(body)
  5078. } else {
  5079. Err(Error::from((status, &*body)))
  5080. }
  5081. })
  5082. .and_then(|body| {
  5083. let parsed: Result<Vec<::models::User>, _> = serde_json::from_slice(&body);
  5084. parsed.map_err(|e| Error::from(e))
  5085. })
  5086. )
  5087. }
  5088. fn repo_list_git_hooks(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::GitHook>, Error = Error<serde_json::Value>>> {
  5089. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  5090. let mut auth_headers = HashMap::<String, String>::new();
  5091. let mut auth_query = HashMap::<String, String>::new();
  5092. if let Some(ref apikey) = configuration.api_key {
  5093. let key = apikey.key.clone();
  5094. let val = match apikey.prefix {
  5095. Some(ref prefix) => format!("{} {}", prefix, key),
  5096. None => key,
  5097. };
  5098. auth_query.insert("access_token".to_owned(), val);
  5099. };
  5100. if let Some(ref apikey) = configuration.api_key {
  5101. let key = apikey.key.clone();
  5102. let val = match apikey.prefix {
  5103. Some(ref prefix) => format!("{} {}", prefix, key),
  5104. None => key,
  5105. };
  5106. auth_headers.insert("Authorization".to_owned(), val);
  5107. };
  5108. if let Some(ref auth_conf) = configuration.basic_auth {
  5109. let auth = hyper::header::Authorization(
  5110. hyper::header::Basic {
  5111. username: auth_conf.0.to_owned(),
  5112. password: auth_conf.1.to_owned(),
  5113. }
  5114. );
  5115. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  5116. };
  5117. if let Some(ref apikey) = configuration.api_key {
  5118. let key = apikey.key.clone();
  5119. let val = match apikey.prefix {
  5120. Some(ref prefix) => format!("{} {}", prefix, key),
  5121. None => key,
  5122. };
  5123. auth_headers.insert("Sudo".to_owned(), val);
  5124. };
  5125. if let Some(ref apikey) = configuration.api_key {
  5126. let key = apikey.key.clone();
  5127. let val = match apikey.prefix {
  5128. Some(ref prefix) => format!("{} {}", prefix, key),
  5129. None => key,
  5130. };
  5131. auth_query.insert("sudo".to_owned(), val);
  5132. };
  5133. if let Some(ref apikey) = configuration.api_key {
  5134. let key = apikey.key.clone();
  5135. let val = match apikey.prefix {
  5136. Some(ref prefix) => format!("{} {}", prefix, key),
  5137. None => key,
  5138. };
  5139. auth_query.insert("token".to_owned(), val);
  5140. };
  5141. let method = hyper::Method::Get;
  5142. let query_string = {
  5143. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  5144. for (key, val) in &auth_query {
  5145. query.append_pair(key, val);
  5146. }
  5147. query.finish()
  5148. };
  5149. let uri_str = format!("{}/repos/{owner}/{repo}/hooks/git?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  5150. // TODO(farcaller): handle error
  5151. // if let Err(e) = uri {
  5152. // return Box::new(futures::future::err(e));
  5153. // }
  5154. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  5155. let mut req = hyper::Request::new(method, uri);
  5156. if let Some(ref user_agent) = configuration.user_agent {
  5157. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  5158. }
  5159. for (key, val) in auth_headers {
  5160. req.headers_mut().set_raw(key, val);
  5161. }
  5162. // send request
  5163. Box::new(
  5164. configuration.client.request(req)
  5165. .map_err(|e| Error::from(e))
  5166. .and_then(|resp| {
  5167. let status = resp.status();
  5168. resp.body().concat2()
  5169. .and_then(move |body| Ok((status, body)))
  5170. .map_err(|e| Error::from(e))
  5171. })
  5172. .and_then(|(status, body)| {
  5173. if status.is_success() {
  5174. Ok(body)
  5175. } else {
  5176. Err(Error::from((status, &*body)))
  5177. }
  5178. })
  5179. .and_then(|body| {
  5180. let parsed: Result<Vec<::models::GitHook>, _> = serde_json::from_slice(&body);
  5181. parsed.map_err(|e| Error::from(e))
  5182. })
  5183. )
  5184. }
  5185. fn repo_list_git_refs(&self, owner: &str, repo: &str, _ref: &str) -> Box<Future<Item = Vec<::models::Reference>, Error = Error<serde_json::Value>>> {
  5186. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  5187. let mut auth_headers = HashMap::<String, String>::new();
  5188. let mut auth_query = HashMap::<String, String>::new();
  5189. if let Some(ref apikey) = configuration.api_key {
  5190. let key = apikey.key.clone();
  5191. let val = match apikey.prefix {
  5192. Some(ref prefix) => format!("{} {}", prefix, key),
  5193. None => key,
  5194. };
  5195. auth_query.insert("access_token".to_owned(), val);
  5196. };
  5197. if let Some(ref apikey) = configuration.api_key {
  5198. let key = apikey.key.clone();
  5199. let val = match apikey.prefix {
  5200. Some(ref prefix) => format!("{} {}", prefix, key),
  5201. None => key,
  5202. };
  5203. auth_headers.insert("Authorization".to_owned(), val);
  5204. };
  5205. if let Some(ref auth_conf) = configuration.basic_auth {
  5206. let auth = hyper::header::Authorization(
  5207. hyper::header::Basic {
  5208. username: auth_conf.0.to_owned(),
  5209. password: auth_conf.1.to_owned(),
  5210. }
  5211. );
  5212. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  5213. };
  5214. if let Some(ref apikey) = configuration.api_key {
  5215. let key = apikey.key.clone();
  5216. let val = match apikey.prefix {
  5217. Some(ref prefix) => format!("{} {}", prefix, key),
  5218. None => key,
  5219. };
  5220. auth_headers.insert("Sudo".to_owned(), val);
  5221. };
  5222. if let Some(ref apikey) = configuration.api_key {
  5223. let key = apikey.key.clone();
  5224. let val = match apikey.prefix {
  5225. Some(ref prefix) => format!("{} {}", prefix, key),
  5226. None => key,
  5227. };
  5228. auth_query.insert("sudo".to_owned(), val);
  5229. };
  5230. if let Some(ref apikey) = configuration.api_key {
  5231. let key = apikey.key.clone();
  5232. let val = match apikey.prefix {
  5233. Some(ref prefix) => format!("{} {}", prefix, key),
  5234. None => key,
  5235. };
  5236. auth_query.insert("token".to_owned(), val);
  5237. };
  5238. let method = hyper::Method::Get;
  5239. let query_string = {
  5240. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  5241. for (key, val) in &auth_query {
  5242. query.append_pair(key, val);
  5243. }
  5244. query.finish()
  5245. };
  5246. let uri_str = format!("{}/repos/{owner}/{repo}/git/refs/{ref}?{}", configuration.base_path, query_string, owner=owner, repo=repo, ref=_ref);
  5247. // TODO(farcaller): handle error
  5248. // if let Err(e) = uri {
  5249. // return Box::new(futures::future::err(e));
  5250. // }
  5251. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  5252. let mut req = hyper::Request::new(method, uri);
  5253. if let Some(ref user_agent) = configuration.user_agent {
  5254. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  5255. }
  5256. for (key, val) in auth_headers {
  5257. req.headers_mut().set_raw(key, val);
  5258. }
  5259. // send request
  5260. Box::new(
  5261. configuration.client.request(req)
  5262. .map_err(|e| Error::from(e))
  5263. .and_then(|resp| {
  5264. let status = resp.status();
  5265. resp.body().concat2()
  5266. .and_then(move |body| Ok((status, body)))
  5267. .map_err(|e| Error::from(e))
  5268. })
  5269. .and_then(|(status, body)| {
  5270. if status.is_success() {
  5271. Ok(body)
  5272. } else {
  5273. Err(Error::from((status, &*body)))
  5274. }
  5275. })
  5276. .and_then(|body| {
  5277. let parsed: Result<Vec<::models::Reference>, _> = serde_json::from_slice(&body);
  5278. parsed.map_err(|e| Error::from(e))
  5279. })
  5280. )
  5281. }
  5282. fn repo_list_hooks(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Hook>, Error = Error<serde_json::Value>>> {
  5283. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  5284. let mut auth_headers = HashMap::<String, String>::new();
  5285. let mut auth_query = HashMap::<String, String>::new();
  5286. if let Some(ref apikey) = configuration.api_key {
  5287. let key = apikey.key.clone();
  5288. let val = match apikey.prefix {
  5289. Some(ref prefix) => format!("{} {}", prefix, key),
  5290. None => key,
  5291. };
  5292. auth_query.insert("access_token".to_owned(), val);
  5293. };
  5294. if let Some(ref apikey) = configuration.api_key {
  5295. let key = apikey.key.clone();
  5296. let val = match apikey.prefix {
  5297. Some(ref prefix) => format!("{} {}", prefix, key),
  5298. None => key,
  5299. };
  5300. auth_headers.insert("Authorization".to_owned(), val);
  5301. };
  5302. if let Some(ref auth_conf) = configuration.basic_auth {
  5303. let auth = hyper::header::Authorization(
  5304. hyper::header::Basic {
  5305. username: auth_conf.0.to_owned(),
  5306. password: auth_conf.1.to_owned(),
  5307. }
  5308. );
  5309. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  5310. };
  5311. if let Some(ref apikey) = configuration.api_key {
  5312. let key = apikey.key.clone();
  5313. let val = match apikey.prefix {
  5314. Some(ref prefix) => format!("{} {}", prefix, key),
  5315. None => key,
  5316. };
  5317. auth_headers.insert("Sudo".to_owned(), val);
  5318. };
  5319. if let Some(ref apikey) = configuration.api_key {
  5320. let key = apikey.key.clone();
  5321. let val = match apikey.prefix {
  5322. Some(ref prefix) => format!("{} {}", prefix, key),
  5323. None => key,
  5324. };
  5325. auth_query.insert("sudo".to_owned(), val);
  5326. };
  5327. if let Some(ref apikey) = configuration.api_key {
  5328. let key = apikey.key.clone();
  5329. let val = match apikey.prefix {
  5330. Some(ref prefix) => format!("{} {}", prefix, key),
  5331. None => key,
  5332. };
  5333. auth_query.insert("token".to_owned(), val);
  5334. };
  5335. let method = hyper::Method::Get;
  5336. let query_string = {
  5337. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  5338. for (key, val) in &auth_query {
  5339. query.append_pair(key, val);
  5340. }
  5341. query.finish()
  5342. };
  5343. let uri_str = format!("{}/repos/{owner}/{repo}/hooks?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  5344. // TODO(farcaller): handle error
  5345. // if let Err(e) = uri {
  5346. // return Box::new(futures::future::err(e));
  5347. // }
  5348. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  5349. let mut req = hyper::Request::new(method, uri);
  5350. if let Some(ref user_agent) = configuration.user_agent {
  5351. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  5352. }
  5353. for (key, val) in auth_headers {
  5354. req.headers_mut().set_raw(key, val);
  5355. }
  5356. // send request
  5357. Box::new(
  5358. configuration.client.request(req)
  5359. .map_err(|e| Error::from(e))
  5360. .and_then(|resp| {
  5361. let status = resp.status();
  5362. resp.body().concat2()
  5363. .and_then(move |body| Ok((status, body)))
  5364. .map_err(|e| Error::from(e))
  5365. })
  5366. .and_then(|(status, body)| {
  5367. if status.is_success() {
  5368. Ok(body)
  5369. } else {
  5370. Err(Error::from((status, &*body)))
  5371. }
  5372. })
  5373. .and_then(|body| {
  5374. let parsed: Result<Vec<::models::Hook>, _> = serde_json::from_slice(&body);
  5375. parsed.map_err(|e| Error::from(e))
  5376. })
  5377. )
  5378. }
  5379. fn repo_list_keys(&self, owner: &str, repo: &str, key_id: i32, fingerprint: &str) -> Box<Future<Item = Vec<::models::DeployKey>, Error = Error<serde_json::Value>>> {
  5380. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  5381. let mut auth_headers = HashMap::<String, String>::new();
  5382. let mut auth_query = HashMap::<String, String>::new();
  5383. if let Some(ref apikey) = configuration.api_key {
  5384. let key = apikey.key.clone();
  5385. let val = match apikey.prefix {
  5386. Some(ref prefix) => format!("{} {}", prefix, key),
  5387. None => key,
  5388. };
  5389. auth_query.insert("access_token".to_owned(), val);
  5390. };
  5391. if let Some(ref apikey) = configuration.api_key {
  5392. let key = apikey.key.clone();
  5393. let val = match apikey.prefix {
  5394. Some(ref prefix) => format!("{} {}", prefix, key),
  5395. None => key,
  5396. };
  5397. auth_headers.insert("Authorization".to_owned(), val);
  5398. };
  5399. if let Some(ref auth_conf) = configuration.basic_auth {
  5400. let auth = hyper::header::Authorization(
  5401. hyper::header::Basic {
  5402. username: auth_conf.0.to_owned(),
  5403. password: auth_conf.1.to_owned(),
  5404. }
  5405. );
  5406. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  5407. };
  5408. if let Some(ref apikey) = configuration.api_key {
  5409. let key = apikey.key.clone();
  5410. let val = match apikey.prefix {
  5411. Some(ref prefix) => format!("{} {}", prefix, key),
  5412. None => key,
  5413. };
  5414. auth_headers.insert("Sudo".to_owned(), val);
  5415. };
  5416. if let Some(ref apikey) = configuration.api_key {
  5417. let key = apikey.key.clone();
  5418. let val = match apikey.prefix {
  5419. Some(ref prefix) => format!("{} {}", prefix, key),
  5420. None => key,
  5421. };
  5422. auth_query.insert("sudo".to_owned(), val);
  5423. };
  5424. if let Some(ref apikey) = configuration.api_key {
  5425. let key = apikey.key.clone();
  5426. let val = match apikey.prefix {
  5427. Some(ref prefix) => format!("{} {}", prefix, key),
  5428. None => key,
  5429. };
  5430. auth_query.insert("token".to_owned(), val);
  5431. };
  5432. let method = hyper::Method::Get;
  5433. let query_string = {
  5434. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  5435. query.append_pair("key_id", &key_id.to_string());
  5436. query.append_pair("fingerprint", &fingerprint.to_string());
  5437. for (key, val) in &auth_query {
  5438. query.append_pair(key, val);
  5439. }
  5440. query.finish()
  5441. };
  5442. let uri_str = format!("{}/repos/{owner}/{repo}/keys?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  5443. // TODO(farcaller): handle error
  5444. // if let Err(e) = uri {
  5445. // return Box::new(futures::future::err(e));
  5446. // }
  5447. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  5448. let mut req = hyper::Request::new(method, uri);
  5449. if let Some(ref user_agent) = configuration.user_agent {
  5450. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  5451. }
  5452. for (key, val) in auth_headers {
  5453. req.headers_mut().set_raw(key, val);
  5454. }
  5455. // send request
  5456. Box::new(
  5457. configuration.client.request(req)
  5458. .map_err(|e| Error::from(e))
  5459. .and_then(|resp| {
  5460. let status = resp.status();
  5461. resp.body().concat2()
  5462. .and_then(move |body| Ok((status, body)))
  5463. .map_err(|e| Error::from(e))
  5464. })
  5465. .and_then(|(status, body)| {
  5466. if status.is_success() {
  5467. Ok(body)
  5468. } else {
  5469. Err(Error::from((status, &*body)))
  5470. }
  5471. })
  5472. .and_then(|body| {
  5473. let parsed: Result<Vec<::models::DeployKey>, _> = serde_json::from_slice(&body);
  5474. parsed.map_err(|e| Error::from(e))
  5475. })
  5476. )
  5477. }
  5478. fn repo_list_pull_requests(&self, owner: &str, repo: &str, page: i32, state: &str, sort: &str, milestone: i64, labels: Vec<i64>) -> Box<Future<Item = Vec<::models::PullRequest>, Error = Error<serde_json::Value>>> {
  5479. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  5480. let mut auth_headers = HashMap::<String, String>::new();
  5481. let mut auth_query = HashMap::<String, String>::new();
  5482. if let Some(ref apikey) = configuration.api_key {
  5483. let key = apikey.key.clone();
  5484. let val = match apikey.prefix {
  5485. Some(ref prefix) => format!("{} {}", prefix, key),
  5486. None => key,
  5487. };
  5488. auth_query.insert("access_token".to_owned(), val);
  5489. };
  5490. if let Some(ref apikey) = configuration.api_key {
  5491. let key = apikey.key.clone();
  5492. let val = match apikey.prefix {
  5493. Some(ref prefix) => format!("{} {}", prefix, key),
  5494. None => key,
  5495. };
  5496. auth_headers.insert("Authorization".to_owned(), val);
  5497. };
  5498. if let Some(ref auth_conf) = configuration.basic_auth {
  5499. let auth = hyper::header::Authorization(
  5500. hyper::header::Basic {
  5501. username: auth_conf.0.to_owned(),
  5502. password: auth_conf.1.to_owned(),
  5503. }
  5504. );
  5505. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  5506. };
  5507. if let Some(ref apikey) = configuration.api_key {
  5508. let key = apikey.key.clone();
  5509. let val = match apikey.prefix {
  5510. Some(ref prefix) => format!("{} {}", prefix, key),
  5511. None => key,
  5512. };
  5513. auth_headers.insert("Sudo".to_owned(), val);
  5514. };
  5515. if let Some(ref apikey) = configuration.api_key {
  5516. let key = apikey.key.clone();
  5517. let val = match apikey.prefix {
  5518. Some(ref prefix) => format!("{} {}", prefix, key),
  5519. None => key,
  5520. };
  5521. auth_query.insert("sudo".to_owned(), val);
  5522. };
  5523. if let Some(ref apikey) = configuration.api_key {
  5524. let key = apikey.key.clone();
  5525. let val = match apikey.prefix {
  5526. Some(ref prefix) => format!("{} {}", prefix, key),
  5527. None => key,
  5528. };
  5529. auth_query.insert("token".to_owned(), val);
  5530. };
  5531. let method = hyper::Method::Get;
  5532. let query_string = {
  5533. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  5534. query.append_pair("page", &page.to_string());
  5535. query.append_pair("state", &state.to_string());
  5536. query.append_pair("sort", &sort.to_string());
  5537. query.append_pair("milestone", &milestone.to_string());
  5538. let mut label_str = "".to_owned();
  5539. for label in labels {
  5540. label_str += &label.to_string();
  5541. label_str += ",";
  5542. }
  5543. query.append_pair("labels", &label_str[..label_str.chars().count()-1].to_string());
  5544. for (key, val) in &auth_query {
  5545. query.append_pair(key, val);
  5546. }
  5547. query.finish()
  5548. };
  5549. let uri_str = format!("{}/repos/{owner}/{repo}/pulls?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  5550. // TODO(farcaller): handle error
  5551. // if let Err(e) = uri {
  5552. // return Box::new(futures::future::err(e));
  5553. // }
  5554. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  5555. let mut req = hyper::Request::new(method, uri);
  5556. if let Some(ref user_agent) = configuration.user_agent {
  5557. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  5558. }
  5559. for (key, val) in auth_headers {
  5560. req.headers_mut().set_raw(key, val);
  5561. }
  5562. // send request
  5563. Box::new(
  5564. configuration.client.request(req)
  5565. .map_err(|e| Error::from(e))
  5566. .and_then(|resp| {
  5567. let status = resp.status();
  5568. resp.body().concat2()
  5569. .and_then(move |body| Ok((status, body)))
  5570. .map_err(|e| Error::from(e))
  5571. })
  5572. .and_then(|(status, body)| {
  5573. if status.is_success() {
  5574. Ok(body)
  5575. } else {
  5576. Err(Error::from((status, &*body)))
  5577. }
  5578. })
  5579. .and_then(|body| {
  5580. let parsed: Result<Vec<::models::PullRequest>, _> = serde_json::from_slice(&body);
  5581. parsed.map_err(|e| Error::from(e))
  5582. })
  5583. )
  5584. }
  5585. fn repo_list_release_attachments(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = Vec<::models::Attachment>, Error = Error<serde_json::Value>>> {
  5586. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  5587. let mut auth_headers = HashMap::<String, String>::new();
  5588. let mut auth_query = HashMap::<String, String>::new();
  5589. if let Some(ref apikey) = configuration.api_key {
  5590. let key = apikey.key.clone();
  5591. let val = match apikey.prefix {
  5592. Some(ref prefix) => format!("{} {}", prefix, key),
  5593. None => key,
  5594. };
  5595. auth_query.insert("access_token".to_owned(), val);
  5596. };
  5597. if let Some(ref apikey) = configuration.api_key {
  5598. let key = apikey.key.clone();
  5599. let val = match apikey.prefix {
  5600. Some(ref prefix) => format!("{} {}", prefix, key),
  5601. None => key,
  5602. };
  5603. auth_headers.insert("Authorization".to_owned(), val);
  5604. };
  5605. if let Some(ref auth_conf) = configuration.basic_auth {
  5606. let auth = hyper::header::Authorization(
  5607. hyper::header::Basic {
  5608. username: auth_conf.0.to_owned(),
  5609. password: auth_conf.1.to_owned(),
  5610. }
  5611. );
  5612. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  5613. };
  5614. if let Some(ref apikey) = configuration.api_key {
  5615. let key = apikey.key.clone();
  5616. let val = match apikey.prefix {
  5617. Some(ref prefix) => format!("{} {}", prefix, key),
  5618. None => key,
  5619. };
  5620. auth_headers.insert("Sudo".to_owned(), val);
  5621. };
  5622. if let Some(ref apikey) = configuration.api_key {
  5623. let key = apikey.key.clone();
  5624. let val = match apikey.prefix {
  5625. Some(ref prefix) => format!("{} {}", prefix, key),
  5626. None => key,
  5627. };
  5628. auth_query.insert("sudo".to_owned(), val);
  5629. };
  5630. if let Some(ref apikey) = configuration.api_key {
  5631. let key = apikey.key.clone();
  5632. let val = match apikey.prefix {
  5633. Some(ref prefix) => format!("{} {}", prefix, key),
  5634. None => key,
  5635. };
  5636. auth_query.insert("token".to_owned(), val);
  5637. };
  5638. let method = hyper::Method::Get;
  5639. let query_string = {
  5640. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  5641. for (key, val) in &auth_query {
  5642. query.append_pair(key, val);
  5643. }
  5644. query.finish()
  5645. };
  5646. let uri_str = format!("{}/repos/{owner}/{repo}/releases/{id}/assets?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  5647. // TODO(farcaller): handle error
  5648. // if let Err(e) = uri {
  5649. // return Box::new(futures::future::err(e));
  5650. // }
  5651. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  5652. let mut req = hyper::Request::new(method, uri);
  5653. if let Some(ref user_agent) = configuration.user_agent {
  5654. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  5655. }
  5656. for (key, val) in auth_headers {
  5657. req.headers_mut().set_raw(key, val);
  5658. }
  5659. // send request
  5660. Box::new(
  5661. configuration.client.request(req)
  5662. .map_err(|e| Error::from(e))
  5663. .and_then(|resp| {
  5664. let status = resp.status();
  5665. resp.body().concat2()
  5666. .and_then(move |body| Ok((status, body)))
  5667. .map_err(|e| Error::from(e))
  5668. })
  5669. .and_then(|(status, body)| {
  5670. if status.is_success() {
  5671. Ok(body)
  5672. } else {
  5673. Err(Error::from((status, &*body)))
  5674. }
  5675. })
  5676. .and_then(|body| {
  5677. let parsed: Result<Vec<::models::Attachment>, _> = serde_json::from_slice(&body);
  5678. parsed.map_err(|e| Error::from(e))
  5679. })
  5680. )
  5681. }
  5682. fn repo_list_releases(&self, owner: &str, repo: &str, page: i32, per_page: i32) -> Box<Future<Item = Vec<::models::Release>, Error = Error<serde_json::Value>>> {
  5683. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  5684. let mut auth_headers = HashMap::<String, String>::new();
  5685. let mut auth_query = HashMap::<String, String>::new();
  5686. if let Some(ref apikey) = configuration.api_key {
  5687. let key = apikey.key.clone();
  5688. let val = match apikey.prefix {
  5689. Some(ref prefix) => format!("{} {}", prefix, key),
  5690. None => key,
  5691. };
  5692. auth_query.insert("access_token".to_owned(), val);
  5693. };
  5694. if let Some(ref apikey) = configuration.api_key {
  5695. let key = apikey.key.clone();
  5696. let val = match apikey.prefix {
  5697. Some(ref prefix) => format!("{} {}", prefix, key),
  5698. None => key,
  5699. };
  5700. auth_headers.insert("Authorization".to_owned(), val);
  5701. };
  5702. if let Some(ref auth_conf) = configuration.basic_auth {
  5703. let auth = hyper::header::Authorization(
  5704. hyper::header::Basic {
  5705. username: auth_conf.0.to_owned(),
  5706. password: auth_conf.1.to_owned(),
  5707. }
  5708. );
  5709. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  5710. };
  5711. if let Some(ref apikey) = configuration.api_key {
  5712. let key = apikey.key.clone();
  5713. let val = match apikey.prefix {
  5714. Some(ref prefix) => format!("{} {}", prefix, key),
  5715. None => key,
  5716. };
  5717. //auth_headers.insert("Sudo".to_owned(), val);
  5718. };
  5719. if let Some(ref apikey) = configuration.api_key {
  5720. let key = apikey.key.clone();
  5721. let val = match apikey.prefix {
  5722. Some(ref prefix) => format!("{} {}", prefix, key),
  5723. None => key,
  5724. };
  5725. //auth_query.insert("sudo".to_owned(), val);
  5726. };
  5727. if let Some(ref apikey) = configuration.api_key {
  5728. let key = apikey.key.clone();
  5729. let val = match apikey.prefix {
  5730. Some(ref prefix) => format!("{} {}", prefix, key),
  5731. None => key,
  5732. };
  5733. auth_query.insert("token".to_owned(), val);
  5734. };
  5735. let method = hyper::Method::Get;
  5736. let query_string = {
  5737. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  5738. query.append_pair("page", &page.to_string());
  5739. query.append_pair("per_page", &per_page.to_string());
  5740. for (key, val) in &auth_query {
  5741. query.append_pair(key, val);
  5742. }
  5743. query.finish()
  5744. };
  5745. let uri_str = format!("{}/repos/{owner}/{repo}/releases?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  5746. //println!("Request URL {}", uri_str);
  5747. // TODO(farcaller): handle error
  5748. // if let Err(e) = uri {
  5749. // return Box::new(futures::future::err(e));
  5750. // }
  5751. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  5752. let mut req = hyper::Request::new(method, uri);
  5753. if let Some(ref user_agent) = configuration.user_agent {
  5754. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  5755. }
  5756. for (key, val) in auth_headers {
  5757. req.headers_mut().set_raw(key, val);
  5758. }
  5759. // send request
  5760. Box::new(
  5761. configuration.client.request(req)
  5762. .map_err(|e| Error::from(e))
  5763. .and_then(|resp| {
  5764. let status = resp.status();
  5765. resp.body().concat2()
  5766. .and_then(move |body| Ok((status, body)))
  5767. .map_err(|e| Error::from(e))
  5768. })
  5769. .and_then(|(status, body)| {
  5770. if status.is_success() {
  5771. Ok(body)
  5772. } else {
  5773. Err(Error::from((status, &*body)))
  5774. }
  5775. })
  5776. .and_then(|body| {
  5777. let parsed: Result<Vec<::models::Release>, _> = serde_json::from_slice(&body);
  5778. parsed.map_err(|e| Error::from(e))
  5779. })
  5780. )
  5781. }
  5782. fn repo_list_stargazers(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>> {
  5783. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  5784. let mut auth_headers = HashMap::<String, String>::new();
  5785. let mut auth_query = HashMap::<String, String>::new();
  5786. if let Some(ref apikey) = configuration.api_key {
  5787. let key = apikey.key.clone();
  5788. let val = match apikey.prefix {
  5789. Some(ref prefix) => format!("{} {}", prefix, key),
  5790. None => key,
  5791. };
  5792. auth_query.insert("access_token".to_owned(), val);
  5793. };
  5794. if let Some(ref apikey) = configuration.api_key {
  5795. let key = apikey.key.clone();
  5796. let val = match apikey.prefix {
  5797. Some(ref prefix) => format!("{} {}", prefix, key),
  5798. None => key,
  5799. };
  5800. auth_headers.insert("Authorization".to_owned(), val);
  5801. };
  5802. if let Some(ref auth_conf) = configuration.basic_auth {
  5803. let auth = hyper::header::Authorization(
  5804. hyper::header::Basic {
  5805. username: auth_conf.0.to_owned(),
  5806. password: auth_conf.1.to_owned(),
  5807. }
  5808. );
  5809. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  5810. };
  5811. if let Some(ref apikey) = configuration.api_key {
  5812. let key = apikey.key.clone();
  5813. let val = match apikey.prefix {
  5814. Some(ref prefix) => format!("{} {}", prefix, key),
  5815. None => key,
  5816. };
  5817. auth_headers.insert("Sudo".to_owned(), val);
  5818. };
  5819. if let Some(ref apikey) = configuration.api_key {
  5820. let key = apikey.key.clone();
  5821. let val = match apikey.prefix {
  5822. Some(ref prefix) => format!("{} {}", prefix, key),
  5823. None => key,
  5824. };
  5825. auth_query.insert("sudo".to_owned(), val);
  5826. };
  5827. if let Some(ref apikey) = configuration.api_key {
  5828. let key = apikey.key.clone();
  5829. let val = match apikey.prefix {
  5830. Some(ref prefix) => format!("{} {}", prefix, key),
  5831. None => key,
  5832. };
  5833. auth_query.insert("token".to_owned(), val);
  5834. };
  5835. let method = hyper::Method::Get;
  5836. let query_string = {
  5837. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  5838. for (key, val) in &auth_query {
  5839. query.append_pair(key, val);
  5840. }
  5841. query.finish()
  5842. };
  5843. let uri_str = format!("{}/repos/{owner}/{repo}/stargazers?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  5844. // TODO(farcaller): handle error
  5845. // if let Err(e) = uri {
  5846. // return Box::new(futures::future::err(e));
  5847. // }
  5848. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  5849. let mut req = hyper::Request::new(method, uri);
  5850. if let Some(ref user_agent) = configuration.user_agent {
  5851. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  5852. }
  5853. for (key, val) in auth_headers {
  5854. req.headers_mut().set_raw(key, val);
  5855. }
  5856. // send request
  5857. Box::new(
  5858. configuration.client.request(req)
  5859. .map_err(|e| Error::from(e))
  5860. .and_then(|resp| {
  5861. let status = resp.status();
  5862. resp.body().concat2()
  5863. .and_then(move |body| Ok((status, body)))
  5864. .map_err(|e| Error::from(e))
  5865. })
  5866. .and_then(|(status, body)| {
  5867. if status.is_success() {
  5868. Ok(body)
  5869. } else {
  5870. Err(Error::from((status, &*body)))
  5871. }
  5872. })
  5873. .and_then(|body| {
  5874. let parsed: Result<Vec<::models::User>, _> = serde_json::from_slice(&body);
  5875. parsed.map_err(|e| Error::from(e))
  5876. })
  5877. )
  5878. }
  5879. fn repo_list_statuses(&self, owner: &str, repo: &str, sha: &str, page: i32, sort: &str, state: &str) -> Box<Future<Item = Vec<::models::Status>, Error = Error<serde_json::Value>>> {
  5880. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  5881. let mut auth_headers = HashMap::<String, String>::new();
  5882. let mut auth_query = HashMap::<String, String>::new();
  5883. if let Some(ref apikey) = configuration.api_key {
  5884. let key = apikey.key.clone();
  5885. let val = match apikey.prefix {
  5886. Some(ref prefix) => format!("{} {}", prefix, key),
  5887. None => key,
  5888. };
  5889. auth_query.insert("access_token".to_owned(), val);
  5890. };
  5891. if let Some(ref apikey) = configuration.api_key {
  5892. let key = apikey.key.clone();
  5893. let val = match apikey.prefix {
  5894. Some(ref prefix) => format!("{} {}", prefix, key),
  5895. None => key,
  5896. };
  5897. auth_headers.insert("Authorization".to_owned(), val);
  5898. };
  5899. if let Some(ref auth_conf) = configuration.basic_auth {
  5900. let auth = hyper::header::Authorization(
  5901. hyper::header::Basic {
  5902. username: auth_conf.0.to_owned(),
  5903. password: auth_conf.1.to_owned(),
  5904. }
  5905. );
  5906. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  5907. };
  5908. if let Some(ref apikey) = configuration.api_key {
  5909. let key = apikey.key.clone();
  5910. let val = match apikey.prefix {
  5911. Some(ref prefix) => format!("{} {}", prefix, key),
  5912. None => key,
  5913. };
  5914. auth_headers.insert("Sudo".to_owned(), val);
  5915. };
  5916. if let Some(ref apikey) = configuration.api_key {
  5917. let key = apikey.key.clone();
  5918. let val = match apikey.prefix {
  5919. Some(ref prefix) => format!("{} {}", prefix, key),
  5920. None => key,
  5921. };
  5922. auth_query.insert("sudo".to_owned(), val);
  5923. };
  5924. if let Some(ref apikey) = configuration.api_key {
  5925. let key = apikey.key.clone();
  5926. let val = match apikey.prefix {
  5927. Some(ref prefix) => format!("{} {}", prefix, key),
  5928. None => key,
  5929. };
  5930. auth_query.insert("token".to_owned(), val);
  5931. };
  5932. let method = hyper::Method::Get;
  5933. let query_string = {
  5934. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  5935. query.append_pair("page", &page.to_string());
  5936. query.append_pair("sort", &sort.to_string());
  5937. query.append_pair("state", &state.to_string());
  5938. for (key, val) in &auth_query {
  5939. query.append_pair(key, val);
  5940. }
  5941. query.finish()
  5942. };
  5943. let uri_str = format!("{}/repos/{owner}/{repo}/statuses/{sha}?{}", configuration.base_path, query_string, owner=owner, repo=repo, sha=sha);
  5944. // TODO(farcaller): handle error
  5945. // if let Err(e) = uri {
  5946. // return Box::new(futures::future::err(e));
  5947. // }
  5948. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  5949. let mut req = hyper::Request::new(method, uri);
  5950. if let Some(ref user_agent) = configuration.user_agent {
  5951. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  5952. }
  5953. for (key, val) in auth_headers {
  5954. req.headers_mut().set_raw(key, val);
  5955. }
  5956. // send request
  5957. Box::new(
  5958. configuration.client.request(req)
  5959. .map_err(|e| Error::from(e))
  5960. .and_then(|resp| {
  5961. let status = resp.status();
  5962. resp.body().concat2()
  5963. .and_then(move |body| Ok((status, body)))
  5964. .map_err(|e| Error::from(e))
  5965. })
  5966. .and_then(|(status, body)| {
  5967. if status.is_success() {
  5968. Ok(body)
  5969. } else {
  5970. Err(Error::from((status, &*body)))
  5971. }
  5972. })
  5973. .and_then(|body| {
  5974. let parsed: Result<Vec<::models::Status>, _> = serde_json::from_slice(&body);
  5975. parsed.map_err(|e| Error::from(e))
  5976. })
  5977. )
  5978. }
  5979. fn repo_list_subscribers(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>> {
  5980. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  5981. let mut auth_headers = HashMap::<String, String>::new();
  5982. let mut auth_query = HashMap::<String, String>::new();
  5983. if let Some(ref apikey) = configuration.api_key {
  5984. let key = apikey.key.clone();
  5985. let val = match apikey.prefix {
  5986. Some(ref prefix) => format!("{} {}", prefix, key),
  5987. None => key,
  5988. };
  5989. auth_query.insert("access_token".to_owned(), val);
  5990. };
  5991. if let Some(ref apikey) = configuration.api_key {
  5992. let key = apikey.key.clone();
  5993. let val = match apikey.prefix {
  5994. Some(ref prefix) => format!("{} {}", prefix, key),
  5995. None => key,
  5996. };
  5997. auth_headers.insert("Authorization".to_owned(), val);
  5998. };
  5999. if let Some(ref auth_conf) = configuration.basic_auth {
  6000. let auth = hyper::header::Authorization(
  6001. hyper::header::Basic {
  6002. username: auth_conf.0.to_owned(),
  6003. password: auth_conf.1.to_owned(),
  6004. }
  6005. );
  6006. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  6007. };
  6008. if let Some(ref apikey) = configuration.api_key {
  6009. let key = apikey.key.clone();
  6010. let val = match apikey.prefix {
  6011. Some(ref prefix) => format!("{} {}", prefix, key),
  6012. None => key,
  6013. };
  6014. auth_headers.insert("Sudo".to_owned(), val);
  6015. };
  6016. if let Some(ref apikey) = configuration.api_key {
  6017. let key = apikey.key.clone();
  6018. let val = match apikey.prefix {
  6019. Some(ref prefix) => format!("{} {}", prefix, key),
  6020. None => key,
  6021. };
  6022. auth_query.insert("sudo".to_owned(), val);
  6023. };
  6024. if let Some(ref apikey) = configuration.api_key {
  6025. let key = apikey.key.clone();
  6026. let val = match apikey.prefix {
  6027. Some(ref prefix) => format!("{} {}", prefix, key),
  6028. None => key,
  6029. };
  6030. auth_query.insert("token".to_owned(), val);
  6031. };
  6032. let method = hyper::Method::Get;
  6033. let query_string = {
  6034. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  6035. for (key, val) in &auth_query {
  6036. query.append_pair(key, val);
  6037. }
  6038. query.finish()
  6039. };
  6040. let uri_str = format!("{}/repos/{owner}/{repo}/subscribers?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  6041. // TODO(farcaller): handle error
  6042. // if let Err(e) = uri {
  6043. // return Box::new(futures::future::err(e));
  6044. // }
  6045. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  6046. let mut req = hyper::Request::new(method, uri);
  6047. if let Some(ref user_agent) = configuration.user_agent {
  6048. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  6049. }
  6050. for (key, val) in auth_headers {
  6051. req.headers_mut().set_raw(key, val);
  6052. }
  6053. // send request
  6054. Box::new(
  6055. configuration.client.request(req)
  6056. .map_err(|e| Error::from(e))
  6057. .and_then(|resp| {
  6058. let status = resp.status();
  6059. resp.body().concat2()
  6060. .and_then(move |body| Ok((status, body)))
  6061. .map_err(|e| Error::from(e))
  6062. })
  6063. .and_then(|(status, body)| {
  6064. if status.is_success() {
  6065. Ok(body)
  6066. } else {
  6067. Err(Error::from((status, &*body)))
  6068. }
  6069. })
  6070. .and_then(|body| {
  6071. let parsed: Result<Vec<::models::User>, _> = serde_json::from_slice(&body);
  6072. parsed.map_err(|e| Error::from(e))
  6073. })
  6074. )
  6075. }
  6076. fn repo_list_tags(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Tag>, Error = Error<serde_json::Value>>> {
  6077. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  6078. let mut auth_headers = HashMap::<String, String>::new();
  6079. let mut auth_query = HashMap::<String, String>::new();
  6080. if let Some(ref apikey) = configuration.api_key {
  6081. let key = apikey.key.clone();
  6082. let val = match apikey.prefix {
  6083. Some(ref prefix) => format!("{} {}", prefix, key),
  6084. None => key,
  6085. };
  6086. auth_query.insert("access_token".to_owned(), val);
  6087. };
  6088. if let Some(ref apikey) = configuration.api_key {
  6089. let key = apikey.key.clone();
  6090. let val = match apikey.prefix {
  6091. Some(ref prefix) => format!("{} {}", prefix, key),
  6092. None => key,
  6093. };
  6094. auth_headers.insert("Authorization".to_owned(), val);
  6095. };
  6096. if let Some(ref auth_conf) = configuration.basic_auth {
  6097. let auth = hyper::header::Authorization(
  6098. hyper::header::Basic {
  6099. username: auth_conf.0.to_owned(),
  6100. password: auth_conf.1.to_owned(),
  6101. }
  6102. );
  6103. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  6104. };
  6105. if let Some(ref apikey) = configuration.api_key {
  6106. let key = apikey.key.clone();
  6107. let val = match apikey.prefix {
  6108. Some(ref prefix) => format!("{} {}", prefix, key),
  6109. None => key,
  6110. };
  6111. auth_headers.insert("Sudo".to_owned(), val);
  6112. };
  6113. if let Some(ref apikey) = configuration.api_key {
  6114. let key = apikey.key.clone();
  6115. let val = match apikey.prefix {
  6116. Some(ref prefix) => format!("{} {}", prefix, key),
  6117. None => key,
  6118. };
  6119. auth_query.insert("sudo".to_owned(), val);
  6120. };
  6121. if let Some(ref apikey) = configuration.api_key {
  6122. let key = apikey.key.clone();
  6123. let val = match apikey.prefix {
  6124. Some(ref prefix) => format!("{} {}", prefix, key),
  6125. None => key,
  6126. };
  6127. auth_query.insert("token".to_owned(), val);
  6128. };
  6129. let method = hyper::Method::Get;
  6130. let query_string = {
  6131. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  6132. for (key, val) in &auth_query {
  6133. query.append_pair(key, val);
  6134. }
  6135. query.finish()
  6136. };
  6137. let uri_str = format!("{}/repos/{owner}/{repo}/tags?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  6138. // TODO(farcaller): handle error
  6139. // if let Err(e) = uri {
  6140. // return Box::new(futures::future::err(e));
  6141. // }
  6142. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  6143. let mut req = hyper::Request::new(method, uri);
  6144. if let Some(ref user_agent) = configuration.user_agent {
  6145. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  6146. }
  6147. for (key, val) in auth_headers {
  6148. req.headers_mut().set_raw(key, val);
  6149. }
  6150. // send request
  6151. Box::new(
  6152. configuration.client.request(req)
  6153. .map_err(|e| Error::from(e))
  6154. .and_then(|resp| {
  6155. let status = resp.status();
  6156. resp.body().concat2()
  6157. .and_then(move |body| Ok((status, body)))
  6158. .map_err(|e| Error::from(e))
  6159. })
  6160. .and_then(|(status, body)| {
  6161. if status.is_success() {
  6162. Ok(body)
  6163. } else {
  6164. Err(Error::from((status, &*body)))
  6165. }
  6166. })
  6167. .and_then(|body| {
  6168. let parsed: Result<Vec<::models::Tag>, _> = serde_json::from_slice(&body);
  6169. parsed.map_err(|e| Error::from(e))
  6170. })
  6171. )
  6172. }
  6173. fn repo_list_topics(&self, owner: &str, repo: &str) -> Box<Future<Item = ::models::TopicName, Error = Error<serde_json::Value>>> {
  6174. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  6175. let mut auth_headers = HashMap::<String, String>::new();
  6176. let mut auth_query = HashMap::<String, String>::new();
  6177. if let Some(ref apikey) = configuration.api_key {
  6178. let key = apikey.key.clone();
  6179. let val = match apikey.prefix {
  6180. Some(ref prefix) => format!("{} {}", prefix, key),
  6181. None => key,
  6182. };
  6183. auth_query.insert("access_token".to_owned(), val);
  6184. };
  6185. if let Some(ref apikey) = configuration.api_key {
  6186. let key = apikey.key.clone();
  6187. let val = match apikey.prefix {
  6188. Some(ref prefix) => format!("{} {}", prefix, key),
  6189. None => key,
  6190. };
  6191. auth_headers.insert("Authorization".to_owned(), val);
  6192. };
  6193. if let Some(ref auth_conf) = configuration.basic_auth {
  6194. let auth = hyper::header::Authorization(
  6195. hyper::header::Basic {
  6196. username: auth_conf.0.to_owned(),
  6197. password: auth_conf.1.to_owned(),
  6198. }
  6199. );
  6200. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  6201. };
  6202. if let Some(ref apikey) = configuration.api_key {
  6203. let key = apikey.key.clone();
  6204. let val = match apikey.prefix {
  6205. Some(ref prefix) => format!("{} {}", prefix, key),
  6206. None => key,
  6207. };
  6208. auth_headers.insert("Sudo".to_owned(), val);
  6209. };
  6210. if let Some(ref apikey) = configuration.api_key {
  6211. let key = apikey.key.clone();
  6212. let val = match apikey.prefix {
  6213. Some(ref prefix) => format!("{} {}", prefix, key),
  6214. None => key,
  6215. };
  6216. auth_query.insert("sudo".to_owned(), val);
  6217. };
  6218. if let Some(ref apikey) = configuration.api_key {
  6219. let key = apikey.key.clone();
  6220. let val = match apikey.prefix {
  6221. Some(ref prefix) => format!("{} {}", prefix, key),
  6222. None => key,
  6223. };
  6224. auth_query.insert("token".to_owned(), val);
  6225. };
  6226. let method = hyper::Method::Get;
  6227. let query_string = {
  6228. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  6229. for (key, val) in &auth_query {
  6230. query.append_pair(key, val);
  6231. }
  6232. query.finish()
  6233. };
  6234. let uri_str = format!("{}/repos/{owner}/{repo}/topics?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  6235. // TODO(farcaller): handle error
  6236. // if let Err(e) = uri {
  6237. // return Box::new(futures::future::err(e));
  6238. // }
  6239. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  6240. let mut req = hyper::Request::new(method, uri);
  6241. if let Some(ref user_agent) = configuration.user_agent {
  6242. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  6243. }
  6244. for (key, val) in auth_headers {
  6245. req.headers_mut().set_raw(key, val);
  6246. }
  6247. // send request
  6248. Box::new(
  6249. configuration.client.request(req)
  6250. .map_err(|e| Error::from(e))
  6251. .and_then(|resp| {
  6252. let status = resp.status();
  6253. resp.body().concat2()
  6254. .and_then(move |body| Ok((status, body)))
  6255. .map_err(|e| Error::from(e))
  6256. })
  6257. .and_then(|(status, body)| {
  6258. if status.is_success() {
  6259. Ok(body)
  6260. } else {
  6261. Err(Error::from((status, &*body)))
  6262. }
  6263. })
  6264. .and_then(|body| {
  6265. let parsed: Result<::models::TopicName, _> = serde_json::from_slice(&body);
  6266. parsed.map_err(|e| Error::from(e))
  6267. })
  6268. )
  6269. }
  6270. fn repo_merge_pull_request(&self, owner: &str, repo: &str, index: i64, body: ::models::MergePullRequestOption) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  6271. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  6272. let mut auth_headers = HashMap::<String, String>::new();
  6273. let mut auth_query = HashMap::<String, String>::new();
  6274. if let Some(ref apikey) = configuration.api_key {
  6275. let key = apikey.key.clone();
  6276. let val = match apikey.prefix {
  6277. Some(ref prefix) => format!("{} {}", prefix, key),
  6278. None => key,
  6279. };
  6280. auth_query.insert("access_token".to_owned(), val);
  6281. };
  6282. if let Some(ref apikey) = configuration.api_key {
  6283. let key = apikey.key.clone();
  6284. let val = match apikey.prefix {
  6285. Some(ref prefix) => format!("{} {}", prefix, key),
  6286. None => key,
  6287. };
  6288. auth_headers.insert("Authorization".to_owned(), val);
  6289. };
  6290. if let Some(ref auth_conf) = configuration.basic_auth {
  6291. let auth = hyper::header::Authorization(
  6292. hyper::header::Basic {
  6293. username: auth_conf.0.to_owned(),
  6294. password: auth_conf.1.to_owned(),
  6295. }
  6296. );
  6297. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  6298. };
  6299. if let Some(ref apikey) = configuration.api_key {
  6300. let key = apikey.key.clone();
  6301. let val = match apikey.prefix {
  6302. Some(ref prefix) => format!("{} {}", prefix, key),
  6303. None => key,
  6304. };
  6305. auth_headers.insert("Sudo".to_owned(), val);
  6306. };
  6307. if let Some(ref apikey) = configuration.api_key {
  6308. let key = apikey.key.clone();
  6309. let val = match apikey.prefix {
  6310. Some(ref prefix) => format!("{} {}", prefix, key),
  6311. None => key,
  6312. };
  6313. auth_query.insert("sudo".to_owned(), val);
  6314. };
  6315. if let Some(ref apikey) = configuration.api_key {
  6316. let key = apikey.key.clone();
  6317. let val = match apikey.prefix {
  6318. Some(ref prefix) => format!("{} {}", prefix, key),
  6319. None => key,
  6320. };
  6321. auth_query.insert("token".to_owned(), val);
  6322. };
  6323. let method = hyper::Method::Post;
  6324. let query_string = {
  6325. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  6326. for (key, val) in &auth_query {
  6327. query.append_pair(key, val);
  6328. }
  6329. query.finish()
  6330. };
  6331. let uri_str = format!("{}/repos/{owner}/{repo}/pulls/{index}/merge?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  6332. // TODO(farcaller): handle error
  6333. // if let Err(e) = uri {
  6334. // return Box::new(futures::future::err(e));
  6335. // }
  6336. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  6337. let mut req = hyper::Request::new(method, uri);
  6338. if let Some(ref user_agent) = configuration.user_agent {
  6339. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  6340. }
  6341. for (key, val) in auth_headers {
  6342. req.headers_mut().set_raw(key, val);
  6343. }
  6344. let serialized = serde_json::to_string(&body).unwrap();
  6345. req.headers_mut().set(hyper::header::ContentType::json());
  6346. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  6347. req.set_body(serialized);
  6348. // send request
  6349. Box::new(
  6350. configuration.client.request(req)
  6351. .map_err(|e| Error::from(e))
  6352. .and_then(|resp| {
  6353. let status = resp.status();
  6354. resp.body().concat2()
  6355. .and_then(move |body| Ok((status, body)))
  6356. .map_err(|e| Error::from(e))
  6357. })
  6358. .and_then(|(status, body)| {
  6359. if status.is_success() {
  6360. Ok(body)
  6361. } else {
  6362. Err(Error::from((status, &*body)))
  6363. }
  6364. })
  6365. .and_then(|_| futures::future::ok(()))
  6366. )
  6367. }
  6368. fn repo_migrate(&self, body: ::models::MigrateRepoForm) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>> {
  6369. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  6370. let mut auth_headers = HashMap::<String, String>::new();
  6371. let mut auth_query = HashMap::<String, String>::new();
  6372. if let Some(ref apikey) = configuration.api_key {
  6373. let key = apikey.key.clone();
  6374. let val = match apikey.prefix {
  6375. Some(ref prefix) => format!("{} {}", prefix, key),
  6376. None => key,
  6377. };
  6378. auth_query.insert("access_token".to_owned(), val);
  6379. };
  6380. if let Some(ref apikey) = configuration.api_key {
  6381. let key = apikey.key.clone();
  6382. let val = match apikey.prefix {
  6383. Some(ref prefix) => format!("{} {}", prefix, key),
  6384. None => key,
  6385. };
  6386. auth_headers.insert("Authorization".to_owned(), val);
  6387. };
  6388. if let Some(ref auth_conf) = configuration.basic_auth {
  6389. let auth = hyper::header::Authorization(
  6390. hyper::header::Basic {
  6391. username: auth_conf.0.to_owned(),
  6392. password: auth_conf.1.to_owned(),
  6393. }
  6394. );
  6395. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  6396. };
  6397. if let Some(ref apikey) = configuration.api_key {
  6398. let key = apikey.key.clone();
  6399. let val = match apikey.prefix {
  6400. Some(ref prefix) => format!("{} {}", prefix, key),
  6401. None => key,
  6402. };
  6403. auth_headers.insert("Sudo".to_owned(), val);
  6404. };
  6405. if let Some(ref apikey) = configuration.api_key {
  6406. let key = apikey.key.clone();
  6407. let val = match apikey.prefix {
  6408. Some(ref prefix) => format!("{} {}", prefix, key),
  6409. None => key,
  6410. };
  6411. auth_query.insert("sudo".to_owned(), val);
  6412. };
  6413. if let Some(ref apikey) = configuration.api_key {
  6414. let key = apikey.key.clone();
  6415. let val = match apikey.prefix {
  6416. Some(ref prefix) => format!("{} {}", prefix, key),
  6417. None => key,
  6418. };
  6419. auth_query.insert("token".to_owned(), val);
  6420. };
  6421. let method = hyper::Method::Post;
  6422. let query_string = {
  6423. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  6424. for (key, val) in &auth_query {
  6425. query.append_pair(key, val);
  6426. }
  6427. query.finish()
  6428. };
  6429. let uri_str = format!("{}/repos/migrate?{}", configuration.base_path, query_string);
  6430. // TODO(farcaller): handle error
  6431. // if let Err(e) = uri {
  6432. // return Box::new(futures::future::err(e));
  6433. // }
  6434. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  6435. let mut req = hyper::Request::new(method, uri);
  6436. if let Some(ref user_agent) = configuration.user_agent {
  6437. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  6438. }
  6439. for (key, val) in auth_headers {
  6440. req.headers_mut().set_raw(key, val);
  6441. }
  6442. let serialized = serde_json::to_string(&body).unwrap();
  6443. req.headers_mut().set(hyper::header::ContentType::json());
  6444. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  6445. req.set_body(serialized);
  6446. // send request
  6447. Box::new(
  6448. configuration.client.request(req)
  6449. .map_err(|e| Error::from(e))
  6450. .and_then(|resp| {
  6451. let status = resp.status();
  6452. resp.body().concat2()
  6453. .and_then(move |body| Ok((status, body)))
  6454. .map_err(|e| Error::from(e))
  6455. })
  6456. .and_then(|(status, body)| {
  6457. if status.is_success() {
  6458. Ok(body)
  6459. } else {
  6460. Err(Error::from((status, &*body)))
  6461. }
  6462. })
  6463. .and_then(|body| {
  6464. let parsed: Result<::models::Repository, _> = serde_json::from_slice(&body);
  6465. parsed.map_err(|e| Error::from(e))
  6466. })
  6467. )
  6468. }
  6469. fn repo_mirror_sync(&self, owner: &str, repo: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  6470. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  6471. let mut auth_headers = HashMap::<String, String>::new();
  6472. let mut auth_query = HashMap::<String, String>::new();
  6473. if let Some(ref apikey) = configuration.api_key {
  6474. let key = apikey.key.clone();
  6475. let val = match apikey.prefix {
  6476. Some(ref prefix) => format!("{} {}", prefix, key),
  6477. None => key,
  6478. };
  6479. auth_query.insert("access_token".to_owned(), val);
  6480. };
  6481. if let Some(ref apikey) = configuration.api_key {
  6482. let key = apikey.key.clone();
  6483. let val = match apikey.prefix {
  6484. Some(ref prefix) => format!("{} {}", prefix, key),
  6485. None => key,
  6486. };
  6487. auth_headers.insert("Authorization".to_owned(), val);
  6488. };
  6489. if let Some(ref auth_conf) = configuration.basic_auth {
  6490. let auth = hyper::header::Authorization(
  6491. hyper::header::Basic {
  6492. username: auth_conf.0.to_owned(),
  6493. password: auth_conf.1.to_owned(),
  6494. }
  6495. );
  6496. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  6497. };
  6498. if let Some(ref apikey) = configuration.api_key {
  6499. let key = apikey.key.clone();
  6500. let val = match apikey.prefix {
  6501. Some(ref prefix) => format!("{} {}", prefix, key),
  6502. None => key,
  6503. };
  6504. auth_headers.insert("Sudo".to_owned(), val);
  6505. };
  6506. if let Some(ref apikey) = configuration.api_key {
  6507. let key = apikey.key.clone();
  6508. let val = match apikey.prefix {
  6509. Some(ref prefix) => format!("{} {}", prefix, key),
  6510. None => key,
  6511. };
  6512. auth_query.insert("sudo".to_owned(), val);
  6513. };
  6514. if let Some(ref apikey) = configuration.api_key {
  6515. let key = apikey.key.clone();
  6516. let val = match apikey.prefix {
  6517. Some(ref prefix) => format!("{} {}", prefix, key),
  6518. None => key,
  6519. };
  6520. auth_query.insert("token".to_owned(), val);
  6521. };
  6522. let method = hyper::Method::Post;
  6523. let query_string = {
  6524. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  6525. for (key, val) in &auth_query {
  6526. query.append_pair(key, val);
  6527. }
  6528. query.finish()
  6529. };
  6530. let uri_str = format!("{}/repos/{owner}/{repo}/mirror-sync?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  6531. // TODO(farcaller): handle error
  6532. // if let Err(e) = uri {
  6533. // return Box::new(futures::future::err(e));
  6534. // }
  6535. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  6536. let mut req = hyper::Request::new(method, uri);
  6537. if let Some(ref user_agent) = configuration.user_agent {
  6538. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  6539. }
  6540. for (key, val) in auth_headers {
  6541. req.headers_mut().set_raw(key, val);
  6542. }
  6543. // send request
  6544. Box::new(
  6545. configuration.client.request(req)
  6546. .map_err(|e| Error::from(e))
  6547. .and_then(|resp| {
  6548. let status = resp.status();
  6549. resp.body().concat2()
  6550. .and_then(move |body| Ok((status, body)))
  6551. .map_err(|e| Error::from(e))
  6552. })
  6553. .and_then(|(status, body)| {
  6554. if status.is_success() {
  6555. Ok(body)
  6556. } else {
  6557. Err(Error::from((status, &*body)))
  6558. }
  6559. })
  6560. .and_then(|_| futures::future::ok(()))
  6561. )
  6562. }
  6563. fn repo_pull_request_is_merged(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  6564. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  6565. let mut auth_headers = HashMap::<String, String>::new();
  6566. let mut auth_query = HashMap::<String, String>::new();
  6567. if let Some(ref apikey) = configuration.api_key {
  6568. let key = apikey.key.clone();
  6569. let val = match apikey.prefix {
  6570. Some(ref prefix) => format!("{} {}", prefix, key),
  6571. None => key,
  6572. };
  6573. auth_query.insert("access_token".to_owned(), val);
  6574. };
  6575. if let Some(ref apikey) = configuration.api_key {
  6576. let key = apikey.key.clone();
  6577. let val = match apikey.prefix {
  6578. Some(ref prefix) => format!("{} {}", prefix, key),
  6579. None => key,
  6580. };
  6581. auth_headers.insert("Authorization".to_owned(), val);
  6582. };
  6583. if let Some(ref auth_conf) = configuration.basic_auth {
  6584. let auth = hyper::header::Authorization(
  6585. hyper::header::Basic {
  6586. username: auth_conf.0.to_owned(),
  6587. password: auth_conf.1.to_owned(),
  6588. }
  6589. );
  6590. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  6591. };
  6592. if let Some(ref apikey) = configuration.api_key {
  6593. let key = apikey.key.clone();
  6594. let val = match apikey.prefix {
  6595. Some(ref prefix) => format!("{} {}", prefix, key),
  6596. None => key,
  6597. };
  6598. auth_headers.insert("Sudo".to_owned(), val);
  6599. };
  6600. if let Some(ref apikey) = configuration.api_key {
  6601. let key = apikey.key.clone();
  6602. let val = match apikey.prefix {
  6603. Some(ref prefix) => format!("{} {}", prefix, key),
  6604. None => key,
  6605. };
  6606. auth_query.insert("sudo".to_owned(), val);
  6607. };
  6608. if let Some(ref apikey) = configuration.api_key {
  6609. let key = apikey.key.clone();
  6610. let val = match apikey.prefix {
  6611. Some(ref prefix) => format!("{} {}", prefix, key),
  6612. None => key,
  6613. };
  6614. auth_query.insert("token".to_owned(), val);
  6615. };
  6616. let method = hyper::Method::Get;
  6617. let query_string = {
  6618. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  6619. for (key, val) in &auth_query {
  6620. query.append_pair(key, val);
  6621. }
  6622. query.finish()
  6623. };
  6624. let uri_str = format!("{}/repos/{owner}/{repo}/pulls/{index}/merge?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  6625. // TODO(farcaller): handle error
  6626. // if let Err(e) = uri {
  6627. // return Box::new(futures::future::err(e));
  6628. // }
  6629. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  6630. let mut req = hyper::Request::new(method, uri);
  6631. if let Some(ref user_agent) = configuration.user_agent {
  6632. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  6633. }
  6634. for (key, val) in auth_headers {
  6635. req.headers_mut().set_raw(key, val);
  6636. }
  6637. // send request
  6638. Box::new(
  6639. configuration.client.request(req)
  6640. .map_err(|e| Error::from(e))
  6641. .and_then(|resp| {
  6642. let status = resp.status();
  6643. resp.body().concat2()
  6644. .and_then(move |body| Ok((status, body)))
  6645. .map_err(|e| Error::from(e))
  6646. })
  6647. .and_then(|(status, body)| {
  6648. if status.is_success() {
  6649. Ok(body)
  6650. } else {
  6651. Err(Error::from((status, &*body)))
  6652. }
  6653. })
  6654. .and_then(|_| futures::future::ok(()))
  6655. )
  6656. }
  6657. fn repo_search(&self, q: &str, topic: bool, include_desc: bool, uid: i64, priority_owner_id: i64, starred_by: i64, private: bool, template: bool, page: i32, limit: i32, mode: &str, exclusive: bool, sort: &str, order: &str) -> Box<Future<Item = ::models::SearchResults, Error = Error<serde_json::Value>>> {
  6658. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  6659. let mut auth_headers = HashMap::<String, String>::new();
  6660. let mut auth_query = HashMap::<String, String>::new();
  6661. if let Some(ref apikey) = configuration.api_key {
  6662. let key = apikey.key.clone();
  6663. let val = match apikey.prefix {
  6664. Some(ref prefix) => format!("{} {}", prefix, key),
  6665. None => key,
  6666. };
  6667. auth_query.insert("access_token".to_owned(), val);
  6668. };
  6669. if let Some(ref apikey) = configuration.api_key {
  6670. let key = apikey.key.clone();
  6671. let val = match apikey.prefix {
  6672. Some(ref prefix) => format!("{} {}", prefix, key),
  6673. None => key,
  6674. };
  6675. auth_headers.insert("Authorization".to_owned(), val);
  6676. };
  6677. if let Some(ref auth_conf) = configuration.basic_auth {
  6678. let auth = hyper::header::Authorization(
  6679. hyper::header::Basic {
  6680. username: auth_conf.0.to_owned(),
  6681. password: auth_conf.1.to_owned(),
  6682. }
  6683. );
  6684. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  6685. };
  6686. if let Some(ref apikey) = configuration.api_key {
  6687. let key = apikey.key.clone();
  6688. let val = match apikey.prefix {
  6689. Some(ref prefix) => format!("{} {}", prefix, key),
  6690. None => key,
  6691. };
  6692. auth_headers.insert("Sudo".to_owned(), val);
  6693. };
  6694. if let Some(ref apikey) = configuration.api_key {
  6695. let key = apikey.key.clone();
  6696. let val = match apikey.prefix {
  6697. Some(ref prefix) => format!("{} {}", prefix, key),
  6698. None => key,
  6699. };
  6700. auth_query.insert("sudo".to_owned(), val);
  6701. };
  6702. if let Some(ref apikey) = configuration.api_key {
  6703. let key = apikey.key.clone();
  6704. let val = match apikey.prefix {
  6705. Some(ref prefix) => format!("{} {}", prefix, key),
  6706. None => key,
  6707. };
  6708. auth_query.insert("token".to_owned(), val);
  6709. };
  6710. let method = hyper::Method::Get;
  6711. let query_string = {
  6712. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  6713. query.append_pair("q", &q.to_string());
  6714. query.append_pair("topic", &topic.to_string());
  6715. query.append_pair("includeDesc", &include_desc.to_string());
  6716. query.append_pair("uid", &uid.to_string());
  6717. query.append_pair("priority_owner_id", &priority_owner_id.to_string());
  6718. query.append_pair("starredBy", &starred_by.to_string());
  6719. query.append_pair("private", &private.to_string());
  6720. query.append_pair("template", &template.to_string());
  6721. query.append_pair("page", &page.to_string());
  6722. query.append_pair("limit", &limit.to_string());
  6723. query.append_pair("mode", &mode.to_string());
  6724. query.append_pair("exclusive", &exclusive.to_string());
  6725. query.append_pair("sort", &sort.to_string());
  6726. query.append_pair("order", &order.to_string());
  6727. for (key, val) in &auth_query {
  6728. query.append_pair(key, val);
  6729. }
  6730. query.finish()
  6731. };
  6732. let uri_str = format!("{}/repos/search?{}", configuration.base_path, query_string);
  6733. // TODO(farcaller): handle error
  6734. // if let Err(e) = uri {
  6735. // return Box::new(futures::future::err(e));
  6736. // }
  6737. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  6738. let mut req = hyper::Request::new(method, uri);
  6739. if let Some(ref user_agent) = configuration.user_agent {
  6740. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  6741. }
  6742. for (key, val) in auth_headers {
  6743. req.headers_mut().set_raw(key, val);
  6744. }
  6745. // send request
  6746. Box::new(
  6747. configuration.client.request(req)
  6748. .map_err(|e| Error::from(e))
  6749. .and_then(|resp| {
  6750. let status = resp.status();
  6751. resp.body().concat2()
  6752. .and_then(move |body| Ok((status, body)))
  6753. .map_err(|e| Error::from(e))
  6754. })
  6755. .and_then(|(status, body)| {
  6756. if status.is_success() {
  6757. Ok(body)
  6758. } else {
  6759. Err(Error::from((status, &*body)))
  6760. }
  6761. })
  6762. .and_then(|body| {
  6763. let parsed: Result<::models::SearchResults, _> = serde_json::from_slice(&body);
  6764. parsed.map_err(|e| Error::from(e))
  6765. })
  6766. )
  6767. }
  6768. fn repo_signing_key(&self, owner: &str, repo: &str) -> Box<Future<Item = String, Error = Error<serde_json::Value>>> {
  6769. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  6770. let mut auth_headers = HashMap::<String, String>::new();
  6771. let mut auth_query = HashMap::<String, String>::new();
  6772. if let Some(ref apikey) = configuration.api_key {
  6773. let key = apikey.key.clone();
  6774. let val = match apikey.prefix {
  6775. Some(ref prefix) => format!("{} {}", prefix, key),
  6776. None => key,
  6777. };
  6778. auth_query.insert("access_token".to_owned(), val);
  6779. };
  6780. if let Some(ref apikey) = configuration.api_key {
  6781. let key = apikey.key.clone();
  6782. let val = match apikey.prefix {
  6783. Some(ref prefix) => format!("{} {}", prefix, key),
  6784. None => key,
  6785. };
  6786. auth_headers.insert("Authorization".to_owned(), val);
  6787. };
  6788. if let Some(ref auth_conf) = configuration.basic_auth {
  6789. let auth = hyper::header::Authorization(
  6790. hyper::header::Basic {
  6791. username: auth_conf.0.to_owned(),
  6792. password: auth_conf.1.to_owned(),
  6793. }
  6794. );
  6795. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  6796. };
  6797. if let Some(ref apikey) = configuration.api_key {
  6798. let key = apikey.key.clone();
  6799. let val = match apikey.prefix {
  6800. Some(ref prefix) => format!("{} {}", prefix, key),
  6801. None => key,
  6802. };
  6803. auth_headers.insert("Sudo".to_owned(), val);
  6804. };
  6805. if let Some(ref apikey) = configuration.api_key {
  6806. let key = apikey.key.clone();
  6807. let val = match apikey.prefix {
  6808. Some(ref prefix) => format!("{} {}", prefix, key),
  6809. None => key,
  6810. };
  6811. auth_query.insert("sudo".to_owned(), val);
  6812. };
  6813. if let Some(ref apikey) = configuration.api_key {
  6814. let key = apikey.key.clone();
  6815. let val = match apikey.prefix {
  6816. Some(ref prefix) => format!("{} {}", prefix, key),
  6817. None => key,
  6818. };
  6819. auth_query.insert("token".to_owned(), val);
  6820. };
  6821. let method = hyper::Method::Get;
  6822. let query_string = {
  6823. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  6824. for (key, val) in &auth_query {
  6825. query.append_pair(key, val);
  6826. }
  6827. query.finish()
  6828. };
  6829. let uri_str = format!("{}/repos/{owner}/{repo}/signing-key.gpg?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  6830. // TODO(farcaller): handle error
  6831. // if let Err(e) = uri {
  6832. // return Box::new(futures::future::err(e));
  6833. // }
  6834. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  6835. let mut req = hyper::Request::new(method, uri);
  6836. if let Some(ref user_agent) = configuration.user_agent {
  6837. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  6838. }
  6839. for (key, val) in auth_headers {
  6840. req.headers_mut().set_raw(key, val);
  6841. }
  6842. // send request
  6843. Box::new(
  6844. configuration.client.request(req)
  6845. .map_err(|e| Error::from(e))
  6846. .and_then(|resp| {
  6847. let status = resp.status();
  6848. resp.body().concat2()
  6849. .and_then(move |body| Ok((status, body)))
  6850. .map_err(|e| Error::from(e))
  6851. })
  6852. .and_then(|(status, body)| {
  6853. if status.is_success() {
  6854. Ok(body)
  6855. } else {
  6856. Err(Error::from((status, &*body)))
  6857. }
  6858. })
  6859. .and_then(|body| {
  6860. let parsed: Result<String, _> = serde_json::from_slice(&body);
  6861. parsed.map_err(|e| Error::from(e))
  6862. })
  6863. )
  6864. }
  6865. fn repo_test_hook(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  6866. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  6867. let mut auth_headers = HashMap::<String, String>::new();
  6868. let mut auth_query = HashMap::<String, String>::new();
  6869. if let Some(ref apikey) = configuration.api_key {
  6870. let key = apikey.key.clone();
  6871. let val = match apikey.prefix {
  6872. Some(ref prefix) => format!("{} {}", prefix, key),
  6873. None => key,
  6874. };
  6875. auth_query.insert("access_token".to_owned(), val);
  6876. };
  6877. if let Some(ref apikey) = configuration.api_key {
  6878. let key = apikey.key.clone();
  6879. let val = match apikey.prefix {
  6880. Some(ref prefix) => format!("{} {}", prefix, key),
  6881. None => key,
  6882. };
  6883. auth_headers.insert("Authorization".to_owned(), val);
  6884. };
  6885. if let Some(ref auth_conf) = configuration.basic_auth {
  6886. let auth = hyper::header::Authorization(
  6887. hyper::header::Basic {
  6888. username: auth_conf.0.to_owned(),
  6889. password: auth_conf.1.to_owned(),
  6890. }
  6891. );
  6892. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  6893. };
  6894. if let Some(ref apikey) = configuration.api_key {
  6895. let key = apikey.key.clone();
  6896. let val = match apikey.prefix {
  6897. Some(ref prefix) => format!("{} {}", prefix, key),
  6898. None => key,
  6899. };
  6900. auth_headers.insert("Sudo".to_owned(), val);
  6901. };
  6902. if let Some(ref apikey) = configuration.api_key {
  6903. let key = apikey.key.clone();
  6904. let val = match apikey.prefix {
  6905. Some(ref prefix) => format!("{} {}", prefix, key),
  6906. None => key,
  6907. };
  6908. auth_query.insert("sudo".to_owned(), val);
  6909. };
  6910. if let Some(ref apikey) = configuration.api_key {
  6911. let key = apikey.key.clone();
  6912. let val = match apikey.prefix {
  6913. Some(ref prefix) => format!("{} {}", prefix, key),
  6914. None => key,
  6915. };
  6916. auth_query.insert("token".to_owned(), val);
  6917. };
  6918. let method = hyper::Method::Post;
  6919. let query_string = {
  6920. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  6921. for (key, val) in &auth_query {
  6922. query.append_pair(key, val);
  6923. }
  6924. query.finish()
  6925. };
  6926. let uri_str = format!("{}/repos/{owner}/{repo}/hooks/{id}/tests?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  6927. // TODO(farcaller): handle error
  6928. // if let Err(e) = uri {
  6929. // return Box::new(futures::future::err(e));
  6930. // }
  6931. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  6932. let mut req = hyper::Request::new(method, uri);
  6933. if let Some(ref user_agent) = configuration.user_agent {
  6934. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  6935. }
  6936. for (key, val) in auth_headers {
  6937. req.headers_mut().set_raw(key, val);
  6938. }
  6939. // send request
  6940. Box::new(
  6941. configuration.client.request(req)
  6942. .map_err(|e| Error::from(e))
  6943. .and_then(|resp| {
  6944. let status = resp.status();
  6945. resp.body().concat2()
  6946. .and_then(move |body| Ok((status, body)))
  6947. .map_err(|e| Error::from(e))
  6948. })
  6949. .and_then(|(status, body)| {
  6950. if status.is_success() {
  6951. Ok(body)
  6952. } else {
  6953. Err(Error::from((status, &*body)))
  6954. }
  6955. })
  6956. .and_then(|_| futures::future::ok(()))
  6957. )
  6958. }
  6959. fn repo_tracked_times(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::TrackedTime>, Error = Error<serde_json::Value>>> {
  6960. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  6961. let mut auth_headers = HashMap::<String, String>::new();
  6962. let mut auth_query = HashMap::<String, String>::new();
  6963. if let Some(ref apikey) = configuration.api_key {
  6964. let key = apikey.key.clone();
  6965. let val = match apikey.prefix {
  6966. Some(ref prefix) => format!("{} {}", prefix, key),
  6967. None => key,
  6968. };
  6969. auth_query.insert("access_token".to_owned(), val);
  6970. };
  6971. if let Some(ref apikey) = configuration.api_key {
  6972. let key = apikey.key.clone();
  6973. let val = match apikey.prefix {
  6974. Some(ref prefix) => format!("{} {}", prefix, key),
  6975. None => key,
  6976. };
  6977. auth_headers.insert("Authorization".to_owned(), val);
  6978. };
  6979. if let Some(ref auth_conf) = configuration.basic_auth {
  6980. let auth = hyper::header::Authorization(
  6981. hyper::header::Basic {
  6982. username: auth_conf.0.to_owned(),
  6983. password: auth_conf.1.to_owned(),
  6984. }
  6985. );
  6986. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  6987. };
  6988. if let Some(ref apikey) = configuration.api_key {
  6989. let key = apikey.key.clone();
  6990. let val = match apikey.prefix {
  6991. Some(ref prefix) => format!("{} {}", prefix, key),
  6992. None => key,
  6993. };
  6994. auth_headers.insert("Sudo".to_owned(), val);
  6995. };
  6996. if let Some(ref apikey) = configuration.api_key {
  6997. let key = apikey.key.clone();
  6998. let val = match apikey.prefix {
  6999. Some(ref prefix) => format!("{} {}", prefix, key),
  7000. None => key,
  7001. };
  7002. auth_query.insert("sudo".to_owned(), val);
  7003. };
  7004. if let Some(ref apikey) = configuration.api_key {
  7005. let key = apikey.key.clone();
  7006. let val = match apikey.prefix {
  7007. Some(ref prefix) => format!("{} {}", prefix, key),
  7008. None => key,
  7009. };
  7010. auth_query.insert("token".to_owned(), val);
  7011. };
  7012. let method = hyper::Method::Get;
  7013. let query_string = {
  7014. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  7015. for (key, val) in &auth_query {
  7016. query.append_pair(key, val);
  7017. }
  7018. query.finish()
  7019. };
  7020. let uri_str = format!("{}/repos/{owner}/{repo}/times?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  7021. // TODO(farcaller): handle error
  7022. // if let Err(e) = uri {
  7023. // return Box::new(futures::future::err(e));
  7024. // }
  7025. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  7026. let mut req = hyper::Request::new(method, uri);
  7027. if let Some(ref user_agent) = configuration.user_agent {
  7028. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  7029. }
  7030. for (key, val) in auth_headers {
  7031. req.headers_mut().set_raw(key, val);
  7032. }
  7033. // send request
  7034. Box::new(
  7035. configuration.client.request(req)
  7036. .map_err(|e| Error::from(e))
  7037. .and_then(|resp| {
  7038. let status = resp.status();
  7039. resp.body().concat2()
  7040. .and_then(move |body| Ok((status, body)))
  7041. .map_err(|e| Error::from(e))
  7042. })
  7043. .and_then(|(status, body)| {
  7044. if status.is_success() {
  7045. Ok(body)
  7046. } else {
  7047. Err(Error::from((status, &*body)))
  7048. }
  7049. })
  7050. .and_then(|body| {
  7051. let parsed: Result<Vec<::models::TrackedTime>, _> = serde_json::from_slice(&body);
  7052. parsed.map_err(|e| Error::from(e))
  7053. })
  7054. )
  7055. }
  7056. fn repo_update_file(&self, owner: &str, repo: &str, filepath: &str, body: ::models::UpdateFileOptions) -> Box<Future<Item = ::models::FileResponse, Error = Error<serde_json::Value>>> {
  7057. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  7058. let mut auth_headers = HashMap::<String, String>::new();
  7059. let mut auth_query = HashMap::<String, String>::new();
  7060. if let Some(ref apikey) = configuration.api_key {
  7061. let key = apikey.key.clone();
  7062. let val = match apikey.prefix {
  7063. Some(ref prefix) => format!("{} {}", prefix, key),
  7064. None => key,
  7065. };
  7066. auth_query.insert("access_token".to_owned(), val);
  7067. };
  7068. if let Some(ref apikey) = configuration.api_key {
  7069. let key = apikey.key.clone();
  7070. let val = match apikey.prefix {
  7071. Some(ref prefix) => format!("{} {}", prefix, key),
  7072. None => key,
  7073. };
  7074. auth_headers.insert("Authorization".to_owned(), val);
  7075. };
  7076. if let Some(ref auth_conf) = configuration.basic_auth {
  7077. let auth = hyper::header::Authorization(
  7078. hyper::header::Basic {
  7079. username: auth_conf.0.to_owned(),
  7080. password: auth_conf.1.to_owned(),
  7081. }
  7082. );
  7083. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  7084. };
  7085. if let Some(ref apikey) = configuration.api_key {
  7086. let key = apikey.key.clone();
  7087. let val = match apikey.prefix {
  7088. Some(ref prefix) => format!("{} {}", prefix, key),
  7089. None => key,
  7090. };
  7091. auth_headers.insert("Sudo".to_owned(), val);
  7092. };
  7093. if let Some(ref apikey) = configuration.api_key {
  7094. let key = apikey.key.clone();
  7095. let val = match apikey.prefix {
  7096. Some(ref prefix) => format!("{} {}", prefix, key),
  7097. None => key,
  7098. };
  7099. auth_query.insert("sudo".to_owned(), val);
  7100. };
  7101. if let Some(ref apikey) = configuration.api_key {
  7102. let key = apikey.key.clone();
  7103. let val = match apikey.prefix {
  7104. Some(ref prefix) => format!("{} {}", prefix, key),
  7105. None => key,
  7106. };
  7107. auth_query.insert("token".to_owned(), val);
  7108. };
  7109. let method = hyper::Method::Put;
  7110. let query_string = {
  7111. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  7112. for (key, val) in &auth_query {
  7113. query.append_pair(key, val);
  7114. }
  7115. query.finish()
  7116. };
  7117. let uri_str = format!("{}/repos/{owner}/{repo}/contents/{filepath}?{}", configuration.base_path, query_string, owner=owner, repo=repo, filepath=filepath);
  7118. // TODO(farcaller): handle error
  7119. // if let Err(e) = uri {
  7120. // return Box::new(futures::future::err(e));
  7121. // }
  7122. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  7123. let mut req = hyper::Request::new(method, uri);
  7124. if let Some(ref user_agent) = configuration.user_agent {
  7125. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  7126. }
  7127. for (key, val) in auth_headers {
  7128. req.headers_mut().set_raw(key, val);
  7129. }
  7130. let serialized = serde_json::to_string(&body).unwrap();
  7131. req.headers_mut().set(hyper::header::ContentType::json());
  7132. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  7133. req.set_body(serialized);
  7134. // send request
  7135. Box::new(
  7136. configuration.client.request(req)
  7137. .map_err(|e| Error::from(e))
  7138. .and_then(|resp| {
  7139. let status = resp.status();
  7140. resp.body().concat2()
  7141. .and_then(move |body| Ok((status, body)))
  7142. .map_err(|e| Error::from(e))
  7143. })
  7144. .and_then(|(status, body)| {
  7145. if status.is_success() {
  7146. Ok(body)
  7147. } else {
  7148. Err(Error::from((status, &*body)))
  7149. }
  7150. })
  7151. .and_then(|body| {
  7152. let parsed: Result<::models::FileResponse, _> = serde_json::from_slice(&body);
  7153. parsed.map_err(|e| Error::from(e))
  7154. })
  7155. )
  7156. }
  7157. fn repo_update_topics(&self, owner: &str, repo: &str, body: ::models::RepoTopicOptions) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  7158. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  7159. let mut auth_headers = HashMap::<String, String>::new();
  7160. let mut auth_query = HashMap::<String, String>::new();
  7161. if let Some(ref apikey) = configuration.api_key {
  7162. let key = apikey.key.clone();
  7163. let val = match apikey.prefix {
  7164. Some(ref prefix) => format!("{} {}", prefix, key),
  7165. None => key,
  7166. };
  7167. auth_query.insert("access_token".to_owned(), val);
  7168. };
  7169. if let Some(ref apikey) = configuration.api_key {
  7170. let key = apikey.key.clone();
  7171. let val = match apikey.prefix {
  7172. Some(ref prefix) => format!("{} {}", prefix, key),
  7173. None => key,
  7174. };
  7175. auth_headers.insert("Authorization".to_owned(), val);
  7176. };
  7177. if let Some(ref auth_conf) = configuration.basic_auth {
  7178. let auth = hyper::header::Authorization(
  7179. hyper::header::Basic {
  7180. username: auth_conf.0.to_owned(),
  7181. password: auth_conf.1.to_owned(),
  7182. }
  7183. );
  7184. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  7185. };
  7186. if let Some(ref apikey) = configuration.api_key {
  7187. let key = apikey.key.clone();
  7188. let val = match apikey.prefix {
  7189. Some(ref prefix) => format!("{} {}", prefix, key),
  7190. None => key,
  7191. };
  7192. auth_headers.insert("Sudo".to_owned(), val);
  7193. };
  7194. if let Some(ref apikey) = configuration.api_key {
  7195. let key = apikey.key.clone();
  7196. let val = match apikey.prefix {
  7197. Some(ref prefix) => format!("{} {}", prefix, key),
  7198. None => key,
  7199. };
  7200. auth_query.insert("sudo".to_owned(), val);
  7201. };
  7202. if let Some(ref apikey) = configuration.api_key {
  7203. let key = apikey.key.clone();
  7204. let val = match apikey.prefix {
  7205. Some(ref prefix) => format!("{} {}", prefix, key),
  7206. None => key,
  7207. };
  7208. auth_query.insert("token".to_owned(), val);
  7209. };
  7210. let method = hyper::Method::Put;
  7211. let query_string = {
  7212. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  7213. for (key, val) in &auth_query {
  7214. query.append_pair(key, val);
  7215. }
  7216. query.finish()
  7217. };
  7218. let uri_str = format!("{}/repos/{owner}/{repo}/topics?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  7219. // TODO(farcaller): handle error
  7220. // if let Err(e) = uri {
  7221. // return Box::new(futures::future::err(e));
  7222. // }
  7223. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  7224. let mut req = hyper::Request::new(method, uri);
  7225. if let Some(ref user_agent) = configuration.user_agent {
  7226. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  7227. }
  7228. for (key, val) in auth_headers {
  7229. req.headers_mut().set_raw(key, val);
  7230. }
  7231. let serialized = serde_json::to_string(&body).unwrap();
  7232. req.headers_mut().set(hyper::header::ContentType::json());
  7233. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  7234. req.set_body(serialized);
  7235. // send request
  7236. Box::new(
  7237. configuration.client.request(req)
  7238. .map_err(|e| Error::from(e))
  7239. .and_then(|resp| {
  7240. let status = resp.status();
  7241. resp.body().concat2()
  7242. .and_then(move |body| Ok((status, body)))
  7243. .map_err(|e| Error::from(e))
  7244. })
  7245. .and_then(|(status, body)| {
  7246. if status.is_success() {
  7247. Ok(body)
  7248. } else {
  7249. Err(Error::from((status, &*body)))
  7250. }
  7251. })
  7252. .and_then(|_| futures::future::ok(()))
  7253. )
  7254. }
  7255. fn topic_search(&self, q: &str) -> Box<Future<Item = Vec<::models::TopicResponse>, Error = Error<serde_json::Value>>> {
  7256. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  7257. let mut auth_headers = HashMap::<String, String>::new();
  7258. let mut auth_query = HashMap::<String, String>::new();
  7259. if let Some(ref apikey) = configuration.api_key {
  7260. let key = apikey.key.clone();
  7261. let val = match apikey.prefix {
  7262. Some(ref prefix) => format!("{} {}", prefix, key),
  7263. None => key,
  7264. };
  7265. auth_query.insert("access_token".to_owned(), val);
  7266. };
  7267. if let Some(ref apikey) = configuration.api_key {
  7268. let key = apikey.key.clone();
  7269. let val = match apikey.prefix {
  7270. Some(ref prefix) => format!("{} {}", prefix, key),
  7271. None => key,
  7272. };
  7273. auth_headers.insert("Authorization".to_owned(), val);
  7274. };
  7275. if let Some(ref auth_conf) = configuration.basic_auth {
  7276. let auth = hyper::header::Authorization(
  7277. hyper::header::Basic {
  7278. username: auth_conf.0.to_owned(),
  7279. password: auth_conf.1.to_owned(),
  7280. }
  7281. );
  7282. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  7283. };
  7284. if let Some(ref apikey) = configuration.api_key {
  7285. let key = apikey.key.clone();
  7286. let val = match apikey.prefix {
  7287. Some(ref prefix) => format!("{} {}", prefix, key),
  7288. None => key,
  7289. };
  7290. auth_headers.insert("Sudo".to_owned(), val);
  7291. };
  7292. if let Some(ref apikey) = configuration.api_key {
  7293. let key = apikey.key.clone();
  7294. let val = match apikey.prefix {
  7295. Some(ref prefix) => format!("{} {}", prefix, key),
  7296. None => key,
  7297. };
  7298. auth_query.insert("sudo".to_owned(), val);
  7299. };
  7300. if let Some(ref apikey) = configuration.api_key {
  7301. let key = apikey.key.clone();
  7302. let val = match apikey.prefix {
  7303. Some(ref prefix) => format!("{} {}", prefix, key),
  7304. None => key,
  7305. };
  7306. auth_query.insert("token".to_owned(), val);
  7307. };
  7308. let method = hyper::Method::Get;
  7309. let query_string = {
  7310. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  7311. query.append_pair("q", &q.to_string());
  7312. for (key, val) in &auth_query {
  7313. query.append_pair(key, val);
  7314. }
  7315. query.finish()
  7316. };
  7317. let uri_str = format!("{}/topics/search?{}", configuration.base_path, query_string);
  7318. // TODO(farcaller): handle error
  7319. // if let Err(e) = uri {
  7320. // return Box::new(futures::future::err(e));
  7321. // }
  7322. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  7323. let mut req = hyper::Request::new(method, uri);
  7324. if let Some(ref user_agent) = configuration.user_agent {
  7325. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  7326. }
  7327. for (key, val) in auth_headers {
  7328. req.headers_mut().set_raw(key, val);
  7329. }
  7330. // send request
  7331. Box::new(
  7332. configuration.client.request(req)
  7333. .map_err(|e| Error::from(e))
  7334. .and_then(|resp| {
  7335. let status = resp.status();
  7336. resp.body().concat2()
  7337. .and_then(move |body| Ok((status, body)))
  7338. .map_err(|e| Error::from(e))
  7339. })
  7340. .and_then(|(status, body)| {
  7341. if status.is_success() {
  7342. Ok(body)
  7343. } else {
  7344. Err(Error::from((status, &*body)))
  7345. }
  7346. })
  7347. .and_then(|body| {
  7348. let parsed: Result<Vec<::models::TopicResponse>, _> = serde_json::from_slice(&body);
  7349. parsed.map_err(|e| Error::from(e))
  7350. })
  7351. )
  7352. }
  7353. fn user_current_check_subscription(&self, owner: &str, repo: &str) -> Box<Future<Item = ::models::WatchInfo, Error = Error<serde_json::Value>>> {
  7354. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  7355. let mut auth_headers = HashMap::<String, String>::new();
  7356. let mut auth_query = HashMap::<String, String>::new();
  7357. if let Some(ref apikey) = configuration.api_key {
  7358. let key = apikey.key.clone();
  7359. let val = match apikey.prefix {
  7360. Some(ref prefix) => format!("{} {}", prefix, key),
  7361. None => key,
  7362. };
  7363. auth_query.insert("access_token".to_owned(), val);
  7364. };
  7365. if let Some(ref apikey) = configuration.api_key {
  7366. let key = apikey.key.clone();
  7367. let val = match apikey.prefix {
  7368. Some(ref prefix) => format!("{} {}", prefix, key),
  7369. None => key,
  7370. };
  7371. auth_headers.insert("Authorization".to_owned(), val);
  7372. };
  7373. if let Some(ref auth_conf) = configuration.basic_auth {
  7374. let auth = hyper::header::Authorization(
  7375. hyper::header::Basic {
  7376. username: auth_conf.0.to_owned(),
  7377. password: auth_conf.1.to_owned(),
  7378. }
  7379. );
  7380. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  7381. };
  7382. if let Some(ref apikey) = configuration.api_key {
  7383. let key = apikey.key.clone();
  7384. let val = match apikey.prefix {
  7385. Some(ref prefix) => format!("{} {}", prefix, key),
  7386. None => key,
  7387. };
  7388. auth_headers.insert("Sudo".to_owned(), val);
  7389. };
  7390. if let Some(ref apikey) = configuration.api_key {
  7391. let key = apikey.key.clone();
  7392. let val = match apikey.prefix {
  7393. Some(ref prefix) => format!("{} {}", prefix, key),
  7394. None => key,
  7395. };
  7396. auth_query.insert("sudo".to_owned(), val);
  7397. };
  7398. if let Some(ref apikey) = configuration.api_key {
  7399. let key = apikey.key.clone();
  7400. let val = match apikey.prefix {
  7401. Some(ref prefix) => format!("{} {}", prefix, key),
  7402. None => key,
  7403. };
  7404. auth_query.insert("token".to_owned(), val);
  7405. };
  7406. let method = hyper::Method::Get;
  7407. let query_string = {
  7408. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  7409. for (key, val) in &auth_query {
  7410. query.append_pair(key, val);
  7411. }
  7412. query.finish()
  7413. };
  7414. let uri_str = format!("{}/repos/{owner}/{repo}/subscription?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  7415. // TODO(farcaller): handle error
  7416. // if let Err(e) = uri {
  7417. // return Box::new(futures::future::err(e));
  7418. // }
  7419. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  7420. let mut req = hyper::Request::new(method, uri);
  7421. if let Some(ref user_agent) = configuration.user_agent {
  7422. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  7423. }
  7424. for (key, val) in auth_headers {
  7425. req.headers_mut().set_raw(key, val);
  7426. }
  7427. // send request
  7428. Box::new(
  7429. configuration.client.request(req)
  7430. .map_err(|e| Error::from(e))
  7431. .and_then(|resp| {
  7432. let status = resp.status();
  7433. resp.body().concat2()
  7434. .and_then(move |body| Ok((status, body)))
  7435. .map_err(|e| Error::from(e))
  7436. })
  7437. .and_then(|(status, body)| {
  7438. if status.is_success() {
  7439. Ok(body)
  7440. } else {
  7441. Err(Error::from((status, &*body)))
  7442. }
  7443. })
  7444. .and_then(|body| {
  7445. let parsed: Result<::models::WatchInfo, _> = serde_json::from_slice(&body);
  7446. parsed.map_err(|e| Error::from(e))
  7447. })
  7448. )
  7449. }
  7450. fn user_current_delete_subscription(&self, owner: &str, repo: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  7451. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  7452. let mut auth_headers = HashMap::<String, String>::new();
  7453. let mut auth_query = HashMap::<String, String>::new();
  7454. if let Some(ref apikey) = configuration.api_key {
  7455. let key = apikey.key.clone();
  7456. let val = match apikey.prefix {
  7457. Some(ref prefix) => format!("{} {}", prefix, key),
  7458. None => key,
  7459. };
  7460. auth_query.insert("access_token".to_owned(), val);
  7461. };
  7462. if let Some(ref apikey) = configuration.api_key {
  7463. let key = apikey.key.clone();
  7464. let val = match apikey.prefix {
  7465. Some(ref prefix) => format!("{} {}", prefix, key),
  7466. None => key,
  7467. };
  7468. auth_headers.insert("Authorization".to_owned(), val);
  7469. };
  7470. if let Some(ref auth_conf) = configuration.basic_auth {
  7471. let auth = hyper::header::Authorization(
  7472. hyper::header::Basic {
  7473. username: auth_conf.0.to_owned(),
  7474. password: auth_conf.1.to_owned(),
  7475. }
  7476. );
  7477. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  7478. };
  7479. if let Some(ref apikey) = configuration.api_key {
  7480. let key = apikey.key.clone();
  7481. let val = match apikey.prefix {
  7482. Some(ref prefix) => format!("{} {}", prefix, key),
  7483. None => key,
  7484. };
  7485. auth_headers.insert("Sudo".to_owned(), val);
  7486. };
  7487. if let Some(ref apikey) = configuration.api_key {
  7488. let key = apikey.key.clone();
  7489. let val = match apikey.prefix {
  7490. Some(ref prefix) => format!("{} {}", prefix, key),
  7491. None => key,
  7492. };
  7493. auth_query.insert("sudo".to_owned(), val);
  7494. };
  7495. if let Some(ref apikey) = configuration.api_key {
  7496. let key = apikey.key.clone();
  7497. let val = match apikey.prefix {
  7498. Some(ref prefix) => format!("{} {}", prefix, key),
  7499. None => key,
  7500. };
  7501. auth_query.insert("token".to_owned(), val);
  7502. };
  7503. let method = hyper::Method::Delete;
  7504. let query_string = {
  7505. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  7506. for (key, val) in &auth_query {
  7507. query.append_pair(key, val);
  7508. }
  7509. query.finish()
  7510. };
  7511. let uri_str = format!("{}/repos/{owner}/{repo}/subscription?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  7512. // TODO(farcaller): handle error
  7513. // if let Err(e) = uri {
  7514. // return Box::new(futures::future::err(e));
  7515. // }
  7516. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  7517. let mut req = hyper::Request::new(method, uri);
  7518. if let Some(ref user_agent) = configuration.user_agent {
  7519. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  7520. }
  7521. for (key, val) in auth_headers {
  7522. req.headers_mut().set_raw(key, val);
  7523. }
  7524. // send request
  7525. Box::new(
  7526. configuration.client.request(req)
  7527. .map_err(|e| Error::from(e))
  7528. .and_then(|resp| {
  7529. let status = resp.status();
  7530. resp.body().concat2()
  7531. .and_then(move |body| Ok((status, body)))
  7532. .map_err(|e| Error::from(e))
  7533. })
  7534. .and_then(|(status, body)| {
  7535. if status.is_success() {
  7536. Ok(body)
  7537. } else {
  7538. Err(Error::from((status, &*body)))
  7539. }
  7540. })
  7541. .and_then(|_| futures::future::ok(()))
  7542. )
  7543. }
  7544. fn user_current_put_subscription(&self, owner: &str, repo: &str) -> Box<Future<Item = ::models::WatchInfo, Error = Error<serde_json::Value>>> {
  7545. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  7546. let mut auth_headers = HashMap::<String, String>::new();
  7547. let mut auth_query = HashMap::<String, String>::new();
  7548. if let Some(ref apikey) = configuration.api_key {
  7549. let key = apikey.key.clone();
  7550. let val = match apikey.prefix {
  7551. Some(ref prefix) => format!("{} {}", prefix, key),
  7552. None => key,
  7553. };
  7554. auth_query.insert("access_token".to_owned(), val);
  7555. };
  7556. if let Some(ref apikey) = configuration.api_key {
  7557. let key = apikey.key.clone();
  7558. let val = match apikey.prefix {
  7559. Some(ref prefix) => format!("{} {}", prefix, key),
  7560. None => key,
  7561. };
  7562. auth_headers.insert("Authorization".to_owned(), val);
  7563. };
  7564. if let Some(ref auth_conf) = configuration.basic_auth {
  7565. let auth = hyper::header::Authorization(
  7566. hyper::header::Basic {
  7567. username: auth_conf.0.to_owned(),
  7568. password: auth_conf.1.to_owned(),
  7569. }
  7570. );
  7571. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  7572. };
  7573. if let Some(ref apikey) = configuration.api_key {
  7574. let key = apikey.key.clone();
  7575. let val = match apikey.prefix {
  7576. Some(ref prefix) => format!("{} {}", prefix, key),
  7577. None => key,
  7578. };
  7579. auth_headers.insert("Sudo".to_owned(), val);
  7580. };
  7581. if let Some(ref apikey) = configuration.api_key {
  7582. let key = apikey.key.clone();
  7583. let val = match apikey.prefix {
  7584. Some(ref prefix) => format!("{} {}", prefix, key),
  7585. None => key,
  7586. };
  7587. auth_query.insert("sudo".to_owned(), val);
  7588. };
  7589. if let Some(ref apikey) = configuration.api_key {
  7590. let key = apikey.key.clone();
  7591. let val = match apikey.prefix {
  7592. Some(ref prefix) => format!("{} {}", prefix, key),
  7593. None => key,
  7594. };
  7595. auth_query.insert("token".to_owned(), val);
  7596. };
  7597. let method = hyper::Method::Put;
  7598. let query_string = {
  7599. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  7600. for (key, val) in &auth_query {
  7601. query.append_pair(key, val);
  7602. }
  7603. query.finish()
  7604. };
  7605. let uri_str = format!("{}/repos/{owner}/{repo}/subscription?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  7606. // TODO(farcaller): handle error
  7607. // if let Err(e) = uri {
  7608. // return Box::new(futures::future::err(e));
  7609. // }
  7610. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  7611. let mut req = hyper::Request::new(method, uri);
  7612. if let Some(ref user_agent) = configuration.user_agent {
  7613. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  7614. }
  7615. for (key, val) in auth_headers {
  7616. req.headers_mut().set_raw(key, val);
  7617. }
  7618. // send request
  7619. Box::new(
  7620. configuration.client.request(req)
  7621. .map_err(|e| Error::from(e))
  7622. .and_then(|resp| {
  7623. let status = resp.status();
  7624. resp.body().concat2()
  7625. .and_then(move |body| Ok((status, body)))
  7626. .map_err(|e| Error::from(e))
  7627. })
  7628. .and_then(|(status, body)| {
  7629. if status.is_success() {
  7630. Ok(body)
  7631. } else {
  7632. Err(Error::from((status, &*body)))
  7633. }
  7634. })
  7635. .and_then(|body| {
  7636. let parsed: Result<::models::WatchInfo, _> = serde_json::from_slice(&body);
  7637. parsed.map_err(|e| Error::from(e))
  7638. })
  7639. )
  7640. }
  7641. }