aboutsummaryrefslogtreecommitdiffstats
path: root/rust/fatcat-api/src/lib.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-05-27 15:45:03 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-05-27 15:45:03 -0700
commitbcb9d2c6793b39b165caf9e63c4803d2a28e9876 (patch)
treeac8a1a50d7949a48b1c4f6fa5e443ab394cd7ace /rust/fatcat-api/src/lib.rs
parent19eb1641eece9f03ca193417cdf244efc1a9da8a (diff)
downloadfatcat-bcb9d2c6793b39b165caf9e63c4803d2a28e9876.tar.gz
fatcat-bcb9d2c6793b39b165caf9e63c4803d2a28e9876.zip
batch POST methods
Diffstat (limited to 'rust/fatcat-api/src/lib.rs')
-rw-r--r--rust/fatcat-api/src/lib.rs100
1 files changed, 100 insertions, 0 deletions
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
@@ -33,6 +33,18 @@ mod mimetypes;
pub use swagger::{ApiError, Context, ContextWrapper};
#[derive(Debug, PartialEq)]
+pub enum ContainerBatchPostResponse {
+ /// Created Entities
+ CreatedEntities(Vec<models::EntityEdit>),
+ /// Bad Request
+ BadRequest(models::ErrorResponse),
+ /// Not Found
+ NotFound(models::ErrorResponse),
+ /// Generic Error
+ GenericError(models::ErrorResponse),
+}
+
+#[derive(Debug, PartialEq)]
pub enum ContainerIdGetResponse {
/// Found Entity
FoundEntity(models::ContainerEntity),
@@ -69,6 +81,18 @@ pub enum ContainerPostResponse {
}
#[derive(Debug, PartialEq)]
+pub enum CreatorBatchPostResponse {
+ /// Created Entities
+ CreatedEntities(Vec<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),
@@ -159,6 +183,18 @@ pub enum EditorUsernameGetResponse {
}
#[derive(Debug, PartialEq)]
+pub enum FileBatchPostResponse {
+ /// Created Entities
+ CreatedEntities(Vec<models::EntityEdit>),
+ /// Bad Request
+ BadRequest(models::ErrorResponse),
+ /// Not Found
+ NotFound(models::ErrorResponse),
+ /// Generic Error
+ GenericError(models::ErrorResponse),
+}
+
+#[derive(Debug, PartialEq)]
pub enum FileIdGetResponse {
/// Found Entity
FoundEntity(models::FileEntity),
@@ -195,6 +231,18 @@ pub enum FilePostResponse {
}
#[derive(Debug, PartialEq)]
+pub enum ReleaseBatchPostResponse {
+ /// Created Entities
+ CreatedEntities(Vec<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),
@@ -231,6 +279,18 @@ pub enum ReleasePostResponse {
}
#[derive(Debug, PartialEq)]
+pub enum WorkBatchPostResponse {
+ /// Created Entities
+ CreatedEntities(Vec<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),
@@ -256,12 +316,16 @@ pub enum WorkPostResponse {
/// API
pub trait Api {
+ fn container_batch_post(&self, entity_list: &Vec<models::ContainerEntity>, context: &Context) -> Box<Future<Item = ContainerBatchPostResponse, Error = ApiError> + Send>;
+
fn container_id_get(&self, id: String, context: &Context) -> Box<Future<Item = ContainerIdGetResponse, Error = ApiError> + Send>;
fn container_lookup_get(&self, issnl: String, context: &Context) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send>;
fn container_post(&self, entity: models::ContainerEntity, context: &Context) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send>;
+ fn creator_batch_post(&self, entity_list: &Vec<models::CreatorEntity>, context: &Context) -> Box<Future<Item = CreatorBatchPostResponse, Error = ApiError> + Send>;
+
fn creator_id_get(&self, id: String, context: &Context) -> Box<Future<Item = CreatorIdGetResponse, Error = ApiError> + Send>;
fn creator_lookup_get(&self, orcid: String, context: &Context) -> Box<Future<Item = CreatorLookupGetResponse, Error = ApiError> + Send>;
@@ -278,18 +342,24 @@ pub trait Api {
fn editor_username_get(&self, username: String, context: &Context) -> Box<Future<Item = EditorUsernameGetResponse, Error = ApiError> + Send>;
+ fn file_batch_post(&self, entity_list: &Vec<models::FileEntity>, context: &Context) -> Box<Future<Item = FileBatchPostResponse, Error = ApiError> + Send>;
+
fn file_id_get(&self, id: String, context: &Context) -> Box<Future<Item = FileIdGetResponse, Error = ApiError> + Send>;
fn file_lookup_get(&self, sha1: String, context: &Context) -> Box<Future<Item = FileLookupGetResponse, Error = ApiError> + Send>;
fn file_post(&self, entity: models::FileEntity, context: &Context) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send>;
+ fn release_batch_post(&self, entity_list: &Vec<models::ReleaseEntity>, context: &Context) -> Box<Future<Item = ReleaseBatchPostResponse, Error = ApiError> + Send>;
+
fn release_id_get(&self, id: String, context: &Context) -> Box<Future<Item = ReleaseIdGetResponse, Error = ApiError> + Send>;
fn release_lookup_get(&self, doi: String, context: &Context) -> Box<Future<Item = ReleaseLookupGetResponse, Error = ApiError> + Send>;
fn release_post(&self, entity: models::ReleaseEntity, context: &Context) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send>;
+ fn work_batch_post(&self, entity_list: &Vec<models::WorkEntity>, context: &Context) -> Box<Future<Item = WorkBatchPostResponse, Error = ApiError> + Send>;
+
fn work_id_get(&self, id: String, context: &Context) -> Box<Future<Item = WorkIdGetResponse, Error = ApiError> + Send>;
fn work_post(&self, entity: models::WorkEntity, context: &Context) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send>;
@@ -297,12 +367,16 @@ pub trait Api {
/// API without a `Context`
pub trait ApiNoContext {
+ fn container_batch_post(&self, entity_list: &Vec<models::ContainerEntity>) -> Box<Future<Item = ContainerBatchPostResponse, Error = ApiError> + Send>;
+
fn container_id_get(&self, id: String) -> Box<Future<Item = ContainerIdGetResponse, Error = ApiError> + Send>;
fn container_lookup_get(&self, issnl: String) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send>;
fn container_post(&self, entity: models::ContainerEntity) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send>;
+ fn creator_batch_post(&self, entity_list: &Vec<models::CreatorEntity>) -> Box<Future<Item = CreatorBatchPostResponse, Error = ApiError> + Send>;
+
fn creator_id_get(&self, id: String) -> Box<Future<Item = CreatorIdGetResponse, Error = ApiError> + Send>;
fn creator_lookup_get(&self, orcid: String) -> Box<Future<Item = CreatorLookupGetResponse, Error = ApiError> + Send>;
@@ -319,18 +393,24 @@ pub trait ApiNoContext {
fn editor_username_get(&self, username: String) -> Box<Future<Item = EditorUsernameGetResponse, Error = ApiError> + Send>;
+ fn file_batch_post(&self, entity_list: &Vec<models::FileEntity>) -> Box<Future<Item = FileBatchPostResponse, Error = ApiError> + Send>;
+
fn file_id_get(&self, id: String) -> Box<Future<Item = FileIdGetResponse, Error = ApiError> + Send>;
fn file_lookup_get(&self, sha1: String) -> Box<Future<Item = FileLookupGetResponse, Error = ApiError> + Send>;
fn file_post(&self, entity: models::FileEntity) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send>;
+ fn release_batch_post(&self, entity_list: &Vec<models::ReleaseEntity>) -> Box<Future<Item = ReleaseBatchPostResponse, Error = ApiError> + Send>;
+
fn release_id_get(&self, id: String) -> Box<Future<Item = ReleaseIdGetResponse, Error = ApiError> + Send>;
fn release_lookup_get(&self, doi: String) -> Box<Future<Item = ReleaseLookupGetResponse, Error = ApiError> + Send>;
fn release_post(&self, entity: models::ReleaseEntity) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send>;
+ fn work_batch_post(&self, entity_list: &Vec<models::WorkEntity>) -> Box<Future<Item = WorkBatchPostResponse, Error = ApiError> + Send>;
+
fn work_id_get(&self, id: String) -> Box<Future<Item = WorkIdGetResponse, Error = ApiError> + Send>;
fn work_post(&self, entity: models::WorkEntity) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + 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<models::ContainerEntity>) -> Box<Future<Item = ContainerBatchPostResponse, Error = ApiError> + Send> {
+ self.api().container_batch_post(entity_list, &self.context())
+ }
+
fn container_id_get(&self, id: String) -> Box<Future<Item = ContainerIdGetResponse, Error = ApiError> + 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<models::CreatorEntity>) -> Box<Future<Item = CreatorBatchPostResponse, Error = ApiError> + Send> {
+ self.api().creator_batch_post(entity_list, &self.context())
+ }
+
fn creator_id_get(&self, id: String) -> Box<Future<Item = CreatorIdGetResponse, Error = ApiError> + 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<models::FileEntity>) -> Box<Future<Item = FileBatchPostResponse, Error = ApiError> + Send> {
+ self.api().file_batch_post(entity_list, &self.context())
+ }
+
fn file_id_get(&self, id: String) -> Box<Future<Item = FileIdGetResponse, Error = ApiError> + 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<models::ReleaseEntity>) -> Box<Future<Item = ReleaseBatchPostResponse, Error = ApiError> + Send> {
+ self.api().release_batch_post(entity_list, &self.context())
+ }
+
fn release_id_get(&self, id: String) -> Box<Future<Item = ReleaseIdGetResponse, Error = ApiError> + 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<models::WorkEntity>) -> Box<Future<Item = WorkBatchPostResponse, Error = ApiError> + Send> {
+ self.api().work_batch_post(entity_list, &self.context())
+ }
+
fn work_id_get(&self, id: String) -> Box<Future<Item = WorkIdGetResponse, Error = ApiError> + Send> {
self.api().work_id_get(id, &self.context())
}