summaryrefslogtreecommitdiffstats
path: root/fatcat-openapi/src
diff options
context:
space:
mode:
Diffstat (limited to 'fatcat-openapi/src')
-rw-r--r--fatcat-openapi/src/client/mod.rs148
-rw-r--r--fatcat-openapi/src/lib.rs58
-rw-r--r--fatcat-openapi/src/models.rs81
-rw-r--r--fatcat-openapi/src/server/mod.rs256
4 files changed, 498 insertions, 45 deletions
diff --git a/fatcat-openapi/src/client/mod.rs b/fatcat-openapi/src/client/mod.rs
index bb1cee8..774f6ee 100644
--- a/fatcat-openapi/src/client/mod.rs
+++ b/fatcat-openapi/src/client/mod.rs
@@ -67,10 +67,10 @@ use crate::{
GetWebcaptureEditResponse, GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse,
GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse,
GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse,
- GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse,
- LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateEditgroupResponse,
- UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse,
- UpdateWebcaptureResponse, UpdateWorkResponse,
+ 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.
@@ -13589,6 +13589,9 @@ where
async 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>,
@@ -13603,6 +13606,15 @@ where
if let Some(param_issnl) = param_issnl {
query_string.append_pair("issnl", &param_issnl.to_string());
}
+ if let Some(param_issne) = param_issne {
+ query_string.append_pair("issne", &param_issne.to_string());
+ }
+ if let Some(param_issnp) = param_issnp {
+ query_string.append_pair("issnp", &param_issnp.to_string());
+ }
+ if let Some(param_issn) = param_issn {
+ query_string.append_pair("issn", &param_issn.to_string());
+ }
if let Some(param_wikidata_qid) = param_wikidata_qid {
query_string.append_pair("wikidata_qid", &param_wikidata_qid.to_string());
}
@@ -13858,6 +13870,130 @@ where
}
}
+ async fn lookup_editor(
+ &self,
+ param_username: Option<String>,
+ context: &C,
+ ) -> Result<LookupEditorResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!("{}/v0/editor/lookup", self.base_path);
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_username) = param_username {
+ query_string.append_pair("username", &param_username.to_string());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Editor>(body)?;
+ Ok(LookupEditorResponse::Found(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(LookupEditorResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(LookupEditorResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(LookupEditorResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
async fn lookup_file(
&self,
param_md5: Option<String>,
@@ -14013,6 +14149,7 @@ where
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: &C,
@@ -14062,6 +14199,9 @@ where
if let Some(param_oai) = param_oai {
query_string.append_pair("oai", &param_oai.to_string());
}
+ if let Some(param_hdl) = param_hdl {
+ query_string.append_pair("hdl", &param_hdl.to_string());
+ }
if let Some(param_expand) = param_expand {
query_string.append_pair("expand", &param_expand.to_string());
}
diff --git a/fatcat-openapi/src/lib.rs b/fatcat-openapi/src/lib.rs
index ba49f27..8dd8e15 100644
--- a/fatcat-openapi/src/lib.rs
+++ b/fatcat-openapi/src/lib.rs
@@ -17,7 +17,7 @@ use swagger::{ApiError, ContextWrapper};
type ServiceError = Box<dyn Error + Send + Sync + 'static>;
pub const BASE_PATH: &'static str = "/v0";
-pub const API_VERSION: &'static str = "0.3.3";
+pub const API_VERSION: &'static str = "0.4.0";
#[derive(Debug, PartialEq)]
#[must_use]
@@ -1363,6 +1363,19 @@ pub enum LookupCreatorResponse {
#[derive(Debug, PartialEq)]
#[must_use]
+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)]
+#[must_use]
pub enum LookupFileResponse {
/// Found Entity
FoundEntity(models::FileEntity),
@@ -2145,6 +2158,9 @@ pub trait Api<C: Send + Sync> {
async 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>,
@@ -2160,6 +2176,12 @@ pub trait Api<C: Send + Sync> {
context: &C,
) -> Result<LookupCreatorResponse, ApiError>;
+ async fn lookup_editor(
+ &self,
+ username: Option<String>,
+ context: &C,
+ ) -> Result<LookupEditorResponse, ApiError>;
+
async fn lookup_file(
&self,
md5: Option<String>,
@@ -2185,6 +2207,7 @@ pub trait Api<C: Send + Sync> {
doaj: Option<String>,
dblp: Option<String>,
oai: Option<String>,
+ hdl: Option<String>,
expand: Option<String>,
hide: Option<String>,
context: &C,
@@ -2721,6 +2744,9 @@ pub trait ApiNoContext<C: Send + Sync> {
async 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>,
@@ -2734,6 +2760,11 @@ pub trait ApiNoContext<C: Send + Sync> {
hide: Option<String>,
) -> Result<LookupCreatorResponse, ApiError>;
+ async fn lookup_editor(
+ &self,
+ username: Option<String>,
+ ) -> Result<LookupEditorResponse, ApiError>;
+
async fn lookup_file(
&self,
md5: Option<String>,
@@ -2758,6 +2789,7 @@ pub trait ApiNoContext<C: Send + Sync> {
doaj: Option<String>,
dblp: Option<String>,
oai: Option<String>,
+ hdl: Option<String>,
expand: Option<String>,
hide: Option<String>,
) -> Result<LookupReleaseResponse, ApiError>;
@@ -3637,13 +3669,25 @@ impl<T: Api<C> + Send + Sync, C: Clone + Send + Sync> ApiNoContext<C> for Contex
async 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>,
) -> Result<LookupContainerResponse, ApiError> {
let context = self.context().clone();
self.api()
- .lookup_container(issnl, wikidata_qid, expand, hide, &context)
+ .lookup_container(
+ issnl,
+ issne,
+ issnp,
+ issn,
+ wikidata_qid,
+ expand,
+ hide,
+ &context,
+ )
.await
}
@@ -3660,6 +3704,14 @@ impl<T: Api<C> + Send + Sync, C: Clone + Send + Sync> ApiNoContext<C> for Contex
.await
}
+ async fn lookup_editor(
+ &self,
+ username: Option<String>,
+ ) -> Result<LookupEditorResponse, ApiError> {
+ let context = self.context().clone();
+ self.api().lookup_editor(username, &context).await
+ }
+
async fn lookup_file(
&self,
md5: Option<String>,
@@ -3689,6 +3741,7 @@ impl<T: Api<C> + Send + Sync, C: Clone + Send + Sync> ApiNoContext<C> for Contex
doaj: Option<String>,
dblp: Option<String>,
oai: Option<String>,
+ hdl: Option<String>,
expand: Option<String>,
hide: Option<String>,
) -> Result<LookupReleaseResponse, ApiError> {
@@ -3708,6 +3761,7 @@ impl<T: Api<C> + Send + Sync, C: Clone + Send + Sync> ApiNoContext<C> for Contex
doaj,
dblp,
oai,
+ hdl,
expand,
hide,
&context,
diff --git a/fatcat-openapi/src/models.rs b/fatcat-openapi/src/models.rs
index d642c62..e418053 100644
--- a/fatcat-openapi/src/models.rs
+++ b/fatcat-openapi/src/models.rs
@@ -891,6 +891,11 @@ pub struct ContainerEntity {
#[serde(skip_serializing_if = "Option::is_none")]
pub container_type: 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>,
+
/// Name of the organization or entity responsible for publication. Not the complete imprint/brand.
#[serde(rename = "publisher")]
#[serde(skip_serializing_if = "Option::is_none")]
@@ -901,6 +906,16 @@ pub struct ContainerEntity {
#[serde(skip_serializing_if = "Option::is_none")]
pub issnl: 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>,
+
+ /// 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>,
+
#[serde(rename = "wikidata_qid")]
#[serde(skip_serializing_if = "Option::is_none")]
pub wikidata_qid: Option<String>,
@@ -917,8 +932,11 @@ impl ContainerEntity {
edit_extra: None,
name: None,
container_type: None,
+ publication_status: None,
publisher: None,
issnl: None,
+ issne: None,
+ issnp: None,
wikidata_qid: None,
}
}
@@ -967,6 +985,11 @@ impl std::string::ToString for ContainerEntity {
params.push(container_type.to_string());
}
+ if let Some(ref publication_status) = self.publication_status {
+ params.push("publication_status".to_string());
+ params.push(publication_status.to_string());
+ }
+
if let Some(ref publisher) = self.publisher {
params.push("publisher".to_string());
params.push(publisher.to_string());
@@ -977,6 +1000,16 @@ impl std::string::ToString for ContainerEntity {
params.push(issnl.to_string());
}
+ if let Some(ref issne) = self.issne {
+ params.push("issne".to_string());
+ params.push(issne.to_string());
+ }
+
+ if let Some(ref issnp) = self.issnp {
+ params.push("issnp".to_string());
+ params.push(issnp.to_string());
+ }
+
if let Some(ref wikidata_qid) = self.wikidata_qid {
params.push("wikidata_qid".to_string());
params.push(wikidata_qid.to_string());
@@ -1004,8 +1037,11 @@ impl std::str::FromStr for ContainerEntity {
pub edit_extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
pub name: Vec<String>,
pub container_type: Vec<String>,
+ pub publication_status: Vec<String>,
pub publisher: Vec<String>,
pub issnl: Vec<String>,
+ pub issne: Vec<String>,
+ pub issnp: Vec<String>,
pub wikidata_qid: Vec<String>,
}
@@ -1057,12 +1093,21 @@ impl std::str::FromStr for ContainerEntity {
"container_type" => intermediate_rep
.container_type
.push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "publication_status" => intermediate_rep
+ .publication_status
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
"publisher" => intermediate_rep
.publisher
.push(String::from_str(val).map_err(|x| format!("{}", x))?),
"issnl" => intermediate_rep
.issnl
.push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "issne" => intermediate_rep
+ .issne
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "issnp" => intermediate_rep
+ .issnp
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
"wikidata_qid" => intermediate_rep
.wikidata_qid
.push(String::from_str(val).map_err(|x| format!("{}", x))?),
@@ -1088,8 +1133,11 @@ impl std::str::FromStr for ContainerEntity {
edit_extra: intermediate_rep.edit_extra.into_iter().next(),
name: intermediate_rep.name.into_iter().next(),
container_type: intermediate_rep.container_type.into_iter().next(),
+ publication_status: intermediate_rep.publication_status.into_iter().next(),
publisher: intermediate_rep.publisher.into_iter().next(),
issnl: intermediate_rep.issnl.into_iter().next(),
+ issne: intermediate_rep.issne.into_iter().next(),
+ issnp: intermediate_rep.issnp.into_iter().next(),
wikidata_qid: intermediate_rep.wikidata_qid.into_iter().next(),
})
}
@@ -4156,7 +4204,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 normative (but unenforced) schema fields.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extra: Option<std::collections::HashMap<String, serde_json::Value>>,
@@ -4170,6 +4222,7 @@ impl FilesetFile {
md5: None,
sha1: None,
sha256: None,
+ mimetype: None,
extra: None,
}
}
@@ -4203,6 +4256,11 @@ impl std::string::ToString for FilesetFile {
params.push(sha256.to_string());
}
+ if let Some(ref mimetype) = self.mimetype {
+ params.push("mimetype".to_string());
+ params.push(mimetype.to_string());
+ }
+
// Skipping extra in query parameter serialization
// Skipping extra in query parameter serialization
@@ -4225,6 +4283,7 @@ impl std::str::FromStr for FilesetFile {
pub md5: Vec<String>,
pub sha1: Vec<String>,
pub sha256: Vec<String>,
+ pub mimetype: Vec<String>,
pub extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
}
@@ -4261,6 +4320,9 @@ impl std::str::FromStr for FilesetFile {
"sha256" => intermediate_rep
.sha256
.push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "mimetype" => intermediate_rep
+ .mimetype
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
"extra" => {
return std::result::Result::Err(
"Parsing a container in this style is not supported in FilesetFile"
@@ -4294,6 +4356,7 @@ impl std::str::FromStr for FilesetFile {
md5: intermediate_rep.md5.into_iter().next(),
sha1: intermediate_rep.sha1.into_iter().next(),
sha256: intermediate_rep.sha256.into_iter().next(),
+ mimetype: intermediate_rep.mimetype.into_iter().next(),
extra: intermediate_rep.extra.into_iter().next(),
})
}
@@ -5794,6 +5857,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 {
@@ -5812,6 +5880,7 @@ impl ReleaseExtIds {
doaj: None,
dblp: None,
oai: None,
+ hdl: None,
}
}
}
@@ -5888,6 +5957,11 @@ impl std::string::ToString for ReleaseExtIds {
params.push(oai.to_string());
}
+ if let Some(ref hdl) = self.hdl {
+ params.push("hdl".to_string());
+ params.push(hdl.to_string());
+ }
+
params.join(",").to_string()
}
}
@@ -5915,6 +5989,7 @@ impl std::str::FromStr for ReleaseExtIds {
pub doaj: Vec<String>,
pub dblp: Vec<String>,
pub oai: Vec<String>,
+ pub hdl: Vec<String>,
}
let mut intermediate_rep = IntermediateRep::default();
@@ -5974,6 +6049,9 @@ impl std::str::FromStr for ReleaseExtIds {
"oai" => intermediate_rep
.oai
.push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "hdl" => intermediate_rep
+ .hdl
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
_ => {
return std::result::Result::Err(
"Unexpected key while parsing ReleaseExtIds".to_string(),
@@ -6001,6 +6079,7 @@ impl std::str::FromStr for ReleaseExtIds {
doaj: intermediate_rep.doaj.into_iter().next(),
dblp: intermediate_rep.dblp.into_iter().next(),
oai: intermediate_rep.oai.into_iter().next(),
+ hdl: intermediate_rep.hdl.into_iter().next(),
})
}
}
diff --git a/fatcat-openapi/src/server/mod.rs b/fatcat-openapi/src/server/mod.rs
index ac07c6e..251c678 100644
--- a/fatcat-openapi/src/server/mod.rs
+++ b/fatcat-openapi/src/server/mod.rs
@@ -47,10 +47,10 @@ use crate::{
GetWebcaptureEditResponse, GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse,
GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse,
GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse,
- GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse,
- LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateEditgroupResponse,
- UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse,
- UpdateWebcaptureResponse, UpdateWorkResponse,
+ GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupEditorResponse,
+ LookupFileResponse, LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse,
+ UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse,
+ UpdateReleaseResponse, UpdateWebcaptureResponse, UpdateWorkResponse,
};
mod paths {
@@ -110,6 +110,7 @@ mod paths {
r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/work$",
r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/work/edit/(?P<edit_id>[^/?#]*)$",
r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/work/(?P<ident>[^/?#]*)$",
+ r"^/v0/editor/lookup$",
r"^/v0/editor/(?P<editor_id>[^/?#]*)$",
r"^/v0/editor/(?P<editor_id>[^/?#]*)/annotations$",
r"^/v0/editor/(?P<editor_id>[^/?#]*)/editgroups$",
@@ -413,195 +414,196 @@ mod paths {
regex::Regex::new(r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/work/(?P<ident>[^/?#]*)$")
.expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_WORK_IDENT");
}
- pub(crate) static ID_EDITOR_EDITOR_ID: usize = 52;
+ pub(crate) static ID_EDITOR_LOOKUP: usize = 52;
+ pub(crate) static ID_EDITOR_EDITOR_ID: usize = 53;
lazy_static! {
pub static ref REGEX_EDITOR_EDITOR_ID: regex::Regex =
regex::Regex::new(r"^/v0/editor/(?P<editor_id>[^/?#]*)$")
.expect("Unable to create regex for EDITOR_EDITOR_ID");
}
- pub(crate) static ID_EDITOR_EDITOR_ID_ANNOTATIONS: usize = 53;
+ pub(crate) static ID_EDITOR_EDITOR_ID_ANNOTATIONS: usize = 54;
lazy_static! {
pub static ref REGEX_EDITOR_EDITOR_ID_ANNOTATIONS: regex::Regex =
regex::Regex::new(r"^/v0/editor/(?P<editor_id>[^/?#]*)/annotations$")
.expect("Unable to create regex for EDITOR_EDITOR_ID_ANNOTATIONS");
}
- pub(crate) static ID_EDITOR_EDITOR_ID_EDITGROUPS: usize = 54;
+ pub(crate) static ID_EDITOR_EDITOR_ID_EDITGROUPS: usize = 55;
lazy_static! {
pub static ref REGEX_EDITOR_EDITOR_ID_EDITGROUPS: regex::Regex =
regex::Regex::new(r"^/v0/editor/(?P<editor_id>[^/?#]*)/editgroups$")
.expect("Unable to create regex for EDITOR_EDITOR_ID_EDITGROUPS");
}
- pub(crate) static ID_FILE_EDIT_EDIT_ID: usize = 55;
+ pub(crate) static ID_FILE_EDIT_EDIT_ID: usize = 56;
lazy_static! {
pub static ref REGEX_FILE_EDIT_EDIT_ID: regex::Regex =
regex::Regex::new(r"^/v0/file/edit/(?P<edit_id>[^/?#]*)$")
.expect("Unable to create regex for FILE_EDIT_EDIT_ID");
}
- pub(crate) static ID_FILE_LOOKUP: usize = 56;
- pub(crate) static ID_FILE_REV_REV_ID: usize = 57;
+ pub(crate) static ID_FILE_LOOKUP: usize = 57;
+ pub(crate) static ID_FILE_REV_REV_ID: usize = 58;
lazy_static! {
pub static ref REGEX_FILE_REV_REV_ID: regex::Regex =
regex::Regex::new(r"^/v0/file/rev/(?P<rev_id>[^/?#]*)$")
.expect("Unable to create regex for FILE_REV_REV_ID");
}
- pub(crate) static ID_FILE_IDENT: usize = 58;
+ pub(crate) static ID_FILE_IDENT: usize = 59;
lazy_static! {
pub static ref REGEX_FILE_IDENT: regex::Regex =
regex::Regex::new(r"^/v0/file/(?P<ident>[^/?#]*)$")
.expect("Unable to create regex for FILE_IDENT");
}
- pub(crate) static ID_FILE_IDENT_HISTORY: usize = 59;
+ pub(crate) static ID_FILE_IDENT_HISTORY: usize = 60;
lazy_static! {
pub static ref REGEX_FILE_IDENT_HISTORY: regex::Regex =
regex::Regex::new(r"^/v0/file/(?P<ident>[^/?#]*)/history$")
.expect("Unable to create regex for FILE_IDENT_HISTORY");
}
- pub(crate) static ID_FILE_IDENT_REDIRECTS: usize = 60;
+ pub(crate) static ID_FILE_IDENT_REDIRECTS: usize = 61;
lazy_static! {
pub static ref REGEX_FILE_IDENT_REDIRECTS: regex::Regex =
regex::Regex::new(r"^/v0/file/(?P<ident>[^/?#]*)/redirects$")
.expect("Unable to create regex for FILE_IDENT_REDIRECTS");
}
- pub(crate) static ID_FILESET_EDIT_EDIT_ID: usize = 61;
+ pub(crate) static ID_FILESET_EDIT_EDIT_ID: usize = 62;
lazy_static! {
pub static ref REGEX_FILESET_EDIT_EDIT_ID: regex::Regex =
regex::Regex::new(r"^/v0/fileset/edit/(?P<edit_id>[^/?#]*)$")
.expect("Unable to create regex for FILESET_EDIT_EDIT_ID");
}
- pub(crate) static ID_FILESET_REV_REV_ID: usize = 62;
+ pub(crate) static ID_FILESET_REV_REV_ID: usize = 63;
lazy_static! {
pub static ref REGEX_FILESET_REV_REV_ID: regex::Regex =
regex::Regex::new(r"^/v0/fileset/rev/(?P<rev_id>[^/?#]*)$")
.expect("Unable to create regex for FILESET_REV_REV_ID");
}
- pub(crate) static ID_FILESET_IDENT: usize = 63;
+ pub(crate) static ID_FILESET_IDENT: usize = 64;
lazy_static! {
pub static ref REGEX_FILESET_IDENT: regex::Regex =
regex::Regex::new(r"^/v0/fileset/(?P<ident>[^/?#]*)$")
.expect("Unable to create regex for FILESET_IDENT");
}
- pub(crate) static ID_FILESET_IDENT_HISTORY: usize = 64;
+ pub(crate) static ID_FILESET_IDENT_HISTORY: usize = 65;
lazy_static! {
pub static ref REGEX_FILESET_IDENT_HISTORY: regex::Regex =
regex::Regex::new(r"^/v0/fileset/(?P<ident>[^/?#]*)/history$")
.expect("Unable to create regex for FILESET_IDENT_HISTORY");
}
- pub(crate) static ID_FILESET_IDENT_REDIRECTS: usize = 65;
+ pub(crate) static ID_FILESET_IDENT_REDIRECTS: usize = 66;
lazy_static! {
pub static ref REGEX_FILESET_IDENT_REDIRECTS: regex::Regex =
regex::Regex::new(r"^/v0/fileset/(?P<ident>[^/?#]*)/redirects$")
.expect("Unable to create regex for FILESET_IDENT_REDIRECTS");
}
- pub(crate) static ID_RELEASE_EDIT_EDIT_ID: usize = 66;
+ pub(crate) static ID_RELEASE_EDIT_EDIT_ID: usize = 67;
lazy_static! {
pub static ref REGEX_RELEASE_EDIT_EDIT_ID: regex::Regex =
regex::Regex::new(r"^/v0/release/edit/(?P<edit_id>[^/?#]*)$")
.expect("Unable to create regex for RELEASE_EDIT_EDIT_ID");
}
- pub(crate) static ID_RELEASE_LOOKUP: usize = 67;
- pub(crate) static ID_RELEASE_REV_REV_ID: usize = 68;
+ pub(crate) static ID_RELEASE_LOOKUP: usize = 68;
+ pub(crate) static ID_RELEASE_REV_REV_ID: usize = 69;
lazy_static! {
pub static ref REGEX_RELEASE_REV_REV_ID: regex::Regex =
regex::Regex::new(r"^/v0/release/rev/(?P<rev_id>[^/?#]*)$")
.expect("Unable to create regex for RELEASE_REV_REV_ID");
}
- pub(crate) static ID_RELEASE_IDENT: usize = 69;
+ pub(crate) static ID_RELEASE_IDENT: usize = 70;
lazy_static! {
pub static ref REGEX_RELEASE_IDENT: regex::Regex =
regex::Regex::new(r"^/v0/release/(?P<ident>[^/?#]*)$")
.expect("Unable to create regex for RELEASE_IDENT");
}
- pub(crate) static ID_RELEASE_IDENT_FILES: usize = 70;
+ pub(crate) static ID_RELEASE_IDENT_FILES: usize = 71;
lazy_static! {
pub static ref REGEX_RELEASE_IDENT_FILES: regex::Regex =
regex::Regex::new(r"^/v0/release/(?P<ident>[^/?#]*)/files$")
.expect("Unable to create regex for RELEASE_IDENT_FILES");
}
- pub(crate) static ID_RELEASE_IDENT_FILESETS: usize = 71;
+ pub(crate) static ID_RELEASE_IDENT_FILESETS: usize = 72;
lazy_static! {
pub static ref REGEX_RELEASE_IDENT_FILESETS: regex::Regex =
regex::Regex::new(r"^/v0/release/(?P<ident>[^/?#]*)/filesets$")
.expect("Unable to create regex for RELEASE_IDENT_FILESETS");
}
- pub(crate) static ID_RELEASE_IDENT_HISTORY: usize = 72;
+ pub(crate) static ID_RELEASE_IDENT_HISTORY: usize = 73;
lazy_static! {
pub static ref REGEX_RELEASE_IDENT_HISTORY: regex::Regex =
regex::Regex::new(r"^/v0/release/(?P<ident>[^/?#]*)/history$")
.expect("Unable to create regex for RELEASE_IDENT_HISTORY");
}
- pub(crate) static ID_RELEASE_IDENT_REDIRECTS: usize = 73;
+ pub(crate) static ID_RELEASE_IDENT_REDIRECTS: usize = 74;
lazy_static! {
pub static ref REGEX_RELEASE_IDENT_REDIRECTS: regex::Regex =
regex::Regex::new(r"^/v0/release/(?P<ident>[^/?#]*)/redirects$")
.expect("Unable to create regex for RELEASE_IDENT_REDIRECTS");
}
- pub(crate) static ID_RELEASE_IDENT_WEBCAPTURES: usize = 74;
+ pub(crate) static ID_RELEASE_IDENT_WEBCAPTURES: usize = 75;
lazy_static! {
pub static ref REGEX_RELEASE_IDENT_WEBCAPTURES: regex::Regex =
regex::Regex::new(r"^/v0/release/(?P<ident>[^/?#]*)/webcaptures$")
.expect("Unable to create regex for RELEASE_IDENT_WEBCAPTURES");
}
- pub(crate) static ID_WEBCAPTURE_EDIT_EDIT_ID: usize = 75;
+ pub(crate) static ID_WEBCAPTURE_EDIT_EDIT_ID: usize = 76;
lazy_static! {
pub static ref REGEX_WEBCAPTURE_EDIT_EDIT_ID: regex::Regex =
regex::Regex::new(r"^/v0/webcapture/edit/(?P<edit_id>[^/?#]*)$")
.expect("Unable to create regex for WEBCAPTURE_EDIT_EDIT_ID");
}
- pub(crate) static ID_WEBCAPTURE_REV_REV_ID: usize = 76;
+ pub(crate) static ID_WEBCAPTURE_REV_REV_ID: usize = 77;
lazy_static! {
pub static ref REGEX_WEBCAPTURE_REV_REV_ID: regex::Regex =
regex::Regex::new(r"^/v0/webcapture/rev/(?P<rev_id>[^/?#]*)$")
.expect("Unable to create regex for WEBCAPTURE_REV_REV_ID");
}
- pub(crate) static ID_WEBCAPTURE_IDENT: usize = 77;
+ pub(crate) static ID_WEBCAPTURE_IDENT: usize = 78;
lazy_static! {
pub static ref REGEX_WEBCAPTURE_IDENT: regex::Regex =
regex::Regex::new(r"^/v0/webcapture/(?P<ident>[^/?#]*)$")
.expect("Unable to create regex for WEBCAPTURE_IDENT");
}
- pub(crate) static ID_WEBCAPTURE_IDENT_HISTORY: usize = 78;
+ pub(crate) static ID_WEBCAPTURE_IDENT_HISTORY: usize = 79;
lazy_static! {
pub static ref REGEX_WEBCAPTURE_IDENT_HISTORY: regex::Regex =
regex::Regex::new(r"^/v0/webcapture/(?P<ident>[^/?#]*)/history$")
.expect("Unable to create regex for WEBCAPTURE_IDENT_HISTORY");
}
- pub(crate) static ID_WEBCAPTURE_IDENT_REDIRECTS: usize = 79;
+ pub(crate) static ID_WEBCAPTURE_IDENT_REDIRECTS: usize = 80;
lazy_static! {
pub static ref REGEX_WEBCAPTURE_IDENT_REDIRECTS: regex::Regex =
regex::Regex::new(r"^/v0/webcapture/(?P<ident>[^/?#]*)/redirects$")
.expect("Unable to create regex for WEBCAPTURE_IDENT_REDIRECTS");
}
- pub(crate) static ID_WORK_EDIT_EDIT_ID: usize = 80;
+ pub(crate) static ID_WORK_EDIT_EDIT_ID: usize = 81;
lazy_static! {
pub static ref REGEX_WORK_EDIT_EDIT_ID: regex::Regex =
regex::Regex::new(r"^/v0/work/edit/(?P<edit_id>[^/?#]*)$")
.expect("Unable to create regex for WORK_EDIT_EDIT_ID");
}
- pub(crate) static ID_WORK_REV_REV_ID: usize = 81;
+ pub(crate) static ID_WORK_REV_REV_ID: usize = 82;
lazy_static! {
pub static ref REGEX_WORK_REV_REV_ID: regex::Regex =
regex::Regex::new(r"^/v0/work/rev/(?P<rev_id>[^/?#]*)$")
.expect("Unable to create regex for WORK_REV_REV_ID");
}
- pub(crate) static ID_WORK_IDENT: usize = 82;
+ pub(crate) static ID_WORK_IDENT: usize = 83;
lazy_static! {
pub static ref REGEX_WORK_IDENT: regex::Regex =
regex::Regex::new(r"^/v0/work/(?P<ident>[^/?#]*)$")
.expect("Unable to create regex for WORK_IDENT");
}
- pub(crate) static ID_WORK_IDENT_HISTORY: usize = 83;
+ pub(crate) static ID_WORK_IDENT_HISTORY: usize = 84;
lazy_static! {
pub static ref REGEX_WORK_IDENT_HISTORY: regex::Regex =
regex::Regex::new(r"^/v0/work/(?P<ident>[^/?#]*)/history$")
.expect("Unable to create regex for WORK_IDENT_HISTORY");
}
- pub(crate) static ID_WORK_IDENT_REDIRECTS: usize = 84;
+ pub(crate) static ID_WORK_IDENT_REDIRECTS: usize = 85;
lazy_static! {
pub static ref REGEX_WORK_IDENT_REDIRECTS: regex::Regex =
regex::Regex::new(r"^/v0/work/(?P<ident>[^/?#]*)/redirects$")
.expect("Unable to create regex for WORK_IDENT_REDIRECTS");
}
- pub(crate) static ID_WORK_IDENT_RELEASES: usize = 85;
+ pub(crate) static ID_WORK_IDENT_RELEASES: usize = 86;
lazy_static! {
pub static ref REGEX_WORK_IDENT_RELEASES: regex::Regex =
regex::Regex::new(r"^/v0/work/(?P<ident>[^/?#]*)/releases$")
@@ -12618,6 +12620,60 @@ where
}
None => None,
};
+ let param_issne = query_params
+ .iter()
+ .filter(|e| e.0 == "issne")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_issne = match param_issne {
+ Some(param_issne) => {
+ let param_issne = <String as std::str::FromStr>::from_str(&param_issne);
+ match param_issne {
+ Ok(param_issne) => Some(param_issne),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter issne - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter issne")),
+ }
+ }
+ None => None,
+ };
+ let param_issnp = query_params
+ .iter()
+ .filter(|e| e.0 == "issnp")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_issnp = match param_issnp {
+ Some(param_issnp) => {
+ let param_issnp = <String as std::str::FromStr>::from_str(&param_issnp);
+ match param_issnp {
+ Ok(param_issnp) => Some(param_issnp),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter issnp - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter issnp")),
+ }
+ }
+ None => None,
+ };
+ let param_issn = query_params
+ .iter()
+ .filter(|e| e.0 == "issn")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_issn = match param_issn {
+ Some(param_issn) => {
+ let param_issn = <String as std::str::FromStr>::from_str(&param_issn);
+ match param_issn {
+ Ok(param_issn) => Some(param_issn),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter issn - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter issn")),
+ }
+ }
+ None => None,
+ };
let param_wikidata_qid = query_params
.iter()
.filter(|e| e.0 == "wikidata_qid")
@@ -12678,6 +12734,9 @@ where
let result = api_impl
.lookup_container(
param_issnl,
+ param_issne,
+ param_issnp,
+ param_issn,
param_wikidata_qid,
param_expand,
param_hide,
@@ -12918,6 +12977,105 @@ where
Ok(response)
}
+ // LookupEditor - GET /editor/lookup
+ &hyper::Method::GET if path.matched(paths::ID_EDITOR_LOOKUP) => {
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_username = query_params
+ .iter()
+ .filter(|e| e.0 == "username")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_username = match param_username {
+ Some(param_username) => {
+ let param_username =
+ <String as std::str::FromStr>::from_str(&param_username);
+ match param_username {
+ Ok(param_username) => Some(param_username),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter username - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter username")),
+ }
+ }
+ None => None,
+ };
+
+ let result = api_impl.lookup_editor(param_username, &context).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ LookupEditorResponse::Found(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_EDITOR_FOUND"));
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ LookupEditorResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_EDITOR_BAD_REQUEST"));
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ LookupEditorResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_EDITOR_NOT_FOUND"));
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ LookupEditorResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_EDITOR_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ }
+ }
+
+ Ok(response)
+ }
+
// LookupFile - GET /file/lookup
&hyper::Method::GET if path.matched(paths::ID_FILE_LOOKUP) => {
// Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
@@ -13341,6 +13499,24 @@ where
}
None => None,
};
+ let param_hdl = query_params
+ .iter()
+ .filter(|e| e.0 == "hdl")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hdl = match param_hdl {
+ Some(param_hdl) => {
+ let param_hdl = <String as std::str::FromStr>::from_str(&param_hdl);
+ match param_hdl {
+ Ok(param_hdl) => Some(param_hdl),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hdl - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hdl")),
+ }
+ }
+ None => None,
+ };
let param_expand = query_params
.iter()
.filter(|e| e.0 == "expand")
@@ -13394,6 +13570,7 @@ where
param_doaj,
param_dblp,
param_oai,
+ param_hdl,
param_expand,
param_hide,
&context,
@@ -15432,6 +15609,7 @@ where
_ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK_IDENT) => {
method_not_allowed()
}
+ _ if path.matched(paths::ID_EDITOR_LOOKUP) => method_not_allowed(),
_ if path.matched(paths::ID_EDITOR_EDITOR_ID) => method_not_allowed(),
_ if path.matched(paths::ID_EDITOR_EDITOR_ID_ANNOTATIONS) => method_not_allowed(),
_ if path.matched(paths::ID_EDITOR_EDITOR_ID_EDITGROUPS) => method_not_allowed(),
@@ -15808,6 +15986,8 @@ impl<T> RequestParser<T> for ApiRequestParser {
}
// LookupCreator - GET /creator/lookup
&hyper::Method::GET if path.matched(paths::ID_CREATOR_LOOKUP) => Ok("LookupCreator"),
+ // LookupEditor - GET /editor/lookup
+ &hyper::Method::GET if path.matched(paths::ID_EDITOR_LOOKUP) => Ok("LookupEditor"),
// LookupFile - GET /file/lookup
&hyper::Method::GET if path.matched(paths::ID_FILE_LOOKUP) => Ok("LookupFile"),
// LookupRelease - GET /release/lookup