diff options
| author | Bryan Newbold <bnewbold@robocracy.org> | 2021-10-12 16:45:07 -0700 | 
|---|---|---|
| committer | Bryan Newbold <bnewbold@robocracy.org> | 2021-10-13 16:21:30 -0700 | 
| commit | 3a45076685471b969596ef5b58823ce8074224c6 (patch) | |
| tree | 9de4a3606c75318958f363a7c7e8a568ad2dc513 /rust/fatcat-openapi/src | |
| parent | d9ff4bc8fe0a6daa39061fea7eb1830fd7b445bf (diff) | |
| download | fatcat-3a45076685471b969596ef5b58823ce8074224c6.tar.gz fatcat-3a45076685471b969596ef5b58823ce8074224c6.zip  | |
rust codegen for v0.4
Diffstat (limited to 'rust/fatcat-openapi/src')
| -rw-r--r-- | rust/fatcat-openapi/src/client.rs | 84 | ||||
| -rw-r--r-- | rust/fatcat-openapi/src/lib.rs | 55 | ||||
| -rw-r--r-- | rust/fatcat-openapi/src/mimetypes.rs | 18 | ||||
| -rw-r--r-- | rust/fatcat-openapi/src/models.rs | 31 | ||||
| -rw-r--r-- | rust/fatcat-openapi/src/server.rs | 93 | 
5 files changed, 268 insertions, 13 deletions
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,  | 
