From bcb9d2c6793b39b165caf9e63c4803d2a28e9876 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Sun, 27 May 2018 15:45:03 -0700 Subject: batch POST methods --- rust/fatcat-api/src/lib.rs | 100 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) (limited to 'rust/fatcat-api/src/lib.rs') diff --git a/rust/fatcat-api/src/lib.rs b/rust/fatcat-api/src/lib.rs index dca1aa35..1a46fbeb 100644 --- a/rust/fatcat-api/src/lib.rs +++ b/rust/fatcat-api/src/lib.rs @@ -32,6 +32,18 @@ mod mimetypes; pub use swagger::{ApiError, Context, ContextWrapper}; +#[derive(Debug, PartialEq)] +pub enum ContainerBatchPostResponse { + /// Created Entities + CreatedEntities(Vec), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum ContainerIdGetResponse { /// Found Entity @@ -68,6 +80,18 @@ pub enum ContainerPostResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum CreatorBatchPostResponse { + /// Created Entities + CreatedEntities(Vec), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum CreatorIdGetResponse { /// Found Entity @@ -158,6 +182,18 @@ pub enum EditorUsernameGetResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum FileBatchPostResponse { + /// Created Entities + CreatedEntities(Vec), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum FileIdGetResponse { /// Found Entity @@ -194,6 +230,18 @@ pub enum FilePostResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum ReleaseBatchPostResponse { + /// Created Entities + CreatedEntities(Vec), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum ReleaseIdGetResponse { /// Found Entity @@ -230,6 +278,18 @@ pub enum ReleasePostResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum WorkBatchPostResponse { + /// Created Entities + CreatedEntities(Vec), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum WorkIdGetResponse { /// Found Entity @@ -256,12 +316,16 @@ pub enum WorkPostResponse { /// API pub trait Api { + fn container_batch_post(&self, entity_list: &Vec, context: &Context) -> Box + Send>; + fn container_id_get(&self, id: String, context: &Context) -> Box + Send>; fn container_lookup_get(&self, issnl: String, context: &Context) -> Box + Send>; fn container_post(&self, entity: models::ContainerEntity, context: &Context) -> Box + Send>; + fn creator_batch_post(&self, entity_list: &Vec, 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>; @@ -278,18 +342,24 @@ pub trait Api { fn editor_username_get(&self, username: String, context: &Context) -> Box + Send>; + fn file_batch_post(&self, entity_list: &Vec, 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, entity: models::FileEntity, context: &Context) -> Box + Send>; + fn release_batch_post(&self, entity_list: &Vec, 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, entity: models::ReleaseEntity, context: &Context) -> Box + Send>; + fn work_batch_post(&self, entity_list: &Vec, context: &Context) -> Box + Send>; + fn work_id_get(&self, id: String, context: &Context) -> Box + Send>; fn work_post(&self, entity: models::WorkEntity, context: &Context) -> Box + Send>; @@ -297,12 +367,16 @@ pub trait Api { /// API without a `Context` pub trait ApiNoContext { + fn container_batch_post(&self, entity_list: &Vec) -> Box + Send>; + fn container_id_get(&self, id: String) -> Box + Send>; fn container_lookup_get(&self, issnl: String) -> Box + Send>; fn container_post(&self, entity: models::ContainerEntity) -> Box + Send>; + fn creator_batch_post(&self, entity_list: &Vec) -> Box + Send>; + fn creator_id_get(&self, id: String) -> Box + Send>; fn creator_lookup_get(&self, orcid: String) -> Box + Send>; @@ -319,18 +393,24 @@ pub trait ApiNoContext { fn editor_username_get(&self, username: String) -> Box + Send>; + fn file_batch_post(&self, entity_list: &Vec) -> Box + Send>; + fn file_id_get(&self, id: String) -> Box + Send>; fn file_lookup_get(&self, sha1: String) -> Box + Send>; fn file_post(&self, entity: models::FileEntity) -> Box + Send>; + fn release_batch_post(&self, entity_list: &Vec) -> Box + Send>; + fn release_id_get(&self, id: String) -> Box + Send>; fn release_lookup_get(&self, doi: String) -> Box + Send>; fn release_post(&self, entity: models::ReleaseEntity) -> Box + Send>; + fn work_batch_post(&self, entity_list: &Vec) -> Box + Send>; + fn work_id_get(&self, id: String) -> Box + Send>; fn work_post(&self, entity: models::WorkEntity) -> Box + Send>; @@ -352,6 +432,10 @@ impl<'a, T: Api + Sized> ContextWrapperExt<'a> for T { } impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { + fn container_batch_post(&self, entity_list: &Vec) -> Box + Send> { + self.api().container_batch_post(entity_list, &self.context()) + } + fn container_id_get(&self, id: String) -> Box + Send> { self.api().container_id_get(id, &self.context()) } @@ -364,6 +448,10 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().container_post(entity, &self.context()) } + fn creator_batch_post(&self, entity_list: &Vec) -> Box + Send> { + self.api().creator_batch_post(entity_list, &self.context()) + } + fn creator_id_get(&self, id: String) -> Box + Send> { self.api().creator_id_get(id, &self.context()) } @@ -396,6 +484,10 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().editor_username_get(username, &self.context()) } + fn file_batch_post(&self, entity_list: &Vec) -> Box + Send> { + self.api().file_batch_post(entity_list, &self.context()) + } + fn file_id_get(&self, id: String) -> Box + Send> { self.api().file_id_get(id, &self.context()) } @@ -408,6 +500,10 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().file_post(entity, &self.context()) } + fn release_batch_post(&self, entity_list: &Vec) -> Box + Send> { + self.api().release_batch_post(entity_list, &self.context()) + } + fn release_id_get(&self, id: String) -> Box + Send> { self.api().release_id_get(id, &self.context()) } @@ -420,6 +516,10 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().release_post(entity, &self.context()) } + fn work_batch_post(&self, entity_list: &Vec) -> Box + Send> { + self.api().work_batch_post(entity_list, &self.context()) + } + fn work_id_get(&self, id: String) -> Box + Send> { self.api().work_id_get(id, &self.context()) } -- cgit v1.2.3