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.

4832 lines
190KB

  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 IssueApiClient<C: hyper::client::Connect> {
  21. configuration: Rc<configuration::Configuration<C>>,
  22. }
  23. impl<C: hyper::client::Connect> IssueApiClient<C> {
  24. pub fn new(configuration: Rc<configuration::Configuration<C>>) -> IssueApiClient<C> {
  25. IssueApiClient {
  26. configuration: configuration,
  27. }
  28. }
  29. }
  30. pub trait IssueApi {
  31. fn issue_add_label(&self, owner: &str, repo: &str, index: i64, body: ::models::IssueLabelsOption) -> Box<Future<Item = Vec<::models::Label>, Error = Error<serde_json::Value>>>;
  32. fn issue_add_subscription(&self, owner: &str, repo: &str, index: i64, user: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  33. fn issue_add_time(&self, owner: &str, repo: &str, index: i64, body: ::models::AddTimeOption) -> Box<Future<Item = ::models::TrackedTime, Error = Error<serde_json::Value>>>;
  34. fn issue_clear_labels(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  35. fn issue_create_comment(&self, owner: &str, repo: &str, index: i64, body: ::models::CreateIssueCommentOption) -> Box<Future<Item = ::models::Comment, Error = Error<serde_json::Value>>>;
  36. fn issue_create_issue(&self, owner: &str, repo: &str, body: ::models::CreateIssueOption) -> Box<Future<Item = ::models::Issue, Error = Error<serde_json::Value>>>;
  37. fn issue_create_label(&self, owner: &str, repo: &str, body: ::models::CreateLabelOption) -> Box<Future<Item = ::models::Label, Error = Error<serde_json::Value>>>;
  38. fn issue_create_milestone(&self, owner: &str, repo: &str, body: ::models::CreateMilestoneOption) -> Box<Future<Item = ::models::Milestone, Error = Error<serde_json::Value>>>;
  39. fn issue_delete_comment(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  40. fn issue_delete_comment_deprecated(&self, owner: &str, repo: &str, index: i32, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  41. fn issue_delete_comment_reaction(&self, owner: &str, repo: &str, id: i64, content: ::models::EditReactionOption) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  42. fn issue_delete_issue_reaction(&self, owner: &str, repo: &str, index: i64, content: ::models::EditReactionOption) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  43. fn issue_delete_label(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  44. fn issue_delete_milestone(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  45. fn issue_delete_stop_watch(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  46. fn issue_delete_subscription(&self, owner: &str, repo: &str, index: i64, user: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  47. fn issue_delete_time(&self, owner: &str, repo: &str, index: i64, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  48. fn issue_edit_comment(&self, owner: &str, repo: &str, id: i64, body: ::models::EditIssueCommentOption) -> Box<Future<Item = ::models::Comment, Error = Error<serde_json::Value>>>;
  49. fn issue_edit_comment_deprecated(&self, owner: &str, repo: &str, index: i32, id: i64, body: ::models::EditIssueCommentOption) -> Box<Future<Item = ::models::Comment, Error = Error<serde_json::Value>>>;
  50. fn issue_edit_issue(&self, owner: &str, repo: &str, index: i64, body: ::models::EditIssueOption) -> Box<Future<Item = ::models::Issue, Error = Error<serde_json::Value>>>;
  51. fn issue_edit_issue_deadline(&self, owner: &str, repo: &str, index: i64, body: ::models::EditDeadlineOption) -> Box<Future<Item = ::models::IssueDeadline, Error = Error<serde_json::Value>>>;
  52. fn issue_edit_label(&self, owner: &str, repo: &str, id: i64, body: ::models::EditLabelOption) -> Box<Future<Item = ::models::Label, Error = Error<serde_json::Value>>>;
  53. fn issue_edit_milestone(&self, owner: &str, repo: &str, id: i64, body: ::models::EditMilestoneOption) -> Box<Future<Item = ::models::Milestone, Error = Error<serde_json::Value>>>;
  54. fn issue_get_comment_reactions(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = Vec<::models::Reaction>, Error = Error<serde_json::Value>>>;
  55. fn issue_get_comments(&self, owner: &str, repo: &str, index: i64, since: &str) -> Box<Future<Item = Vec<::models::Comment>, Error = Error<serde_json::Value>>>;
  56. fn issue_get_issue(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = ::models::Issue, Error = Error<serde_json::Value>>>;
  57. fn issue_get_issue_reactions(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = Vec<::models::Reaction>, Error = Error<serde_json::Value>>>;
  58. fn issue_get_label(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = ::models::Label, Error = Error<serde_json::Value>>>;
  59. fn issue_get_labels(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = Vec<::models::Label>, Error = Error<serde_json::Value>>>;
  60. fn issue_get_milestone(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = ::models::Milestone, Error = Error<serde_json::Value>>>;
  61. fn issue_get_milestones_list(&self, owner: &str, repo: &str, state: &str) -> Box<Future<Item = Vec<::models::Milestone>, Error = Error<serde_json::Value>>>;
  62. fn issue_get_repo_comments(&self, owner: &str, repo: &str, since: &str) -> Box<Future<Item = Vec<::models::Comment>, Error = Error<serde_json::Value>>>;
  63. fn issue_list_issues(&self, owner: &str, repo: &str, state: &str, labels: &str, page: i32, q: &str, _type: &str) -> Box<Future<Item = Vec<::models::Issue>, Error = Error<serde_json::Value>>>;
  64. fn issue_list_labels(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Label>, Error = Error<serde_json::Value>>>;
  65. fn issue_post_comment_reaction(&self, owner: &str, repo: &str, id: i64, content: ::models::EditReactionOption) -> Box<Future<Item = ::models::Reaction, Error = Error<serde_json::Value>>>;
  66. fn issue_post_issue_reaction(&self, owner: &str, repo: &str, index: i64, content: ::models::EditReactionOption) -> Box<Future<Item = ::models::Reaction, Error = Error<serde_json::Value>>>;
  67. fn issue_remove_label(&self, owner: &str, repo: &str, index: i64, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  68. fn issue_replace_labels(&self, owner: &str, repo: &str, index: i64, body: ::models::IssueLabelsOption) -> Box<Future<Item = Vec<::models::Label>, Error = Error<serde_json::Value>>>;
  69. fn issue_reset_time(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  70. fn issue_search_issues(&self, state: &str, labels: &str, page: i32, q: &str, priority_repo_id: i64, _type: &str) -> Box<Future<Item = Vec<::models::Issue>, Error = Error<serde_json::Value>>>;
  71. fn issue_start_stop_watch(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  72. fn issue_stop_stop_watch(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  73. fn issue_subscriptions(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>>;
  74. fn issue_tracked_times(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = Vec<::models::TrackedTime>, Error = Error<serde_json::Value>>>;
  75. }
  76. impl<C: hyper::client::Connect>IssueApi for IssueApiClient<C> {
  77. fn issue_add_label(&self, owner: &str, repo: &str, index: i64, body: ::models::IssueLabelsOption) -> Box<Future<Item = Vec<::models::Label>, Error = Error<serde_json::Value>>> {
  78. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  79. let mut auth_headers = HashMap::<String, String>::new();
  80. let mut auth_query = HashMap::<String, String>::new();
  81. if let Some(ref apikey) = configuration.api_key {
  82. let key = apikey.key.clone();
  83. let val = match apikey.prefix {
  84. Some(ref prefix) => format!("{} {}", prefix, key),
  85. None => key,
  86. };
  87. auth_query.insert("access_token".to_owned(), val);
  88. };
  89. if let Some(ref apikey) = configuration.api_key {
  90. let key = apikey.key.clone();
  91. let val = match apikey.prefix {
  92. Some(ref prefix) => format!("{} {}", prefix, key),
  93. None => key,
  94. };
  95. auth_headers.insert("Authorization".to_owned(), val);
  96. };
  97. if let Some(ref auth_conf) = configuration.basic_auth {
  98. let auth = hyper::header::Authorization(
  99. hyper::header::Basic {
  100. username: auth_conf.0.to_owned(),
  101. password: auth_conf.1.to_owned(),
  102. }
  103. );
  104. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  105. };
  106. if let Some(ref apikey) = configuration.api_key {
  107. let key = apikey.key.clone();
  108. let val = match apikey.prefix {
  109. Some(ref prefix) => format!("{} {}", prefix, key),
  110. None => key,
  111. };
  112. auth_headers.insert("Sudo".to_owned(), val);
  113. };
  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("sudo".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_query.insert("token".to_owned(), val);
  129. };
  130. let method = hyper::Method::Post;
  131. let query_string = {
  132. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  133. for (key, val) in &auth_query {
  134. query.append_pair(key, val);
  135. }
  136. query.finish()
  137. };
  138. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/labels?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  139. // TODO(farcaller): handle error
  140. // if let Err(e) = uri {
  141. // return Box::new(futures::future::err(e));
  142. // }
  143. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  144. let mut req = hyper::Request::new(method, uri);
  145. if let Some(ref user_agent) = configuration.user_agent {
  146. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  147. }
  148. for (key, val) in auth_headers {
  149. req.headers_mut().set_raw(key, val);
  150. }
  151. let serialized = serde_json::to_string(&body).unwrap();
  152. req.headers_mut().set(hyper::header::ContentType::json());
  153. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  154. req.set_body(serialized);
  155. // send request
  156. Box::new(
  157. configuration.client.request(req)
  158. .map_err(|e| Error::from(e))
  159. .and_then(|resp| {
  160. let status = resp.status();
  161. resp.body().concat2()
  162. .and_then(move |body| Ok((status, body)))
  163. .map_err(|e| Error::from(e))
  164. })
  165. .and_then(|(status, body)| {
  166. if status.is_success() {
  167. Ok(body)
  168. } else {
  169. Err(Error::from((status, &*body)))
  170. }
  171. })
  172. .and_then(|body| {
  173. let parsed: Result<Vec<::models::Label>, _> = serde_json::from_slice(&body);
  174. parsed.map_err(|e| Error::from(e))
  175. })
  176. )
  177. }
  178. fn issue_add_subscription(&self, owner: &str, repo: &str, index: i64, user: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  179. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  180. let mut auth_headers = HashMap::<String, String>::new();
  181. let mut auth_query = HashMap::<String, String>::new();
  182. if let Some(ref apikey) = configuration.api_key {
  183. let key = apikey.key.clone();
  184. let val = match apikey.prefix {
  185. Some(ref prefix) => format!("{} {}", prefix, key),
  186. None => key,
  187. };
  188. auth_query.insert("access_token".to_owned(), val);
  189. };
  190. if let Some(ref apikey) = configuration.api_key {
  191. let key = apikey.key.clone();
  192. let val = match apikey.prefix {
  193. Some(ref prefix) => format!("{} {}", prefix, key),
  194. None => key,
  195. };
  196. auth_headers.insert("Authorization".to_owned(), val);
  197. };
  198. if let Some(ref auth_conf) = configuration.basic_auth {
  199. let auth = hyper::header::Authorization(
  200. hyper::header::Basic {
  201. username: auth_conf.0.to_owned(),
  202. password: auth_conf.1.to_owned(),
  203. }
  204. );
  205. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  206. };
  207. if let Some(ref apikey) = configuration.api_key {
  208. let key = apikey.key.clone();
  209. let val = match apikey.prefix {
  210. Some(ref prefix) => format!("{} {}", prefix, key),
  211. None => key,
  212. };
  213. auth_headers.insert("Sudo".to_owned(), val);
  214. };
  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("sudo".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_query.insert("token".to_owned(), val);
  230. };
  231. let method = hyper::Method::Put;
  232. let query_string = {
  233. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  234. for (key, val) in &auth_query {
  235. query.append_pair(key, val);
  236. }
  237. query.finish()
  238. };
  239. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/subscriptions/{user}?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index, user=user);
  240. // TODO(farcaller): handle error
  241. // if let Err(e) = uri {
  242. // return Box::new(futures::future::err(e));
  243. // }
  244. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  245. let mut req = hyper::Request::new(method, uri);
  246. if let Some(ref user_agent) = configuration.user_agent {
  247. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  248. }
  249. for (key, val) in auth_headers {
  250. req.headers_mut().set_raw(key, val);
  251. }
  252. // send request
  253. Box::new(
  254. configuration.client.request(req)
  255. .map_err(|e| Error::from(e))
  256. .and_then(|resp| {
  257. let status = resp.status();
  258. resp.body().concat2()
  259. .and_then(move |body| Ok((status, body)))
  260. .map_err(|e| Error::from(e))
  261. })
  262. .and_then(|(status, body)| {
  263. if status.is_success() {
  264. Ok(body)
  265. } else {
  266. Err(Error::from((status, &*body)))
  267. }
  268. })
  269. .and_then(|_| futures::future::ok(()))
  270. )
  271. }
  272. fn issue_add_time(&self, owner: &str, repo: &str, index: i64, body: ::models::AddTimeOption) -> Box<Future<Item = ::models::TrackedTime, Error = Error<serde_json::Value>>> {
  273. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  274. let mut auth_headers = HashMap::<String, String>::new();
  275. let mut auth_query = HashMap::<String, String>::new();
  276. if let Some(ref apikey) = configuration.api_key {
  277. let key = apikey.key.clone();
  278. let val = match apikey.prefix {
  279. Some(ref prefix) => format!("{} {}", prefix, key),
  280. None => key,
  281. };
  282. auth_query.insert("access_token".to_owned(), val);
  283. };
  284. if let Some(ref apikey) = configuration.api_key {
  285. let key = apikey.key.clone();
  286. let val = match apikey.prefix {
  287. Some(ref prefix) => format!("{} {}", prefix, key),
  288. None => key,
  289. };
  290. auth_headers.insert("Authorization".to_owned(), val);
  291. };
  292. if let Some(ref auth_conf) = configuration.basic_auth {
  293. let auth = hyper::header::Authorization(
  294. hyper::header::Basic {
  295. username: auth_conf.0.to_owned(),
  296. password: auth_conf.1.to_owned(),
  297. }
  298. );
  299. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  300. };
  301. if let Some(ref apikey) = configuration.api_key {
  302. let key = apikey.key.clone();
  303. let val = match apikey.prefix {
  304. Some(ref prefix) => format!("{} {}", prefix, key),
  305. None => key,
  306. };
  307. auth_headers.insert("Sudo".to_owned(), val);
  308. };
  309. if let Some(ref apikey) = configuration.api_key {
  310. let key = apikey.key.clone();
  311. let val = match apikey.prefix {
  312. Some(ref prefix) => format!("{} {}", prefix, key),
  313. None => key,
  314. };
  315. auth_query.insert("sudo".to_owned(), val);
  316. };
  317. if let Some(ref apikey) = configuration.api_key {
  318. let key = apikey.key.clone();
  319. let val = match apikey.prefix {
  320. Some(ref prefix) => format!("{} {}", prefix, key),
  321. None => key,
  322. };
  323. auth_query.insert("token".to_owned(), val);
  324. };
  325. let method = hyper::Method::Post;
  326. let query_string = {
  327. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  328. for (key, val) in &auth_query {
  329. query.append_pair(key, val);
  330. }
  331. query.finish()
  332. };
  333. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/times?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  334. // TODO(farcaller): handle error
  335. // if let Err(e) = uri {
  336. // return Box::new(futures::future::err(e));
  337. // }
  338. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  339. let mut req = hyper::Request::new(method, uri);
  340. if let Some(ref user_agent) = configuration.user_agent {
  341. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  342. }
  343. for (key, val) in auth_headers {
  344. req.headers_mut().set_raw(key, val);
  345. }
  346. let serialized = serde_json::to_string(&body).unwrap();
  347. req.headers_mut().set(hyper::header::ContentType::json());
  348. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  349. req.set_body(serialized);
  350. // send request
  351. Box::new(
  352. configuration.client.request(req)
  353. .map_err(|e| Error::from(e))
  354. .and_then(|resp| {
  355. let status = resp.status();
  356. resp.body().concat2()
  357. .and_then(move |body| Ok((status, body)))
  358. .map_err(|e| Error::from(e))
  359. })
  360. .and_then(|(status, body)| {
  361. if status.is_success() {
  362. Ok(body)
  363. } else {
  364. Err(Error::from((status, &*body)))
  365. }
  366. })
  367. .and_then(|body| {
  368. let parsed: Result<::models::TrackedTime, _> = serde_json::from_slice(&body);
  369. parsed.map_err(|e| Error::from(e))
  370. })
  371. )
  372. }
  373. fn issue_clear_labels(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  374. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  375. let mut auth_headers = HashMap::<String, String>::new();
  376. let mut auth_query = HashMap::<String, String>::new();
  377. if let Some(ref apikey) = configuration.api_key {
  378. let key = apikey.key.clone();
  379. let val = match apikey.prefix {
  380. Some(ref prefix) => format!("{} {}", prefix, key),
  381. None => key,
  382. };
  383. auth_query.insert("access_token".to_owned(), val);
  384. };
  385. if let Some(ref apikey) = configuration.api_key {
  386. let key = apikey.key.clone();
  387. let val = match apikey.prefix {
  388. Some(ref prefix) => format!("{} {}", prefix, key),
  389. None => key,
  390. };
  391. auth_headers.insert("Authorization".to_owned(), val);
  392. };
  393. if let Some(ref auth_conf) = configuration.basic_auth {
  394. let auth = hyper::header::Authorization(
  395. hyper::header::Basic {
  396. username: auth_conf.0.to_owned(),
  397. password: auth_conf.1.to_owned(),
  398. }
  399. );
  400. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  401. };
  402. if let Some(ref apikey) = configuration.api_key {
  403. let key = apikey.key.clone();
  404. let val = match apikey.prefix {
  405. Some(ref prefix) => format!("{} {}", prefix, key),
  406. None => key,
  407. };
  408. auth_headers.insert("Sudo".to_owned(), val);
  409. };
  410. if let Some(ref apikey) = configuration.api_key {
  411. let key = apikey.key.clone();
  412. let val = match apikey.prefix {
  413. Some(ref prefix) => format!("{} {}", prefix, key),
  414. None => key,
  415. };
  416. auth_query.insert("sudo".to_owned(), val);
  417. };
  418. if let Some(ref apikey) = configuration.api_key {
  419. let key = apikey.key.clone();
  420. let val = match apikey.prefix {
  421. Some(ref prefix) => format!("{} {}", prefix, key),
  422. None => key,
  423. };
  424. auth_query.insert("token".to_owned(), val);
  425. };
  426. let method = hyper::Method::Delete;
  427. let query_string = {
  428. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  429. for (key, val) in &auth_query {
  430. query.append_pair(key, val);
  431. }
  432. query.finish()
  433. };
  434. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/labels?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  435. // TODO(farcaller): handle error
  436. // if let Err(e) = uri {
  437. // return Box::new(futures::future::err(e));
  438. // }
  439. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  440. let mut req = hyper::Request::new(method, uri);
  441. if let Some(ref user_agent) = configuration.user_agent {
  442. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  443. }
  444. for (key, val) in auth_headers {
  445. req.headers_mut().set_raw(key, val);
  446. }
  447. // send request
  448. Box::new(
  449. configuration.client.request(req)
  450. .map_err(|e| Error::from(e))
  451. .and_then(|resp| {
  452. let status = resp.status();
  453. resp.body().concat2()
  454. .and_then(move |body| Ok((status, body)))
  455. .map_err(|e| Error::from(e))
  456. })
  457. .and_then(|(status, body)| {
  458. if status.is_success() {
  459. Ok(body)
  460. } else {
  461. Err(Error::from((status, &*body)))
  462. }
  463. })
  464. .and_then(|_| futures::future::ok(()))
  465. )
  466. }
  467. fn issue_create_comment(&self, owner: &str, repo: &str, index: i64, body: ::models::CreateIssueCommentOption) -> Box<Future<Item = ::models::Comment, Error = Error<serde_json::Value>>> {
  468. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  469. let mut auth_headers = HashMap::<String, String>::new();
  470. let mut auth_query = HashMap::<String, String>::new();
  471. if let Some(ref apikey) = configuration.api_key {
  472. let key = apikey.key.clone();
  473. let val = match apikey.prefix {
  474. Some(ref prefix) => format!("{} {}", prefix, key),
  475. None => key,
  476. };
  477. auth_query.insert("access_token".to_owned(), val);
  478. };
  479. if let Some(ref apikey) = configuration.api_key {
  480. let key = apikey.key.clone();
  481. let val = match apikey.prefix {
  482. Some(ref prefix) => format!("{} {}", prefix, key),
  483. None => key,
  484. };
  485. auth_headers.insert("Authorization".to_owned(), val);
  486. };
  487. if let Some(ref auth_conf) = configuration.basic_auth {
  488. let auth = hyper::header::Authorization(
  489. hyper::header::Basic {
  490. username: auth_conf.0.to_owned(),
  491. password: auth_conf.1.to_owned(),
  492. }
  493. );
  494. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  495. };
  496. if let Some(ref apikey) = configuration.api_key {
  497. let key = apikey.key.clone();
  498. let val = match apikey.prefix {
  499. Some(ref prefix) => format!("{} {}", prefix, key),
  500. None => key,
  501. };
  502. auth_headers.insert("Sudo".to_owned(), val);
  503. };
  504. if let Some(ref apikey) = configuration.api_key {
  505. let key = apikey.key.clone();
  506. let val = match apikey.prefix {
  507. Some(ref prefix) => format!("{} {}", prefix, key),
  508. None => key,
  509. };
  510. auth_query.insert("sudo".to_owned(), val);
  511. };
  512. if let Some(ref apikey) = configuration.api_key {
  513. let key = apikey.key.clone();
  514. let val = match apikey.prefix {
  515. Some(ref prefix) => format!("{} {}", prefix, key),
  516. None => key,
  517. };
  518. auth_query.insert("token".to_owned(), val);
  519. };
  520. let method = hyper::Method::Post;
  521. let query_string = {
  522. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  523. for (key, val) in &auth_query {
  524. query.append_pair(key, val);
  525. }
  526. query.finish()
  527. };
  528. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/comments?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  529. // TODO(farcaller): handle error
  530. // if let Err(e) = uri {
  531. // return Box::new(futures::future::err(e));
  532. // }
  533. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  534. let mut req = hyper::Request::new(method, uri);
  535. if let Some(ref user_agent) = configuration.user_agent {
  536. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  537. }
  538. for (key, val) in auth_headers {
  539. req.headers_mut().set_raw(key, val);
  540. }
  541. let serialized = serde_json::to_string(&body).unwrap();
  542. req.headers_mut().set(hyper::header::ContentType::json());
  543. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  544. req.set_body(serialized);
  545. // send request
  546. Box::new(
  547. configuration.client.request(req)
  548. .map_err(|e| Error::from(e))
  549. .and_then(|resp| {
  550. let status = resp.status();
  551. resp.body().concat2()
  552. .and_then(move |body| Ok((status, body)))
  553. .map_err(|e| Error::from(e))
  554. })
  555. .and_then(|(status, body)| {
  556. if status.is_success() {
  557. Ok(body)
  558. } else {
  559. Err(Error::from((status, &*body)))
  560. }
  561. })
  562. .and_then(|body| {
  563. let parsed: Result<::models::Comment, _> = serde_json::from_slice(&body);
  564. parsed.map_err(|e| Error::from(e))
  565. })
  566. )
  567. }
  568. fn issue_create_issue(&self, owner: &str, repo: &str, body: ::models::CreateIssueOption) -> Box<Future<Item = ::models::Issue, Error = Error<serde_json::Value>>> {
  569. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  570. let mut auth_headers = HashMap::<String, String>::new();
  571. let mut auth_query = HashMap::<String, String>::new();
  572. if let Some(ref apikey) = configuration.api_key {
  573. let key = apikey.key.clone();
  574. let val = match apikey.prefix {
  575. Some(ref prefix) => format!("{} {}", prefix, key),
  576. None => key,
  577. };
  578. auth_query.insert("access_token".to_owned(), val);
  579. };
  580. if let Some(ref apikey) = configuration.api_key {
  581. let key = apikey.key.clone();
  582. let val = match apikey.prefix {
  583. Some(ref prefix) => format!("{} {}", prefix, key),
  584. None => key,
  585. };
  586. auth_headers.insert("Authorization".to_owned(), val);
  587. };
  588. if let Some(ref auth_conf) = configuration.basic_auth {
  589. let auth = hyper::header::Authorization(
  590. hyper::header::Basic {
  591. username: auth_conf.0.to_owned(),
  592. password: auth_conf.1.to_owned(),
  593. }
  594. );
  595. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  596. };
  597. if let Some(ref apikey) = configuration.api_key {
  598. let key = apikey.key.clone();
  599. let val = match apikey.prefix {
  600. Some(ref prefix) => format!("{} {}", prefix, key),
  601. None => key,
  602. };
  603. auth_headers.insert("Sudo".to_owned(), val);
  604. };
  605. if let Some(ref apikey) = configuration.api_key {
  606. let key = apikey.key.clone();
  607. let val = match apikey.prefix {
  608. Some(ref prefix) => format!("{} {}", prefix, key),
  609. None => key,
  610. };
  611. auth_query.insert("sudo".to_owned(), val);
  612. };
  613. if let Some(ref apikey) = configuration.api_key {
  614. let key = apikey.key.clone();
  615. let val = match apikey.prefix {
  616. Some(ref prefix) => format!("{} {}", prefix, key),
  617. None => key,
  618. };
  619. auth_query.insert("token".to_owned(), val);
  620. };
  621. let method = hyper::Method::Post;
  622. let query_string = {
  623. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  624. for (key, val) in &auth_query {
  625. query.append_pair(key, val);
  626. }
  627. query.finish()
  628. };
  629. let uri_str = format!("{}/repos/{owner}/{repo}/issues?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  630. // TODO(farcaller): handle error
  631. // if let Err(e) = uri {
  632. // return Box::new(futures::future::err(e));
  633. // }
  634. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  635. let mut req = hyper::Request::new(method, uri);
  636. if let Some(ref user_agent) = configuration.user_agent {
  637. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  638. }
  639. for (key, val) in auth_headers {
  640. req.headers_mut().set_raw(key, val);
  641. }
  642. let serialized = serde_json::to_string(&body).unwrap();
  643. req.headers_mut().set(hyper::header::ContentType::json());
  644. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  645. req.set_body(serialized);
  646. // send request
  647. Box::new(
  648. configuration.client.request(req)
  649. .map_err(|e| Error::from(e))
  650. .and_then(|resp| {
  651. let status = resp.status();
  652. resp.body().concat2()
  653. .and_then(move |body| Ok((status, body)))
  654. .map_err(|e| Error::from(e))
  655. })
  656. .and_then(|(status, body)| {
  657. if status.is_success() {
  658. Ok(body)
  659. } else {
  660. Err(Error::from((status, &*body)))
  661. }
  662. })
  663. .and_then(|body| {
  664. let parsed: Result<::models::Issue, _> = serde_json::from_slice(&body);
  665. parsed.map_err(|e| Error::from(e))
  666. })
  667. )
  668. }
  669. fn issue_create_label(&self, owner: &str, repo: &str, body: ::models::CreateLabelOption) -> Box<Future<Item = ::models::Label, Error = Error<serde_json::Value>>> {
  670. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  671. let mut auth_headers = HashMap::<String, String>::new();
  672. let mut auth_query = HashMap::<String, String>::new();
  673. if let Some(ref apikey) = configuration.api_key {
  674. let key = apikey.key.clone();
  675. let val = match apikey.prefix {
  676. Some(ref prefix) => format!("{} {}", prefix, key),
  677. None => key,
  678. };
  679. auth_query.insert("access_token".to_owned(), val);
  680. };
  681. if let Some(ref apikey) = configuration.api_key {
  682. let key = apikey.key.clone();
  683. let val = match apikey.prefix {
  684. Some(ref prefix) => format!("{} {}", prefix, key),
  685. None => key,
  686. };
  687. auth_headers.insert("Authorization".to_owned(), val);
  688. };
  689. if let Some(ref auth_conf) = configuration.basic_auth {
  690. let auth = hyper::header::Authorization(
  691. hyper::header::Basic {
  692. username: auth_conf.0.to_owned(),
  693. password: auth_conf.1.to_owned(),
  694. }
  695. );
  696. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  697. };
  698. if let Some(ref apikey) = configuration.api_key {
  699. let key = apikey.key.clone();
  700. let val = match apikey.prefix {
  701. Some(ref prefix) => format!("{} {}", prefix, key),
  702. None => key,
  703. };
  704. auth_headers.insert("Sudo".to_owned(), val);
  705. };
  706. if let Some(ref apikey) = configuration.api_key {
  707. let key = apikey.key.clone();
  708. let val = match apikey.prefix {
  709. Some(ref prefix) => format!("{} {}", prefix, key),
  710. None => key,
  711. };
  712. auth_query.insert("sudo".to_owned(), val);
  713. };
  714. if let Some(ref apikey) = configuration.api_key {
  715. let key = apikey.key.clone();
  716. let val = match apikey.prefix {
  717. Some(ref prefix) => format!("{} {}", prefix, key),
  718. None => key,
  719. };
  720. auth_query.insert("token".to_owned(), val);
  721. };
  722. let method = hyper::Method::Post;
  723. let query_string = {
  724. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  725. for (key, val) in &auth_query {
  726. query.append_pair(key, val);
  727. }
  728. query.finish()
  729. };
  730. let uri_str = format!("{}/repos/{owner}/{repo}/labels?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  731. // TODO(farcaller): handle error
  732. // if let Err(e) = uri {
  733. // return Box::new(futures::future::err(e));
  734. // }
  735. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  736. let mut req = hyper::Request::new(method, uri);
  737. if let Some(ref user_agent) = configuration.user_agent {
  738. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  739. }
  740. for (key, val) in auth_headers {
  741. req.headers_mut().set_raw(key, val);
  742. }
  743. let serialized = serde_json::to_string(&body).unwrap();
  744. req.headers_mut().set(hyper::header::ContentType::json());
  745. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  746. req.set_body(serialized);
  747. // send request
  748. Box::new(
  749. configuration.client.request(req)
  750. .map_err(|e| Error::from(e))
  751. .and_then(|resp| {
  752. let status = resp.status();
  753. resp.body().concat2()
  754. .and_then(move |body| Ok((status, body)))
  755. .map_err(|e| Error::from(e))
  756. })
  757. .and_then(|(status, body)| {
  758. if status.is_success() {
  759. Ok(body)
  760. } else {
  761. Err(Error::from((status, &*body)))
  762. }
  763. })
  764. .and_then(|body| {
  765. let parsed: Result<::models::Label, _> = serde_json::from_slice(&body);
  766. parsed.map_err(|e| Error::from(e))
  767. })
  768. )
  769. }
  770. fn issue_create_milestone(&self, owner: &str, repo: &str, body: ::models::CreateMilestoneOption) -> Box<Future<Item = ::models::Milestone, Error = Error<serde_json::Value>>> {
  771. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  772. let mut auth_headers = HashMap::<String, String>::new();
  773. let mut auth_query = HashMap::<String, String>::new();
  774. if let Some(ref apikey) = configuration.api_key {
  775. let key = apikey.key.clone();
  776. let val = match apikey.prefix {
  777. Some(ref prefix) => format!("{} {}", prefix, key),
  778. None => key,
  779. };
  780. auth_query.insert("access_token".to_owned(), val);
  781. };
  782. if let Some(ref apikey) = configuration.api_key {
  783. let key = apikey.key.clone();
  784. let val = match apikey.prefix {
  785. Some(ref prefix) => format!("{} {}", prefix, key),
  786. None => key,
  787. };
  788. auth_headers.insert("Authorization".to_owned(), val);
  789. };
  790. if let Some(ref auth_conf) = configuration.basic_auth {
  791. let auth = hyper::header::Authorization(
  792. hyper::header::Basic {
  793. username: auth_conf.0.to_owned(),
  794. password: auth_conf.1.to_owned(),
  795. }
  796. );
  797. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  798. };
  799. if let Some(ref apikey) = configuration.api_key {
  800. let key = apikey.key.clone();
  801. let val = match apikey.prefix {
  802. Some(ref prefix) => format!("{} {}", prefix, key),
  803. None => key,
  804. };
  805. auth_headers.insert("Sudo".to_owned(), val);
  806. };
  807. if let Some(ref apikey) = configuration.api_key {
  808. let key = apikey.key.clone();
  809. let val = match apikey.prefix {
  810. Some(ref prefix) => format!("{} {}", prefix, key),
  811. None => key,
  812. };
  813. auth_query.insert("sudo".to_owned(), val);
  814. };
  815. if let Some(ref apikey) = configuration.api_key {
  816. let key = apikey.key.clone();
  817. let val = match apikey.prefix {
  818. Some(ref prefix) => format!("{} {}", prefix, key),
  819. None => key,
  820. };
  821. auth_query.insert("token".to_owned(), val);
  822. };
  823. let method = hyper::Method::Post;
  824. let query_string = {
  825. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  826. for (key, val) in &auth_query {
  827. query.append_pair(key, val);
  828. }
  829. query.finish()
  830. };
  831. let uri_str = format!("{}/repos/{owner}/{repo}/milestones?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  832. // TODO(farcaller): handle error
  833. // if let Err(e) = uri {
  834. // return Box::new(futures::future::err(e));
  835. // }
  836. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  837. let mut req = hyper::Request::new(method, uri);
  838. if let Some(ref user_agent) = configuration.user_agent {
  839. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  840. }
  841. for (key, val) in auth_headers {
  842. req.headers_mut().set_raw(key, val);
  843. }
  844. let serialized = serde_json::to_string(&body).unwrap();
  845. req.headers_mut().set(hyper::header::ContentType::json());
  846. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  847. req.set_body(serialized);
  848. // send request
  849. Box::new(
  850. configuration.client.request(req)
  851. .map_err(|e| Error::from(e))
  852. .and_then(|resp| {
  853. let status = resp.status();
  854. resp.body().concat2()
  855. .and_then(move |body| Ok((status, body)))
  856. .map_err(|e| Error::from(e))
  857. })
  858. .and_then(|(status, body)| {
  859. if status.is_success() {
  860. Ok(body)
  861. } else {
  862. Err(Error::from((status, &*body)))
  863. }
  864. })
  865. .and_then(|body| {
  866. let parsed: Result<::models::Milestone, _> = serde_json::from_slice(&body);
  867. parsed.map_err(|e| Error::from(e))
  868. })
  869. )
  870. }
  871. fn issue_delete_comment(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  872. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  873. let mut auth_headers = HashMap::<String, String>::new();
  874. let mut auth_query = HashMap::<String, String>::new();
  875. if let Some(ref apikey) = configuration.api_key {
  876. let key = apikey.key.clone();
  877. let val = match apikey.prefix {
  878. Some(ref prefix) => format!("{} {}", prefix, key),
  879. None => key,
  880. };
  881. auth_query.insert("access_token".to_owned(), val);
  882. };
  883. if let Some(ref apikey) = configuration.api_key {
  884. let key = apikey.key.clone();
  885. let val = match apikey.prefix {
  886. Some(ref prefix) => format!("{} {}", prefix, key),
  887. None => key,
  888. };
  889. auth_headers.insert("Authorization".to_owned(), val);
  890. };
  891. if let Some(ref auth_conf) = configuration.basic_auth {
  892. let auth = hyper::header::Authorization(
  893. hyper::header::Basic {
  894. username: auth_conf.0.to_owned(),
  895. password: auth_conf.1.to_owned(),
  896. }
  897. );
  898. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  899. };
  900. if let Some(ref apikey) = configuration.api_key {
  901. let key = apikey.key.clone();
  902. let val = match apikey.prefix {
  903. Some(ref prefix) => format!("{} {}", prefix, key),
  904. None => key,
  905. };
  906. auth_headers.insert("Sudo".to_owned(), val);
  907. };
  908. if let Some(ref apikey) = configuration.api_key {
  909. let key = apikey.key.clone();
  910. let val = match apikey.prefix {
  911. Some(ref prefix) => format!("{} {}", prefix, key),
  912. None => key,
  913. };
  914. auth_query.insert("sudo".to_owned(), val);
  915. };
  916. if let Some(ref apikey) = configuration.api_key {
  917. let key = apikey.key.clone();
  918. let val = match apikey.prefix {
  919. Some(ref prefix) => format!("{} {}", prefix, key),
  920. None => key,
  921. };
  922. auth_query.insert("token".to_owned(), val);
  923. };
  924. let method = hyper::Method::Delete;
  925. let query_string = {
  926. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  927. for (key, val) in &auth_query {
  928. query.append_pair(key, val);
  929. }
  930. query.finish()
  931. };
  932. let uri_str = format!("{}/repos/{owner}/{repo}/issues/comments/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  933. // TODO(farcaller): handle error
  934. // if let Err(e) = uri {
  935. // return Box::new(futures::future::err(e));
  936. // }
  937. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  938. let mut req = hyper::Request::new(method, uri);
  939. if let Some(ref user_agent) = configuration.user_agent {
  940. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  941. }
  942. for (key, val) in auth_headers {
  943. req.headers_mut().set_raw(key, val);
  944. }
  945. // send request
  946. Box::new(
  947. configuration.client.request(req)
  948. .map_err(|e| Error::from(e))
  949. .and_then(|resp| {
  950. let status = resp.status();
  951. resp.body().concat2()
  952. .and_then(move |body| Ok((status, body)))
  953. .map_err(|e| Error::from(e))
  954. })
  955. .and_then(|(status, body)| {
  956. if status.is_success() {
  957. Ok(body)
  958. } else {
  959. Err(Error::from((status, &*body)))
  960. }
  961. })
  962. .and_then(|_| futures::future::ok(()))
  963. )
  964. }
  965. fn issue_delete_comment_deprecated(&self, owner: &str, repo: &str, index: i32, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  966. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  967. let mut auth_headers = HashMap::<String, String>::new();
  968. let mut auth_query = HashMap::<String, String>::new();
  969. if let Some(ref apikey) = configuration.api_key {
  970. let key = apikey.key.clone();
  971. let val = match apikey.prefix {
  972. Some(ref prefix) => format!("{} {}", prefix, key),
  973. None => key,
  974. };
  975. auth_query.insert("access_token".to_owned(), val);
  976. };
  977. if let Some(ref apikey) = configuration.api_key {
  978. let key = apikey.key.clone();
  979. let val = match apikey.prefix {
  980. Some(ref prefix) => format!("{} {}", prefix, key),
  981. None => key,
  982. };
  983. auth_headers.insert("Authorization".to_owned(), val);
  984. };
  985. if let Some(ref auth_conf) = configuration.basic_auth {
  986. let auth = hyper::header::Authorization(
  987. hyper::header::Basic {
  988. username: auth_conf.0.to_owned(),
  989. password: auth_conf.1.to_owned(),
  990. }
  991. );
  992. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  993. };
  994. if let Some(ref apikey) = configuration.api_key {
  995. let key = apikey.key.clone();
  996. let val = match apikey.prefix {
  997. Some(ref prefix) => format!("{} {}", prefix, key),
  998. None => key,
  999. };
  1000. auth_headers.insert("Sudo".to_owned(), val);
  1001. };
  1002. if let Some(ref apikey) = configuration.api_key {
  1003. let key = apikey.key.clone();
  1004. let val = match apikey.prefix {
  1005. Some(ref prefix) => format!("{} {}", prefix, key),
  1006. None => key,
  1007. };
  1008. auth_query.insert("sudo".to_owned(), val);
  1009. };
  1010. if let Some(ref apikey) = configuration.api_key {
  1011. let key = apikey.key.clone();
  1012. let val = match apikey.prefix {
  1013. Some(ref prefix) => format!("{} {}", prefix, key),
  1014. None => key,
  1015. };
  1016. auth_query.insert("token".to_owned(), val);
  1017. };
  1018. let method = hyper::Method::Delete;
  1019. let query_string = {
  1020. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1021. for (key, val) in &auth_query {
  1022. query.append_pair(key, val);
  1023. }
  1024. query.finish()
  1025. };
  1026. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/comments/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index, id=id);
  1027. // TODO(farcaller): handle error
  1028. // if let Err(e) = uri {
  1029. // return Box::new(futures::future::err(e));
  1030. // }
  1031. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1032. let mut req = hyper::Request::new(method, uri);
  1033. if let Some(ref user_agent) = configuration.user_agent {
  1034. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1035. }
  1036. for (key, val) in auth_headers {
  1037. req.headers_mut().set_raw(key, val);
  1038. }
  1039. // send request
  1040. Box::new(
  1041. configuration.client.request(req)
  1042. .map_err(|e| Error::from(e))
  1043. .and_then(|resp| {
  1044. let status = resp.status();
  1045. resp.body().concat2()
  1046. .and_then(move |body| Ok((status, body)))
  1047. .map_err(|e| Error::from(e))
  1048. })
  1049. .and_then(|(status, body)| {
  1050. if status.is_success() {
  1051. Ok(body)
  1052. } else {
  1053. Err(Error::from((status, &*body)))
  1054. }
  1055. })
  1056. .and_then(|_| futures::future::ok(()))
  1057. )
  1058. }
  1059. fn issue_delete_comment_reaction(&self, owner: &str, repo: &str, id: i64, content: ::models::EditReactionOption) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  1060. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1061. let mut auth_headers = HashMap::<String, String>::new();
  1062. let mut auth_query = HashMap::<String, String>::new();
  1063. if let Some(ref apikey) = configuration.api_key {
  1064. let key = apikey.key.clone();
  1065. let val = match apikey.prefix {
  1066. Some(ref prefix) => format!("{} {}", prefix, key),
  1067. None => key,
  1068. };
  1069. auth_query.insert("access_token".to_owned(), val);
  1070. };
  1071. if let Some(ref apikey) = configuration.api_key {
  1072. let key = apikey.key.clone();
  1073. let val = match apikey.prefix {
  1074. Some(ref prefix) => format!("{} {}", prefix, key),
  1075. None => key,
  1076. };
  1077. auth_headers.insert("Authorization".to_owned(), val);
  1078. };
  1079. if let Some(ref auth_conf) = configuration.basic_auth {
  1080. let auth = hyper::header::Authorization(
  1081. hyper::header::Basic {
  1082. username: auth_conf.0.to_owned(),
  1083. password: auth_conf.1.to_owned(),
  1084. }
  1085. );
  1086. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1087. };
  1088. if let Some(ref apikey) = configuration.api_key {
  1089. let key = apikey.key.clone();
  1090. let val = match apikey.prefix {
  1091. Some(ref prefix) => format!("{} {}", prefix, key),
  1092. None => key,
  1093. };
  1094. auth_headers.insert("Sudo".to_owned(), val);
  1095. };
  1096. if let Some(ref apikey) = configuration.api_key {
  1097. let key = apikey.key.clone();
  1098. let val = match apikey.prefix {
  1099. Some(ref prefix) => format!("{} {}", prefix, key),
  1100. None => key,
  1101. };
  1102. auth_query.insert("sudo".to_owned(), val);
  1103. };
  1104. if let Some(ref apikey) = configuration.api_key {
  1105. let key = apikey.key.clone();
  1106. let val = match apikey.prefix {
  1107. Some(ref prefix) => format!("{} {}", prefix, key),
  1108. None => key,
  1109. };
  1110. auth_query.insert("token".to_owned(), val);
  1111. };
  1112. let method = hyper::Method::Delete;
  1113. let query_string = {
  1114. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1115. for (key, val) in &auth_query {
  1116. query.append_pair(key, val);
  1117. }
  1118. query.finish()
  1119. };
  1120. let uri_str = format!("{}/repos/{owner}/{repo}/issues/comments/{id}/reactions?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  1121. // TODO(farcaller): handle error
  1122. // if let Err(e) = uri {
  1123. // return Box::new(futures::future::err(e));
  1124. // }
  1125. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1126. let mut req = hyper::Request::new(method, uri);
  1127. if let Some(ref user_agent) = configuration.user_agent {
  1128. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1129. }
  1130. for (key, val) in auth_headers {
  1131. req.headers_mut().set_raw(key, val);
  1132. }
  1133. let serialized = serde_json::to_string(&content).unwrap();
  1134. req.headers_mut().set(hyper::header::ContentType::json());
  1135. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  1136. req.set_body(serialized);
  1137. // send request
  1138. Box::new(
  1139. configuration.client.request(req)
  1140. .map_err(|e| Error::from(e))
  1141. .and_then(|resp| {
  1142. let status = resp.status();
  1143. resp.body().concat2()
  1144. .and_then(move |body| Ok((status, body)))
  1145. .map_err(|e| Error::from(e))
  1146. })
  1147. .and_then(|(status, body)| {
  1148. if status.is_success() {
  1149. Ok(body)
  1150. } else {
  1151. Err(Error::from((status, &*body)))
  1152. }
  1153. })
  1154. .and_then(|_| futures::future::ok(()))
  1155. )
  1156. }
  1157. fn issue_delete_issue_reaction(&self, owner: &str, repo: &str, index: i64, content: ::models::EditReactionOption) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  1158. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1159. let mut auth_headers = HashMap::<String, String>::new();
  1160. let mut auth_query = HashMap::<String, String>::new();
  1161. if let Some(ref apikey) = configuration.api_key {
  1162. let key = apikey.key.clone();
  1163. let val = match apikey.prefix {
  1164. Some(ref prefix) => format!("{} {}", prefix, key),
  1165. None => key,
  1166. };
  1167. auth_query.insert("access_token".to_owned(), val);
  1168. };
  1169. if let Some(ref apikey) = configuration.api_key {
  1170. let key = apikey.key.clone();
  1171. let val = match apikey.prefix {
  1172. Some(ref prefix) => format!("{} {}", prefix, key),
  1173. None => key,
  1174. };
  1175. auth_headers.insert("Authorization".to_owned(), val);
  1176. };
  1177. if let Some(ref auth_conf) = configuration.basic_auth {
  1178. let auth = hyper::header::Authorization(
  1179. hyper::header::Basic {
  1180. username: auth_conf.0.to_owned(),
  1181. password: auth_conf.1.to_owned(),
  1182. }
  1183. );
  1184. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1185. };
  1186. if let Some(ref apikey) = configuration.api_key {
  1187. let key = apikey.key.clone();
  1188. let val = match apikey.prefix {
  1189. Some(ref prefix) => format!("{} {}", prefix, key),
  1190. None => key,
  1191. };
  1192. auth_headers.insert("Sudo".to_owned(), val);
  1193. };
  1194. if let Some(ref apikey) = configuration.api_key {
  1195. let key = apikey.key.clone();
  1196. let val = match apikey.prefix {
  1197. Some(ref prefix) => format!("{} {}", prefix, key),
  1198. None => key,
  1199. };
  1200. auth_query.insert("sudo".to_owned(), val);
  1201. };
  1202. if let Some(ref apikey) = configuration.api_key {
  1203. let key = apikey.key.clone();
  1204. let val = match apikey.prefix {
  1205. Some(ref prefix) => format!("{} {}", prefix, key),
  1206. None => key,
  1207. };
  1208. auth_query.insert("token".to_owned(), val);
  1209. };
  1210. let method = hyper::Method::Delete;
  1211. let query_string = {
  1212. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1213. for (key, val) in &auth_query {
  1214. query.append_pair(key, val);
  1215. }
  1216. query.finish()
  1217. };
  1218. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/reactions?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  1219. // TODO(farcaller): handle error
  1220. // if let Err(e) = uri {
  1221. // return Box::new(futures::future::err(e));
  1222. // }
  1223. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1224. let mut req = hyper::Request::new(method, uri);
  1225. if let Some(ref user_agent) = configuration.user_agent {
  1226. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1227. }
  1228. for (key, val) in auth_headers {
  1229. req.headers_mut().set_raw(key, val);
  1230. }
  1231. let serialized = serde_json::to_string(&content).unwrap();
  1232. req.headers_mut().set(hyper::header::ContentType::json());
  1233. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  1234. req.set_body(serialized);
  1235. // send request
  1236. Box::new(
  1237. configuration.client.request(req)
  1238. .map_err(|e| Error::from(e))
  1239. .and_then(|resp| {
  1240. let status = resp.status();
  1241. resp.body().concat2()
  1242. .and_then(move |body| Ok((status, body)))
  1243. .map_err(|e| Error::from(e))
  1244. })
  1245. .and_then(|(status, body)| {
  1246. if status.is_success() {
  1247. Ok(body)
  1248. } else {
  1249. Err(Error::from((status, &*body)))
  1250. }
  1251. })
  1252. .and_then(|_| futures::future::ok(()))
  1253. )
  1254. }
  1255. fn issue_delete_label(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  1256. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1257. let mut auth_headers = HashMap::<String, String>::new();
  1258. let mut auth_query = HashMap::<String, String>::new();
  1259. if let Some(ref apikey) = configuration.api_key {
  1260. let key = apikey.key.clone();
  1261. let val = match apikey.prefix {
  1262. Some(ref prefix) => format!("{} {}", prefix, key),
  1263. None => key,
  1264. };
  1265. auth_query.insert("access_token".to_owned(), val);
  1266. };
  1267. if let Some(ref apikey) = configuration.api_key {
  1268. let key = apikey.key.clone();
  1269. let val = match apikey.prefix {
  1270. Some(ref prefix) => format!("{} {}", prefix, key),
  1271. None => key,
  1272. };
  1273. auth_headers.insert("Authorization".to_owned(), val);
  1274. };
  1275. if let Some(ref auth_conf) = configuration.basic_auth {
  1276. let auth = hyper::header::Authorization(
  1277. hyper::header::Basic {
  1278. username: auth_conf.0.to_owned(),
  1279. password: auth_conf.1.to_owned(),
  1280. }
  1281. );
  1282. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1283. };
  1284. if let Some(ref apikey) = configuration.api_key {
  1285. let key = apikey.key.clone();
  1286. let val = match apikey.prefix {
  1287. Some(ref prefix) => format!("{} {}", prefix, key),
  1288. None => key,
  1289. };
  1290. auth_headers.insert("Sudo".to_owned(), val);
  1291. };
  1292. if let Some(ref apikey) = configuration.api_key {
  1293. let key = apikey.key.clone();
  1294. let val = match apikey.prefix {
  1295. Some(ref prefix) => format!("{} {}", prefix, key),
  1296. None => key,
  1297. };
  1298. auth_query.insert("sudo".to_owned(), val);
  1299. };
  1300. if let Some(ref apikey) = configuration.api_key {
  1301. let key = apikey.key.clone();
  1302. let val = match apikey.prefix {
  1303. Some(ref prefix) => format!("{} {}", prefix, key),
  1304. None => key,
  1305. };
  1306. auth_query.insert("token".to_owned(), val);
  1307. };
  1308. let method = hyper::Method::Delete;
  1309. let query_string = {
  1310. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1311. for (key, val) in &auth_query {
  1312. query.append_pair(key, val);
  1313. }
  1314. query.finish()
  1315. };
  1316. let uri_str = format!("{}/repos/{owner}/{repo}/labels/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  1317. // TODO(farcaller): handle error
  1318. // if let Err(e) = uri {
  1319. // return Box::new(futures::future::err(e));
  1320. // }
  1321. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1322. let mut req = hyper::Request::new(method, uri);
  1323. if let Some(ref user_agent) = configuration.user_agent {
  1324. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1325. }
  1326. for (key, val) in auth_headers {
  1327. req.headers_mut().set_raw(key, val);
  1328. }
  1329. // send request
  1330. Box::new(
  1331. configuration.client.request(req)
  1332. .map_err(|e| Error::from(e))
  1333. .and_then(|resp| {
  1334. let status = resp.status();
  1335. resp.body().concat2()
  1336. .and_then(move |body| Ok((status, body)))
  1337. .map_err(|e| Error::from(e))
  1338. })
  1339. .and_then(|(status, body)| {
  1340. if status.is_success() {
  1341. Ok(body)
  1342. } else {
  1343. Err(Error::from((status, &*body)))
  1344. }
  1345. })
  1346. .and_then(|_| futures::future::ok(()))
  1347. )
  1348. }
  1349. fn issue_delete_milestone(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  1350. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1351. let mut auth_headers = HashMap::<String, String>::new();
  1352. let mut auth_query = HashMap::<String, String>::new();
  1353. if let Some(ref apikey) = configuration.api_key {
  1354. let key = apikey.key.clone();
  1355. let val = match apikey.prefix {
  1356. Some(ref prefix) => format!("{} {}", prefix, key),
  1357. None => key,
  1358. };
  1359. auth_query.insert("access_token".to_owned(), val);
  1360. };
  1361. if let Some(ref apikey) = configuration.api_key {
  1362. let key = apikey.key.clone();
  1363. let val = match apikey.prefix {
  1364. Some(ref prefix) => format!("{} {}", prefix, key),
  1365. None => key,
  1366. };
  1367. auth_headers.insert("Authorization".to_owned(), val);
  1368. };
  1369. if let Some(ref auth_conf) = configuration.basic_auth {
  1370. let auth = hyper::header::Authorization(
  1371. hyper::header::Basic {
  1372. username: auth_conf.0.to_owned(),
  1373. password: auth_conf.1.to_owned(),
  1374. }
  1375. );
  1376. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1377. };
  1378. if let Some(ref apikey) = configuration.api_key {
  1379. let key = apikey.key.clone();
  1380. let val = match apikey.prefix {
  1381. Some(ref prefix) => format!("{} {}", prefix, key),
  1382. None => key,
  1383. };
  1384. auth_headers.insert("Sudo".to_owned(), val);
  1385. };
  1386. if let Some(ref apikey) = configuration.api_key {
  1387. let key = apikey.key.clone();
  1388. let val = match apikey.prefix {
  1389. Some(ref prefix) => format!("{} {}", prefix, key),
  1390. None => key,
  1391. };
  1392. auth_query.insert("sudo".to_owned(), val);
  1393. };
  1394. if let Some(ref apikey) = configuration.api_key {
  1395. let key = apikey.key.clone();
  1396. let val = match apikey.prefix {
  1397. Some(ref prefix) => format!("{} {}", prefix, key),
  1398. None => key,
  1399. };
  1400. auth_query.insert("token".to_owned(), val);
  1401. };
  1402. let method = hyper::Method::Delete;
  1403. let query_string = {
  1404. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1405. for (key, val) in &auth_query {
  1406. query.append_pair(key, val);
  1407. }
  1408. query.finish()
  1409. };
  1410. let uri_str = format!("{}/repos/{owner}/{repo}/milestones/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  1411. // TODO(farcaller): handle error
  1412. // if let Err(e) = uri {
  1413. // return Box::new(futures::future::err(e));
  1414. // }
  1415. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1416. let mut req = hyper::Request::new(method, uri);
  1417. if let Some(ref user_agent) = configuration.user_agent {
  1418. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1419. }
  1420. for (key, val) in auth_headers {
  1421. req.headers_mut().set_raw(key, val);
  1422. }
  1423. // send request
  1424. Box::new(
  1425. configuration.client.request(req)
  1426. .map_err(|e| Error::from(e))
  1427. .and_then(|resp| {
  1428. let status = resp.status();
  1429. resp.body().concat2()
  1430. .and_then(move |body| Ok((status, body)))
  1431. .map_err(|e| Error::from(e))
  1432. })
  1433. .and_then(|(status, body)| {
  1434. if status.is_success() {
  1435. Ok(body)
  1436. } else {
  1437. Err(Error::from((status, &*body)))
  1438. }
  1439. })
  1440. .and_then(|_| futures::future::ok(()))
  1441. )
  1442. }
  1443. fn issue_delete_stop_watch(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  1444. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1445. let mut auth_headers = HashMap::<String, String>::new();
  1446. let mut auth_query = HashMap::<String, String>::new();
  1447. if let Some(ref apikey) = configuration.api_key {
  1448. let key = apikey.key.clone();
  1449. let val = match apikey.prefix {
  1450. Some(ref prefix) => format!("{} {}", prefix, key),
  1451. None => key,
  1452. };
  1453. auth_query.insert("access_token".to_owned(), val);
  1454. };
  1455. if let Some(ref apikey) = configuration.api_key {
  1456. let key = apikey.key.clone();
  1457. let val = match apikey.prefix {
  1458. Some(ref prefix) => format!("{} {}", prefix, key),
  1459. None => key,
  1460. };
  1461. auth_headers.insert("Authorization".to_owned(), val);
  1462. };
  1463. if let Some(ref auth_conf) = configuration.basic_auth {
  1464. let auth = hyper::header::Authorization(
  1465. hyper::header::Basic {
  1466. username: auth_conf.0.to_owned(),
  1467. password: auth_conf.1.to_owned(),
  1468. }
  1469. );
  1470. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1471. };
  1472. if let Some(ref apikey) = configuration.api_key {
  1473. let key = apikey.key.clone();
  1474. let val = match apikey.prefix {
  1475. Some(ref prefix) => format!("{} {}", prefix, key),
  1476. None => key,
  1477. };
  1478. auth_headers.insert("Sudo".to_owned(), val);
  1479. };
  1480. if let Some(ref apikey) = configuration.api_key {
  1481. let key = apikey.key.clone();
  1482. let val = match apikey.prefix {
  1483. Some(ref prefix) => format!("{} {}", prefix, key),
  1484. None => key,
  1485. };
  1486. auth_query.insert("sudo".to_owned(), val);
  1487. };
  1488. if let Some(ref apikey) = configuration.api_key {
  1489. let key = apikey.key.clone();
  1490. let val = match apikey.prefix {
  1491. Some(ref prefix) => format!("{} {}", prefix, key),
  1492. None => key,
  1493. };
  1494. auth_query.insert("token".to_owned(), val);
  1495. };
  1496. let method = hyper::Method::Delete;
  1497. let query_string = {
  1498. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1499. for (key, val) in &auth_query {
  1500. query.append_pair(key, val);
  1501. }
  1502. query.finish()
  1503. };
  1504. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/stopwatch/delete?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  1505. // TODO(farcaller): handle error
  1506. // if let Err(e) = uri {
  1507. // return Box::new(futures::future::err(e));
  1508. // }
  1509. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1510. let mut req = hyper::Request::new(method, uri);
  1511. if let Some(ref user_agent) = configuration.user_agent {
  1512. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1513. }
  1514. for (key, val) in auth_headers {
  1515. req.headers_mut().set_raw(key, val);
  1516. }
  1517. // send request
  1518. Box::new(
  1519. configuration.client.request(req)
  1520. .map_err(|e| Error::from(e))
  1521. .and_then(|resp| {
  1522. let status = resp.status();
  1523. resp.body().concat2()
  1524. .and_then(move |body| Ok((status, body)))
  1525. .map_err(|e| Error::from(e))
  1526. })
  1527. .and_then(|(status, body)| {
  1528. if status.is_success() {
  1529. Ok(body)
  1530. } else {
  1531. Err(Error::from((status, &*body)))
  1532. }
  1533. })
  1534. .and_then(|_| futures::future::ok(()))
  1535. )
  1536. }
  1537. fn issue_delete_subscription(&self, owner: &str, repo: &str, index: i64, user: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  1538. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1539. let mut auth_headers = HashMap::<String, String>::new();
  1540. let mut auth_query = HashMap::<String, String>::new();
  1541. if let Some(ref apikey) = configuration.api_key {
  1542. let key = apikey.key.clone();
  1543. let val = match apikey.prefix {
  1544. Some(ref prefix) => format!("{} {}", prefix, key),
  1545. None => key,
  1546. };
  1547. auth_query.insert("access_token".to_owned(), val);
  1548. };
  1549. if let Some(ref apikey) = configuration.api_key {
  1550. let key = apikey.key.clone();
  1551. let val = match apikey.prefix {
  1552. Some(ref prefix) => format!("{} {}", prefix, key),
  1553. None => key,
  1554. };
  1555. auth_headers.insert("Authorization".to_owned(), val);
  1556. };
  1557. if let Some(ref auth_conf) = configuration.basic_auth {
  1558. let auth = hyper::header::Authorization(
  1559. hyper::header::Basic {
  1560. username: auth_conf.0.to_owned(),
  1561. password: auth_conf.1.to_owned(),
  1562. }
  1563. );
  1564. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1565. };
  1566. if let Some(ref apikey) = configuration.api_key {
  1567. let key = apikey.key.clone();
  1568. let val = match apikey.prefix {
  1569. Some(ref prefix) => format!("{} {}", prefix, key),
  1570. None => key,
  1571. };
  1572. auth_headers.insert("Sudo".to_owned(), val);
  1573. };
  1574. if let Some(ref apikey) = configuration.api_key {
  1575. let key = apikey.key.clone();
  1576. let val = match apikey.prefix {
  1577. Some(ref prefix) => format!("{} {}", prefix, key),
  1578. None => key,
  1579. };
  1580. auth_query.insert("sudo".to_owned(), val);
  1581. };
  1582. if let Some(ref apikey) = configuration.api_key {
  1583. let key = apikey.key.clone();
  1584. let val = match apikey.prefix {
  1585. Some(ref prefix) => format!("{} {}", prefix, key),
  1586. None => key,
  1587. };
  1588. auth_query.insert("token".to_owned(), val);
  1589. };
  1590. let method = hyper::Method::Delete;
  1591. let query_string = {
  1592. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1593. for (key, val) in &auth_query {
  1594. query.append_pair(key, val);
  1595. }
  1596. query.finish()
  1597. };
  1598. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/subscriptions/{user}?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index, user=user);
  1599. // TODO(farcaller): handle error
  1600. // if let Err(e) = uri {
  1601. // return Box::new(futures::future::err(e));
  1602. // }
  1603. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1604. let mut req = hyper::Request::new(method, uri);
  1605. if let Some(ref user_agent) = configuration.user_agent {
  1606. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1607. }
  1608. for (key, val) in auth_headers {
  1609. req.headers_mut().set_raw(key, val);
  1610. }
  1611. // send request
  1612. Box::new(
  1613. configuration.client.request(req)
  1614. .map_err(|e| Error::from(e))
  1615. .and_then(|resp| {
  1616. let status = resp.status();
  1617. resp.body().concat2()
  1618. .and_then(move |body| Ok((status, body)))
  1619. .map_err(|e| Error::from(e))
  1620. })
  1621. .and_then(|(status, body)| {
  1622. if status.is_success() {
  1623. Ok(body)
  1624. } else {
  1625. Err(Error::from((status, &*body)))
  1626. }
  1627. })
  1628. .and_then(|_| futures::future::ok(()))
  1629. )
  1630. }
  1631. fn issue_delete_time(&self, owner: &str, repo: &str, index: i64, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  1632. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1633. let mut auth_headers = HashMap::<String, String>::new();
  1634. let mut auth_query = HashMap::<String, String>::new();
  1635. if let Some(ref apikey) = configuration.api_key {
  1636. let key = apikey.key.clone();
  1637. let val = match apikey.prefix {
  1638. Some(ref prefix) => format!("{} {}", prefix, key),
  1639. None => key,
  1640. };
  1641. auth_query.insert("access_token".to_owned(), val);
  1642. };
  1643. if let Some(ref apikey) = configuration.api_key {
  1644. let key = apikey.key.clone();
  1645. let val = match apikey.prefix {
  1646. Some(ref prefix) => format!("{} {}", prefix, key),
  1647. None => key,
  1648. };
  1649. auth_headers.insert("Authorization".to_owned(), val);
  1650. };
  1651. if let Some(ref auth_conf) = configuration.basic_auth {
  1652. let auth = hyper::header::Authorization(
  1653. hyper::header::Basic {
  1654. username: auth_conf.0.to_owned(),
  1655. password: auth_conf.1.to_owned(),
  1656. }
  1657. );
  1658. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1659. };
  1660. if let Some(ref apikey) = configuration.api_key {
  1661. let key = apikey.key.clone();
  1662. let val = match apikey.prefix {
  1663. Some(ref prefix) => format!("{} {}", prefix, key),
  1664. None => key,
  1665. };
  1666. auth_headers.insert("Sudo".to_owned(), val);
  1667. };
  1668. if let Some(ref apikey) = configuration.api_key {
  1669. let key = apikey.key.clone();
  1670. let val = match apikey.prefix {
  1671. Some(ref prefix) => format!("{} {}", prefix, key),
  1672. None => key,
  1673. };
  1674. auth_query.insert("sudo".to_owned(), val);
  1675. };
  1676. if let Some(ref apikey) = configuration.api_key {
  1677. let key = apikey.key.clone();
  1678. let val = match apikey.prefix {
  1679. Some(ref prefix) => format!("{} {}", prefix, key),
  1680. None => key,
  1681. };
  1682. auth_query.insert("token".to_owned(), val);
  1683. };
  1684. let method = hyper::Method::Delete;
  1685. let query_string = {
  1686. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1687. for (key, val) in &auth_query {
  1688. query.append_pair(key, val);
  1689. }
  1690. query.finish()
  1691. };
  1692. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/times/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index, id=id);
  1693. // TODO(farcaller): handle error
  1694. // if let Err(e) = uri {
  1695. // return Box::new(futures::future::err(e));
  1696. // }
  1697. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1698. let mut req = hyper::Request::new(method, uri);
  1699. if let Some(ref user_agent) = configuration.user_agent {
  1700. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1701. }
  1702. for (key, val) in auth_headers {
  1703. req.headers_mut().set_raw(key, val);
  1704. }
  1705. // send request
  1706. Box::new(
  1707. configuration.client.request(req)
  1708. .map_err(|e| Error::from(e))
  1709. .and_then(|resp| {
  1710. let status = resp.status();
  1711. resp.body().concat2()
  1712. .and_then(move |body| Ok((status, body)))
  1713. .map_err(|e| Error::from(e))
  1714. })
  1715. .and_then(|(status, body)| {
  1716. if status.is_success() {
  1717. Ok(body)
  1718. } else {
  1719. Err(Error::from((status, &*body)))
  1720. }
  1721. })
  1722. .and_then(|_| futures::future::ok(()))
  1723. )
  1724. }
  1725. fn issue_edit_comment(&self, owner: &str, repo: &str, id: i64, body: ::models::EditIssueCommentOption) -> Box<Future<Item = ::models::Comment, Error = Error<serde_json::Value>>> {
  1726. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1727. let mut auth_headers = HashMap::<String, String>::new();
  1728. let mut auth_query = HashMap::<String, String>::new();
  1729. if let Some(ref apikey) = configuration.api_key {
  1730. let key = apikey.key.clone();
  1731. let val = match apikey.prefix {
  1732. Some(ref prefix) => format!("{} {}", prefix, key),
  1733. None => key,
  1734. };
  1735. auth_query.insert("access_token".to_owned(), val);
  1736. };
  1737. if let Some(ref apikey) = configuration.api_key {
  1738. let key = apikey.key.clone();
  1739. let val = match apikey.prefix {
  1740. Some(ref prefix) => format!("{} {}", prefix, key),
  1741. None => key,
  1742. };
  1743. auth_headers.insert("Authorization".to_owned(), val);
  1744. };
  1745. if let Some(ref auth_conf) = configuration.basic_auth {
  1746. let auth = hyper::header::Authorization(
  1747. hyper::header::Basic {
  1748. username: auth_conf.0.to_owned(),
  1749. password: auth_conf.1.to_owned(),
  1750. }
  1751. );
  1752. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1753. };
  1754. if let Some(ref apikey) = configuration.api_key {
  1755. let key = apikey.key.clone();
  1756. let val = match apikey.prefix {
  1757. Some(ref prefix) => format!("{} {}", prefix, key),
  1758. None => key,
  1759. };
  1760. auth_headers.insert("Sudo".to_owned(), val);
  1761. };
  1762. if let Some(ref apikey) = configuration.api_key {
  1763. let key = apikey.key.clone();
  1764. let val = match apikey.prefix {
  1765. Some(ref prefix) => format!("{} {}", prefix, key),
  1766. None => key,
  1767. };
  1768. auth_query.insert("sudo".to_owned(), val);
  1769. };
  1770. if let Some(ref apikey) = configuration.api_key {
  1771. let key = apikey.key.clone();
  1772. let val = match apikey.prefix {
  1773. Some(ref prefix) => format!("{} {}", prefix, key),
  1774. None => key,
  1775. };
  1776. auth_query.insert("token".to_owned(), val);
  1777. };
  1778. let method = hyper::Method::Patch;
  1779. let query_string = {
  1780. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1781. for (key, val) in &auth_query {
  1782. query.append_pair(key, val);
  1783. }
  1784. query.finish()
  1785. };
  1786. let uri_str = format!("{}/repos/{owner}/{repo}/issues/comments/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  1787. // TODO(farcaller): handle error
  1788. // if let Err(e) = uri {
  1789. // return Box::new(futures::future::err(e));
  1790. // }
  1791. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1792. let mut req = hyper::Request::new(method, uri);
  1793. if let Some(ref user_agent) = configuration.user_agent {
  1794. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1795. }
  1796. for (key, val) in auth_headers {
  1797. req.headers_mut().set_raw(key, val);
  1798. }
  1799. let serialized = serde_json::to_string(&body).unwrap();
  1800. req.headers_mut().set(hyper::header::ContentType::json());
  1801. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  1802. req.set_body(serialized);
  1803. // send request
  1804. Box::new(
  1805. configuration.client.request(req)
  1806. .map_err(|e| Error::from(e))
  1807. .and_then(|resp| {
  1808. let status = resp.status();
  1809. resp.body().concat2()
  1810. .and_then(move |body| Ok((status, body)))
  1811. .map_err(|e| Error::from(e))
  1812. })
  1813. .and_then(|(status, body)| {
  1814. if status.is_success() {
  1815. Ok(body)
  1816. } else {
  1817. Err(Error::from((status, &*body)))
  1818. }
  1819. })
  1820. .and_then(|body| {
  1821. let parsed: Result<::models::Comment, _> = serde_json::from_slice(&body);
  1822. parsed.map_err(|e| Error::from(e))
  1823. })
  1824. )
  1825. }
  1826. fn issue_edit_comment_deprecated(&self, owner: &str, repo: &str, index: i32, id: i64, body: ::models::EditIssueCommentOption) -> Box<Future<Item = ::models::Comment, Error = Error<serde_json::Value>>> {
  1827. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1828. let mut auth_headers = HashMap::<String, String>::new();
  1829. let mut auth_query = HashMap::<String, String>::new();
  1830. if let Some(ref apikey) = configuration.api_key {
  1831. let key = apikey.key.clone();
  1832. let val = match apikey.prefix {
  1833. Some(ref prefix) => format!("{} {}", prefix, key),
  1834. None => key,
  1835. };
  1836. auth_query.insert("access_token".to_owned(), val);
  1837. };
  1838. if let Some(ref apikey) = configuration.api_key {
  1839. let key = apikey.key.clone();
  1840. let val = match apikey.prefix {
  1841. Some(ref prefix) => format!("{} {}", prefix, key),
  1842. None => key,
  1843. };
  1844. auth_headers.insert("Authorization".to_owned(), val);
  1845. };
  1846. if let Some(ref auth_conf) = configuration.basic_auth {
  1847. let auth = hyper::header::Authorization(
  1848. hyper::header::Basic {
  1849. username: auth_conf.0.to_owned(),
  1850. password: auth_conf.1.to_owned(),
  1851. }
  1852. );
  1853. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1854. };
  1855. if let Some(ref apikey) = configuration.api_key {
  1856. let key = apikey.key.clone();
  1857. let val = match apikey.prefix {
  1858. Some(ref prefix) => format!("{} {}", prefix, key),
  1859. None => key,
  1860. };
  1861. auth_headers.insert("Sudo".to_owned(), val);
  1862. };
  1863. if let Some(ref apikey) = configuration.api_key {
  1864. let key = apikey.key.clone();
  1865. let val = match apikey.prefix {
  1866. Some(ref prefix) => format!("{} {}", prefix, key),
  1867. None => key,
  1868. };
  1869. auth_query.insert("sudo".to_owned(), val);
  1870. };
  1871. if let Some(ref apikey) = configuration.api_key {
  1872. let key = apikey.key.clone();
  1873. let val = match apikey.prefix {
  1874. Some(ref prefix) => format!("{} {}", prefix, key),
  1875. None => key,
  1876. };
  1877. auth_query.insert("token".to_owned(), val);
  1878. };
  1879. let method = hyper::Method::Patch;
  1880. let query_string = {
  1881. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1882. for (key, val) in &auth_query {
  1883. query.append_pair(key, val);
  1884. }
  1885. query.finish()
  1886. };
  1887. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/comments/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index, id=id);
  1888. // TODO(farcaller): handle error
  1889. // if let Err(e) = uri {
  1890. // return Box::new(futures::future::err(e));
  1891. // }
  1892. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1893. let mut req = hyper::Request::new(method, uri);
  1894. if let Some(ref user_agent) = configuration.user_agent {
  1895. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1896. }
  1897. for (key, val) in auth_headers {
  1898. req.headers_mut().set_raw(key, val);
  1899. }
  1900. let serialized = serde_json::to_string(&body).unwrap();
  1901. req.headers_mut().set(hyper::header::ContentType::json());
  1902. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  1903. req.set_body(serialized);
  1904. // send request
  1905. Box::new(
  1906. configuration.client.request(req)
  1907. .map_err(|e| Error::from(e))
  1908. .and_then(|resp| {
  1909. let status = resp.status();
  1910. resp.body().concat2()
  1911. .and_then(move |body| Ok((status, body)))
  1912. .map_err(|e| Error::from(e))
  1913. })
  1914. .and_then(|(status, body)| {
  1915. if status.is_success() {
  1916. Ok(body)
  1917. } else {
  1918. Err(Error::from((status, &*body)))
  1919. }
  1920. })
  1921. .and_then(|body| {
  1922. let parsed: Result<::models::Comment, _> = serde_json::from_slice(&body);
  1923. parsed.map_err(|e| Error::from(e))
  1924. })
  1925. )
  1926. }
  1927. fn issue_edit_issue(&self, owner: &str, repo: &str, index: i64, body: ::models::EditIssueOption) -> Box<Future<Item = ::models::Issue, Error = Error<serde_json::Value>>> {
  1928. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1929. let mut auth_headers = HashMap::<String, String>::new();
  1930. let mut auth_query = HashMap::<String, String>::new();
  1931. if let Some(ref apikey) = configuration.api_key {
  1932. let key = apikey.key.clone();
  1933. let val = match apikey.prefix {
  1934. Some(ref prefix) => format!("{} {}", prefix, key),
  1935. None => key,
  1936. };
  1937. auth_query.insert("access_token".to_owned(), val);
  1938. };
  1939. if let Some(ref apikey) = configuration.api_key {
  1940. let key = apikey.key.clone();
  1941. let val = match apikey.prefix {
  1942. Some(ref prefix) => format!("{} {}", prefix, key),
  1943. None => key,
  1944. };
  1945. auth_headers.insert("Authorization".to_owned(), val);
  1946. };
  1947. if let Some(ref auth_conf) = configuration.basic_auth {
  1948. let auth = hyper::header::Authorization(
  1949. hyper::header::Basic {
  1950. username: auth_conf.0.to_owned(),
  1951. password: auth_conf.1.to_owned(),
  1952. }
  1953. );
  1954. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1955. };
  1956. if let Some(ref apikey) = configuration.api_key {
  1957. let key = apikey.key.clone();
  1958. let val = match apikey.prefix {
  1959. Some(ref prefix) => format!("{} {}", prefix, key),
  1960. None => key,
  1961. };
  1962. auth_headers.insert("Sudo".to_owned(), val);
  1963. };
  1964. if let Some(ref apikey) = configuration.api_key {
  1965. let key = apikey.key.clone();
  1966. let val = match apikey.prefix {
  1967. Some(ref prefix) => format!("{} {}", prefix, key),
  1968. None => key,
  1969. };
  1970. auth_query.insert("sudo".to_owned(), val);
  1971. };
  1972. if let Some(ref apikey) = configuration.api_key {
  1973. let key = apikey.key.clone();
  1974. let val = match apikey.prefix {
  1975. Some(ref prefix) => format!("{} {}", prefix, key),
  1976. None => key,
  1977. };
  1978. auth_query.insert("token".to_owned(), val);
  1979. };
  1980. let method = hyper::Method::Patch;
  1981. let query_string = {
  1982. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1983. for (key, val) in &auth_query {
  1984. query.append_pair(key, val);
  1985. }
  1986. query.finish()
  1987. };
  1988. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  1989. // TODO(farcaller): handle error
  1990. // if let Err(e) = uri {
  1991. // return Box::new(futures::future::err(e));
  1992. // }
  1993. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1994. let mut req = hyper::Request::new(method, uri);
  1995. if let Some(ref user_agent) = configuration.user_agent {
  1996. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1997. }
  1998. for (key, val) in auth_headers {
  1999. req.headers_mut().set_raw(key, val);
  2000. }
  2001. let serialized = serde_json::to_string(&body).unwrap();
  2002. req.headers_mut().set(hyper::header::ContentType::json());
  2003. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  2004. req.set_body(serialized);
  2005. // send request
  2006. Box::new(
  2007. configuration.client.request(req)
  2008. .map_err(|e| Error::from(e))
  2009. .and_then(|resp| {
  2010. let status = resp.status();
  2011. resp.body().concat2()
  2012. .and_then(move |body| Ok((status, body)))
  2013. .map_err(|e| Error::from(e))
  2014. })
  2015. .and_then(|(status, body)| {
  2016. if status.is_success() {
  2017. Ok(body)
  2018. } else {
  2019. Err(Error::from((status, &*body)))
  2020. }
  2021. })
  2022. .and_then(|body| {
  2023. let parsed: Result<::models::Issue, _> = serde_json::from_slice(&body);
  2024. parsed.map_err(|e| Error::from(e))
  2025. })
  2026. )
  2027. }
  2028. fn issue_edit_issue_deadline(&self, owner: &str, repo: &str, index: i64, body: ::models::EditDeadlineOption) -> Box<Future<Item = ::models::IssueDeadline, Error = Error<serde_json::Value>>> {
  2029. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2030. let mut auth_headers = HashMap::<String, String>::new();
  2031. let mut auth_query = HashMap::<String, String>::new();
  2032. if let Some(ref apikey) = configuration.api_key {
  2033. let key = apikey.key.clone();
  2034. let val = match apikey.prefix {
  2035. Some(ref prefix) => format!("{} {}", prefix, key),
  2036. None => key,
  2037. };
  2038. auth_query.insert("access_token".to_owned(), val);
  2039. };
  2040. if let Some(ref apikey) = configuration.api_key {
  2041. let key = apikey.key.clone();
  2042. let val = match apikey.prefix {
  2043. Some(ref prefix) => format!("{} {}", prefix, key),
  2044. None => key,
  2045. };
  2046. auth_headers.insert("Authorization".to_owned(), val);
  2047. };
  2048. if let Some(ref auth_conf) = configuration.basic_auth {
  2049. let auth = hyper::header::Authorization(
  2050. hyper::header::Basic {
  2051. username: auth_conf.0.to_owned(),
  2052. password: auth_conf.1.to_owned(),
  2053. }
  2054. );
  2055. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2056. };
  2057. if let Some(ref apikey) = configuration.api_key {
  2058. let key = apikey.key.clone();
  2059. let val = match apikey.prefix {
  2060. Some(ref prefix) => format!("{} {}", prefix, key),
  2061. None => key,
  2062. };
  2063. auth_headers.insert("Sudo".to_owned(), val);
  2064. };
  2065. if let Some(ref apikey) = configuration.api_key {
  2066. let key = apikey.key.clone();
  2067. let val = match apikey.prefix {
  2068. Some(ref prefix) => format!("{} {}", prefix, key),
  2069. None => key,
  2070. };
  2071. auth_query.insert("sudo".to_owned(), val);
  2072. };
  2073. if let Some(ref apikey) = configuration.api_key {
  2074. let key = apikey.key.clone();
  2075. let val = match apikey.prefix {
  2076. Some(ref prefix) => format!("{} {}", prefix, key),
  2077. None => key,
  2078. };
  2079. auth_query.insert("token".to_owned(), val);
  2080. };
  2081. let method = hyper::Method::Post;
  2082. let query_string = {
  2083. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2084. for (key, val) in &auth_query {
  2085. query.append_pair(key, val);
  2086. }
  2087. query.finish()
  2088. };
  2089. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/deadline?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  2090. // TODO(farcaller): handle error
  2091. // if let Err(e) = uri {
  2092. // return Box::new(futures::future::err(e));
  2093. // }
  2094. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2095. let mut req = hyper::Request::new(method, uri);
  2096. if let Some(ref user_agent) = configuration.user_agent {
  2097. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2098. }
  2099. for (key, val) in auth_headers {
  2100. req.headers_mut().set_raw(key, val);
  2101. }
  2102. let serialized = serde_json::to_string(&body).unwrap();
  2103. req.headers_mut().set(hyper::header::ContentType::json());
  2104. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  2105. req.set_body(serialized);
  2106. // send request
  2107. Box::new(
  2108. configuration.client.request(req)
  2109. .map_err(|e| Error::from(e))
  2110. .and_then(|resp| {
  2111. let status = resp.status();
  2112. resp.body().concat2()
  2113. .and_then(move |body| Ok((status, body)))
  2114. .map_err(|e| Error::from(e))
  2115. })
  2116. .and_then(|(status, body)| {
  2117. if status.is_success() {
  2118. Ok(body)
  2119. } else {
  2120. Err(Error::from((status, &*body)))
  2121. }
  2122. })
  2123. .and_then(|body| {
  2124. let parsed: Result<::models::IssueDeadline, _> = serde_json::from_slice(&body);
  2125. parsed.map_err(|e| Error::from(e))
  2126. })
  2127. )
  2128. }
  2129. fn issue_edit_label(&self, owner: &str, repo: &str, id: i64, body: ::models::EditLabelOption) -> Box<Future<Item = ::models::Label, Error = Error<serde_json::Value>>> {
  2130. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2131. let mut auth_headers = HashMap::<String, String>::new();
  2132. let mut auth_query = HashMap::<String, String>::new();
  2133. if let Some(ref apikey) = configuration.api_key {
  2134. let key = apikey.key.clone();
  2135. let val = match apikey.prefix {
  2136. Some(ref prefix) => format!("{} {}", prefix, key),
  2137. None => key,
  2138. };
  2139. auth_query.insert("access_token".to_owned(), val);
  2140. };
  2141. if let Some(ref apikey) = configuration.api_key {
  2142. let key = apikey.key.clone();
  2143. let val = match apikey.prefix {
  2144. Some(ref prefix) => format!("{} {}", prefix, key),
  2145. None => key,
  2146. };
  2147. auth_headers.insert("Authorization".to_owned(), val);
  2148. };
  2149. if let Some(ref auth_conf) = configuration.basic_auth {
  2150. let auth = hyper::header::Authorization(
  2151. hyper::header::Basic {
  2152. username: auth_conf.0.to_owned(),
  2153. password: auth_conf.1.to_owned(),
  2154. }
  2155. );
  2156. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2157. };
  2158. if let Some(ref apikey) = configuration.api_key {
  2159. let key = apikey.key.clone();
  2160. let val = match apikey.prefix {
  2161. Some(ref prefix) => format!("{} {}", prefix, key),
  2162. None => key,
  2163. };
  2164. auth_headers.insert("Sudo".to_owned(), val);
  2165. };
  2166. if let Some(ref apikey) = configuration.api_key {
  2167. let key = apikey.key.clone();
  2168. let val = match apikey.prefix {
  2169. Some(ref prefix) => format!("{} {}", prefix, key),
  2170. None => key,
  2171. };
  2172. auth_query.insert("sudo".to_owned(), val);
  2173. };
  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("token".to_owned(), val);
  2181. };
  2182. let method = hyper::Method::Patch;
  2183. let query_string = {
  2184. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2185. for (key, val) in &auth_query {
  2186. query.append_pair(key, val);
  2187. }
  2188. query.finish()
  2189. };
  2190. let uri_str = format!("{}/repos/{owner}/{repo}/labels/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  2191. // TODO(farcaller): handle error
  2192. // if let Err(e) = uri {
  2193. // return Box::new(futures::future::err(e));
  2194. // }
  2195. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2196. let mut req = hyper::Request::new(method, uri);
  2197. if let Some(ref user_agent) = configuration.user_agent {
  2198. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2199. }
  2200. for (key, val) in auth_headers {
  2201. req.headers_mut().set_raw(key, val);
  2202. }
  2203. let serialized = serde_json::to_string(&body).unwrap();
  2204. req.headers_mut().set(hyper::header::ContentType::json());
  2205. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  2206. req.set_body(serialized);
  2207. // send request
  2208. Box::new(
  2209. configuration.client.request(req)
  2210. .map_err(|e| Error::from(e))
  2211. .and_then(|resp| {
  2212. let status = resp.status();
  2213. resp.body().concat2()
  2214. .and_then(move |body| Ok((status, body)))
  2215. .map_err(|e| Error::from(e))
  2216. })
  2217. .and_then(|(status, body)| {
  2218. if status.is_success() {
  2219. Ok(body)
  2220. } else {
  2221. Err(Error::from((status, &*body)))
  2222. }
  2223. })
  2224. .and_then(|body| {
  2225. let parsed: Result<::models::Label, _> = serde_json::from_slice(&body);
  2226. parsed.map_err(|e| Error::from(e))
  2227. })
  2228. )
  2229. }
  2230. fn issue_edit_milestone(&self, owner: &str, repo: &str, id: i64, body: ::models::EditMilestoneOption) -> Box<Future<Item = ::models::Milestone, Error = Error<serde_json::Value>>> {
  2231. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2232. let mut auth_headers = HashMap::<String, String>::new();
  2233. let mut auth_query = HashMap::<String, String>::new();
  2234. if let Some(ref apikey) = configuration.api_key {
  2235. let key = apikey.key.clone();
  2236. let val = match apikey.prefix {
  2237. Some(ref prefix) => format!("{} {}", prefix, key),
  2238. None => key,
  2239. };
  2240. auth_query.insert("access_token".to_owned(), val);
  2241. };
  2242. if let Some(ref apikey) = configuration.api_key {
  2243. let key = apikey.key.clone();
  2244. let val = match apikey.prefix {
  2245. Some(ref prefix) => format!("{} {}", prefix, key),
  2246. None => key,
  2247. };
  2248. auth_headers.insert("Authorization".to_owned(), val);
  2249. };
  2250. if let Some(ref auth_conf) = configuration.basic_auth {
  2251. let auth = hyper::header::Authorization(
  2252. hyper::header::Basic {
  2253. username: auth_conf.0.to_owned(),
  2254. password: auth_conf.1.to_owned(),
  2255. }
  2256. );
  2257. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2258. };
  2259. if let Some(ref apikey) = configuration.api_key {
  2260. let key = apikey.key.clone();
  2261. let val = match apikey.prefix {
  2262. Some(ref prefix) => format!("{} {}", prefix, key),
  2263. None => key,
  2264. };
  2265. auth_headers.insert("Sudo".to_owned(), val);
  2266. };
  2267. if let Some(ref apikey) = configuration.api_key {
  2268. let key = apikey.key.clone();
  2269. let val = match apikey.prefix {
  2270. Some(ref prefix) => format!("{} {}", prefix, key),
  2271. None => key,
  2272. };
  2273. auth_query.insert("sudo".to_owned(), val);
  2274. };
  2275. if let Some(ref apikey) = configuration.api_key {
  2276. let key = apikey.key.clone();
  2277. let val = match apikey.prefix {
  2278. Some(ref prefix) => format!("{} {}", prefix, key),
  2279. None => key,
  2280. };
  2281. auth_query.insert("token".to_owned(), val);
  2282. };
  2283. let method = hyper::Method::Patch;
  2284. let query_string = {
  2285. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2286. for (key, val) in &auth_query {
  2287. query.append_pair(key, val);
  2288. }
  2289. query.finish()
  2290. };
  2291. let uri_str = format!("{}/repos/{owner}/{repo}/milestones/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  2292. // TODO(farcaller): handle error
  2293. // if let Err(e) = uri {
  2294. // return Box::new(futures::future::err(e));
  2295. // }
  2296. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2297. let mut req = hyper::Request::new(method, uri);
  2298. if let Some(ref user_agent) = configuration.user_agent {
  2299. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2300. }
  2301. for (key, val) in auth_headers {
  2302. req.headers_mut().set_raw(key, val);
  2303. }
  2304. let serialized = serde_json::to_string(&body).unwrap();
  2305. req.headers_mut().set(hyper::header::ContentType::json());
  2306. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  2307. req.set_body(serialized);
  2308. // send request
  2309. Box::new(
  2310. configuration.client.request(req)
  2311. .map_err(|e| Error::from(e))
  2312. .and_then(|resp| {
  2313. let status = resp.status();
  2314. resp.body().concat2()
  2315. .and_then(move |body| Ok((status, body)))
  2316. .map_err(|e| Error::from(e))
  2317. })
  2318. .and_then(|(status, body)| {
  2319. if status.is_success() {
  2320. Ok(body)
  2321. } else {
  2322. Err(Error::from((status, &*body)))
  2323. }
  2324. })
  2325. .and_then(|body| {
  2326. let parsed: Result<::models::Milestone, _> = serde_json::from_slice(&body);
  2327. parsed.map_err(|e| Error::from(e))
  2328. })
  2329. )
  2330. }
  2331. fn issue_get_comment_reactions(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = Vec<::models::Reaction>, Error = Error<serde_json::Value>>> {
  2332. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2333. let mut auth_headers = HashMap::<String, String>::new();
  2334. let mut auth_query = HashMap::<String, String>::new();
  2335. if let Some(ref apikey) = configuration.api_key {
  2336. let key = apikey.key.clone();
  2337. let val = match apikey.prefix {
  2338. Some(ref prefix) => format!("{} {}", prefix, key),
  2339. None => key,
  2340. };
  2341. auth_query.insert("access_token".to_owned(), val);
  2342. };
  2343. if let Some(ref apikey) = configuration.api_key {
  2344. let key = apikey.key.clone();
  2345. let val = match apikey.prefix {
  2346. Some(ref prefix) => format!("{} {}", prefix, key),
  2347. None => key,
  2348. };
  2349. auth_headers.insert("Authorization".to_owned(), val);
  2350. };
  2351. if let Some(ref auth_conf) = configuration.basic_auth {
  2352. let auth = hyper::header::Authorization(
  2353. hyper::header::Basic {
  2354. username: auth_conf.0.to_owned(),
  2355. password: auth_conf.1.to_owned(),
  2356. }
  2357. );
  2358. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2359. };
  2360. if let Some(ref apikey) = configuration.api_key {
  2361. let key = apikey.key.clone();
  2362. let val = match apikey.prefix {
  2363. Some(ref prefix) => format!("{} {}", prefix, key),
  2364. None => key,
  2365. };
  2366. auth_headers.insert("Sudo".to_owned(), val);
  2367. };
  2368. if let Some(ref apikey) = configuration.api_key {
  2369. let key = apikey.key.clone();
  2370. let val = match apikey.prefix {
  2371. Some(ref prefix) => format!("{} {}", prefix, key),
  2372. None => key,
  2373. };
  2374. auth_query.insert("sudo".to_owned(), val);
  2375. };
  2376. if let Some(ref apikey) = configuration.api_key {
  2377. let key = apikey.key.clone();
  2378. let val = match apikey.prefix {
  2379. Some(ref prefix) => format!("{} {}", prefix, key),
  2380. None => key,
  2381. };
  2382. auth_query.insert("token".to_owned(), val);
  2383. };
  2384. let method = hyper::Method::Get;
  2385. let query_string = {
  2386. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2387. for (key, val) in &auth_query {
  2388. query.append_pair(key, val);
  2389. }
  2390. query.finish()
  2391. };
  2392. let uri_str = format!("{}/repos/{owner}/{repo}/issues/comments/{id}/reactions?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  2393. // TODO(farcaller): handle error
  2394. // if let Err(e) = uri {
  2395. // return Box::new(futures::future::err(e));
  2396. // }
  2397. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2398. let mut req = hyper::Request::new(method, uri);
  2399. if let Some(ref user_agent) = configuration.user_agent {
  2400. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2401. }
  2402. for (key, val) in auth_headers {
  2403. req.headers_mut().set_raw(key, val);
  2404. }
  2405. // send request
  2406. Box::new(
  2407. configuration.client.request(req)
  2408. .map_err(|e| Error::from(e))
  2409. .and_then(|resp| {
  2410. let status = resp.status();
  2411. resp.body().concat2()
  2412. .and_then(move |body| Ok((status, body)))
  2413. .map_err(|e| Error::from(e))
  2414. })
  2415. .and_then(|(status, body)| {
  2416. if status.is_success() {
  2417. Ok(body)
  2418. } else {
  2419. Err(Error::from((status, &*body)))
  2420. }
  2421. })
  2422. .and_then(|body| {
  2423. let parsed: Result<Vec<::models::Reaction>, _> = serde_json::from_slice(&body);
  2424. parsed.map_err(|e| Error::from(e))
  2425. })
  2426. )
  2427. }
  2428. fn issue_get_comments(&self, owner: &str, repo: &str, index: i64, since: &str) -> Box<Future<Item = Vec<::models::Comment>, Error = Error<serde_json::Value>>> {
  2429. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2430. let mut auth_headers = HashMap::<String, String>::new();
  2431. let mut auth_query = HashMap::<String, String>::new();
  2432. if let Some(ref apikey) = configuration.api_key {
  2433. let key = apikey.key.clone();
  2434. let val = match apikey.prefix {
  2435. Some(ref prefix) => format!("{} {}", prefix, key),
  2436. None => key,
  2437. };
  2438. auth_query.insert("access_token".to_owned(), val);
  2439. };
  2440. if let Some(ref apikey) = configuration.api_key {
  2441. let key = apikey.key.clone();
  2442. let val = match apikey.prefix {
  2443. Some(ref prefix) => format!("{} {}", prefix, key),
  2444. None => key,
  2445. };
  2446. auth_headers.insert("Authorization".to_owned(), val);
  2447. };
  2448. if let Some(ref auth_conf) = configuration.basic_auth {
  2449. let auth = hyper::header::Authorization(
  2450. hyper::header::Basic {
  2451. username: auth_conf.0.to_owned(),
  2452. password: auth_conf.1.to_owned(),
  2453. }
  2454. );
  2455. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2456. };
  2457. if let Some(ref apikey) = configuration.api_key {
  2458. let key = apikey.key.clone();
  2459. let val = match apikey.prefix {
  2460. Some(ref prefix) => format!("{} {}", prefix, key),
  2461. None => key,
  2462. };
  2463. auth_headers.insert("Sudo".to_owned(), val);
  2464. };
  2465. if let Some(ref apikey) = configuration.api_key {
  2466. let key = apikey.key.clone();
  2467. let val = match apikey.prefix {
  2468. Some(ref prefix) => format!("{} {}", prefix, key),
  2469. None => key,
  2470. };
  2471. auth_query.insert("sudo".to_owned(), val);
  2472. };
  2473. if let Some(ref apikey) = configuration.api_key {
  2474. let key = apikey.key.clone();
  2475. let val = match apikey.prefix {
  2476. Some(ref prefix) => format!("{} {}", prefix, key),
  2477. None => key,
  2478. };
  2479. auth_query.insert("token".to_owned(), val);
  2480. };
  2481. let method = hyper::Method::Get;
  2482. let query_string = {
  2483. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2484. query.append_pair("since", &since.to_string());
  2485. for (key, val) in &auth_query {
  2486. query.append_pair(key, val);
  2487. }
  2488. query.finish()
  2489. };
  2490. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/comments?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  2491. // TODO(farcaller): handle error
  2492. // if let Err(e) = uri {
  2493. // return Box::new(futures::future::err(e));
  2494. // }
  2495. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2496. let mut req = hyper::Request::new(method, uri);
  2497. if let Some(ref user_agent) = configuration.user_agent {
  2498. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2499. }
  2500. for (key, val) in auth_headers {
  2501. req.headers_mut().set_raw(key, val);
  2502. }
  2503. // send request
  2504. Box::new(
  2505. configuration.client.request(req)
  2506. .map_err(|e| Error::from(e))
  2507. .and_then(|resp| {
  2508. let status = resp.status();
  2509. resp.body().concat2()
  2510. .and_then(move |body| Ok((status, body)))
  2511. .map_err(|e| Error::from(e))
  2512. })
  2513. .and_then(|(status, body)| {
  2514. if status.is_success() {
  2515. Ok(body)
  2516. } else {
  2517. Err(Error::from((status, &*body)))
  2518. }
  2519. })
  2520. .and_then(|body| {
  2521. let parsed: Result<Vec<::models::Comment>, _> = serde_json::from_slice(&body);
  2522. parsed.map_err(|e| Error::from(e))
  2523. })
  2524. )
  2525. }
  2526. fn issue_get_issue(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = ::models::Issue, Error = Error<serde_json::Value>>> {
  2527. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2528. let mut auth_headers = HashMap::<String, String>::new();
  2529. let mut auth_query = HashMap::<String, String>::new();
  2530. if let Some(ref apikey) = configuration.api_key {
  2531. let key = apikey.key.clone();
  2532. let val = match apikey.prefix {
  2533. Some(ref prefix) => format!("{} {}", prefix, key),
  2534. None => key,
  2535. };
  2536. auth_query.insert("access_token".to_owned(), val);
  2537. };
  2538. if let Some(ref apikey) = configuration.api_key {
  2539. let key = apikey.key.clone();
  2540. let val = match apikey.prefix {
  2541. Some(ref prefix) => format!("{} {}", prefix, key),
  2542. None => key,
  2543. };
  2544. auth_headers.insert("Authorization".to_owned(), val);
  2545. };
  2546. if let Some(ref auth_conf) = configuration.basic_auth {
  2547. let auth = hyper::header::Authorization(
  2548. hyper::header::Basic {
  2549. username: auth_conf.0.to_owned(),
  2550. password: auth_conf.1.to_owned(),
  2551. }
  2552. );
  2553. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2554. };
  2555. if let Some(ref apikey) = configuration.api_key {
  2556. let key = apikey.key.clone();
  2557. let val = match apikey.prefix {
  2558. Some(ref prefix) => format!("{} {}", prefix, key),
  2559. None => key,
  2560. };
  2561. auth_headers.insert("Sudo".to_owned(), val);
  2562. };
  2563. if let Some(ref apikey) = configuration.api_key {
  2564. let key = apikey.key.clone();
  2565. let val = match apikey.prefix {
  2566. Some(ref prefix) => format!("{} {}", prefix, key),
  2567. None => key,
  2568. };
  2569. auth_query.insert("sudo".to_owned(), val);
  2570. };
  2571. if let Some(ref apikey) = configuration.api_key {
  2572. let key = apikey.key.clone();
  2573. let val = match apikey.prefix {
  2574. Some(ref prefix) => format!("{} {}", prefix, key),
  2575. None => key,
  2576. };
  2577. auth_query.insert("token".to_owned(), val);
  2578. };
  2579. let method = hyper::Method::Get;
  2580. let query_string = {
  2581. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2582. for (key, val) in &auth_query {
  2583. query.append_pair(key, val);
  2584. }
  2585. query.finish()
  2586. };
  2587. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  2588. // TODO(farcaller): handle error
  2589. // if let Err(e) = uri {
  2590. // return Box::new(futures::future::err(e));
  2591. // }
  2592. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2593. let mut req = hyper::Request::new(method, uri);
  2594. if let Some(ref user_agent) = configuration.user_agent {
  2595. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2596. }
  2597. for (key, val) in auth_headers {
  2598. req.headers_mut().set_raw(key, val);
  2599. }
  2600. // send request
  2601. Box::new(
  2602. configuration.client.request(req)
  2603. .map_err(|e| Error::from(e))
  2604. .and_then(|resp| {
  2605. let status = resp.status();
  2606. resp.body().concat2()
  2607. .and_then(move |body| Ok((status, body)))
  2608. .map_err(|e| Error::from(e))
  2609. })
  2610. .and_then(|(status, body)| {
  2611. if status.is_success() {
  2612. Ok(body)
  2613. } else {
  2614. Err(Error::from((status, &*body)))
  2615. }
  2616. })
  2617. .and_then(|body| {
  2618. let parsed: Result<::models::Issue, _> = serde_json::from_slice(&body);
  2619. parsed.map_err(|e| Error::from(e))
  2620. })
  2621. )
  2622. }
  2623. fn issue_get_issue_reactions(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = Vec<::models::Reaction>, Error = Error<serde_json::Value>>> {
  2624. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2625. let mut auth_headers = HashMap::<String, String>::new();
  2626. let mut auth_query = HashMap::<String, String>::new();
  2627. if let Some(ref apikey) = configuration.api_key {
  2628. let key = apikey.key.clone();
  2629. let val = match apikey.prefix {
  2630. Some(ref prefix) => format!("{} {}", prefix, key),
  2631. None => key,
  2632. };
  2633. auth_query.insert("access_token".to_owned(), val);
  2634. };
  2635. if let Some(ref apikey) = configuration.api_key {
  2636. let key = apikey.key.clone();
  2637. let val = match apikey.prefix {
  2638. Some(ref prefix) => format!("{} {}", prefix, key),
  2639. None => key,
  2640. };
  2641. auth_headers.insert("Authorization".to_owned(), val);
  2642. };
  2643. if let Some(ref auth_conf) = configuration.basic_auth {
  2644. let auth = hyper::header::Authorization(
  2645. hyper::header::Basic {
  2646. username: auth_conf.0.to_owned(),
  2647. password: auth_conf.1.to_owned(),
  2648. }
  2649. );
  2650. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2651. };
  2652. if let Some(ref apikey) = configuration.api_key {
  2653. let key = apikey.key.clone();
  2654. let val = match apikey.prefix {
  2655. Some(ref prefix) => format!("{} {}", prefix, key),
  2656. None => key,
  2657. };
  2658. auth_headers.insert("Sudo".to_owned(), val);
  2659. };
  2660. if let Some(ref apikey) = configuration.api_key {
  2661. let key = apikey.key.clone();
  2662. let val = match apikey.prefix {
  2663. Some(ref prefix) => format!("{} {}", prefix, key),
  2664. None => key,
  2665. };
  2666. auth_query.insert("sudo".to_owned(), val);
  2667. };
  2668. if let Some(ref apikey) = configuration.api_key {
  2669. let key = apikey.key.clone();
  2670. let val = match apikey.prefix {
  2671. Some(ref prefix) => format!("{} {}", prefix, key),
  2672. None => key,
  2673. };
  2674. auth_query.insert("token".to_owned(), val);
  2675. };
  2676. let method = hyper::Method::Get;
  2677. let query_string = {
  2678. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2679. for (key, val) in &auth_query {
  2680. query.append_pair(key, val);
  2681. }
  2682. query.finish()
  2683. };
  2684. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/reactions?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  2685. // TODO(farcaller): handle error
  2686. // if let Err(e) = uri {
  2687. // return Box::new(futures::future::err(e));
  2688. // }
  2689. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2690. let mut req = hyper::Request::new(method, uri);
  2691. if let Some(ref user_agent) = configuration.user_agent {
  2692. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2693. }
  2694. for (key, val) in auth_headers {
  2695. req.headers_mut().set_raw(key, val);
  2696. }
  2697. // send request
  2698. Box::new(
  2699. configuration.client.request(req)
  2700. .map_err(|e| Error::from(e))
  2701. .and_then(|resp| {
  2702. let status = resp.status();
  2703. resp.body().concat2()
  2704. .and_then(move |body| Ok((status, body)))
  2705. .map_err(|e| Error::from(e))
  2706. })
  2707. .and_then(|(status, body)| {
  2708. if status.is_success() {
  2709. Ok(body)
  2710. } else {
  2711. Err(Error::from((status, &*body)))
  2712. }
  2713. })
  2714. .and_then(|body| {
  2715. let parsed: Result<Vec<::models::Reaction>, _> = serde_json::from_slice(&body);
  2716. parsed.map_err(|e| Error::from(e))
  2717. })
  2718. )
  2719. }
  2720. fn issue_get_label(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = ::models::Label, Error = Error<serde_json::Value>>> {
  2721. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2722. let mut auth_headers = HashMap::<String, String>::new();
  2723. let mut auth_query = HashMap::<String, String>::new();
  2724. if let Some(ref apikey) = configuration.api_key {
  2725. let key = apikey.key.clone();
  2726. let val = match apikey.prefix {
  2727. Some(ref prefix) => format!("{} {}", prefix, key),
  2728. None => key,
  2729. };
  2730. auth_query.insert("access_token".to_owned(), val);
  2731. };
  2732. if let Some(ref apikey) = configuration.api_key {
  2733. let key = apikey.key.clone();
  2734. let val = match apikey.prefix {
  2735. Some(ref prefix) => format!("{} {}", prefix, key),
  2736. None => key,
  2737. };
  2738. auth_headers.insert("Authorization".to_owned(), val);
  2739. };
  2740. if let Some(ref auth_conf) = configuration.basic_auth {
  2741. let auth = hyper::header::Authorization(
  2742. hyper::header::Basic {
  2743. username: auth_conf.0.to_owned(),
  2744. password: auth_conf.1.to_owned(),
  2745. }
  2746. );
  2747. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2748. };
  2749. if let Some(ref apikey) = configuration.api_key {
  2750. let key = apikey.key.clone();
  2751. let val = match apikey.prefix {
  2752. Some(ref prefix) => format!("{} {}", prefix, key),
  2753. None => key,
  2754. };
  2755. auth_headers.insert("Sudo".to_owned(), val);
  2756. };
  2757. if let Some(ref apikey) = configuration.api_key {
  2758. let key = apikey.key.clone();
  2759. let val = match apikey.prefix {
  2760. Some(ref prefix) => format!("{} {}", prefix, key),
  2761. None => key,
  2762. };
  2763. auth_query.insert("sudo".to_owned(), val);
  2764. };
  2765. if let Some(ref apikey) = configuration.api_key {
  2766. let key = apikey.key.clone();
  2767. let val = match apikey.prefix {
  2768. Some(ref prefix) => format!("{} {}", prefix, key),
  2769. None => key,
  2770. };
  2771. auth_query.insert("token".to_owned(), val);
  2772. };
  2773. let method = hyper::Method::Get;
  2774. let query_string = {
  2775. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2776. for (key, val) in &auth_query {
  2777. query.append_pair(key, val);
  2778. }
  2779. query.finish()
  2780. };
  2781. let uri_str = format!("{}/repos/{owner}/{repo}/labels/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  2782. // TODO(farcaller): handle error
  2783. // if let Err(e) = uri {
  2784. // return Box::new(futures::future::err(e));
  2785. // }
  2786. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2787. let mut req = hyper::Request::new(method, uri);
  2788. if let Some(ref user_agent) = configuration.user_agent {
  2789. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2790. }
  2791. for (key, val) in auth_headers {
  2792. req.headers_mut().set_raw(key, val);
  2793. }
  2794. // send request
  2795. Box::new(
  2796. configuration.client.request(req)
  2797. .map_err(|e| Error::from(e))
  2798. .and_then(|resp| {
  2799. let status = resp.status();
  2800. resp.body().concat2()
  2801. .and_then(move |body| Ok((status, body)))
  2802. .map_err(|e| Error::from(e))
  2803. })
  2804. .and_then(|(status, body)| {
  2805. if status.is_success() {
  2806. Ok(body)
  2807. } else {
  2808. Err(Error::from((status, &*body)))
  2809. }
  2810. })
  2811. .and_then(|body| {
  2812. let parsed: Result<::models::Label, _> = serde_json::from_slice(&body);
  2813. parsed.map_err(|e| Error::from(e))
  2814. })
  2815. )
  2816. }
  2817. fn issue_get_labels(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = Vec<::models::Label>, Error = Error<serde_json::Value>>> {
  2818. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2819. let mut auth_headers = HashMap::<String, String>::new();
  2820. let mut auth_query = HashMap::<String, String>::new();
  2821. if let Some(ref apikey) = configuration.api_key {
  2822. let key = apikey.key.clone();
  2823. let val = match apikey.prefix {
  2824. Some(ref prefix) => format!("{} {}", prefix, key),
  2825. None => key,
  2826. };
  2827. auth_query.insert("access_token".to_owned(), val);
  2828. };
  2829. if let Some(ref apikey) = configuration.api_key {
  2830. let key = apikey.key.clone();
  2831. let val = match apikey.prefix {
  2832. Some(ref prefix) => format!("{} {}", prefix, key),
  2833. None => key,
  2834. };
  2835. auth_headers.insert("Authorization".to_owned(), val);
  2836. };
  2837. if let Some(ref auth_conf) = configuration.basic_auth {
  2838. let auth = hyper::header::Authorization(
  2839. hyper::header::Basic {
  2840. username: auth_conf.0.to_owned(),
  2841. password: auth_conf.1.to_owned(),
  2842. }
  2843. );
  2844. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2845. };
  2846. if let Some(ref apikey) = configuration.api_key {
  2847. let key = apikey.key.clone();
  2848. let val = match apikey.prefix {
  2849. Some(ref prefix) => format!("{} {}", prefix, key),
  2850. None => key,
  2851. };
  2852. auth_headers.insert("Sudo".to_owned(), val);
  2853. };
  2854. if let Some(ref apikey) = configuration.api_key {
  2855. let key = apikey.key.clone();
  2856. let val = match apikey.prefix {
  2857. Some(ref prefix) => format!("{} {}", prefix, key),
  2858. None => key,
  2859. };
  2860. auth_query.insert("sudo".to_owned(), val);
  2861. };
  2862. if let Some(ref apikey) = configuration.api_key {
  2863. let key = apikey.key.clone();
  2864. let val = match apikey.prefix {
  2865. Some(ref prefix) => format!("{} {}", prefix, key),
  2866. None => key,
  2867. };
  2868. auth_query.insert("token".to_owned(), val);
  2869. };
  2870. let method = hyper::Method::Get;
  2871. let query_string = {
  2872. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2873. for (key, val) in &auth_query {
  2874. query.append_pair(key, val);
  2875. }
  2876. query.finish()
  2877. };
  2878. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/labels?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  2879. // TODO(farcaller): handle error
  2880. // if let Err(e) = uri {
  2881. // return Box::new(futures::future::err(e));
  2882. // }
  2883. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2884. let mut req = hyper::Request::new(method, uri);
  2885. if let Some(ref user_agent) = configuration.user_agent {
  2886. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2887. }
  2888. for (key, val) in auth_headers {
  2889. req.headers_mut().set_raw(key, val);
  2890. }
  2891. // send request
  2892. Box::new(
  2893. configuration.client.request(req)
  2894. .map_err(|e| Error::from(e))
  2895. .and_then(|resp| {
  2896. let status = resp.status();
  2897. resp.body().concat2()
  2898. .and_then(move |body| Ok((status, body)))
  2899. .map_err(|e| Error::from(e))
  2900. })
  2901. .and_then(|(status, body)| {
  2902. if status.is_success() {
  2903. Ok(body)
  2904. } else {
  2905. Err(Error::from((status, &*body)))
  2906. }
  2907. })
  2908. .and_then(|body| {
  2909. let parsed: Result<Vec<::models::Label>, _> = serde_json::from_slice(&body);
  2910. parsed.map_err(|e| Error::from(e))
  2911. })
  2912. )
  2913. }
  2914. fn issue_get_milestone(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = ::models::Milestone, Error = Error<serde_json::Value>>> {
  2915. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2916. let mut auth_headers = HashMap::<String, String>::new();
  2917. let mut auth_query = HashMap::<String, String>::new();
  2918. if let Some(ref apikey) = configuration.api_key {
  2919. let key = apikey.key.clone();
  2920. let val = match apikey.prefix {
  2921. Some(ref prefix) => format!("{} {}", prefix, key),
  2922. None => key,
  2923. };
  2924. auth_query.insert("access_token".to_owned(), val);
  2925. };
  2926. if let Some(ref apikey) = configuration.api_key {
  2927. let key = apikey.key.clone();
  2928. let val = match apikey.prefix {
  2929. Some(ref prefix) => format!("{} {}", prefix, key),
  2930. None => key,
  2931. };
  2932. auth_headers.insert("Authorization".to_owned(), val);
  2933. };
  2934. if let Some(ref auth_conf) = configuration.basic_auth {
  2935. let auth = hyper::header::Authorization(
  2936. hyper::header::Basic {
  2937. username: auth_conf.0.to_owned(),
  2938. password: auth_conf.1.to_owned(),
  2939. }
  2940. );
  2941. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2942. };
  2943. if let Some(ref apikey) = configuration.api_key {
  2944. let key = apikey.key.clone();
  2945. let val = match apikey.prefix {
  2946. Some(ref prefix) => format!("{} {}", prefix, key),
  2947. None => key,
  2948. };
  2949. auth_headers.insert("Sudo".to_owned(), val);
  2950. };
  2951. if let Some(ref apikey) = configuration.api_key {
  2952. let key = apikey.key.clone();
  2953. let val = match apikey.prefix {
  2954. Some(ref prefix) => format!("{} {}", prefix, key),
  2955. None => key,
  2956. };
  2957. auth_query.insert("sudo".to_owned(), val);
  2958. };
  2959. if let Some(ref apikey) = configuration.api_key {
  2960. let key = apikey.key.clone();
  2961. let val = match apikey.prefix {
  2962. Some(ref prefix) => format!("{} {}", prefix, key),
  2963. None => key,
  2964. };
  2965. auth_query.insert("token".to_owned(), val);
  2966. };
  2967. let method = hyper::Method::Get;
  2968. let query_string = {
  2969. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2970. for (key, val) in &auth_query {
  2971. query.append_pair(key, val);
  2972. }
  2973. query.finish()
  2974. };
  2975. let uri_str = format!("{}/repos/{owner}/{repo}/milestones/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  2976. // TODO(farcaller): handle error
  2977. // if let Err(e) = uri {
  2978. // return Box::new(futures::future::err(e));
  2979. // }
  2980. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2981. let mut req = hyper::Request::new(method, uri);
  2982. if let Some(ref user_agent) = configuration.user_agent {
  2983. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2984. }
  2985. for (key, val) in auth_headers {
  2986. req.headers_mut().set_raw(key, val);
  2987. }
  2988. // send request
  2989. Box::new(
  2990. configuration.client.request(req)
  2991. .map_err(|e| Error::from(e))
  2992. .and_then(|resp| {
  2993. let status = resp.status();
  2994. resp.body().concat2()
  2995. .and_then(move |body| Ok((status, body)))
  2996. .map_err(|e| Error::from(e))
  2997. })
  2998. .and_then(|(status, body)| {
  2999. if status.is_success() {
  3000. Ok(body)
  3001. } else {
  3002. Err(Error::from((status, &*body)))
  3003. }
  3004. })
  3005. .and_then(|body| {
  3006. let parsed: Result<::models::Milestone, _> = serde_json::from_slice(&body);
  3007. parsed.map_err(|e| Error::from(e))
  3008. })
  3009. )
  3010. }
  3011. fn issue_get_milestones_list(&self, owner: &str, repo: &str, state: &str) -> Box<Future<Item = Vec<::models::Milestone>, Error = Error<serde_json::Value>>> {
  3012. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3013. let mut auth_headers = HashMap::<String, String>::new();
  3014. let mut auth_query = HashMap::<String, String>::new();
  3015. if let Some(ref apikey) = configuration.api_key {
  3016. let key = apikey.key.clone();
  3017. let val = match apikey.prefix {
  3018. Some(ref prefix) => format!("{} {}", prefix, key),
  3019. None => key,
  3020. };
  3021. auth_query.insert("access_token".to_owned(), val);
  3022. };
  3023. if let Some(ref apikey) = configuration.api_key {
  3024. let key = apikey.key.clone();
  3025. let val = match apikey.prefix {
  3026. Some(ref prefix) => format!("{} {}", prefix, key),
  3027. None => key,
  3028. };
  3029. auth_headers.insert("Authorization".to_owned(), val);
  3030. };
  3031. if let Some(ref auth_conf) = configuration.basic_auth {
  3032. let auth = hyper::header::Authorization(
  3033. hyper::header::Basic {
  3034. username: auth_conf.0.to_owned(),
  3035. password: auth_conf.1.to_owned(),
  3036. }
  3037. );
  3038. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3039. };
  3040. if let Some(ref apikey) = configuration.api_key {
  3041. let key = apikey.key.clone();
  3042. let val = match apikey.prefix {
  3043. Some(ref prefix) => format!("{} {}", prefix, key),
  3044. None => key,
  3045. };
  3046. auth_headers.insert("Sudo".to_owned(), val);
  3047. };
  3048. if let Some(ref apikey) = configuration.api_key {
  3049. let key = apikey.key.clone();
  3050. let val = match apikey.prefix {
  3051. Some(ref prefix) => format!("{} {}", prefix, key),
  3052. None => key,
  3053. };
  3054. auth_query.insert("sudo".to_owned(), val);
  3055. };
  3056. if let Some(ref apikey) = configuration.api_key {
  3057. let key = apikey.key.clone();
  3058. let val = match apikey.prefix {
  3059. Some(ref prefix) => format!("{} {}", prefix, key),
  3060. None => key,
  3061. };
  3062. auth_query.insert("token".to_owned(), val);
  3063. };
  3064. let method = hyper::Method::Get;
  3065. let query_string = {
  3066. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3067. query.append_pair("state", &state.to_string());
  3068. for (key, val) in &auth_query {
  3069. query.append_pair(key, val);
  3070. }
  3071. query.finish()
  3072. };
  3073. let uri_str = format!("{}/repos/{owner}/{repo}/milestones?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  3074. // TODO(farcaller): handle error
  3075. // if let Err(e) = uri {
  3076. // return Box::new(futures::future::err(e));
  3077. // }
  3078. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3079. let mut req = hyper::Request::new(method, uri);
  3080. if let Some(ref user_agent) = configuration.user_agent {
  3081. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3082. }
  3083. for (key, val) in auth_headers {
  3084. req.headers_mut().set_raw(key, val);
  3085. }
  3086. // send request
  3087. Box::new(
  3088. configuration.client.request(req)
  3089. .map_err(|e| Error::from(e))
  3090. .and_then(|resp| {
  3091. let status = resp.status();
  3092. resp.body().concat2()
  3093. .and_then(move |body| Ok((status, body)))
  3094. .map_err(|e| Error::from(e))
  3095. })
  3096. .and_then(|(status, body)| {
  3097. if status.is_success() {
  3098. Ok(body)
  3099. } else {
  3100. Err(Error::from((status, &*body)))
  3101. }
  3102. })
  3103. .and_then(|body| {
  3104. let parsed: Result<Vec<::models::Milestone>, _> = serde_json::from_slice(&body);
  3105. parsed.map_err(|e| Error::from(e))
  3106. })
  3107. )
  3108. }
  3109. fn issue_get_repo_comments(&self, owner: &str, repo: &str, since: &str) -> Box<Future<Item = Vec<::models::Comment>, Error = Error<serde_json::Value>>> {
  3110. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3111. let mut auth_headers = HashMap::<String, String>::new();
  3112. let mut auth_query = HashMap::<String, String>::new();
  3113. if let Some(ref apikey) = configuration.api_key {
  3114. let key = apikey.key.clone();
  3115. let val = match apikey.prefix {
  3116. Some(ref prefix) => format!("{} {}", prefix, key),
  3117. None => key,
  3118. };
  3119. auth_query.insert("access_token".to_owned(), val);
  3120. };
  3121. if let Some(ref apikey) = configuration.api_key {
  3122. let key = apikey.key.clone();
  3123. let val = match apikey.prefix {
  3124. Some(ref prefix) => format!("{} {}", prefix, key),
  3125. None => key,
  3126. };
  3127. auth_headers.insert("Authorization".to_owned(), val);
  3128. };
  3129. if let Some(ref auth_conf) = configuration.basic_auth {
  3130. let auth = hyper::header::Authorization(
  3131. hyper::header::Basic {
  3132. username: auth_conf.0.to_owned(),
  3133. password: auth_conf.1.to_owned(),
  3134. }
  3135. );
  3136. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3137. };
  3138. if let Some(ref apikey) = configuration.api_key {
  3139. let key = apikey.key.clone();
  3140. let val = match apikey.prefix {
  3141. Some(ref prefix) => format!("{} {}", prefix, key),
  3142. None => key,
  3143. };
  3144. auth_headers.insert("Sudo".to_owned(), val);
  3145. };
  3146. if let Some(ref apikey) = configuration.api_key {
  3147. let key = apikey.key.clone();
  3148. let val = match apikey.prefix {
  3149. Some(ref prefix) => format!("{} {}", prefix, key),
  3150. None => key,
  3151. };
  3152. auth_query.insert("sudo".to_owned(), val);
  3153. };
  3154. if let Some(ref apikey) = configuration.api_key {
  3155. let key = apikey.key.clone();
  3156. let val = match apikey.prefix {
  3157. Some(ref prefix) => format!("{} {}", prefix, key),
  3158. None => key,
  3159. };
  3160. auth_query.insert("token".to_owned(), val);
  3161. };
  3162. let method = hyper::Method::Get;
  3163. let query_string = {
  3164. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3165. query.append_pair("since", &since.to_string());
  3166. for (key, val) in &auth_query {
  3167. query.append_pair(key, val);
  3168. }
  3169. query.finish()
  3170. };
  3171. let uri_str = format!("{}/repos/{owner}/{repo}/issues/comments?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  3172. // TODO(farcaller): handle error
  3173. // if let Err(e) = uri {
  3174. // return Box::new(futures::future::err(e));
  3175. // }
  3176. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3177. let mut req = hyper::Request::new(method, uri);
  3178. if let Some(ref user_agent) = configuration.user_agent {
  3179. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3180. }
  3181. for (key, val) in auth_headers {
  3182. req.headers_mut().set_raw(key, val);
  3183. }
  3184. // send request
  3185. Box::new(
  3186. configuration.client.request(req)
  3187. .map_err(|e| Error::from(e))
  3188. .and_then(|resp| {
  3189. let status = resp.status();
  3190. resp.body().concat2()
  3191. .and_then(move |body| Ok((status, body)))
  3192. .map_err(|e| Error::from(e))
  3193. })
  3194. .and_then(|(status, body)| {
  3195. if status.is_success() {
  3196. Ok(body)
  3197. } else {
  3198. Err(Error::from((status, &*body)))
  3199. }
  3200. })
  3201. .and_then(|body| {
  3202. let parsed: Result<Vec<::models::Comment>, _> = serde_json::from_slice(&body);
  3203. parsed.map_err(|e| Error::from(e))
  3204. })
  3205. )
  3206. }
  3207. fn issue_list_issues(&self, owner: &str, repo: &str, state: &str, labels: &str, page: i32, q: &str, _type: &str) -> Box<Future<Item = Vec<::models::Issue>, Error = Error<serde_json::Value>>> {
  3208. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3209. let mut auth_headers = HashMap::<String, String>::new();
  3210. let mut auth_query = HashMap::<String, String>::new();
  3211. if let Some(ref apikey) = configuration.api_key {
  3212. let key = apikey.key.clone();
  3213. let val = match apikey.prefix {
  3214. Some(ref prefix) => format!("{} {}", prefix, key),
  3215. None => key,
  3216. };
  3217. auth_query.insert("access_token".to_owned(), val);
  3218. };
  3219. if let Some(ref apikey) = configuration.api_key {
  3220. let key = apikey.key.clone();
  3221. let val = match apikey.prefix {
  3222. Some(ref prefix) => format!("{} {}", prefix, key),
  3223. None => key,
  3224. };
  3225. auth_headers.insert("Authorization".to_owned(), val);
  3226. };
  3227. if let Some(ref auth_conf) = configuration.basic_auth {
  3228. let auth = hyper::header::Authorization(
  3229. hyper::header::Basic {
  3230. username: auth_conf.0.to_owned(),
  3231. password: auth_conf.1.to_owned(),
  3232. }
  3233. );
  3234. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3235. };
  3236. if let Some(ref apikey) = configuration.api_key {
  3237. let key = apikey.key.clone();
  3238. let val = match apikey.prefix {
  3239. Some(ref prefix) => format!("{} {}", prefix, key),
  3240. None => key,
  3241. };
  3242. auth_headers.insert("Sudo".to_owned(), val);
  3243. };
  3244. if let Some(ref apikey) = configuration.api_key {
  3245. let key = apikey.key.clone();
  3246. let val = match apikey.prefix {
  3247. Some(ref prefix) => format!("{} {}", prefix, key),
  3248. None => key,
  3249. };
  3250. auth_query.insert("sudo".to_owned(), val);
  3251. };
  3252. if let Some(ref apikey) = configuration.api_key {
  3253. let key = apikey.key.clone();
  3254. let val = match apikey.prefix {
  3255. Some(ref prefix) => format!("{} {}", prefix, key),
  3256. None => key,
  3257. };
  3258. auth_query.insert("token".to_owned(), val);
  3259. };
  3260. let method = hyper::Method::Get;
  3261. let query_string = {
  3262. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3263. query.append_pair("state", &state.to_string());
  3264. query.append_pair("labels", &labels.to_string());
  3265. query.append_pair("page", &page.to_string());
  3266. query.append_pair("q", &q.to_string());
  3267. query.append_pair("type", &_type.to_string());
  3268. for (key, val) in &auth_query {
  3269. query.append_pair(key, val);
  3270. }
  3271. query.finish()
  3272. };
  3273. let uri_str = format!("{}/repos/{owner}/{repo}/issues?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  3274. // TODO(farcaller): handle error
  3275. // if let Err(e) = uri {
  3276. // return Box::new(futures::future::err(e));
  3277. // }
  3278. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3279. let mut req = hyper::Request::new(method, uri);
  3280. if let Some(ref user_agent) = configuration.user_agent {
  3281. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3282. }
  3283. for (key, val) in auth_headers {
  3284. req.headers_mut().set_raw(key, val);
  3285. }
  3286. // send request
  3287. Box::new(
  3288. configuration.client.request(req)
  3289. .map_err(|e| Error::from(e))
  3290. .and_then(|resp| {
  3291. let status = resp.status();
  3292. resp.body().concat2()
  3293. .and_then(move |body| Ok((status, body)))
  3294. .map_err(|e| Error::from(e))
  3295. })
  3296. .and_then(|(status, body)| {
  3297. if status.is_success() {
  3298. Ok(body)
  3299. } else {
  3300. Err(Error::from((status, &*body)))
  3301. }
  3302. })
  3303. .and_then(|body| {
  3304. let parsed: Result<Vec<::models::Issue>, _> = serde_json::from_slice(&body);
  3305. parsed.map_err(|e| Error::from(e))
  3306. })
  3307. )
  3308. }
  3309. fn issue_list_labels(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Label>, Error = Error<serde_json::Value>>> {
  3310. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3311. let mut auth_headers = HashMap::<String, String>::new();
  3312. let mut auth_query = HashMap::<String, String>::new();
  3313. if let Some(ref apikey) = configuration.api_key {
  3314. let key = apikey.key.clone();
  3315. let val = match apikey.prefix {
  3316. Some(ref prefix) => format!("{} {}", prefix, key),
  3317. None => key,
  3318. };
  3319. auth_query.insert("access_token".to_owned(), val);
  3320. };
  3321. if let Some(ref apikey) = configuration.api_key {
  3322. let key = apikey.key.clone();
  3323. let val = match apikey.prefix {
  3324. Some(ref prefix) => format!("{} {}", prefix, key),
  3325. None => key,
  3326. };
  3327. auth_headers.insert("Authorization".to_owned(), val);
  3328. };
  3329. if let Some(ref auth_conf) = configuration.basic_auth {
  3330. let auth = hyper::header::Authorization(
  3331. hyper::header::Basic {
  3332. username: auth_conf.0.to_owned(),
  3333. password: auth_conf.1.to_owned(),
  3334. }
  3335. );
  3336. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3337. };
  3338. if let Some(ref apikey) = configuration.api_key {
  3339. let key = apikey.key.clone();
  3340. let val = match apikey.prefix {
  3341. Some(ref prefix) => format!("{} {}", prefix, key),
  3342. None => key,
  3343. };
  3344. auth_headers.insert("Sudo".to_owned(), val);
  3345. };
  3346. if let Some(ref apikey) = configuration.api_key {
  3347. let key = apikey.key.clone();
  3348. let val = match apikey.prefix {
  3349. Some(ref prefix) => format!("{} {}", prefix, key),
  3350. None => key,
  3351. };
  3352. auth_query.insert("sudo".to_owned(), val);
  3353. };
  3354. if let Some(ref apikey) = configuration.api_key {
  3355. let key = apikey.key.clone();
  3356. let val = match apikey.prefix {
  3357. Some(ref prefix) => format!("{} {}", prefix, key),
  3358. None => key,
  3359. };
  3360. auth_query.insert("token".to_owned(), val);
  3361. };
  3362. let method = hyper::Method::Get;
  3363. let query_string = {
  3364. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3365. for (key, val) in &auth_query {
  3366. query.append_pair(key, val);
  3367. }
  3368. query.finish()
  3369. };
  3370. let uri_str = format!("{}/repos/{owner}/{repo}/labels?{}", configuration.base_path, query_string, owner=owner, repo=repo);
  3371. // TODO(farcaller): handle error
  3372. // if let Err(e) = uri {
  3373. // return Box::new(futures::future::err(e));
  3374. // }
  3375. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3376. let mut req = hyper::Request::new(method, uri);
  3377. if let Some(ref user_agent) = configuration.user_agent {
  3378. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3379. }
  3380. for (key, val) in auth_headers {
  3381. req.headers_mut().set_raw(key, val);
  3382. }
  3383. // send request
  3384. Box::new(
  3385. configuration.client.request(req)
  3386. .map_err(|e| Error::from(e))
  3387. .and_then(|resp| {
  3388. let status = resp.status();
  3389. resp.body().concat2()
  3390. .and_then(move |body| Ok((status, body)))
  3391. .map_err(|e| Error::from(e))
  3392. })
  3393. .and_then(|(status, body)| {
  3394. if status.is_success() {
  3395. Ok(body)
  3396. } else {
  3397. Err(Error::from((status, &*body)))
  3398. }
  3399. })
  3400. .and_then(|body| {
  3401. let parsed: Result<Vec<::models::Label>, _> = serde_json::from_slice(&body);
  3402. parsed.map_err(|e| Error::from(e))
  3403. })
  3404. )
  3405. }
  3406. fn issue_post_comment_reaction(&self, owner: &str, repo: &str, id: i64, content: ::models::EditReactionOption) -> Box<Future<Item = ::models::Reaction, Error = Error<serde_json::Value>>> {
  3407. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3408. let mut auth_headers = HashMap::<String, String>::new();
  3409. let mut auth_query = HashMap::<String, String>::new();
  3410. if let Some(ref apikey) = configuration.api_key {
  3411. let key = apikey.key.clone();
  3412. let val = match apikey.prefix {
  3413. Some(ref prefix) => format!("{} {}", prefix, key),
  3414. None => key,
  3415. };
  3416. auth_query.insert("access_token".to_owned(), val);
  3417. };
  3418. if let Some(ref apikey) = configuration.api_key {
  3419. let key = apikey.key.clone();
  3420. let val = match apikey.prefix {
  3421. Some(ref prefix) => format!("{} {}", prefix, key),
  3422. None => key,
  3423. };
  3424. auth_headers.insert("Authorization".to_owned(), val);
  3425. };
  3426. if let Some(ref auth_conf) = configuration.basic_auth {
  3427. let auth = hyper::header::Authorization(
  3428. hyper::header::Basic {
  3429. username: auth_conf.0.to_owned(),
  3430. password: auth_conf.1.to_owned(),
  3431. }
  3432. );
  3433. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3434. };
  3435. if let Some(ref apikey) = configuration.api_key {
  3436. let key = apikey.key.clone();
  3437. let val = match apikey.prefix {
  3438. Some(ref prefix) => format!("{} {}", prefix, key),
  3439. None => key,
  3440. };
  3441. auth_headers.insert("Sudo".to_owned(), val);
  3442. };
  3443. if let Some(ref apikey) = configuration.api_key {
  3444. let key = apikey.key.clone();
  3445. let val = match apikey.prefix {
  3446. Some(ref prefix) => format!("{} {}", prefix, key),
  3447. None => key,
  3448. };
  3449. auth_query.insert("sudo".to_owned(), val);
  3450. };
  3451. if let Some(ref apikey) = configuration.api_key {
  3452. let key = apikey.key.clone();
  3453. let val = match apikey.prefix {
  3454. Some(ref prefix) => format!("{} {}", prefix, key),
  3455. None => key,
  3456. };
  3457. auth_query.insert("token".to_owned(), val);
  3458. };
  3459. let method = hyper::Method::Post;
  3460. let query_string = {
  3461. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3462. for (key, val) in &auth_query {
  3463. query.append_pair(key, val);
  3464. }
  3465. query.finish()
  3466. };
  3467. let uri_str = format!("{}/repos/{owner}/{repo}/issues/comments/{id}/reactions?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
  3468. // TODO(farcaller): handle error
  3469. // if let Err(e) = uri {
  3470. // return Box::new(futures::future::err(e));
  3471. // }
  3472. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3473. let mut req = hyper::Request::new(method, uri);
  3474. if let Some(ref user_agent) = configuration.user_agent {
  3475. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3476. }
  3477. for (key, val) in auth_headers {
  3478. req.headers_mut().set_raw(key, val);
  3479. }
  3480. let serialized = serde_json::to_string(&content).unwrap();
  3481. req.headers_mut().set(hyper::header::ContentType::json());
  3482. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  3483. req.set_body(serialized);
  3484. // send request
  3485. Box::new(
  3486. configuration.client.request(req)
  3487. .map_err(|e| Error::from(e))
  3488. .and_then(|resp| {
  3489. let status = resp.status();
  3490. resp.body().concat2()
  3491. .and_then(move |body| Ok((status, body)))
  3492. .map_err(|e| Error::from(e))
  3493. })
  3494. .and_then(|(status, body)| {
  3495. if status.is_success() {
  3496. Ok(body)
  3497. } else {
  3498. Err(Error::from((status, &*body)))
  3499. }
  3500. })
  3501. .and_then(|body| {
  3502. let parsed: Result<::models::Reaction, _> = serde_json::from_slice(&body);
  3503. parsed.map_err(|e| Error::from(e))
  3504. })
  3505. )
  3506. }
  3507. fn issue_post_issue_reaction(&self, owner: &str, repo: &str, index: i64, content: ::models::EditReactionOption) -> Box<Future<Item = ::models::Reaction, Error = Error<serde_json::Value>>> {
  3508. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3509. let mut auth_headers = HashMap::<String, String>::new();
  3510. let mut auth_query = HashMap::<String, String>::new();
  3511. if let Some(ref apikey) = configuration.api_key {
  3512. let key = apikey.key.clone();
  3513. let val = match apikey.prefix {
  3514. Some(ref prefix) => format!("{} {}", prefix, key),
  3515. None => key,
  3516. };
  3517. auth_query.insert("access_token".to_owned(), val);
  3518. };
  3519. if let Some(ref apikey) = configuration.api_key {
  3520. let key = apikey.key.clone();
  3521. let val = match apikey.prefix {
  3522. Some(ref prefix) => format!("{} {}", prefix, key),
  3523. None => key,
  3524. };
  3525. auth_headers.insert("Authorization".to_owned(), val);
  3526. };
  3527. if let Some(ref auth_conf) = configuration.basic_auth {
  3528. let auth = hyper::header::Authorization(
  3529. hyper::header::Basic {
  3530. username: auth_conf.0.to_owned(),
  3531. password: auth_conf.1.to_owned(),
  3532. }
  3533. );
  3534. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3535. };
  3536. if let Some(ref apikey) = configuration.api_key {
  3537. let key = apikey.key.clone();
  3538. let val = match apikey.prefix {
  3539. Some(ref prefix) => format!("{} {}", prefix, key),
  3540. None => key,
  3541. };
  3542. auth_headers.insert("Sudo".to_owned(), val);
  3543. };
  3544. if let Some(ref apikey) = configuration.api_key {
  3545. let key = apikey.key.clone();
  3546. let val = match apikey.prefix {
  3547. Some(ref prefix) => format!("{} {}", prefix, key),
  3548. None => key,
  3549. };
  3550. auth_query.insert("sudo".to_owned(), val);
  3551. };
  3552. if let Some(ref apikey) = configuration.api_key {
  3553. let key = apikey.key.clone();
  3554. let val = match apikey.prefix {
  3555. Some(ref prefix) => format!("{} {}", prefix, key),
  3556. None => key,
  3557. };
  3558. auth_query.insert("token".to_owned(), val);
  3559. };
  3560. let method = hyper::Method::Post;
  3561. let query_string = {
  3562. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3563. for (key, val) in &auth_query {
  3564. query.append_pair(key, val);
  3565. }
  3566. query.finish()
  3567. };
  3568. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/reactions?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  3569. // TODO(farcaller): handle error
  3570. // if let Err(e) = uri {
  3571. // return Box::new(futures::future::err(e));
  3572. // }
  3573. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3574. let mut req = hyper::Request::new(method, uri);
  3575. if let Some(ref user_agent) = configuration.user_agent {
  3576. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3577. }
  3578. for (key, val) in auth_headers {
  3579. req.headers_mut().set_raw(key, val);
  3580. }
  3581. let serialized = serde_json::to_string(&content).unwrap();
  3582. req.headers_mut().set(hyper::header::ContentType::json());
  3583. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  3584. req.set_body(serialized);
  3585. // send request
  3586. Box::new(
  3587. configuration.client.request(req)
  3588. .map_err(|e| Error::from(e))
  3589. .and_then(|resp| {
  3590. let status = resp.status();
  3591. resp.body().concat2()
  3592. .and_then(move |body| Ok((status, body)))
  3593. .map_err(|e| Error::from(e))
  3594. })
  3595. .and_then(|(status, body)| {
  3596. if status.is_success() {
  3597. Ok(body)
  3598. } else {
  3599. Err(Error::from((status, &*body)))
  3600. }
  3601. })
  3602. .and_then(|body| {
  3603. let parsed: Result<::models::Reaction, _> = serde_json::from_slice(&body);
  3604. parsed.map_err(|e| Error::from(e))
  3605. })
  3606. )
  3607. }
  3608. fn issue_remove_label(&self, owner: &str, repo: &str, index: i64, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  3609. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3610. let mut auth_headers = HashMap::<String, String>::new();
  3611. let mut auth_query = HashMap::<String, String>::new();
  3612. if let Some(ref apikey) = configuration.api_key {
  3613. let key = apikey.key.clone();
  3614. let val = match apikey.prefix {
  3615. Some(ref prefix) => format!("{} {}", prefix, key),
  3616. None => key,
  3617. };
  3618. auth_query.insert("access_token".to_owned(), val);
  3619. };
  3620. if let Some(ref apikey) = configuration.api_key {
  3621. let key = apikey.key.clone();
  3622. let val = match apikey.prefix {
  3623. Some(ref prefix) => format!("{} {}", prefix, key),
  3624. None => key,
  3625. };
  3626. auth_headers.insert("Authorization".to_owned(), val);
  3627. };
  3628. if let Some(ref auth_conf) = configuration.basic_auth {
  3629. let auth = hyper::header::Authorization(
  3630. hyper::header::Basic {
  3631. username: auth_conf.0.to_owned(),
  3632. password: auth_conf.1.to_owned(),
  3633. }
  3634. );
  3635. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3636. };
  3637. if let Some(ref apikey) = configuration.api_key {
  3638. let key = apikey.key.clone();
  3639. let val = match apikey.prefix {
  3640. Some(ref prefix) => format!("{} {}", prefix, key),
  3641. None => key,
  3642. };
  3643. auth_headers.insert("Sudo".to_owned(), val);
  3644. };
  3645. if let Some(ref apikey) = configuration.api_key {
  3646. let key = apikey.key.clone();
  3647. let val = match apikey.prefix {
  3648. Some(ref prefix) => format!("{} {}", prefix, key),
  3649. None => key,
  3650. };
  3651. auth_query.insert("sudo".to_owned(), val);
  3652. };
  3653. if let Some(ref apikey) = configuration.api_key {
  3654. let key = apikey.key.clone();
  3655. let val = match apikey.prefix {
  3656. Some(ref prefix) => format!("{} {}", prefix, key),
  3657. None => key,
  3658. };
  3659. auth_query.insert("token".to_owned(), val);
  3660. };
  3661. let method = hyper::Method::Delete;
  3662. let query_string = {
  3663. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3664. for (key, val) in &auth_query {
  3665. query.append_pair(key, val);
  3666. }
  3667. query.finish()
  3668. };
  3669. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/labels/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index, id=id);
  3670. // TODO(farcaller): handle error
  3671. // if let Err(e) = uri {
  3672. // return Box::new(futures::future::err(e));
  3673. // }
  3674. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3675. let mut req = hyper::Request::new(method, uri);
  3676. if let Some(ref user_agent) = configuration.user_agent {
  3677. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3678. }
  3679. for (key, val) in auth_headers {
  3680. req.headers_mut().set_raw(key, val);
  3681. }
  3682. // send request
  3683. Box::new(
  3684. configuration.client.request(req)
  3685. .map_err(|e| Error::from(e))
  3686. .and_then(|resp| {
  3687. let status = resp.status();
  3688. resp.body().concat2()
  3689. .and_then(move |body| Ok((status, body)))
  3690. .map_err(|e| Error::from(e))
  3691. })
  3692. .and_then(|(status, body)| {
  3693. if status.is_success() {
  3694. Ok(body)
  3695. } else {
  3696. Err(Error::from((status, &*body)))
  3697. }
  3698. })
  3699. .and_then(|_| futures::future::ok(()))
  3700. )
  3701. }
  3702. fn issue_replace_labels(&self, owner: &str, repo: &str, index: i64, body: ::models::IssueLabelsOption) -> Box<Future<Item = Vec<::models::Label>, Error = Error<serde_json::Value>>> {
  3703. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3704. let mut auth_headers = HashMap::<String, String>::new();
  3705. let mut auth_query = HashMap::<String, String>::new();
  3706. if let Some(ref apikey) = configuration.api_key {
  3707. let key = apikey.key.clone();
  3708. let val = match apikey.prefix {
  3709. Some(ref prefix) => format!("{} {}", prefix, key),
  3710. None => key,
  3711. };
  3712. auth_query.insert("access_token".to_owned(), val);
  3713. };
  3714. if let Some(ref apikey) = configuration.api_key {
  3715. let key = apikey.key.clone();
  3716. let val = match apikey.prefix {
  3717. Some(ref prefix) => format!("{} {}", prefix, key),
  3718. None => key,
  3719. };
  3720. auth_headers.insert("Authorization".to_owned(), val);
  3721. };
  3722. if let Some(ref auth_conf) = configuration.basic_auth {
  3723. let auth = hyper::header::Authorization(
  3724. hyper::header::Basic {
  3725. username: auth_conf.0.to_owned(),
  3726. password: auth_conf.1.to_owned(),
  3727. }
  3728. );
  3729. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3730. };
  3731. if let Some(ref apikey) = configuration.api_key {
  3732. let key = apikey.key.clone();
  3733. let val = match apikey.prefix {
  3734. Some(ref prefix) => format!("{} {}", prefix, key),
  3735. None => key,
  3736. };
  3737. auth_headers.insert("Sudo".to_owned(), val);
  3738. };
  3739. if let Some(ref apikey) = configuration.api_key {
  3740. let key = apikey.key.clone();
  3741. let val = match apikey.prefix {
  3742. Some(ref prefix) => format!("{} {}", prefix, key),
  3743. None => key,
  3744. };
  3745. auth_query.insert("sudo".to_owned(), val);
  3746. };
  3747. if let Some(ref apikey) = configuration.api_key {
  3748. let key = apikey.key.clone();
  3749. let val = match apikey.prefix {
  3750. Some(ref prefix) => format!("{} {}", prefix, key),
  3751. None => key,
  3752. };
  3753. auth_query.insert("token".to_owned(), val);
  3754. };
  3755. let method = hyper::Method::Put;
  3756. let query_string = {
  3757. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3758. for (key, val) in &auth_query {
  3759. query.append_pair(key, val);
  3760. }
  3761. query.finish()
  3762. };
  3763. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/labels?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  3764. // TODO(farcaller): handle error
  3765. // if let Err(e) = uri {
  3766. // return Box::new(futures::future::err(e));
  3767. // }
  3768. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3769. let mut req = hyper::Request::new(method, uri);
  3770. if let Some(ref user_agent) = configuration.user_agent {
  3771. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3772. }
  3773. for (key, val) in auth_headers {
  3774. req.headers_mut().set_raw(key, val);
  3775. }
  3776. let serialized = serde_json::to_string(&body).unwrap();
  3777. req.headers_mut().set(hyper::header::ContentType::json());
  3778. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  3779. req.set_body(serialized);
  3780. // send request
  3781. Box::new(
  3782. configuration.client.request(req)
  3783. .map_err(|e| Error::from(e))
  3784. .and_then(|resp| {
  3785. let status = resp.status();
  3786. resp.body().concat2()
  3787. .and_then(move |body| Ok((status, body)))
  3788. .map_err(|e| Error::from(e))
  3789. })
  3790. .and_then(|(status, body)| {
  3791. if status.is_success() {
  3792. Ok(body)
  3793. } else {
  3794. Err(Error::from((status, &*body)))
  3795. }
  3796. })
  3797. .and_then(|body| {
  3798. let parsed: Result<Vec<::models::Label>, _> = serde_json::from_slice(&body);
  3799. parsed.map_err(|e| Error::from(e))
  3800. })
  3801. )
  3802. }
  3803. fn issue_reset_time(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  3804. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3805. let mut auth_headers = HashMap::<String, String>::new();
  3806. let mut auth_query = HashMap::<String, String>::new();
  3807. if let Some(ref apikey) = configuration.api_key {
  3808. let key = apikey.key.clone();
  3809. let val = match apikey.prefix {
  3810. Some(ref prefix) => format!("{} {}", prefix, key),
  3811. None => key,
  3812. };
  3813. auth_query.insert("access_token".to_owned(), val);
  3814. };
  3815. if let Some(ref apikey) = configuration.api_key {
  3816. let key = apikey.key.clone();
  3817. let val = match apikey.prefix {
  3818. Some(ref prefix) => format!("{} {}", prefix, key),
  3819. None => key,
  3820. };
  3821. auth_headers.insert("Authorization".to_owned(), val);
  3822. };
  3823. if let Some(ref auth_conf) = configuration.basic_auth {
  3824. let auth = hyper::header::Authorization(
  3825. hyper::header::Basic {
  3826. username: auth_conf.0.to_owned(),
  3827. password: auth_conf.1.to_owned(),
  3828. }
  3829. );
  3830. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3831. };
  3832. if let Some(ref apikey) = configuration.api_key {
  3833. let key = apikey.key.clone();
  3834. let val = match apikey.prefix {
  3835. Some(ref prefix) => format!("{} {}", prefix, key),
  3836. None => key,
  3837. };
  3838. auth_headers.insert("Sudo".to_owned(), val);
  3839. };
  3840. if let Some(ref apikey) = configuration.api_key {
  3841. let key = apikey.key.clone();
  3842. let val = match apikey.prefix {
  3843. Some(ref prefix) => format!("{} {}", prefix, key),
  3844. None => key,
  3845. };
  3846. auth_query.insert("sudo".to_owned(), val);
  3847. };
  3848. if let Some(ref apikey) = configuration.api_key {
  3849. let key = apikey.key.clone();
  3850. let val = match apikey.prefix {
  3851. Some(ref prefix) => format!("{} {}", prefix, key),
  3852. None => key,
  3853. };
  3854. auth_query.insert("token".to_owned(), val);
  3855. };
  3856. let method = hyper::Method::Delete;
  3857. let query_string = {
  3858. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3859. for (key, val) in &auth_query {
  3860. query.append_pair(key, val);
  3861. }
  3862. query.finish()
  3863. };
  3864. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/times?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  3865. // TODO(farcaller): handle error
  3866. // if let Err(e) = uri {
  3867. // return Box::new(futures::future::err(e));
  3868. // }
  3869. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3870. let mut req = hyper::Request::new(method, uri);
  3871. if let Some(ref user_agent) = configuration.user_agent {
  3872. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3873. }
  3874. for (key, val) in auth_headers {
  3875. req.headers_mut().set_raw(key, val);
  3876. }
  3877. // send request
  3878. Box::new(
  3879. configuration.client.request(req)
  3880. .map_err(|e| Error::from(e))
  3881. .and_then(|resp| {
  3882. let status = resp.status();
  3883. resp.body().concat2()
  3884. .and_then(move |body| Ok((status, body)))
  3885. .map_err(|e| Error::from(e))
  3886. })
  3887. .and_then(|(status, body)| {
  3888. if status.is_success() {
  3889. Ok(body)
  3890. } else {
  3891. Err(Error::from((status, &*body)))
  3892. }
  3893. })
  3894. .and_then(|_| futures::future::ok(()))
  3895. )
  3896. }
  3897. fn issue_search_issues(&self, state: &str, labels: &str, page: i32, q: &str, priority_repo_id: i64, _type: &str) -> Box<Future<Item = Vec<::models::Issue>, Error = Error<serde_json::Value>>> {
  3898. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3899. let mut auth_headers = HashMap::<String, String>::new();
  3900. let mut auth_query = HashMap::<String, String>::new();
  3901. if let Some(ref apikey) = configuration.api_key {
  3902. let key = apikey.key.clone();
  3903. let val = match apikey.prefix {
  3904. Some(ref prefix) => format!("{} {}", prefix, key),
  3905. None => key,
  3906. };
  3907. auth_query.insert("access_token".to_owned(), val);
  3908. };
  3909. if let Some(ref apikey) = configuration.api_key {
  3910. let key = apikey.key.clone();
  3911. let val = match apikey.prefix {
  3912. Some(ref prefix) => format!("{} {}", prefix, key),
  3913. None => key,
  3914. };
  3915. auth_headers.insert("Authorization".to_owned(), val);
  3916. };
  3917. if let Some(ref auth_conf) = configuration.basic_auth {
  3918. let auth = hyper::header::Authorization(
  3919. hyper::header::Basic {
  3920. username: auth_conf.0.to_owned(),
  3921. password: auth_conf.1.to_owned(),
  3922. }
  3923. );
  3924. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3925. };
  3926. if let Some(ref apikey) = configuration.api_key {
  3927. let key = apikey.key.clone();
  3928. let val = match apikey.prefix {
  3929. Some(ref prefix) => format!("{} {}", prefix, key),
  3930. None => key,
  3931. };
  3932. auth_headers.insert("Sudo".to_owned(), val);
  3933. };
  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("sudo".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_query.insert("token".to_owned(), val);
  3949. };
  3950. let method = hyper::Method::Get;
  3951. let query_string = {
  3952. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3953. query.append_pair("state", &state.to_string());
  3954. query.append_pair("labels", &labels.to_string());
  3955. query.append_pair("page", &page.to_string());
  3956. query.append_pair("q", &q.to_string());
  3957. query.append_pair("priority_repo_id", &priority_repo_id.to_string());
  3958. query.append_pair("type", &_type.to_string());
  3959. for (key, val) in &auth_query {
  3960. query.append_pair(key, val);
  3961. }
  3962. query.finish()
  3963. };
  3964. let uri_str = format!("{}/repos/issues/search?{}", configuration.base_path, query_string);
  3965. // TODO(farcaller): handle error
  3966. // if let Err(e) = uri {
  3967. // return Box::new(futures::future::err(e));
  3968. // }
  3969. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3970. let mut req = hyper::Request::new(method, uri);
  3971. if let Some(ref user_agent) = configuration.user_agent {
  3972. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3973. }
  3974. for (key, val) in auth_headers {
  3975. req.headers_mut().set_raw(key, val);
  3976. }
  3977. // send request
  3978. Box::new(
  3979. configuration.client.request(req)
  3980. .map_err(|e| Error::from(e))
  3981. .and_then(|resp| {
  3982. let status = resp.status();
  3983. resp.body().concat2()
  3984. .and_then(move |body| Ok((status, body)))
  3985. .map_err(|e| Error::from(e))
  3986. })
  3987. .and_then(|(status, body)| {
  3988. if status.is_success() {
  3989. Ok(body)
  3990. } else {
  3991. Err(Error::from((status, &*body)))
  3992. }
  3993. })
  3994. .and_then(|body| {
  3995. let parsed: Result<Vec<::models::Issue>, _> = serde_json::from_slice(&body);
  3996. parsed.map_err(|e| Error::from(e))
  3997. })
  3998. )
  3999. }
  4000. fn issue_start_stop_watch(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  4001. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  4002. let mut auth_headers = HashMap::<String, String>::new();
  4003. let mut auth_query = HashMap::<String, String>::new();
  4004. if let Some(ref apikey) = configuration.api_key {
  4005. let key = apikey.key.clone();
  4006. let val = match apikey.prefix {
  4007. Some(ref prefix) => format!("{} {}", prefix, key),
  4008. None => key,
  4009. };
  4010. auth_query.insert("access_token".to_owned(), val);
  4011. };
  4012. if let Some(ref apikey) = configuration.api_key {
  4013. let key = apikey.key.clone();
  4014. let val = match apikey.prefix {
  4015. Some(ref prefix) => format!("{} {}", prefix, key),
  4016. None => key,
  4017. };
  4018. auth_headers.insert("Authorization".to_owned(), val);
  4019. };
  4020. if let Some(ref auth_conf) = configuration.basic_auth {
  4021. let auth = hyper::header::Authorization(
  4022. hyper::header::Basic {
  4023. username: auth_conf.0.to_owned(),
  4024. password: auth_conf.1.to_owned(),
  4025. }
  4026. );
  4027. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  4028. };
  4029. if let Some(ref apikey) = configuration.api_key {
  4030. let key = apikey.key.clone();
  4031. let val = match apikey.prefix {
  4032. Some(ref prefix) => format!("{} {}", prefix, key),
  4033. None => key,
  4034. };
  4035. auth_headers.insert("Sudo".to_owned(), val);
  4036. };
  4037. if let Some(ref apikey) = configuration.api_key {
  4038. let key = apikey.key.clone();
  4039. let val = match apikey.prefix {
  4040. Some(ref prefix) => format!("{} {}", prefix, key),
  4041. None => key,
  4042. };
  4043. auth_query.insert("sudo".to_owned(), val);
  4044. };
  4045. if let Some(ref apikey) = configuration.api_key {
  4046. let key = apikey.key.clone();
  4047. let val = match apikey.prefix {
  4048. Some(ref prefix) => format!("{} {}", prefix, key),
  4049. None => key,
  4050. };
  4051. auth_query.insert("token".to_owned(), val);
  4052. };
  4053. let method = hyper::Method::Post;
  4054. let query_string = {
  4055. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  4056. for (key, val) in &auth_query {
  4057. query.append_pair(key, val);
  4058. }
  4059. query.finish()
  4060. };
  4061. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/stopwatch/start?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  4062. // TODO(farcaller): handle error
  4063. // if let Err(e) = uri {
  4064. // return Box::new(futures::future::err(e));
  4065. // }
  4066. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  4067. let mut req = hyper::Request::new(method, uri);
  4068. if let Some(ref user_agent) = configuration.user_agent {
  4069. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  4070. }
  4071. for (key, val) in auth_headers {
  4072. req.headers_mut().set_raw(key, val);
  4073. }
  4074. // send request
  4075. Box::new(
  4076. configuration.client.request(req)
  4077. .map_err(|e| Error::from(e))
  4078. .and_then(|resp| {
  4079. let status = resp.status();
  4080. resp.body().concat2()
  4081. .and_then(move |body| Ok((status, body)))
  4082. .map_err(|e| Error::from(e))
  4083. })
  4084. .and_then(|(status, body)| {
  4085. if status.is_success() {
  4086. Ok(body)
  4087. } else {
  4088. Err(Error::from((status, &*body)))
  4089. }
  4090. })
  4091. .and_then(|_| futures::future::ok(()))
  4092. )
  4093. }
  4094. fn issue_stop_stop_watch(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  4095. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  4096. let mut auth_headers = HashMap::<String, String>::new();
  4097. let mut auth_query = HashMap::<String, String>::new();
  4098. if let Some(ref apikey) = configuration.api_key {
  4099. let key = apikey.key.clone();
  4100. let val = match apikey.prefix {
  4101. Some(ref prefix) => format!("{} {}", prefix, key),
  4102. None => key,
  4103. };
  4104. auth_query.insert("access_token".to_owned(), val);
  4105. };
  4106. if let Some(ref apikey) = configuration.api_key {
  4107. let key = apikey.key.clone();
  4108. let val = match apikey.prefix {
  4109. Some(ref prefix) => format!("{} {}", prefix, key),
  4110. None => key,
  4111. };
  4112. auth_headers.insert("Authorization".to_owned(), val);
  4113. };
  4114. if let Some(ref auth_conf) = configuration.basic_auth {
  4115. let auth = hyper::header::Authorization(
  4116. hyper::header::Basic {
  4117. username: auth_conf.0.to_owned(),
  4118. password: auth_conf.1.to_owned(),
  4119. }
  4120. );
  4121. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  4122. };
  4123. if let Some(ref apikey) = configuration.api_key {
  4124. let key = apikey.key.clone();
  4125. let val = match apikey.prefix {
  4126. Some(ref prefix) => format!("{} {}", prefix, key),
  4127. None => key,
  4128. };
  4129. auth_headers.insert("Sudo".to_owned(), val);
  4130. };
  4131. if let Some(ref apikey) = configuration.api_key {
  4132. let key = apikey.key.clone();
  4133. let val = match apikey.prefix {
  4134. Some(ref prefix) => format!("{} {}", prefix, key),
  4135. None => key,
  4136. };
  4137. auth_query.insert("sudo".to_owned(), val);
  4138. };
  4139. if let Some(ref apikey) = configuration.api_key {
  4140. let key = apikey.key.clone();
  4141. let val = match apikey.prefix {
  4142. Some(ref prefix) => format!("{} {}", prefix, key),
  4143. None => key,
  4144. };
  4145. auth_query.insert("token".to_owned(), val);
  4146. };
  4147. let method = hyper::Method::Post;
  4148. let query_string = {
  4149. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  4150. for (key, val) in &auth_query {
  4151. query.append_pair(key, val);
  4152. }
  4153. query.finish()
  4154. };
  4155. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/stopwatch/stop?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  4156. // TODO(farcaller): handle error
  4157. // if let Err(e) = uri {
  4158. // return Box::new(futures::future::err(e));
  4159. // }
  4160. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  4161. let mut req = hyper::Request::new(method, uri);
  4162. if let Some(ref user_agent) = configuration.user_agent {
  4163. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  4164. }
  4165. for (key, val) in auth_headers {
  4166. req.headers_mut().set_raw(key, val);
  4167. }
  4168. // send request
  4169. Box::new(
  4170. configuration.client.request(req)
  4171. .map_err(|e| Error::from(e))
  4172. .and_then(|resp| {
  4173. let status = resp.status();
  4174. resp.body().concat2()
  4175. .and_then(move |body| Ok((status, body)))
  4176. .map_err(|e| Error::from(e))
  4177. })
  4178. .and_then(|(status, body)| {
  4179. if status.is_success() {
  4180. Ok(body)
  4181. } else {
  4182. Err(Error::from((status, &*body)))
  4183. }
  4184. })
  4185. .and_then(|_| futures::future::ok(()))
  4186. )
  4187. }
  4188. fn issue_subscriptions(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>> {
  4189. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  4190. let mut auth_headers = HashMap::<String, String>::new();
  4191. let mut auth_query = HashMap::<String, String>::new();
  4192. if let Some(ref apikey) = configuration.api_key {
  4193. let key = apikey.key.clone();
  4194. let val = match apikey.prefix {
  4195. Some(ref prefix) => format!("{} {}", prefix, key),
  4196. None => key,
  4197. };
  4198. auth_query.insert("access_token".to_owned(), val);
  4199. };
  4200. if let Some(ref apikey) = configuration.api_key {
  4201. let key = apikey.key.clone();
  4202. let val = match apikey.prefix {
  4203. Some(ref prefix) => format!("{} {}", prefix, key),
  4204. None => key,
  4205. };
  4206. auth_headers.insert("Authorization".to_owned(), val);
  4207. };
  4208. if let Some(ref auth_conf) = configuration.basic_auth {
  4209. let auth = hyper::header::Authorization(
  4210. hyper::header::Basic {
  4211. username: auth_conf.0.to_owned(),
  4212. password: auth_conf.1.to_owned(),
  4213. }
  4214. );
  4215. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  4216. };
  4217. if let Some(ref apikey) = configuration.api_key {
  4218. let key = apikey.key.clone();
  4219. let val = match apikey.prefix {
  4220. Some(ref prefix) => format!("{} {}", prefix, key),
  4221. None => key,
  4222. };
  4223. auth_headers.insert("Sudo".to_owned(), val);
  4224. };
  4225. if let Some(ref apikey) = configuration.api_key {
  4226. let key = apikey.key.clone();
  4227. let val = match apikey.prefix {
  4228. Some(ref prefix) => format!("{} {}", prefix, key),
  4229. None => key,
  4230. };
  4231. auth_query.insert("sudo".to_owned(), val);
  4232. };
  4233. if let Some(ref apikey) = configuration.api_key {
  4234. let key = apikey.key.clone();
  4235. let val = match apikey.prefix {
  4236. Some(ref prefix) => format!("{} {}", prefix, key),
  4237. None => key,
  4238. };
  4239. auth_query.insert("token".to_owned(), val);
  4240. };
  4241. let method = hyper::Method::Get;
  4242. let query_string = {
  4243. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  4244. for (key, val) in &auth_query {
  4245. query.append_pair(key, val);
  4246. }
  4247. query.finish()
  4248. };
  4249. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/subscriptions?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  4250. // TODO(farcaller): handle error
  4251. // if let Err(e) = uri {
  4252. // return Box::new(futures::future::err(e));
  4253. // }
  4254. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  4255. let mut req = hyper::Request::new(method, uri);
  4256. if let Some(ref user_agent) = configuration.user_agent {
  4257. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  4258. }
  4259. for (key, val) in auth_headers {
  4260. req.headers_mut().set_raw(key, val);
  4261. }
  4262. // send request
  4263. Box::new(
  4264. configuration.client.request(req)
  4265. .map_err(|e| Error::from(e))
  4266. .and_then(|resp| {
  4267. let status = resp.status();
  4268. resp.body().concat2()
  4269. .and_then(move |body| Ok((status, body)))
  4270. .map_err(|e| Error::from(e))
  4271. })
  4272. .and_then(|(status, body)| {
  4273. if status.is_success() {
  4274. Ok(body)
  4275. } else {
  4276. Err(Error::from((status, &*body)))
  4277. }
  4278. })
  4279. .and_then(|body| {
  4280. let parsed: Result<Vec<::models::User>, _> = serde_json::from_slice(&body);
  4281. parsed.map_err(|e| Error::from(e))
  4282. })
  4283. )
  4284. }
  4285. fn issue_tracked_times(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = Vec<::models::TrackedTime>, Error = Error<serde_json::Value>>> {
  4286. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  4287. let mut auth_headers = HashMap::<String, String>::new();
  4288. let mut auth_query = HashMap::<String, String>::new();
  4289. if let Some(ref apikey) = configuration.api_key {
  4290. let key = apikey.key.clone();
  4291. let val = match apikey.prefix {
  4292. Some(ref prefix) => format!("{} {}", prefix, key),
  4293. None => key,
  4294. };
  4295. auth_query.insert("access_token".to_owned(), val);
  4296. };
  4297. if let Some(ref apikey) = configuration.api_key {
  4298. let key = apikey.key.clone();
  4299. let val = match apikey.prefix {
  4300. Some(ref prefix) => format!("{} {}", prefix, key),
  4301. None => key,
  4302. };
  4303. auth_headers.insert("Authorization".to_owned(), val);
  4304. };
  4305. if let Some(ref auth_conf) = configuration.basic_auth {
  4306. let auth = hyper::header::Authorization(
  4307. hyper::header::Basic {
  4308. username: auth_conf.0.to_owned(),
  4309. password: auth_conf.1.to_owned(),
  4310. }
  4311. );
  4312. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  4313. };
  4314. if let Some(ref apikey) = configuration.api_key {
  4315. let key = apikey.key.clone();
  4316. let val = match apikey.prefix {
  4317. Some(ref prefix) => format!("{} {}", prefix, key),
  4318. None => key,
  4319. };
  4320. auth_headers.insert("Sudo".to_owned(), val);
  4321. };
  4322. if let Some(ref apikey) = configuration.api_key {
  4323. let key = apikey.key.clone();
  4324. let val = match apikey.prefix {
  4325. Some(ref prefix) => format!("{} {}", prefix, key),
  4326. None => key,
  4327. };
  4328. auth_query.insert("sudo".to_owned(), val);
  4329. };
  4330. if let Some(ref apikey) = configuration.api_key {
  4331. let key = apikey.key.clone();
  4332. let val = match apikey.prefix {
  4333. Some(ref prefix) => format!("{} {}", prefix, key),
  4334. None => key,
  4335. };
  4336. auth_query.insert("token".to_owned(), val);
  4337. };
  4338. let method = hyper::Method::Get;
  4339. let query_string = {
  4340. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  4341. for (key, val) in &auth_query {
  4342. query.append_pair(key, val);
  4343. }
  4344. query.finish()
  4345. };
  4346. let uri_str = format!("{}/repos/{owner}/{repo}/issues/{index}/times?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
  4347. // TODO(farcaller): handle error
  4348. // if let Err(e) = uri {
  4349. // return Box::new(futures::future::err(e));
  4350. // }
  4351. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  4352. let mut req = hyper::Request::new(method, uri);
  4353. if let Some(ref user_agent) = configuration.user_agent {
  4354. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  4355. }
  4356. for (key, val) in auth_headers {
  4357. req.headers_mut().set_raw(key, val);
  4358. }
  4359. // send request
  4360. Box::new(
  4361. configuration.client.request(req)
  4362. .map_err(|e| Error::from(e))
  4363. .and_then(|resp| {
  4364. let status = resp.status();
  4365. resp.body().concat2()
  4366. .and_then(move |body| Ok((status, body)))
  4367. .map_err(|e| Error::from(e))
  4368. })
  4369. .and_then(|(status, body)| {
  4370. if status.is_success() {
  4371. Ok(body)
  4372. } else {
  4373. Err(Error::from((status, &*body)))
  4374. }
  4375. })
  4376. .and_then(|body| {
  4377. let parsed: Result<Vec<::models::TrackedTime>, _> = serde_json::from_slice(&body);
  4378. parsed.map_err(|e| Error::from(e))
  4379. })
  4380. )
  4381. }
  4382. }