https://github.com/cran/rgbif
Tip revision: 22fa17cd853cf565a17fed616c0afe44b1ad4ba3 authored by John Waller on 03 September 2022, 18:10:02 UTC
version 3.7.3
version 3.7.3
Tip revision: 22fa17c
networks.r
#' Networks metadata.
#'
#' @template otherlimstart
#' @template occ
#' @template identifierargs
#' @export
#'
#' @param data The type of data to get. One or more of: 'contact', 'endpoint',
#' 'identifier', 'tag', 'machineTag', 'comment', 'constituents', or the
#' special 'all'. Default: `'all'`
#' @param uuid UUID of the data network provider. This must be specified if
#' data is anything other than 'all'. Only 1 can be passed in
#' @param query Query nodes. Only used when `data='all'`. Ignored
#' otherwise.
#'
#' @references <https://www.gbif.org/developer/registry#networks>
#'
#' @examples \dontrun{
#' networks()
#' networks(uuid='2b7c7b4f-4d4f-40d3-94de-c28b6fa054a6')
#'
#' # curl options
#' networks(curlopts = list(verbose=TRUE))
#' }
networks <- function(data = 'all', uuid = NULL, query = NULL, identifier=NULL,
identifierType=NULL, limit=100, start=NULL,
curlopts = list()) {
.Deprecated(msg="rgbif::networks() is deprecated since rgbif 3.7.3, use rgbif::network() instead.")
args <- rgbif_compact(list(q = query, limit = as.integer(limit),
offset = start))
data <- match.arg(data,
choices = c(
'all', 'contact', 'endpoint', 'identifier',
'tag', 'machineTag', 'comment', 'constituents'),
several.ok = TRUE)
# Define function to get data
getdata <- function(x){
if (!x == 'all' && is.null(uuid))
stop('You must specify a uuid if data does not equal "all"')
url <- if (is.null(uuid)) {
paste0(gbif_base(), '/network')
} else {
if (x == 'all') { sprintf('%s/network/%s', gbif_base(), uuid) } else {
sprintf('%s/network/%s/%s', gbif_base(), uuid, x)
}
}
res <- gbif_GET(url, args, TRUE, curlopts)
structure(list(meta = get_meta(res), data = parse_results(res, uuid)))
}
# Get data
if (length(data) == 1) getdata(data) else lapply(data, getdata)
}