|
- /*
- * Gitea API.
- *
- * This documentation describes the Gitea API.
- *
- * OpenAPI spec version: 1.1.1
- *
- * Generated by: https://github.com/swagger-api/swagger-codegen.git
- */
-
- use std::rc::Rc;
- use std::borrow::Borrow;
- use std::borrow::Cow;
- use std::collections::HashMap;
-
- use hyper;
- use serde_json;
- use futures;
- use futures::{Future, Stream};
-
- use hyper::header::UserAgent;
-
- use super::{Error, configuration};
-
- pub struct RepositoryApiClient<C: hyper::client::Connect> {
- configuration: Rc<configuration::Configuration<C>>,
- }
-
- impl<C: hyper::client::Connect> RepositoryApiClient<C> {
- pub fn new(configuration: Rc<configuration::Configuration<C>>) -> RepositoryApiClient<C> {
- RepositoryApiClient {
- configuration: configuration,
- }
- }
- }
-
- pub trait RepositoryApi {
- fn create_current_user_repo(&self, body: ::models::CreateRepoOption) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>>;
- fn create_fork(&self, owner: &str, repo: &str, body: ::models::CreateForkOption) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>>;
- fn get_blob(&self, owner: &str, repo: &str, sha: &str) -> Box<Future<Item = ::models::GitBlobResponse, Error = Error<serde_json::Value>>>;
- fn get_tag(&self, owner: &str, repo: &str, sha: &str) -> Box<Future<Item = ::models::AnnotatedTag, Error = Error<serde_json::Value>>>;
- fn get_tree(&self, owner: &str, repo: &str, sha: &str, recursive: bool, page: i32, per_page: i32) -> Box<Future<Item = ::models::GitTreeResponse, Error = Error<serde_json::Value>>>;
- fn list_forks(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Repository>, Error = Error<serde_json::Value>>>;
- fn repo_add_collaborator(&self, owner: &str, repo: &str, collaborator: &str, body: ::models::AddCollaboratorOption) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn repo_add_topc(&self, owner: &str, repo: &str, topic: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn repo_check_collaborator(&self, owner: &str, repo: &str, collaborator: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn repo_create_file(&self, owner: &str, repo: &str, filepath: &str, body: ::models::CreateFileOptions) -> Box<Future<Item = ::models::FileResponse, Error = Error<serde_json::Value>>>;
- fn repo_create_hook(&self, owner: &str, repo: &str, body: ::models::CreateHookOption) -> Box<Future<Item = ::models::Hook, Error = Error<serde_json::Value>>>;
- fn repo_create_key(&self, owner: &str, repo: &str, body: ::models::CreateKeyOption) -> Box<Future<Item = ::models::DeployKey, Error = Error<serde_json::Value>>>;
- fn repo_create_pull_request(&self, owner: &str, repo: &str, body: ::models::CreatePullRequestOption) -> Box<Future<Item = ::models::PullRequest, Error = Error<serde_json::Value>>>;
- fn repo_create_release(&self, owner: &str, repo: &str, body: ::models::CreateReleaseOption) -> Box<Future<Item = ::models::Release, Error = Error<serde_json::Value>>>;
- fn repo_create_release_attachment(&self, owner: &str, repo: &str, id: i64, attachment: ::models::File, name: &str) -> Box<Future<Item = ::models::Attachment, Error = Error<serde_json::Value>>>;
- fn repo_create_status(&self, owner: &str, repo: &str, sha: &str, body: ::models::CreateStatusOption) -> Box<Future<Item = ::models::Status, Error = Error<serde_json::Value>>>;
- fn repo_delete(&self, owner: &str, repo: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn repo_delete_collaborator(&self, owner: &str, repo: &str, collaborator: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn repo_delete_file(&self, owner: &str, repo: &str, filepath: &str, body: ::models::DeleteFileOptions) -> Box<Future<Item = ::models::FileDeleteResponse, Error = Error<serde_json::Value>>>;
- fn repo_delete_git_hook(&self, owner: &str, repo: &str, id: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn repo_delete_hook(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn repo_delete_key(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn repo_delete_release(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn repo_delete_release_attachment(&self, owner: &str, repo: &str, id: i64, attachment_id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn repo_delete_topic(&self, owner: &str, repo: &str, topic: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn repo_edit(&self, owner: &str, repo: &str, body: ::models::EditRepoOption) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>>;
- fn repo_edit_git_hook(&self, owner: &str, repo: &str, id: &str, body: ::models::EditGitHookOption) -> Box<Future<Item = ::models::GitHook, Error = Error<serde_json::Value>>>;
- fn repo_edit_hook(&self, owner: &str, repo: &str, id: i64, body: ::models::EditHookOption) -> Box<Future<Item = ::models::Hook, Error = Error<serde_json::Value>>>;
- fn repo_edit_pull_request(&self, owner: &str, repo: &str, index: i64, body: ::models::EditPullRequestOption) -> Box<Future<Item = ::models::PullRequest, Error = Error<serde_json::Value>>>;
- fn repo_edit_release(&self, owner: &str, repo: &str, id: i64, body: ::models::EditReleaseOption) -> Box<Future<Item = ::models::Release, Error = Error<serde_json::Value>>>;
- fn repo_edit_release_attachment(&self, owner: &str, repo: &str, id: i64, attachment_id: i64, body: ::models::EditAttachmentOptions) -> Box<Future<Item = ::models::Attachment, Error = Error<serde_json::Value>>>;
- fn repo_get(&self, owner: &str, repo: &str) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>>;
- fn repo_get_all_commits(&self, owner: &str, repo: &str, sha: &str, page: i32) -> Box<Future<Item = Vec<::models::Commit>, Error = Error<serde_json::Value>>>;
- fn repo_get_archive(&self, owner: &str, repo: &str, archive: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn repo_get_branch(&self, owner: &str, repo: &str, branch: &str) -> Box<Future<Item = ::models::Branch, Error = Error<serde_json::Value>>>;
- fn repo_get_by_id(&self, id: i64) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>>;
- fn repo_get_combined_status_by_ref(&self, owner: &str, repo: &str, _ref: &str, page: i32) -> Box<Future<Item = ::models::Status, Error = Error<serde_json::Value>>>;
- fn repo_get_contents(&self, owner: &str, repo: &str, filepath: &str, _ref: &str) -> Box<Future<Item = ::models::ContentsResponse, Error = Error<serde_json::Value>>>;
- fn repo_get_contents_list(&self, owner: &str, repo: &str, _ref: &str) -> Box<Future<Item = Vec<::models::ContentsResponse>, Error = Error<serde_json::Value>>>;
- fn repo_get_editor_config(&self, owner: &str, repo: &str, filepath: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn repo_get_git_hook(&self, owner: &str, repo: &str, id: &str) -> Box<Future<Item = ::models::GitHook, Error = Error<serde_json::Value>>>;
- fn repo_get_hook(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = ::models::Hook, Error = Error<serde_json::Value>>>;
- fn repo_get_key(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = ::models::DeployKey, Error = Error<serde_json::Value>>>;
- fn repo_get_pull_request(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = ::models::PullRequest, Error = Error<serde_json::Value>>>;
- fn repo_get_raw_file(&self, owner: &str, repo: &str, filepath: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn repo_get_release(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = ::models::Release, Error = Error<serde_json::Value>>>;
- fn repo_get_release_attachment(&self, owner: &str, repo: &str, id: i64, attachment_id: i64) -> Box<Future<Item = ::models::Attachment, Error = Error<serde_json::Value>>>;
- fn repo_get_single_commit(&self, owner: &str, repo: &str, sha: &str) -> Box<Future<Item = ::models::Commit, Error = Error<serde_json::Value>>>;
- fn repo_list_all_git_refs(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Reference>, Error = Error<serde_json::Value>>>;
- fn repo_list_branches(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Branch>, Error = Error<serde_json::Value>>>;
- fn repo_list_collaborators(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>>;
- fn repo_list_git_hooks(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::GitHook>, Error = Error<serde_json::Value>>>;
- fn repo_list_git_refs(&self, owner: &str, repo: &str, _ref: &str) -> Box<Future<Item = Vec<::models::Reference>, Error = Error<serde_json::Value>>>;
- fn repo_list_hooks(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Hook>, Error = Error<serde_json::Value>>>;
- fn repo_list_keys(&self, owner: &str, repo: &str, key_id: i32, fingerprint: &str) -> Box<Future<Item = Vec<::models::DeployKey>, Error = Error<serde_json::Value>>>;
- fn repo_list_pull_requests(&self, owner: &str, repo: &str, page: i32, state: &str, sort: &str, milestone: i64, labels: Vec<i64>) -> Box<Future<Item = Vec<::models::PullRequest>, Error = Error<serde_json::Value>>>;
- fn repo_list_release_attachments(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = Vec<::models::Attachment>, Error = Error<serde_json::Value>>>;
- fn repo_list_releases(&self, owner: &str, repo: &str, page: i32, per_page: i32) -> Box<Future<Item = Vec<::models::Release>, Error = Error<serde_json::Value>>>;
- fn repo_list_stargazers(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>>;
- fn repo_list_statuses(&self, owner: &str, repo: &str, sha: &str, page: i32, sort: &str, state: &str) -> Box<Future<Item = Vec<::models::Status>, Error = Error<serde_json::Value>>>;
- fn repo_list_subscribers(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>>;
- fn repo_list_tags(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Tag>, Error = Error<serde_json::Value>>>;
- fn repo_list_topics(&self, owner: &str, repo: &str) -> Box<Future<Item = ::models::TopicName, Error = Error<serde_json::Value>>>;
- fn repo_merge_pull_request(&self, owner: &str, repo: &str, index: i64, body: ::models::MergePullRequestOption) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn repo_migrate(&self, body: ::models::MigrateRepoForm) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>>;
- fn repo_mirror_sync(&self, owner: &str, repo: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn repo_pull_request_is_merged(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn repo_search(&self, q: &str, topic: bool, include_desc: bool, uid: i64, priority_owner_id: i64, starred_by: i64, private: bool, template: bool, page: i32, limit: i32, mode: &str, exclusive: bool, sort: &str, order: &str) -> Box<Future<Item = ::models::SearchResults, Error = Error<serde_json::Value>>>;
- fn repo_signing_key(&self, owner: &str, repo: &str) -> Box<Future<Item = String, Error = Error<serde_json::Value>>>;
- fn repo_test_hook(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn repo_tracked_times(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::TrackedTime>, Error = Error<serde_json::Value>>>;
- fn repo_update_file(&self, owner: &str, repo: &str, filepath: &str, body: ::models::UpdateFileOptions) -> Box<Future<Item = ::models::FileResponse, Error = Error<serde_json::Value>>>;
- fn repo_update_topics(&self, owner: &str, repo: &str, body: ::models::RepoTopicOptions) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn topic_search(&self, q: &str) -> Box<Future<Item = Vec<::models::TopicResponse>, Error = Error<serde_json::Value>>>;
- fn user_current_check_subscription(&self, owner: &str, repo: &str) -> Box<Future<Item = ::models::WatchInfo, Error = Error<serde_json::Value>>>;
- fn user_current_delete_subscription(&self, owner: &str, repo: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
- fn user_current_put_subscription(&self, owner: &str, repo: &str) -> Box<Future<Item = ::models::WatchInfo, Error = Error<serde_json::Value>>>;
- }
-
-
- impl<C: hyper::client::Connect>RepositoryApi for RepositoryApiClient<C> {
- fn create_current_user_repo(&self, body: ::models::CreateRepoOption) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Post;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/user/repos?{}", configuration.base_path, query_string);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::Repository, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn create_fork(&self, owner: &str, repo: &str, body: ::models::CreateForkOption) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Post;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/forks?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::Repository, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn get_blob(&self, owner: &str, repo: &str, sha: &str) -> Box<Future<Item = ::models::GitBlobResponse, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/git/blobs/{sha}?{}", configuration.base_path, query_string, owner=owner, repo=repo, sha=sha);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::GitBlobResponse, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn get_tag(&self, owner: &str, repo: &str, sha: &str) -> Box<Future<Item = ::models::AnnotatedTag, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/git/tags/{sha}?{}", configuration.base_path, query_string, owner=owner, repo=repo, sha=sha);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::AnnotatedTag, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn get_tree(&self, owner: &str, repo: &str, sha: &str, recursive: bool, page: i32, per_page: i32) -> Box<Future<Item = ::models::GitTreeResponse, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- query.append_pair("recursive", &recursive.to_string());
- query.append_pair("page", &page.to_string());
- query.append_pair("per_page", &per_page.to_string());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/git/trees/{sha}?{}", configuration.base_path, query_string, owner=owner, repo=repo, sha=sha);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::GitTreeResponse, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn list_forks(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Repository>, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/forks?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<Vec<::models::Repository>, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_add_collaborator(&self, owner: &str, repo: &str, collaborator: &str, body: ::models::AddCollaboratorOption) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Put;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/collaborators/{collaborator}?{}", configuration.base_path, query_string, owner=owner, repo=repo, collaborator=collaborator);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn repo_add_topc(&self, owner: &str, repo: &str, topic: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Put;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/topics/{topic}?{}", configuration.base_path, query_string, owner=owner, repo=repo, topic=topic);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn repo_check_collaborator(&self, owner: &str, repo: &str, collaborator: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/collaborators/{collaborator}?{}", configuration.base_path, query_string, owner=owner, repo=repo, collaborator=collaborator);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn repo_create_file(&self, owner: &str, repo: &str, filepath: &str, body: ::models::CreateFileOptions) -> Box<Future<Item = ::models::FileResponse, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Post;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/contents/{filepath}?{}", configuration.base_path, query_string, owner=owner, repo=repo, filepath=filepath);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::FileResponse, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_create_hook(&self, owner: &str, repo: &str, body: ::models::CreateHookOption) -> Box<Future<Item = ::models::Hook, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Post;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/hooks?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::Hook, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_create_key(&self, owner: &str, repo: &str, body: ::models::CreateKeyOption) -> Box<Future<Item = ::models::DeployKey, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Post;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/keys?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::DeployKey, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_create_pull_request(&self, owner: &str, repo: &str, body: ::models::CreatePullRequestOption) -> Box<Future<Item = ::models::PullRequest, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Post;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/pulls?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::PullRequest, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_create_release(&self, owner: &str, repo: &str, body: ::models::CreateReleaseOption) -> Box<Future<Item = ::models::Release, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Post;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/releases?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::Release, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_create_release_attachment(&self, owner: &str, repo: &str, id: i64, attachment: ::models::File, name: &str) -> Box<Future<Item = ::models::Attachment, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Post;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- query.append_pair("name", &name.to_string());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/releases/{id}/assets?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::Attachment, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_create_status(&self, owner: &str, repo: &str, sha: &str, body: ::models::CreateStatusOption) -> Box<Future<Item = ::models::Status, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Post;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/statuses/{sha}?{}", configuration.base_path, query_string, owner=owner, repo=repo, sha=sha);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::Status, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_delete(&self, owner: &str, repo: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Delete;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn repo_delete_collaborator(&self, owner: &str, repo: &str, collaborator: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Delete;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/collaborators/{collaborator}?{}", configuration.base_path, query_string, owner=owner, repo=repo, collaborator=collaborator);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn repo_delete_file(&self, owner: &str, repo: &str, filepath: &str, body: ::models::DeleteFileOptions) -> Box<Future<Item = ::models::FileDeleteResponse, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Delete;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/contents/{filepath}?{}", configuration.base_path, query_string, owner=owner, repo=repo, filepath=filepath);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::FileDeleteResponse, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_delete_git_hook(&self, owner: &str, repo: &str, id: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Delete;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/hooks/git/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn repo_delete_hook(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Delete;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/hooks/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn repo_delete_key(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Delete;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/keys/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn repo_delete_release(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Delete;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/releases/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn repo_delete_release_attachment(&self, owner: &str, repo: &str, id: i64, attachment_id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Delete;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/releases/{id}/assets/{attachment_id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id, attachment_id=attachment_id);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn repo_delete_topic(&self, owner: &str, repo: &str, topic: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Delete;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/topics/{topic}?{}", configuration.base_path, query_string, owner=owner, repo=repo, topic=topic);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn repo_edit(&self, owner: &str, repo: &str, body: ::models::EditRepoOption) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Patch;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::Repository, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_edit_git_hook(&self, owner: &str, repo: &str, id: &str, body: ::models::EditGitHookOption) -> Box<Future<Item = ::models::GitHook, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Patch;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/hooks/git/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::GitHook, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_edit_hook(&self, owner: &str, repo: &str, id: i64, body: ::models::EditHookOption) -> Box<Future<Item = ::models::Hook, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Patch;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/hooks/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::Hook, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_edit_pull_request(&self, owner: &str, repo: &str, index: i64, body: ::models::EditPullRequestOption) -> Box<Future<Item = ::models::PullRequest, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Patch;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/pulls/{index}?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::PullRequest, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_edit_release(&self, owner: &str, repo: &str, id: i64, body: ::models::EditReleaseOption) -> Box<Future<Item = ::models::Release, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Patch;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/releases/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::Release, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_edit_release_attachment(&self, owner: &str, repo: &str, id: i64, attachment_id: i64, body: ::models::EditAttachmentOptions) -> Box<Future<Item = ::models::Attachment, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Patch;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/releases/{id}/assets/{attachment_id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id, attachment_id=attachment_id);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::Attachment, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_get(&self, owner: &str, repo: &str) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- //auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- //auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::Repository, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_get_all_commits(&self, owner: &str, repo: &str, sha: &str, page: i32) -> Box<Future<Item = Vec<::models::Commit>, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- query.append_pair("sha", &sha.to_string());
- query.append_pair("page", &page.to_string());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/commits?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<Vec<::models::Commit>, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_get_archive(&self, owner: &str, repo: &str, archive: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/archive/{archive}?{}", configuration.base_path, query_string, owner=owner, repo=repo, archive=archive);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn repo_get_branch(&self, owner: &str, repo: &str, branch: &str) -> Box<Future<Item = ::models::Branch, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/branches/{branch}?{}", configuration.base_path, query_string, owner=owner, repo=repo, branch=branch);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::Branch, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_get_by_id(&self, id: i64) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repositories/{id}?{}", configuration.base_path, query_string, id=id);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::Repository, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_get_combined_status_by_ref(&self, owner: &str, repo: &str, _ref: &str, page: i32) -> Box<Future<Item = ::models::Status, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- query.append_pair("page", &page.to_string());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/commits/{ref}/statuses?{}", configuration.base_path, query_string, owner=owner, repo=repo, ref=_ref);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::Status, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_get_contents(&self, owner: &str, repo: &str, filepath: &str, _ref: &str) -> Box<Future<Item = ::models::ContentsResponse, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- query.append_pair("ref", &_ref.to_string());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/contents/{filepath}?{}", configuration.base_path, query_string, owner=owner, repo=repo, filepath=filepath);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::ContentsResponse, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_get_contents_list(&self, owner: &str, repo: &str, _ref: &str) -> Box<Future<Item = Vec<::models::ContentsResponse>, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- query.append_pair("ref", &_ref.to_string());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/contents?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<Vec<::models::ContentsResponse>, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_get_editor_config(&self, owner: &str, repo: &str, filepath: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/editorconfig/{filepath}?{}", configuration.base_path, query_string, owner=owner, repo=repo, filepath=filepath);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn repo_get_git_hook(&self, owner: &str, repo: &str, id: &str) -> Box<Future<Item = ::models::GitHook, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/hooks/git/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::GitHook, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_get_hook(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = ::models::Hook, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/hooks/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::Hook, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_get_key(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = ::models::DeployKey, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/keys/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::DeployKey, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_get_pull_request(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = ::models::PullRequest, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/pulls/{index}?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::PullRequest, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_get_raw_file(&self, owner: &str, repo: &str, filepath: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/raw/{filepath}?{}", configuration.base_path, query_string, owner=owner, repo=repo, filepath=filepath);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn repo_get_release(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = ::models::Release, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/releases/{id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::Release, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_get_release_attachment(&self, owner: &str, repo: &str, id: i64, attachment_id: i64) -> Box<Future<Item = ::models::Attachment, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/releases/{id}/assets/{attachment_id}?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id, attachment_id=attachment_id);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::Attachment, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_get_single_commit(&self, owner: &str, repo: &str, sha: &str) -> Box<Future<Item = ::models::Commit, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/git/commits/{sha}?{}", configuration.base_path, query_string, owner=owner, repo=repo, sha=sha);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::Commit, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_list_all_git_refs(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Reference>, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/git/refs?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<Vec<::models::Reference>, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_list_branches(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Branch>, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/branches?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<Vec<::models::Branch>, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_list_collaborators(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/collaborators?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<Vec<::models::User>, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_list_git_hooks(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::GitHook>, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/hooks/git?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<Vec<::models::GitHook>, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_list_git_refs(&self, owner: &str, repo: &str, _ref: &str) -> Box<Future<Item = Vec<::models::Reference>, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/git/refs/{ref}?{}", configuration.base_path, query_string, owner=owner, repo=repo, ref=_ref);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<Vec<::models::Reference>, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_list_hooks(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Hook>, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/hooks?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<Vec<::models::Hook>, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_list_keys(&self, owner: &str, repo: &str, key_id: i32, fingerprint: &str) -> Box<Future<Item = Vec<::models::DeployKey>, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- query.append_pair("key_id", &key_id.to_string());
- query.append_pair("fingerprint", &fingerprint.to_string());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/keys?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<Vec<::models::DeployKey>, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_list_pull_requests(&self, owner: &str, repo: &str, page: i32, state: &str, sort: &str, milestone: i64, labels: Vec<i64>) -> Box<Future<Item = Vec<::models::PullRequest>, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- query.append_pair("page", &page.to_string());
- query.append_pair("state", &state.to_string());
- query.append_pair("sort", &sort.to_string());
- query.append_pair("milestone", &milestone.to_string());
- let mut label_str = "".to_owned();
- for label in labels {
- label_str += &label.to_string();
- label_str += ",";
- }
- query.append_pair("labels", &label_str[..label_str.chars().count()-1].to_string());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/pulls?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<Vec<::models::PullRequest>, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_list_release_attachments(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = Vec<::models::Attachment>, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/releases/{id}/assets?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<Vec<::models::Attachment>, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_list_releases(&self, owner: &str, repo: &str, page: i32, per_page: i32) -> Box<Future<Item = Vec<::models::Release>, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- //auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- //auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- query.append_pair("page", &page.to_string());
- query.append_pair("per_page", &per_page.to_string());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/releases?{}", configuration.base_path, query_string, owner=owner, repo=repo);
- //println!("Request URL {}", uri_str);
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<Vec<::models::Release>, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_list_stargazers(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/stargazers?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<Vec<::models::User>, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_list_statuses(&self, owner: &str, repo: &str, sha: &str, page: i32, sort: &str, state: &str) -> Box<Future<Item = Vec<::models::Status>, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- query.append_pair("page", &page.to_string());
- query.append_pair("sort", &sort.to_string());
- query.append_pair("state", &state.to_string());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/statuses/{sha}?{}", configuration.base_path, query_string, owner=owner, repo=repo, sha=sha);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<Vec<::models::Status>, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_list_subscribers(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::User>, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/subscribers?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<Vec<::models::User>, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_list_tags(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::Tag>, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/tags?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<Vec<::models::Tag>, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_list_topics(&self, owner: &str, repo: &str) -> Box<Future<Item = ::models::TopicName, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/topics?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::TopicName, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_merge_pull_request(&self, owner: &str, repo: &str, index: i64, body: ::models::MergePullRequestOption) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Post;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/pulls/{index}/merge?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn repo_migrate(&self, body: ::models::MigrateRepoForm) -> Box<Future<Item = ::models::Repository, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Post;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/migrate?{}", configuration.base_path, query_string);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::Repository, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_mirror_sync(&self, owner: &str, repo: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Post;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/mirror-sync?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn repo_pull_request_is_merged(&self, owner: &str, repo: &str, index: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/pulls/{index}/merge?{}", configuration.base_path, query_string, owner=owner, repo=repo, index=index);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn repo_search(&self, q: &str, topic: bool, include_desc: bool, uid: i64, priority_owner_id: i64, starred_by: i64, private: bool, template: bool, page: i32, limit: i32, mode: &str, exclusive: bool, sort: &str, order: &str) -> Box<Future<Item = ::models::SearchResults, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- query.append_pair("q", &q.to_string());
- query.append_pair("topic", &topic.to_string());
- query.append_pair("includeDesc", &include_desc.to_string());
- query.append_pair("uid", &uid.to_string());
- query.append_pair("priority_owner_id", &priority_owner_id.to_string());
- query.append_pair("starredBy", &starred_by.to_string());
- query.append_pair("private", &private.to_string());
- query.append_pair("template", &template.to_string());
- query.append_pair("page", &page.to_string());
- query.append_pair("limit", &limit.to_string());
- query.append_pair("mode", &mode.to_string());
- query.append_pair("exclusive", &exclusive.to_string());
- query.append_pair("sort", &sort.to_string());
- query.append_pair("order", &order.to_string());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/search?{}", configuration.base_path, query_string);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::SearchResults, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_signing_key(&self, owner: &str, repo: &str) -> Box<Future<Item = String, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/signing-key.gpg?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<String, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_test_hook(&self, owner: &str, repo: &str, id: i64) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Post;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/hooks/{id}/tests?{}", configuration.base_path, query_string, owner=owner, repo=repo, id=id);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn repo_tracked_times(&self, owner: &str, repo: &str) -> Box<Future<Item = Vec<::models::TrackedTime>, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/times?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<Vec<::models::TrackedTime>, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_update_file(&self, owner: &str, repo: &str, filepath: &str, body: ::models::UpdateFileOptions) -> Box<Future<Item = ::models::FileResponse, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Put;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/contents/{filepath}?{}", configuration.base_path, query_string, owner=owner, repo=repo, filepath=filepath);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::FileResponse, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn repo_update_topics(&self, owner: &str, repo: &str, body: ::models::RepoTopicOptions) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Put;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/topics?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
- let serialized = serde_json::to_string(&body).unwrap();
- req.headers_mut().set(hyper::header::ContentType::json());
- req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
- req.set_body(serialized);
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn topic_search(&self, q: &str) -> Box<Future<Item = Vec<::models::TopicResponse>, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- query.append_pair("q", &q.to_string());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/topics/search?{}", configuration.base_path, query_string);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<Vec<::models::TopicResponse>, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn user_current_check_subscription(&self, owner: &str, repo: &str) -> Box<Future<Item = ::models::WatchInfo, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Get;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/subscription?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::WatchInfo, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- fn user_current_delete_subscription(&self, owner: &str, repo: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Delete;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/subscription?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|_| futures::future::ok(()))
- )
- }
-
- fn user_current_put_subscription(&self, owner: &str, repo: &str) -> Box<Future<Item = ::models::WatchInfo, Error = Error<serde_json::Value>>> {
- let configuration: &configuration::Configuration<C> = self.configuration.borrow();
-
- let mut auth_headers = HashMap::<String, String>::new();
- let mut auth_query = HashMap::<String, String>::new();
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("access_token".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Authorization".to_owned(), val);
- };
- if let Some(ref auth_conf) = configuration.basic_auth {
- let auth = hyper::header::Authorization(
- hyper::header::Basic {
- username: auth_conf.0.to_owned(),
- password: auth_conf.1.to_owned(),
- }
- );
- auth_headers.insert("Authorization".to_owned(), auth.to_string());
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_headers.insert("Sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("sudo".to_owned(), val);
- };
- if let Some(ref apikey) = configuration.api_key {
- let key = apikey.key.clone();
- let val = match apikey.prefix {
- Some(ref prefix) => format!("{} {}", prefix, key),
- None => key,
- };
- auth_query.insert("token".to_owned(), val);
- };
- let method = hyper::Method::Put;
-
- let query_string = {
- let mut query = ::url::form_urlencoded::Serializer::new(String::new());
- for (key, val) in &auth_query {
- query.append_pair(key, val);
- }
- query.finish()
- };
- let uri_str = format!("{}/repos/{owner}/{repo}/subscription?{}", configuration.base_path, query_string, owner=owner, repo=repo);
-
- // TODO(farcaller): handle error
- // if let Err(e) = uri {
- // return Box::new(futures::future::err(e));
- // }
- let mut uri: hyper::Uri = uri_str.parse().unwrap();
-
- let mut req = hyper::Request::new(method, uri);
-
- if let Some(ref user_agent) = configuration.user_agent {
- req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
- }
-
-
- for (key, val) in auth_headers {
- req.headers_mut().set_raw(key, val);
- }
-
-
- // send request
- Box::new(
- configuration.client.request(req)
- .map_err(|e| Error::from(e))
- .and_then(|resp| {
- let status = resp.status();
- resp.body().concat2()
- .and_then(move |body| Ok((status, body)))
- .map_err(|e| Error::from(e))
- })
- .and_then(|(status, body)| {
- if status.is_success() {
- Ok(body)
- } else {
- Err(Error::from((status, &*body)))
- }
- })
- .and_then(|body| {
- let parsed: Result<::models::WatchInfo, _> = serde_json::from_slice(&body);
- parsed.map_err(|e| Error::from(e))
- })
- )
- }
-
- }
|