This is an iRODS client library for the R language. It uses the iRODS REST API.
Note: This repository has been deprecated and archived.
Please find a new pure-R implementation at:
https://github.com/irods/irods_client_library_rirods
This is an iRODS client library for the R language. It uses the iRODS REST API.
The R iRODS client API uses the REST API for communications with iRODS. See iRODS REST Repository and iRODS REST Documentation for setting up the REST web services.
To use the R iRODS client, the R packages httr, XML, and bitops must also be installed.
install.packages("httr")
install.packages("XML")
install.packages("bitops")
The first steps to use the API is to import the iRODS_API.R file and create an connection context object. This is done as follows:
# Supplying a password to IrodsContext
source("/path/to/source/file/iRODS_API.R")
context <- IrodsContext("localhost", "8080", "rods", "rods")
# Using the password that is in the local .irodsA file
source("/path/to/source/file/iRODS_API.R")
context <- IrodsContext("localhost", "8080", "rods")
# Using a secured connection to the REST interface.
source("/path/to/source/file/iRODS_API.R")
context <- IrodsContext("localhost", "8080", "rods", "rods", ssl = TRUE)
The arguments to the IrodsContext constructor are:
Note that the REST API Port is the port to connect to the REST API web service. This is NOT the port to connect to the iCAT server.
For the following operations, it is assumed that the context object has already been created.
This routine gets the contents of a data object.
Arguments:
Code Example:
res <- context$getDataObjectContents("/tempZone/home/rods/a.txt", FALSE)
print(res)
This routine puts a file into iRODS.
Arguments:
Code Example:
context$putDataObject("/home/jjames/tmp.txt", "/tempZone/home/rods/tmp.txt")
Removes an iRODS data object.
Arguments:
Code Example:
context$removeDataObject("/tempZone/home/rods/tmp.txt")
Lists the contents of an iRODS collection. This routine returns a list containing a list of dataObjects and collections. The list is in the format:
list(dataObjects=(do1, do2, do3), collections=(coll1, coll2, coll3))
Arguments:
Code Example:
res <- context$listCollection("/tempZone/home/rods")
for (coll in res[["collections"]]) {
print(coll)
}
for (dataObj in res[["dataObjects"]]) {
print(dataObj)
}
Creates an iRODS collection.
Arguments:
Code Example:
context$createCollection("/tempZone/home/rods/temp")
Removes an iRODS collection.
Arguments:
Code Example:
context$removeCollection("/tempZone/home/rods/temp")
Gets the metadata for a collection. The return value is a list of named lists representing the metadata
on the collection. This list looks like the following:
((attr=attr1, val=val1, unit=unit1), (attr=attr2, val=val2, unit=unit2), …)
Arguments:
Code Example:
meta <- context$getCollectionMetadata("/tempZone/home/rods")
for (row in meta) {
print (row$attr)
print(row$val)
print(row$unit)
}
Gets the metadata for a data object. The return value is a list of named lists representing the metadata
on the collection. This list looks like the following:
((attr=attr1, val=val1, unit=unit1), (attr=attr2, val=val2, unit=unit2), …)
Arguments:
Code Example:
meta <- context$getDataObjectMetadata("/tempZone/home/rods/myfile.txt")
for (row in meta) {
print(row$attr)
print(row$val)
print(row$unit)
}
Adds metadata to a data object.
Arguments:
Code Example:
avu_list <- list()
avu_list <- append(avu_list, list(list(attr="myAttr", val="myVal", unit="myUnit")))
avu_list <- append(avu_list, list(list(attr="myAttr2", val="myVal2", unit="myUnit2")))
context$addDataObjectMetadata("/tempZone/home/rods/tmp.txt", avu_list)
Deletes metadata from a data object.
Arguments:
Code Example:
avu_list <- list()
avu_list <- append(avu_list, list(list(attr="myAttr", val="myVal", unit="myUnit")))
avu_list <- append(avu_list, list(list(attr="myAttr2", val="myVal2", unit="myUnit2")))
context$deleteDataObjectMetadata("/tempZone/home/rods/tmp.txt", avu_list)
Adds metadata to a collection.
Arguments:
Code Example:
avu_list <- list()
avu_list <- append(avu_list, list(list(attr="myAttr", val="myVal", unit="myUnit")))
avu_list <- append(avu_list, list(list(attr="myAttr2", val="myVal2", unit="myUnit2")))
context$addCollectionMetadata("/tempZone/home/rods", avu_list)
Deletes metadata on a collection.
Arguments:
Code Example:
avu_list <- list()
avu_list <- append(avu_list, list(list(attr="myAttr", val="myVal", unit="myUnit")))
avu_list <- append(avu_list, list(list(attr="myAttr2", val="myVal2", unit="myUnit2")))
context$deleteCollectionMetadata("/tempZone/home/rods", avu_list)