From 5a7e60632e41c7f6b7ae0b7e3ab413209c88ea4b Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 24 Jul 2018 02:10:36 -0700 Subject: partial implementation of new API features --- rust/fatcat-api/src/client.rs | 16 ++++---- rust/fatcat-api/src/models.rs | 87 +++++++++++++++++++++++++++++++++++++------ rust/fatcat-api/src/server.rs | 14 ++++--- 3 files changed, 93 insertions(+), 24 deletions(-) (limited to 'rust/fatcat-api/src') 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(input: T, correct_scheme: Option<&'static str>) -> Result { 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, + #[serde(rename = "prev_revision")] + #[serde(skip_serializing_if = "Option::is_none")] + pub prev_revision: Option, + #[serde(rename = "redirect_ident")] #[serde(skip_serializing_if = "Option::is_none")] pub redirect_ident: Option, @@ -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, - #[serde(rename = "url")] + #[serde(rename = "urls")] #[serde(skip_serializing_if = "Option::is_none")] - pub url: Option, + pub urls: Option>, #[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, @@ -393,6 +398,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")] @@ -407,6 +427,10 @@ pub struct ReleaseContrib { #[serde(skip_serializing_if = "Option::is_none")] pub raw: Option, + #[serde(rename = "extra")] + #[serde(skip_serializing_if = "Option::is_none")] + pub extra: Option, + #[serde(rename = "role")] #[serde(skip_serializing_if = "Option::is_none")] pub role: Option, @@ -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>, + #[serde(rename = "refs")] #[serde(skip_serializing_if = "Option::is_none")] pub refs: Option>, @@ -454,6 +483,14 @@ pub struct ReleaseEntity { #[serde(skip_serializing_if = "Option::is_none")] pub volume: Option, + #[serde(rename = "pmcid")] + #[serde(skip_serializing_if = "Option::is_none")] + pub pmcid: Option, + + #[serde(rename = "pmid")] + #[serde(skip_serializing_if = "Option::is_none")] + pub pmid: Option, + #[serde(rename = "isbn13")] #[serde(skip_serializing_if = "Option::is_none")] pub isbn13: Option, @@ -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, @@ -539,6 +579,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, + + #[serde(rename = "content")] + #[serde(skip_serializing_if = "Option::is_none")] + pub content: Option, + + #[serde(rename = "mimetype")] + #[serde(skip_serializing_if = "Option::is_none")] + pub mimetype: Option, + + #[serde(rename = "lang")] + #[serde(skip_serializing_if = "Option::is_none")] + pub lang: Option, +} + +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")] @@ -549,9 +619,9 @@ pub struct ReleaseRef { #[serde(skip_serializing_if = "Option::is_none")] pub target_release_id: Option, - #[serde(rename = "raw")] + #[serde(rename = "extra")] #[serde(skip_serializing_if = "Option::is_none")] - pub raw: Option, + pub extra: Option, #[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, - #[serde(rename = "extra")] #[serde(skip_serializing_if = "Option::is_none")] pub extra: Option, @@ -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] } -- cgit v1.2.3