Learn R Programming

zen4R (version 0.2)

ZenodoManager: ZenodoManager

Description

ZenodoManager

Usage

ZenodoManager

Arguments

Value

Object of R6Class for modelling an ZenodoManager

Format

R6Class object.

Methods

new(url, token, logger)

This method is used to instantiate an ZenodoManager. By default, the url is set to "https://zenodo.org/api". The token is mandatory in order to use Zenodo API. The logger can be either NULL, "INFO" (with minimum logs), or "DEBUG" (for complete curl http calls logs)

getLicenses(pretty)

Get the list of licenses. By default the argument pretty is set to TRUE which will returns the list of licenses as data.frame. Set pretty = FALSE to get the raw list of licenses.

getLicenseById(id)

Get license by Id

getCommunities(pretty)

Get the list of communities. By default the argument pretty is set to TRUE which will returns the list of communities as data.frame. Set pretty = FALSE to get the raw list of communities.

getCommunityById(id)

Get community by Id

getGrants(pretty)

Get the list of grants. By default the argument pretty is set to TRUE which will returns the list of grants as data.frame. Set pretty = FALSE to get the raw list of grants.

getGrantById(id)

Get grant by Id

getFunders(pretty)

Get the list of funders. By default the argument pretty is set to TRUE which will returns the list of funders as data.frame. Set pretty = FALSE to get the raw list of funders.

getFunderById(id)

Get funder by Id

getDepositions(q, size, all_versions)

Get the list of Zenodo records deposited in your Zenodo workspace. By defaut the list of depositions will be returned by page with a size of 10 results per page (default size of the Zenodo API). The parameter q allows to specify an ElasticSearch-compliant query to filter depositions (default query is empty to retrieve all records). The argument all_versions, if set to TRUE allows to get all versions of records as part of the depositions list. Examples of ElasticSearch queries for Zenodo can be found at http://help.zenodo.org/guides/search/.

getDepositionByConceptDOI(conceptdoi)

Get a Zenodo deposition record by concept DOI (generic DOI common to all deposition record versions)

getDepositionByDOI(doi)

Get a Zenodo deposition record by DOI.

getDepositionById(recid)

Get a Zenodo deposition record by its Zenodo specific record id.

depositRecord(record, publish)

A method to deposit/update a Zenodo record. The record should be an object of class ZenodoRecord. The method returns the deposited record of class ZenodoRecord. The parameter publish (default value is FALSE) can be set to TRUE (to use CAUTIOUSLY, only if you want to publish your record)

depositRecordVersion(record, publish)

A method to deposit a new version for a published record. For details about the behavior of this function, see https://developers.zenodo.org/#new-version

deleteRecord(recordId)

Deletes a Zenodo record based on its identifier.

deleteRecordByDOI(doi)

Deletes a Zenodo record based on its DOI. This DOI is necessarily a pre-reserved DOI corresponding to a draft record, and not a published DOI, as Zenodo does not allow to delete a record already published.

deleteRecords(q)

Deletes all Zenodo deposited (unpublished) records. The parameter q allows to specify an ElasticSearch-compliant query to filter depositions (default query is empty to retrieve all records). Examples of ElasticSearch queries for Zenodo can be found at http://help.zenodo.org/guides/search/.

createEmptyRecord()

Creates an empty record in the Zenodo deposit. Returns the record newly created in Zenodo, as an object of class ZenodoRecord with an assigned identifier.

editRecord(recordId)

Unlocks a record already submitted. This is required to edit metadata of a Zenodo record already published.

discardChanges(recordId)

Discards changes operated on a record.

publishRecord(recordId)

Publishes a deposited record online.

getFiles(recordId)

Get the list of uploaded files for a deposited record

uploadFile(path, recordId)

Uploads a file for a given Zenodo deposited record

deleteFile(recordId, fileId)

Deletes a file for a given Zenodo deposited record

Examples

Run this code
# NOT RUN {
  ZENODO <- ZenodoManager$new(
     url = "https://sandbox.zenodo.org/api",
     token = "<your_token>",
     logger = "INFO"
  )
  
  #create (deposit) an empty record
  newRec <- ZENODO$createEmptyRecord()
  
  #create and fill a local (not yet deposited) record
  myrec <- ZenodoRecord$new()
  myrec$setTitle("my R package")
  myrec$setDescription("A description of my R package")
  myrec$setUploadType("software")
  myrec$addCreator(
    firstname = "John", lastname = "Doe",
    affiliation = "Independent", orcid = "0000-0000-0000-0000"
   )
  myrec$setLicense("mit")
  myrec$setAccessRight("open")
  myrec$setDOI("mydoi") #use this method if your DOI has been assigned elsewhere, outside Zenodo
  myrec$addCommunity("ecfunded")
  
  #deposit the record 
  myrec <- ZENODO$depositRecord(myrec)
  
  #publish a record (with caution!!)
  #this method will PUBLISH the deposition done earlier
  ZENODO$publishRecord(myrec$id)
  #With even more caution the publication can be done with a shortcut argument at deposit time
  ZENODO$depositRecord(myrec, publish = TRUE)
  
  #delete a record (by id)
  #this methods only works for unpublished deposits 
  #(if a record is published, it cannot be deleted anymore!)
  ZENODO$deleteRecord(myrec$id)
  
  #HOW TO UPLOAD FILES to a deposit
  
  #upload a file
  ZENODO$uploadFile("path/to/your/file", myrec$id)
  
  #list files
  zen_files <- ZENODO$getFiles(myrec$id)
  
  #delete a file?
  ZENODO$deleteFile(myrec$id, zen_files[[1]]$id)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab