Made updating groups and collections less verbose.
authorFuad Muhic <fmuhic@capeannenterprises.com>
Thu, 21 Dec 2017 14:39:10 +0000 (15:39 +0100)
committerFuad Muhic <fmuhic@capeannenterprises.com>
Thu, 21 Dec 2017 14:39:10 +0000 (15:39 +0100)
Arvados-DCO-1.1-Signed-off-by: Fuad Muhic <fmuhic@capeannenterprises.com>

sdk/R/R/Arvados.R
sdk/R/README

index b5210263e1950c51742563927c68b0d72537ad50..3236ab7930f535823b3163610a7935d13e9b2875 100644 (file)
@@ -100,13 +100,16 @@ Arvados <- R6::R6Class(
             collection
         },
 
-        updateCollection = function(uuid, body
+        updateCollection = function(uuid, newContent
         {
             collectionURL <- paste0(private$host, "collections/", uuid)
             headers <- list("Authorization" = paste("OAuth2", private$token),
                             "Content-Type"  = "application/json")
 
+            body <- list(list())
             names(body) <- c("collection")
+            body$collection <- newContent
+
             body <- jsonlite::toJSON(body, auto_unbox = T)
 
             serverResponse <- private$http$PUT(collectionURL, headers, body)
@@ -119,13 +122,16 @@ Arvados <- R6::R6Class(
             collection
         },
 
-        createCollection = function(body
+        createCollection = function(content
         {
             collectionURL <- paste0(private$host, "collections")
             headers <- list("Authorization" = paste("OAuth2", private$token),
                             "Content-Type"  = "application/json")
 
+            body <- list(list())
             names(body) <- c("collection")
+            body$collection <- content
+
             body <- jsonlite::toJSON(body, auto_unbox = T)
 
             serverResponse <- private$http$POST(collectionURL, headers, body)
@@ -153,14 +159,15 @@ Arvados <- R6::R6Class(
             project
         },
 
-        createProject = function(body
+        createProject = function(content
         {
             projectURL <- paste0(private$host, "groups")
             headers <- list("Authorization" = paste("OAuth2", private$token),
                             "Content-Type"  = "application/json")
 
+            body <- list(list())
             names(body) <- c("group")
-            body$group <- c("group_class" = "project", body$group)
+            body$group <- c("group_class" = "project", content)
             body <- jsonlite::toJSON(body, auto_unbox = T)
 
             serverResponse <- private$http$POST(projectURL, headers, body)
@@ -173,13 +180,15 @@ Arvados <- R6::R6Class(
             project
         },
 
-        updateProject = function(uuid, body
+        updateProject = function(uuid, newContent
         {
             projectURL <- paste0(private$host, "groups/", uuid)
             headers <- list("Authorization" = paste("OAuth2", private$token),
                             "Content-Type"  = "application/json")
 
+            body <- list(list())
             names(body) <- c("group")
+            body$group <- newContent
             body <- jsonlite::toJSON(body, auto_unbox = T)
 
             serverResponse <- private$http$PUT(projectURL, headers, body)
index 5ae23c2acca73814caa51e32c7bd62aa8fcefb1f..0c4347352ac043a6fe23826ab630488e05d1c96d 100644 (file)
@@ -51,13 +51,13 @@ deletedCollection <- arv$deleteCollection("uuid")
 
 #Update collection:
 
-updatedCollection <- arv$updateCollection("uuid", list(list(name = "new_name", description = "new_desciption")))
+updatedCollection <- arv$updateCollection("uuid", list(name = "new_name", description = "new_desciption"))
 
 --------------------------------------------------------------------------------------------------------------------------------
 
 #Create collection:
 
-createdCollection <- arv$createCollection(list(list(name = "new_name", description = "new_desciption")))
+createdCollection <- arv$createCollection(list(name = "new_name", description = "new_desciption"))
 
 --------------------------------------------------------------------------------------------------------------------------------
 
@@ -201,12 +201,12 @@ deletedProject <- arv$deleteProject("uuid")
 
 #Update project:
 
-updatedProject <- arv$updateProject("uuid", list(list(name = "new_name", description = "new_desciption")))
+updatedProject <- arv$updateProject("uuid", list(name = "new_name", description = "new_desciption"))
 
 --------------------------------------------------------------------------------------------------------------------------------
 
 #Create project:
 
-createdProject <- arv$createProject(list(list(name = "project_name", description = "project_desciption")))
+createdProject <- arv$createProject(list(name = "project_name", description = "project_desciption"))
 
 --------------------------------------------------------------------------------------------------------------------------------