diff options
Diffstat (limited to 'rust')
| -rw-r--r-- | rust/fatcat-api-spec/README.md | 2 | ||||
| -rw-r--r-- | rust/fatcat-api-spec/api.yaml | 8 | ||||
| -rw-r--r-- | rust/fatcat-api-spec/api/swagger.yaml | 12 | ||||
| -rw-r--r-- | rust/fatcat-api-spec/examples/client.rs | 2 | ||||
| -rw-r--r-- | rust/fatcat-api-spec/examples/server_lib/server.rs | 6 | ||||
| -rw-r--r-- | rust/fatcat-api-spec/src/client.rs | 8 | ||||
| -rw-r--r-- | rust/fatcat-api-spec/src/lib.rs | 9 | ||||
| -rw-r--r-- | rust/fatcat-api-spec/src/server.rs | 16 | ||||
| -rw-r--r-- | rust/src/endpoint_handlers.rs | 34 | ||||
| -rw-r--r-- | rust/src/endpoints.rs | 4 | 
10 files changed, 89 insertions, 12 deletions
| diff --git a/rust/fatcat-api-spec/README.md b/rust/fatcat-api-spec/README.md index a55ad337..2ea830e9 100644 --- a/rust/fatcat-api-spec/README.md +++ b/rust/fatcat-api-spec/README.md @@ -13,7 +13,7 @@ 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.1.0 -- Build date: 2019-01-21T19:59:50.253Z +- Build date: 2019-01-21T20:07:57.927Z  This autogenerated project defines an API crate `fatcat` which contains:  * An `Api` trait defining the API in Rust. diff --git a/rust/fatcat-api-spec/api.yaml b/rust/fatcat-api-spec/api.yaml index 0a5391c8..c0411bbc 100644 --- a/rust/fatcat-api-spec/api.yaml +++ b/rust/fatcat-api-spec/api.yaml @@ -2220,6 +2220,14 @@ paths:            in: query            type: string            required: false +        - name: arxiv_id +          in: query +          type: string +          required: false +        - name: jstor_id +          in: query +          type: string +          required: false          - name: expand            in: query            type: string diff --git a/rust/fatcat-api-spec/api/swagger.yaml b/rust/fatcat-api-spec/api/swagger.yaml index 989ca0ab..ca5c8838 100644 --- a/rust/fatcat-api-spec/api/swagger.yaml +++ b/rust/fatcat-api-spec/api/swagger.yaml @@ -5041,6 +5041,18 @@ paths:          type: "string"          formatString: "{:?}"          example: "Some(\"core_id_example\".to_string())" +      - name: "arxiv_id" +        in: "query" +        required: false +        type: "string" +        formatString: "{:?}" +        example: "Some(\"arxiv_id_example\".to_string())" +      - name: "jstor_id" +        in: "query" +        required: false +        type: "string" +        formatString: "{:?}" +        example: "Some(\"jstor_id_example\".to_string())"        - name: "expand"          in: "query"          description: "List of sub-entities to expand in response." diff --git a/rust/fatcat-api-spec/examples/client.rs b/rust/fatcat-api-spec/examples/client.rs index b4d90719..196580e4 100644 --- a/rust/fatcat-api-spec/examples/client.rs +++ b/rust/fatcat-api-spec/examples/client.rs @@ -554,6 +554,8 @@ fn main() {                      Some("pmid_example".to_string()),                      Some("pmcid_example".to_string()),                      Some("core_id_example".to_string()), +                    Some("arxiv_id_example".to_string()), +                    Some("jstor_id_example".to_string()),                      Some("expand_example".to_string()),                      Some("hide_example".to_string()),                  ) diff --git a/rust/fatcat-api-spec/examples/server_lib/server.rs b/rust/fatcat-api-spec/examples/server_lib/server.rs index 3c37106a..20336528 100644 --- a/rust/fatcat-api-spec/examples/server_lib/server.rs +++ b/rust/fatcat-api-spec/examples/server_lib/server.rs @@ -826,19 +826,23 @@ impl Api for Server {          pmid: Option<String>,          pmcid: Option<String>,          core_id: Option<String>, +        arxiv_id: Option<String>, +        jstor_id: 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,              pmid,              pmcid,              core_id, +            arxiv_id, +            jstor_id,              expand,              hide,              context.x_span_id.unwrap_or(String::from("<none>")).clone() diff --git a/rust/fatcat-api-spec/src/client.rs b/rust/fatcat-api-spec/src/client.rs index a3e97fb3..df9d2127 100644 --- a/rust/fatcat-api-spec/src/client.rs +++ b/rust/fatcat-api-spec/src/client.rs @@ -5988,6 +5988,8 @@ impl Api for Client {          param_pmid: Option<String>,          param_pmcid: Option<String>,          param_core_id: Option<String>, +        param_arxiv_id: Option<String>, +        param_jstor_id: Option<String>,          param_expand: Option<String>,          param_hide: Option<String>,          context: &Context, @@ -5999,11 +6001,13 @@ impl Api for Client {          let query_pmid = param_pmid.map_or_else(String::new, |query| format!("pmid={pmid}&", pmid = query.to_string()));          let query_pmcid = param_pmcid.map_or_else(String::new, |query| format!("pmcid={pmcid}&", pmcid = query.to_string()));          let query_core_id = param_core_id.map_or_else(String::new, |query| format!("core_id={core_id}&", core_id = query.to_string())); +        let query_arxiv_id = param_arxiv_id.map_or_else(String::new, |query| format!("arxiv_id={arxiv_id}&", arxiv_id = query.to_string())); +        let query_jstor_id = param_jstor_id.map_or_else(String::new, |query| format!("jstor_id={jstor_id}&", jstor_id = 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_id}{expand}{hide}", +            "{}/v0/release/lookup?{doi}{wikidata_qid}{isbn13}{pmid}{pmcid}{core_id}{arxiv_id}{jstor_id}{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), @@ -6011,6 +6015,8 @@ impl Api for Client {              pmid = utf8_percent_encode(&query_pmid, QUERY_ENCODE_SET),              pmcid = utf8_percent_encode(&query_pmcid, QUERY_ENCODE_SET),              core_id = utf8_percent_encode(&query_core_id, QUERY_ENCODE_SET), +            arxiv_id = utf8_percent_encode(&query_arxiv_id, QUERY_ENCODE_SET), +            jstor_id = utf8_percent_encode(&query_jstor_id, 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-api-spec/src/lib.rs b/rust/fatcat-api-spec/src/lib.rs index 9585f1c0..20e53f62 100644 --- a/rust/fatcat-api-spec/src/lib.rs +++ b/rust/fatcat-api-spec/src/lib.rs @@ -1568,6 +1568,8 @@ pub trait Api {          pmid: Option<String>,          pmcid: Option<String>,          core_id: Option<String>, +        arxiv_id: Option<String>, +        jstor_id: Option<String>,          expand: Option<String>,          hide: Option<String>,          context: &Context, @@ -1833,6 +1835,8 @@ pub trait ApiNoContext {          pmid: Option<String>,          pmcid: Option<String>,          core_id: Option<String>, +        arxiv_id: Option<String>, +        jstor_id: Option<String>,          expand: Option<String>,          hide: Option<String>,      ) -> Box<Future<Item = LookupReleaseResponse, Error = ApiError> + Send>; @@ -2248,10 +2252,13 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {          pmid: Option<String>,          pmcid: Option<String>,          core_id: Option<String>, +        arxiv_id: Option<String>, +        jstor_id: Option<String>,          expand: Option<String>,          hide: Option<String>,      ) -> Box<Future<Item = LookupReleaseResponse, Error = ApiError> + Send> { -        self.api().lookup_release(doi, wikidata_qid, isbn13, pmid, pmcid, core_id, expand, hide, &self.context()) +        self.api() +            .lookup_release(doi, wikidata_qid, isbn13, pmid, pmcid, core_id, arxiv_id, jstor_id, expand, hide, &self.context())      }      fn update_release(&self, ident: String, entity: models::ReleaseEntity, editgroup_id: String) -> Box<Future<Item = UpdateReleaseResponse, Error = ApiError> + Send> { diff --git a/rust/fatcat-api-spec/src/server.rs b/rust/fatcat-api-spec/src/server.rs index 495c7b20..c3d018d1 100644 --- a/rust/fatcat-api-spec/src/server.rs +++ b/rust/fatcat-api-spec/src/server.rs @@ -8256,11 +8256,25 @@ where                  let param_pmid = query_params.get("pmid").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());                  let param_pmcid = query_params.get("pmcid").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());                  let param_core_id = query_params.get("core_id").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); +                let param_arxiv_id = query_params.get("arxiv_id").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); +                let param_jstor_id = query_params.get("jstor_id").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_release(param_doi, param_wikidata_qid, param_isbn13, param_pmid, param_pmcid, param_core_id, param_expand, param_hide, context) +                    .lookup_release( +                        param_doi, +                        param_wikidata_qid, +                        param_isbn13, +                        param_pmid, +                        param_pmcid, +                        param_core_id, +                        param_arxiv_id, +                        param_jstor_id, +                        param_expand, +                        param_hide, +                        context, +                    )                      .wait()                  {                      Ok(rsp) => match rsp { diff --git a/rust/src/endpoint_handlers.rs b/rust/src/endpoint_handlers.rs index bc606af9..4567e810 100644 --- a/rust/src/endpoint_handlers.rs +++ b/rust/src/endpoint_handlers.rs @@ -259,12 +259,14 @@ impl Server {          pmid: &Option<String>,          pmcid: &Option<String>,          core_id: &Option<String>, +        arxiv_id: &Option<String>, +        jstor_id: &Option<String>,          expand_flags: ExpandFlags,          hide_flags: HideFlags,      ) -> Result<ReleaseEntity> {          let (ident, rev): (ReleaseIdentRow, ReleaseRevRow) = -            match (doi, wikidata_qid, isbn13, pmid, pmcid, core_id) { -                (Some(doi), None, None, None, None, None) => { +            match (doi, wikidata_qid, isbn13, pmid, pmcid, core_id, arxiv_id, jstor_id) { +                (Some(doi), None, None, None, None, None, None, None) => {                      check_doi(doi)?;                      release_ident::table                          .inner_join(release_rev::table) @@ -273,7 +275,7 @@ impl Server {                          .filter(release_ident::redirect_id.is_null())                          .first(conn)?                  } -                (None, Some(wikidata_qid), None, None, None, None) => { +                (None, Some(wikidata_qid), None, None, None, None, None, None) => {                      check_wikidata_qid(wikidata_qid)?;                      release_ident::table                          .inner_join(release_rev::table) @@ -282,7 +284,7 @@ impl Server {                          .filter(release_ident::redirect_id.is_null())                          .first(conn)?                  } -                (None, None, Some(isbn13), None, None, None) => { +                (None, None, Some(isbn13), None, None, None, None, None) => {                      // TODO: check_isbn13(isbn13)?;                      release_ident::table                          .inner_join(release_rev::table) @@ -291,7 +293,7 @@ impl Server {                          .filter(release_ident::redirect_id.is_null())                          .first(conn)?                  } -                (None, None, None, Some(pmid), None, None) => { +                (None, None, None, Some(pmid), None, None, None, None) => {                      check_pmid(pmid)?;                      release_ident::table                          .inner_join(release_rev::table) @@ -300,7 +302,7 @@ impl Server {                          .filter(release_ident::redirect_id.is_null())                          .first(conn)?                  } -                (None, None, None, None, Some(pmcid), None) => { +                (None, None, None, None, Some(pmcid), None, None, None) => {                      check_pmcid(pmcid)?;                      release_ident::table                          .inner_join(release_rev::table) @@ -309,7 +311,7 @@ impl Server {                          .filter(release_ident::redirect_id.is_null())                          .first(conn)?                  } -                (None, None, None, None, None, Some(core_id)) => { +                (None, None, None, None, None, Some(core_id), None, None) => {                      // TODO: check_core_id(core_id)?;                      release_ident::table                          .inner_join(release_rev::table) @@ -318,6 +320,24 @@ impl Server {                          .filter(release_ident::redirect_id.is_null())                          .first(conn)?                  } +                (None, None, None, None, None, None, Some(arxiv_id), None) => { +                    // TODO: check_arxiv_id(arxiv_id)?; +                    release_ident::table +                        .inner_join(release_rev::table) +                        .filter(release_rev::arxiv_id.eq(arxiv_id)) +                        .filter(release_ident::is_live.eq(true)) +                        .filter(release_ident::redirect_id.is_null()) +                        .first(conn)? +                } +                (None, None, None, None, None, None, None, Some(jstor_id)) => { +                    // TODO: check_jstor_id(jstor_id)?; +                    release_ident::table +                        .inner_join(release_rev::table) +                        .filter(release_rev::jstor_id.eq(jstor_id)) +                        .filter(release_ident::is_live.eq(true)) +                        .filter(release_ident::redirect_id.is_null()) +                        .first(conn)? +                }                  _ => {                      return Err(                          FatcatError::MissingOrMultipleExternalId("in lookup".to_string()).into(), diff --git a/rust/src/endpoints.rs b/rust/src/endpoints.rs index 670c7fd9..8c45ea75 100644 --- a/rust/src/endpoints.rs +++ b/rust/src/endpoints.rs @@ -665,6 +665,8 @@ impl Api for Server {          pmid: Option<String>,          pmcid: Option<String>,          core_id: Option<String>, +        arxiv_id: Option<String>, +        jstor_id: Option<String>,          expand: Option<String>,          hide: Option<String>,          _context: &Context, @@ -688,6 +690,8 @@ impl Api for Server {                  &pmid,                  &pmcid,                  &core_id, +                &arxiv_id, +                &jstor_id,                  expand_flags,                  hide_flags,              ) | 
