R6 class for constructing deposits queries
Public fields
service
(character) of deposits host service.
sandbox
(logical) Connect client with sandbox if
TRUE
(zenodo only)deposits
(data.frame) Current deposits hosted on service, one row per deposit.
url_base
(character) Base URL of host service API
url_service
(character) URL of deposit service
id
(integer) Deposit identifier from host service.
headers
(list) list of named headers
hostdata
(list) Data as stored by host platform
metadata
(
atom4R::DCEntry
) holds metadataterm_map
(data.frame) Map between DCMI and deposit terms for specified host service.
Methods
Method new()
Create a new depositsClient
object
Usage
depositsClient$new(service, metadata = NULL, sandbox = FALSE, headers = NULL)
Arguments
service
(character) of a deposits service (see deposits_services).
metadata
Either of one three possible ways of defining metadata:
The name (or full path) or a local file containing metadata constructed with deposits_metadata_template;
A names list of metadata with names matching values given by dcmi_terms, and values specified as individual character strings or lists for multiple entries.
An atom4R
DCEntry
object containing metadata, either constructed directly via atom4R routines, or via deposits_meta_to_dcmi.
sandbox
If
TRUE
, connect client to sandbox, rather than actual API endpoint (for "zenodo" only).headers
Any acceptable headers. See examples in httr2 package.
Method print()
print method for the depositsClient
class
Method deposits_search()
Search all public deposits
Usage
depositsClient$deposits_search(
search_string = NULL,
page_size = 10L,
page_number = 1L,
...
)
Arguments
search_string
Single string to search for
page_size
Number of records to return in one page
page_number
Starting page for return results; used in combination with 'page_size' for pagination.
...
Named pairs of query parameters. Zenodo parameters are described at https://developers.zenodo.org/#list36, and currently include:
status: either "draft" or "published"
sort: either "bestmatch" (the default) or "mostrecent"
all_versions: Either "true" or "false"
communities: Search for deposits only within specified communities
type: Return deposits only of specified type
subtype: Return deposits only of specified subtype
bound: A geolocation bounding box
custom: Custom keywords
Figshare parameters are described at https://docs.figshare.com/#articles_search, and currently include:
resource_doi: Only return deposits matching this 'resource_doi'
item_type: Return deopsits of specified type (as integer).
doi: Only return deposits matching this DOI
handle: Only return deposits matching this handle
project_id: Only return deposits from within specified project
order: Order for sorting results; one of "published_date", "modified_date", "views", "shares", "downloads", or "cites"
search_for: Search term.
order_direction: "asc" or "desc"
institution: Only return deposits from specified institution (as integer)
group: Only return deposits from specified group (as integer)
published_since: Only return deposits published since specified date (as YYYY-MM-DD)
modified_since: Only return deposits modified since specified date (as YYYY-MM-DD)
Method deposit_fill_metadata()
Fill deposits client with metadata, and upload to deposits service if connected.
Arguments
metadata
Either of one three possible ways of defining metadata:
The name (or full path) or a local file containing metadata constructed with deposits_metadata_template;
A names list of metadata with names matching values given by dcmi_terms, and values specified as individual character strings or lists for multiple entries.
An atom4R
DCEntry
object containing metadata, either constructed directly via atom4R routines, or via deposits_meta_to_dcmi.
Method deposit_service()
Create a new depositsClient
object
Arguments
service
(character) of a deposits service (see deposits_services).
sandbox
If
TRUE
, connect client to sandbox, rather than actual API endpoint (for "zenodo" only).headers
Any acceptable headers. See examples in httr2 package.
Method deposit_upload_file()
Upload file to an existing deposit
Method deposit_download_file()
Download a specified 'filename' from a deposit
Usage
depositsClient$deposit_download_file(
deposit_id = NULL,
filename,
path = NULL,
overwrite = FALSE,
quiet = FALSE
)
Arguments
deposit_id
The 'id' number of deposit which file is to be downloaded from. If not specified, the 'id' value of current deposits client is used.
filename
The name of the file to be download as specified in the deposit.
path
The local directory where file is to be downloaded.
overwrite
Do not overwrite existing files unless set to
TRUE
.quiet
If
FALSE
, display download progress.
Examples
if (FALSE) {
# make a client
cli <- depositsClient$new ("zenodo") # or:
cli <- depositsClient$new ("figshare")
print (cli)
# methods
cli$deposits_list ()
# Fill depositsClient metadata
metadata <- list (
title = "New Title",
abstract = "This is the abstract",
creator = list ("A. Person", "B. Person")
)
cli$deposit_fill_metadata (metadata)
print (cli)
# or pass metadata directly at construction of new client
cli <- depositsClient$new ("figshare", metadata = metadata)
}
## ------------------------------------------------
## Method `depositsClient$deposits_search`
## ------------------------------------------------
if (FALSE) {
cli <- depositsClient$new (service = "figshare")
search_results <- cli$deposits_search (search_string = "Text string query", page_size = 5L)
}