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.

3603 lines
137KB

  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 OrganizationApiClient<C: hyper::client::Connect> {
  21. configuration: Rc<configuration::Configuration<C>>,
  22. }
  23. impl<C: hyper::client::Connect> OrganizationApiClient<C> {
  24. pub fn new(configuration: Rc<configuration::Configuration<C>>) -> OrganizationApiClient<C> {
  25. OrganizationApiClient {
  26. configuration: configuration,
  27. }
  28. }
  29. }
  30. pub trait OrganizationApi {
  31. fn create_org_repo(&self, org: &str, body: ::models::CreateRepoOption) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>>;
  32. fn org_add_team_member(&self, id: i64, username: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  33. fn org_add_team_repository(&self, id: i64, org: &str, repo: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  34. fn org_conceal_member(&self, org: &str, username: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  35. fn org_create(&self, organization: ::models::CreateOrgOption) -> Box<Future<Item = ::models::Organization, Error = Error<serde_json::Value>>>;
  36. fn org_create_hook(&self, org: &str, body: ::models::CreateHookOption) -> Box<Future<Item = ::models::Hook, Error = Error<serde_json::Value>>>;
  37. fn org_create_team(&self, org: &str, body: ::models::CreateTeamOption) -> Box<Future<Item = ::models::Team, Error = Error<serde_json::Value>>>;
  38. fn org_delete(&self, org: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  39. fn org_delete_hook(&self, org: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  40. fn org_delete_member(&self, org: &str, username: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  41. fn org_delete_team(&self, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  42. fn org_edit(&self, org: &str, body: ::models::EditOrgOption) -> Box<Future<Item = ::models::Organization, Error = Error<serde_json::Value>>>;
  43. fn org_edit_hook(&self, org: &str, id: i64, body: ::models::EditHookOption) -> Box<Future<Item = ::models::Hook, Error = Error<serde_json::Value>>>;
  44. fn org_edit_team(&self, id: i32, body: ::models::EditTeamOption) -> Box<Future<Item = ::models::Team, Error = Error<serde_json::Value>>>;
  45. fn org_get(&self, org: &str) -> Box<Future<Item = ::models::Organization, Error = Error<serde_json::Value>>>;
  46. fn org_get_hook(&self, org: &str, id: i64) -> Box<Future<Item = ::models::Hook, Error = Error<serde_json::Value>>>;
  47. fn org_get_team(&self, id: i64) -> Box<Future<Item = ::models::Team, Error = Error<serde_json::Value>>>;
  48. fn org_is_member(&self, org: &str, username: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  49. fn org_is_public_member(&self, org: &str, username: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  50. fn org_list_current_user_orgs(&self, ) -> Box<Future<Item = Vec<::models::Organization>, Error = Error<serde_json::Value>>>;
  51. fn org_list_hooks(&self, org: &str) -> Box<Future<Item = Vec<::models::Hook>, Error = Error<serde_json::Value>>>;
  52. fn org_list_members(&self, org: &str) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>>;
  53. fn org_list_public_members(&self, org: &str) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>>;
  54. fn org_list_repos(&self, org: &str) -> Box<Future<Item = Vec<::models::Repository>, Error = Error<serde_json::Value>>>;
  55. fn org_list_team_member(&self, id: i64, username: &str) -> Box<Future<Item = ::models::User, Error = Error<serde_json::Value>>>;
  56. fn org_list_team_members(&self, id: i64) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>>;
  57. fn org_list_team_repos(&self, id: i64) -> Box<Future<Item = Vec<::models::Repository>, Error = Error<serde_json::Value>>>;
  58. fn org_list_teams(&self, org: &str) -> Box<Future<Item = Vec<::models::Team>, Error = Error<serde_json::Value>>>;
  59. fn org_list_user_orgs(&self, username: &str) -> Box<Future<Item = Vec<::models::Organization>, Error = Error<serde_json::Value>>>;
  60. fn org_publicize_member(&self, org: &str, username: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  61. fn org_remove_team_member(&self, id: i64, username: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  62. fn org_remove_team_repository(&self, id: i64, org: &str, repo: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
  63. fn team_search(&self, org: &str, q: &str, include_desc: bool, limit: i32, page: i32) -> Box<Future<Item = ::models::InlineResponse200, Error = Error<serde_json::Value>>>;
  64. }
  65. impl<C: hyper::client::Connect>OrganizationApi for OrganizationApiClient<C> {
  66. fn create_org_repo(&self, org: &str, body: ::models::CreateRepoOption) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>> {
  67. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  68. let mut auth_headers = HashMap::<String, String>::new();
  69. let mut auth_query = HashMap::<String, String>::new();
  70. if let Some(ref apikey) = configuration.api_key {
  71. let key = apikey.key.clone();
  72. let val = match apikey.prefix {
  73. Some(ref prefix) => format!("{} {}", prefix, key),
  74. None => key,
  75. };
  76. auth_query.insert("access_token".to_owned(), val);
  77. };
  78. if let Some(ref apikey) = configuration.api_key {
  79. let key = apikey.key.clone();
  80. let val = match apikey.prefix {
  81. Some(ref prefix) => format!("{} {}", prefix, key),
  82. None => key,
  83. };
  84. auth_headers.insert("Authorization".to_owned(), val);
  85. };
  86. if let Some(ref auth_conf) = configuration.basic_auth {
  87. let auth = hyper::header::Authorization(
  88. hyper::header::Basic {
  89. username: auth_conf.0.to_owned(),
  90. password: auth_conf.1.to_owned(),
  91. }
  92. );
  93. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  94. };
  95. if let Some(ref apikey) = configuration.api_key {
  96. let key = apikey.key.clone();
  97. let val = match apikey.prefix {
  98. Some(ref prefix) => format!("{} {}", prefix, key),
  99. None => key,
  100. };
  101. auth_headers.insert("Sudo".to_owned(), val);
  102. };
  103. if let Some(ref apikey) = configuration.api_key {
  104. let key = apikey.key.clone();
  105. let val = match apikey.prefix {
  106. Some(ref prefix) => format!("{} {}", prefix, key),
  107. None => key,
  108. };
  109. auth_query.insert("sudo".to_owned(), val);
  110. };
  111. if let Some(ref apikey) = configuration.api_key {
  112. let key = apikey.key.clone();
  113. let val = match apikey.prefix {
  114. Some(ref prefix) => format!("{} {}", prefix, key),
  115. None => key,
  116. };
  117. auth_query.insert("token".to_owned(), val);
  118. };
  119. let method = hyper::Method::Post;
  120. let query_string = {
  121. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  122. for (key, val) in &auth_query {
  123. query.append_pair(key, val);
  124. }
  125. query.finish()
  126. };
  127. let uri_str = format!("{}/org/{org}/repos?{}", configuration.base_path, query_string, org=org);
  128. // TODO(farcaller): handle error
  129. // if let Err(e) = uri {
  130. // return Box::new(futures::future::err(e));
  131. // }
  132. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  133. let mut req = hyper::Request::new(method, uri);
  134. if let Some(ref user_agent) = configuration.user_agent {
  135. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  136. }
  137. for (key, val) in auth_headers {
  138. req.headers_mut().set_raw(key, val);
  139. }
  140. let serialized = serde_json::to_string(&body).unwrap();
  141. req.headers_mut().set(hyper::header::ContentType::json());
  142. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  143. req.set_body(serialized);
  144. // send request
  145. Box::new(
  146. configuration.client.request(req)
  147. .map_err(|e| Error::from(e))
  148. .and_then(|resp| {
  149. let status = resp.status();
  150. resp.body().concat2()
  151. .and_then(move |body| Ok((status, body)))
  152. .map_err(|e| Error::from(e))
  153. })
  154. .and_then(|(status, body)| {
  155. if status.is_success() {
  156. Ok(body)
  157. } else {
  158. Err(Error::from((status, &*body)))
  159. }
  160. })
  161. .and_then(|body| {
  162. let parsed: Result<::models::Repository, _> = serde_json::from_slice(&body);
  163. parsed.map_err(|e| Error::from(e))
  164. })
  165. )
  166. }
  167. fn org_add_team_member(&self, id: i64, username: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  168. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  169. let mut auth_headers = HashMap::<String, String>::new();
  170. let mut auth_query = HashMap::<String, String>::new();
  171. if let Some(ref apikey) = configuration.api_key {
  172. let key = apikey.key.clone();
  173. let val = match apikey.prefix {
  174. Some(ref prefix) => format!("{} {}", prefix, key),
  175. None => key,
  176. };
  177. auth_query.insert("access_token".to_owned(), val);
  178. };
  179. if let Some(ref apikey) = configuration.api_key {
  180. let key = apikey.key.clone();
  181. let val = match apikey.prefix {
  182. Some(ref prefix) => format!("{} {}", prefix, key),
  183. None => key,
  184. };
  185. auth_headers.insert("Authorization".to_owned(), val);
  186. };
  187. if let Some(ref auth_conf) = configuration.basic_auth {
  188. let auth = hyper::header::Authorization(
  189. hyper::header::Basic {
  190. username: auth_conf.0.to_owned(),
  191. password: auth_conf.1.to_owned(),
  192. }
  193. );
  194. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  195. };
  196. if let Some(ref apikey) = configuration.api_key {
  197. let key = apikey.key.clone();
  198. let val = match apikey.prefix {
  199. Some(ref prefix) => format!("{} {}", prefix, key),
  200. None => key,
  201. };
  202. auth_headers.insert("Sudo".to_owned(), val);
  203. };
  204. if let Some(ref apikey) = configuration.api_key {
  205. let key = apikey.key.clone();
  206. let val = match apikey.prefix {
  207. Some(ref prefix) => format!("{} {}", prefix, key),
  208. None => key,
  209. };
  210. auth_query.insert("sudo".to_owned(), val);
  211. };
  212. if let Some(ref apikey) = configuration.api_key {
  213. let key = apikey.key.clone();
  214. let val = match apikey.prefix {
  215. Some(ref prefix) => format!("{} {}", prefix, key),
  216. None => key,
  217. };
  218. auth_query.insert("token".to_owned(), val);
  219. };
  220. let method = hyper::Method::Put;
  221. let query_string = {
  222. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  223. for (key, val) in &auth_query {
  224. query.append_pair(key, val);
  225. }
  226. query.finish()
  227. };
  228. let uri_str = format!("{}/teams/{id}/members/{username}?{}", configuration.base_path, query_string, id=id, username=username);
  229. // TODO(farcaller): handle error
  230. // if let Err(e) = uri {
  231. // return Box::new(futures::future::err(e));
  232. // }
  233. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  234. let mut req = hyper::Request::new(method, uri);
  235. if let Some(ref user_agent) = configuration.user_agent {
  236. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  237. }
  238. for (key, val) in auth_headers {
  239. req.headers_mut().set_raw(key, val);
  240. }
  241. // send request
  242. Box::new(
  243. configuration.client.request(req)
  244. .map_err(|e| Error::from(e))
  245. .and_then(|resp| {
  246. let status = resp.status();
  247. resp.body().concat2()
  248. .and_then(move |body| Ok((status, body)))
  249. .map_err(|e| Error::from(e))
  250. })
  251. .and_then(|(status, body)| {
  252. if status.is_success() {
  253. Ok(body)
  254. } else {
  255. Err(Error::from((status, &*body)))
  256. }
  257. })
  258. .and_then(|_| futures::future::ok(()))
  259. )
  260. }
  261. fn org_add_team_repository(&self, id: i64, org: &str, repo: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  262. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  263. let mut auth_headers = HashMap::<String, String>::new();
  264. let mut auth_query = HashMap::<String, String>::new();
  265. if let Some(ref apikey) = configuration.api_key {
  266. let key = apikey.key.clone();
  267. let val = match apikey.prefix {
  268. Some(ref prefix) => format!("{} {}", prefix, key),
  269. None => key,
  270. };
  271. auth_query.insert("access_token".to_owned(), val);
  272. };
  273. if let Some(ref apikey) = configuration.api_key {
  274. let key = apikey.key.clone();
  275. let val = match apikey.prefix {
  276. Some(ref prefix) => format!("{} {}", prefix, key),
  277. None => key,
  278. };
  279. auth_headers.insert("Authorization".to_owned(), val);
  280. };
  281. if let Some(ref auth_conf) = configuration.basic_auth {
  282. let auth = hyper::header::Authorization(
  283. hyper::header::Basic {
  284. username: auth_conf.0.to_owned(),
  285. password: auth_conf.1.to_owned(),
  286. }
  287. );
  288. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  289. };
  290. if let Some(ref apikey) = configuration.api_key {
  291. let key = apikey.key.clone();
  292. let val = match apikey.prefix {
  293. Some(ref prefix) => format!("{} {}", prefix, key),
  294. None => key,
  295. };
  296. auth_headers.insert("Sudo".to_owned(), val);
  297. };
  298. if let Some(ref apikey) = configuration.api_key {
  299. let key = apikey.key.clone();
  300. let val = match apikey.prefix {
  301. Some(ref prefix) => format!("{} {}", prefix, key),
  302. None => key,
  303. };
  304. auth_query.insert("sudo".to_owned(), val);
  305. };
  306. if let Some(ref apikey) = configuration.api_key {
  307. let key = apikey.key.clone();
  308. let val = match apikey.prefix {
  309. Some(ref prefix) => format!("{} {}", prefix, key),
  310. None => key,
  311. };
  312. auth_query.insert("token".to_owned(), val);
  313. };
  314. let method = hyper::Method::Put;
  315. let query_string = {
  316. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  317. for (key, val) in &auth_query {
  318. query.append_pair(key, val);
  319. }
  320. query.finish()
  321. };
  322. let uri_str = format!("{}/teams/{id}/repos/{org}/{repo}?{}", configuration.base_path, query_string, id=id, org=org, repo=repo);
  323. // TODO(farcaller): handle error
  324. // if let Err(e) = uri {
  325. // return Box::new(futures::future::err(e));
  326. // }
  327. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  328. let mut req = hyper::Request::new(method, uri);
  329. if let Some(ref user_agent) = configuration.user_agent {
  330. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  331. }
  332. for (key, val) in auth_headers {
  333. req.headers_mut().set_raw(key, val);
  334. }
  335. // send request
  336. Box::new(
  337. configuration.client.request(req)
  338. .map_err(|e| Error::from(e))
  339. .and_then(|resp| {
  340. let status = resp.status();
  341. resp.body().concat2()
  342. .and_then(move |body| Ok((status, body)))
  343. .map_err(|e| Error::from(e))
  344. })
  345. .and_then(|(status, body)| {
  346. if status.is_success() {
  347. Ok(body)
  348. } else {
  349. Err(Error::from((status, &*body)))
  350. }
  351. })
  352. .and_then(|_| futures::future::ok(()))
  353. )
  354. }
  355. fn org_conceal_member(&self, org: &str, username: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  356. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  357. let mut auth_headers = HashMap::<String, String>::new();
  358. let mut auth_query = HashMap::<String, String>::new();
  359. if let Some(ref apikey) = configuration.api_key {
  360. let key = apikey.key.clone();
  361. let val = match apikey.prefix {
  362. Some(ref prefix) => format!("{} {}", prefix, key),
  363. None => key,
  364. };
  365. auth_query.insert("access_token".to_owned(), val);
  366. };
  367. if let Some(ref apikey) = configuration.api_key {
  368. let key = apikey.key.clone();
  369. let val = match apikey.prefix {
  370. Some(ref prefix) => format!("{} {}", prefix, key),
  371. None => key,
  372. };
  373. auth_headers.insert("Authorization".to_owned(), val);
  374. };
  375. if let Some(ref auth_conf) = configuration.basic_auth {
  376. let auth = hyper::header::Authorization(
  377. hyper::header::Basic {
  378. username: auth_conf.0.to_owned(),
  379. password: auth_conf.1.to_owned(),
  380. }
  381. );
  382. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  383. };
  384. if let Some(ref apikey) = configuration.api_key {
  385. let key = apikey.key.clone();
  386. let val = match apikey.prefix {
  387. Some(ref prefix) => format!("{} {}", prefix, key),
  388. None => key,
  389. };
  390. auth_headers.insert("Sudo".to_owned(), val);
  391. };
  392. if let Some(ref apikey) = configuration.api_key {
  393. let key = apikey.key.clone();
  394. let val = match apikey.prefix {
  395. Some(ref prefix) => format!("{} {}", prefix, key),
  396. None => key,
  397. };
  398. auth_query.insert("sudo".to_owned(), val);
  399. };
  400. if let Some(ref apikey) = configuration.api_key {
  401. let key = apikey.key.clone();
  402. let val = match apikey.prefix {
  403. Some(ref prefix) => format!("{} {}", prefix, key),
  404. None => key,
  405. };
  406. auth_query.insert("token".to_owned(), val);
  407. };
  408. let method = hyper::Method::Delete;
  409. let query_string = {
  410. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  411. for (key, val) in &auth_query {
  412. query.append_pair(key, val);
  413. }
  414. query.finish()
  415. };
  416. let uri_str = format!("{}/orgs/{org}/public_members/{username}?{}", configuration.base_path, query_string, org=org, username=username);
  417. // TODO(farcaller): handle error
  418. // if let Err(e) = uri {
  419. // return Box::new(futures::future::err(e));
  420. // }
  421. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  422. let mut req = hyper::Request::new(method, uri);
  423. if let Some(ref user_agent) = configuration.user_agent {
  424. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  425. }
  426. for (key, val) in auth_headers {
  427. req.headers_mut().set_raw(key, val);
  428. }
  429. // send request
  430. Box::new(
  431. configuration.client.request(req)
  432. .map_err(|e| Error::from(e))
  433. .and_then(|resp| {
  434. let status = resp.status();
  435. resp.body().concat2()
  436. .and_then(move |body| Ok((status, body)))
  437. .map_err(|e| Error::from(e))
  438. })
  439. .and_then(|(status, body)| {
  440. if status.is_success() {
  441. Ok(body)
  442. } else {
  443. Err(Error::from((status, &*body)))
  444. }
  445. })
  446. .and_then(|_| futures::future::ok(()))
  447. )
  448. }
  449. fn org_create(&self, organization: ::models::CreateOrgOption) -> Box<Future<Item = ::models::Organization, Error = Error<serde_json::Value>>> {
  450. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  451. let mut auth_headers = HashMap::<String, String>::new();
  452. let mut auth_query = HashMap::<String, String>::new();
  453. if let Some(ref apikey) = configuration.api_key {
  454. let key = apikey.key.clone();
  455. let val = match apikey.prefix {
  456. Some(ref prefix) => format!("{} {}", prefix, key),
  457. None => key,
  458. };
  459. auth_query.insert("access_token".to_owned(), val);
  460. };
  461. if let Some(ref apikey) = configuration.api_key {
  462. let key = apikey.key.clone();
  463. let val = match apikey.prefix {
  464. Some(ref prefix) => format!("{} {}", prefix, key),
  465. None => key,
  466. };
  467. auth_headers.insert("Authorization".to_owned(), val);
  468. };
  469. if let Some(ref auth_conf) = configuration.basic_auth {
  470. let auth = hyper::header::Authorization(
  471. hyper::header::Basic {
  472. username: auth_conf.0.to_owned(),
  473. password: auth_conf.1.to_owned(),
  474. }
  475. );
  476. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  477. };
  478. if let Some(ref apikey) = configuration.api_key {
  479. let key = apikey.key.clone();
  480. let val = match apikey.prefix {
  481. Some(ref prefix) => format!("{} {}", prefix, key),
  482. None => key,
  483. };
  484. auth_headers.insert("Sudo".to_owned(), val);
  485. };
  486. if let Some(ref apikey) = configuration.api_key {
  487. let key = apikey.key.clone();
  488. let val = match apikey.prefix {
  489. Some(ref prefix) => format!("{} {}", prefix, key),
  490. None => key,
  491. };
  492. auth_query.insert("sudo".to_owned(), val);
  493. };
  494. if let Some(ref apikey) = configuration.api_key {
  495. let key = apikey.key.clone();
  496. let val = match apikey.prefix {
  497. Some(ref prefix) => format!("{} {}", prefix, key),
  498. None => key,
  499. };
  500. auth_query.insert("token".to_owned(), val);
  501. };
  502. let method = hyper::Method::Post;
  503. let query_string = {
  504. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  505. for (key, val) in &auth_query {
  506. query.append_pair(key, val);
  507. }
  508. query.finish()
  509. };
  510. let uri_str = format!("{}/orgs?{}", configuration.base_path, query_string);
  511. // TODO(farcaller): handle error
  512. // if let Err(e) = uri {
  513. // return Box::new(futures::future::err(e));
  514. // }
  515. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  516. let mut req = hyper::Request::new(method, uri);
  517. if let Some(ref user_agent) = configuration.user_agent {
  518. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  519. }
  520. for (key, val) in auth_headers {
  521. req.headers_mut().set_raw(key, val);
  522. }
  523. let serialized = serde_json::to_string(&organization).unwrap();
  524. req.headers_mut().set(hyper::header::ContentType::json());
  525. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  526. req.set_body(serialized);
  527. // send request
  528. Box::new(
  529. configuration.client.request(req)
  530. .map_err(|e| Error::from(e))
  531. .and_then(|resp| {
  532. let status = resp.status();
  533. resp.body().concat2()
  534. .and_then(move |body| Ok((status, body)))
  535. .map_err(|e| Error::from(e))
  536. })
  537. .and_then(|(status, body)| {
  538. if status.is_success() {
  539. Ok(body)
  540. } else {
  541. Err(Error::from((status, &*body)))
  542. }
  543. })
  544. .and_then(|body| {
  545. let parsed: Result<::models::Organization, _> = serde_json::from_slice(&body);
  546. parsed.map_err(|e| Error::from(e))
  547. })
  548. )
  549. }
  550. fn org_create_hook(&self, org: &str, body: ::models::CreateHookOption) -> Box<Future<Item = ::models::Hook, Error = Error<serde_json::Value>>> {
  551. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  552. let mut auth_headers = HashMap::<String, String>::new();
  553. let mut auth_query = HashMap::<String, String>::new();
  554. if let Some(ref apikey) = configuration.api_key {
  555. let key = apikey.key.clone();
  556. let val = match apikey.prefix {
  557. Some(ref prefix) => format!("{} {}", prefix, key),
  558. None => key,
  559. };
  560. auth_query.insert("access_token".to_owned(), val);
  561. };
  562. if let Some(ref apikey) = configuration.api_key {
  563. let key = apikey.key.clone();
  564. let val = match apikey.prefix {
  565. Some(ref prefix) => format!("{} {}", prefix, key),
  566. None => key,
  567. };
  568. auth_headers.insert("Authorization".to_owned(), val);
  569. };
  570. if let Some(ref auth_conf) = configuration.basic_auth {
  571. let auth = hyper::header::Authorization(
  572. hyper::header::Basic {
  573. username: auth_conf.0.to_owned(),
  574. password: auth_conf.1.to_owned(),
  575. }
  576. );
  577. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  578. };
  579. if let Some(ref apikey) = configuration.api_key {
  580. let key = apikey.key.clone();
  581. let val = match apikey.prefix {
  582. Some(ref prefix) => format!("{} {}", prefix, key),
  583. None => key,
  584. };
  585. auth_headers.insert("Sudo".to_owned(), val);
  586. };
  587. if let Some(ref apikey) = configuration.api_key {
  588. let key = apikey.key.clone();
  589. let val = match apikey.prefix {
  590. Some(ref prefix) => format!("{} {}", prefix, key),
  591. None => key,
  592. };
  593. auth_query.insert("sudo".to_owned(), val);
  594. };
  595. if let Some(ref apikey) = configuration.api_key {
  596. let key = apikey.key.clone();
  597. let val = match apikey.prefix {
  598. Some(ref prefix) => format!("{} {}", prefix, key),
  599. None => key,
  600. };
  601. auth_query.insert("token".to_owned(), val);
  602. };
  603. let method = hyper::Method::Post;
  604. let query_string = {
  605. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  606. for (key, val) in &auth_query {
  607. query.append_pair(key, val);
  608. }
  609. query.finish()
  610. };
  611. let uri_str = format!("{}/orgs/{org}/hooks/?{}", configuration.base_path, query_string, org=org);
  612. // TODO(farcaller): handle error
  613. // if let Err(e) = uri {
  614. // return Box::new(futures::future::err(e));
  615. // }
  616. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  617. let mut req = hyper::Request::new(method, uri);
  618. if let Some(ref user_agent) = configuration.user_agent {
  619. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  620. }
  621. for (key, val) in auth_headers {
  622. req.headers_mut().set_raw(key, val);
  623. }
  624. let serialized = serde_json::to_string(&body).unwrap();
  625. req.headers_mut().set(hyper::header::ContentType::json());
  626. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  627. req.set_body(serialized);
  628. // send request
  629. Box::new(
  630. configuration.client.request(req)
  631. .map_err(|e| Error::from(e))
  632. .and_then(|resp| {
  633. let status = resp.status();
  634. resp.body().concat2()
  635. .and_then(move |body| Ok((status, body)))
  636. .map_err(|e| Error::from(e))
  637. })
  638. .and_then(|(status, body)| {
  639. if status.is_success() {
  640. Ok(body)
  641. } else {
  642. Err(Error::from((status, &*body)))
  643. }
  644. })
  645. .and_then(|body| {
  646. let parsed: Result<::models::Hook, _> = serde_json::from_slice(&body);
  647. parsed.map_err(|e| Error::from(e))
  648. })
  649. )
  650. }
  651. fn org_create_team(&self, org: &str, body: ::models::CreateTeamOption) -> Box<Future<Item = ::models::Team, Error = Error<serde_json::Value>>> {
  652. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  653. let mut auth_headers = HashMap::<String, String>::new();
  654. let mut auth_query = HashMap::<String, String>::new();
  655. if let Some(ref apikey) = configuration.api_key {
  656. let key = apikey.key.clone();
  657. let val = match apikey.prefix {
  658. Some(ref prefix) => format!("{} {}", prefix, key),
  659. None => key,
  660. };
  661. auth_query.insert("access_token".to_owned(), val);
  662. };
  663. if let Some(ref apikey) = configuration.api_key {
  664. let key = apikey.key.clone();
  665. let val = match apikey.prefix {
  666. Some(ref prefix) => format!("{} {}", prefix, key),
  667. None => key,
  668. };
  669. auth_headers.insert("Authorization".to_owned(), val);
  670. };
  671. if let Some(ref auth_conf) = configuration.basic_auth {
  672. let auth = hyper::header::Authorization(
  673. hyper::header::Basic {
  674. username: auth_conf.0.to_owned(),
  675. password: auth_conf.1.to_owned(),
  676. }
  677. );
  678. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  679. };
  680. if let Some(ref apikey) = configuration.api_key {
  681. let key = apikey.key.clone();
  682. let val = match apikey.prefix {
  683. Some(ref prefix) => format!("{} {}", prefix, key),
  684. None => key,
  685. };
  686. auth_headers.insert("Sudo".to_owned(), val);
  687. };
  688. if let Some(ref apikey) = configuration.api_key {
  689. let key = apikey.key.clone();
  690. let val = match apikey.prefix {
  691. Some(ref prefix) => format!("{} {}", prefix, key),
  692. None => key,
  693. };
  694. auth_query.insert("sudo".to_owned(), val);
  695. };
  696. if let Some(ref apikey) = configuration.api_key {
  697. let key = apikey.key.clone();
  698. let val = match apikey.prefix {
  699. Some(ref prefix) => format!("{} {}", prefix, key),
  700. None => key,
  701. };
  702. auth_query.insert("token".to_owned(), val);
  703. };
  704. let method = hyper::Method::Post;
  705. let query_string = {
  706. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  707. for (key, val) in &auth_query {
  708. query.append_pair(key, val);
  709. }
  710. query.finish()
  711. };
  712. let uri_str = format!("{}/orgs/{org}/teams?{}", configuration.base_path, query_string, org=org);
  713. // TODO(farcaller): handle error
  714. // if let Err(e) = uri {
  715. // return Box::new(futures::future::err(e));
  716. // }
  717. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  718. let mut req = hyper::Request::new(method, uri);
  719. if let Some(ref user_agent) = configuration.user_agent {
  720. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  721. }
  722. for (key, val) in auth_headers {
  723. req.headers_mut().set_raw(key, val);
  724. }
  725. let serialized = serde_json::to_string(&body).unwrap();
  726. req.headers_mut().set(hyper::header::ContentType::json());
  727. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  728. req.set_body(serialized);
  729. // send request
  730. Box::new(
  731. configuration.client.request(req)
  732. .map_err(|e| Error::from(e))
  733. .and_then(|resp| {
  734. let status = resp.status();
  735. resp.body().concat2()
  736. .and_then(move |body| Ok((status, body)))
  737. .map_err(|e| Error::from(e))
  738. })
  739. .and_then(|(status, body)| {
  740. if status.is_success() {
  741. Ok(body)
  742. } else {
  743. Err(Error::from((status, &*body)))
  744. }
  745. })
  746. .and_then(|body| {
  747. let parsed: Result<::models::Team, _> = serde_json::from_slice(&body);
  748. parsed.map_err(|e| Error::from(e))
  749. })
  750. )
  751. }
  752. fn org_delete(&self, org: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  753. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  754. let mut auth_headers = HashMap::<String, String>::new();
  755. let mut auth_query = HashMap::<String, String>::new();
  756. if let Some(ref apikey) = configuration.api_key {
  757. let key = apikey.key.clone();
  758. let val = match apikey.prefix {
  759. Some(ref prefix) => format!("{} {}", prefix, key),
  760. None => key,
  761. };
  762. auth_query.insert("access_token".to_owned(), val);
  763. };
  764. if let Some(ref apikey) = configuration.api_key {
  765. let key = apikey.key.clone();
  766. let val = match apikey.prefix {
  767. Some(ref prefix) => format!("{} {}", prefix, key),
  768. None => key,
  769. };
  770. auth_headers.insert("Authorization".to_owned(), val);
  771. };
  772. if let Some(ref auth_conf) = configuration.basic_auth {
  773. let auth = hyper::header::Authorization(
  774. hyper::header::Basic {
  775. username: auth_conf.0.to_owned(),
  776. password: auth_conf.1.to_owned(),
  777. }
  778. );
  779. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  780. };
  781. if let Some(ref apikey) = configuration.api_key {
  782. let key = apikey.key.clone();
  783. let val = match apikey.prefix {
  784. Some(ref prefix) => format!("{} {}", prefix, key),
  785. None => key,
  786. };
  787. auth_headers.insert("Sudo".to_owned(), val);
  788. };
  789. if let Some(ref apikey) = configuration.api_key {
  790. let key = apikey.key.clone();
  791. let val = match apikey.prefix {
  792. Some(ref prefix) => format!("{} {}", prefix, key),
  793. None => key,
  794. };
  795. auth_query.insert("sudo".to_owned(), val);
  796. };
  797. if let Some(ref apikey) = configuration.api_key {
  798. let key = apikey.key.clone();
  799. let val = match apikey.prefix {
  800. Some(ref prefix) => format!("{} {}", prefix, key),
  801. None => key,
  802. };
  803. auth_query.insert("token".to_owned(), val);
  804. };
  805. let method = hyper::Method::Delete;
  806. let query_string = {
  807. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  808. for (key, val) in &auth_query {
  809. query.append_pair(key, val);
  810. }
  811. query.finish()
  812. };
  813. let uri_str = format!("{}/orgs/{org}?{}", configuration.base_path, query_string, org=org);
  814. // TODO(farcaller): handle error
  815. // if let Err(e) = uri {
  816. // return Box::new(futures::future::err(e));
  817. // }
  818. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  819. let mut req = hyper::Request::new(method, uri);
  820. if let Some(ref user_agent) = configuration.user_agent {
  821. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  822. }
  823. for (key, val) in auth_headers {
  824. req.headers_mut().set_raw(key, val);
  825. }
  826. // send request
  827. Box::new(
  828. configuration.client.request(req)
  829. .map_err(|e| Error::from(e))
  830. .and_then(|resp| {
  831. let status = resp.status();
  832. resp.body().concat2()
  833. .and_then(move |body| Ok((status, body)))
  834. .map_err(|e| Error::from(e))
  835. })
  836. .and_then(|(status, body)| {
  837. if status.is_success() {
  838. Ok(body)
  839. } else {
  840. Err(Error::from((status, &*body)))
  841. }
  842. })
  843. .and_then(|_| futures::future::ok(()))
  844. )
  845. }
  846. fn org_delete_hook(&self, org: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  847. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  848. let mut auth_headers = HashMap::<String, String>::new();
  849. let mut auth_query = HashMap::<String, String>::new();
  850. if let Some(ref apikey) = configuration.api_key {
  851. let key = apikey.key.clone();
  852. let val = match apikey.prefix {
  853. Some(ref prefix) => format!("{} {}", prefix, key),
  854. None => key,
  855. };
  856. auth_query.insert("access_token".to_owned(), val);
  857. };
  858. if let Some(ref apikey) = configuration.api_key {
  859. let key = apikey.key.clone();
  860. let val = match apikey.prefix {
  861. Some(ref prefix) => format!("{} {}", prefix, key),
  862. None => key,
  863. };
  864. auth_headers.insert("Authorization".to_owned(), val);
  865. };
  866. if let Some(ref auth_conf) = configuration.basic_auth {
  867. let auth = hyper::header::Authorization(
  868. hyper::header::Basic {
  869. username: auth_conf.0.to_owned(),
  870. password: auth_conf.1.to_owned(),
  871. }
  872. );
  873. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  874. };
  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_headers.insert("Sudo".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_query.insert("sudo".to_owned(), val);
  890. };
  891. if let Some(ref apikey) = configuration.api_key {
  892. let key = apikey.key.clone();
  893. let val = match apikey.prefix {
  894. Some(ref prefix) => format!("{} {}", prefix, key),
  895. None => key,
  896. };
  897. auth_query.insert("token".to_owned(), val);
  898. };
  899. let method = hyper::Method::Delete;
  900. let query_string = {
  901. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  902. for (key, val) in &auth_query {
  903. query.append_pair(key, val);
  904. }
  905. query.finish()
  906. };
  907. let uri_str = format!("{}/orgs/{org}/hooks/{id}?{}", configuration.base_path, query_string, org=org, id=id);
  908. // TODO(farcaller): handle error
  909. // if let Err(e) = uri {
  910. // return Box::new(futures::future::err(e));
  911. // }
  912. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  913. let mut req = hyper::Request::new(method, uri);
  914. if let Some(ref user_agent) = configuration.user_agent {
  915. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  916. }
  917. for (key, val) in auth_headers {
  918. req.headers_mut().set_raw(key, val);
  919. }
  920. // send request
  921. Box::new(
  922. configuration.client.request(req)
  923. .map_err(|e| Error::from(e))
  924. .and_then(|resp| {
  925. let status = resp.status();
  926. resp.body().concat2()
  927. .and_then(move |body| Ok((status, body)))
  928. .map_err(|e| Error::from(e))
  929. })
  930. .and_then(|(status, body)| {
  931. if status.is_success() {
  932. Ok(body)
  933. } else {
  934. Err(Error::from((status, &*body)))
  935. }
  936. })
  937. .and_then(|_| futures::future::ok(()))
  938. )
  939. }
  940. fn org_delete_member(&self, org: &str, username: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  941. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  942. let mut auth_headers = HashMap::<String, String>::new();
  943. let mut auth_query = HashMap::<String, String>::new();
  944. if let Some(ref apikey) = configuration.api_key {
  945. let key = apikey.key.clone();
  946. let val = match apikey.prefix {
  947. Some(ref prefix) => format!("{} {}", prefix, key),
  948. None => key,
  949. };
  950. auth_query.insert("access_token".to_owned(), val);
  951. };
  952. if let Some(ref apikey) = configuration.api_key {
  953. let key = apikey.key.clone();
  954. let val = match apikey.prefix {
  955. Some(ref prefix) => format!("{} {}", prefix, key),
  956. None => key,
  957. };
  958. auth_headers.insert("Authorization".to_owned(), val);
  959. };
  960. if let Some(ref auth_conf) = configuration.basic_auth {
  961. let auth = hyper::header::Authorization(
  962. hyper::header::Basic {
  963. username: auth_conf.0.to_owned(),
  964. password: auth_conf.1.to_owned(),
  965. }
  966. );
  967. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  968. };
  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_headers.insert("Sudo".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_query.insert("sudo".to_owned(), val);
  984. };
  985. if let Some(ref apikey) = configuration.api_key {
  986. let key = apikey.key.clone();
  987. let val = match apikey.prefix {
  988. Some(ref prefix) => format!("{} {}", prefix, key),
  989. None => key,
  990. };
  991. auth_query.insert("token".to_owned(), val);
  992. };
  993. let method = hyper::Method::Delete;
  994. let query_string = {
  995. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  996. for (key, val) in &auth_query {
  997. query.append_pair(key, val);
  998. }
  999. query.finish()
  1000. };
  1001. let uri_str = format!("{}/orgs/{org}/members/{username}?{}", configuration.base_path, query_string, org=org, username=username);
  1002. // TODO(farcaller): handle error
  1003. // if let Err(e) = uri {
  1004. // return Box::new(futures::future::err(e));
  1005. // }
  1006. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1007. let mut req = hyper::Request::new(method, uri);
  1008. if let Some(ref user_agent) = configuration.user_agent {
  1009. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1010. }
  1011. for (key, val) in auth_headers {
  1012. req.headers_mut().set_raw(key, val);
  1013. }
  1014. // send request
  1015. Box::new(
  1016. configuration.client.request(req)
  1017. .map_err(|e| Error::from(e))
  1018. .and_then(|resp| {
  1019. let status = resp.status();
  1020. resp.body().concat2()
  1021. .and_then(move |body| Ok((status, body)))
  1022. .map_err(|e| Error::from(e))
  1023. })
  1024. .and_then(|(status, body)| {
  1025. if status.is_success() {
  1026. Ok(body)
  1027. } else {
  1028. Err(Error::from((status, &*body)))
  1029. }
  1030. })
  1031. .and_then(|_| futures::future::ok(()))
  1032. )
  1033. }
  1034. fn org_delete_team(&self, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  1035. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1036. let mut auth_headers = HashMap::<String, String>::new();
  1037. let mut auth_query = HashMap::<String, String>::new();
  1038. if let Some(ref apikey) = configuration.api_key {
  1039. let key = apikey.key.clone();
  1040. let val = match apikey.prefix {
  1041. Some(ref prefix) => format!("{} {}", prefix, key),
  1042. None => key,
  1043. };
  1044. auth_query.insert("access_token".to_owned(), val);
  1045. };
  1046. if let Some(ref apikey) = configuration.api_key {
  1047. let key = apikey.key.clone();
  1048. let val = match apikey.prefix {
  1049. Some(ref prefix) => format!("{} {}", prefix, key),
  1050. None => key,
  1051. };
  1052. auth_headers.insert("Authorization".to_owned(), val);
  1053. };
  1054. if let Some(ref auth_conf) = configuration.basic_auth {
  1055. let auth = hyper::header::Authorization(
  1056. hyper::header::Basic {
  1057. username: auth_conf.0.to_owned(),
  1058. password: auth_conf.1.to_owned(),
  1059. }
  1060. );
  1061. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1062. };
  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_headers.insert("Sudo".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_query.insert("sudo".to_owned(), val);
  1078. };
  1079. if let Some(ref apikey) = configuration.api_key {
  1080. let key = apikey.key.clone();
  1081. let val = match apikey.prefix {
  1082. Some(ref prefix) => format!("{} {}", prefix, key),
  1083. None => key,
  1084. };
  1085. auth_query.insert("token".to_owned(), val);
  1086. };
  1087. let method = hyper::Method::Delete;
  1088. let query_string = {
  1089. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1090. for (key, val) in &auth_query {
  1091. query.append_pair(key, val);
  1092. }
  1093. query.finish()
  1094. };
  1095. let uri_str = format!("{}/teams/{id}?{}", configuration.base_path, query_string, id=id);
  1096. // TODO(farcaller): handle error
  1097. // if let Err(e) = uri {
  1098. // return Box::new(futures::future::err(e));
  1099. // }
  1100. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1101. let mut req = hyper::Request::new(method, uri);
  1102. if let Some(ref user_agent) = configuration.user_agent {
  1103. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1104. }
  1105. for (key, val) in auth_headers {
  1106. req.headers_mut().set_raw(key, val);
  1107. }
  1108. // send request
  1109. Box::new(
  1110. configuration.client.request(req)
  1111. .map_err(|e| Error::from(e))
  1112. .and_then(|resp| {
  1113. let status = resp.status();
  1114. resp.body().concat2()
  1115. .and_then(move |body| Ok((status, body)))
  1116. .map_err(|e| Error::from(e))
  1117. })
  1118. .and_then(|(status, body)| {
  1119. if status.is_success() {
  1120. Ok(body)
  1121. } else {
  1122. Err(Error::from((status, &*body)))
  1123. }
  1124. })
  1125. .and_then(|_| futures::future::ok(()))
  1126. )
  1127. }
  1128. fn org_edit(&self, org: &str, body: ::models::EditOrgOption) -> Box<Future<Item = ::models::Organization, Error = Error<serde_json::Value>>> {
  1129. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1130. let mut auth_headers = HashMap::<String, String>::new();
  1131. let mut auth_query = HashMap::<String, String>::new();
  1132. if let Some(ref apikey) = configuration.api_key {
  1133. let key = apikey.key.clone();
  1134. let val = match apikey.prefix {
  1135. Some(ref prefix) => format!("{} {}", prefix, key),
  1136. None => key,
  1137. };
  1138. auth_query.insert("access_token".to_owned(), val);
  1139. };
  1140. if let Some(ref apikey) = configuration.api_key {
  1141. let key = apikey.key.clone();
  1142. let val = match apikey.prefix {
  1143. Some(ref prefix) => format!("{} {}", prefix, key),
  1144. None => key,
  1145. };
  1146. auth_headers.insert("Authorization".to_owned(), val);
  1147. };
  1148. if let Some(ref auth_conf) = configuration.basic_auth {
  1149. let auth = hyper::header::Authorization(
  1150. hyper::header::Basic {
  1151. username: auth_conf.0.to_owned(),
  1152. password: auth_conf.1.to_owned(),
  1153. }
  1154. );
  1155. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1156. };
  1157. if let Some(ref apikey) = configuration.api_key {
  1158. let key = apikey.key.clone();
  1159. let val = match apikey.prefix {
  1160. Some(ref prefix) => format!("{} {}", prefix, key),
  1161. None => key,
  1162. };
  1163. auth_headers.insert("Sudo".to_owned(), val);
  1164. };
  1165. if let Some(ref apikey) = configuration.api_key {
  1166. let key = apikey.key.clone();
  1167. let val = match apikey.prefix {
  1168. Some(ref prefix) => format!("{} {}", prefix, key),
  1169. None => key,
  1170. };
  1171. auth_query.insert("sudo".to_owned(), val);
  1172. };
  1173. if let Some(ref apikey) = configuration.api_key {
  1174. let key = apikey.key.clone();
  1175. let val = match apikey.prefix {
  1176. Some(ref prefix) => format!("{} {}", prefix, key),
  1177. None => key,
  1178. };
  1179. auth_query.insert("token".to_owned(), val);
  1180. };
  1181. let method = hyper::Method::Patch;
  1182. let query_string = {
  1183. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1184. for (key, val) in &auth_query {
  1185. query.append_pair(key, val);
  1186. }
  1187. query.finish()
  1188. };
  1189. let uri_str = format!("{}/orgs/{org}?{}", configuration.base_path, query_string, org=org);
  1190. // TODO(farcaller): handle error
  1191. // if let Err(e) = uri {
  1192. // return Box::new(futures::future::err(e));
  1193. // }
  1194. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1195. let mut req = hyper::Request::new(method, uri);
  1196. if let Some(ref user_agent) = configuration.user_agent {
  1197. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1198. }
  1199. for (key, val) in auth_headers {
  1200. req.headers_mut().set_raw(key, val);
  1201. }
  1202. let serialized = serde_json::to_string(&body).unwrap();
  1203. req.headers_mut().set(hyper::header::ContentType::json());
  1204. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  1205. req.set_body(serialized);
  1206. // send request
  1207. Box::new(
  1208. configuration.client.request(req)
  1209. .map_err(|e| Error::from(e))
  1210. .and_then(|resp| {
  1211. let status = resp.status();
  1212. resp.body().concat2()
  1213. .and_then(move |body| Ok((status, body)))
  1214. .map_err(|e| Error::from(e))
  1215. })
  1216. .and_then(|(status, body)| {
  1217. if status.is_success() {
  1218. Ok(body)
  1219. } else {
  1220. Err(Error::from((status, &*body)))
  1221. }
  1222. })
  1223. .and_then(|body| {
  1224. let parsed: Result<::models::Organization, _> = serde_json::from_slice(&body);
  1225. parsed.map_err(|e| Error::from(e))
  1226. })
  1227. )
  1228. }
  1229. fn org_edit_hook(&self, org: &str, id: i64, body: ::models::EditHookOption) -> Box<Future<Item = ::models::Hook, Error = Error<serde_json::Value>>> {
  1230. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1231. let mut auth_headers = HashMap::<String, String>::new();
  1232. let mut auth_query = HashMap::<String, String>::new();
  1233. if let Some(ref apikey) = configuration.api_key {
  1234. let key = apikey.key.clone();
  1235. let val = match apikey.prefix {
  1236. Some(ref prefix) => format!("{} {}", prefix, key),
  1237. None => key,
  1238. };
  1239. auth_query.insert("access_token".to_owned(), val);
  1240. };
  1241. if let Some(ref apikey) = configuration.api_key {
  1242. let key = apikey.key.clone();
  1243. let val = match apikey.prefix {
  1244. Some(ref prefix) => format!("{} {}", prefix, key),
  1245. None => key,
  1246. };
  1247. auth_headers.insert("Authorization".to_owned(), val);
  1248. };
  1249. if let Some(ref auth_conf) = configuration.basic_auth {
  1250. let auth = hyper::header::Authorization(
  1251. hyper::header::Basic {
  1252. username: auth_conf.0.to_owned(),
  1253. password: auth_conf.1.to_owned(),
  1254. }
  1255. );
  1256. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1257. };
  1258. if let Some(ref apikey) = configuration.api_key {
  1259. let key = apikey.key.clone();
  1260. let val = match apikey.prefix {
  1261. Some(ref prefix) => format!("{} {}", prefix, key),
  1262. None => key,
  1263. };
  1264. auth_headers.insert("Sudo".to_owned(), val);
  1265. };
  1266. if let Some(ref apikey) = configuration.api_key {
  1267. let key = apikey.key.clone();
  1268. let val = match apikey.prefix {
  1269. Some(ref prefix) => format!("{} {}", prefix, key),
  1270. None => key,
  1271. };
  1272. auth_query.insert("sudo".to_owned(), val);
  1273. };
  1274. if let Some(ref apikey) = configuration.api_key {
  1275. let key = apikey.key.clone();
  1276. let val = match apikey.prefix {
  1277. Some(ref prefix) => format!("{} {}", prefix, key),
  1278. None => key,
  1279. };
  1280. auth_query.insert("token".to_owned(), val);
  1281. };
  1282. let method = hyper::Method::Patch;
  1283. let query_string = {
  1284. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1285. for (key, val) in &auth_query {
  1286. query.append_pair(key, val);
  1287. }
  1288. query.finish()
  1289. };
  1290. let uri_str = format!("{}/orgs/{org}/hooks/{id}?{}", configuration.base_path, query_string, org=org, id=id);
  1291. // TODO(farcaller): handle error
  1292. // if let Err(e) = uri {
  1293. // return Box::new(futures::future::err(e));
  1294. // }
  1295. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1296. let mut req = hyper::Request::new(method, uri);
  1297. if let Some(ref user_agent) = configuration.user_agent {
  1298. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1299. }
  1300. for (key, val) in auth_headers {
  1301. req.headers_mut().set_raw(key, val);
  1302. }
  1303. let serialized = serde_json::to_string(&body).unwrap();
  1304. req.headers_mut().set(hyper::header::ContentType::json());
  1305. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  1306. req.set_body(serialized);
  1307. // send request
  1308. Box::new(
  1309. configuration.client.request(req)
  1310. .map_err(|e| Error::from(e))
  1311. .and_then(|resp| {
  1312. let status = resp.status();
  1313. resp.body().concat2()
  1314. .and_then(move |body| Ok((status, body)))
  1315. .map_err(|e| Error::from(e))
  1316. })
  1317. .and_then(|(status, body)| {
  1318. if status.is_success() {
  1319. Ok(body)
  1320. } else {
  1321. Err(Error::from((status, &*body)))
  1322. }
  1323. })
  1324. .and_then(|body| {
  1325. let parsed: Result<::models::Hook, _> = serde_json::from_slice(&body);
  1326. parsed.map_err(|e| Error::from(e))
  1327. })
  1328. )
  1329. }
  1330. fn org_edit_team(&self, id: i32, body: ::models::EditTeamOption) -> Box<Future<Item = ::models::Team, Error = Error<serde_json::Value>>> {
  1331. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1332. let mut auth_headers = HashMap::<String, String>::new();
  1333. let mut auth_query = HashMap::<String, String>::new();
  1334. if let Some(ref apikey) = configuration.api_key {
  1335. let key = apikey.key.clone();
  1336. let val = match apikey.prefix {
  1337. Some(ref prefix) => format!("{} {}", prefix, key),
  1338. None => key,
  1339. };
  1340. auth_query.insert("access_token".to_owned(), val);
  1341. };
  1342. if let Some(ref apikey) = configuration.api_key {
  1343. let key = apikey.key.clone();
  1344. let val = match apikey.prefix {
  1345. Some(ref prefix) => format!("{} {}", prefix, key),
  1346. None => key,
  1347. };
  1348. auth_headers.insert("Authorization".to_owned(), val);
  1349. };
  1350. if let Some(ref auth_conf) = configuration.basic_auth {
  1351. let auth = hyper::header::Authorization(
  1352. hyper::header::Basic {
  1353. username: auth_conf.0.to_owned(),
  1354. password: auth_conf.1.to_owned(),
  1355. }
  1356. );
  1357. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1358. };
  1359. if let Some(ref apikey) = configuration.api_key {
  1360. let key = apikey.key.clone();
  1361. let val = match apikey.prefix {
  1362. Some(ref prefix) => format!("{} {}", prefix, key),
  1363. None => key,
  1364. };
  1365. auth_headers.insert("Sudo".to_owned(), val);
  1366. };
  1367. if let Some(ref apikey) = configuration.api_key {
  1368. let key = apikey.key.clone();
  1369. let val = match apikey.prefix {
  1370. Some(ref prefix) => format!("{} {}", prefix, key),
  1371. None => key,
  1372. };
  1373. auth_query.insert("sudo".to_owned(), val);
  1374. };
  1375. if let Some(ref apikey) = configuration.api_key {
  1376. let key = apikey.key.clone();
  1377. let val = match apikey.prefix {
  1378. Some(ref prefix) => format!("{} {}", prefix, key),
  1379. None => key,
  1380. };
  1381. auth_query.insert("token".to_owned(), val);
  1382. };
  1383. let method = hyper::Method::Patch;
  1384. let query_string = {
  1385. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1386. for (key, val) in &auth_query {
  1387. query.append_pair(key, val);
  1388. }
  1389. query.finish()
  1390. };
  1391. let uri_str = format!("{}/teams/{id}?{}", configuration.base_path, query_string, id=id);
  1392. // TODO(farcaller): handle error
  1393. // if let Err(e) = uri {
  1394. // return Box::new(futures::future::err(e));
  1395. // }
  1396. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1397. let mut req = hyper::Request::new(method, uri);
  1398. if let Some(ref user_agent) = configuration.user_agent {
  1399. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1400. }
  1401. for (key, val) in auth_headers {
  1402. req.headers_mut().set_raw(key, val);
  1403. }
  1404. let serialized = serde_json::to_string(&body).unwrap();
  1405. req.headers_mut().set(hyper::header::ContentType::json());
  1406. req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
  1407. req.set_body(serialized);
  1408. // send request
  1409. Box::new(
  1410. configuration.client.request(req)
  1411. .map_err(|e| Error::from(e))
  1412. .and_then(|resp| {
  1413. let status = resp.status();
  1414. resp.body().concat2()
  1415. .and_then(move |body| Ok((status, body)))
  1416. .map_err(|e| Error::from(e))
  1417. })
  1418. .and_then(|(status, body)| {
  1419. if status.is_success() {
  1420. Ok(body)
  1421. } else {
  1422. Err(Error::from((status, &*body)))
  1423. }
  1424. })
  1425. .and_then(|body| {
  1426. let parsed: Result<::models::Team, _> = serde_json::from_slice(&body);
  1427. parsed.map_err(|e| Error::from(e))
  1428. })
  1429. )
  1430. }
  1431. fn org_get(&self, org: &str) -> Box<Future<Item = ::models::Organization, Error = Error<serde_json::Value>>> {
  1432. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1433. let mut auth_headers = HashMap::<String, String>::new();
  1434. let mut auth_query = HashMap::<String, String>::new();
  1435. if let Some(ref apikey) = configuration.api_key {
  1436. let key = apikey.key.clone();
  1437. let val = match apikey.prefix {
  1438. Some(ref prefix) => format!("{} {}", prefix, key),
  1439. None => key,
  1440. };
  1441. auth_query.insert("access_token".to_owned(), val);
  1442. };
  1443. if let Some(ref apikey) = configuration.api_key {
  1444. let key = apikey.key.clone();
  1445. let val = match apikey.prefix {
  1446. Some(ref prefix) => format!("{} {}", prefix, key),
  1447. None => key,
  1448. };
  1449. auth_headers.insert("Authorization".to_owned(), val);
  1450. };
  1451. if let Some(ref auth_conf) = configuration.basic_auth {
  1452. let auth = hyper::header::Authorization(
  1453. hyper::header::Basic {
  1454. username: auth_conf.0.to_owned(),
  1455. password: auth_conf.1.to_owned(),
  1456. }
  1457. );
  1458. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1459. };
  1460. if let Some(ref apikey) = configuration.api_key {
  1461. let key = apikey.key.clone();
  1462. let val = match apikey.prefix {
  1463. Some(ref prefix) => format!("{} {}", prefix, key),
  1464. None => key,
  1465. };
  1466. auth_headers.insert("Sudo".to_owned(), val);
  1467. };
  1468. if let Some(ref apikey) = configuration.api_key {
  1469. let key = apikey.key.clone();
  1470. let val = match apikey.prefix {
  1471. Some(ref prefix) => format!("{} {}", prefix, key),
  1472. None => key,
  1473. };
  1474. auth_query.insert("sudo".to_owned(), val);
  1475. };
  1476. if let Some(ref apikey) = configuration.api_key {
  1477. let key = apikey.key.clone();
  1478. let val = match apikey.prefix {
  1479. Some(ref prefix) => format!("{} {}", prefix, key),
  1480. None => key,
  1481. };
  1482. auth_query.insert("token".to_owned(), val);
  1483. };
  1484. let method = hyper::Method::Get;
  1485. let query_string = {
  1486. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1487. for (key, val) in &auth_query {
  1488. query.append_pair(key, val);
  1489. }
  1490. query.finish()
  1491. };
  1492. let uri_str = format!("{}/orgs/{org}?{}", configuration.base_path, query_string, org=org);
  1493. // TODO(farcaller): handle error
  1494. // if let Err(e) = uri {
  1495. // return Box::new(futures::future::err(e));
  1496. // }
  1497. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1498. let mut req = hyper::Request::new(method, uri);
  1499. if let Some(ref user_agent) = configuration.user_agent {
  1500. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1501. }
  1502. for (key, val) in auth_headers {
  1503. req.headers_mut().set_raw(key, val);
  1504. }
  1505. // send request
  1506. Box::new(
  1507. configuration.client.request(req)
  1508. .map_err(|e| Error::from(e))
  1509. .and_then(|resp| {
  1510. let status = resp.status();
  1511. resp.body().concat2()
  1512. .and_then(move |body| Ok((status, body)))
  1513. .map_err(|e| Error::from(e))
  1514. })
  1515. .and_then(|(status, body)| {
  1516. if status.is_success() {
  1517. Ok(body)
  1518. } else {
  1519. Err(Error::from((status, &*body)))
  1520. }
  1521. })
  1522. .and_then(|body| {
  1523. let parsed: Result<::models::Organization, _> = serde_json::from_slice(&body);
  1524. parsed.map_err(|e| Error::from(e))
  1525. })
  1526. )
  1527. }
  1528. fn org_get_hook(&self, org: &str, id: i64) -> Box<Future<Item = ::models::Hook, Error = Error<serde_json::Value>>> {
  1529. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1530. let mut auth_headers = HashMap::<String, String>::new();
  1531. let mut auth_query = HashMap::<String, String>::new();
  1532. if let Some(ref apikey) = configuration.api_key {
  1533. let key = apikey.key.clone();
  1534. let val = match apikey.prefix {
  1535. Some(ref prefix) => format!("{} {}", prefix, key),
  1536. None => key,
  1537. };
  1538. auth_query.insert("access_token".to_owned(), val);
  1539. };
  1540. if let Some(ref apikey) = configuration.api_key {
  1541. let key = apikey.key.clone();
  1542. let val = match apikey.prefix {
  1543. Some(ref prefix) => format!("{} {}", prefix, key),
  1544. None => key,
  1545. };
  1546. auth_headers.insert("Authorization".to_owned(), val);
  1547. };
  1548. if let Some(ref auth_conf) = configuration.basic_auth {
  1549. let auth = hyper::header::Authorization(
  1550. hyper::header::Basic {
  1551. username: auth_conf.0.to_owned(),
  1552. password: auth_conf.1.to_owned(),
  1553. }
  1554. );
  1555. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1556. };
  1557. if let Some(ref apikey) = configuration.api_key {
  1558. let key = apikey.key.clone();
  1559. let val = match apikey.prefix {
  1560. Some(ref prefix) => format!("{} {}", prefix, key),
  1561. None => key,
  1562. };
  1563. auth_headers.insert("Sudo".to_owned(), val);
  1564. };
  1565. if let Some(ref apikey) = configuration.api_key {
  1566. let key = apikey.key.clone();
  1567. let val = match apikey.prefix {
  1568. Some(ref prefix) => format!("{} {}", prefix, key),
  1569. None => key,
  1570. };
  1571. auth_query.insert("sudo".to_owned(), val);
  1572. };
  1573. if let Some(ref apikey) = configuration.api_key {
  1574. let key = apikey.key.clone();
  1575. let val = match apikey.prefix {
  1576. Some(ref prefix) => format!("{} {}", prefix, key),
  1577. None => key,
  1578. };
  1579. auth_query.insert("token".to_owned(), val);
  1580. };
  1581. let method = hyper::Method::Get;
  1582. let query_string = {
  1583. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1584. for (key, val) in &auth_query {
  1585. query.append_pair(key, val);
  1586. }
  1587. query.finish()
  1588. };
  1589. let uri_str = format!("{}/orgs/{org}/hooks/{id}?{}", configuration.base_path, query_string, org=org, id=id);
  1590. // TODO(farcaller): handle error
  1591. // if let Err(e) = uri {
  1592. // return Box::new(futures::future::err(e));
  1593. // }
  1594. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1595. let mut req = hyper::Request::new(method, uri);
  1596. if let Some(ref user_agent) = configuration.user_agent {
  1597. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1598. }
  1599. for (key, val) in auth_headers {
  1600. req.headers_mut().set_raw(key, val);
  1601. }
  1602. // send request
  1603. Box::new(
  1604. configuration.client.request(req)
  1605. .map_err(|e| Error::from(e))
  1606. .and_then(|resp| {
  1607. let status = resp.status();
  1608. resp.body().concat2()
  1609. .and_then(move |body| Ok((status, body)))
  1610. .map_err(|e| Error::from(e))
  1611. })
  1612. .and_then(|(status, body)| {
  1613. if status.is_success() {
  1614. Ok(body)
  1615. } else {
  1616. Err(Error::from((status, &*body)))
  1617. }
  1618. })
  1619. .and_then(|body| {
  1620. let parsed: Result<::models::Hook, _> = serde_json::from_slice(&body);
  1621. parsed.map_err(|e| Error::from(e))
  1622. })
  1623. )
  1624. }
  1625. fn org_get_team(&self, id: i64) -> Box<Future<Item = ::models::Team, Error = Error<serde_json::Value>>> {
  1626. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1627. let mut auth_headers = HashMap::<String, String>::new();
  1628. let mut auth_query = HashMap::<String, String>::new();
  1629. if let Some(ref apikey) = configuration.api_key {
  1630. let key = apikey.key.clone();
  1631. let val = match apikey.prefix {
  1632. Some(ref prefix) => format!("{} {}", prefix, key),
  1633. None => key,
  1634. };
  1635. auth_query.insert("access_token".to_owned(), val);
  1636. };
  1637. if let Some(ref apikey) = configuration.api_key {
  1638. let key = apikey.key.clone();
  1639. let val = match apikey.prefix {
  1640. Some(ref prefix) => format!("{} {}", prefix, key),
  1641. None => key,
  1642. };
  1643. auth_headers.insert("Authorization".to_owned(), val);
  1644. };
  1645. if let Some(ref auth_conf) = configuration.basic_auth {
  1646. let auth = hyper::header::Authorization(
  1647. hyper::header::Basic {
  1648. username: auth_conf.0.to_owned(),
  1649. password: auth_conf.1.to_owned(),
  1650. }
  1651. );
  1652. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1653. };
  1654. if let Some(ref apikey) = configuration.api_key {
  1655. let key = apikey.key.clone();
  1656. let val = match apikey.prefix {
  1657. Some(ref prefix) => format!("{} {}", prefix, key),
  1658. None => key,
  1659. };
  1660. auth_headers.insert("Sudo".to_owned(), val);
  1661. };
  1662. if let Some(ref apikey) = configuration.api_key {
  1663. let key = apikey.key.clone();
  1664. let val = match apikey.prefix {
  1665. Some(ref prefix) => format!("{} {}", prefix, key),
  1666. None => key,
  1667. };
  1668. auth_query.insert("sudo".to_owned(), val);
  1669. };
  1670. if let Some(ref apikey) = configuration.api_key {
  1671. let key = apikey.key.clone();
  1672. let val = match apikey.prefix {
  1673. Some(ref prefix) => format!("{} {}", prefix, key),
  1674. None => key,
  1675. };
  1676. auth_query.insert("token".to_owned(), val);
  1677. };
  1678. let method = hyper::Method::Get;
  1679. let query_string = {
  1680. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1681. for (key, val) in &auth_query {
  1682. query.append_pair(key, val);
  1683. }
  1684. query.finish()
  1685. };
  1686. let uri_str = format!("{}/teams/{id}?{}", configuration.base_path, query_string, id=id);
  1687. // TODO(farcaller): handle error
  1688. // if let Err(e) = uri {
  1689. // return Box::new(futures::future::err(e));
  1690. // }
  1691. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1692. let mut req = hyper::Request::new(method, uri);
  1693. if let Some(ref user_agent) = configuration.user_agent {
  1694. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1695. }
  1696. for (key, val) in auth_headers {
  1697. req.headers_mut().set_raw(key, val);
  1698. }
  1699. // send request
  1700. Box::new(
  1701. configuration.client.request(req)
  1702. .map_err(|e| Error::from(e))
  1703. .and_then(|resp| {
  1704. let status = resp.status();
  1705. resp.body().concat2()
  1706. .and_then(move |body| Ok((status, body)))
  1707. .map_err(|e| Error::from(e))
  1708. })
  1709. .and_then(|(status, body)| {
  1710. if status.is_success() {
  1711. Ok(body)
  1712. } else {
  1713. Err(Error::from((status, &*body)))
  1714. }
  1715. })
  1716. .and_then(|body| {
  1717. let parsed: Result<::models::Team, _> = serde_json::from_slice(&body);
  1718. parsed.map_err(|e| Error::from(e))
  1719. })
  1720. )
  1721. }
  1722. fn org_is_member(&self, org: &str, username: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  1723. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1724. let mut auth_headers = HashMap::<String, String>::new();
  1725. let mut auth_query = HashMap::<String, String>::new();
  1726. if let Some(ref apikey) = configuration.api_key {
  1727. let key = apikey.key.clone();
  1728. let val = match apikey.prefix {
  1729. Some(ref prefix) => format!("{} {}", prefix, key),
  1730. None => key,
  1731. };
  1732. auth_query.insert("access_token".to_owned(), val);
  1733. };
  1734. if let Some(ref apikey) = configuration.api_key {
  1735. let key = apikey.key.clone();
  1736. let val = match apikey.prefix {
  1737. Some(ref prefix) => format!("{} {}", prefix, key),
  1738. None => key,
  1739. };
  1740. auth_headers.insert("Authorization".to_owned(), val);
  1741. };
  1742. if let Some(ref auth_conf) = configuration.basic_auth {
  1743. let auth = hyper::header::Authorization(
  1744. hyper::header::Basic {
  1745. username: auth_conf.0.to_owned(),
  1746. password: auth_conf.1.to_owned(),
  1747. }
  1748. );
  1749. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1750. };
  1751. if let Some(ref apikey) = configuration.api_key {
  1752. let key = apikey.key.clone();
  1753. let val = match apikey.prefix {
  1754. Some(ref prefix) => format!("{} {}", prefix, key),
  1755. None => key,
  1756. };
  1757. auth_headers.insert("Sudo".to_owned(), val);
  1758. };
  1759. if let Some(ref apikey) = configuration.api_key {
  1760. let key = apikey.key.clone();
  1761. let val = match apikey.prefix {
  1762. Some(ref prefix) => format!("{} {}", prefix, key),
  1763. None => key,
  1764. };
  1765. auth_query.insert("sudo".to_owned(), val);
  1766. };
  1767. if let Some(ref apikey) = configuration.api_key {
  1768. let key = apikey.key.clone();
  1769. let val = match apikey.prefix {
  1770. Some(ref prefix) => format!("{} {}", prefix, key),
  1771. None => key,
  1772. };
  1773. auth_query.insert("token".to_owned(), val);
  1774. };
  1775. let method = hyper::Method::Get;
  1776. let query_string = {
  1777. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1778. for (key, val) in &auth_query {
  1779. query.append_pair(key, val);
  1780. }
  1781. query.finish()
  1782. };
  1783. let uri_str = format!("{}/orgs/{org}/members/{username}?{}", configuration.base_path, query_string, org=org, username=username);
  1784. // TODO(farcaller): handle error
  1785. // if let Err(e) = uri {
  1786. // return Box::new(futures::future::err(e));
  1787. // }
  1788. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1789. let mut req = hyper::Request::new(method, uri);
  1790. if let Some(ref user_agent) = configuration.user_agent {
  1791. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1792. }
  1793. for (key, val) in auth_headers {
  1794. req.headers_mut().set_raw(key, val);
  1795. }
  1796. // send request
  1797. Box::new(
  1798. configuration.client.request(req)
  1799. .map_err(|e| Error::from(e))
  1800. .and_then(|resp| {
  1801. let status = resp.status();
  1802. resp.body().concat2()
  1803. .and_then(move |body| Ok((status, body)))
  1804. .map_err(|e| Error::from(e))
  1805. })
  1806. .and_then(|(status, body)| {
  1807. if status.is_success() {
  1808. Ok(body)
  1809. } else {
  1810. Err(Error::from((status, &*body)))
  1811. }
  1812. })
  1813. .and_then(|_| futures::future::ok(()))
  1814. )
  1815. }
  1816. fn org_is_public_member(&self, org: &str, username: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  1817. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1818. let mut auth_headers = HashMap::<String, String>::new();
  1819. let mut auth_query = HashMap::<String, String>::new();
  1820. if let Some(ref apikey) = configuration.api_key {
  1821. let key = apikey.key.clone();
  1822. let val = match apikey.prefix {
  1823. Some(ref prefix) => format!("{} {}", prefix, key),
  1824. None => key,
  1825. };
  1826. auth_query.insert("access_token".to_owned(), val);
  1827. };
  1828. if let Some(ref apikey) = configuration.api_key {
  1829. let key = apikey.key.clone();
  1830. let val = match apikey.prefix {
  1831. Some(ref prefix) => format!("{} {}", prefix, key),
  1832. None => key,
  1833. };
  1834. auth_headers.insert("Authorization".to_owned(), val);
  1835. };
  1836. if let Some(ref auth_conf) = configuration.basic_auth {
  1837. let auth = hyper::header::Authorization(
  1838. hyper::header::Basic {
  1839. username: auth_conf.0.to_owned(),
  1840. password: auth_conf.1.to_owned(),
  1841. }
  1842. );
  1843. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  1844. };
  1845. if let Some(ref apikey) = configuration.api_key {
  1846. let key = apikey.key.clone();
  1847. let val = match apikey.prefix {
  1848. Some(ref prefix) => format!("{} {}", prefix, key),
  1849. None => key,
  1850. };
  1851. auth_headers.insert("Sudo".to_owned(), val);
  1852. };
  1853. if let Some(ref apikey) = configuration.api_key {
  1854. let key = apikey.key.clone();
  1855. let val = match apikey.prefix {
  1856. Some(ref prefix) => format!("{} {}", prefix, key),
  1857. None => key,
  1858. };
  1859. auth_query.insert("sudo".to_owned(), val);
  1860. };
  1861. if let Some(ref apikey) = configuration.api_key {
  1862. let key = apikey.key.clone();
  1863. let val = match apikey.prefix {
  1864. Some(ref prefix) => format!("{} {}", prefix, key),
  1865. None => key,
  1866. };
  1867. auth_query.insert("token".to_owned(), val);
  1868. };
  1869. let method = hyper::Method::Get;
  1870. let query_string = {
  1871. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1872. for (key, val) in &auth_query {
  1873. query.append_pair(key, val);
  1874. }
  1875. query.finish()
  1876. };
  1877. let uri_str = format!("{}/orgs/{org}/public_members/{username}?{}", configuration.base_path, query_string, org=org, username=username);
  1878. // TODO(farcaller): handle error
  1879. // if let Err(e) = uri {
  1880. // return Box::new(futures::future::err(e));
  1881. // }
  1882. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1883. let mut req = hyper::Request::new(method, uri);
  1884. if let Some(ref user_agent) = configuration.user_agent {
  1885. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1886. }
  1887. for (key, val) in auth_headers {
  1888. req.headers_mut().set_raw(key, val);
  1889. }
  1890. // send request
  1891. Box::new(
  1892. configuration.client.request(req)
  1893. .map_err(|e| Error::from(e))
  1894. .and_then(|resp| {
  1895. let status = resp.status();
  1896. resp.body().concat2()
  1897. .and_then(move |body| Ok((status, body)))
  1898. .map_err(|e| Error::from(e))
  1899. })
  1900. .and_then(|(status, body)| {
  1901. if status.is_success() {
  1902. Ok(body)
  1903. } else {
  1904. Err(Error::from((status, &*body)))
  1905. }
  1906. })
  1907. .and_then(|_| futures::future::ok(()))
  1908. )
  1909. }
  1910. fn org_list_current_user_orgs(&self, ) -> Box<Future<Item = Vec<::models::Organization>, Error = Error<serde_json::Value>>> {
  1911. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  1912. let mut auth_headers = HashMap::<String, String>::new();
  1913. let mut auth_query = HashMap::<String, String>::new();
  1914. if let Some(ref apikey) = configuration.api_key {
  1915. let key = apikey.key.clone();
  1916. let val = match apikey.prefix {
  1917. Some(ref prefix) => format!("{} {}", prefix, key),
  1918. None => key,
  1919. };
  1920. auth_query.insert("access_token".to_owned(), val);
  1921. };
  1922. if let Some(ref apikey) = configuration.api_key {
  1923. let key = apikey.key.clone();
  1924. let val = match apikey.prefix {
  1925. Some(ref prefix) => format!("{} {}", prefix, key),
  1926. None => key,
  1927. };
  1928. auth_headers.insert("Authorization".to_owned(), val);
  1929. };
  1930. if let Some(ref auth_conf) = configuration.basic_auth {
  1931. let auth = hyper::header::Authorization(
  1932. hyper::header::Basic {
  1933. username: auth_conf.0.to_owned(),
  1934. password: auth_conf.1.to_owned(),
  1935. }
  1936. );
  1937. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  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("Sudo".to_owned(), val);
  1946. };
  1947. if let Some(ref apikey) = configuration.api_key {
  1948. let key = apikey.key.clone();
  1949. let val = match apikey.prefix {
  1950. Some(ref prefix) => format!("{} {}", prefix, key),
  1951. None => key,
  1952. };
  1953. auth_query.insert("sudo".to_owned(), val);
  1954. };
  1955. if let Some(ref apikey) = configuration.api_key {
  1956. let key = apikey.key.clone();
  1957. let val = match apikey.prefix {
  1958. Some(ref prefix) => format!("{} {}", prefix, key),
  1959. None => key,
  1960. };
  1961. auth_query.insert("token".to_owned(), val);
  1962. };
  1963. let method = hyper::Method::Get;
  1964. let query_string = {
  1965. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  1966. for (key, val) in &auth_query {
  1967. query.append_pair(key, val);
  1968. }
  1969. query.finish()
  1970. };
  1971. let uri_str = format!("{}/user/orgs?{}", configuration.base_path, query_string);
  1972. // TODO(farcaller): handle error
  1973. // if let Err(e) = uri {
  1974. // return Box::new(futures::future::err(e));
  1975. // }
  1976. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  1977. let mut req = hyper::Request::new(method, uri);
  1978. if let Some(ref user_agent) = configuration.user_agent {
  1979. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  1980. }
  1981. for (key, val) in auth_headers {
  1982. req.headers_mut().set_raw(key, val);
  1983. }
  1984. // send request
  1985. Box::new(
  1986. configuration.client.request(req)
  1987. .map_err(|e| Error::from(e))
  1988. .and_then(|resp| {
  1989. let status = resp.status();
  1990. resp.body().concat2()
  1991. .and_then(move |body| Ok((status, body)))
  1992. .map_err(|e| Error::from(e))
  1993. })
  1994. .and_then(|(status, body)| {
  1995. if status.is_success() {
  1996. Ok(body)
  1997. } else {
  1998. Err(Error::from((status, &*body)))
  1999. }
  2000. })
  2001. .and_then(|body| {
  2002. let parsed: Result<Vec<::models::Organization>, _> = serde_json::from_slice(&body);
  2003. parsed.map_err(|e| Error::from(e))
  2004. })
  2005. )
  2006. }
  2007. fn org_list_hooks(&self, org: &str) -> Box<Future<Item = Vec<::models::Hook>, Error = Error<serde_json::Value>>> {
  2008. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2009. let mut auth_headers = HashMap::<String, String>::new();
  2010. let mut auth_query = HashMap::<String, String>::new();
  2011. if let Some(ref apikey) = configuration.api_key {
  2012. let key = apikey.key.clone();
  2013. let val = match apikey.prefix {
  2014. Some(ref prefix) => format!("{} {}", prefix, key),
  2015. None => key,
  2016. };
  2017. auth_query.insert("access_token".to_owned(), val);
  2018. };
  2019. if let Some(ref apikey) = configuration.api_key {
  2020. let key = apikey.key.clone();
  2021. let val = match apikey.prefix {
  2022. Some(ref prefix) => format!("{} {}", prefix, key),
  2023. None => key,
  2024. };
  2025. auth_headers.insert("Authorization".to_owned(), val);
  2026. };
  2027. if let Some(ref auth_conf) = configuration.basic_auth {
  2028. let auth = hyper::header::Authorization(
  2029. hyper::header::Basic {
  2030. username: auth_conf.0.to_owned(),
  2031. password: auth_conf.1.to_owned(),
  2032. }
  2033. );
  2034. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2035. };
  2036. if let Some(ref apikey) = configuration.api_key {
  2037. let key = apikey.key.clone();
  2038. let val = match apikey.prefix {
  2039. Some(ref prefix) => format!("{} {}", prefix, key),
  2040. None => key,
  2041. };
  2042. auth_headers.insert("Sudo".to_owned(), val);
  2043. };
  2044. if let Some(ref apikey) = configuration.api_key {
  2045. let key = apikey.key.clone();
  2046. let val = match apikey.prefix {
  2047. Some(ref prefix) => format!("{} {}", prefix, key),
  2048. None => key,
  2049. };
  2050. auth_query.insert("sudo".to_owned(), val);
  2051. };
  2052. if let Some(ref apikey) = configuration.api_key {
  2053. let key = apikey.key.clone();
  2054. let val = match apikey.prefix {
  2055. Some(ref prefix) => format!("{} {}", prefix, key),
  2056. None => key,
  2057. };
  2058. auth_query.insert("token".to_owned(), val);
  2059. };
  2060. let method = hyper::Method::Get;
  2061. let query_string = {
  2062. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2063. for (key, val) in &auth_query {
  2064. query.append_pair(key, val);
  2065. }
  2066. query.finish()
  2067. };
  2068. let uri_str = format!("{}/orgs/{org}/hooks?{}", configuration.base_path, query_string, org=org);
  2069. // TODO(farcaller): handle error
  2070. // if let Err(e) = uri {
  2071. // return Box::new(futures::future::err(e));
  2072. // }
  2073. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2074. let mut req = hyper::Request::new(method, uri);
  2075. if let Some(ref user_agent) = configuration.user_agent {
  2076. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2077. }
  2078. for (key, val) in auth_headers {
  2079. req.headers_mut().set_raw(key, val);
  2080. }
  2081. // send request
  2082. Box::new(
  2083. configuration.client.request(req)
  2084. .map_err(|e| Error::from(e))
  2085. .and_then(|resp| {
  2086. let status = resp.status();
  2087. resp.body().concat2()
  2088. .and_then(move |body| Ok((status, body)))
  2089. .map_err(|e| Error::from(e))
  2090. })
  2091. .and_then(|(status, body)| {
  2092. if status.is_success() {
  2093. Ok(body)
  2094. } else {
  2095. Err(Error::from((status, &*body)))
  2096. }
  2097. })
  2098. .and_then(|body| {
  2099. let parsed: Result<Vec<::models::Hook>, _> = serde_json::from_slice(&body);
  2100. parsed.map_err(|e| Error::from(e))
  2101. })
  2102. )
  2103. }
  2104. fn org_list_members(&self, org: &str) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>> {
  2105. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2106. let mut auth_headers = HashMap::<String, String>::new();
  2107. let mut auth_query = HashMap::<String, String>::new();
  2108. if let Some(ref apikey) = configuration.api_key {
  2109. let key = apikey.key.clone();
  2110. let val = match apikey.prefix {
  2111. Some(ref prefix) => format!("{} {}", prefix, key),
  2112. None => key,
  2113. };
  2114. auth_query.insert("access_token".to_owned(), val);
  2115. };
  2116. if let Some(ref apikey) = configuration.api_key {
  2117. let key = apikey.key.clone();
  2118. let val = match apikey.prefix {
  2119. Some(ref prefix) => format!("{} {}", prefix, key),
  2120. None => key,
  2121. };
  2122. auth_headers.insert("Authorization".to_owned(), val);
  2123. };
  2124. if let Some(ref auth_conf) = configuration.basic_auth {
  2125. let auth = hyper::header::Authorization(
  2126. hyper::header::Basic {
  2127. username: auth_conf.0.to_owned(),
  2128. password: auth_conf.1.to_owned(),
  2129. }
  2130. );
  2131. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2132. };
  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_headers.insert("Sudo".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_query.insert("sudo".to_owned(), val);
  2148. };
  2149. if let Some(ref apikey) = configuration.api_key {
  2150. let key = apikey.key.clone();
  2151. let val = match apikey.prefix {
  2152. Some(ref prefix) => format!("{} {}", prefix, key),
  2153. None => key,
  2154. };
  2155. auth_query.insert("token".to_owned(), val);
  2156. };
  2157. let method = hyper::Method::Get;
  2158. let query_string = {
  2159. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2160. for (key, val) in &auth_query {
  2161. query.append_pair(key, val);
  2162. }
  2163. query.finish()
  2164. };
  2165. let uri_str = format!("{}/orgs/{org}/members?{}", configuration.base_path, query_string, org=org);
  2166. // TODO(farcaller): handle error
  2167. // if let Err(e) = uri {
  2168. // return Box::new(futures::future::err(e));
  2169. // }
  2170. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2171. let mut req = hyper::Request::new(method, uri);
  2172. if let Some(ref user_agent) = configuration.user_agent {
  2173. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2174. }
  2175. for (key, val) in auth_headers {
  2176. req.headers_mut().set_raw(key, val);
  2177. }
  2178. // send request
  2179. Box::new(
  2180. configuration.client.request(req)
  2181. .map_err(|e| Error::from(e))
  2182. .and_then(|resp| {
  2183. let status = resp.status();
  2184. resp.body().concat2()
  2185. .and_then(move |body| Ok((status, body)))
  2186. .map_err(|e| Error::from(e))
  2187. })
  2188. .and_then(|(status, body)| {
  2189. if status.is_success() {
  2190. Ok(body)
  2191. } else {
  2192. Err(Error::from((status, &*body)))
  2193. }
  2194. })
  2195. .and_then(|body| {
  2196. let parsed: Result<Vec<::models::User>, _> = serde_json::from_slice(&body);
  2197. parsed.map_err(|e| Error::from(e))
  2198. })
  2199. )
  2200. }
  2201. fn org_list_public_members(&self, org: &str) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>> {
  2202. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2203. let mut auth_headers = HashMap::<String, String>::new();
  2204. let mut auth_query = HashMap::<String, String>::new();
  2205. if let Some(ref apikey) = configuration.api_key {
  2206. let key = apikey.key.clone();
  2207. let val = match apikey.prefix {
  2208. Some(ref prefix) => format!("{} {}", prefix, key),
  2209. None => key,
  2210. };
  2211. auth_query.insert("access_token".to_owned(), val);
  2212. };
  2213. if let Some(ref apikey) = configuration.api_key {
  2214. let key = apikey.key.clone();
  2215. let val = match apikey.prefix {
  2216. Some(ref prefix) => format!("{} {}", prefix, key),
  2217. None => key,
  2218. };
  2219. auth_headers.insert("Authorization".to_owned(), val);
  2220. };
  2221. if let Some(ref auth_conf) = configuration.basic_auth {
  2222. let auth = hyper::header::Authorization(
  2223. hyper::header::Basic {
  2224. username: auth_conf.0.to_owned(),
  2225. password: auth_conf.1.to_owned(),
  2226. }
  2227. );
  2228. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2229. };
  2230. if let Some(ref apikey) = configuration.api_key {
  2231. let key = apikey.key.clone();
  2232. let val = match apikey.prefix {
  2233. Some(ref prefix) => format!("{} {}", prefix, key),
  2234. None => key,
  2235. };
  2236. auth_headers.insert("Sudo".to_owned(), val);
  2237. };
  2238. if let Some(ref apikey) = configuration.api_key {
  2239. let key = apikey.key.clone();
  2240. let val = match apikey.prefix {
  2241. Some(ref prefix) => format!("{} {}", prefix, key),
  2242. None => key,
  2243. };
  2244. auth_query.insert("sudo".to_owned(), val);
  2245. };
  2246. if let Some(ref apikey) = configuration.api_key {
  2247. let key = apikey.key.clone();
  2248. let val = match apikey.prefix {
  2249. Some(ref prefix) => format!("{} {}", prefix, key),
  2250. None => key,
  2251. };
  2252. auth_query.insert("token".to_owned(), val);
  2253. };
  2254. let method = hyper::Method::Get;
  2255. let query_string = {
  2256. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2257. for (key, val) in &auth_query {
  2258. query.append_pair(key, val);
  2259. }
  2260. query.finish()
  2261. };
  2262. let uri_str = format!("{}/orgs/{org}/public_members?{}", configuration.base_path, query_string, org=org);
  2263. // TODO(farcaller): handle error
  2264. // if let Err(e) = uri {
  2265. // return Box::new(futures::future::err(e));
  2266. // }
  2267. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2268. let mut req = hyper::Request::new(method, uri);
  2269. if let Some(ref user_agent) = configuration.user_agent {
  2270. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2271. }
  2272. for (key, val) in auth_headers {
  2273. req.headers_mut().set_raw(key, val);
  2274. }
  2275. // send request
  2276. Box::new(
  2277. configuration.client.request(req)
  2278. .map_err(|e| Error::from(e))
  2279. .and_then(|resp| {
  2280. let status = resp.status();
  2281. resp.body().concat2()
  2282. .and_then(move |body| Ok((status, body)))
  2283. .map_err(|e| Error::from(e))
  2284. })
  2285. .and_then(|(status, body)| {
  2286. if status.is_success() {
  2287. Ok(body)
  2288. } else {
  2289. Err(Error::from((status, &*body)))
  2290. }
  2291. })
  2292. .and_then(|body| {
  2293. let parsed: Result<Vec<::models::User>, _> = serde_json::from_slice(&body);
  2294. parsed.map_err(|e| Error::from(e))
  2295. })
  2296. )
  2297. }
  2298. fn org_list_repos(&self, org: &str) -> Box<Future<Item = Vec<::models::Repository>, Error = Error<serde_json::Value>>> {
  2299. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2300. let mut auth_headers = HashMap::<String, String>::new();
  2301. let mut auth_query = HashMap::<String, String>::new();
  2302. if let Some(ref apikey) = configuration.api_key {
  2303. let key = apikey.key.clone();
  2304. let val = match apikey.prefix {
  2305. Some(ref prefix) => format!("{} {}", prefix, key),
  2306. None => key,
  2307. };
  2308. auth_query.insert("access_token".to_owned(), val);
  2309. };
  2310. if let Some(ref apikey) = configuration.api_key {
  2311. let key = apikey.key.clone();
  2312. let val = match apikey.prefix {
  2313. Some(ref prefix) => format!("{} {}", prefix, key),
  2314. None => key,
  2315. };
  2316. auth_headers.insert("Authorization".to_owned(), val);
  2317. };
  2318. if let Some(ref auth_conf) = configuration.basic_auth {
  2319. let auth = hyper::header::Authorization(
  2320. hyper::header::Basic {
  2321. username: auth_conf.0.to_owned(),
  2322. password: auth_conf.1.to_owned(),
  2323. }
  2324. );
  2325. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2326. };
  2327. if let Some(ref apikey) = configuration.api_key {
  2328. let key = apikey.key.clone();
  2329. let val = match apikey.prefix {
  2330. Some(ref prefix) => format!("{} {}", prefix, key),
  2331. None => key,
  2332. };
  2333. auth_headers.insert("Sudo".to_owned(), val);
  2334. };
  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("sudo".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_query.insert("token".to_owned(), val);
  2350. };
  2351. let method = hyper::Method::Get;
  2352. let query_string = {
  2353. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2354. for (key, val) in &auth_query {
  2355. query.append_pair(key, val);
  2356. }
  2357. query.finish()
  2358. };
  2359. let uri_str = format!("{}/orgs/{org}/repos?{}", configuration.base_path, query_string, org=org);
  2360. // TODO(farcaller): handle error
  2361. // if let Err(e) = uri {
  2362. // return Box::new(futures::future::err(e));
  2363. // }
  2364. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2365. let mut req = hyper::Request::new(method, uri);
  2366. if let Some(ref user_agent) = configuration.user_agent {
  2367. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2368. }
  2369. for (key, val) in auth_headers {
  2370. req.headers_mut().set_raw(key, val);
  2371. }
  2372. // send request
  2373. Box::new(
  2374. configuration.client.request(req)
  2375. .map_err(|e| Error::from(e))
  2376. .and_then(|resp| {
  2377. let status = resp.status();
  2378. resp.body().concat2()
  2379. .and_then(move |body| Ok((status, body)))
  2380. .map_err(|e| Error::from(e))
  2381. })
  2382. .and_then(|(status, body)| {
  2383. if status.is_success() {
  2384. Ok(body)
  2385. } else {
  2386. Err(Error::from((status, &*body)))
  2387. }
  2388. })
  2389. .and_then(|body| {
  2390. let parsed: Result<Vec<::models::Repository>, _> = serde_json::from_slice(&body);
  2391. parsed.map_err(|e| Error::from(e))
  2392. })
  2393. )
  2394. }
  2395. fn org_list_team_member(&self, id: i64, username: &str) -> Box<Future<Item = ::models::User, Error = Error<serde_json::Value>>> {
  2396. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2397. let mut auth_headers = HashMap::<String, String>::new();
  2398. let mut auth_query = HashMap::<String, String>::new();
  2399. if let Some(ref apikey) = configuration.api_key {
  2400. let key = apikey.key.clone();
  2401. let val = match apikey.prefix {
  2402. Some(ref prefix) => format!("{} {}", prefix, key),
  2403. None => key,
  2404. };
  2405. auth_query.insert("access_token".to_owned(), val);
  2406. };
  2407. if let Some(ref apikey) = configuration.api_key {
  2408. let key = apikey.key.clone();
  2409. let val = match apikey.prefix {
  2410. Some(ref prefix) => format!("{} {}", prefix, key),
  2411. None => key,
  2412. };
  2413. auth_headers.insert("Authorization".to_owned(), val);
  2414. };
  2415. if let Some(ref auth_conf) = configuration.basic_auth {
  2416. let auth = hyper::header::Authorization(
  2417. hyper::header::Basic {
  2418. username: auth_conf.0.to_owned(),
  2419. password: auth_conf.1.to_owned(),
  2420. }
  2421. );
  2422. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2423. };
  2424. if let Some(ref apikey) = configuration.api_key {
  2425. let key = apikey.key.clone();
  2426. let val = match apikey.prefix {
  2427. Some(ref prefix) => format!("{} {}", prefix, key),
  2428. None => key,
  2429. };
  2430. auth_headers.insert("Sudo".to_owned(), val);
  2431. };
  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("sudo".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_query.insert("token".to_owned(), val);
  2447. };
  2448. let method = hyper::Method::Get;
  2449. let query_string = {
  2450. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2451. for (key, val) in &auth_query {
  2452. query.append_pair(key, val);
  2453. }
  2454. query.finish()
  2455. };
  2456. let uri_str = format!("{}/teams/{id}/members/{username}?{}", configuration.base_path, query_string, id=id, username=username);
  2457. // TODO(farcaller): handle error
  2458. // if let Err(e) = uri {
  2459. // return Box::new(futures::future::err(e));
  2460. // }
  2461. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2462. let mut req = hyper::Request::new(method, uri);
  2463. if let Some(ref user_agent) = configuration.user_agent {
  2464. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2465. }
  2466. for (key, val) in auth_headers {
  2467. req.headers_mut().set_raw(key, val);
  2468. }
  2469. // send request
  2470. Box::new(
  2471. configuration.client.request(req)
  2472. .map_err(|e| Error::from(e))
  2473. .and_then(|resp| {
  2474. let status = resp.status();
  2475. resp.body().concat2()
  2476. .and_then(move |body| Ok((status, body)))
  2477. .map_err(|e| Error::from(e))
  2478. })
  2479. .and_then(|(status, body)| {
  2480. if status.is_success() {
  2481. Ok(body)
  2482. } else {
  2483. Err(Error::from((status, &*body)))
  2484. }
  2485. })
  2486. .and_then(|body| {
  2487. let parsed: Result<::models::User, _> = serde_json::from_slice(&body);
  2488. parsed.map_err(|e| Error::from(e))
  2489. })
  2490. )
  2491. }
  2492. fn org_list_team_members(&self, id: i64) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>> {
  2493. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2494. let mut auth_headers = HashMap::<String, String>::new();
  2495. let mut auth_query = HashMap::<String, String>::new();
  2496. if let Some(ref apikey) = configuration.api_key {
  2497. let key = apikey.key.clone();
  2498. let val = match apikey.prefix {
  2499. Some(ref prefix) => format!("{} {}", prefix, key),
  2500. None => key,
  2501. };
  2502. auth_query.insert("access_token".to_owned(), val);
  2503. };
  2504. if let Some(ref apikey) = configuration.api_key {
  2505. let key = apikey.key.clone();
  2506. let val = match apikey.prefix {
  2507. Some(ref prefix) => format!("{} {}", prefix, key),
  2508. None => key,
  2509. };
  2510. auth_headers.insert("Authorization".to_owned(), val);
  2511. };
  2512. if let Some(ref auth_conf) = configuration.basic_auth {
  2513. let auth = hyper::header::Authorization(
  2514. hyper::header::Basic {
  2515. username: auth_conf.0.to_owned(),
  2516. password: auth_conf.1.to_owned(),
  2517. }
  2518. );
  2519. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2520. };
  2521. if let Some(ref apikey) = configuration.api_key {
  2522. let key = apikey.key.clone();
  2523. let val = match apikey.prefix {
  2524. Some(ref prefix) => format!("{} {}", prefix, key),
  2525. None => key,
  2526. };
  2527. auth_headers.insert("Sudo".to_owned(), val);
  2528. };
  2529. if let Some(ref apikey) = configuration.api_key {
  2530. let key = apikey.key.clone();
  2531. let val = match apikey.prefix {
  2532. Some(ref prefix) => format!("{} {}", prefix, key),
  2533. None => key,
  2534. };
  2535. auth_query.insert("sudo".to_owned(), val);
  2536. };
  2537. if let Some(ref apikey) = configuration.api_key {
  2538. let key = apikey.key.clone();
  2539. let val = match apikey.prefix {
  2540. Some(ref prefix) => format!("{} {}", prefix, key),
  2541. None => key,
  2542. };
  2543. auth_query.insert("token".to_owned(), val);
  2544. };
  2545. let method = hyper::Method::Get;
  2546. let query_string = {
  2547. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2548. for (key, val) in &auth_query {
  2549. query.append_pair(key, val);
  2550. }
  2551. query.finish()
  2552. };
  2553. let uri_str = format!("{}/teams/{id}/members?{}", configuration.base_path, query_string, id=id);
  2554. // TODO(farcaller): handle error
  2555. // if let Err(e) = uri {
  2556. // return Box::new(futures::future::err(e));
  2557. // }
  2558. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2559. let mut req = hyper::Request::new(method, uri);
  2560. if let Some(ref user_agent) = configuration.user_agent {
  2561. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2562. }
  2563. for (key, val) in auth_headers {
  2564. req.headers_mut().set_raw(key, val);
  2565. }
  2566. // send request
  2567. Box::new(
  2568. configuration.client.request(req)
  2569. .map_err(|e| Error::from(e))
  2570. .and_then(|resp| {
  2571. let status = resp.status();
  2572. resp.body().concat2()
  2573. .and_then(move |body| Ok((status, body)))
  2574. .map_err(|e| Error::from(e))
  2575. })
  2576. .and_then(|(status, body)| {
  2577. if status.is_success() {
  2578. Ok(body)
  2579. } else {
  2580. Err(Error::from((status, &*body)))
  2581. }
  2582. })
  2583. .and_then(|body| {
  2584. let parsed: Result<Vec<::models::User>, _> = serde_json::from_slice(&body);
  2585. parsed.map_err(|e| Error::from(e))
  2586. })
  2587. )
  2588. }
  2589. fn org_list_team_repos(&self, id: i64) -> Box<Future<Item = Vec<::models::Repository>, Error = Error<serde_json::Value>>> {
  2590. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2591. let mut auth_headers = HashMap::<String, String>::new();
  2592. let mut auth_query = HashMap::<String, String>::new();
  2593. if let Some(ref apikey) = configuration.api_key {
  2594. let key = apikey.key.clone();
  2595. let val = match apikey.prefix {
  2596. Some(ref prefix) => format!("{} {}", prefix, key),
  2597. None => key,
  2598. };
  2599. auth_query.insert("access_token".to_owned(), val);
  2600. };
  2601. if let Some(ref apikey) = configuration.api_key {
  2602. let key = apikey.key.clone();
  2603. let val = match apikey.prefix {
  2604. Some(ref prefix) => format!("{} {}", prefix, key),
  2605. None => key,
  2606. };
  2607. auth_headers.insert("Authorization".to_owned(), val);
  2608. };
  2609. if let Some(ref auth_conf) = configuration.basic_auth {
  2610. let auth = hyper::header::Authorization(
  2611. hyper::header::Basic {
  2612. username: auth_conf.0.to_owned(),
  2613. password: auth_conf.1.to_owned(),
  2614. }
  2615. );
  2616. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2617. };
  2618. if let Some(ref apikey) = configuration.api_key {
  2619. let key = apikey.key.clone();
  2620. let val = match apikey.prefix {
  2621. Some(ref prefix) => format!("{} {}", prefix, key),
  2622. None => key,
  2623. };
  2624. auth_headers.insert("Sudo".to_owned(), val);
  2625. };
  2626. if let Some(ref apikey) = configuration.api_key {
  2627. let key = apikey.key.clone();
  2628. let val = match apikey.prefix {
  2629. Some(ref prefix) => format!("{} {}", prefix, key),
  2630. None => key,
  2631. };
  2632. auth_query.insert("sudo".to_owned(), val);
  2633. };
  2634. if let Some(ref apikey) = configuration.api_key {
  2635. let key = apikey.key.clone();
  2636. let val = match apikey.prefix {
  2637. Some(ref prefix) => format!("{} {}", prefix, key),
  2638. None => key,
  2639. };
  2640. auth_query.insert("token".to_owned(), val);
  2641. };
  2642. let method = hyper::Method::Get;
  2643. let query_string = {
  2644. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2645. for (key, val) in &auth_query {
  2646. query.append_pair(key, val);
  2647. }
  2648. query.finish()
  2649. };
  2650. let uri_str = format!("{}/teams/{id}/repos?{}", configuration.base_path, query_string, id=id);
  2651. // TODO(farcaller): handle error
  2652. // if let Err(e) = uri {
  2653. // return Box::new(futures::future::err(e));
  2654. // }
  2655. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2656. let mut req = hyper::Request::new(method, uri);
  2657. if let Some(ref user_agent) = configuration.user_agent {
  2658. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2659. }
  2660. for (key, val) in auth_headers {
  2661. req.headers_mut().set_raw(key, val);
  2662. }
  2663. // send request
  2664. Box::new(
  2665. configuration.client.request(req)
  2666. .map_err(|e| Error::from(e))
  2667. .and_then(|resp| {
  2668. let status = resp.status();
  2669. resp.body().concat2()
  2670. .and_then(move |body| Ok((status, body)))
  2671. .map_err(|e| Error::from(e))
  2672. })
  2673. .and_then(|(status, body)| {
  2674. if status.is_success() {
  2675. Ok(body)
  2676. } else {
  2677. Err(Error::from((status, &*body)))
  2678. }
  2679. })
  2680. .and_then(|body| {
  2681. let parsed: Result<Vec<::models::Repository>, _> = serde_json::from_slice(&body);
  2682. parsed.map_err(|e| Error::from(e))
  2683. })
  2684. )
  2685. }
  2686. fn org_list_teams(&self, org: &str) -> Box<Future<Item = Vec<::models::Team>, Error = Error<serde_json::Value>>> {
  2687. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2688. let mut auth_headers = HashMap::<String, String>::new();
  2689. let mut auth_query = HashMap::<String, String>::new();
  2690. if let Some(ref apikey) = configuration.api_key {
  2691. let key = apikey.key.clone();
  2692. let val = match apikey.prefix {
  2693. Some(ref prefix) => format!("{} {}", prefix, key),
  2694. None => key,
  2695. };
  2696. auth_query.insert("access_token".to_owned(), val);
  2697. };
  2698. if let Some(ref apikey) = configuration.api_key {
  2699. let key = apikey.key.clone();
  2700. let val = match apikey.prefix {
  2701. Some(ref prefix) => format!("{} {}", prefix, key),
  2702. None => key,
  2703. };
  2704. auth_headers.insert("Authorization".to_owned(), val);
  2705. };
  2706. if let Some(ref auth_conf) = configuration.basic_auth {
  2707. let auth = hyper::header::Authorization(
  2708. hyper::header::Basic {
  2709. username: auth_conf.0.to_owned(),
  2710. password: auth_conf.1.to_owned(),
  2711. }
  2712. );
  2713. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2714. };
  2715. if let Some(ref apikey) = configuration.api_key {
  2716. let key = apikey.key.clone();
  2717. let val = match apikey.prefix {
  2718. Some(ref prefix) => format!("{} {}", prefix, key),
  2719. None => key,
  2720. };
  2721. auth_headers.insert("Sudo".to_owned(), val);
  2722. };
  2723. if let Some(ref apikey) = configuration.api_key {
  2724. let key = apikey.key.clone();
  2725. let val = match apikey.prefix {
  2726. Some(ref prefix) => format!("{} {}", prefix, key),
  2727. None => key,
  2728. };
  2729. auth_query.insert("sudo".to_owned(), val);
  2730. };
  2731. if let Some(ref apikey) = configuration.api_key {
  2732. let key = apikey.key.clone();
  2733. let val = match apikey.prefix {
  2734. Some(ref prefix) => format!("{} {}", prefix, key),
  2735. None => key,
  2736. };
  2737. auth_query.insert("token".to_owned(), val);
  2738. };
  2739. let method = hyper::Method::Get;
  2740. let query_string = {
  2741. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2742. for (key, val) in &auth_query {
  2743. query.append_pair(key, val);
  2744. }
  2745. query.finish()
  2746. };
  2747. let uri_str = format!("{}/orgs/{org}/teams?{}", configuration.base_path, query_string, org=org);
  2748. // TODO(farcaller): handle error
  2749. // if let Err(e) = uri {
  2750. // return Box::new(futures::future::err(e));
  2751. // }
  2752. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2753. let mut req = hyper::Request::new(method, uri);
  2754. if let Some(ref user_agent) = configuration.user_agent {
  2755. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2756. }
  2757. for (key, val) in auth_headers {
  2758. req.headers_mut().set_raw(key, val);
  2759. }
  2760. // send request
  2761. Box::new(
  2762. configuration.client.request(req)
  2763. .map_err(|e| Error::from(e))
  2764. .and_then(|resp| {
  2765. let status = resp.status();
  2766. resp.body().concat2()
  2767. .and_then(move |body| Ok((status, body)))
  2768. .map_err(|e| Error::from(e))
  2769. })
  2770. .and_then(|(status, body)| {
  2771. if status.is_success() {
  2772. Ok(body)
  2773. } else {
  2774. Err(Error::from((status, &*body)))
  2775. }
  2776. })
  2777. .and_then(|body| {
  2778. let parsed: Result<Vec<::models::Team>, _> = serde_json::from_slice(&body);
  2779. parsed.map_err(|e| Error::from(e))
  2780. })
  2781. )
  2782. }
  2783. fn org_list_user_orgs(&self, username: &str) -> Box<Future<Item = Vec<::models::Organization>, Error = Error<serde_json::Value>>> {
  2784. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2785. let mut auth_headers = HashMap::<String, String>::new();
  2786. let mut auth_query = HashMap::<String, String>::new();
  2787. if let Some(ref apikey) = configuration.api_key {
  2788. let key = apikey.key.clone();
  2789. let val = match apikey.prefix {
  2790. Some(ref prefix) => format!("{} {}", prefix, key),
  2791. None => key,
  2792. };
  2793. auth_query.insert("access_token".to_owned(), val);
  2794. };
  2795. if let Some(ref apikey) = configuration.api_key {
  2796. let key = apikey.key.clone();
  2797. let val = match apikey.prefix {
  2798. Some(ref prefix) => format!("{} {}", prefix, key),
  2799. None => key,
  2800. };
  2801. auth_headers.insert("Authorization".to_owned(), val);
  2802. };
  2803. if let Some(ref auth_conf) = configuration.basic_auth {
  2804. let auth = hyper::header::Authorization(
  2805. hyper::header::Basic {
  2806. username: auth_conf.0.to_owned(),
  2807. password: auth_conf.1.to_owned(),
  2808. }
  2809. );
  2810. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2811. };
  2812. if let Some(ref apikey) = configuration.api_key {
  2813. let key = apikey.key.clone();
  2814. let val = match apikey.prefix {
  2815. Some(ref prefix) => format!("{} {}", prefix, key),
  2816. None => key,
  2817. };
  2818. auth_headers.insert("Sudo".to_owned(), val);
  2819. };
  2820. if let Some(ref apikey) = configuration.api_key {
  2821. let key = apikey.key.clone();
  2822. let val = match apikey.prefix {
  2823. Some(ref prefix) => format!("{} {}", prefix, key),
  2824. None => key,
  2825. };
  2826. auth_query.insert("sudo".to_owned(), val);
  2827. };
  2828. if let Some(ref apikey) = configuration.api_key {
  2829. let key = apikey.key.clone();
  2830. let val = match apikey.prefix {
  2831. Some(ref prefix) => format!("{} {}", prefix, key),
  2832. None => key,
  2833. };
  2834. auth_query.insert("token".to_owned(), val);
  2835. };
  2836. let method = hyper::Method::Get;
  2837. let query_string = {
  2838. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2839. for (key, val) in &auth_query {
  2840. query.append_pair(key, val);
  2841. }
  2842. query.finish()
  2843. };
  2844. let uri_str = format!("{}/users/{username}/orgs?{}", configuration.base_path, query_string, username=username);
  2845. // TODO(farcaller): handle error
  2846. // if let Err(e) = uri {
  2847. // return Box::new(futures::future::err(e));
  2848. // }
  2849. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2850. let mut req = hyper::Request::new(method, uri);
  2851. if let Some(ref user_agent) = configuration.user_agent {
  2852. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2853. }
  2854. for (key, val) in auth_headers {
  2855. req.headers_mut().set_raw(key, val);
  2856. }
  2857. // send request
  2858. Box::new(
  2859. configuration.client.request(req)
  2860. .map_err(|e| Error::from(e))
  2861. .and_then(|resp| {
  2862. let status = resp.status();
  2863. resp.body().concat2()
  2864. .and_then(move |body| Ok((status, body)))
  2865. .map_err(|e| Error::from(e))
  2866. })
  2867. .and_then(|(status, body)| {
  2868. if status.is_success() {
  2869. Ok(body)
  2870. } else {
  2871. Err(Error::from((status, &*body)))
  2872. }
  2873. })
  2874. .and_then(|body| {
  2875. let parsed: Result<Vec<::models::Organization>, _> = serde_json::from_slice(&body);
  2876. parsed.map_err(|e| Error::from(e))
  2877. })
  2878. )
  2879. }
  2880. fn org_publicize_member(&self, org: &str, username: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  2881. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2882. let mut auth_headers = HashMap::<String, String>::new();
  2883. let mut auth_query = HashMap::<String, String>::new();
  2884. if let Some(ref apikey) = configuration.api_key {
  2885. let key = apikey.key.clone();
  2886. let val = match apikey.prefix {
  2887. Some(ref prefix) => format!("{} {}", prefix, key),
  2888. None => key,
  2889. };
  2890. auth_query.insert("access_token".to_owned(), val);
  2891. };
  2892. if let Some(ref apikey) = configuration.api_key {
  2893. let key = apikey.key.clone();
  2894. let val = match apikey.prefix {
  2895. Some(ref prefix) => format!("{} {}", prefix, key),
  2896. None => key,
  2897. };
  2898. auth_headers.insert("Authorization".to_owned(), val);
  2899. };
  2900. if let Some(ref auth_conf) = configuration.basic_auth {
  2901. let auth = hyper::header::Authorization(
  2902. hyper::header::Basic {
  2903. username: auth_conf.0.to_owned(),
  2904. password: auth_conf.1.to_owned(),
  2905. }
  2906. );
  2907. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  2908. };
  2909. if let Some(ref apikey) = configuration.api_key {
  2910. let key = apikey.key.clone();
  2911. let val = match apikey.prefix {
  2912. Some(ref prefix) => format!("{} {}", prefix, key),
  2913. None => key,
  2914. };
  2915. auth_headers.insert("Sudo".to_owned(), val);
  2916. };
  2917. if let Some(ref apikey) = configuration.api_key {
  2918. let key = apikey.key.clone();
  2919. let val = match apikey.prefix {
  2920. Some(ref prefix) => format!("{} {}", prefix, key),
  2921. None => key,
  2922. };
  2923. auth_query.insert("sudo".to_owned(), val);
  2924. };
  2925. if let Some(ref apikey) = configuration.api_key {
  2926. let key = apikey.key.clone();
  2927. let val = match apikey.prefix {
  2928. Some(ref prefix) => format!("{} {}", prefix, key),
  2929. None => key,
  2930. };
  2931. auth_query.insert("token".to_owned(), val);
  2932. };
  2933. let method = hyper::Method::Put;
  2934. let query_string = {
  2935. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  2936. for (key, val) in &auth_query {
  2937. query.append_pair(key, val);
  2938. }
  2939. query.finish()
  2940. };
  2941. let uri_str = format!("{}/orgs/{org}/public_members/{username}?{}", configuration.base_path, query_string, org=org, username=username);
  2942. // TODO(farcaller): handle error
  2943. // if let Err(e) = uri {
  2944. // return Box::new(futures::future::err(e));
  2945. // }
  2946. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  2947. let mut req = hyper::Request::new(method, uri);
  2948. if let Some(ref user_agent) = configuration.user_agent {
  2949. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  2950. }
  2951. for (key, val) in auth_headers {
  2952. req.headers_mut().set_raw(key, val);
  2953. }
  2954. // send request
  2955. Box::new(
  2956. configuration.client.request(req)
  2957. .map_err(|e| Error::from(e))
  2958. .and_then(|resp| {
  2959. let status = resp.status();
  2960. resp.body().concat2()
  2961. .and_then(move |body| Ok((status, body)))
  2962. .map_err(|e| Error::from(e))
  2963. })
  2964. .and_then(|(status, body)| {
  2965. if status.is_success() {
  2966. Ok(body)
  2967. } else {
  2968. Err(Error::from((status, &*body)))
  2969. }
  2970. })
  2971. .and_then(|_| futures::future::ok(()))
  2972. )
  2973. }
  2974. fn org_remove_team_member(&self, id: i64, username: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  2975. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  2976. let mut auth_headers = HashMap::<String, String>::new();
  2977. let mut auth_query = HashMap::<String, String>::new();
  2978. if let Some(ref apikey) = configuration.api_key {
  2979. let key = apikey.key.clone();
  2980. let val = match apikey.prefix {
  2981. Some(ref prefix) => format!("{} {}", prefix, key),
  2982. None => key,
  2983. };
  2984. auth_query.insert("access_token".to_owned(), val);
  2985. };
  2986. if let Some(ref apikey) = configuration.api_key {
  2987. let key = apikey.key.clone();
  2988. let val = match apikey.prefix {
  2989. Some(ref prefix) => format!("{} {}", prefix, key),
  2990. None => key,
  2991. };
  2992. auth_headers.insert("Authorization".to_owned(), val);
  2993. };
  2994. if let Some(ref auth_conf) = configuration.basic_auth {
  2995. let auth = hyper::header::Authorization(
  2996. hyper::header::Basic {
  2997. username: auth_conf.0.to_owned(),
  2998. password: auth_conf.1.to_owned(),
  2999. }
  3000. );
  3001. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3002. };
  3003. if let Some(ref apikey) = configuration.api_key {
  3004. let key = apikey.key.clone();
  3005. let val = match apikey.prefix {
  3006. Some(ref prefix) => format!("{} {}", prefix, key),
  3007. None => key,
  3008. };
  3009. auth_headers.insert("Sudo".to_owned(), val);
  3010. };
  3011. if let Some(ref apikey) = configuration.api_key {
  3012. let key = apikey.key.clone();
  3013. let val = match apikey.prefix {
  3014. Some(ref prefix) => format!("{} {}", prefix, key),
  3015. None => key,
  3016. };
  3017. auth_query.insert("sudo".to_owned(), val);
  3018. };
  3019. if let Some(ref apikey) = configuration.api_key {
  3020. let key = apikey.key.clone();
  3021. let val = match apikey.prefix {
  3022. Some(ref prefix) => format!("{} {}", prefix, key),
  3023. None => key,
  3024. };
  3025. auth_query.insert("token".to_owned(), val);
  3026. };
  3027. let method = hyper::Method::Delete;
  3028. let query_string = {
  3029. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3030. for (key, val) in &auth_query {
  3031. query.append_pair(key, val);
  3032. }
  3033. query.finish()
  3034. };
  3035. let uri_str = format!("{}/teams/{id}/members/{username}?{}", configuration.base_path, query_string, id=id, username=username);
  3036. // TODO(farcaller): handle error
  3037. // if let Err(e) = uri {
  3038. // return Box::new(futures::future::err(e));
  3039. // }
  3040. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3041. let mut req = hyper::Request::new(method, uri);
  3042. if let Some(ref user_agent) = configuration.user_agent {
  3043. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3044. }
  3045. for (key, val) in auth_headers {
  3046. req.headers_mut().set_raw(key, val);
  3047. }
  3048. // send request
  3049. Box::new(
  3050. configuration.client.request(req)
  3051. .map_err(|e| Error::from(e))
  3052. .and_then(|resp| {
  3053. let status = resp.status();
  3054. resp.body().concat2()
  3055. .and_then(move |body| Ok((status, body)))
  3056. .map_err(|e| Error::from(e))
  3057. })
  3058. .and_then(|(status, body)| {
  3059. if status.is_success() {
  3060. Ok(body)
  3061. } else {
  3062. Err(Error::from((status, &*body)))
  3063. }
  3064. })
  3065. .and_then(|_| futures::future::ok(()))
  3066. )
  3067. }
  3068. fn org_remove_team_repository(&self, id: i64, org: &str, repo: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
  3069. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3070. let mut auth_headers = HashMap::<String, String>::new();
  3071. let mut auth_query = HashMap::<String, String>::new();
  3072. if let Some(ref apikey) = configuration.api_key {
  3073. let key = apikey.key.clone();
  3074. let val = match apikey.prefix {
  3075. Some(ref prefix) => format!("{} {}", prefix, key),
  3076. None => key,
  3077. };
  3078. auth_query.insert("access_token".to_owned(), val);
  3079. };
  3080. if let Some(ref apikey) = configuration.api_key {
  3081. let key = apikey.key.clone();
  3082. let val = match apikey.prefix {
  3083. Some(ref prefix) => format!("{} {}", prefix, key),
  3084. None => key,
  3085. };
  3086. auth_headers.insert("Authorization".to_owned(), val);
  3087. };
  3088. if let Some(ref auth_conf) = configuration.basic_auth {
  3089. let auth = hyper::header::Authorization(
  3090. hyper::header::Basic {
  3091. username: auth_conf.0.to_owned(),
  3092. password: auth_conf.1.to_owned(),
  3093. }
  3094. );
  3095. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3096. };
  3097. if let Some(ref apikey) = configuration.api_key {
  3098. let key = apikey.key.clone();
  3099. let val = match apikey.prefix {
  3100. Some(ref prefix) => format!("{} {}", prefix, key),
  3101. None => key,
  3102. };
  3103. auth_headers.insert("Sudo".to_owned(), val);
  3104. };
  3105. if let Some(ref apikey) = configuration.api_key {
  3106. let key = apikey.key.clone();
  3107. let val = match apikey.prefix {
  3108. Some(ref prefix) => format!("{} {}", prefix, key),
  3109. None => key,
  3110. };
  3111. auth_query.insert("sudo".to_owned(), val);
  3112. };
  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("token".to_owned(), val);
  3120. };
  3121. let method = hyper::Method::Delete;
  3122. let query_string = {
  3123. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3124. for (key, val) in &auth_query {
  3125. query.append_pair(key, val);
  3126. }
  3127. query.finish()
  3128. };
  3129. let uri_str = format!("{}/teams/{id}/repos/{org}/{repo}?{}", configuration.base_path, query_string, id=id, org=org, repo=repo);
  3130. // TODO(farcaller): handle error
  3131. // if let Err(e) = uri {
  3132. // return Box::new(futures::future::err(e));
  3133. // }
  3134. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3135. let mut req = hyper::Request::new(method, uri);
  3136. if let Some(ref user_agent) = configuration.user_agent {
  3137. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3138. }
  3139. for (key, val) in auth_headers {
  3140. req.headers_mut().set_raw(key, val);
  3141. }
  3142. // send request
  3143. Box::new(
  3144. configuration.client.request(req)
  3145. .map_err(|e| Error::from(e))
  3146. .and_then(|resp| {
  3147. let status = resp.status();
  3148. resp.body().concat2()
  3149. .and_then(move |body| Ok((status, body)))
  3150. .map_err(|e| Error::from(e))
  3151. })
  3152. .and_then(|(status, body)| {
  3153. if status.is_success() {
  3154. Ok(body)
  3155. } else {
  3156. Err(Error::from((status, &*body)))
  3157. }
  3158. })
  3159. .and_then(|_| futures::future::ok(()))
  3160. )
  3161. }
  3162. fn team_search(&self, org: &str, q: &str, include_desc: bool, limit: i32, page: i32) -> Box<Future<Item = ::models::InlineResponse200, Error = Error<serde_json::Value>>> {
  3163. let configuration: &configuration::Configuration<C> = self.configuration.borrow();
  3164. let mut auth_headers = HashMap::<String, String>::new();
  3165. let mut auth_query = HashMap::<String, String>::new();
  3166. if let Some(ref apikey) = configuration.api_key {
  3167. let key = apikey.key.clone();
  3168. let val = match apikey.prefix {
  3169. Some(ref prefix) => format!("{} {}", prefix, key),
  3170. None => key,
  3171. };
  3172. auth_query.insert("access_token".to_owned(), val);
  3173. };
  3174. if let Some(ref apikey) = configuration.api_key {
  3175. let key = apikey.key.clone();
  3176. let val = match apikey.prefix {
  3177. Some(ref prefix) => format!("{} {}", prefix, key),
  3178. None => key,
  3179. };
  3180. auth_headers.insert("Authorization".to_owned(), val);
  3181. };
  3182. if let Some(ref auth_conf) = configuration.basic_auth {
  3183. let auth = hyper::header::Authorization(
  3184. hyper::header::Basic {
  3185. username: auth_conf.0.to_owned(),
  3186. password: auth_conf.1.to_owned(),
  3187. }
  3188. );
  3189. auth_headers.insert("Authorization".to_owned(), auth.to_string());
  3190. };
  3191. if let Some(ref apikey) = configuration.api_key {
  3192. let key = apikey.key.clone();
  3193. let val = match apikey.prefix {
  3194. Some(ref prefix) => format!("{} {}", prefix, key),
  3195. None => key,
  3196. };
  3197. auth_headers.insert("Sudo".to_owned(), val);
  3198. };
  3199. if let Some(ref apikey) = configuration.api_key {
  3200. let key = apikey.key.clone();
  3201. let val = match apikey.prefix {
  3202. Some(ref prefix) => format!("{} {}", prefix, key),
  3203. None => key,
  3204. };
  3205. auth_query.insert("sudo".to_owned(), val);
  3206. };
  3207. if let Some(ref apikey) = configuration.api_key {
  3208. let key = apikey.key.clone();
  3209. let val = match apikey.prefix {
  3210. Some(ref prefix) => format!("{} {}", prefix, key),
  3211. None => key,
  3212. };
  3213. auth_query.insert("token".to_owned(), val);
  3214. };
  3215. let method = hyper::Method::Get;
  3216. let query_string = {
  3217. let mut query = ::url::form_urlencoded::Serializer::new(String::new());
  3218. query.append_pair("q", &q.to_string());
  3219. query.append_pair("include_desc", &include_desc.to_string());
  3220. query.append_pair("limit", &limit.to_string());
  3221. query.append_pair("page", &page.to_string());
  3222. for (key, val) in &auth_query {
  3223. query.append_pair(key, val);
  3224. }
  3225. query.finish()
  3226. };
  3227. let uri_str = format!("{}/orgs/{org}/teams/search?{}", configuration.base_path, query_string, org=org);
  3228. // TODO(farcaller): handle error
  3229. // if let Err(e) = uri {
  3230. // return Box::new(futures::future::err(e));
  3231. // }
  3232. let mut uri: hyper::Uri = uri_str.parse().unwrap();
  3233. let mut req = hyper::Request::new(method, uri);
  3234. if let Some(ref user_agent) = configuration.user_agent {
  3235. req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
  3236. }
  3237. for (key, val) in auth_headers {
  3238. req.headers_mut().set_raw(key, val);
  3239. }
  3240. // send request
  3241. Box::new(
  3242. configuration.client.request(req)
  3243. .map_err(|e| Error::from(e))
  3244. .and_then(|resp| {
  3245. let status = resp.status();
  3246. resp.body().concat2()
  3247. .and_then(move |body| Ok((status, body)))
  3248. .map_err(|e| Error::from(e))
  3249. })
  3250. .and_then(|(status, body)| {
  3251. if status.is_success() {
  3252. Ok(body)
  3253. } else {
  3254. Err(Error::from((status, &*body)))
  3255. }
  3256. })
  3257. .and_then(|body| {
  3258. let parsed: Result<::models::InlineResponse200, _> = serde_json::from_slice(&body);
  3259. parsed.map_err(|e| Error::from(e))
  3260. })
  3261. )
  3262. }
  3263. }