diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-05-26 17:08:21 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-05-26 17:08:21 -0700 |
commit | 55f8a495354d233f7a68128b2f3c21dbe7395427 (patch) | |
tree | e3afd04a58cc74abd9e15557d27d19ce47256f98 /rust/fatcat-api/src | |
parent | 82f8b4d838de3fb8eda5db9b23c5bc48ab281f9e (diff) | |
download | fatcat-55f8a495354d233f7a68128b2f3c21dbe7395427.tar.gz fatcat-55f8a495354d233f7a68128b2f3c21dbe7395427.zip |
tweak schema (api and sql)
Diffstat (limited to 'rust/fatcat-api/src')
-rw-r--r-- | rust/fatcat-api/src/client.rs | 6 | ||||
-rw-r--r-- | rust/fatcat-api/src/lib.rs | 8 | ||||
-rw-r--r-- | rust/fatcat-api/src/models.rs | 45 | ||||
-rw-r--r-- | rust/fatcat-api/src/server.rs | 12 |
4 files changed, 48 insertions, 23 deletions
diff --git a/rust/fatcat-api/src/client.rs b/rust/fatcat-api/src/client.rs index 517d9705..23f6dd21 100644 --- a/rust/fatcat-api/src/client.rs +++ b/rust/fatcat-api/src/client.rs @@ -221,11 +221,11 @@ impl Api for Client { Box::new(futures::done(result)) } - fn container_lookup_get(&self, param_issn: String, context: &Context) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send> { + fn container_lookup_get(&self, param_issnl: String, context: &Context) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send> { // Query parameters - let query_issn = format!("issn={issn}&", issn = param_issn.to_string()); + let query_issnl = format!("issnl={issnl}&", issnl = param_issnl.to_string()); - let url = format!("{}/v0/container/lookup?{issn}", self.base_path, issn = utf8_percent_encode(&query_issn, QUERY_ENCODE_SET)); + let url = format!("{}/v0/container/lookup?{issnl}", self.base_path, issnl = utf8_percent_encode(&query_issnl, QUERY_ENCODE_SET)); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Get, &url); diff --git a/rust/fatcat-api/src/lib.rs b/rust/fatcat-api/src/lib.rs index 94633e00..a21a0751 100644 --- a/rust/fatcat-api/src/lib.rs +++ b/rust/fatcat-api/src/lib.rs @@ -258,7 +258,7 @@ pub enum WorkPostResponse { pub trait Api { fn container_id_get(&self, id: String, context: &Context) -> Box<Future<Item = ContainerIdGetResponse, Error = ApiError> + Send>; - fn container_lookup_get(&self, issn: String, context: &Context) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send>; + fn container_lookup_get(&self, issnl: String, context: &Context) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send>; fn container_post(&self, body: models::ContainerEntity, context: &Context) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send>; @@ -299,7 +299,7 @@ pub trait Api { pub trait ApiNoContext { fn container_id_get(&self, id: String) -> Box<Future<Item = ContainerIdGetResponse, Error = ApiError> + Send>; - fn container_lookup_get(&self, issn: String) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send>; + fn container_lookup_get(&self, issnl: String) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send>; fn container_post(&self, body: models::ContainerEntity) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send>; @@ -356,8 +356,8 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().container_id_get(id, &self.context()) } - fn container_lookup_get(&self, issn: String) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send> { - self.api().container_lookup_get(issn, &self.context()) + fn container_lookup_get(&self, issnl: String) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send> { + self.api().container_lookup_get(issnl, &self.context()) } fn container_post(&self, body: models::ContainerEntity) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send> { diff --git a/rust/fatcat-api/src/models.rs b/rust/fatcat-api/src/models.rs index 68242058..b05c0fc1 100644 --- a/rust/fatcat-api/src/models.rs +++ b/rust/fatcat-api/src/models.rs @@ -94,9 +94,17 @@ impl ChangelogentriesInner { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct ContainerEntity { - #[serde(rename = "issn")] + #[serde(rename = "coden")] #[serde(skip_serializing_if = "Option::is_none")] - pub issn: Option<String>, + pub coden: Option<String>, + + #[serde(rename = "abbrev")] + #[serde(skip_serializing_if = "Option::is_none")] + pub abbrev: Option<String>, + + #[serde(rename = "issnl")] + #[serde(skip_serializing_if = "Option::is_none")] + pub issnl: Option<String>, #[serde(rename = "publisher")] #[serde(skip_serializing_if = "Option::is_none")] @@ -134,7 +142,9 @@ pub struct ContainerEntity { impl ContainerEntity { pub fn new(name: String) -> ContainerEntity { ContainerEntity { - issn: None, + coden: None, + abbrev: None, + issnl: None, publisher: None, name: name, state: None, @@ -153,8 +163,8 @@ pub struct CreatorEntity { #[serde(skip_serializing_if = "Option::is_none")] pub orcid: Option<String>, - #[serde(rename = "name")] - pub name: String, + #[serde(rename = "full_name")] + pub full_name: String, #[serde(rename = "extra")] #[serde(skip_serializing_if = "Option::is_none")] @@ -183,10 +193,10 @@ pub struct CreatorEntity { } impl CreatorEntity { - pub fn new(name: String) -> CreatorEntity { + pub fn new(full_name: String) -> CreatorEntity { CreatorEntity { orcid: None, - name: name, + full_name: full_name, extra: None, editgroup_id: None, redirect: None, @@ -337,6 +347,10 @@ pub struct FileEntity { #[serde(skip_serializing_if = "Option::is_none")] pub url: Option<String>, + #[serde(rename = "md5")] + #[serde(skip_serializing_if = "Option::is_none")] + pub md5: Option<String>, + #[serde(rename = "sha1")] #[serde(skip_serializing_if = "Option::is_none")] pub sha1: Option<String>, @@ -376,6 +390,7 @@ impl FileEntity { FileEntity { releases: None, url: None, + md5: None, sha1: None, size: None, extra: None, @@ -402,9 +417,9 @@ pub struct ReleaseContrib { #[serde(skip_serializing_if = "Option::is_none")] pub creator_stub: Option<String>, - #[serde(rename = "contrib_type")] + #[serde(rename = "role")] #[serde(skip_serializing_if = "Option::is_none")] - pub contrib_type: Option<String>, + pub role: Option<String>, } impl ReleaseContrib { @@ -413,7 +428,7 @@ impl ReleaseContrib { index: None, creator_id: None, creator_stub: None, - contrib_type: None, + role: None, } } } @@ -428,6 +443,10 @@ pub struct ReleaseEntity { #[serde(skip_serializing_if = "Option::is_none")] pub contribs: Option<Vec<models::ReleaseContrib>>, + #[serde(rename = "publisher")] + #[serde(skip_serializing_if = "Option::is_none")] + pub publisher: Option<String>, + #[serde(rename = "issue")] #[serde(skip_serializing_if = "Option::is_none")] pub issue: Option<String>, @@ -440,6 +459,10 @@ pub struct ReleaseEntity { #[serde(skip_serializing_if = "Option::is_none")] pub volume: Option<String>, + #[serde(rename = "isbn13")] + #[serde(skip_serializing_if = "Option::is_none")] + pub isbn13: Option<String>, + #[serde(rename = "doi")] #[serde(skip_serializing_if = "Option::is_none")] pub doi: Option<String>, @@ -493,9 +516,11 @@ impl ReleaseEntity { ReleaseEntity { refs: None, contribs: None, + publisher: None, issue: None, pages: None, volume: None, + isbn13: None, doi: None, date: None, release_type: None, diff --git a/rust/fatcat-api/src/server.rs b/rust/fatcat-api/src/server.rs index 95829602..ed012478 100644 --- a/rust/fatcat-api/src/server.rs +++ b/rust/fatcat-api/src/server.rs @@ -190,15 +190,15 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default(); - let param_issn = query_params - .get("issn") - .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter issn".to_string())))? + let param_issnl = query_params + .get("issnl") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter issnl".to_string())))? .first() - .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter issn was empty".to_string())))? + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter issnl was empty".to_string())))? .parse::<String>() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter issn - doesn't match schema: {}", e))))?; + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter issnl - doesn't match schema: {}", e))))?; - match api.container_lookup_get(param_issn, context).wait() { + match api.container_lookup_get(param_issnl, context).wait() { Ok(rsp) => match rsp { ContainerLookupGetResponse::FoundEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); |