List the directories that were registered in SewerRat.

listRegisteredDirectories(
  url,
  user = NULL,
  contains = NULL,
  prefix = NULL,
  within = NULL,
  exists = NULL,
  number = 100,
  on.truncation = c("message", "warning", "none")
)

Arguments

url

String containing the URL to the SewerRat REST API.

user

String containing the name of a user. If not NULL, results are filtered to directories registered by this user. If TRUE, this is set to the current user.

contains

String containing an absolute path. If not NULL, results are filtered to directories that contain this path.

prefix

String containing an absolute path or a prefix thereof. If not NULL, results are filtered to directories that start with this string. This is soft-deprecated and users should prefer to use within.

within

String containing an absolute path. If not NULL, results are filtered to directories that are equal to or lie within this path.

exists

Logical scalar indicating whether to only report directories that exist on the filesystem. If FALSE, only non-existent directories are reported, and if NULL, no filtering is applied based on existence.

number

Integer specifying the maximum number of results to return. This can also be Inf to return all results.

on.truncation

String specifying what to do when the number of results exceeds number. Either "warning", "message", or "none".

Value

List of named lists, where each inner list corresponds to a registered directory and contains:

  • path, string containing a path to the directory.

  • user, string containing the name of the user who registered this directory.

  • time, numeric scalar specifying the the Unix epoch time when this directory was registered.

  • names, a character vector containing the base names of the JSON files to be indexed.

Author

Aaron Lun

Examples

# Starting up an example SewerRat service:
info <- startSewerRat()

# Mocking up a directory of stuff to query.
mydir <- tempfile()
dir.create(mydir)
write(file=file.path(mydir, "metadata.json"), '{ "first": "Aaron", "last": "Lun" }')
dir.create(file.path(mydir, "diet"))
write(file=file.path(mydir, "diet", "metadata.json"), 
   '{ "meal": "lunch", "ingredients": "water" }')

# Registering it:
register(mydir, "metadata.json", url=info$url)

# List the registered directories:
listRegisteredDirectories(url=info$url)
#> [[1]]
#> [[1]]$path
#> [1] "/tmp/RtmpOvzCpk/file1ce7715ec9e"
#> 
#> [[1]]$user
#> [1] "root"
#> 
#> [[1]]$time
#> [1] 1749491762
#> 
#> [[1]]$names
#> [[1]]$names[[1]]
#> [1] "metadata.json"
#> 
#> 
#> 
#> [[2]]
#> [[2]]$path
#> [1] "/tmp/RtmpOvzCpk/file1ce3dba865d"
#> 
#> [[2]]$user
#> [1] "root"
#> 
#> [[2]]$time
#> [1] 1749491762
#> 
#> [[2]]$names
#> [[2]]$names[[1]]
#> [1] "metadata.json"
#> 
#> 
#> 
#> [[3]]
#> [[3]]$path
#> [1] "/tmp/RtmpOvzCpk/file1ce2d05a2ad"
#> 
#> [[3]]$user
#> [1] "root"
#> 
#> [[3]]$time
#> [1] 1749491762
#> 
#> [[3]]$names
#> [[3]]$names[[1]]
#> [1] "metadata.json"
#> 
#> 
#> 
listRegisteredDirectories(url=info$url, user=TRUE)
#> [[1]]
#> [[1]]$path
#> [1] "/tmp/RtmpOvzCpk/file1ce7715ec9e"
#> 
#> [[1]]$user
#> [1] "root"
#> 
#> [[1]]$time
#> [1] 1749491762
#> 
#> [[1]]$names
#> [[1]]$names[[1]]
#> [1] "metadata.json"
#> 
#> 
#> 
#> [[2]]
#> [[2]]$path
#> [1] "/tmp/RtmpOvzCpk/file1ce3dba865d"
#> 
#> [[2]]$user
#> [1] "root"
#> 
#> [[2]]$time
#> [1] 1749491762
#> 
#> [[2]]$names
#> [[2]]$names[[1]]
#> [1] "metadata.json"
#> 
#> 
#> 
#> [[3]]
#> [[3]]$path
#> [1] "/tmp/RtmpOvzCpk/file1ce2d05a2ad"
#> 
#> [[3]]$user
#> [1] "root"
#> 
#> [[3]]$time
#> [1] 1749491762
#> 
#> [[3]]$names
#> [[3]]$names[[1]]
#> [1] "metadata.json"
#> 
#> 
#>