Learn R Programming

zen4R (version 0.1)

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

getDepositions()

Get the list of Zenodo records deposited in your Zenodo workspace

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)

deleteRecord(recordId)

Deletes a Zenodo record based on its identifier.

deleteRecords()

Deletes all Zenodo deposited (unpublished) records.

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.

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