#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate chrono; extern crate futures; #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; // Logically this should be in the client and server modules, but rust doesn't allow `macro_use` from a module. #[cfg(any(feature = "client", feature = "server"))] #[macro_use] extern crate hyper; extern crate swagger; use futures::Stream; use std::io::Error; #[allow(unused_imports)] use std::collections::HashMap; pub use futures::Future; #[cfg(any(feature = "client", feature = "server"))] mod mimetypes; pub use swagger::{ApiError, Context, ContextWrapper}; #[derive(Debug, PartialEq)] pub enum ContainerIdGetResponse { /// Found Entity FoundEntity(models::ContainerEntity), /// Bad Request BadRequest(models::ErrorResponse), /// Not Found NotFound(models::ErrorResponse), /// Generic Error GenericError(models::ErrorResponse), } #[derive(Debug, PartialEq)] pub enum ContainerLookupGetResponse { /// Found Entity FoundEntity(models::ContainerEntity), /// Bad Request BadRequest(models::ErrorResponse), /// Not Found NotFound(models::ErrorResponse), /// Generic Error GenericError(models::ErrorResponse), } #[derive(Debug, PartialEq)] pub enum ContainerPostResponse { /// Created Entity CreatedEntity(models::EntityEdit), /// Bad Request BadRequest(models::ErrorResponse), /// Not Found NotFound(models::ErrorResponse), /// Generic Error GenericError(models::ErrorResponse), } #[derive(Debug, PartialEq)] pub enum CreatorIdGetResponse { /// Found Entity FoundEntity(models::CreatorEntity), /// Bad Request BadRequest(models::ErrorResponse), /// Not Found NotFound(models::ErrorResponse), /// Generic Error GenericError(models::ErrorResponse), } #[derive(Debug, PartialEq)] pub enum CreatorLookupGetResponse { /// Found Entity FoundEntity(models::CreatorEntity), /// Bad Request BadRequest(models::ErrorResponse), /// Not Found NotFound(models::ErrorResponse), /// Generic Error GenericError(models::ErrorResponse), } #[derive(Debug, PartialEq)] pub enum CreatorPostResponse { /// Created Entity CreatedEntity(models::EntityEdit), /// Bad Request BadRequest(models::ErrorResponse), /// Not Found NotFound(models::ErrorResponse), /// Generic Error GenericError(models::ErrorResponse), } #[derive(Debug, PartialEq)] pub enum EditgroupIdAcceptPostResponse { /// Merged Successfully MergedSuccessfully(models::Success), /// Unmergable Unmergable(models::ErrorResponse), /// Not Found NotFound(models::ErrorResponse), /// Generic Error GenericError(models::ErrorResponse), } #[derive(Debug, PartialEq)] pub enum EditgroupIdGetResponse { /// Found Entity FoundEntity(models::Editgroup), /// Bad Request BadRequest(models::ErrorResponse), /// Not Found NotFound(models::ErrorResponse), /// Generic Error GenericError(models::ErrorResponse), } #[derive(Debug, PartialEq)] pub enum EditgroupPostResponse { /// Successfully Created SuccessfullyCreated(models::Editgroup), /// Bad Request BadRequest(models::ErrorResponse), /// Generic Error GenericError(models::ErrorResponse), } #[derive(Debug, PartialEq)] pub enum EditorUsernameChangelogGetResponse { /// Found Merged Changes FoundMergedChanges(models::Changelogentries), /// Not Found NotFound(models::ErrorResponse), /// Generic Error GenericError(models::ErrorResponse), } #[derive(Debug, PartialEq)] pub enum EditorUsernameGetResponse { /// Found Editor FoundEditor(models::Editor), /// Not Found NotFound(models::ErrorResponse), /// Generic Error GenericError(models::ErrorResponse), } #[derive(Debug, PartialEq)] pub enum FileIdGetResponse { /// Found Entity FoundEntity(models::FileEntity), /// Bad Request BadRequest(models::ErrorResponse), /// Not Found NotFound(models::ErrorResponse), /// Generic Error GenericError(models::ErrorResponse), } #[derive(Debug, PartialEq)] pub enum FileLookupGetResponse { /// Found Entity FoundEntity(models::FileEntity), /// Bad Request BadRequest(models::ErrorResponse), /// Not Found NotFound(models::ErrorResponse), /// Generic Error GenericError(models::ErrorResponse), } #[derive(Debug, PartialEq)] pub enum FilePostResponse { /// Created Entity CreatedEntity(models::EntityEdit), /// Bad Request BadRequest(models::ErrorResponse), /// Not Found NotFound(models::ErrorResponse), /// Generic Error GenericError(models::ErrorResponse), } #[derive(Debug, PartialEq)] pub enum ReleaseIdGetResponse { /// Found Entity FoundEntity(models::ReleaseEntity), /// Bad Request BadRequest(models::ErrorResponse), /// Not Found NotFound(models::ErrorResponse), /// Generic Error GenericError(models::ErrorResponse), } #[derive(Debug, PartialEq)] pub enum ReleaseLookupGetResponse { /// Found Entity FoundEntity(models::ReleaseEntity), /// Bad Request BadRequest(models::ErrorResponse), /// Not Found NotFound(models::ErrorResponse), /// Generic Error GenericError(models::ErrorResponse), } #[derive(Debug, PartialEq)] pub enum ReleasePostResponse { /// Created Entity CreatedEntity(models::EntityEdit), /// Bad Request BadRequest(models::ErrorResponse), /// Not Found NotFound(models::ErrorResponse), /// Generic Error GenericError(models::ErrorResponse), } #[derive(Debug, PartialEq)] pub enum WorkIdGetResponse { /// Found Entity FoundEntity(models::WorkEntity), /// Bad Request BadRequest(models::ErrorResponse), /// Not Found NotFound(models::ErrorResponse), /// Generic Error GenericError(models::ErrorResponse), } #[derive(Debug, PartialEq)] pub enum WorkPostResponse { /// Created Entity CreatedEntity(models::EntityEdit), /// Bad Request BadRequest(models::ErrorResponse), /// Not Found NotFound(models::ErrorResponse), /// Generic Error GenericError(models::ErrorResponse), } /// API pub trait Api { fn container_id_get(&self, id: String, context: &Context) -> Box + Send>; fn container_lookup_get(&self, issn: String, context: &Context) -> Box + Send>; fn container_post(&self, body: models::ContainerEntity, context: &Context) -> Box + Send>; fn creator_id_get(&self, id: String, context: &Context) -> Box + Send>; fn creator_lookup_get(&self, orcid: String, context: &Context) -> Box + Send>; fn creator_post(&self, body: models::CreatorEntity, context: &Context) -> Box + Send>; fn editgroup_id_accept_post(&self, id: i64, context: &Context) -> Box + Send>; fn editgroup_id_get(&self, id: i64, context: &Context) -> Box + Send>; fn editgroup_post(&self, body: models::Editgroup, context: &Context) -> Box + Send>; fn editor_username_changelog_get(&self, username: String, context: &Context) -> Box + Send>; fn editor_username_get(&self, username: String, context: &Context) -> Box + Send>; fn file_id_get(&self, id: String, context: &Context) -> Box + Send>; fn file_lookup_get(&self, sha1: String, context: &Context) -> Box + Send>; fn file_post(&self, body: models::FileEntity, context: &Context) -> Box + Send>; fn release_id_get(&self, id: String, context: &Context) -> Box + Send>; fn release_lookup_get(&self, doi: String, context: &Context) -> Box + Send>; fn release_post(&self, body: models::ReleaseEntity, context: &Context) -> Box + Send>; fn work_id_get(&self, id: String, context: &Context) -> Box + Send>; fn work_post(&self, body: models::WorkEntity, context: &Context) -> Box + Send>; } /// API without a `Context` pub trait ApiNoContext { fn container_id_get(&self, id: String) -> Box + Send>; fn container_lookup_get(&self, issn: String) -> Box + Send>; fn container_post(&self, body: models::ContainerEntity) -> Box + Send>; fn creator_id_get(&self, id: String) -> Box + Send>; fn creator_lookup_get(&self, orcid: String) -> Box + Send>; fn creator_post(&self, body: models::CreatorEntity) -> Box + Send>; fn editgroup_id_accept_post(&self, id: i64) -> Box + Send>; fn editgroup_id_get(&self, id: i64) -> Box + Send>; fn editgroup_post(&self, body: models::Editgroup) -> Box + Send>; fn editor_username_changelog_get(&self, username: String) -> Box + Send>; fn editor_username_get(&self, username: String) -> Box + Send>; fn file_id_get(&self, id: String) -> Box + Send>; fn file_lookup_get(&self, sha1: String) -> Box + Send>; fn file_post(&self, body: models::FileEntity) -> Box + Send>; fn release_id_get(&self, id: String) -> Box + Send>; fn release_lookup_get(&self, doi: String) -> Box + Send>; fn release_post(&self, body: models::ReleaseEntity) -> Box + Send>; fn work_id_get(&self, id: String) -> Box + Send>; fn work_post(&self, body: models::WorkEntity) -> Box + Send>; } /// Trait to extend an API to make it easy to bind it to a context. pub trait ContextWrapperExt<'a> where Self: Sized, { /// Binds this API to a context. fn with_context(self: &'a Self, context: Context) -> ContextWrapper<'a, Self>; } impl<'a, T: Api + Sized> ContextWrapperExt<'a> for T { fn with_context(self: &'a T, context: Context) -> ContextWrapper<'a, T> { ContextWrapper::::new(self, context) } } impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { fn container_id_get(&self, id: String) -> Box + Send> { self.api().container_id_get(id, &self.context()) } fn container_lookup_get(&self, issn: String) -> Box + Send> { self.api().container_lookup_get(issn, &self.context()) } fn container_post(&self, body: models::ContainerEntity) -> Box + Send> { self.api().container_post(body, &self.context()) } fn creator_id_get(&self, id: String) -> Box + Send> { self.api().creator_id_get(id, &self.context()) } fn creator_lookup_get(&self, orcid: String) -> Box + Send> { self.api().creator_lookup_get(orcid, &self.context()) } fn creator_post(&self, body: models::CreatorEntity) -> Box + Send> { self.api().creator_post(body, &self.context()) } fn editgroup_id_accept_post(&self, id: i64) -> Box + Send> { self.api().editgroup_id_accept_post(id, &self.context()) } fn editgroup_id_get(&self, id: i64) -> Box + Send> { self.api().editgroup_id_get(id, &self.context()) } fn editgroup_post(&self, body: models::Editgroup) -> Box + Send> { self.api().editgroup_post(body, &self.context()) } fn editor_username_changelog_get(&self, username: String) -> Box + Send> { self.api().editor_username_changelog_get(username, &self.context()) } fn editor_username_get(&self, username: String) -> Box + Send> { self.api().editor_username_get(username, &self.context()) } fn file_id_get(&self, id: String) -> Box + Send> { self.api().file_id_get(id, &self.context()) } fn file_lookup_get(&self, sha1: String) -> Box + Send> { self.api().file_lookup_get(sha1, &self.context()) } fn file_post(&self, body: models::FileEntity) -> Box + Send> { self.api().file_post(body, &self.context()) } fn release_id_get(&self, id: String) -> Box + Send> { self.api().release_id_get(id, &self.context()) } fn release_lookup_get(&self, doi: String) -> Box + Send> { self.api().release_lookup_get(doi, &self.context()) } fn release_post(&self, body: models::ReleaseEntity) -> Box + Send> { self.api().release_post(body, &self.context()) } fn work_id_get(&self, id: String) -> Box + Send> { self.api().work_id_get(id, &self.context()) } fn work_post(&self, body: models::WorkEntity) -> Box + Send> { self.api().work_post(body, &self.context()) } } #[cfg(feature = "client")] pub mod client; // Re-export Client as a top-level name #[cfg(feature = "client")] pub use self::client::Client; #[cfg(feature = "server")] pub mod server; // Re-export router() as a top-level name #[cfg(feature = "server")] pub use self::server::router; pub mod models;