summaryrefslogtreecommitdiffstats
path: root/rust
diff options
context:
space:
mode:
Diffstat (limited to 'rust')
-rw-r--r--rust/fatcat-api/README.md2
-rw-r--r--rust/fatcat-api/api.yaml50
-rw-r--r--rust/fatcat-api/api/swagger.yaml234
-rw-r--r--rust/fatcat-api/src/models.rs81
-rw-r--r--rust/src/api_server.rs56
-rw-r--r--rust/src/database_models.rs28
-rw-r--r--rust/src/database_schema.rs19
-rw-r--r--rust/tests/test_api_server.rs13
8 files changed, 333 insertions, 150 deletions
diff --git a/rust/fatcat-api/README.md b/rust/fatcat-api/README.md
index 856d54b5..57f877d2 100644
--- a/rust/fatcat-api/README.md
+++ b/rust/fatcat-api/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: 2018-05-28T21:40:16.318Z
+- Build date: 2018-06-04T07:14:27.260Z
This autogenerated project defines an API crate `fatcat` which contains:
* An `Api` trait defining the API in Rust.
diff --git a/rust/fatcat-api/api.yaml b/rust/fatcat-api/api.yaml
index 8ced937d..c53ff4a7 100644
--- a/rust/fatcat-api/api.yaml
+++ b/rust/fatcat-api/api.yaml
@@ -22,7 +22,7 @@ x-entity-props: &ENTITYPROPS
ident:
type: string
#format: uuid
- example: "f1f046a3-45c9-4b99-adce-000000000001"
+ example: "00000000-0000-0000-adce-000000000001"
revision:
type: integer
example: 42
@@ -30,7 +30,7 @@ x-entity-props: &ENTITYPROPS
redirect:
type: string
#format: uuid
- example: "f1f046a3-45c9-4b99-adce-000000000002"
+ example: "00000000-0000-0000-adce-000000000002"
editgroup_id:
type: integer
example: 16
@@ -80,12 +80,16 @@ definitions:
creator_entity:
type: object
required:
- - full_name
+ - display_name
properties:
<<: *ENTITYPROPS
- full_name:
+ display_name:
type: string
example: "Grace Hopper"
+ given_name:
+ type: string
+ surname:
+ type: string
orcid:
type: string
#format: custom
@@ -106,10 +110,17 @@ definitions:
type: string
#format: custom
example: "d41efcc592d1e40ac13905377399eb9b"
+ sha256:
+ type: string
+ #format: custom
+ example: "a77e4c11a57f1d757fca5754a8f83b5d4ece49a2d28596889127c1a2f3f28832"
url:
type: string
format: url
example: "https://example.edu/~frau/prcding.pdf"
+ mimetype:
+ type: string
+ example: "application/pdf"
releases:
type: array
items:
@@ -126,14 +137,17 @@ definitions:
type: string
work_id:
type: string
- example: "f1f046a3-45c9-4b99-adce-000000000001"
+ example: "00000000-0000-0000-adce-000000000001"
container_id:
type: string
- example: "f1f046a3-45c9-4b99-adce-000000000001"
+ example: "00000000-0000-0000-adce-000000000001"
release_type:
type: string
+ example: "book"
+ release_status:
+ type: string
example: "preprint"
- date:
+ release_date:
type: string
format: date
doi:
@@ -152,6 +166,8 @@ definitions:
example: "12"
publisher:
type: string
+ language:
+ type: string
contribs:
type: array
items:
@@ -179,14 +195,14 @@ definitions:
format: int64
ident:
type: string
- example: "f1f046a3-45c9-4b99-adce-000000000001"
+ example: "00000000-0000-0000-adce-000000000001"
revision:
type: integer
example: 42
format: int64
redirect_ident:
type: string
- example: "f1f046a3-45c9-4b99-adce-000000000002"
+ example: "00000000-0000-0000-adce-000000000002"
#format: uuid
editgroup_id:
type: integer
@@ -269,8 +285,20 @@ definitions:
target_release_id:
type: string
#format: uuid
- stub:
+ raw:
+ type: string
+ key:
+ type: string
+ year:
+ type: integer
+ format: int64
+ container_title:
+ type: string
+ title:
+ type: string
+ locator:
type: string
+ example: "p123"
release_contrib:
type: object
properties:
@@ -280,7 +308,7 @@ definitions:
creator_id:
type: string
#format: uuid
- creator_stub:
+ raw:
type: string
role:
type: string
diff --git a/rust/fatcat-api/api/swagger.yaml b/rust/fatcat-api/api/swagger.yaml
index 0bb29bc6..2a847e1c 100644
--- a/rust/fatcat-api/api/swagger.yaml
+++ b/rust/fatcat-api/api/swagger.yaml
@@ -1365,14 +1365,14 @@ definitions:
example: 16
redirect:
type: "string"
- example: "f1f046a3-45c9-4b99-adce-000000000002"
+ example: "00000000-0000-0000-adce-000000000002"
revision:
type: "integer"
format: "int64"
example: 42
ident:
type: "string"
- example: "f1f046a3-45c9-4b99-adce-000000000001"
+ example: "00000000-0000-0000-adce-000000000001"
state:
type: "string"
enum:
@@ -1381,9 +1381,9 @@ definitions:
- "redirect"
- "deleted"
example:
- redirect: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect: "00000000-0000-0000-adce-000000000002"
coden: "coden"
- ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ ident: "00000000-0000-0000-adce-000000000001"
extra: "{}"
name: "Journal of Important Results"
publisher: "Society of Curious Students"
@@ -1396,12 +1396,16 @@ definitions:
creator_entity:
type: "object"
required:
- - "full_name"
+ - "display_name"
properties:
orcid:
type: "string"
example: "0000-0002-1825-0097"
- full_name:
+ surname:
+ type: "string"
+ given_name:
+ type: "string"
+ display_name:
type: "string"
example: "Grace Hopper"
state:
@@ -1413,14 +1417,14 @@ definitions:
- "deleted"
ident:
type: "string"
- example: "f1f046a3-45c9-4b99-adce-000000000001"
+ example: "00000000-0000-0000-adce-000000000001"
revision:
type: "integer"
format: "int64"
example: 42
redirect:
type: "string"
- example: "f1f046a3-45c9-4b99-adce-000000000002"
+ example: "00000000-0000-0000-adce-000000000002"
editgroup_id:
type: "integer"
format: "int64"
@@ -1428,13 +1432,15 @@ definitions:
extra:
type: "object"
example:
- redirect: "f1f046a3-45c9-4b99-adce-000000000002"
- full_name: "Grace Hopper"
- ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ redirect: "00000000-0000-0000-adce-000000000002"
+ surname: "surname"
+ ident: "00000000-0000-0000-adce-000000000001"
extra: "{}"
editgroup_id: 16
orcid: "0000-0002-1825-0097"
state: "wip"
+ given_name: "given_name"
+ display_name: "Grace Hopper"
revision: 42
upperCaseName: "CREATOR_ENTITY"
file_entity:
@@ -1444,10 +1450,16 @@ definitions:
type: "array"
items:
type: "string"
+ mimetype:
+ type: "string"
+ example: "application/pdf"
url:
type: "string"
format: "url"
example: "https://example.edu/~frau/prcding.pdf"
+ sha256:
+ type: "string"
+ example: "a77e4c11a57f1d757fca5754a8f83b5d4ece49a2d28596889127c1a2f3f28832"
md5:
type: "string"
example: "d41efcc592d1e40ac13905377399eb9b"
@@ -1466,14 +1478,14 @@ definitions:
example: 16
redirect:
type: "string"
- example: "f1f046a3-45c9-4b99-adce-000000000002"
+ example: "00000000-0000-0000-adce-000000000002"
revision:
type: "integer"
format: "int64"
example: 42
ident:
type: "string"
- example: "f1f046a3-45c9-4b99-adce-000000000001"
+ example: "00000000-0000-0000-adce-000000000001"
state:
type: "string"
enum:
@@ -1482,19 +1494,21 @@ definitions:
- "redirect"
- "deleted"
example:
+ redirect: "00000000-0000-0000-adce-000000000002"
+ sha256: "a77e4c11a57f1d757fca5754a8f83b5d4ece49a2d28596889127c1a2f3f28832"
+ ident: "00000000-0000-0000-adce-000000000001"
+ url: "https://example.edu/~frau/prcding.pdf"
+ releases:
+ - "releases"
+ - "releases"
+ revision: 42
sha1: "f013d66c7f6817d08b7eb2a93e6d0440c1f3e7f8"
- redirect: "f1f046a3-45c9-4b99-adce-000000000002"
size: 1048576
- ident: "f1f046a3-45c9-4b99-adce-000000000001"
extra: "{}"
editgroup_id: 16
+ mimetype: "application/pdf"
state: "wip"
- url: "https://example.edu/~frau/prcding.pdf"
- releases:
- - "releases"
- - "releases"
md5: "d41efcc592d1e40ac13905377399eb9b"
- revision: 42
upperCaseName: "FILE_ENTITY"
release_entity:
type: "object"
@@ -1510,6 +1524,8 @@ definitions:
type: "array"
items:
$ref: "#/definitions/release_contrib"
+ language:
+ type: "string"
publisher:
type: "string"
issue:
@@ -1524,18 +1540,21 @@ definitions:
doi:
type: "string"
example: "10.1234/abcde.789"
- date:
+ release_date:
type: "string"
format: "date"
- release_type:
+ release_status:
type: "string"
example: "preprint"
+ release_type:
+ type: "string"
+ example: "book"
container_id:
type: "string"
- example: "f1f046a3-45c9-4b99-adce-000000000001"
+ example: "00000000-0000-0000-adce-000000000001"
work_id:
type: "string"
- example: "f1f046a3-45c9-4b99-adce-000000000001"
+ example: "00000000-0000-0000-adce-000000000001"
title:
type: "string"
state:
@@ -1547,14 +1566,14 @@ definitions:
- "deleted"
ident:
type: "string"
- example: "f1f046a3-45c9-4b99-adce-000000000001"
+ example: "00000000-0000-0000-adce-000000000001"
revision:
type: "integer"
format: "int64"
example: 42
redirect:
type: "string"
- example: "f1f046a3-45c9-4b99-adce-000000000002"
+ example: "00000000-0000-0000-adce-000000000002"
editgroup_id:
type: "integer"
format: "int64"
@@ -1562,38 +1581,50 @@ definitions:
extra:
type: "object"
example:
- date: "2000-01-23"
- redirect: "f1f046a3-45c9-4b99-adce-000000000002"
- work_id: "f1f046a3-45c9-4b99-adce-000000000001"
+ redirect: "00000000-0000-0000-adce-000000000002"
+ work_id: "00000000-0000-0000-adce-000000000001"
issue: "12"
- ident: "f1f046a3-45c9-4b99-adce-000000000001"
- release_type: "preprint"
+ ident: "00000000-0000-0000-adce-000000000001"
+ release_type: "book"
+ language: "language"
title: "title"
+ release_status: "preprint"
contribs:
- role: "role"
- creator_stub: "creator_stub"
creator_id: "creator_id"
- index: 6
+ index: 1
+ raw: "raw"
- role: "role"
- creator_stub: "creator_stub"
creator_id: "creator_id"
- index: 6
+ index: 1
+ raw: "raw"
revision: 42
volume: "volume"
pages: "pages"
refs:
- target_release_id: "target_release_id"
- stub: "stub"
+ year: 6
+ container_title: "container_title"
index: 0
+ raw: "raw"
+ title: "title"
+ locator: "p123"
+ key: "key"
- target_release_id: "target_release_id"
- stub: "stub"
+ year: 6
+ container_title: "container_title"
index: 0
+ raw: "raw"
+ title: "title"
+ locator: "p123"
+ key: "key"
+ release_date: "2000-01-23"
isbn13: "isbn13"
extra: "{}"
publisher: "publisher"
editgroup_id: 16
state: "wip"
- container_id: "f1f046a3-45c9-4b99-adce-000000000001"
+ container_id: "00000000-0000-0000-adce-000000000001"
doi: "10.1234/abcde.789"
upperCaseName: "RELEASE_ENTITY"
work_entity:
@@ -1609,14 +1640,14 @@ definitions:
example: 16
redirect:
type: "string"
- example: "f1f046a3-45c9-4b99-adce-000000000002"
+ example: "00000000-0000-0000-adce-000000000002"
revision:
type: "integer"
format: "int64"
example: 42
ident:
type: "string"
- example: "f1f046a3-45c9-4b99-adce-000000000001"
+ example: "00000000-0000-0000-adce-000000000001"
state:
type: "string"
enum:
@@ -1625,8 +1656,8 @@ definitions:
- "redirect"
- "deleted"
example:
- redirect: "f1f046a3-45c9-4b99-adce-000000000002"
- ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ redirect: "00000000-0000-0000-adce-000000000002"
+ ident: "00000000-0000-0000-adce-000000000001"
extra: "{}"
work_type: "work_type"
editgroup_id: 16
@@ -1646,14 +1677,14 @@ definitions:
example: 847
ident:
type: "string"
- example: "f1f046a3-45c9-4b99-adce-000000000001"
+ example: "00000000-0000-0000-adce-000000000001"
revision:
type: "integer"
format: "int64"
example: 42
redirect_ident:
type: "string"
- example: "f1f046a3-45c9-4b99-adce-000000000002"
+ example: "00000000-0000-0000-adce-000000000002"
editgroup_id:
type: "integer"
format: "int64"
@@ -1661,10 +1692,10 @@ definitions:
extra:
type: "object"
example:
- ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
upperCaseName: "ENTITY_EDIT"
@@ -1700,68 +1731,68 @@ definitions:
extra: "{}"
edits:
works:
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
creators:
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
files:
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
containers:
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
releases:
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
description: "description"
@@ -1781,12 +1812,29 @@ definitions:
format: "int64"
target_release_id:
type: "string"
- stub:
+ raw:
+ type: "string"
+ key:
type: "string"
+ year:
+ type: "integer"
+ format: "int64"
+ container_title:
+ type: "string"
+ title:
+ type: "string"
+ locator:
+ type: "string"
+ example: "p123"
example:
target_release_id: "target_release_id"
- stub: "stub"
+ year: 6
+ container_title: "container_title"
index: 0
+ raw: "raw"
+ title: "title"
+ locator: "p123"
+ key: "key"
upperCaseName: "RELEASE_REF"
release_contrib:
type: "object"
@@ -1796,15 +1844,15 @@ definitions:
format: "int64"
creator_id:
type: "string"
- creator_stub:
+ raw:
type: "string"
role:
type: "string"
example:
role: "role"
- creator_stub: "creator_stub"
creator_id: "creator_id"
- index: 6
+ index: 1
+ raw: "raw"
upperCaseName: "RELEASE_CONTRIB"
editgroup_edits:
properties:
@@ -1830,68 +1878,68 @@ definitions:
$ref: "#/definitions/entity_edit"
example:
works:
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
creators:
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
files:
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
containers:
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
releases:
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
- - ident: "f1f046a3-45c9-4b99-adce-000000000001"
+ - ident: "00000000-0000-0000-adce-000000000001"
edit_id: 847
extra: "{}"
- redirect_ident: "f1f046a3-45c9-4b99-adce-000000000002"
+ redirect_ident: "00000000-0000-0000-adce-000000000002"
editgroup_id: 16
revision: 42
upperCaseName: "EDITGROUP_EDITS"
@@ -1921,14 +1969,14 @@ x-entity-props:
- "deleted"
ident:
type: "string"
- example: "f1f046a3-45c9-4b99-adce-000000000001"
+ example: "00000000-0000-0000-adce-000000000001"
revision:
type: "integer"
example: 42
format: "int64"
redirect:
type: "string"
- example: "f1f046a3-45c9-4b99-adce-000000000002"
+ example: "00000000-0000-0000-adce-000000000002"
editgroup_id:
type: "integer"
example: 16
diff --git a/rust/fatcat-api/src/models.rs b/rust/fatcat-api/src/models.rs
index ab18e9b3..140e0c2e 100644
--- a/rust/fatcat-api/src/models.rs
+++ b/rust/fatcat-api/src/models.rs
@@ -163,8 +163,16 @@ pub struct CreatorEntity {
#[serde(skip_serializing_if = "Option::is_none")]
pub orcid: Option<String>,
- #[serde(rename = "full_name")]
- pub full_name: String,
+ #[serde(rename = "surname")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub surname: Option<String>,
+
+ #[serde(rename = "given_name")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub given_name: Option<String>,
+
+ #[serde(rename = "display_name")]
+ pub display_name: String,
// Note: inline enums are not fully supported by swagger-codegen
#[serde(rename = "state")]
@@ -193,10 +201,12 @@ pub struct CreatorEntity {
}
impl CreatorEntity {
- pub fn new(full_name: String) -> CreatorEntity {
+ pub fn new(display_name: String) -> CreatorEntity {
CreatorEntity {
orcid: None,
- full_name: full_name,
+ surname: None,
+ given_name: None,
+ display_name: display_name,
state: None,
ident: None,
revision: None,
@@ -343,10 +353,18 @@ pub struct FileEntity {
#[serde(skip_serializing_if = "Option::is_none")]
pub releases: Option<Vec<String>>,
+ #[serde(rename = "mimetype")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub mimetype: Option<String>,
+
#[serde(rename = "url")]
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
+ #[serde(rename = "sha256")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub sha256: Option<String>,
+
#[serde(rename = "md5")]
#[serde(skip_serializing_if = "Option::is_none")]
pub md5: Option<String>,
@@ -389,7 +407,9 @@ impl FileEntity {
pub fn new() -> FileEntity {
FileEntity {
releases: None,
+ mimetype: None,
url: None,
+ sha256: None,
md5: None,
sha1: None,
size: None,
@@ -413,9 +433,9 @@ pub struct ReleaseContrib {
#[serde(skip_serializing_if = "Option::is_none")]
pub creator_id: Option<String>,
- #[serde(rename = "creator_stub")]
+ #[serde(rename = "raw")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub creator_stub: Option<String>,
+ pub raw: Option<String>,
#[serde(rename = "role")]
#[serde(skip_serializing_if = "Option::is_none")]
@@ -427,7 +447,7 @@ impl ReleaseContrib {
ReleaseContrib {
index: None,
creator_id: None,
- creator_stub: None,
+ raw: None,
role: None,
}
}
@@ -443,6 +463,10 @@ pub struct ReleaseEntity {
#[serde(skip_serializing_if = "Option::is_none")]
pub contribs: Option<Vec<models::ReleaseContrib>>,
+ #[serde(rename = "language")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub language: Option<String>,
+
#[serde(rename = "publisher")]
#[serde(skip_serializing_if = "Option::is_none")]
pub publisher: Option<String>,
@@ -467,9 +491,13 @@ pub struct ReleaseEntity {
#[serde(skip_serializing_if = "Option::is_none")]
pub doi: Option<String>,
- #[serde(rename = "date")]
+ #[serde(rename = "release_date")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub release_date: Option<chrono::DateTime<chrono::Utc>>,
+
+ #[serde(rename = "release_status")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub date: Option<chrono::DateTime<chrono::Utc>>,
+ pub release_status: Option<String>,
#[serde(rename = "release_type")]
#[serde(skip_serializing_if = "Option::is_none")]
@@ -516,13 +544,15 @@ impl ReleaseEntity {
ReleaseEntity {
refs: None,
contribs: None,
+ language: None,
publisher: None,
issue: None,
pages: None,
volume: None,
isbn13: None,
doi: None,
- date: None,
+ release_date: None,
+ release_status: None,
release_type: None,
container_id: None,
work_id: work_id,
@@ -547,9 +577,29 @@ pub struct ReleaseRef {
#[serde(skip_serializing_if = "Option::is_none")]
pub target_release_id: Option<String>,
- #[serde(rename = "stub")]
+ #[serde(rename = "raw")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub raw: Option<String>,
+
+ #[serde(rename = "key")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub key: Option<String>,
+
+ #[serde(rename = "year")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub year: Option<i64>,
+
+ #[serde(rename = "container_title")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub container_title: Option<String>,
+
+ #[serde(rename = "title")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub title: Option<String>,
+
+ #[serde(rename = "locator")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub stub: Option<String>,
+ pub locator: Option<String>,
}
impl ReleaseRef {
@@ -557,7 +607,12 @@ impl ReleaseRef {
ReleaseRef {
index: None,
target_release_id: None,
- stub: None,
+ raw: None,
+ key: None,
+ year: None,
+ container_title: None,
+ title: None,
+ locator: None,
}
}
}
diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs
index 0706fc22..c167c067 100644
--- a/rust/src/api_server.rs
+++ b/rust/src/api_server.rs
@@ -155,7 +155,9 @@ fn creator_row2entity(ident: Option<CreatorIdentRow>, rev: CreatorRevRow) -> Res
None => (None, None, None),
};
Ok(CreatorEntity {
- full_name: rev.full_name,
+ display_name: rev.display_name,
+ given_name: rev.given_name,
+ surname: rev.surname,
orcid: rev.orcid,
state: state,
ident: ident_id,
@@ -189,9 +191,11 @@ fn file_row2entity(
Ok(FileEntity {
sha1: rev.sha1,
+ sha256: rev.sha256,
md5: rev.md5,
size: rev.size.map(|v| v as i64),
url: rev.url,
+ mimetype: rev.mimetype,
releases: Some(releases),
state: state,
ident: ident_id,
@@ -223,7 +227,12 @@ fn release_row2entity(
.iter()
.map(|r: &ReleaseRefRow| ReleaseRef {
index: r.index.clone(),
- stub: r.stub.clone(),
+ key: r.key.clone(),
+ raw: r.raw.clone(),
+ container_title: r.container_title.clone(),
+ year: r.year.clone(),
+ title: r.title.clone(),
+ locator: r.locator.clone(),
target_release_id: r.target_release_ident_id.map(|v| v.to_string()),
})
.collect();
@@ -236,7 +245,7 @@ fn release_row2entity(
.map(|c: &ReleaseContribRow| ReleaseContrib {
index: c.index,
role: c.role.clone(),
- creator_stub: c.stub.clone(),
+ raw: c.raw.clone(),
creator_id: c.creator_ident_id.map(|v| v.to_string()),
})
.collect();
@@ -244,7 +253,8 @@ fn release_row2entity(
Ok(ReleaseEntity {
title: rev.title,
release_type: rev.release_type,
- date: rev.date
+ release_status: rev.release_status,
+ release_date: rev.release_date
.map(|v| chrono::DateTime::from_utc(v.and_hms(0, 0, 0), chrono::Utc)),
doi: rev.doi,
isbn13: rev.isbn13,
@@ -253,6 +263,7 @@ fn release_row2entity(
issue: rev.issue,
container_id: rev.container_ident_id.map(|u| u.to_string()),
publisher: rev.publisher,
+ language: rev.language,
work_id: rev.work_ident_id.to_string(),
refs: Some(refs),
contribs: Some(contribs),
@@ -481,16 +492,18 @@ impl Server {
};
let edit: CreatorEditRow = diesel::sql_query(
- "WITH rev AS ( INSERT INTO creator_rev (full_name, orcid, extra_json)
- VALUES ($1, $2, $3)
+ "WITH rev AS ( INSERT INTO creator_rev (display_name, given_name, surname, orcid, extra_json)
+ VALUES ($1, $2, $3, $4, $5)
RETURNING id ),
ident AS ( INSERT INTO creator_ident (rev_id)
VALUES ((SELECT rev.id FROM rev))
RETURNING id )
INSERT INTO creator_edit (editgroup_id, ident_id, rev_id) VALUES
- ($4, (SELECT ident.id FROM ident), (SELECT rev.id FROM rev))
+ ($6, (SELECT ident.id FROM ident), (SELECT rev.id FROM rev))
RETURNING *",
- ).bind::<diesel::sql_types::Text, _>(entity.full_name)
+ ).bind::<diesel::sql_types::Text, _>(entity.display_name)
+ .bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.given_name)
+ .bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.surname)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.orcid)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Json>, _>(entity.extra)
.bind::<diesel::sql_types::BigInt, _>(editgroup_id)
@@ -521,19 +534,21 @@ impl Server {
let edit: FileEditRow =
diesel::sql_query(
- "WITH rev AS ( INSERT INTO file_rev (size, sha1, md5, url, extra_json)
- VALUES ($1, $2, $3, $4, $5)
+ "WITH rev AS ( INSERT INTO file_rev (size, sha1, sha256, md5, url, mimetype, extra_json)
+ VALUES ($1, $2, $3, $4, $5, $6, $7)
RETURNING id ),
ident AS ( INSERT INTO file_ident (rev_id)
VALUES ((SELECT rev.id FROM rev))
RETURNING id )
INSERT INTO file_edit (editgroup_id, ident_id, rev_id) VALUES
- ($6, (SELECT ident.id FROM ident), (SELECT rev.id FROM rev))
+ ($8, (SELECT ident.id FROM ident), (SELECT rev.id FROM rev))
RETURNING *",
).bind::<diesel::sql_types::Nullable<diesel::sql_types::Int8>, _>(entity.size)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.sha1)
+ .bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.sha256)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.md5)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.url)
+ .bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.mimetype)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Json>, _>(entity.extra)
.bind::<diesel::sql_types::BigInt, _>(editgroup_id)
.get_result(conn)?;
@@ -590,19 +605,20 @@ impl Server {
};
let edit: ReleaseEditRow = diesel::sql_query(
- "WITH rev AS ( INSERT INTO release_rev (title, release_type, date, doi, isbn13, volume, pages, issue, work_ident_id, container_ident_id, publisher, extra_json)
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)
+ "WITH rev AS ( INSERT INTO release_rev (title, release_type, release_status, release_date, doi, isbn13, volume, pages, issue, work_ident_id, container_ident_id, publisher, language, extra_json)
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)
RETURNING id ),
ident AS ( INSERT INTO release_ident (rev_id)
VALUES ((SELECT rev.id FROM rev))
RETURNING id )
INSERT INTO release_edit (editgroup_id, ident_id, rev_id) VALUES
- ($13, (SELECT ident.id FROM ident), (SELECT rev.id FROM rev))
+ ($15, (SELECT ident.id FROM ident), (SELECT rev.id FROM rev))
RETURNING *",
).bind::<diesel::sql_types::Text, _>(entity.title)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.release_type)
+ .bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.release_status)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Date>, _>(
- entity.date.map(|v| v.naive_utc().date()))
+ entity.release_date.map(|v| v.naive_utc().date()))
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.doi)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.isbn13)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.volume)
@@ -611,6 +627,7 @@ impl Server {
.bind::<diesel::sql_types::Uuid, _>(work_id)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Uuid>, _>(container_id)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.publisher)
+ .bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.language)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Json>, _>(entity.extra)
.bind::<diesel::sql_types::BigInt, _>(editgroup_id)
.get_result(conn)?;
@@ -629,7 +646,12 @@ impl Server {
.clone()
.map(|v| uuid::Uuid::parse_str(&v).expect("valid UUID")),
index: r.index,
- stub: r.stub.clone(),
+ key: r.key.clone(),
+ container_title: r.container_title.clone(),
+ year: r.year,
+ title: r.title.clone(),
+ locator: r.locator.clone(),
+ raw: r.raw.clone(),
})
.collect();
let ref_rows: Vec<ReleaseRefRow> = insert_into(release_ref::table)
@@ -656,7 +678,7 @@ impl Server {
.map(|v| uuid::Uuid::parse_str(&v).expect("valid UUID")),
index: c.index,
role: c.role.clone(),
- stub: c.creator_stub.clone(),
+ raw: c.raw.clone(),
})
.collect();
let contrib_rows: Vec<ReleaseContribRow> = insert_into(release_contrib::table)
diff --git a/rust/src/database_models.rs b/rust/src/database_models.rs
index b62492ab..2d72795e 100644
--- a/rust/src/database_models.rs
+++ b/rust/src/database_models.rs
@@ -111,7 +111,9 @@ entity_structs!(
pub struct CreatorRevRow {
pub id: i64,
pub extra_json: Option<serde_json::Value>,
- pub full_name: String,
+ pub display_name: String,
+ pub given_name: Option<String>,
+ pub surname: Option<String>,
pub orcid: Option<String>,
}
@@ -129,8 +131,10 @@ pub struct FileRevRow {
pub extra_json: Option<serde_json::Value>,
pub size: Option<i64>,
pub sha1: Option<String>,
+ pub sha256: Option<String>,
pub md5: Option<String>,
pub url: Option<String>,
+ pub mimetype: Option<String>,
}
entity_structs!("file_edit", FileEditRow, "file_ident", FileIdentRow);
@@ -144,13 +148,15 @@ pub struct ReleaseRevRow {
pub container_ident_id: Option<Uuid>,
pub title: String,
pub release_type: Option<String>,
- pub date: Option<chrono::NaiveDate>,
+ pub release_status: Option<String>,
+ pub release_date: Option<chrono::NaiveDate>,
pub doi: Option<String>,
pub isbn13: Option<String>,
pub volume: Option<String>,
pub pages: Option<String>,
pub issue: Option<String>,
pub publisher: Option<String>,
+ pub language: Option<String>,
}
entity_structs!(
@@ -179,7 +185,7 @@ pub struct ReleaseContribRow {
pub creator_ident_id: Option<Uuid>,
pub role: Option<String>,
pub index: Option<i64>,
- pub stub: Option<String>,
+ pub raw: Option<String>,
}
#[derive(Debug, Insertable)]
@@ -189,7 +195,7 @@ pub struct ReleaseContribNewRow {
pub creator_ident_id: Option<Uuid>,
pub role: Option<String>,
pub index: Option<i64>,
- pub stub: Option<String>,
+ pub raw: Option<String>,
}
#[derive(Debug, Queryable, Identifiable, Associations, AsChangeset)]
@@ -199,7 +205,12 @@ pub struct ReleaseRefRow {
pub release_rev: i64,
pub target_release_ident_id: Option<Uuid>,
pub index: Option<i64>,
- pub stub: Option<String>,
+ pub key: Option<String>,
+ pub raw: Option<String>,
+ pub container_title: Option<String>,
+ pub year: Option<i64>,
+ pub title: Option<String>,
+ pub locator: Option<String>,
}
#[derive(Debug, Insertable, AsChangeset)]
@@ -208,7 +219,12 @@ pub struct ReleaseRefNewRow {
pub release_rev: i64,
pub target_release_ident_id: Option<Uuid>,
pub index: Option<i64>,
- pub stub: Option<String>,
+ pub key: Option<String>,
+ pub raw: Option<String>,
+ pub container_title: Option<String>,
+ pub year: Option<i64>,
+ pub title: Option<String>,
+ pub locator: Option<String>,
}
#[derive(Debug, Queryable, Insertable, Associations, AsChangeset)]
diff --git a/rust/src/database_schema.rs b/rust/src/database_schema.rs
index 2541bcd8..d60bb6ee 100644
--- a/rust/src/database_schema.rs
+++ b/rust/src/database_schema.rs
@@ -62,7 +62,9 @@ table! {
creator_rev (id) {
id -> Int8,
extra_json -> Nullable<Json>,
- full_name -> Text,
+ display_name -> Text,
+ given_name -> Nullable<Text>,
+ surname -> Nullable<Text>,
orcid -> Nullable<Text>,
}
}
@@ -118,8 +120,10 @@ table! {
extra_json -> Nullable<Json>,
size -> Nullable<Int8>,
sha1 -> Nullable<Text>,
+ sha256 -> Nullable<Text>,
md5 -> Nullable<Text>,
url -> Nullable<Text>,
+ mimetype -> Nullable<Text>,
}
}
@@ -130,7 +134,7 @@ table! {
creator_ident_id -> Nullable<Uuid>,
role -> Nullable<Text>,
index -> Nullable<Int8>,
- stub -> Nullable<Text>,
+ raw -> Nullable<Text>,
}
}
@@ -160,7 +164,12 @@ table! {
release_rev -> Int8,
target_release_ident_id -> Nullable<Uuid>,
index -> Nullable<Int8>,
- stub -> Nullable<Text>,
+ key -> Nullable<Text>,
+ raw -> Nullable<Text>,
+ container_title -> Nullable<Text>,
+ year -> Nullable<Int8>,
+ title -> Nullable<Text>,
+ locator -> Nullable<Text>,
}
}
@@ -172,13 +181,15 @@ table! {
container_ident_id -> Nullable<Uuid>,
title -> Text,
release_type -> Nullable<Text>,
- date -> Nullable<Date>,
+ release_status -> Nullable<Text>,
+ release_date -> Nullable<Date>,
doi -> Nullable<Text>,
isbn13 -> Nullable<Text>,
volume -> Nullable<Text>,
pages -> Nullable<Text>,
issue -> Nullable<Text>,
publisher -> Nullable<Text>,
+ language -> Nullable<Text>,
}
}
diff --git a/rust/tests/test_api_server.rs b/rust/tests/test_api_server.rs
index 36605661..9393c09b 100644
--- a/rust/tests/test_api_server.rs
+++ b/rust/tests/test_api_server.rs
@@ -186,7 +186,7 @@ fn test_post_creator() {
request::post(
"http://localhost:9411/v0/creator",
headers,
- r#"{"full_name": "some person"}"#,
+ r#"{"display_name": "some person"}"#,
&router,
),
status::Created,
@@ -215,7 +215,10 @@ fn test_post_file() {
headers,
r#"{"size": 76543,
"sha1": "f013d66c7f6817d08b7eb2a93e6d0440c1f3e7f8",
+ "md5": "f013d66c7f6817d08b7eb2a93e6d0440c1f3e7f8",
+ "sha256": "f013d66c7f6817d08b7eb2a93e6d0440c1f3e7f8",
"url": "http://archive.org/asdf.txt",
+ "mimetype": "application/pdf",
"releases": [
"00000000-0000-0000-4444-000000000001",
"00000000-0000-0000-4444-000000000002"
@@ -263,17 +266,17 @@ fn test_post_release() {
"container_id": "00000000-0000-0000-1111-000000000001",
"refs": [{
"index": 3,
- "stub": "just a string"
+ "raw": "just a string"
},{
- "stub": "just a string"
+ "raw": "just a string"
}],
"contribs": [{
"index": 1,
- "creator_stub": "textual description of contributor (aka, name)",
+ "raw": "textual description of contributor (aka, name)",
"creator_id": "00000000-0000-0000-2222-000000000001",
"contrib_type": "author"
},{
- "creator_stub": "shorter"
+ "raw": "shorter"
}],
"extra": { "source": "speculation" }
}"#,