|
19 | 19 | #' @param spoof String containing the name of a user on whose behalf this request is being made. |
20 | 20 | #' This should only be used if the Gobbler service allows spoofing by the current user. |
21 | 21 | #' If \code{NULL}, no spoofing is performed. |
| 22 | +#' @param dryRun Logical scalar indicating whether to return the new permissions without actually modifying the registry. |
22 | 23 | #' @inheritParams createProject |
23 | 24 | #' |
24 | 25 | #' @author Aaron Lun |
|
28 | 29 | #' |
29 | 30 | #' \code{\link{createProject}}, to set permissions during project creation. |
30 | 31 | #' |
31 | | -#' @return \code{NULL} is invisibly returned upon successful setting of the permissions. |
| 32 | +#' @return If \code{dryRun=FALSE}, \code{NULL} is invisibly returned upon successful setting of the permissions. |
| 33 | +#' |
| 34 | +#' If \code{dryRun=TRUE}, a named list is returned containing the new permissions for the project/asset. |
| 35 | +#' This contains zero, one or more of \code{owners}, \code{uploaders} and \code{global_write} (see \code{\link{fetchPermissions}} for descriptions). |
| 36 | +#' A missing field indicates that it will not be updated in the project/asset permissions. |
32 | 37 | #' |
33 | 38 | #' @examples |
34 | 39 | #' info <- startGobbler() |
|
55 | 60 | #' fetchPermissions("test", registry=info$registry) |
56 | 61 | #' |
57 | 62 | #' @export |
58 | | -setPermissions <- function(project, registry, staging, url, asset=NULL, owners=NULL, uploaders=NULL, globalWrite=NULL, append=TRUE, spoof=NULL) { |
| 63 | +setPermissions <- function(project, registry, staging, url, asset=NULL, owners=NULL, uploaders=NULL, globalWrite=NULL, append=TRUE, spoof=NULL, dryRun=FALSE) { |
59 | 64 | perms <- list() |
60 | 65 | names(perms) <- character(0) |
61 | 66 |
|
@@ -87,7 +92,11 @@ setPermissions <- function(project, registry, staging, url, asset=NULL, owners=N |
87 | 92 | perms$global_write <- globalWrite |
88 | 93 | } |
89 | 94 |
|
| 95 | + if (dryRun) { |
| 96 | + return(perms) |
| 97 | + } |
90 | 98 | payload$permissions <- perms |
| 99 | + |
91 | 100 | dump_request(staging, url, "set_permissions", payload, spoof=spoof) |
92 | 101 | invisible(NULL) |
93 | 102 | } |
0 commit comments