3 This SDK focuses on providing support for accessing Arvados projects, collections, and the files within collections.
4 The API is not final and feedback is solicited from users on ways in which it could be improved.
8 `install.packages("ArvadosR", repos=c("http://r.arvados.org", getOption("repos")["CRAN"]), dependencies=TRUE)`
10 Note: on Linux, you may have to install supporting packages.
14 `yum install libxml2-devel openssl-devel curl-devel`
18 `apt-get install build-essential libxml2-dev libssl-dev libcurl4-gnutls-dev`
25 * Load Library and Initialize API:
28 `arv <- Arvados$new() # uses environment variables ARVADOS_API_TOKEN and ARVADOS_API_HOST`
29 `arv <- Arvados$new("your Arvados token", "example.arvadosapi.com")`
31 Optionally, add numRetries parameter to specify number of times to retry failed service requests.
34 `arv <- Arvados$new("your Arvados token", "example.arvadosapi.com", numRetries = 3)`
36 This parameter can be set at any time using setNumRetries
38 `arv$setNumRetries(5)`
41 #### WORKING WITH COLLECTIONS
45 `collection <- arv$getCollection("uuid")`
49 `collectionList <- arv$listCollections(list(list("name", "like", "Test%"))) # offset of 0 and default limit of 100`
50 `collectionList <- arv$listCollections(list(list("name", "like", "Test%")), limit = 10, offset = 2)`
52 `collectionList$items_available # count of total number of items (may be more than returned due to paging)`
53 `collectionList$items # items which match the filter criteria`
55 * List all collections even if the number of items is greater than maximum API limit:
57 `collectionList <- arv$listAllCollections(list(list("name", "like", "Test%")))`
59 * Delete a collection:
61 `deletedCollection <- arv$deleteCollection("uuid")`
63 * Update a collection's metadata:
65 `updatedCollection <- arv$updateCollection("uuid", list(name = "New name", description = "New description"))`
69 `createdCollection <- arv$createCollection(list(name = "Example", description = "This is a test collection"))`
72 #### MANIPULATIN COLLECTION CONTENT
74 * Create collection object:
76 `collection <- Collection$new(arv, "uuid")`
80 `files <- collection$getFileListing()`
82 * Get ArvadosFile or Subcollection from internal tree-like structure:
84 `arvadosFile <- collection$get("location/to/my/file.cpp")`
88 `arvadosSubcollection <- collection$get("location/to/my/directory/")`
92 `arvadosFile <- collection$get("myinput.txt")`
93 `arvConnection <- arvadosFile$connection("r")`
94 `mytable <- read.table(arvConnection)`
98 `arvadosFile <- collection$create("myoutput.txt")`
99 `arvConnection <- arvadosFile$connection("w")`
100 `write.table(mytable, arvConnection)`
101 `arvadosFile$flush()`
103 * Write to existing file (override current content of the file):
105 `arvadosFile <- collection$get("location/to/my/file.cpp")`
106 `arvadosFile$write("This is new file content")`
108 * Read whole file or just a portion of it:
110 `fileContent <- arvadosFile$read()`
111 `fileContent <- arvadosFile$read("text")`
112 `fileContent <- arvadosFile$read("raw", offset = 1024, length = 512)`
114 * Get ArvadosFile or Subcollection size:
116 `size <- arvadosFile$getSizeInBytes()`
120 `size <- arvadosSubcollection$getSizeInBytes()`
122 * Create new file in a collection:
124 `collection$create(fileNames, optionalRelativePath)`
128 `mainFile <- collection$create("main.cpp", "cpp/src/")`
129 `fileList <- collection$create(c("main.cpp", lib.dll), "cpp/src/")`
131 * Add existing ArvadosFile or Subcollection to a collection:
133 `folder <- Subcollection$new("src")`
134 `file <- ArvadosFile$new("main.cpp")`
137 `collection$add(folder, "cpp")`
139 This examples will add file "main.cpp" in "./cpp/src/" folder if folder exists.
140 If subcollection contains more files or folders they will be added recursively.
142 * Delete file from a collection:
144 `collection$remove("location/to/my/file.cpp")`
146 You can remove both Subcollection and ArvadosFile.
147 If subcollection contains more files or folders they will be removed recursively.
149 You can also remove multiple files at once:
151 `collection$remove(c("path/to/my/file.cpp", "path/to/other/file.cpp"))`
153 * Delete file or folder from a Subcollection:
155 `subcollection <- collection$get("mySubcollection/")`
156 `subcollection$remove("fileInsideSubcollection.exe")`
157 `subcollection$remove("folderInsideSubcollection/")`
159 * Move file or folder inside collection:
161 Directley from collection
163 `collection$move("folder/file.cpp", "file.cpp")`
167 `file <- collection$get("location/to/my/file.cpp")`
168 `file$move("newDestination/file.cpp")`
170 Or from subcollection
172 `subcollection <- collection$get("location/to/folder")`
173 `subcollection$move("newDestination/folder")`
175 Make sure to include new file name in destination.
176 In second example file$move("newDestination/") will not work.
178 #### WORKING WITH ARVADOS PROJECTS
182 `project <- arv$getProject("uuid")`
186 `projects <- arv$listProjects(list(list("owner_uuid", "=", "aaaaa-j7d0g-ccccccccccccccc"))) # list subprojects of a project`
187 `arv$listProjects(list(list("name","like","Example%"))) # list projects which have names beginning with Example`
189 * List all projects even if the number of items is greater than maximum API limit:
191 `collectionList <- arv$listAllProjects(list(list("name","like","Example%")))`
195 `deletedProject <- arv$deleteProject("uuid")`
199 `updatedProject <- arv$updateProject("uuid", list(name = "new_name", description = "new description"))`
203 `createdProject <- arv$createProject(list(name = "project_name", description = "project description"))`
205 ### BUILDING THE ARVADOS SDK TARBALL
210 This will create a tarball of the Arvados package in the current directory.