X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/711711827bb0c3564836707bb7d4453c60c6a98c..8e43dcf899a3322e66c709b149ce557f5255bf18:/sdk/R/R/RESTService.R diff --git a/sdk/R/R/RESTService.R b/sdk/R/R/RESTService.R index 867665299f..9c65e72861 100644 --- a/sdk/R/R/RESTService.R +++ b/sdk/R/R/RESTService.R @@ -36,16 +36,13 @@ RESTService <- R6::R6Class( { if(is.null(private$webDavHostName)) { - discoveryDocumentURL <- paste0("https://", private$rawHostName, - "/discovery/v1/apis/arvados/v1/rest") + publicConfigURL <- paste0("https://", private$rawHostName, + "/arvados/v1/config") - headers <- list(Authorization = paste("OAuth2", self$token)) - - serverResponse <- self$http$exec("GET", discoveryDocumentURL, headers, - retryTimes = self$numRetries) + serverResponse <- self$http$exec("GET", publicConfigURL, retryTimes = self$numRetries) - discoveryDocument <- self$httpParser$parseJSONResponse(serverResponse) - private$webDavHostName <- discoveryDocument$keepWebServiceUrl + configDocument <- self$httpParser$parseJSONResponse(serverResponse) + private$webDavHostName <- configDocument$Services$WebDAVDownload$ExternalURL if(is.null(private$webDavHostName)) stop("Unable to find WebDAV server.") @@ -81,10 +78,10 @@ RESTService <- R6::R6Class( { collectionURL <- paste0(self$getWebDavHostName(), "c=", uuid, "/") fromURL <- paste0(collectionURL, from) - toURL <- paste0(collectionURL, to) + toURL <- paste0(collectionURL, trimFromStart(to, "/")) headers <- list("Authorization" = paste("OAuth2", self$token), - "Destination" = toURL) + "Destination" = toURL) serverResponse <- self$http$exec("MOVE", fromURL, headers, retryTimes = self$numRetries) @@ -95,12 +92,30 @@ RESTService <- R6::R6Class( serverResponse }, + copy = function(from, to, uuid) + { + collectionURL <- paste0(self$getWebDavHostName(), "c=", uuid, "/") + fromURL <- paste0(collectionURL, from) + toURL <- paste0(collectionURL, trimFromStart(to, "/")) + + headers <- list("Authorization" = paste("OAuth2", self$token), + "Destination" = toURL) + + serverResponse <- self$http$exec("COPY", fromURL, headers, + retryTimes = self$numRetries) + + if(serverResponse$status_code < 200 || serverResponse$status_code >= 300) + stop(paste("Server code:", serverResponse$status_code)) + + serverResponse + }, + getCollectionContent = function(uuid) { collectionURL <- URLencode(paste0(self$getWebDavHostName(), "c=", uuid)) - headers <- list("Authorization" = paste("OAuth2", self$token)) + headers <- list("Authorization" = paste("Bearer", self$token)) response <- self$http$exec("PROPFIND", collectionURL, headers, retryTimes = self$numRetries)