diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-07-24 02:10:36 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-07-24 02:10:36 -0700 |
commit | 5a7e60632e41c7f6b7ae0b7e3ab413209c88ea4b (patch) | |
tree | a1710ea413f9a34ef6864dd4fd7501a5ed82fd1a /rust/fatcat-api/src | |
parent | 4720becd96ea298dfcfcdfb61a2fad7eba4ba670 (diff) | |
download | fatcat-5a7e60632e41c7f6b7ae0b7e3ab413209c88ea4b.tar.gz fatcat-5a7e60632e41c7f6b7ae0b7e3ab413209c88ea4b.zip |
partial implementation of new API features
Diffstat (limited to 'rust/fatcat-api/src')
-rw-r--r-- | rust/fatcat-api/src/client.rs | 16 | ||||
-rw-r--r-- | rust/fatcat-api/src/models.rs | 87 | ||||
-rw-r--r-- | rust/fatcat-api/src/server.rs | 14 |
3 files changed, 93 insertions, 24 deletions
diff --git a/rust/fatcat-api/src/client.rs b/rust/fatcat-api/src/client.rs index b785adab..2b6fd2a6 100644 --- a/rust/fatcat-api/src/client.rs +++ b/rust/fatcat-api/src/client.rs @@ -6,14 +6,14 @@ extern crate url; use self::hyper_openssl::openssl; use self::url::percent_encoding::{utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, QUERY_ENCODE_SET}; use futures; -use futures::{Future, Stream}; use futures::{future, stream}; +use futures::{Future, Stream}; use hyper; -use hyper::Url; use hyper::client::IntoUrl; use hyper::header::{ContentType, Headers}; use hyper::mime; use hyper::mime::{Attr, Mime, SubLevel, TopLevel, Value}; +use hyper::Url; use std::borrow::Cow; use std::error; use std::fmt; @@ -34,11 +34,13 @@ use swagger; use swagger::{ApiError, Context, XSpanId}; use models; -use {AcceptEditgroupResponse, Api, CreateContainerBatchResponse, CreateContainerResponse, CreateCreatorBatchResponse, CreateCreatorResponse, CreateEditgroupResponse, CreateFileBatchResponse, - CreateFileResponse, CreateReleaseBatchResponse, CreateReleaseResponse, CreateWorkBatchResponse, CreateWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerHistoryResponse, - GetContainerResponse, GetCreatorHistoryResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetEditgroupResponse, GetEditorChangelogResponse, GetEditorResponse, GetFileHistoryResponse, - GetFileResponse, GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseResponse, GetStatsResponse, GetWorkHistoryResponse, GetWorkReleasesResponse, GetWorkResponse, - LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse}; +use { + AcceptEditgroupResponse, Api, CreateContainerBatchResponse, CreateContainerResponse, CreateCreatorBatchResponse, CreateCreatorResponse, CreateEditgroupResponse, CreateFileBatchResponse, + CreateFileResponse, CreateReleaseBatchResponse, CreateReleaseResponse, CreateWorkBatchResponse, CreateWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerHistoryResponse, + GetContainerResponse, GetCreatorHistoryResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetEditgroupResponse, GetEditorChangelogResponse, GetEditorResponse, GetFileHistoryResponse, + GetFileResponse, GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseResponse, GetStatsResponse, GetWorkHistoryResponse, GetWorkReleasesResponse, GetWorkResponse, + LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, +}; /// Convert input into a base path, e.g. "http://example:123". Also checks the scheme as it goes. fn into_base_path<T: IntoUrl>(input: T, correct_scheme: Option<&'static str>) -> Result<String, ClientInitError> { diff --git a/rust/fatcat-api/src/models.rs b/rust/fatcat-api/src/models.rs index 4ecc180c..d798fe03 100644 --- a/rust/fatcat-api/src/models.rs +++ b/rust/fatcat-api/src/models.rs @@ -258,6 +258,10 @@ pub struct EntityEdit { #[serde(skip_serializing_if = "Option::is_none")] pub revision: Option<String>, + #[serde(rename = "prev_revision")] + #[serde(skip_serializing_if = "Option::is_none")] + pub prev_revision: Option<String>, + #[serde(rename = "redirect_ident")] #[serde(skip_serializing_if = "Option::is_none")] pub redirect_ident: Option<String>, @@ -276,6 +280,7 @@ impl EntityEdit { edit_id: edit_id, ident: ident, revision: None, + prev_revision: None, redirect_ident: None, editgroup_id: editgroup_id, extra: None, @@ -327,9 +332,9 @@ pub struct FileEntity { #[serde(skip_serializing_if = "Option::is_none")] pub mimetype: Option<String>, - #[serde(rename = "url")] + #[serde(rename = "urls")] #[serde(skip_serializing_if = "Option::is_none")] - pub url: Option<String>, + pub urls: Option<Vec<models::FileEntityUrls>>, #[serde(rename = "sha256")] #[serde(skip_serializing_if = "Option::is_none")] @@ -378,7 +383,7 @@ impl FileEntity { FileEntity { releases: None, mimetype: None, - url: None, + urls: None, sha256: None, md5: None, sha1: None, @@ -394,6 +399,21 @@ impl FileEntity { } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct FileEntityUrls { + #[serde(rename = "url")] + pub url: String, + + #[serde(rename = "rel")] + pub rel: String, +} + +impl FileEntityUrls { + pub fn new(url: String, rel: String) -> FileEntityUrls { + FileEntityUrls { url: url, rel: rel } + } +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct ReleaseContrib { #[serde(rename = "index")] #[serde(skip_serializing_if = "Option::is_none")] @@ -407,6 +427,10 @@ pub struct ReleaseContrib { #[serde(skip_serializing_if = "Option::is_none")] pub raw: Option<String>, + #[serde(rename = "extra")] + #[serde(skip_serializing_if = "Option::is_none")] + pub extra: Option<serde_json::Value>, + #[serde(rename = "role")] #[serde(skip_serializing_if = "Option::is_none")] pub role: Option<String>, @@ -418,6 +442,7 @@ impl ReleaseContrib { index: None, creator_id: None, raw: None, + extra: None, role: None, } } @@ -425,6 +450,10 @@ impl ReleaseContrib { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct ReleaseEntity { + #[serde(rename = "abstracts")] + #[serde(skip_serializing_if = "Option::is_none")] + pub abstracts: Option<Vec<models::ReleaseEntityAbstracts>>, + #[serde(rename = "refs")] #[serde(skip_serializing_if = "Option::is_none")] pub refs: Option<Vec<models::ReleaseRef>>, @@ -454,6 +483,14 @@ pub struct ReleaseEntity { #[serde(skip_serializing_if = "Option::is_none")] pub volume: Option<String>, + #[serde(rename = "pmcid")] + #[serde(skip_serializing_if = "Option::is_none")] + pub pmcid: Option<String>, + + #[serde(rename = "pmid")] + #[serde(skip_serializing_if = "Option::is_none")] + pub pmid: Option<String>, + #[serde(rename = "isbn13")] #[serde(skip_serializing_if = "Option::is_none")] pub isbn13: Option<String>, @@ -514,6 +551,7 @@ pub struct ReleaseEntity { impl ReleaseEntity { pub fn new(title: String) -> ReleaseEntity { ReleaseEntity { + abstracts: None, refs: None, contribs: None, language: None, @@ -521,6 +559,8 @@ impl ReleaseEntity { pages: None, issue: None, volume: None, + pmcid: None, + pmid: None, isbn13: None, doi: None, release_date: None, @@ -540,6 +580,36 @@ impl ReleaseEntity { } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct ReleaseEntityAbstracts { + #[serde(rename = "sha1")] + #[serde(skip_serializing_if = "Option::is_none")] + pub sha1: Option<String>, + + #[serde(rename = "content")] + #[serde(skip_serializing_if = "Option::is_none")] + pub content: Option<String>, + + #[serde(rename = "mimetype")] + #[serde(skip_serializing_if = "Option::is_none")] + pub mimetype: Option<String>, + + #[serde(rename = "lang")] + #[serde(skip_serializing_if = "Option::is_none")] + pub lang: Option<String>, +} + +impl ReleaseEntityAbstracts { + pub fn new() -> ReleaseEntityAbstracts { + ReleaseEntityAbstracts { + sha1: None, + content: None, + mimetype: None, + lang: None, + } + } +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct ReleaseRef { #[serde(rename = "index")] #[serde(skip_serializing_if = "Option::is_none")] @@ -549,9 +619,9 @@ pub struct ReleaseRef { #[serde(skip_serializing_if = "Option::is_none")] pub target_release_id: Option<String>, - #[serde(rename = "raw")] + #[serde(rename = "extra")] #[serde(skip_serializing_if = "Option::is_none")] - pub raw: Option<String>, + pub extra: Option<serde_json::Value>, #[serde(rename = "key")] #[serde(skip_serializing_if = "Option::is_none")] @@ -579,7 +649,7 @@ impl ReleaseRef { ReleaseRef { index: None, target_release_id: None, - raw: None, + extra: None, key: None, year: None, container_title: None, @@ -616,10 +686,6 @@ impl Success { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct WorkEntity { - #[serde(rename = "work_type")] - #[serde(skip_serializing_if = "Option::is_none")] - pub work_type: Option<String>, - #[serde(rename = "extra")] #[serde(skip_serializing_if = "Option::is_none")] pub extra: Option<serde_json::Value>, @@ -649,7 +715,6 @@ pub struct WorkEntity { impl WorkEntity { pub fn new() -> WorkEntity { WorkEntity { - work_type: None, extra: None, editgroup_id: None, redirect: None, diff --git a/rust/fatcat-api/src/server.rs b/rust/fatcat-api/src/server.rs index e4e0bc1d..e94fd5ef 100644 --- a/rust/fatcat-api/src/server.rs +++ b/rust/fatcat-api/src/server.rs @@ -12,8 +12,8 @@ use self::iron::url::percent_encoding::percent_decode; use self::iron::{modifiers, status, BeforeMiddleware}; use self::router::Router; use self::urlencoded::UrlEncodedQuery; -use futures::Future; use futures::future; +use futures::Future; use futures::{stream, Stream}; use hyper; use hyper::header::{ContentType, Headers}; @@ -36,11 +36,13 @@ use swagger::{ApiError, Context, XSpanId}; #[allow(unused_imports)] use models; -use {AcceptEditgroupResponse, Api, CreateContainerBatchResponse, CreateContainerResponse, CreateCreatorBatchResponse, CreateCreatorResponse, CreateEditgroupResponse, CreateFileBatchResponse, - CreateFileResponse, CreateReleaseBatchResponse, CreateReleaseResponse, CreateWorkBatchResponse, CreateWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerHistoryResponse, - GetContainerResponse, GetCreatorHistoryResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetEditgroupResponse, GetEditorChangelogResponse, GetEditorResponse, GetFileHistoryResponse, - GetFileResponse, GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseResponse, GetStatsResponse, GetWorkHistoryResponse, GetWorkReleasesResponse, GetWorkResponse, - LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse}; +use { + AcceptEditgroupResponse, Api, CreateContainerBatchResponse, CreateContainerResponse, CreateCreatorBatchResponse, CreateCreatorResponse, CreateEditgroupResponse, CreateFileBatchResponse, + CreateFileResponse, CreateReleaseBatchResponse, CreateReleaseResponse, CreateWorkBatchResponse, CreateWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerHistoryResponse, + GetContainerResponse, GetCreatorHistoryResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetEditgroupResponse, GetEditorChangelogResponse, GetEditorResponse, GetFileHistoryResponse, + GetFileResponse, GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseResponse, GetStatsResponse, GetWorkHistoryResponse, GetWorkReleasesResponse, GetWorkResponse, + LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, +}; header! { (Warning, "Warning") => [String] } |