[ARVADOS] updated: 1.1.1-160-gbe76fcd

Git user git at public.curoverse.com
Tue Dec 5 11:15:12 EST 2017


Summary of changes:
 apps/workbench/test/unit/user_test.rb              |  14 ++
 build/run-build-packages.sh                        |   2 +
 build/run-library.sh                               |   2 +-
 .../methods/container_requests.html.textile.liquid |  16 +-
 doc/api/methods/containers.html.textile.liquid     |   2 +-
 doc/install/install-keepstore.html.textile.liquid  |   2 +-
 sdk/R/.RData                                       | Bin 136720 -> 112519 bytes
 sdk/R/NAMESPACE                                    |   2 +-
 sdk/R/R/Arvados.R                                  | 225 ++++++++---------
 sdk/R/R/Collection.R                               |  39 +--
 sdk/R/R/HttpParser.R                               |   9 +-
 sdk/R/R/HttpRequest.R                              | 221 +++++++----------
 sdk/R/R/custom_classes.R                           |  14 +-
 sdk/R/man/{Collection.Rd => Collection-class.Rd}   |  21 +-
 sdk/R/man/collection_create.Rd                     |  18 --
 sdk/R/man/collection_delete.Rd                     |  24 --
 sdk/R/man/collection_get.Rd                        |  18 --
 sdk/R/man/collection_list.Rd                       |  22 --
 services/api/app/models/container.rb               |   3 +-
 services/api/app/models/container_request.rb       |   7 +-
 services/api/test/fixtures/containers.yml          |   2 +-
 services/api/test/unit/container_request_test.rb   |  43 +++-
 services/api/test/unit/container_test.rb           |  36 +++
 services/arv-git-httpd/main.go                     |  11 +
 .../crunch-dispatch-local/crunch-dispatch-local.go |  16 ++
 .../crunch-dispatch-slurm/crunch-dispatch-slurm.go |  52 +++-
 .../crunch-dispatch-slurm_test.go                  | 246 ++++++++++++-------
 services/crunch-dispatch-slurm/squeue.go           |  42 +++-
 services/crunch-run/crunchrun.go                   |  26 +-
 services/crunch-run/crunchrun_test.go              | 101 ++++++++
 services/crunchstat/crunchstat.go                  |  11 +
 services/fuse/arvados_fuse/command.py              |   1 +
 services/health/main.go                            |  12 +
 services/keep-balance/main.go                      |  12 +
 services/keep-web/handler.go                       |   2 +
 services/keep-web/main.go                          |  12 +
 services/keep-web/status_test.go                   |   1 +
 services/keepproxy/keepproxy.go                    |  11 +
 services/keepstore/handlers.go                     |   2 +
 services/keepstore/keepstore.go                    |  11 +
 services/keepstore/pull_worker_test.go             |   1 +
 services/nodemanager/arvnodeman/launcher.py        |   2 +-
 services/nodemanager/arvnodeman/status.py          |   5 +-
 services/nodemanager/tests/test_status.py          |   1 +
 services/ws/main.go                                |  10 +-
 services/ws/router.go                              |   1 +
 services/ws/server_test.go                         |  16 ++
 tools/arv-sync-groups/arv-sync-groups.go           |  14 +-
 tools/crunchstat-summary/MANIFEST.in               |   2 +-
 .../crunchstat_summary/dygraphs.js                 |   2 +
 .../crunchstat_summary/dygraphs.py                 |   2 +-
 .../crunchstat_summary/synchronizer.js             | 273 +++++++++++++++++++++
 .../crunchstat_summary/webchart.py                 |   4 +-
 tools/keep-block-check/keep-block-check.go         |  13 +
 tools/keep-exercise/keep-exercise.go               |  13 +
 tools/keep-rsync/keep-rsync.go                     |  13 +
 56 files changed, 1170 insertions(+), 513 deletions(-)
 rename sdk/R/man/{Collection.Rd => Collection-class.Rd} (61%)
 delete mode 100644 sdk/R/man/collection_create.Rd
 delete mode 100644 sdk/R/man/collection_delete.Rd
 delete mode 100644 sdk/R/man/collection_get.Rd
 delete mode 100644 sdk/R/man/collection_list.Rd
 create mode 100644 tools/crunchstat-summary/crunchstat_summary/synchronizer.js

       via  be76fcdd9aa19fbf8982df2543685816a4afb1e0 (commit)
       via  2295b8b5c11c0177ff927d147800f6174feb4b9e (commit)
       via  0632129bf7861a6ca3ef4ff4e21006a5f11e8be0 (commit)
       via  c50dc8052ca72ac1ead3236546e5f3d98beaeead (commit)
       via  c53ad9bc61054880ae6d68db8b868556c7278a78 (commit)
       via  0403d3bcd2003b0f88e0140ecfa8a62dae9bfd18 (commit)
       via  bcf069c6a726e219bc40224653268d87776e54aa (commit)
       via  b8f92203bfa5766f9aa8bfb728bb4a1580e7d6d1 (commit)
       via  d7db1f0877015228835fac67d4ad08789d39c520 (commit)
       via  d7b909ceb2646ef0637daaea70c768b799670c60 (commit)
       via  5fae6a137301f1a127ef4cccfc6bce86a6a9506c (commit)
       via  0c888bcc93b559339c8abbce784bdcc44746bca2 (commit)
       via  fb55efaad83acde95234f6c3b1eb54db8a0ca28a (commit)
       via  c4e6d3c9a8a55460c4ee663e66ea1093c6088d4f (commit)
       via  82b6440aaa9f265509770150d80e44319dc66fc7 (commit)
       via  eaf301421b5a71e8344688723c3852e7bd5154b8 (commit)
       via  83bd8999a9cc528ff0169d19bd9d974760a59a45 (commit)
       via  0910e857cbde6a23802ba026c3e5811e9d7b1d97 (commit)
       via  0e2cc747caebc3e07cbbf0ed6ee18e8141646080 (commit)
       via  59a04ec098d646b97f5b11da19d380bddedf59fd (commit)
       via  1cd144fe8da5fdc1d2e2e0ba2a3dcf47fc717251 (commit)
       via  0c3b77f80068f8f5924c9f94e64a48edcbce47c7 (commit)
       via  df658c5cf9ae6e86f94d1a6ef1de69ce7981cf97 (commit)
       via  f24bdaa4bebace7d4959053b47a6ef139e4b02a7 (commit)
       via  540ae1f8ada2b51a34ec244473f45bc03714019a (commit)
       via  0b1508df7ee4526340e8834422dd49ced63ee8d9 (commit)
       via  10993634c308dc62dd5e60f7d8d8ebf0391dd050 (commit)
       via  28560112303491b46c46377bc051e605e36a0927 (commit)
       via  0bc641e077a050b3f86957514fae0e4d8ba1770b (commit)
       via  ab3d39a8fdbc76425f48988c27187f3b54967ff9 (commit)
       via  c108a18d477c34c7f89d9a27af34751133329786 (commit)
       via  ca71780328ebc4c2e6d524f0b7a82d72c6036cc0 (commit)
       via  3134a937ab5133d73c799618f2a53e21e7c8a460 (commit)
       via  c24ca3f718f8d97103ef178546df4431ffaa2572 (commit)
       via  d2fe8d01732f69f2c19138b2619c09ef498d18e9 (commit)
       via  92656b214ed120c631bc6adab3b35992939e2ced (commit)
       via  60a60a176c77488cfacc7fd02e03b7b8c69de587 (commit)
       via  7209d0ade292bebbc8d92f8200778b3250e4130a (commit)
       via  cb9c8f800495b8a499348d931326a06f020b8ffa (commit)
       via  ca06cfbda0e84d469f7810a280cfa4dfa8997260 (commit)
      from  2d8d861fadc8f3e0e7d5524c78f980dedc56f759 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit be76fcdd9aa19fbf8982df2543685816a4afb1e0
Merge: 2295b8b 0632129
Author: Fuad Muhic <fmuhic at capeannenterprises.com>
Date:   Tue Dec 5 17:14:32 2017 +0100

    Merge branch 'master' of git.curoverse.com:arvados into 11876-r-sdk
    
    Arvados-DCO-1.1-Signed-off-by: Fuad Muhic <fmuhic at capeannenterprises.com>


commit 2295b8b5c11c0177ff927d147800f6174feb4b9e
Author: Fuad Muhic <fmuhic at capeannenterprises.com>
Date:   Tue Dec 5 15:35:27 2017 +0100

    Refactored most of the code.
    
    Arvados-DCO-1.1-Signed-off-by: Fuad Muhic <fmuhic at capeannenterprises.com>

diff --git a/sdk/R/.RData b/sdk/R/.RData
index 1e0b193..0f875af 100644
Binary files a/sdk/R/.RData and b/sdk/R/.RData differ
diff --git a/sdk/R/NAMESPACE b/sdk/R/NAMESPACE
index 41f3994..f9e576a 100644
--- a/sdk/R/NAMESPACE
+++ b/sdk/R/NAMESPACE
@@ -1,4 +1,4 @@
 # Generated by roxygen2: do not edit by hand
 
 export(Arvados)
-export(Collection)
+exportClasses(Collection)
diff --git a/sdk/R/R/Arvados.R b/sdk/R/R/Arvados.R
index d502b8d..abd07f9 100644
--- a/sdk/R/R/Arvados.R
+++ b/sdk/R/R/Arvados.R
@@ -15,169 +15,138 @@ Arvados <- setRefClass(
     "Arvados",
 
     fields = list(
-        token = "ANY",
-        host  = "ANY"
+
+        getToken          = "function",
+        getHostName       = "function",
+
+        #Todo(Fudo): These are hardcoded and for debug only. Remove them later on.
+        getWebDavToken    = "function",
+        getWebDavHostName = "function",
+
+        collection_get    = "function",
+        collection_list   = "function",
+        collection_create = "function",
+        collection_update = "function",
+        collection_delete = "function"
     ),
 
     methods = list(
 
         initialize = function(auth_token = NULL, host_name = NULL) 
         {
-            version <- "v1"
-            #Todo(Fudo): Set environment variables
-            token <<- auth_token
-            host  <<- paste0("https://", host_name, "/arvados/", version, "/")
-        }
-    )
-)
+            # Private state
+            if(!is.null(host_name))
+               Sys.setenv(ARVADOS_API_HOST  = host_name)
 
-#' collection_get
-#'
-#' Get Arvados collection
-#'
-#' @name collection_get
-#' @field uuid UUID of the given collection
-#' @examples arv = Arvados("token", "hostName")
-#' @examples arv$collection_get("uuid")
-Arvados$methods(
-
-    collection_get = function(uuid) 
-    {
-        collection_relative_url <- paste0("collections/", uuid)
-        http_request <- HttpRequest("GET", token, host, collection_relative_url) 
-        server_response <- http_request$execute()
-
-        httpParser <- HttpParser()
-        collection <- httpParser$parseCollectionGet(server_response)
+            if(!is.null(auth_token))
+                Sys.setenv(ARVADOS_API_TOKEN = auth_token)
 
-        if(!is.null(collection$errors))
-            stop(collection$errors)       
+            host  <- Sys.getenv("ARVADOS_API_HOST");
+            token <- Sys.getenv("ARVADOS_API_TOKEN");
 
-        class(collection) <- "ArvadosCollection"
+            if(host == "" | token == "")
+                stop("Please provide host name and authentification token or set ARVADOS_API_HOST and ARVADOS_API_TOKEN environmental variables.")
 
-        return(collection)
-    }
-)
-
-#' collection_list
-#'
-#' Retreive list of collections based on provided filter.
-#'
-#' @name collection_list
-#' @field filters List of filters we want to use to retreive list of collections.
-#' @field limit Limits the number of result returned by server.
-#' @field offset Offset from beginning of the result set.
-#' @examples arv = Arvados("token", "hostName")
-#' @examples arv$collection_list(list("uuid", "=" "aaaaa-bbbbb-ccccccccccccccc"))
-Arvados$methods(
+            version <- "v1"
+            host  <- paste0("https://", host, "/arvados/", version, "/")
 
-    collection_list = function(filters = NULL, limit = NULL, offset = NULL) 
-    {
-        #Todo(Fudo): Implement limit and offset
-        collection_relative_url <- "collections"
-        http_request <- HttpRequest("GET", token, host, collection_relative_url,
-                                    body = NULL,  filters, limit, offset) 
+            # Public methods
+            getToken <<- function() { token }
+            getHostName <<- function() { host }
 
-        server_response <- http_request$execute()
+            #Todo(Fudo): Hardcoded credentials to WebDAV server. Remove them later
+            getWebDavToken    <<- function() { "4invqy35tf70t7hmvdc83ges8ug9cklhgqq1l8gj2cjn18teuq" }
+            getWebDavHostName <<- function() { "https://collections.4xphq.arvadosapi.com/c=4xphq-4zz18-9d5b0qm4fgijeyi/_/" }
 
-        httpParser <- HttpParser()
-        collection <- httpParser$parseCollectionGet(server_response)
+            collection_get <<- function(uuid) 
+            {
+                collection_url <- paste0(host, "collections/", uuid)
+                headers <- list(Authorization = paste("OAuth2", token))
 
-        if(!is.null(collection$errors))
-            stop(collection$errors)       
+                http <- HttpRequest() 
+                serverResponse <- http$GET(collection_url, headers)
 
-        class(collection) <- "ArvadosCollectionList"
+                httpParser <- HttpParser()
+                collection <- httpParser$parseJSONResponse(serverResponse)
 
-        return(collection)
-    }
-)
+                if(!is.null(collection$errors))
+                    stop(collection$errors)       
 
-#' collection_create
-#'
-#' Create Arvados collection
-#'
-#' @name collection_create
-#' @field body Structure of the collection we want to create.
-#' @examples arv = Arvados("token", "hostName")
-#' @examples arv$collection_create(list(collection = list(name = "myCollection")))
-Arvados$methods(
+                collection
+            }
 
-    collection_create = function(body) 
-    {
-        collection_relative_url <- paste0("collections/", "/?alt=json")
-        body = jsonlite::toJSON(body, auto_unbox = T)
+            collection_list <<- function(filters = NULL, limit = 100, offset = 0) 
+            {
+                collection_url <- paste0(host, "collections")
+                headers <- list(Authorization = paste("OAuth2", token))
 
-        http_request    <- HttpRequest("POST", token, host, collection_relative_url, body) 
-        server_response <- http_request$execute()
+                http <- HttpRequest() 
+                serverResponse <- http$GET(collection_url, headers, NULL, filters, limit, offset)
 
-        httpParser <- HttpParser()
-        collection <- httpParser$parseCollectionGet(server_response)
+                httpParser <- HttpParser()
+                collection <- httpParser$parseJSONResponse(serverResponse)
 
-        if(!is.null(collection$errors))
-            stop(collection$errors)       
+                if(!is.null(collection$errors))
+                    stop(collection$errors)       
 
-        class(collection) <- "ArvadosCollection"
+                collection
+            }
 
-        return(collection)
-    }
-)
+            collection_delete <<- function(uuid) 
+            {
+                collection_url <- paste0(host, "collections/", uuid)
+                headers <- list("Authorization" = paste("OAuth2", token),
+                                "Content-Type"  = "application/json")
 
-#' collection_delete
-#'
-#' Delete Arvados collection
-#'
-#' @name collection_delete
-#' @field uuid UUID of the collection we want to delete.
-#' @examples arv = Arvados("token", "hostName")
-#' @examples arv$collection_delete(uuid = "aaaaa-bbbbb-ccccccccccccccc")
-Arvados$methods(
+                http <- HttpRequest() 
+                serverResponse <- http$DELETE(collection_url, headers)
 
-    collection_delete = function(uuid) 
-    {
-        collection_relative_url <- paste0("collections/", uuid, "/?alt=json")
+                httpParser <- HttpParser()
+                collection <- httpParser$parseJSONResponse(serverResponse)
 
-        http_request    <- HttpRequest("DELETE", token, host, collection_relative_url) 
-        server_response <- http_request$execute()
+                if(!is.null(collection$errors))
+                    stop(collection$errors)       
 
-        httpParser <- HttpParser()
-        collection <- httpParser$parseCollectionGet(server_response)
+                collection
+            }
 
-        if(!is.null(collection$errors))
-            stop(collection$errors)       
+            collection_update <<- function(uuid, body) 
+            {
+                collection_url <- paste0(host, "collections/", uuid)
+                headers <- list("Authorization" = paste("OAuth2", token),
+                                "Content-Type"  = "application/json")
+                body <- jsonlite::toJSON(body, auto_unbox = T)
 
-        class(collection) <- "ArvadosCollection"
+                http <- HttpRequest() 
+                serverResponse <- http$PUT(collection_url, headers, body)
 
-        return(collection)
-    }
-)
+                httpParser <- HttpParser()
+                collection <- httpParser$parseJSONResponse(serverResponse)
 
-#' collection_update
-#'
-#' Update Arvados collection
-#'
-#' @name collection_update
-#' @field uuid UUID of the collection we want to update.
-#' @field body New structure of the collection.
-#' @examples arv = Arvados("token", "hostName")
-#' @examples arv$collection_update(uuid = "aaaaa-bbbbb-ccccccccccccccc", list(collection = list(name = "newName")))
-Arvados$methods(
+                if(!is.null(collection$errors))
+                    stop(collection$errors)       
 
-    collection_update = function(uuid, body) 
-    {
-        collection_relative_url <- paste0("collections/", uuid, "/?alt=json")
-        body = jsonlite::toJSON(body, auto_unbox = T)
+                collection
+            }
 
-        http_request    <- HttpRequest("PUT", token, host, collection_relative_url, body) 
-        server_response <- http_request$execute()
+            collection_create <<- function(body) 
+            {
+                collection_url <- paste0(host, "collections")
+                headers <- list("Authorization" = paste("OAuth2", token),
+                                "Content-Type"  = "application/json")
+                body <- jsonlite::toJSON(body, auto_unbox = T)
 
-        httpParser <- HttpParser()
-        collection <- httpParser$parseCollectionGet(server_response)
+                http <- HttpRequest() 
+                serverResponse <- http$POST(collection_url, headers, body)
 
-        if(!is.null(collection$errors))
-            stop(collection$errors)       
+                httpParser <- HttpParser()
+                collection <- httpParser$parseJSONResponse(serverResponse)
 
-        class(collection) <- "ArvadosCollection"
+                if(!is.null(collection$errors))
+                    stop(collection$errors)       
 
-        return(collection)
-    }
+                collection
+            }
+        }
+    )
 )
diff --git a/sdk/R/R/Collection.R b/sdk/R/R/Collection.R
index 037f711..cf2a612 100644
--- a/sdk/R/R/Collection.R
+++ b/sdk/R/R/Collection.R
@@ -33,7 +33,6 @@ Collection <- setRefClass(
 
     "Collection",
 
-    #NOTE(Fudo): Fix types!
     fields = list(uuid                     = "ANY",
                   items                    = "ANY",
                   etag                     = "ANY",
@@ -55,16 +54,18 @@ Collection <- setRefClass(
                   file_names               = "ANY",
                   trash_at                 = "ANY",
                   is_trashed               = "ANY",
-                  arvados_api              = "Arvados"
+
+                  getCollectionContent = "function"
     ),
 
     methods = list(
 
         initialize = function(api, uuid) 
         {
-            arvados_api <<- api
-            result <- arvados_api$collection_get(uuid)
+
+            result <- api$collection_get(uuid)
             
+            # Private members
             uuid                     <<- result$uuid                               
             etag                     <<- result$etag                               
             owner_uuid               <<- result$owner_uuid                         
@@ -86,23 +87,27 @@ Collection <- setRefClass(
             trash_at                 <<- result$trash_at                           
             is_trashed               <<- result$is_trashed                         
 
-            items  <<- getCollectionContent()
-        },
 
-        getCollectionContent = function()
-        {
-            #IMPORTANT(Fudo): This url is hardcoded for now. Fix it later.
-            uri <- URLencode("https://collections.4xphq.arvadosapi.com/c=4xphq-4zz18-9d5b0qm4fgijeyi/_/")
+            #Public methods
 
-            # fetch directory listing via curl and parse XML response
-            h <- curl::new_handle()
-            curl::handle_setopt(h, customrequest = "PROPFIND")
+            # Private methods
+            getCollectionContent <<- function()
+            {
+                #TODO(Fudo): Use proper URL here.
+                uri <- URLencode(api$getWebDavHostName())
 
-            #IMPORTANT(Fudo): Token is hardcoded as well. Write it properly.
-            curl::handle_setheaders(h, "Authorization" = paste("OAuth2 4invqy35tf70t7hmvdc83ges8ug9cklhgqq1l8gj2cjn18teuq"))
-            response <- curl::curl_fetch_memory(uri, h)
+                # fetch directory listing via curl and parse XML response
+                h <- curl::new_handle()
+                curl::handle_setopt(h, customrequest = "PROPFIND")
 
-            HttpParser()$parseWebDAVResponse(response, uri)
+                #TODO(Fudo): Use proper token here.
+                curl::handle_setheaders(h, "Authorization" = paste("OAuth2", api$getWebDavToken()))
+                response <- curl::curl_fetch_memory(uri, h)
+
+                HttpParser()$parseWebDAVResponse(response, uri)
+            }
+
+            items  <<- getCollectionContent()
         }
     )
 )
diff --git a/sdk/R/R/HttpParser.R b/sdk/R/R/HttpParser.R
index ebe7d8c..bbe0a60 100644
--- a/sdk/R/R/HttpParser.R
+++ b/sdk/R/R/HttpParser.R
@@ -19,6 +19,13 @@ HttpParser <- setRefClass(
             #Todo(Fudo): Create new Collection object and populate it
         },
 
+        parseJSONResponse = function(server_response) 
+        {
+            parsed_response <- httr::content(server_response, as = "parsed", type = "application/json")
+
+            #Todo(Fudo): Create new Collection object and populate it
+        },
+
         parseWebDAVResponse = function(response, uri)
         {
             #Todo(Fudo): Move this to HttpParser.
@@ -29,7 +36,7 @@ HttpParser <- setRefClass(
             base <- paste(paste("/", strsplit(uri, "/")[[1]][-1:-3], sep="", collapse=""), "/", sep="")
             result <- unlist(
                 XML::xpathApply(doc, "//D:response/D:href", function(node) {
-                    sub(base, "", URLdecode(xmlValue(node)), fixed=TRUE)
+                    sub(base, "", URLdecode(XML::xmlValue(node)), fixed=TRUE)
                 })
             )
             result[result != ""]
diff --git a/sdk/R/R/HttpRequest.R b/sdk/R/R/HttpRequest.R
index 041d64d..eecf0c1 100644
--- a/sdk/R/R/HttpRequest.R
+++ b/sdk/R/R/HttpRequest.R
@@ -5,163 +5,126 @@ HttpRequest <- setRefClass(
     "HttrRequest",
 
     fields = list(
-        send_method         = "character",
-        server_base_url     = "character",
-        server_relative_url = "character",
-        auth_token          = "character",
-        allowed_methods     = "list",
-        request_body        = "ANY",
-        query_filters       = "ANY",
-        response_limit      = "ANY",
-        query_offset        = "ANY"
+
+        GET    = "function",
+        PUT    = "function",
+        POST   = "function",
+        DELETE = "function"
     ),
 
     methods = list(
-        initialize = function(method,
-                              token,
-                              base_url,
-                              relative_url,
-                              body = NULL,
-                              filters = NULL,
-                              limit = 100,
-                              offset = 0) 
-        {
-            send_method         <<- method
-            auth_token          <<- token
-            server_base_url     <<- base_url
-            server_relative_url <<- relative_url
-            request_body        <<- body
-            query_filters       <<- filters
-            response_limit      <<- limit
-            query_offset        <<- offset
-        },
-
-        execute = function() 
+        initialize = function() 
         {
-            #Todo(Fudo): Get rid of the switch and make this module more general.
-            http_method <- switch(send_method,
-                                  "GET"    = .self$getRequest,
-                                  "POST"   = .self$postRequest,
-                                  "PUT"    = .self$putRequest,
-                                  "DELETE" = .self$deleteRequest,
-                                  "PATCH"  = .self$pathcRequest)
-            http_method()
-        },
-
-        getRequest = function() 
-        {
-            requestHeaders <- httr::add_headers(Authorization = .self$getAuthHeader())
-            requestQuery   <- .self$generateQuery()
-            url            <- paste0(server_base_url, server_relative_url, requestQuery)
-
-            server_data <- httr::GET(url    = url,
-                                     config = requestHeaders)
-        },
+            # Public methods
+            GET <<- function(url, headers = NULL, body = NULL,
+                             queryFilters = NULL, limit = 100, offset = 0)
+            {
+                print(limit)
+                headers <- httr::add_headers(unlist(headers))
+                query <- .createQuery(queryFilters, limit, offset)
+                url <- paste0(url, query)
+                print(url)
 
-        #Todo(Fudo): Try to make this more generic
-        postRequest = function() 
-        {
-            url <- paste0(server_base_url, server_relative_url)
-            requestHeaders <- httr::add_headers("Authorization" = .self$getAuthHeader(),
-                                                "Content-Type"  = "application/json")
-            response <- POST(url, body = request_body, config = requestHeaders)
-        },
+                serverResponse <- httr::GET(url = url, config = headers)
+            }
 
-        putRequest = function() 
-        {
-            url <- paste0(server_base_url, server_relative_url)
-            requestHeaders <- httr::add_headers("Authorization" = .self$getAuthHeader(),
-                                                "Content-Type"  = "application/json")
+            PUT <<- function(url, headers = NULL, body = NULL,
+                             queryFilters = NULL, limit = 100, offset = 0)
+            {
+                headers <- httr::add_headers(unlist(headers))
+                query <- .createQuery(queryFilters, limit, offset)
+                url <- paste0(url, query)
 
-            response <- PUT(url, body = request_body, config = requestHeaders)
-        },
+                serverResponse <- httr::PUT(url = url, config = headers, body = body)
+            }
 
-        deleteRequest = function() 
-        {
-            url <- paste0(server_base_url, server_relative_url)
-            requestHeaders <- httr::add_headers("Authorization" = .self$getAuthHeader(),
-                                                "Content-Type"  = "application/json")
-            response <- DELETE(url, config = requestHeaders)
-        },
+            POST <<- function(url, headers = NULL, body = NULL,
+                              queryFilters = NULL, limit = 100, offset = 0)
+            {
+                headers <- httr::add_headers(unlist(headers))
+                query <- .createQuery(queryFilters, limit, offset)
+                url <- paste0(url, query)
 
-        pathcRequest = function() 
-        {
-            #Todo(Fudo): Implement this later on.
-            print("PATCH method")
-        },
+                serverResponse <- httr::POST(url = url, config = headers, body = body)
+            }
 
-        getAuthHeader = function() 
-        {
-            auth_method <- "OAuth2"
-            auth_header <- paste(auth_method, auth_token)
-        },
+            DELETE <<- function(url, headers = NULL, body = NULL,
+                             queryFilters = NULL, limit = 100, offset = 0)
+            {
+                headers <- httr::add_headers(unlist(headers))
+                query <- .createQuery(queryFilters, limit, offset)
+                url <- paste0(url, query)
 
-        generateQuery = function() 
-        {
-            #Todo(Fudo): This function is a mess, refactor it
-            finalQuery <- "?alt=json"
+                serverResponse <- httr::DELETE(url = url, config = headers)
+            }
 
-            if(!is.null(query_filters))
+            # Private methods
+            .createQuery <- function(filters, limit, offset)
             {
-                filters <- sapply(query_filters, function(filter)
+                finalQuery <- "?alt=json"
+
+                if(!is.null(filters))
                 {
-                    if(length(filter) != 3)
-                        stop("Filter list must have exacthey 3 elements.")
+                    filters <- sapply(filters, function(filter)
+                    {
+                        if(length(filter) != 3)
+                            stop("Filter list must have exacthey 3 elements.")
 
-                    attributeAndOperator = filter[c(1, 2)]
-                    filterList = filter[[3]]
-                    filterListIsPrimitive = TRUE
-                    if(length(filterList) > 1)
-                        filterListIsPrimitive = FALSE
+                        attributeAndOperator = filter[c(1, 2)]
+                        filterList = filter[[3]]
+                        filterListIsPrimitive = TRUE
+                        if(length(filterList) > 1)
+                            filterListIsPrimitive = FALSE
 
-                    attributeAndOperator <- sapply(attributeAndOperator, function(component) {
-                        component <- paste0("\"", component, "\"")
-                    })
+                        attributeAndOperator <- sapply(attributeAndOperator, function(component) {
+                            component <- paste0("\"", component, "\"")
+                        })
 
-                    filterList <- sapply(unlist(filterList), function(filter) {
-                        filter <- paste0("\"", filter, "\"")
-                    })
+                        filterList <- sapply(unlist(filterList), function(filter) {
+                            filter <- paste0("\"", filter, "\"")
+                        })
 
-                    filterList <- paste(filterList, collapse = ",+")
+                        filterList <- paste(filterList, collapse = ",+")
 
-                    if(!filterListIsPrimitive)
-                        filterList <- paste0("[", filterList, "]")
+                        if(!filterListIsPrimitive)
+                            filterList <- paste0("[", filterList, "]")
 
-                    filter <- c(attributeAndOperator, filterList)
+                        filter <- c(attributeAndOperator, filterList)
 
-                    queryParameter <- paste(filter, collapse = ",+")
-                    queryParameter <- paste0("[", queryParameter, "]")
-        
-                })
+                        queryParameter <- paste(filter, collapse = ",+")
+                        queryParameter <- paste0("[", queryParameter, "]")
+            
+                    })
 
-                filters <- paste(filters, collapse = ",+")
-                filters <- paste0("[", filters, "]")
+                    filters <- paste(filters, collapse = ",+")
+                    filters <- paste0("[", filters, "]")
 
-                encodedQuery <- URLencode(filters, reserved = T, repeated = T)
+                    encodedQuery <- URLencode(filters, reserved = T, repeated = T)
 
-                finalQuery <- paste0(finalQuery, "&filters=", encodedQuery)
+                    finalQuery <- paste0(finalQuery, "&filters=", encodedQuery)
 
-                #Todo(Fudo): This is a hack for now. Find a proper solution.
-                finalQuery <- stringr::str_replace_all(finalQuery, "%2B", "+")
-            }
+                    #Todo(Fudo): This is a hack for now. Find a proper solution.
+                    finalQuery <- stringr::str_replace_all(finalQuery, "%2B", "+")
+                }
 
-            if(!is.null(response_limit))
-            {
-                if(!is.numeric(response_limit))
-                    stop("Limit must be a numeric type.")
-                
-                finalQuery <- paste0(finalQuery, "&limit=", response_limit)
-            }
+                if(!is.null(limit))
+                {
+                    if(!is.numeric(limit))
+                        stop("Limit must be a numeric type.")
+                    
+                    finalQuery <- paste0(finalQuery, "&limit=", limit)
+                }
 
-            if(!is.null(query_offset))
-            {
-                if(!is.numeric(query_offset))
-                    stop("Offset must be a numeric type.")
-                
-                finalQuery <- paste0(finalQuery, "&offset=", query_offset)
-            }
+                if(!is.null(offset))
+                {
+                    if(!is.numeric(offset))
+                        stop("Offset must be a numeric type.")
+                    
+                    finalQuery <- paste0(finalQuery, "&offset=", offset)
+                }
 
-            finalQuery
+                finalQuery
+            }
         }
     )
 )
diff --git a/sdk/R/R/custom_classes.R b/sdk/R/R/custom_classes.R
index 89d1d12..22f1f76 100644
--- a/sdk/R/R/custom_classes.R
+++ b/sdk/R/R/custom_classes.R
@@ -1,11 +1,3 @@
-#Study(Fudo): For some reason this doesnt seem to work,
-#see what seems to be a problem.
-
-setOldClass("characterOrNULL")
-setClassUnion("characterOrNULL", c("character", "NULL"))
-
-setClassUnion("listOrNULL", c("list", "NULL"))
-setOldClass("listOrNULL")
-
-setOldClass("numericOrNULL")
-setClassUnion("numericOrNULL", c("numeric", "NULL"))
+setClassUnion("characterOrNull", c("character", "NULL"))
+setClassUnion("listOrNull", c("list", "NULL"))
+setClassUnion("numericOrNull", c("numeric", "NULL"))
diff --git a/sdk/R/man/Collection.Rd b/sdk/R/man/Collection-class.Rd
similarity index 61%
rename from sdk/R/man/Collection.Rd
rename to sdk/R/man/Collection-class.Rd
index add30b1..79a771a 100644
--- a/sdk/R/man/Collection.Rd
+++ b/sdk/R/man/Collection-class.Rd
@@ -1,18 +1,10 @@
 % Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/arvados_objects.R
-\name{Collection}
+% Please edit documentation in R/Collection.R
+\docType{class}
+\name{Collection-class}
+\alias{Collection-class}
 \alias{Collection}
 \title{Collection Object}
-\usage{
-Collection(uuid = NULL, etag = NULL, owner_uuid = NULL,
-  created_at = NULL, modified_by_client_uuid = NULL,
-  modified_by_user_uuid = NULL, modified_at = NULL,
-  portable_data_hash = NULL, replication_desired = NULL,
-  replication_confirmed_at = NULL, replication_confirmed = NULL,
-  updated_at = NULL, manifest_text = NULL, name = NULL,
-  description = NULL, properties = NULL, delete_at = NULL,
-  file_names = NULL, trash_at = NULL, is_trashed = NULL)
-}
 \arguments{
 \item{uuid}{Object ID}
 
@@ -54,9 +46,6 @@ Collection(uuid = NULL, etag = NULL, owner_uuid = NULL,
 
 \item{is_trashed}{No description}
 }
-\value{
-Collection object
-}
 \description{
 Collection Object
 }
@@ -64,4 +53,4 @@ Collection Object
 Todo: Update description
 Collection
 }
-\concept{Collection functions}
+
diff --git a/sdk/R/man/collection_create.Rd b/sdk/R/man/collection_create.Rd
deleted file mode 100644
index 4a0509b..0000000
--- a/sdk/R/man/collection_create.Rd
+++ /dev/null
@@ -1,18 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/Arvados.R
-\name{collection_create}
-\alias{collection_create}
-\title{collection_create}
-\description{
-Create Arvados collection
-}
-\section{Fields}{
-
-\describe{
-\item{\code{body}}{Structure of the collection we want to create.}
-}}
-
-\examples{
-arv = Arvados("token", "host_name")
-arv$collection_create(list(collection = list(name = "myCollection")))
-}
diff --git a/sdk/R/man/collection_delete.Rd b/sdk/R/man/collection_delete.Rd
deleted file mode 100644
index 5c37a9b..0000000
--- a/sdk/R/man/collection_delete.Rd
+++ /dev/null
@@ -1,24 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/Arvados.R
-\name{collection_delete}
-\alias{collection_delete}
-\title{collection_delete}
-\description{
-Delete Arvados collection
-
-Delete Arvados collection
-}
-\section{Fields}{
-
-\describe{
-\item{\code{uuid}}{UUID of the collection we want to delete.}
-
-\item{\code{uuid}}{UUID of the collection we want to delete.}
-}}
-
-\examples{
-arv = Arvados("token", "host_name")
-arv$collection_delete(uuid = "aaaaa-bbbbb-ccccccccccccccc")
-arv = Arvados("token", "host_name")
-arv$collection_delete(uuid = "aaaaa-bbbbb-ccccccccccccccc")
-}
diff --git a/sdk/R/man/collection_get.Rd b/sdk/R/man/collection_get.Rd
deleted file mode 100644
index e29170b..0000000
--- a/sdk/R/man/collection_get.Rd
+++ /dev/null
@@ -1,18 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/Arvados.R
-\name{collection_get}
-\alias{collection_get}
-\title{collection_get}
-\description{
-Get Arvados collection
-}
-\section{Fields}{
-
-\describe{
-\item{\code{uuid}}{UUID of the given collection}
-}}
-
-\examples{
-arv = Arvados("token", "host_name")
-arv$collection_get("uuid")
-}
diff --git a/sdk/R/man/collection_list.Rd b/sdk/R/man/collection_list.Rd
deleted file mode 100644
index a1a73d7..0000000
--- a/sdk/R/man/collection_list.Rd
+++ /dev/null
@@ -1,22 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/Arvados.R
-\name{collection_list}
-\alias{collection_list}
-\title{collection_list}
-\description{
-Retreive list of collections based on provided filter.
-}
-\section{Fields}{
-
-\describe{
-\item{\code{filters}}{List of filters we want to use to retreive list of collections.}
-
-\item{\code{limit}}{Limits the number of result returned by server.}
-
-\item{\code{offset}}{Offset from beginning of the result set.}
-}}
-
-\examples{
-arv = Arvados("token", "host_name")
-arv$collection_list(list("uuid", "=" "aaaaa-bbbbb-ccccccccccccccc"))
-}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list