ZenodoManager: ZenodoManager

ZenodoManagerR Documentation

ZenodoManager

Description

ZenodoManager

ZenodoManager

Format

R6Class object.

Value

Object of R6Class for modelling an ZenodoManager

Super class

zen4R::zen4RLogger -> ZenodoManager

Public fields

sandbox

Zenodo manager sandbox status, TRUE if we interact with Sandbox infra

anonymous

Zenodo manager anonymous status, TRUE when no token is specified

Methods

Public methods

Inherited methods

Method new()

initializes the Zenodo Manager

Usage
ZenodoManager$new(
  url = "https://zenodo.org/api",
  token = zenodo_pat(),
  sandbox = FALSE,
  logger = NULL,
  keyring_backend = "env"
)
Arguments
url

Zenodo API URL. By default, the url is set to "https://zenodo.org/api". For tests, the Zenodo sandbox API URL can be used: https://sandbox.zenodo.org/api

token

the user token. By default an attempt will be made to retrieve token using zenodo_pat

sandbox

Indicates if the Zenodo sandbox platform should be used. Default is FALSE

logger

logger type. The logger can be either NULL, "INFO" (with minimum logs), or "DEBUG" (for complete curl http calls logs)

keyring_backend

The keyring backend used to store user token. The keyring_backend can be set to use a different backend for storing the Zenodo token with keyring (Default value is 'env').


Method getToken()

Get user token

Usage
ZenodoManager$getToken()
Returns

the token, object of class character


Method getLanguages()

Get Languages supported by Zenodo.

Usage
ZenodoManager$getLanguages(pretty = TRUE)
Arguments
pretty

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

Returns

list of languages as data.frame or list


Method getLanguageById()

Get language by Id.

Usage
ZenodoManager$getLanguageById(id)
Arguments
id

license id

Returns

the license


Method getLicenses()

Get Licenses supported by Zenodo.

Usage
ZenodoManager$getLicenses(pretty = TRUE)
Arguments
pretty

Prettify the output. 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.

Returns

list of licenses as data.frame or list


Method getLicenseById()

Get license by Id.

Usage
ZenodoManager$getLicenseById(id)
Arguments
id

license id

Returns

the license


Method getResourceTypes()

Get Resource types supported by Zenodo.

Usage
ZenodoManager$getResourceTypes(pretty = TRUE)
Arguments
pretty

Prettify the output. By default the argument pretty is set to TRUE which will returns the list of resource types as data.frame. Set pretty = FALSE to get the raw list of resource types

Returns

list of resource types as data.frame or list


Method getResourceTypeById()

Get resource type by Id.

Usage
ZenodoManager$getResourceTypeById(id)
Arguments
id

resource type id

Returns

the resource type


Method getCommunities()

Get Communities supported by Zenodo.

Usage
ZenodoManager$getCommunities(pretty = TRUE, q = "", size = 500)
Arguments
pretty

Prettify the output. 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

q

an ElasticSearch compliant query, object of class character. Default is emtpy. Note that the Zenodo API restrains a maximum number of 10,000 records to be retrieved. Consequently, not all communities can be listed from Zenodo, a query has to be specified.

size

number of communities to be returned. By default equal to 500

Returns

list of communities as data.frame or list


Method getCommunityById()

Get community by Id.

Usage
ZenodoManager$getCommunityById(id)
Arguments
id

community id

Returns

the community


Method getGrants()

Get Grants supported by Zenodo. DEPRECATED: replaced by getAwards

Usage
ZenodoManager$getGrants(q = "", pretty = TRUE, size = 500)
Arguments
q

an ElasticSearch compliant query, object of class character. Default is emtpy. Note that the Zenodo API restrains a maximum number of 10,000 records to be retrieved. Consequently, not all grants can be listed from Zenodo, a query has to be specified.

pretty

Prettify the output. 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

size

number of grants to be returned. By default equal to 500.

Returns

list of grants as data.frame or list


Method getAwards()

Get Awards supported by Zenodo.

Usage
ZenodoManager$getAwards(q = "", pretty = TRUE, size = 500)
Arguments
q

an ElasticSearch compliant query, object of class character. Default is emtpy. Note that the Zenodo API restrains a maximum number of 10,000 records to be retrieved. Consequently, not all awards can be listed from Zenodo, a query has to be specified.

pretty

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

size

number of awards to be returned. By default equal to 500.

Returns

list of awards as data.frame or list


Method getGrantsByName()

Get grants by name. DEPRECATED: replaced by getAwardByName

Usage
ZenodoManager$getGrantsByName(name, pretty = TRUE)
Arguments
name

name

pretty

Prettify the output. 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

Returns

list of grants as data.frame or list


Method getAwardsByName()

Get awards by name.

Usage
ZenodoManager$getAwardsByName(name, pretty = TRUE)
Arguments
name

name

pretty

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

Returns

list of awards as data.frame or list


Method getGrantById()

Get grant by Id.DEPRECATED: replaced by getAwardById

Usage
ZenodoManager$getGrantById(id)
Arguments
id

grant id

Returns

the grant


Method getAwardById()

Get award by Id.

Usage
ZenodoManager$getAwardById(id)
Arguments
id

award id

Returns

the award


Method getAffiliations()

Get Affiliations supported by Zenodo.

Usage
ZenodoManager$getAffiliations(q = "", pretty = TRUE, size = 500)
Arguments
q

an ElasticSearch compliant query, object of class character. Default is emtpy. Note that the Zenodo API restrains a maximum number of 10,000 records to be retrieved. Consequently, not all affiliations can be listed from Zenodo, a query has to be specified.

pretty

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

size

number of affiliations to be returned. By default equal to 500.

Returns

list of affiliations as data.frame or list


Method getAffiliationByName()

Get affiliations by name.

Usage
ZenodoManager$getAffiliationByName(name, pretty = TRUE)
Arguments
name

name

pretty

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

Returns

list of affiliations as data.frame or list


Method getAffiliationById()

Get affiliation by Id.

Usage
ZenodoManager$getAffiliationById(id)
Arguments
id

affiliation id

Returns

the affiliation


Method getFunders()

Get Funders supported by Zenodo based on a query.

Usage
ZenodoManager$getFunders(q = "", pretty = TRUE, size = 500)
Arguments
q

an ElasticSearch compliant query, object of class character. Default is emtpy. Note that the Zenodo API restrains a maximum number of 10,000 records to be retrieved. Consequently, not all funders can be listed from Zenodo, a query has to be specified.

pretty

Prettify the output. 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

size

number of funders to be returned. By default equal to 500

Returns

list of funders as data.frame or list


Method getFundersByName()

Get funders by name.

Usage
ZenodoManager$getFundersByName(name, pretty = TRUE)
Arguments
name

name

pretty

Prettify the output. 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

Returns

list of funders as data.frame or list


Method getFunderById()

Get funder by Id.

Usage
ZenodoManager$getFunderById(id)
Arguments
id

funder id

Returns

the funder


Method getDepositions()

Get the list of Zenodo records deposited in your Zenodo workspace (user records). By default 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. The argument exact specifies that an exact matching is wished, in which case paginated search will be disabled (only the first search page will be returned). Examples of ElasticSearch queries for Zenodo can be found at https://help.zenodo.org/guides/search/.

Usage
ZenodoManager$getDepositions(
  q = "",
  size = 10,
  all_versions = FALSE,
  exact = TRUE,
  quiet = FALSE
)
Arguments
q

Elastic-Search-compliant query, as object of class character. Default is ""

size

number of depositions to be retrieved per request (paginated). Default is 10

all_versions

object of class logical indicating if all versions of deposits have to be retrieved. Default is FALSE

exact

object of class logical indicating if exact matching has to be applied. Default is TRUE

quiet

object of class logical indicating if logs have to skipped. Default is FALSE

Returns

a list of ZenodoRecord


Method getDepositionByConceptDOI()

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

Usage
ZenodoManager$getDepositionByConceptDOI(conceptdoi)
Arguments
conceptdoi

the concept DOI, object of class character

Returns

an object of class ZenodoRecord if record does exist, NULL otherwise


Method getDepositionByDOI()

Get a Zenodo deposition record by DOI.

Usage
ZenodoManager$getDepositionByDOI(doi)
Arguments
doi

the DOI, object of class character

Returns

an object of class ZenodoRecord if record does exist, NULL otherwise


Method getDepositionById()

Get a Zenodo deposition record by ID.

Usage
ZenodoManager$getDepositionById(recid)
Arguments
recid

the record ID, object of class character

Returns

an object of class ZenodoRecord if record does exist, NULL otherwise


Method getDepositionByConceptId()

Get a Zenodo deposition record by concept ID.

Usage
ZenodoManager$getDepositionByConceptId(conceptrecid)
Arguments
conceptrecid

the record concept ID, object of class character

Returns

an object of class ZenodoRecord if record does exist, NULL otherwise


Method depositRecord()

Deposits a record on Zenodo.

Usage
ZenodoManager$depositRecord(record, publish = FALSE)
Arguments
record

the record to deposit, object of class ZenodoRecord

publish

object of class logical indicating if record has to be published (default FALSE). Can be set to TRUE (to use CAUTIOUSLY, only if you want to publish your record)

Returns

TRUE if deposited (and eventually published), FALSE otherwise


Method depositRecordVersion()

Deposits a record version on Zenodo. For details about the behavior of this function, see https://developers.zenodo.org/#new-version

Usage
ZenodoManager$depositRecordVersion(
  record,
  delete_latest_files = TRUE,
  files = list(),
  publish = FALSE
)
Arguments
record

the record version to deposit, object of class ZenodoRecord

delete_latest_files

object of class logical indicating if latest files have to be deleted. Default is TRUE

files

a list of files to be uploaded with the new record version

publish

object of class logical indicating if record has to be published (default FALSE)

Returns

TRUE if deposited (and eventually published), FALSE otherwise


Method deleteRecord()

Deletes a record given its ID

Usage
ZenodoManager$deleteRecord(recordId)
Arguments
recordId

the ID of the record to be deleted

Returns

TRUE if deleted, FALSE otherwise


Method deleteRecordByDOI()

Deletes a record by DOI

Usage
ZenodoManager$deleteRecordByDOI(doi)
Arguments
doi

the DOI of the record to be deleted

Returns

TRUE if deleted, FALSE otherwise


Method deleteRecords()

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 https://help.zenodo.org/guides/search/.

Usage
ZenodoManager$deleteRecords(q = "", size = 10)
Arguments
q

an ElasticSearch compliant query, object of class character

size

number of records to be passed to $getDepositions method

Returns

TRUE if all records have been deleted, FALSE otherwise


Method 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.

Usage
ZenodoManager$createEmptyRecord()
Returns

an object of class ZenodoRecord


Method editRecord()

Unlocks a record already submitted. Required to edit metadata of a Zenodo record already published.

Usage
ZenodoManager$editRecord(recordId)
Arguments
recordId

the ID of the record to unlock and set in editing mode.

Returns

an object of class ZenodoRecord


Method discardChanges()

Discards changes on a Zenodo record.

Usage
ZenodoManager$discardChanges(recordId)
Arguments
recordId

the ID of the record for which changes have to be discarded.

Returns

an object of class ZenodoRecord


Method publishRecord()

Publishes a Zenodo record.

Usage
ZenodoManager$publishRecord(recordId)
Arguments
recordId

the ID of the record to be published.

Returns

an object of class ZenodoRecord


Method getFiles()

Get list of files attached to a Zenodo record.

Usage
ZenodoManager$getFiles(recordId)
Arguments
recordId

the ID of the record.

Returns

list of files


Method getFile()

Get a file record metadata.

Usage
ZenodoManager$getFile(recordId, filename)
Arguments
recordId

the ID of the record.

filename

filename

Returns

the file metadata


Method startFileUpload()

Start a file upload. The method will create a key for the file to be uploaded This method is essentially for internal purpose, and is called directly in uploadFile for user convenience and for backward compatibility with the legacy Zenodo API.

Usage
ZenodoManager$startFileUpload(path, recordId)
Arguments
path

Local path of the file

recordId

ID of the record


Method completeFileUpload()

Completes a file upload. The method will complete a file upload through a commit operation This method is essentially for internal purpose, and is called directly in uploadFile for user convenience and for backward compatibility with the legacy Zenodo API.

Usage
ZenodoManager$completeFileUpload(path, recordId)
Arguments
path

Local path of the file

recordId

ID of the record


Method uploadFile()

Uploads a file to a Zenodo record. With the new Zenodo Invenio RDM API, this method internally calls startFileUpload to create a file record (with a filename key) at start, followed by the actual file content upload. At this stage, the file upload is in "pending" status. At the end, the function calls completeFileUpload to commit the file which status becomes "completed".

Usage
ZenodoManager$uploadFile(path, recordId = NULL, record = NULL)
Arguments
path

Local path of the file

recordId

ID of the record. Deprecated, use record instead to take advantage of the new Zenodo bucket upload API.

record

object of class ZenodoRecord


Method deleteFile()

Deletes a file for a record. With the new Zenodo Invenio RDM API, if a file is deleted although its status was pending, only the upload content is deleted, and the file upload record (identified by a filename key) is kept. If the status was completed (with a file commit), the file record is deleted.

Usage
ZenodoManager$deleteFile(recordId, filename)
Arguments
recordId

ID of the record

filename

name of the file to be deleted


Method getRecords()

Get the list of Zenodo records. By defaut the list of records 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. The argument exact specifies that an exact matching is wished, in which case paginated search will be disabled (only the first search page will be returned). Examples of ElasticSearch queries for Zenodo can be found at https://help.zenodo.org/guides/search/.

Usage
ZenodoManager$getRecords(q = "", size = 10, all_versions = FALSE, exact = TRUE)
Arguments
q

Elastic-Search-compliant query, as object of class character. Default is ""

size

number of records to be retrieved per request (paginated). Default is 10

all_versions

object of class logical indicating if all versions of records have to be retrieved. Default is FALSE

exact

object of class logical indicating if exact matching has to be applied. Default is TRUE

quiet

object of class logical indicating if logs have to skipped. Default is FALSE

Returns

a list of ZenodoRecord


Method getRecordByConceptDOI()

Get Record by concept DOI

Usage
ZenodoManager$getRecordByConceptDOI(conceptdoi)
Arguments
conceptdoi

the concept DOI

Returns

a object of class ZenodoRecord


Method getRecordByDOI()

Get Record by DOI

Usage
ZenodoManager$getRecordByDOI(doi)
Arguments
doi

the DOI

Returns

a object of class ZenodoRecord


Method getRecordById()

Get Record by ID

Usage
ZenodoManager$getRecordById(recid)
Arguments
recid

the record ID

Returns

a object of class ZenodoRecord


Method getRecordByConceptId()

Get Record by concept ID

Usage
ZenodoManager$getRecordByConceptId(conceptrecid)
Arguments
conceptrecid

the concept ID

Returns

a object of class ZenodoRecord


Method clone()

The objects of this class are cloneable with this method.

Usage
ZenodoManager$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Note

Main user class to be used with zen4R

Author(s)

Emmanuel Blondel <emmanuel.blondel1@gmail.com>

Examples

## 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", record = myrec)
  
  #list files
  zen_files <- ZENODO$getFiles(myrec$id)
  
  #delete a file?
  ZENODO$deleteFile(myrec$id, zen_files[[1]]$id)

## End(Not run)


eblondel/zen4R documentation built on March 26, 2024, 4:17 p.m.