Added methods listAllCollections and listAllProjects.
[arvados.git] / sdk / R / R / HttpRequest.R
index f5c11a176fd16fd1c14e9c365d24dd6aafbc369d..a1e1f61275263ec63910f5d48a5d017621fb02ff 100644 (file)
@@ -4,8 +4,11 @@ HttpRequest <- R6::R6Class(
 
     public = list(
 
+        validContentTypes = NULL,
+
         initialize = function() 
         {
+            self$validContentTypes <- c("text", "raw")
         },
 
         GET = function(url, headers = NULL, queryFilters = NULL, limit = NULL, offset = NULL)
@@ -53,14 +56,21 @@ HttpRequest <- R6::R6Class(
             curl::handle_setopt(h, customrequest = "PROPFIND")
             curl::handle_setheaders(h, .list = headers)
 
+            propfindResponse <- curl::curl_fetch_memory(url, h)
+        },
+
+        MOVE = function(url, headers = NULL)
+        {
+            h <- curl::new_handle()
+            curl::handle_setopt(h, customrequest = "MOVE")
+            curl::handle_setheaders(h, .list = headers)
+
             propfindResponse <- curl::curl_fetch_memory(url, h)
         }
     ),
 
     private = list(
 
-        #Todo(Fudo): Refactor this and find a better way to build
-        # Python array from R list (recursion?)
         createQuery = function(filters, limit, offset)
         {
             finalQuery <- NULL
@@ -70,7 +80,7 @@ HttpRequest <- R6::R6Class(
                 filters <- sapply(filters, function(filter)
                 {
                     if(length(filter) != 3)
-                        stop("Filter list must have exacthey 3 elements.")
+                        stop("Filter list must have exactly 3 elements.")
 
                     attributeAndOperator = filter[c(1, 2)]
                     filterList = filter[[3]]
@@ -103,7 +113,6 @@ HttpRequest <- R6::R6Class(
 
                 encodedQuery <- URLencode(filters, reserved = T, repeated = T)
 
-                #Todo(Fudo): This is a hack for now. Find a proper solution.
                 encodedQuery <- stringr::str_replace_all(encodedQuery, "%2B", "+")
 
                 finalQuery <- c(finalQuery, paste0("filters=", encodedQuery))
@@ -130,9 +139,10 @@ HttpRequest <- R6::R6Class(
             if(length(finalQuery) > 1)
             {
                 finalQuery <- paste0(finalQuery, collapse = "&")
-                finalQuery <- paste0("?", finalQuery)
             }
 
+            finalQuery <- paste0("/?", finalQuery)
+
             finalQuery
         }
     ),