ropenscilabs / deposits

R Client for access to multiple data repository services
https://docs.ropensci.org/deposits/
Other
38 stars 3 forks source link

deposit_version function #77

Closed mpadge closed 1 year ago

mpadge commented 1 year ago

Figshare automatically puts an integer version number on new deposits, starting at "0". The version endopint increments this, and allows uploading of new metadata associated with new version.

PUT "https://api.figshare.com/v2/account/articles/{article_id}/versions/{version_id}/"

It's unclear whether {version_id} should be current version, or desired new version? It also clearly only works for published articles, so can't easily be tested at the moment.


Zenodo:

POST /api/deposit/depositions/:id/actions/newversion

This only works for public deposits, but works like this:

cli <- depositsClient$new (service = "zenodo", sandbox = TRUE)
cli$deposit_retrieve (cli$deposits$id [1])
url <- get_service_url (cli, deposit_id = cli$id)
url <- paste0 (url, "/actions/newversion")

req <- create_httr2_helper (url, cli$headers$Authorization, "POST")
resp <- httr2::req_perform (req)

hostdata <- httr2::resp_body_json (resp)
latest <- hostdata$links$latest

latest is then the new unique id, but that is not listed as an extra deposit, just as a version of the original deposit. All actions still have to be performed on the original deposit with the original deposit id. No metadata can be passed to the newversion call (it is simply ignored), and the new version directly inherits all the old metadata.

First action needed is to allow editing:

POST /api/deposit/depositions/:id/actions/edit

The original deposit will revert to "status: unsubmitted", and files and metadata can then be edited as desired with usual methods. Editing can also be discarded by calling:

POST /api/deposit/depositions/:id/actions/discard

When ready, new version can then be published via publish method.

mpadge commented 1 year ago

Note that this can't be applied to figshare, as that just does automatic versions on update -> publish, with incremental integer version numbers. This is currently only applicable to zenodo.

mpadge commented 1 year ago

PR #85 implements all of the infrastructure. Now just need to add a "publishing and versioning" vignette to close this.