Retrieve a single metadata entry in a registered directory from the SewerRat API.

retrieveMetadata(path, url)

Arguments

path

String containing the absolute path to a metadata file in a registered directory.

url

String containing the URL to the SewerRat REST API.

Value

A named list containing path, the path to the metadata file; user, the identity of the owning user; time, the Unix time at which the file was modified; and metadata, the loaded metadata, typically as a named list representing a JSON object.

Author

Aaron Lun

Examples

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)

retrieveMetadata(paste0(mydir, "/metadata.json"), url=info$url)
#> $path
#> [1] "/tmp/RtmpJDU5Vu/file217671a950e/metadata.json"
#> 
#> $user
#> [1] "root"
#> 
#> $time
#> [1] 1727971509
#> 
#> $metadata
#> $metadata$first
#> [1] "Aaron"
#> 
#> $metadata$last
#> [1] "Lun"
#> 
#> 
retrieveMetadata(paste0(mydir, "/diet/metadata.json"), url=info$url)
#> $path
#> [1] "/tmp/RtmpJDU5Vu/file217671a950e/diet/metadata.json"
#> 
#> $user
#> [1] "root"
#> 
#> $time
#> [1] 1727971509
#> 
#> $metadata
#> $metadata$meal
#> [1] "lunch"
#> 
#> $metadata$ingredients
#> [1] "water"
#> 
#>