aboutsummaryrefslogtreecommitdiffstats
path: root/rust/fatcat-openapi
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2021-10-12 16:45:07 -0700
committerBryan Newbold <bnewbold@robocracy.org>2021-10-13 16:21:30 -0700
commit3a45076685471b969596ef5b58823ce8074224c6 (patch)
tree9de4a3606c75318958f363a7c7e8a568ad2dc513 /rust/fatcat-openapi
parentd9ff4bc8fe0a6daa39061fea7eb1830fd7b445bf (diff)
downloadfatcat-3a45076685471b969596ef5b58823ce8074224c6.tar.gz
fatcat-3a45076685471b969596ef5b58823ce8074224c6.zip
rust codegen for v0.4
Diffstat (limited to 'rust/fatcat-openapi')
-rw-r--r--rust/fatcat-openapi/README.md7
-rw-r--r--rust/fatcat-openapi/examples/client.rs20
-rw-r--r--rust/fatcat-openapi/examples/server_lib/server.rs24
-rw-r--r--rust/fatcat-openapi/src/client.rs84
-rw-r--r--rust/fatcat-openapi/src/lib.rs55
-rw-r--r--rust/fatcat-openapi/src/mimetypes.rs18
-rw-r--r--rust/fatcat-openapi/src/models.rs31
-rw-r--r--rust/fatcat-openapi/src/server.rs93
8 files changed, 307 insertions, 25 deletions
diff --git a/rust/fatcat-openapi/README.md b/rust/fatcat-openapi/README.md
index 78d95fbf..327fe3a8 100644
--- a/rust/fatcat-openapi/README.md
+++ b/rust/fatcat-openapi/README.md
@@ -12,8 +12,8 @@ To see how to make this your own, look here:
[README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md)
-- API version: 0.3.3
-- Build date: 2021-04-12T17:36:30.927Z
+- API version: 0.4.0
+- Build date: 2021-10-12T23:51:46.767Z
For more information, please visit [https://fatcat.wiki](https://fatcat.wiki)
This autogenerated project defines an API crate `fatcat` which contains:
@@ -95,6 +95,7 @@ cargo run --example client UpdateEditgroup
cargo run --example client GetEditor
cargo run --example client GetEditorAnnotations
cargo run --example client GetEditorEditgroups
+cargo run --example client LookupEditor
cargo run --example client UpdateEditor
cargo run --example client CreateFile
cargo run --example client CreateFileAutoBatch
@@ -171,7 +172,7 @@ The server example is designed to form the basis for implementing your own serve
* Set up a new Rust project, e.g., with `cargo init --bin`.
* Insert `fatcat` into the `members` array under [workspace] in the root `Cargo.toml`, e.g., `members = [ "fatcat" ]`.
-* Add `fatcat = {version = "0.3.3", path = "fatcat"}` under `[dependencies]` in the root `Cargo.toml`.
+* Add `fatcat = {version = "0.4.0", path = "fatcat"}` under `[dependencies]` in the root `Cargo.toml`.
* Copy the `[dependencies]` and `[dev-dependencies]` from `fatcat/Cargo.toml` into the root `Cargo.toml`'s `[dependencies]` section.
* Copy all of the `[dev-dependencies]`, but only the `[dependencies]` that are required by the example server. These should be clearly indicated by comments.
* Remove `"optional = true"` from each of these lines if present.
diff --git a/rust/fatcat-openapi/examples/client.rs b/rust/fatcat-openapi/examples/client.rs
index eaaf26a6..b919d174 100644
--- a/rust/fatcat-openapi/examples/client.rs
+++ b/rust/fatcat-openapi/examples/client.rs
@@ -23,9 +23,9 @@ use fatcat_openapi::{
GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetFilesetEditResponse, GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse,
GetReleaseEditResponse, GetReleaseFilesResponse, GetReleaseFilesetsResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse,
GetReleaseWebcapturesResponse, GetWebcaptureEditResponse, GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse, GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse,
- GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse,
- LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse,
- UpdateWebcaptureResponse, UpdateWorkResponse,
+ GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupEditorResponse,
+ LookupFileResponse, LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse,
+ UpdateReleaseResponse, UpdateWebcaptureResponse, UpdateWorkResponse,
};
#[allow(unused_imports)]
use futures::{future, stream, Future, Stream};
@@ -64,6 +64,7 @@ fn main() {
"GetEditor",
"GetEditorAnnotations",
"GetEditorEditgroups",
+ "LookupEditor",
"DeleteFile",
"DeleteFileEdit",
"GetFile",
@@ -212,6 +213,9 @@ fn main() {
let result = client
.lookup_container(
Some("issnl_example".to_string()),
+ Some("issne_example".to_string()),
+ Some("issnp_example".to_string()),
+ Some("issn_example".to_string()),
Some("wikidata_qid_example".to_string()),
Some("expand_example".to_string()),
Some("hide_example".to_string()),
@@ -349,6 +353,11 @@ fn main() {
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
}
+ Some("LookupEditor") => {
+ let result = client.lookup_editor(Some("username_example".to_string())).wait();
+ println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
+ }
+
// Disabled because there's no example.
// Some("UpdateEditor") => {
// let result = client.update_editor("editor_id_example".to_string(), ???).wait();
@@ -561,6 +570,7 @@ fn main() {
Some("doaj_example".to_string()),
Some("dblp_example".to_string()),
Some("oai_example".to_string()),
+ Some("hdl_example".to_string()),
Some("expand_example".to_string()),
Some("hide_example".to_string()),
)
@@ -690,6 +700,8 @@ fn main() {
// let result = client.update_work("editgroup_id_example".to_string(), "ident_example".to_string(), ???).wait();
// println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
// },
- _ => panic!("Invalid operation provided"),
+ _ => {
+ panic!("Invalid operation provided")
+ }
}
}
diff --git a/rust/fatcat-openapi/examples/server_lib/server.rs b/rust/fatcat-openapi/examples/server_lib/server.rs
index 56b82cc5..2aa38fd8 100644
--- a/rust/fatcat-openapi/examples/server_lib/server.rs
+++ b/rust/fatcat-openapi/examples/server_lib/server.rs
@@ -22,9 +22,9 @@ use fatcat_openapi::{
GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetFilesetEditResponse, GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse,
GetReleaseEditResponse, GetReleaseFilesResponse, GetReleaseFilesetsResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse,
GetReleaseWebcapturesResponse, GetWebcaptureEditResponse, GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse, GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse,
- GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse,
- LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse,
- UpdateWebcaptureResponse, UpdateWorkResponse,
+ GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupEditorResponse,
+ LookupFileResponse, LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse,
+ UpdateReleaseResponse, UpdateWebcaptureResponse, UpdateWorkResponse,
};
#[derive(Copy, Clone)]
@@ -159,6 +159,9 @@ impl Api for Server {
fn lookup_container(
&self,
issnl: Option<String>,
+ issne: Option<String>,
+ issnp: Option<String>,
+ issn: Option<String>,
wikidata_qid: Option<String>,
expand: Option<String>,
hide: Option<String>,
@@ -166,8 +169,11 @@ impl Api for Server {
) -> Box<Future<Item = LookupContainerResponse, Error = ApiError> + Send> {
let context = context.clone();
println!(
- "lookup_container({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}",
+ "lookup_container({:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}",
issnl,
+ issne,
+ issnp,
+ issn,
wikidata_qid,
expand,
hide,
@@ -444,6 +450,12 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
+ fn lookup_editor(&self, username: Option<String>, context: &Context) -> Box<Future<Item = LookupEditorResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ println!("lookup_editor({:?}) - X-Span-ID: {:?}", username, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ Box::new(futures::failed("Generic failure".into()))
+ }
+
fn update_editor(&self, editor_id: String, editor: models::Editor, context: &Context) -> Box<Future<Item = UpdateEditorResponse, Error = ApiError> + Send> {
let context = context.clone();
println!(
@@ -819,13 +831,14 @@ impl Api for Server {
doaj: Option<String>,
dblp: Option<String>,
oai: Option<String>,
+ hdl: Option<String>,
expand: Option<String>,
hide: Option<String>,
context: &Context,
) -> Box<Future<Item = LookupReleaseResponse, Error = ApiError> + Send> {
let context = context.clone();
println!(
- "lookup_release({:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}",
+ "lookup_release({:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}",
doi,
wikidata_qid,
isbn13,
@@ -839,6 +852,7 @@ impl Api for Server {
doaj,
dblp,
oai,
+ hdl,
expand,
hide,
context.x_span_id.unwrap_or(String::from("<none>")).clone()
diff --git a/rust/fatcat-openapi/src/client.rs b/rust/fatcat-openapi/src/client.rs
index fdb03405..85cec698 100644
--- a/rust/fatcat-openapi/src/client.rs
+++ b/rust/fatcat-openapi/src/client.rs
@@ -46,8 +46,9 @@ use crate::{
GetFilesetEditResponse, GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse, GetReleaseEditResponse, GetReleaseFilesResponse,
GetReleaseFilesetsResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetReleaseWebcapturesResponse, GetWebcaptureEditResponse,
GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse, GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse, GetWorkHistoryResponse, GetWorkRedirectsResponse,
- GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, UpdateContainerResponse,
- UpdateCreatorResponse, UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, UpdateWebcaptureResponse, UpdateWorkResponse,
+ GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupEditorResponse, LookupFileResponse, LookupReleaseResponse,
+ UpdateContainerResponse, UpdateCreatorResponse, UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, UpdateWebcaptureResponse,
+ UpdateWorkResponse,
};
/// Convert input into a base path, e.g. "http://example:123". Also checks the scheme as it goes.
@@ -1245,6 +1246,9 @@ impl Api for Client {
fn lookup_container(
&self,
param_issnl: Option<String>,
+ param_issne: Option<String>,
+ param_issnp: Option<String>,
+ param_issn: Option<String>,
param_wikidata_qid: Option<String>,
param_expand: Option<String>,
param_hide: Option<String>,
@@ -1252,14 +1256,20 @@ impl Api for Client {
) -> Box<Future<Item = LookupContainerResponse, Error = ApiError> + Send> {
// Query parameters
let query_issnl = param_issnl.map_or_else(String::new, |query| format!("issnl={issnl}&", issnl = query.to_string()));
+ let query_issne = param_issne.map_or_else(String::new, |query| format!("issne={issne}&", issne = query.to_string()));
+ let query_issnp = param_issnp.map_or_else(String::new, |query| format!("issnp={issnp}&", issnp = query.to_string()));
+ let query_issn = param_issn.map_or_else(String::new, |query| format!("issn={issn}&", issn = query.to_string()));
let query_wikidata_qid = param_wikidata_qid.map_or_else(String::new, |query| format!("wikidata_qid={wikidata_qid}&", wikidata_qid = query.to_string()));
let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string()));
let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string()));
let url = format!(
- "{}/v0/container/lookup?{issnl}{wikidata_qid}{expand}{hide}",
+ "{}/v0/container/lookup?{issnl}{issne}{issnp}{issn}{wikidata_qid}{expand}{hide}",
self.base_path,
issnl = utf8_percent_encode(&query_issnl, QUERY_ENCODE_SET),
+ issne = utf8_percent_encode(&query_issne, QUERY_ENCODE_SET),
+ issnp = utf8_percent_encode(&query_issnp, QUERY_ENCODE_SET),
+ issn = utf8_percent_encode(&query_issn, QUERY_ENCODE_SET),
wikidata_qid = utf8_percent_encode(&query_wikidata_qid, QUERY_ENCODE_SET),
expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET),
hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET)
@@ -3215,6 +3225,69 @@ impl Api for Client {
Box::new(futures::done(result))
}
+ fn lookup_editor(&self, param_username: Option<String>, context: &Context) -> Box<Future<Item = LookupEditorResponse, Error = ApiError> + Send> {
+ // Query parameters
+ let query_username = param_username.map_or_else(String::new, |query| format!("username={username}&", username = query.to_string()));
+
+ let url = format!("{}/v0/editor/lookup?{username}", self.base_path, username = utf8_percent_encode(&query_username, QUERY_ENCODE_SET));
+
+ let hyper_client = (self.hyper_client)();
+ let request = hyper_client.request(hyper::method::Method::Get, &url);
+ let mut custom_headers = hyper::header::Headers::new();
+
+ context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
+
+ let request = request.headers(custom_headers);
+
+ // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
+ fn parse_response(mut response: hyper::client::response::Response) -> Result<LookupEditorResponse, ApiError> {
+ match response.status.to_u16() {
+ 200 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Editor>(&buf)?;
+
+ Ok(LookupEditorResponse::Found(body))
+ }
+ 400 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(LookupEditorResponse::BadRequest(body))
+ }
+ 404 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(LookupEditorResponse::NotFound(body))
+ }
+ 500 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(LookupEditorResponse::GenericError(body))
+ }
+ code => {
+ let mut buf = [0; 100];
+ let debug_body = match response.read(&mut buf) {
+ Ok(len) => match str::from_utf8(&buf[..len]) {
+ Ok(body) => Cow::from(body),
+ Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ };
+ Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
+ }
+ }
+ }
+
+ let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ Box::new(futures::done(result))
+ }
+
fn update_editor(&self, param_editor_id: String, param_editor: models::Editor, context: &Context) -> Box<Future<Item = UpdateEditorResponse, Error = ApiError> + Send> {
let url = format!(
"{}/v0/editor/{editor_id}",
@@ -5880,6 +5953,7 @@ impl Api for Client {
param_doaj: Option<String>,
param_dblp: Option<String>,
param_oai: Option<String>,
+ param_hdl: Option<String>,
param_expand: Option<String>,
param_hide: Option<String>,
context: &Context,
@@ -5898,11 +5972,12 @@ impl Api for Client {
let query_doaj = param_doaj.map_or_else(String::new, |query| format!("doaj={doaj}&", doaj = query.to_string()));
let query_dblp = param_dblp.map_or_else(String::new, |query| format!("dblp={dblp}&", dblp = query.to_string()));
let query_oai = param_oai.map_or_else(String::new, |query| format!("oai={oai}&", oai = query.to_string()));
+ let query_hdl = param_hdl.map_or_else(String::new, |query| format!("hdl={hdl}&", hdl = query.to_string()));
let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string()));
let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string()));
let url = format!(
- "{}/v0/release/lookup?{doi}{wikidata_qid}{isbn13}{pmid}{pmcid}{core}{arxiv}{jstor}{ark}{mag}{doaj}{dblp}{oai}{expand}{hide}",
+ "{}/v0/release/lookup?{doi}{wikidata_qid}{isbn13}{pmid}{pmcid}{core}{arxiv}{jstor}{ark}{mag}{doaj}{dblp}{oai}{hdl}{expand}{hide}",
self.base_path,
doi = utf8_percent_encode(&query_doi, QUERY_ENCODE_SET),
wikidata_qid = utf8_percent_encode(&query_wikidata_qid, QUERY_ENCODE_SET),
@@ -5917,6 +5992,7 @@ impl Api for Client {
doaj = utf8_percent_encode(&query_doaj, QUERY_ENCODE_SET),
dblp = utf8_percent_encode(&query_dblp, QUERY_ENCODE_SET),
oai = utf8_percent_encode(&query_oai, QUERY_ENCODE_SET),
+ hdl = utf8_percent_encode(&query_hdl, QUERY_ENCODE_SET),
expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET),
hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET)
);
diff --git a/rust/fatcat-openapi/src/lib.rs b/rust/fatcat-openapi/src/lib.rs
index 4fe878e1..686cd84e 100644
--- a/rust/fatcat-openapi/src/lib.rs
+++ b/rust/fatcat-openapi/src/lib.rs
@@ -563,6 +563,18 @@ pub enum GetEditorEditgroupsResponse {
}
#[derive(Debug, PartialEq)]
+pub enum LookupEditorResponse {
+ /// Found
+ Found(models::Editor),
+ /// Bad Request
+ BadRequest(models::ErrorResponse),
+ /// Not Found
+ NotFound(models::ErrorResponse),
+ /// Generic Error
+ GenericError(models::ErrorResponse),
+}
+
+#[derive(Debug, PartialEq)]
pub enum UpdateEditorResponse {
/// Updated Editor
UpdatedEditor(models::Editor),
@@ -1383,6 +1395,9 @@ pub trait Api {
fn lookup_container(
&self,
issnl: Option<String>,
+ issne: Option<String>,
+ issnp: Option<String>,
+ issn: Option<String>,
wikidata_qid: Option<String>,
expand: Option<String>,
hide: Option<String>,
@@ -1469,6 +1484,8 @@ pub trait Api {
context: &Context,
) -> Box<dyn Future<Item = GetEditorEditgroupsResponse, Error = ApiError> + Send>;
+ fn lookup_editor(&self, username: Option<String>, context: &Context) -> Box<dyn Future<Item = LookupEditorResponse, Error = ApiError> + Send>;
+
fn update_editor(&self, editor_id: String, editor: models::Editor, context: &Context) -> Box<dyn Future<Item = UpdateEditorResponse, Error = ApiError> + Send>;
fn create_file(&self, editgroup_id: String, entity: models::FileEntity, context: &Context) -> Box<dyn Future<Item = CreateFileResponse, Error = ApiError> + Send>;
@@ -1560,6 +1577,7 @@ pub trait Api {
doaj: Option<String>,
dblp: Option<String>,
oai: Option<String>,
+ hdl: Option<String>,
expand: Option<String>,
hide: Option<String>,
context: &Context,
@@ -1649,6 +1667,9 @@ pub trait ApiNoContext {
fn lookup_container(
&self,
issnl: Option<String>,
+ issne: Option<String>,
+ issnp: Option<String>,
+ issn: Option<String>,
wikidata_qid: Option<String>,
expand: Option<String>,
hide: Option<String>,
@@ -1724,6 +1745,8 @@ pub trait ApiNoContext {
since: Option<chrono::DateTime<chrono::Utc>>,
) -> Box<dyn Future<Item = GetEditorEditgroupsResponse, Error = ApiError> + Send>;
+ fn lookup_editor(&self, username: Option<String>) -> Box<dyn Future<Item = LookupEditorResponse, Error = ApiError> + Send>;
+
fn update_editor(&self, editor_id: String, editor: models::Editor) -> Box<dyn Future<Item = UpdateEditorResponse, Error = ApiError> + Send>;
fn create_file(&self, editgroup_id: String, entity: models::FileEntity) -> Box<dyn Future<Item = CreateFileResponse, Error = ApiError> + Send>;
@@ -1814,6 +1837,7 @@ pub trait ApiNoContext {
doaj: Option<String>,
dblp: Option<String>,
oai: Option<String>,
+ hdl: Option<String>,
expand: Option<String>,
hide: Option<String>,
) -> Box<dyn Future<Item = LookupReleaseResponse, Error = ApiError> + Send>;
@@ -1938,11 +1962,14 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
fn lookup_container(
&self,
issnl: Option<String>,
+ issne: Option<String>,
+ issnp: Option<String>,
+ issn: Option<String>,
wikidata_qid: Option<String>,
expand: Option<String>,
hide: Option<String>,
) -> Box<dyn Future<Item = LookupContainerResponse, Error = ApiError> + Send> {
- self.api().lookup_container(issnl, wikidata_qid, expand, hide, &self.context())
+ self.api().lookup_container(issnl, issne, issnp, issn, wikidata_qid, expand, hide, &self.context())
}
fn update_container(&self, editgroup_id: String, ident: String, entity: models::ContainerEntity) -> Box<dyn Future<Item = UpdateContainerResponse, Error = ApiError> + Send> {
@@ -2061,6 +2088,10 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
self.api().get_editor_editgroups(editor_id, limit, before, since, &self.context())
}
+ fn lookup_editor(&self, username: Option<String>) -> Box<dyn Future<Item = LookupEditorResponse, Error = ApiError> + Send> {
+ self.api().lookup_editor(username, &self.context())
+ }
+
fn update_editor(&self, editor_id: String, editor: models::Editor) -> Box<dyn Future<Item = UpdateEditorResponse, Error = ApiError> + Send> {
self.api().update_editor(editor_id, editor, &self.context())
}
@@ -2219,11 +2250,29 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
doaj: Option<String>,
dblp: Option<String>,
oai: Option<String>,
+ hdl: Option<String>,
expand: Option<String>,
hide: Option<String>,
) -> Box<dyn Future<Item = LookupReleaseResponse, Error = ApiError> + Send> {
- self.api()
- .lookup_release(doi, wikidata_qid, isbn13, pmid, pmcid, core, arxiv, jstor, ark, mag, doaj, dblp, oai, expand, hide, &self.context())
+ self.api().lookup_release(
+ doi,
+ wikidata_qid,
+ isbn13,
+ pmid,
+ pmcid,
+ core,
+ arxiv,
+ jstor,
+ ark,
+ mag,
+ doaj,
+ dblp,
+ oai,
+ hdl,
+ expand,
+ hide,
+ &self.context(),
+ )
}
fn update_release(&self, editgroup_id: String, ident: String, entity: models::ReleaseEntity) -> Box<dyn Future<Item = UpdateReleaseResponse, Error = ApiError> + Send> {
diff --git a/rust/fatcat-openapi/src/mimetypes.rs b/rust/fatcat-openapi/src/mimetypes.rs
index 13c4ccbe..3db27ab3 100644
--- a/rust/fatcat-openapi/src/mimetypes.rs
+++ b/rust/fatcat-openapi/src/mimetypes.rs
@@ -760,6 +760,22 @@ pub mod responses {
lazy_static! {
pub static ref GET_EDITOR_EDITGROUPS_GENERIC_ERROR: Mime = mime!(Application / Json);
}
+ // Create Mime objects for the response content types for LookupEditor
+ lazy_static! {
+ pub static ref LOOKUP_EDITOR_FOUND: Mime = mime!(Application / Json);
+ }
+ // Create Mime objects for the response content types for LookupEditor
+ lazy_static! {
+ pub static ref LOOKUP_EDITOR_BAD_REQUEST: Mime = mime!(Application / Json);
+ }
+ // Create Mime objects for the response content types for LookupEditor
+ lazy_static! {
+ pub static ref LOOKUP_EDITOR_NOT_FOUND: Mime = mime!(Application / Json);
+ }
+ // Create Mime objects for the response content types for LookupEditor
+ lazy_static! {
+ pub static ref LOOKUP_EDITOR_GENERIC_ERROR: Mime = mime!(Application / Json);
+ }
// Create Mime objects for the response content types for UpdateEditor
lazy_static! {
pub static ref UPDATE_EDITOR_UPDATED_EDITOR: Mime = mime!(Application / Json);
@@ -1880,7 +1896,6 @@ pub mod responses {
lazy_static! {
pub static ref UPDATE_WORK_GENERIC_ERROR: Mime = mime!(Application / Json);
}
-
}
pub mod requests {
@@ -1989,5 +2004,4 @@ pub mod requests {
lazy_static! {
pub static ref UPDATE_WORK: Mime = mime!(Application / Json);
}
-
}
diff --git a/rust/fatcat-openapi/src/models.rs b/rust/fatcat-openapi/src/models.rs
index 965caacf..ca203c61 100644
--- a/rust/fatcat-openapi/src/models.rs
+++ b/rust/fatcat-openapi/src/models.rs
@@ -120,6 +120,16 @@ pub struct ContainerEntity {
#[serde(skip_serializing_if = "Option::is_none")]
pub wikidata_qid: Option<String>,
+ /// Print ISSN number (ISSN-P). Should be valid and registered with issn.org
+ #[serde(rename = "issnp")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub issnp: Option<String>,
+
+ /// Electronic ISSN number (ISSN-E). Should be valid and registered with issn.org
+ #[serde(rename = "issne")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub issne: Option<String>,
+
/// Linking ISSN number (ISSN-L). Should be valid and registered with issn.org
#[serde(rename = "issnl")]
#[serde(skip_serializing_if = "Option::is_none")]
@@ -130,6 +140,11 @@ pub struct ContainerEntity {
#[serde(skip_serializing_if = "Option::is_none")]
pub publisher: Option<String>,
+ /// Whether the container is active, discontinued, etc
+ #[serde(rename = "publication_status")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub publication_status: Option<String>,
+
/// Type of container, eg 'journal' or 'proceedings'. See Guide for list of valid types.
#[serde(rename = "container_type")]
#[serde(skip_serializing_if = "Option::is_none")]
@@ -175,8 +190,11 @@ impl ContainerEntity {
pub fn new() -> ContainerEntity {
ContainerEntity {
wikidata_qid: None,
+ issnp: None,
+ issne: None,
issnl: None,
publisher: None,
+ publication_status: None,
container_type: None,
name: None,
edit_extra: None,
@@ -818,7 +836,11 @@ pub struct FilesetFile {
#[serde(skip_serializing_if = "Option::is_none")]
pub sha256: Option<String>,
- /// Free-form additional metadata about this specific file in the set. Eg, `mimetype`. See guide for nomative (but unenforced) schema fields.
+ #[serde(rename = "mimetype")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub mimetype: Option<String>,
+
+ /// Free-form additional metadata about this specific file in the set. Eg, `original_url`. See guide for nomative (but unenforced) schema fields.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extra: Option<serde_json::Value>,
@@ -832,6 +854,7 @@ impl FilesetFile {
md5: None,
sha1: None,
sha256: None,
+ mimetype: None,
extra: None,
}
}
@@ -1245,6 +1268,11 @@ pub struct ReleaseExtIds {
#[serde(rename = "oai")]
#[serde(skip_serializing_if = "Option::is_none")]
pub oai: Option<String>,
+
+ /// Handle identifier. Do not put DOIs in this field
+ #[serde(rename = "hdl")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub hdl: Option<String>,
}
impl ReleaseExtIds {
@@ -1263,6 +1291,7 @@ impl ReleaseExtIds {
doaj: None,
dblp: None,
oai: None,
+ hdl: None,
}
}
}
diff --git a/rust/fatcat-openapi/src/server.rs b/rust/fatcat-openapi/src/server.rs
index 59e83124..c328692f 100644
--- a/rust/fatcat-openapi/src/server.rs
+++ b/rust/fatcat-openapi/src/server.rs
@@ -48,8 +48,9 @@ use crate::{
GetFilesetEditResponse, GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse, GetReleaseEditResponse, GetReleaseFilesResponse,
GetReleaseFilesetsResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetReleaseWebcapturesResponse, GetWebcaptureEditResponse,
GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse, GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse, GetWorkHistoryResponse, GetWorkRedirectsResponse,
- GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, UpdateContainerResponse,
- UpdateCreatorResponse, UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, UpdateWebcaptureResponse, UpdateWorkResponse,
+ GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupEditorResponse, LookupFileResponse, LookupReleaseResponse,
+ UpdateContainerResponse, UpdateCreatorResponse, UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, UpdateWebcaptureResponse,
+ UpdateWorkResponse,
};
header! { (Warning, "Warning") => [String] }
@@ -1631,11 +1632,17 @@ 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_issnl = query_params.get("issnl").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
+ let param_issne = query_params.get("issne").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
+ let param_issnp = query_params.get("issnp").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
+ let param_issn = query_params.get("issn").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
let param_wikidata_qid = query_params.get("wikidata_qid").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- match api.lookup_container(param_issnl, param_wikidata_qid, param_expand, param_hide, context).wait() {
+ match api
+ .lookup_container(param_issnl, param_issne, param_issnp, param_issn, param_wikidata_qid, param_expand, param_hide, context)
+ .wait()
+ {
Ok(rsp) => match rsp {
LookupContainerResponse::FoundEntity(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
@@ -4406,6 +4413,84 @@ where
);
let api_clone = api.clone();
+ router.get(
+ "/v0/editor/lookup",
+ move |req: &mut Request| {
+ let mut context = Context::default();
+
+ // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
+ fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ context.auth_data = req.extensions.remove::<AuthData>();
+ context.authorization = req.extensions.remove::<Authorization>();
+
+ // 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_username = query_params.get("username").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
+
+ match api.lookup_editor(param_username, context).wait() {
+ Ok(rsp) => match rsp {
+ LookupEditorResponse::Found(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(200), body_string));
+ response.headers.set(ContentType(mimetypes::responses::LOOKUP_EDITOR_FOUND.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ LookupEditorResponse::BadRequest(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(mimetypes::responses::LOOKUP_EDITOR_BAD_REQUEST.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ LookupEditorResponse::NotFound(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(404), body_string));
+ response.headers.set(ContentType(mimetypes::responses::LOOKUP_EDITOR_NOT_FOUND.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ LookupEditorResponse::GenericError(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(500), body_string));
+ response.headers.set(ContentType(mimetypes::responses::LOOKUP_EDITOR_GENERIC_ERROR.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ }
+ }
+ }
+
+ handle_request(req, &api_clone, &mut context).or_else(|mut response| {
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ Ok(response)
+ })
+ },
+ "LookupEditor",
+ );
+
+ let api_clone = api.clone();
router.put(
"/v0/editor/:editor_id",
move |req: &mut Request| {
@@ -8290,6 +8375,7 @@ where
let param_doaj = query_params.get("doaj").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
let param_dblp = query_params.get("dblp").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
let param_oai = query_params.get("oai").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
+ let param_hdl = query_params.get("hdl").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
@@ -8308,6 +8394,7 @@ where
param_doaj,
param_dblp,
param_oai,
+ param_hdl,
param_expand,
param_hide,
context,