Skip to contents

In iRODS, metadata is stored as attribute-value-units triples (AVUs), consisting of an attribute name, an attribute value and an optional unit. This function allows to chain several operations ('add' or 'remove') linked to specific AVUs. Read more about metadata by looking at the iCommands equivalent imeta in the iRODS Docs.

Usage

imeta(
  logical_path,
  entity_type = c("data_object", "collection", "user"),
  operations = list(),
  verbose = FALSE
)

Arguments

logical_path

Path to the data object or collection (or name of the user).

entity_type

Type of item to add metadata to or remove it from. Options are 'data_object', 'collection' and 'user'.

operations

List of named lists or data.frame representing operations. The valid components of each of these lists or vectors are:

  • operation, with values 'add' or 'remove', depending on whether the AVU should be added to or removed from the metadata of the item (required).

  • attribute, with the name of the AVU (required).

  • value, with the value of the AVU (required).

  • units, with the unit of the AVU (optional).

verbose

Whether information should be printed about the HTTP request and response. Defaults to FALSE.

Value

Invisibly, the HTTP response.

References

https://docs.irods.org/master/icommands/metadata/

See also

Examples

is_irods_demo_running()
#> [1] TRUE

# demonstration server (requires Bash, Docker and Docker-compose)
# use_irods_demo()

# connect project to server
create_irods("http://localhost/irods-rest/0.9.3", "/tempZone/home")

# authentication
iauth("rods", "rods")

# some data
foo <- data.frame(x = c(1, 8, 9), y = c("x", "y", "z"))

# store
isaveRDS(foo, "foo.rds")

# check if file is stored
ils()
#> 
#> ==========
#> iRODS Zone
#> ==========
#>                 logical_path        type
#>  /tempZone/home/rods/foo.rds data_object

# add some metadata
imeta(
  "foo.rds",
  "data_object",
   operations =
    list(
     list(operation = "add", attribute = "foo", value = "bar", units = "baz")
   )
)

# `operations` can contain multiple tags supplied as a `data.frame`
imeta(
  "foo.rds",
  "data_object",
  operations = data.frame(
    operation = c("add", "add"),
    attribute = c("foo2", "foo3"),
    value = c("bar2", "bar3"),
    units = c("baz2", "baz3")
   )
 )

# or again as a list of lists
imeta(
  "foo.rds",
  "data_object",
  operations = list(
    list(operation = "add", attribute = "foo4", value = "bar4", units = "baz4"),
    list(operation = "add", attribute = "foo5", value = "bar5", units = "baz5")
  )
)

# list of lists are useful as AVUs don't have to contain units
imeta(
  "foo.rds",
  "data_object",
  operations = list(
    list(operation = "add", attribute = "foo6", value = "bar6"),
    list(operation = "add", attribute = "foo7", value = "bar7", units = "baz7")
  )
)

# check if file is stored with associated metadata
ils(metadata = TRUE)
#> 
#> ========
#> metadata
#> ========
#> /tempZone/home/rods/foo.rds :
#>  attribute value units
#>        foo   bar   baz
#>       foo2  bar2  baz2
#>       foo3  bar3  baz3
#>       foo4  bar4  baz4
#>       foo5  bar5  baz5
#>       foo6  bar6      
#>       foo7  bar7  baz7
#> 
#> 
#> ==========
#> iRODS Zone
#> ==========
#>                 logical_path        type
#>  /tempZone/home/rods/foo.rds data_object

# delete object
irm("foo.rds", force = TRUE)