Skip to content

Commit

Permalink
cleanup docs
Browse files Browse the repository at this point in the history
  • Loading branch information
leeper committed Apr 2, 2016
1 parent eafbe38 commit 2f31967
Show file tree
Hide file tree
Showing 31 changed files with 217 additions and 748 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dataverse
Version: 0.1.14
Date: 2016-04-01
Version: 0.1.15
Date: 2016-04-02
Title: Client for Dataverse 4 Repositories
Authors@R: c(person("Thomas J.", "Leeper", role = c("aut", "cre"),
email = "thosjleeper@gmail.com"),
Expand Down
8 changes: 4 additions & 4 deletions R/dataAccess.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#' @export
dataverse_file <-
function(file,
ds = NULL,
dataset = NULL,
format = c("original", "RData", "prep", "bundle"),
# thumb = TRUE,
vars = NULL,
Expand All @@ -48,7 +48,7 @@ function(file,
format <- match.arg(format)

# from doi get file ID
if (!is.null(ds) && !is.numeric(file)) {
if (!is.null(dataset) && !is.numeric(file)) {
file <- (function(doi, filename, ...) {
files <- dataset_files(prepend_doi(doi))
ids <- unlist(lapply(files, function(x) x[["datafile"]][["id"]]))
Expand All @@ -67,7 +67,7 @@ function(file,
id <- ids[w]
}
id
})(ds, file)
})(dataset, file)

}

Expand Down Expand Up @@ -116,7 +116,7 @@ function(file,
u <- paste0(api_url(server), "access/datafile/", file, "/metadata/", format)
r <- httr::GET(u, httr::add_headers("X-Dataverse-key" = key), ...)
httr::stop_for_status(r)
content(r, as = "text", encoding = "UTF-8")
httr::content(r, as = "text", encoding = "UTF-8")
}


Expand Down
24 changes: 18 additions & 6 deletions R/native_dataset_publish.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
#' @examples
#' \dontrun{
#' meta <- list()
#'
#' d <- create_dataset("mydataverse", body = list())
#' ds <- create_dataset("mydataverse", body = meta)
#'
#' # cleanup
#' delete_dataset(ds)
#' }
#' @export
create_dataset <- function(dataverse, body, key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), ...) {
Expand All @@ -33,7 +35,14 @@ create_dataset <- function(dataverse, body, key = Sys.getenv("DATAVERSE_KEY"), s
#' @seealso \code{\link{get_dataset}}, \code{\link{create_dataset}}, \code{\link{delete_dataset}}, \code{\link{publish_dataset}}
#' @examples
#' \dontrun{
#' meta1 <- list()
#' ds <- create_dataset("mydataverse", body = meta1)
#'
#' meta2 <- list()
#' update_dataset(ds, body = meta2)
#'
#' # cleanup
#' delete_dataset(ds)
#' }
#' @export
update_dataset <- function(dataset, body, key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), ...) {
Expand All @@ -49,15 +58,16 @@ update_dataset <- function(dataset, body, key = Sys.getenv("DATAVERSE_KEY"), ser
#' @template ds
#' @param minor A logical specifying whether the new release of the dataset is a \dQuote{minor} release (\code{TRUE}, by default), resulting in a minor version increase (e.g., from 1.1 to 1.2). If \code{FALSE}, the dataset is given a \dQuote{major} release (e.g., from 1.1 to 2.0).
#' @template envvars
#' @template dots
#' @details Use this function to \dQuote{publish} (i.e., publicly release) a draft Dataverse dataset. This creates a publicly visible listing of the dataset, accessible by its DOI, with a numbered version. This action cannot be undone.
#' There are no requirements for what constitutes a major or minor release, but a minor release might be used to update metadata (e.g., a new linked publication) or the addition of supplemental files. A major release is best used to reflect a substantial change to the dataset, such as would require a published erratum or a substantial change to data or code.
#' @template envvars
#' @template dots
#' @return A list.
#' @seealso \code{\link{get_dataset}}, \code{\link{publish_dataverse}}
#' @examples
#' \dontrun{
#'
#' meta <- list()
#' ds <- create_dataset("mydataverse", body = meta)
#' publish_dataset(ds)
#' }
#' @export
publish_dataset <- function(dataset, minor = TRUE, key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), ...) {
Expand All @@ -78,7 +88,9 @@ publish_dataset <- function(dataset, minor = TRUE, key = Sys.getenv("DATAVERSE_K
#' @seealso \code{\link{get_dataset}}, \code{\link{create_dataset}}, \code{\link{update_dataset}}, \code{\link{delete_dataset}}, \code{\link{publish_dataset}}
#' @examples
#' \dontrun{
#'
#' meta <- list()
#' ds <- create_dataset("mydataverse", body = meta)
#' delete_dataset(ds)
#' }
#' @export
delete_dataset <- function(dataset, key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), ...) {
Expand Down
4 changes: 0 additions & 4 deletions R/native_dv.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ get_facets <- function(dataverse, key = Sys.getenv("DATAVERSE_KEY"), server = Sy
#' monogan <- get_dataverse("monogan")
#' monogan_data <- dataverse_contents(monogan)
#' dataverse_metadata(monogan)
#'
#' # get metadata
#' dataverse_metadata(monogan)
#'
#' }
#' @export
dataverse_metadata <- function(dataverse, key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), ...) {
Expand Down
10 changes: 5 additions & 5 deletions R/native_dv_publish.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
#' @seealso To manage Dataverses: \code{\link{delete_dataverse}}, \code{\link{publish_dataverse}}, \code{\link{dataverse_contents}}; to get datasets: \code{\link{get_dataset}}; to search for Dataverses, datasets, or files: \code{\link{dataverse_search}}
#' @examples
#' \dontrun{
#' (dv <- create_dataverse("mydataverse"))
#'
#' # cleanup
#' delete_dataverse("mydataverse")
#' }
#' @export
create_dataverse <- function(dataverse, key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), ...) {
Expand All @@ -35,7 +38,8 @@ create_dataverse <- function(dataverse, key = Sys.getenv("DATAVERSE_KEY"), serve
#' @seealso To manage Dataverses: \code{\link{create_dataverse}}, \code{\link{publish_dataverse}}, \code{\link{dataverse_contents}}; to get datasets: \code{\link{get_dataset}}; to search for Dataverses, datasets, or files: \code{\link{dataverse_search}}
#' @examples
#' \dontrun{
#'
#' dv <- create_dataverse("mydataverse")
#' delete_dataverse(dv)
#' }
#' @export
delete_dataverse <- function(dataverse, key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), ...) {
Expand All @@ -56,10 +60,6 @@ delete_dataverse <- function(dataverse, key = Sys.getenv("DATAVERSE_KEY"), serve
#' @template dots
#' @return A list
#' @seealso \code{\link{dataverse_metadata}}
#' @examples
#' \dontrun{
#'
#' }
#' @export
set_dataverse_metadata <- function(dataverse, body, root = TRUE, key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), ...) {
dataverse <- dataverse_id(dataverse)
Expand Down
141 changes: 14 additions & 127 deletions R/native_role_groups.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#' @title Create role group
#' @description Create a role group
#' @rdname role_groups
#' @title Role groups
#' @description Create, update, and delete role groups
#' @details Role groups can be used to organize roles for a Dataverse.
#' @template dv
#' @template group
#' @param alias A character string specifying an alias for the role group.
#' @param name A character string specifying the name of the role group.
#' @param description A character string specifying a description of the role group.
#' @template envvars
#' @template dots
#' @return A list of class \dQuote{dataverse_group}.
#' @seealso \code{\link{list_groups}}, \code{\link{update_group}}, \code{\link{get_group}}, \code{\link{add_roles_to_group}}, \code{\link{delete_group}}
#' @seealso \code{\link{add_roles_to_group}}
#' @examples
#' \dontrun{
#' # create a group
Expand Down Expand Up @@ -40,34 +42,7 @@ create_group <- function(dataverse, alias, name, description, key = Sys.getenv("
structure(j, class = "dataverse_group")
}

#' @title Update role group
#' @description \dots
#' @details \dots
#' @template group
#' @param name A character string specifying the name of the role group.
#' @param description A character string specifying a description of the role group.
#' @param dataverse A character string specifying a Dataverse name or an object of class \dQuote{dataverse}. Can be missing if \code{role} is an object of class \dQuote{dataverse_group}.
#' @template envvars
#' @template dots
#' @return A list of class \dQuote{dataverse_group}.
#' @seealso \code{\link{create_group}}, \code{\link{list_groups}}, \code{\link{get_group}}, \code{\link{add_roles_to_group}}, \code{\link{delete_group}}
#' @examples
#' \dontrun{
#' # create a group
#' g <- create_group("my_dataverse", "testgroup", "aGroupName", "this is a test group")
#'
#' # update group details
#' update_group(g, description = "this needs a new description")
#'
#' # get group details
#' get_group(g)
#'
#' # list all groups
#' list_groups("my_dataverse")
#'
#' # delete group
#' delete_group(g)
#' }
#' @rdname role_groups
#' @export
update_group <- function(group, name, description, dataverse, key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), ...) {
b <- list()
Expand Down Expand Up @@ -99,31 +74,7 @@ update_group <- function(group, name, description, dataverse, key = Sys.getenv("
structure(j, class = "dataverse_group")
}

#' @title List role groups
#' @description Returns a list of role groups for a given dataverse
#' @details Role groups can be used to organize roles for a dataverse.
#' @template dv
#' @template envvars
#' @template dots
#' @return A list of objects of class \dQuote{dataverse_group}.
#' @seealso \code{\link{create_group}}, \code{\link{update_group}}, \code{\link{get_group}}, \code{\link{add_roles_to_group}}, \code{\link{delete_group}}
#' @examples
#' \dontrun{
#' # create a group
#' g <- create_group("my_dataverse", "testgroup", "aGroupName", "this is a test group")
#'
#' # update group details
#' update_group(g, description = "this needs a new description")
#'
#' # get group details
#' get_group(g)
#'
#' # list all groups
#' list_groups("my_dataverse")
#'
#' # delete group
#' delete_group(g)
#' }
#' @rdname role_groups
#' @export
list_groups <- function(dataverse, key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), ...) {
dataverse <- dataverse_id(dataverse)
Expand All @@ -138,32 +89,7 @@ list_groups <- function(dataverse, key = Sys.getenv("DATAVERSE_KEY"), server = S
})
}

#' @title Get role group
#' @description \dots
#' @details \dots
#' @template group
#' @param dataverse A character string specifying a Dataverse name or an object of class \dQuote{dataverse}. Can be missing if \code{role} is an object of class \dQuote{dataverse_group}.
#' @template envvars
#' @template dots
#' @return A list of class \dQuote{dataverse_group}.
#' @seealso \code{\link{list_groups}}, \code{\link{create_group}}, \code{\link{update_group}}, \code{\link{add_roles_to_group}}, \code{\link{delete_group}}
#' @examples
#' \dontrun{
#' # create a group
#' g <- create_group("my_dataverse", "testgroup", "aGroupName", "this is a test group")
#'
#' # update group details
#' update_group(g, description = "this needs a new description")
#'
#' # get group details
#' get_group(g)
#'
#' # list all groups
#' list_groups("my_dataverse")
#'
#' # delete group
#' delete_group(g)
#' }
#' @rdname role_groups
#' @export
get_group <- function(group, dataverse, key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), ...) {
if (inherits(group, "dataverse_group")) {
Expand All @@ -180,31 +106,7 @@ get_group <- function(group, dataverse, key = Sys.getenv("DATAVERSE_KEY"), serve
structure(j, class = "dataverse_group")
}

#' @title Delete role group
#' @description \dots
#' @details \dots
#' @template group
#' @param dataverse A character string specifying a Dataverse name or an object of class \dQuote{dataverse}. Can be missing if \code{role} is an object of class \dQuote{dataverse_group}.
#' @template envvars
#' @template dots
#' @return A list.
#' @examples
#' \dontrun{
#' # create a group
#' g <- create_group("my_dataverse", "testgroup", "aGroupName", "this is a test group")
#'
#' # update group details
#' update_group(g, description = "this needs a new description")
#'
#' # get group details
#' get_group(g)
#'
#' # list all groups
#' list_groups("my_dataverse")
#'
#' # delete group
#' delete_group(g)
#' }
#' @rdname role_groups
#' @export
delete_group <- function(group, dataverse, key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), ...) {
if (inherits(group, "dataverse_group")) {
Expand All @@ -224,19 +126,16 @@ delete_group <- function(group, dataverse, key = Sys.getenv("DATAVERSE_KEY"), se
}
}

#' @title Add roles to group
#' @description \dots
#' @details \dots
#' @rdname add_roles
#' @title Add/Remove role to/from group
#' @description Add/remove role from group
#' @details Role groups can be used to organize roles for a Dataverse. These functions add or remove roles from a group
#' @template group
#' @template role
#' @param dataverse A character string specifying a Dataverse name or an object of class \dQuote{dataverse}. Can be missing if \code{role} is an object of class \dQuote{dataverse_group}.
#' @template envvars
#' @template dots
#' @return A list.
#' @examples
#' \dontrun{
#'
#' }
#' @export
add_roles_to_group <- function(group, role, dataverse, key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), ...) {

Expand All @@ -259,19 +158,7 @@ add_roles_to_group <- function(group, role, dataverse, key = Sys.getenv("DATAVER
j
}

#' @title Remove role from group
#' @description \dots
#' @details \dots
#' @template group
#' @template role
#' @param dataverse A character string specifying a Dataverse name or an object of class \dQuote{dataverse}. Can be missing if \code{role} is an object of class \dQuote{dataverse_group}.
#' @template envvars
#' @template dots
#' @return A list.
#' @examples
#' \dontrun{
#'
#' }
#' @rdname add_roles
#' @export
remove_role_from_group <- function(group, role, dataverse, key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), ...) {
if (inherits(group, "dataverse_group")) {
Expand Down
Loading

0 comments on commit 2f31967

Please sign in to comment.