Set the owner and uploader permissions for a project.

setPermissions(
  project,
  registry,
  staging,
  url,
  asset = NULL,
  owners = NULL,
  uploaders = NULL,
  globalWrite = NULL,
  append = TRUE,
  spoof = NULL,
  dryRun = FALSE
)

Arguments

project

String containing the project name.

registry

String containing a path to the registry.

staging

String containing the path to the staging directory.

url

String containing the URL of the gobbler REST API.

asset

String containing the asset name. If specified, permissions are set on the asset rather than the entire project.

owners

Character vector containing the user IDs for owners of this project/asset. If NULL, no change is made to the existing owners of the project.

uploaders

List specifying the authorized uploaders for this project/asset. See the uploaders field in the fetchPermissions return value for the expected format. If NULL, no change is made to the existing uploaders of the project/asset.

globalWrite

Logical scalar indicating whether global writes should be enabled (see fetchPermissions for details). If NULL, no change is made to the global write status of the project. Ignored if asset is specified.

append

Logical scalar indicating whether owners and uploaders should be appended to the existing owners and uploaders, respectively, of the project/asset. If FALSE, the owners and uploaders are used to replace the existing values.

spoof

String containing the name of a user on whose behalf this request is being made. This should only be used if the Gobbler service allows spoofing by the current user. If NULL, no spoofing is performed.

dryRun

Logical scalar indicating whether to return the new permissions without actually modifying the registry.

Value

If dryRun=FALSE, NULL is invisibly returned upon successful setting of the permissions.

If dryRun=TRUE, a named list is returned containing the new permissions for the project/asset. This contains zero, one or more of owners, uploaders and global_write (see fetchPermissions for descriptions). A missing field indicates that it will not be updated in the project/asset permissions.

See also

fetchPermissions, to fetch the permissions.

createProject, to set permissions during project creation.

Author

Aaron Lun

Examples

info <- startGobbler()
removeProject("test", info$staging, url=info$url) # start with a clean slate.
createProject("test", info$staging, url=info$url)

# Mocking up an upload.
src <- allocateUploadDirectory(info$staging)
write(file=file.path(src, "foo"), "BAR")
uploadDirectory("test", "simple", "v1", src, staging=info$staging, url=info$url)
fetchPermissions("test", registry=info$registry)
#> $owners
#> $owners[[1]]
#> [1] "root"
#> 
#> 
#> $uploaders
#> list()
#> 

# Setting them to something else.
setPermissions("test",
    owners=c("mum", "dad"),
    uploaders=list(
        list(id='brother1', asset='ps5', until=Sys.time() + 100000),
        list(id='brother2', asset='harry_potter', version='goblet_of_fire')
    ),
    staging=info$staging,
    url=info$url,
    registry=info$registry
)
fetchPermissions("test", registry=info$registry)
#> $owners
#> $owners[[1]]
#> [1] "root"
#> 
#> $owners[[2]]
#> [1] "mum"
#> 
#> $owners[[3]]
#> [1] "dad"
#> 
#> 
#> $uploaders
#> $uploaders[[1]]
#> $uploaders[[1]]$id
#> [1] "brother1"
#> 
#> $uploaders[[1]]$asset
#> [1] "ps5"
#> 
#> $uploaders[[1]]$until
#> [1] "2025-08-20 04:49:30 UTC"
#> 
#> 
#> $uploaders[[2]]
#> $uploaders[[2]]$id
#> [1] "brother2"
#> 
#> $uploaders[[2]]$asset
#> [1] "harry_potter"
#> 
#> $uploaders[[2]]$version
#> [1] "goblet_of_fire"
#> 
#> 
#>