| ZenodoManager | R Documentation |
ZenodoManager
ZenodoManager
R6Class object.
Object of R6Class for modelling an ZenodoManager
zen4R::zen4RLogger -> ZenodoManager
sandboxZenodo manager sandbox status, TRUE if we interact with Sandbox infra
anonymousZenodo manager anonymous status, TRUE when no token is specified
new()initializes the Zenodo Manager
ZenodoManager$new( url = "https://zenodo.org/api", token = zenodo_pat(), sandbox = FALSE, logger = NULL, keyring_backend = "env" )
urlZenodo 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
tokenthe user token. By default an attempt will be made to retrieve token using zenodo_pat
sandboxIndicates if the Zenodo sandbox platform should be used. Default is FALSE
loggerlogger type. The logger can be either NULL, "INFO" (with minimum logs), or "DEBUG" (for complete curl http calls logs)
keyring_backendThe 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').
getToken()Get user token
ZenodoManager$getToken()
the token, object of class character
getLanguages()Get Languages supported by Zenodo.
ZenodoManager$getLanguages(pretty = TRUE)
prettyPrettify 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
list of languages as data.frame or list
getLanguageById()Get language by Id.
ZenodoManager$getLanguageById(id)
idlicense id
the license
getLicenses()Get Licenses supported by Zenodo.
ZenodoManager$getLicenses(pretty = TRUE)
prettyPrettify 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.
list of licenses as data.frame or list
getLicenseById()Get license by Id.
ZenodoManager$getLicenseById(id)
idlicense id
the license
getResourceTypes()Get Resource types supported by Zenodo.
ZenodoManager$getResourceTypes(pretty = TRUE)
prettyPrettify 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
list of resource types as data.frame or list
getResourceTypeById()Get resource type by Id.
ZenodoManager$getResourceTypeById(id)
idresource type id
the resource type
getCommunities()Get Communities supported by Zenodo.
ZenodoManager$getCommunities(pretty = TRUE, q = "", size = 500)
prettyPrettify 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
qan 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.
sizenumber of communities to be returned. By default equal to 500
list of communities as data.frame or list
getCommunityById()Get community by Id.
ZenodoManager$getCommunityById(id)
idcommunity id
the community
submitRecordToCommunities()Submit a published record to one or more community
ZenodoManager$submitRecordToCommunities( record, communities = list(), message = NULL )
recordan object of class ZenodoRecord
communitiescommunities to which the record will be submitted
messagemessage to send to the community curator(s), either a text or a named list for each community in case a community-specific message should be sent
a submission object of class list, or NULL if nothing was submitted
removeRecordFromCommunities()Remove a record from one or more community
ZenodoManager$removeRecordFromCommunities(record, communities = list())
recordan object of class ZenodoRecord
communitiescommunities to which the record will be submitted
TRUE if removed, FALSE otherwise
getRecordCommunities()Get record communities
ZenodoManager$getRecordCommunities(record)
recordobject of class ZenodoRecord
the list of communities in which the record was included
createReviewRequest()Creates a record review request in a community
ZenodoManager$createReviewRequest(record, community)
recordan object of class ZenodoRecord
communitya community to which the record is submitted for review and publication
a review request object of class list, or NULL if nothing was submitted
getReviewRequest()Get a record review request
ZenodoManager$getReviewRequest(record)
recordan object of class ZenodoRecord
a review request object of class list, or NULL if nothing exists
deleteReviewRequest()Deletes a review request
ZenodoManager$deleteReviewRequest(record)
recordan object of class ZenodoRecord
TRUE if deleted, FALSE otherwise
submitRecordForReview()Submits a record for review. Prior to this submission, a community
has to be selected for a record. This is done by using the method createReviewRequest(record, community).
ZenodoManager$submitRecordForReview(recordId, message = NULL)
recordIdthe ID of a Zenodo record
messagemessage content for the submission. Optional
TRUE if submitted, FALSE otherwise
getGrants()Get Grants supported by Zenodo. DEPRECATED: replaced by getAwards
ZenodoManager$getGrants(q = "", pretty = TRUE, size = 500)
qan 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.
prettyPrettify 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
sizenumber of grants to be returned. By default equal to 500.
list of grants as data.frame or list
getAwards()Get Awards supported by Zenodo.
ZenodoManager$getAwards(q = "", pretty = TRUE, size = 500)
qan 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.
prettyPrettify 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
sizenumber of awards to be returned. By default equal to 500.
list of awards as data.frame or list
getGrantsByName()Get grants by name. DEPRECATED: replaced by getAwardByName
ZenodoManager$getGrantsByName(name, pretty = TRUE)
namename
prettyPrettify 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
list of grants as data.frame or list
getAwardsByName()Get awards by name.
ZenodoManager$getAwardsByName(name, pretty = TRUE)
namename
prettyPrettify 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
list of awards as data.frame or list
getGrantById()Get grant by Id.DEPRECATED: replaced by getAwardById
ZenodoManager$getGrantById(id)
idgrant id
the grant
getAwardById()Get award by Id.
ZenodoManager$getAwardById(id)
idaward id
the award
getAffiliations()Get Affiliations supported by Zenodo.
ZenodoManager$getAffiliations(q = "", pretty = TRUE, size = 500)
qan 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.
prettyPrettify 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
sizenumber of affiliations to be returned. By default equal to 500.
list of affiliations as data.frame or list
getAffiliationByName()Get affiliations by name.
ZenodoManager$getAffiliationByName(name, pretty = TRUE)
namename
prettyPrettify 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
list of affiliations as data.frame or list
getAffiliationById()Get affiliation by Id.
ZenodoManager$getAffiliationById(id)
idaffiliation id
the affiliation
getFunders()Get Funders supported by Zenodo based on a query.
ZenodoManager$getFunders(q = "", pretty = TRUE, size = 500)
qan 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.
prettyPrettify 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
sizenumber of funders to be returned. By default equal to 500
list of funders as data.frame or list
getFundersByName()Get funders by name.
ZenodoManager$getFundersByName(name, pretty = TRUE)
namename
prettyPrettify 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
list of funders as data.frame or list
getFunderById()Get funder by Id.
ZenodoManager$getFunderById(id)
idfunder id
the funder
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/.
ZenodoManager$getDepositions( q = "", size = 10, all_versions = FALSE, exact = TRUE, quiet = FALSE )
qElastic-Search-compliant query, as object of class character. Default is ""
sizenumber of depositions to be retrieved per request (paginated). Default is 10
all_versionsobject of class logical indicating if all versions of deposits have to be retrieved. Default is FALSE
exactobject of class logical indicating if exact matching has to be applied. Default is TRUE
quietobject of class logical indicating if logs have to skipped. Default is FALSE
a list of ZenodoRecord
getDepositionByConceptDOI()Get a Zenodo deposition record by concept DOI (generic DOI common to all deposition record versions).
ZenodoManager$getDepositionByConceptDOI(conceptdoi)
conceptdoithe concept DOI, object of class character
an object of class ZenodoRecord if record does exist, NULL otherwise
getDepositionByDOI()Get a Zenodo deposition record by DOI.
ZenodoManager$getDepositionByDOI(doi)
doithe DOI, object of class character
an object of class ZenodoRecord if record does exist, NULL otherwise
getDepositionById()Get a Zenodo deposition record by ID.
ZenodoManager$getDepositionById(recid)
recidthe record ID, object of class character
an object of class ZenodoRecord if record does exist, NULL otherwise
getDepositionByConceptId()Get a Zenodo deposition record by concept ID.
ZenodoManager$getDepositionByConceptId(conceptrecid)
conceptrecidthe record concept ID, object of class character
an object of class ZenodoRecord if record does exist, NULL otherwise
depositRecord()Deposits a record on Zenodo.
ZenodoManager$depositRecord(record, reserveDOI = TRUE, publish = FALSE)
recordthe record to deposit, object of class ZenodoRecord
reserveDOIreserve DOI. By default TRUE
publishobject 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)
object of class ZenodoRecord
reserveDOI()Reserves a DOI for a deposition (draft record)
ZenodoManager$reserveDOI(record)
recordthe record to deposit, object of class ZenodoRecord
object of class ZenodoRecord
deleteDOI()Reserves a DOI for a deposition (draft record)
ZenodoManager$deleteDOI(record)
recordthe record for which DOI has to be deleted, object of class ZenodoRecord
object of class ZenodoRecord
depositRecordVersion()Deposits a record version on Zenodo.
ZenodoManager$depositRecordVersion( record, delete_latest_files = TRUE, files = list(), publish = FALSE )
recordthe record version to deposit, object of class ZenodoRecord
delete_latest_filesobject of class logical indicating if latest files have to be deleted. Default is TRUE
filesa list of files to be uploaded with the new record version
publishobject of class logical indicating if record has to be published (default FALSE)
TRUE if deposited (and eventually published), FALSE otherwise
deleteRecord()Deletes a record given its ID
ZenodoManager$deleteRecord(recordId)
recordIdthe ID of the record to be deleted
TRUE if deleted, FALSE otherwise
deleteRecordByDOI()Deletes a record by DOI
ZenodoManager$deleteRecordByDOI(doi)
doithe DOI of the record to be deleted
TRUE if deleted, FALSE otherwise
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/.
ZenodoManager$deleteRecords(q = "", size = 10)
qan ElasticSearch compliant query, object of class character
sizenumber of records to be passed to $getDepositions method
TRUE if all records have been deleted, FALSE otherwise
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.
ZenodoManager$createEmptyRecord(reserveDOI = TRUE)
reserveDOIreserve DOI. By default TRUE
an object of class ZenodoRecord
editRecord()Unlocks a record already submitted. Required to edit metadata of a Zenodo record already published.
ZenodoManager$editRecord(recordId)
recordIdthe ID of the record to unlock and set in editing mode.
an object of class ZenodoRecord
discardChanges()Discards changes on a Zenodo record. Deleting a draft for an unpublished record will remove the draft and associated files from the system. Deleting a draft for a published record will remove the draft but not the published record.
ZenodoManager$discardChanges(recordId)
recordIdthe ID of the record for which changes have to be discarded.
an object of class ZenodoRecord
publishRecord()Publishes a Zenodo record.
ZenodoManager$publishRecord(recordId)
recordIdthe ID of the record to be published.
an object of class ZenodoRecord
getFiles()Get list of files attached to a Zenodo record.
ZenodoManager$getFiles(recordId)
recordIdthe ID of the record.
list of files
getFile()Get a file record metadata.
ZenodoManager$getFile(recordId, filename)
recordIdthe ID of the record.
filenamefilename
the file metadata
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.
ZenodoManager$startFileUpload(path, recordId)
pathLocal path of the file
recordIdID of the record
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.
ZenodoManager$completeFileUpload(path, recordId)
pathLocal path of the file
recordIdID of the record
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".
ZenodoManager$uploadFile(path, record = NULL)
pathLocal path of the file
recordobject of class ZenodoRecord
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.
ZenodoManager$deleteFile(recordId, filename)
recordIdID of the record
filenamename of the file to be deleted
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/.
ZenodoManager$getRecords(q = "", size = 10, all_versions = FALSE, exact = TRUE)
qElastic-Search-compliant query, as object of class character. Default is ""
sizenumber of records to be retrieved per request (paginated). Default is 10
all_versionsobject of class logical indicating if all versions of records have to be retrieved. Default is FALSE
exactobject of class logical indicating if exact matching has to be applied. Default is TRUE
quietobject of class logical indicating if logs have to skipped. Default is FALSE
a list of ZenodoRecord
getRecordByConceptDOI()Get Record by concept DOI
ZenodoManager$getRecordByConceptDOI(conceptdoi)
conceptdoithe concept DOI
a object of class ZenodoRecord
getRecordByDOI()Get Record by DOI
ZenodoManager$getRecordByDOI(doi)
doithe DOI
a object of class ZenodoRecord
getRecordById()Get Record by ID
ZenodoManager$getRecordById(recid)
recidthe record ID
a object of class ZenodoRecord
getRecordByConceptId()Get Record by concept ID
ZenodoManager$getRecordByConceptId(conceptrecid)
conceptrecidthe concept ID
a object of class ZenodoRecord
getRequests()Search requests
ZenodoManager$getRequests(q = "", sort = "bestmatch", size = 10)
qSearch query used to filter results based on ElasticSearch's query string syntax. e.g. https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax
sortSort search results. Built-in options are "bestmatch", "name", "newest", "oldest" (default: "bestmatch" or "newest").
sizenumber of records to be retrieved per request (paginated). Default is 10
a list of ZenodoRecord
getRequest()Get a request
ZenodoManager$getRequest(request_id)
request_idthe request ID
the request list object, NULL otherwise
isActionableRequest()Checks if the request can be subject to an operation (accept, decline, cancel) depending on its status. To be subject to an operation, a request should not be closed or expired
ZenodoManager$isActionableRequest(request_id)
request_idthe request ID
TRUE if
acceptRequest()Accepts a request
ZenodoManager$acceptRequest(request_id, message = NULL)
request_idthe request ID
messageoptional message reason for acceptance
TRUE if accepted, FALSE otherwise
declineRequest()Declines a request
ZenodoManager$declineRequest(request_id, message = NULL)
request_idthe request ID
messageoptional message reason for declination
TRUE if declined, FALSE otherwise
cancelRequest()Cancels a request
ZenodoManager$cancelRequest(request_id, message = NULL)
request_idthe request ID
messageoptional message reason for cancelation
TRUE if canceled, FALSE otherwise
clone()The objects of this class are cloneable with this method.
ZenodoManager$clone(deep = FALSE)
deepWhether to make a deep clone.
Main user class to be used with zen4R
Emmanuel Blondel <emmanuel.blondel1@gmail.com>
## 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
#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]]$filename)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.