20259: Add documentation for banner and tooltip features
[arvados.git] / sdk / R / R / Arvados.R
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: Apache-2.0
4
5 #' R6 Class Representing a Arvados
6 #'
7 #' @description
8 #' Arvados class gives users ability to access Arvados REST API. It also allowes user to manipulate collections (and projects?)
9
10 #' @export Arvados
11 Arvados <- R6::R6Class(
12
13     "Arvados",
14
15     public = list(
16
17         #' @description
18         #' Initialize new enviroment.
19         #' @param authToken ARVADOS_API_TOKEN from 'Get API Token' on Arvados.
20         #' @param hostName ARVADOS_API_HOST from 'Get API Token' on Arvados.
21         #' @param numRetries Specify number of times to retry failed service requests.
22         #' @return A new `Arvados` object.
23         #' @examples
24         #' arv <- Arvados$new(authToken = "ARVADOS_API_TOKEN", hostName = "ARVADOS_API_HOST", numRetries = 3)
25         initialize = function(authToken = NULL, hostName = NULL, numRetries = 0)
26         {
27             if(!is.null(hostName))
28                 Sys.setenv(ARVADOS_API_HOST = hostName)
29
30             if(!is.null(authToken))
31                 Sys.setenv(ARVADOS_API_TOKEN = authToken)
32
33             hostName <- Sys.getenv("ARVADOS_API_HOST")
34             token    <- Sys.getenv("ARVADOS_API_TOKEN")
35
36             if(hostName == "" | token == "")
37                 stop(paste("Please provide host name and authentification token",
38                            "or set ARVADOS_API_HOST and ARVADOS_API_TOKEN",
39                            "environment variables."))
40
41             private$token <- token
42             private$host  <- paste0("https://", hostName, "/arvados/v1/")
43             private$numRetries <- numRetries
44             private$REST <- RESTService$new(token, hostName,
45                                             HttpRequest$new(), HttpParser$new(),
46                                             numRetries)
47
48         },
49
50         #' @description
51         #' project_exist enables checking if the project with such a UUID exist.
52         #' @param uuid The UUID of a project or a file.
53         #' @examples
54         #' arv$project_exist(uuid = projectUUID)
55         project_exist = function(uuid)
56         {
57             proj <- self$project_list(list(list("uuid", '=', uuid)))
58             value <- length(proj$items)
59
60             if (value == 1){
61                 cat(format('TRUE'))
62             } else {
63                 cat(format('FALSE'))
64             }
65         },
66
67         #' @description
68         #' project_get returns the demanded project.
69         #' @param uuid The UUID of the Group in question.
70         #' @examples
71         #' project <- arv$project_get(uuid = projectUUID)
72         project_get = function(uuid)
73         {
74             self$groups_get(uuid)
75         },
76
77         #' @description
78         #' project_create creates a new project of a given name and description.
79         #' @param name Name of the project.
80         #' @param description Description of the project.
81         #' @param ownerUUID The UUID of the maternal project to created one.
82         #' @param properties List of the properties of the project.
83         #' @param ensureUniqueName Adjust name to ensure uniqueness instead of returning an error.
84         #' @examples
85         #' Properties <- list() # should contain a list of new properties to be added
86         #' new_project <- arv$project_create(name = "project name", description = "project description", owner_uuid = "project UUID", properties = NULL, ensureUniqueName = "false")
87         project_create = function(name, description, ownerUUID, properties = NULL, ensureUniqueName = "false")
88         {
89             group <- list(name = name, description = description, owner_uuid = ownerUUID, properties = properties)
90             group <- c("group_class" = "project", group)
91             self$groups_create(group, ensureUniqueName =  ensureUniqueName)
92         },
93
94         #' @description
95         #' project_properties_set is a method defined in Arvados class that enables setting properties. Allows to set or overwrite the properties. In case there are set already it overwrites them.
96         #' @param listProperties List of new properties.
97         #' @param uuid The UUID of a project or a file.
98         #' @examples
99         #' Properties <- list() # should contain a list of new properties to be added
100         #' arv$project_properties_set(Properties, uuid)
101         project_properties_set = function(listProperties, uuid)
102         {
103             group <- c("group_class" = "project", list("properties" = listProperties))
104             self$groups_update(group, uuid)
105
106         },
107
108         #' @description
109         #' project_properties_append is a method defined in Arvados class that enables appending properties. Allows to add new properties.
110         #' @param listOfNewProperties List of new properties.
111         #' @param uuid The UUID of a project or a file.
112         #' @examples
113         #' newProperties <- list() # should contain a list of new properties to be added
114         #' arv$project_properties_append(properties = newProperties, uuid)
115         project_properties_append = function(properties, uuid)
116         {
117             proj <- self$project_list(list(list('uuid', '=', uuid)))
118             projProp <- proj$items[[1]]$properties
119
120             newListOfProperties <- c(projProp, properties)
121             uniqueProperties <- unique(unlist(newListOfProperties))
122             newListOfProperties <- suppressWarnings(newListOfProperties[which(newListOfProperties == uniqueProperties)])
123
124             group <- c("group_class" = "project", list("properties" = newListOfProperties))
125             self$groups_update(group, uuid);
126
127         },
128
129         #' @description
130         #' project_properties_get is a method defined in Arvados class that returns properties.
131         #' @param uuid The UUID of a project or a file.
132         #' @examples
133         #' arv$project_properties_get(projectUUID)
134         project_properties_get = function(uuid)
135         {
136             proj <- self$project_list(list(list('uuid', '=', uuid)))
137             proj$items[[1]]$properties
138         },
139
140         #' @description
141         #' project_properties_delete is a method defined in Arvados class that deletes list of properties.
142         #' @param oneProp Property to be deleted.
143         #' @param uuid The UUID of a project or a file.
144         #' @examples
145         #' Properties <- list() # should contain a list of new properties to be added
146         #' arv$project_properties_delete(Properties,  projectUUID)
147         project_properties_delete = function(oneProp, uuid)
148         {
149             proj <- self$project_list(list(list('uuid', '=', uuid))) # find project
150             projProp <- proj$items[[1]]$properties
151             for (i in 1:length(projProp)){
152                 solution <- identical(projProp[i],oneProp)
153                 if (solution == TRUE) {
154                     projProp <- projProp[names(projProp) != names(oneProp)]
155                     self$project_properties_set(projProp, uuid)
156                 }
157             }
158         },
159
160         #' @description
161         #' project_update enables updating project. New name, description and properties may be given.
162         #' @param ... Feature to be updated (name, description, properties).
163         #' @param uuid The UUID of a project in question.
164         #' @examples
165         #' newProperties <- list() # should contain a list of new properties to be added
166         #' arv$project_update(name = "new project name", properties = newProperties, uuid = projectUUID)
167         project_update = function(..., uuid) {
168             vec <- list(...)
169             for (i in 1:length(vec))
170             {
171                 if (names(vec[i]) == 'properties') {
172                     solution <- self$project_properties_append(vec$properties, uuid = uuid)
173                 }
174             }
175             vecNew <- vec[names(vec) != "properties"]
176             vecNew <- c("group_class" = "project", vecNew)
177             z <- self$groups_update(vecNew, uuid)
178         },
179
180         #' @description
181         #' project_list enables listing project by its name, uuid, properties, permissions.
182         #' @param filters
183         #' @param where
184         #' @param order
185         #' @param distinct
186         #' @param limit
187         #' @param offset
188         #' @param count
189         #' @param includeTrash Include items whose is_trashed attribute is true.
190         #' @param uuid The UUID of a project in question.
191         #' @param recursive Include contents from child groups recursively.
192         #' @examples
193         #' listOfprojects <- arv$project_list(list(list("owner_uuid", "=", projectUUID))) # Sample query which show projects within the project of a given UUID
194         project_list = function(filters = NULL, where = NULL,
195                                 order = NULL, select = NULL, distinct = NULL,
196                                 limit = "100", offset = "0", count = "exact",
197                                 includeTrash = NULL)
198         {
199             filters[[length(filters) + 1]] <- list("group_class", "=", "project")
200             self$groups_list(filters, where, order, select, distinct,
201                              limit, offset, count, includeTrash)
202         },
203
204         #' @description
205         #' project_delete trashes project of a given uuid. It can be restored from trash or deleted permanently.
206         #' @param uuid The UUID of the Group in question.
207         project_delete = function(uuid)
208         {
209             self$groups_delete(uuid)
210         },
211
212         #' @description
213         #' api_clients_get is a method defined in Arvados class.
214         #' @param uuid The UUID of the apiClient in question.
215         api_clients_get = function(uuid)
216         {
217             endPoint <- stringr::str_interp("api_clients/${uuid}")
218             url <- paste0(private$host, endPoint)
219             headers <- list(Authorization = paste("Bearer", private$token),
220                             "Content-Type" = "application/json")
221             queryArgs <- NULL
222
223             body <- NULL
224
225             response <- private$REST$http$exec("GET", url, headers, body,
226                                                queryArgs, private$numRetries)
227             resource <- private$REST$httpParser$parseJSONResponse(response)
228
229             if(!is.null(resource$errors))
230                 stop(resource$errors)
231
232             resource
233         },
234
235         #' @description
236         #' api_clients_create is a method defined in Arvados class.
237         #' @param apiClient apiClient object.
238         #' @param ensureUniqueName Adjust name to ensure uniqueness instead of returning an error.
239         #' @param clusterID Create object on a remote federated cluster instead of the current one.
240         api_clients_create = function(apiClient,
241                                       ensureUniqueName = "false", clusterID = NULL)
242         {
243             endPoint <- stringr::str_interp("api_clients")
244             url <- paste0(private$host, endPoint)
245             headers <- list(Authorization = paste("Bearer", private$token),
246                             "Content-Type" = "application/json")
247             queryArgs <- list(ensureUniqueName = ensureUniqueName,
248                               clusterID = clusterID)
249
250             if(length(apiClient) > 0)
251                 body <- jsonlite::toJSON(list(apiClient = apiClient),
252                                          auto_unbox = TRUE)
253             else
254                 body <- NULL
255
256             response <- private$REST$http$exec("POST", url, headers, body,
257                                                queryArgs, private$numRetries)
258             resource <- private$REST$httpParser$parseJSONResponse(response)
259
260             if(!is.null(resource$errors))
261                 stop(resource$errors)
262
263             resource
264         },
265
266         #' @description
267         #' api_clients_update is a method defined in Arvados class.
268         #' @param apiClient apiClient object.
269         #' @param uuid The UUID of the apiClient in question.
270         api_clients_update = function(apiClient, uuid)
271         {
272             endPoint <- stringr::str_interp("api_clients/${uuid}")
273             url <- paste0(private$host, endPoint)
274             headers <- list(Authorization = paste("Bearer", private$token),
275                             "Content-Type" = "application/json")
276             queryArgs <- NULL
277
278             if(length(apiClient) > 0)
279                 body <- jsonlite::toJSON(list(apiClient = apiClient),
280                                          auto_unbox = TRUE)
281             else
282                 body <- NULL
283
284             response <- private$REST$http$exec("PUT", url, headers, body,
285                                                queryArgs, private$numRetries)
286             resource <- private$REST$httpParser$parseJSONResponse(response)
287
288             if(!is.null(resource$errors))
289                 stop(resource$errors)
290
291             resource
292         },
293
294         #' @description
295         #' api_clients_delete is a method defined in Arvados class.
296         #' @param uuid The UUID of the apiClient in question.
297         api_clients_delete = function(uuid)
298         {
299             endPoint <- stringr::str_interp("api_clients/${uuid}")
300             url <- paste0(private$host, endPoint)
301             headers <- list(Authorization = paste("Bearer", private$token),
302                             "Content-Type" = "application/json")
303             queryArgs <- NULL
304
305             body <- NULL
306
307             response <- private$REST$http$exec("DELETE", url, headers, body,
308                                                queryArgs, private$numRetries)
309             resource <- private$REST$httpParser$parseJSONResponse(response)
310
311             if(!is.null(resource$errors))
312                 stop(resource$errors)
313
314             resource
315         },
316
317         #' @description
318         #' api_clients_list is a method defined in Arvados class.
319         #' @param filters
320         #' @param where
321         #' @param order
322         #' @param select
323         #' @param distinct
324         #' @param limit
325         #' @param offset
326         #' @param count
327         #' @param clusterID List objects on a remote federated cluster instead of the current one.
328         #' @param bypassFederation Bypass federation behavior, list items from local instance database only.
329         api_clients_list = function(filters = NULL,
330                                     where = NULL, order = NULL, select = NULL,
331                                     distinct = NULL, limit = "100", offset = "0",
332                                     count = "exact", clusterID = NULL, bypassFederation = NULL)
333         {
334             endPoint <- stringr::str_interp("api_clients")
335             url <- paste0(private$host, endPoint)
336             headers <- list(Authorization = paste("Bearer", private$token),
337                             "Content-Type" = "application/json")
338             queryArgs <- list(filters = filters, where = where,
339                               order = order, select = select, distinct = distinct,
340                               limit = limit, offset = offset, count = count,
341                               clusterID = clusterID, bypassFederation = bypassFederation)
342
343             body <- NULL
344
345             response <- private$REST$http$exec("GET", url, headers, body,
346                                                queryArgs, private$numRetries)
347             resource <- private$REST$httpParser$parseJSONResponse(response)
348
349             if(!is.null(resource$errors))
350                 stop(resource$errors)
351
352             resource
353         },
354
355         #' @description
356         #' api_client_authorizations_get is a method defined in Arvados class.
357         #' @param uuid The UUID of the apiClientAuthorization in question.
358         api_client_authorizations_get = function(uuid)
359         {
360             endPoint <- stringr::str_interp("api_client_authorizations/${uuid}")
361             url <- paste0(private$host, endPoint)
362             headers <- list(Authorization = paste("Bearer", private$token),
363                             "Content-Type" = "application/json")
364             queryArgs <- NULL
365
366             body <- NULL
367
368             response <- private$REST$http$exec("GET", url, headers, body,
369                                                queryArgs, private$numRetries)
370             resource <- private$REST$httpParser$parseJSONResponse(response)
371
372             if(!is.null(resource$errors))
373                 stop(resource$errors)
374
375             resource
376         },
377
378         #' @description
379         #' api_client_authorizations_create is a method defined in Arvados class.
380         #' @param apiClientAuthorization apiClientAuthorization object.
381         #' @param ensureUniqueName Adjust name to ensure uniqueness instead of returning an error on (ownerUUID, name) collision_
382         #' @param clusterID Create object on a remote federated cluster instead of the current one.
383         api_client_authorizations_create = function(apiClientAuthorization,
384                                                     ensureUniqueName = "false", clusterID = NULL)
385         {
386             endPoint <- stringr::str_interp("api_client_authorizations")
387             url <- paste0(private$host, endPoint)
388             headers <- list(Authorization = paste("Bearer", private$token),
389                             "Content-Type" = "application/json")
390             queryArgs <- list(ensureUniqueName = ensureUniqueName,
391                               clusterID = clusterID)
392
393             if(length(apiClientAuthorization) > 0)
394                 body <- jsonlite::toJSON(list(apiClientAuthorization = apiClientAuthorization),
395                                          auto_unbox = TRUE)
396             else
397                 body <- NULL
398
399             response <- private$REST$http$exec("POST", url, headers, body,
400                                                queryArgs, private$numRetries)
401             resource <- private$REST$httpParser$parseJSONResponse(response)
402
403             if(!is.null(resource$errors))
404                 stop(resource$errors)
405
406             resource
407         },
408
409         #' @description
410         #' api_client_authorizations_update is a method defined in Arvados class.
411         #' @param apiClientAuthorization apiClientAuthorization object.
412         #' @param uuid The UUID of the apiClientAuthorization in question.
413         api_client_authorizations_update = function(apiClientAuthorization, uuid)
414         {
415             endPoint <- stringr::str_interp("api_client_authorizations/${uuid}")
416             url <- paste0(private$host, endPoint)
417             headers <- list(Authorization = paste("Bearer", private$token),
418                             "Content-Type" = "application/json")
419             queryArgs <- NULL
420
421             if(length(apiClientAuthorization) > 0)
422                 body <- jsonlite::toJSON(list(apiClientAuthorization = apiClientAuthorization),
423                                          auto_unbox = TRUE)
424             else
425                 body <- NULL
426
427             response <- private$REST$http$exec("PUT", url, headers, body,
428                                                queryArgs, private$numRetries)
429             resource <- private$REST$httpParser$parseJSONResponse(response)
430
431             if(!is.null(resource$errors))
432                 stop(resource$errors)
433
434             resource
435         },
436
437         #' @description
438         #' api_client_authorizations_delete is a method defined in Arvados class.
439         #' @param uuid The UUID of the apiClientAuthorization in question.
440         api_client_authorizations_delete = function(uuid)
441         {
442             endPoint <- stringr::str_interp("api_client_authorizations/${uuid}")
443             url <- paste0(private$host, endPoint)
444             headers <- list(Authorization = paste("Bearer", private$token),
445                             "Content-Type" = "application/json")
446             queryArgs <- NULL
447
448             body <- NULL
449
450             response <- private$REST$http$exec("DELETE", url, headers, body,
451                                                queryArgs, private$numRetries)
452             resource <- private$REST$httpParser$parseJSONResponse(response)
453
454             if(!is.null(resource$errors))
455                 stop(resource$errors)
456
457             resource
458         },
459
460         #' @description
461         #' api_client_authorizations_create_system_auth is a method defined in Arvados class.
462         #' @param apiClientID
463         #' @param scopes
464         api_client_authorizations_create_system_auth = function(apiClientID = NULL, scopes = NULL)
465         {
466             endPoint <- stringr::str_interp("api_client_authorizations/create_system_auth")
467             url <- paste0(private$host, endPoint)
468             headers <- list(Authorization = paste("Bearer", private$token),
469                             "Content-Type" = "application/json")
470             queryArgs <- list(apiClientID = apiClientID,
471                               scopes = scopes)
472
473             body <- NULL
474
475             response <- private$REST$http$exec("POST", url, headers, body,
476                                                queryArgs, private$numRetries)
477             resource <- private$REST$httpParser$parseJSONResponse(response)
478
479             if(!is.null(resource$errors))
480                 stop(resource$errors)
481
482             resource
483         },
484
485         #' @description
486         #' api_client_authorizations_current is a method defined in Arvados class.
487         api_client_authorizations_current = function()
488         {
489             endPoint <- stringr::str_interp("api_client_authorizations/current")
490             url <- paste0(private$host, endPoint)
491             headers <- list(Authorization = paste("Bearer", private$token),
492                             "Content-Type" = "application/json")
493             queryArgs <- NULL
494
495             body <- NULL
496
497             response <- private$REST$http$exec("GET", url, headers, body,
498                                                queryArgs, private$numRetries)
499             resource <- private$REST$httpParser$parseJSONResponse(response)
500
501             if(!is.null(resource$errors))
502                 stop(resource$errors)
503
504             resource
505         },
506
507         #' @description
508         #' api_client_authorizations_list is a method defined in Arvados class.
509         #' @param filters
510         #' @param where
511         #' @param order
512         #' @param select
513         #' @param distinct
514         #' @param limit
515         #' @param offset
516         #' @param count
517         #' @param clusterID List objects on a remote federated cluster instead of the current one.
518         #' @param bypassFederation Bypass federation behavior, list items from local instance database only.
519         api_client_authorizations_list = function(filters = NULL,
520                                                   where = NULL, order = NULL, select = NULL,
521                                                   distinct = NULL, limit = "100", offset = "0",
522                                                   count = "exact", clusterID = NULL, bypassFederation = NULL)
523         {
524             endPoint <- stringr::str_interp("api_client_authorizations")
525             url <- paste0(private$host, endPoint)
526             headers <- list(Authorization = paste("Bearer", private$token),
527                             "Content-Type" = "application/json")
528             queryArgs <- list(filters = filters, where = where,
529                               order = order, select = select, distinct = distinct,
530                               limit = limit, offset = offset, count = count,
531                               clusterID = clusterID, bypassFederation = bypassFederation)
532
533             body <- NULL
534
535             response <- private$REST$http$exec("GET", url, headers, body,
536                                                queryArgs, private$numRetries)
537             resource <- private$REST$httpParser$parseJSONResponse(response)
538
539             if(!is.null(resource$errors))
540                 stop(resource$errors)
541
542             resource
543         },
544
545         #' @description
546         #' authorized_keys_get is a method defined in Arvados class.
547         #' @param uuid The UUID of the authorizedKey in question.
548         authorized_keys_get = function(uuid)
549         {
550             endPoint <- stringr::str_interp("authorized_keys/${uuid}")
551             url <- paste0(private$host, endPoint)
552             headers <- list(Authorization = paste("Bearer", private$token),
553                             "Content-Type" = "application/json")
554             queryArgs <- NULL
555
556             body <- NULL
557
558             response <- private$REST$http$exec("GET", url, headers, body,
559                                                queryArgs, private$numRetries)
560             resource <- private$REST$httpParser$parseJSONResponse(response)
561
562             if(!is.null(resource$errors))
563                 stop(resource$errors)
564
565             resource
566         },
567
568         #' @description
569         #' authorized_keys_create is a method defined in Arvados class.
570         #' @param authorizedKey authorizedKey object.
571         #' @param ensureUniqueName Adjust name to ensure uniqueness instead of returning an error.
572         #' @param clusterID Create object on a remote federated cluster instead of the current one.
573         authorized_keys_create = function(authorizedKey,
574                                           ensureUniqueName = "false", clusterID = NULL)
575         {
576             endPoint <- stringr::str_interp("authorized_keys")
577             url <- paste0(private$host, endPoint)
578             headers <- list(Authorization = paste("Bearer", private$token),
579                             "Content-Type" = "application/json")
580             queryArgs <- list(ensureUniqueName = ensureUniqueName,
581                               clusterID = clusterID)
582
583             if(length(authorizedKey) > 0)
584                 body <- jsonlite::toJSON(list(authorizedKey = authorizedKey),
585                                          auto_unbox = TRUE)
586             else
587                 body <- NULL
588
589             response <- private$REST$http$exec("POST", url, headers, body,
590                                                queryArgs, private$numRetries)
591             resource <- private$REST$httpParser$parseJSONResponse(response)
592
593             if(!is.null(resource$errors))
594                 stop(resource$errors)
595
596             resource
597         },
598
599         #' @description
600         #' authorized_keys_update is a method defined in Arvados class.
601         #' @param authorizedKey authorizedKey object.
602         #' @param uuid The UUID of the authorizedKey in question.
603         authorized_keys_update = function(authorizedKey, uuid)
604         {
605             endPoint <- stringr::str_interp("authorized_keys/${uuid}")
606             url <- paste0(private$host, endPoint)
607             headers <- list(Authorization = paste("Bearer", private$token),
608                             "Content-Type" = "application/json")
609             queryArgs <- NULL
610
611             if(length(authorizedKey) > 0)
612                 body <- jsonlite::toJSON(list(authorizedKey = authorizedKey),
613                                          auto_unbox = TRUE)
614             else
615                 body <- NULL
616
617             response <- private$REST$http$exec("PUT", url, headers, body,
618                                                queryArgs, private$numRetries)
619             resource <- private$REST$httpParser$parseJSONResponse(response)
620
621             if(!is.null(resource$errors))
622                 stop(resource$errors)
623
624             resource
625         },
626
627         #' @description
628         #' authorized_keys_delete is a method defined in Arvados class.
629         #' @param uuid The UUID of the authorizedKey in question.
630         authorized_keys_delete = function(uuid)
631         {
632             endPoint <- stringr::str_interp("authorized_keys/${uuid}")
633             url <- paste0(private$host, endPoint)
634             headers <- list(Authorization = paste("Bearer", private$token),
635                             "Content-Type" = "application/json")
636             queryArgs <- NULL
637
638             body <- NULL
639
640             response <- private$REST$http$exec("DELETE", url, headers, body,
641                                                queryArgs, private$numRetries)
642             resource <- private$REST$httpParser$parseJSONResponse(response)
643
644             if(!is.null(resource$errors))
645                 stop(resource$errors)
646
647             resource
648         },
649
650         #' @description
651         #' authorized_keys_list is a method defined in Arvados class.
652         #' @param filters
653         #' @param where
654         #' @param order
655         #' @param select
656         #' @param distinct
657         #' @param limit
658         #' @param offset
659         #' @param count
660         #' @param clusterID List objects on a remote federated cluster instead of the current one.
661         #' @param bypassFederation Bypass federation behavior, list items from local instance database only.
662         authorized_keys_list = function(filters = NULL,
663                                         where = NULL, order = NULL, select = NULL,
664                                         distinct = NULL, limit = "100", offset = "0",
665                                         count = "exact", clusterID = NULL, bypassFederation = NULL)
666         {
667             endPoint <- stringr::str_interp("authorized_keys")
668             url <- paste0(private$host, endPoint)
669             headers <- list(Authorization = paste("Bearer", private$token),
670                             "Content-Type" = "application/json")
671             queryArgs <- list(filters = filters, where = where,
672                               order = order, select = select, distinct = distinct,
673                               limit = limit, offset = offset, count = count,
674                               clusterID = clusterID, bypassFederation = bypassFederation)
675
676             body <- NULL
677
678             response <- private$REST$http$exec("GET", url, headers, body,
679                                                queryArgs, private$numRetries)
680             resource <- private$REST$httpParser$parseJSONResponse(response)
681
682             if(!is.null(resource$errors))
683                 stop(resource$errors)
684
685             resource
686         },
687
688         #' @description
689         #' collections_get is a method defined in Arvados class.
690         #' @param uuid The UUID of the Collection in question.
691         #' collection <- arv$collections_get(uuid = collectionUUID)
692         collections_get = function(uuid)
693         {
694             endPoint <- stringr::str_interp("collections/${uuid}")
695             url <- paste0(private$host, endPoint)
696             headers <- list(Authorization = paste("Bearer", private$token),
697                             "Content-Type" = "application/json")
698             queryArgs <- NULL
699
700             body <- NULL
701
702             response <- private$REST$http$exec("GET", url, headers, body,
703                                                queryArgs, private$numRetries)
704             resource <- private$REST$httpParser$parseJSONResponse(response)
705
706             if(!is.null(resource$errors))
707                 stop(resource$errors)
708
709             resource
710         },
711
712         #' @description
713         #' collections_create is a method defined in Arvados class that enables collections creation.
714         #' @param name Name of the collection.
715         #' @param description Description of the collection.
716         #' @param ownerUUID UUID of the maternal project to created one.
717         #' @param properties Properties of the collection.
718         #' @param ensureUniqueName Adjust name to ensure uniqueness instead of returning an error.
719         #' @param clusterID Create object on a remote federated cluster instead of the current one.
720         #' @examples
721         #' Properties <- list() # should contain a list of new properties to be added
722         #' arv$collections_create(name = "collectionTitle", description = "collectionDescription", ownerUUID = "collectionOwner", properties = Properties)
723         collections_create = function(name, description, ownerUUID = NULL, properties = NULL, # name and description are obligatory
724                                       ensureUniqueName = "false", clusterID = NULL)
725         {
726             endPoint <- stringr::str_interp("collections")
727             url <- paste0(private$host, endPoint)
728             headers <- list(Authorization = paste("Bearer", private$token),
729                             "Content-Type" = "application/json")
730             queryArgs <- list(ensureUniqueName = ensureUniqueName,
731                               clusterID = clusterID)
732
733             collection <- list(name = name, description = description, owner_uuid = ownerUUID, properties = properties)
734             if(length(collection) > 0)
735                 body <- jsonlite::toJSON(list(collection = collection),
736                                          auto_unbox = TRUE)
737             else
738                 body <- NULL
739
740             response <- private$REST$http$exec("POST", url, headers, body,
741                                                queryArgs, private$numRetries)
742             resource <- private$REST$httpParser$parseJSONResponse(response)
743
744             if(!is.null(resource$errors)){
745                 if(identical(sub('Entity:.*',"", resource$errors), "//railsapi.internal/arvados/v1/collections: 422 Unprocessable ")){
746                     resource <- cat(format("A collection with the given name already exists in this projects. If you want to update it use collections_update() instead"))
747                 }else{
748                     stop(resource$errors)
749                 }
750             }
751
752             resource
753         },
754
755         #' @description
756         #' collections_update is a method defined in Arvados class.
757         #' @param name New name of the collection.
758         #' @param description New description of the collection.
759         #' @param ownerUUID UUID of the maternal project to created one.
760         #' @param properties New list of properties of the collection.
761         #' @param uuid The UUID of the Collection in question.
762         #' @examples
763         #' collection <- arv$collections_update(name = "newCollectionTitle", description = "newCollectionDescription", ownerUUID = "collectionOwner", properties = NULL, uuid = "collectionUUID")
764         collections_update = function(name, description, ownerUUID = NULL, properties = NULL, uuid)
765         {
766             endPoint <- stringr::str_interp("collections/${uuid}")
767             url <- paste0(private$host, endPoint)
768             headers <- list(Authorization = paste("Bearer", private$token),
769                             "Content-Type" = "application/json")
770             queryArgs <- NULL
771
772             collection <- list(name = name, description = description, ownerUUID = ownerUUID, properties = properties)
773             if(length(collection) > 0)
774                 body <- jsonlite::toJSON(list(collection = collection),
775                                          auto_unbox = TRUE)
776             else
777                 body <- NULL
778
779             response <- private$REST$http$exec("PUT", url, headers, body,
780                                                queryArgs, private$numRetries)
781             resource <- private$REST$httpParser$parseJSONResponse(response)
782
783             if(!is.null(resource$errors))
784                 stop(resource$errors)
785
786             resource
787         },
788
789         #' @description
790         #' collections_delete is a method defined in Arvados class.
791         #' @param uuid The UUID of the Collection in question.
792         #' @examples
793         #' arv$collection_delete(collectionUUID)
794         collections_delete = function(uuid)
795         {
796             endPoint <- stringr::str_interp("collections/${uuid}")
797             url <- paste0(private$host, endPoint)
798             headers <- list(Authorization = paste("Bearer", private$token),
799                             "Content-Type" = "application/json")
800             queryArgs <- NULL
801
802             body <- NULL
803
804             response <- private$REST$http$exec("DELETE", url, headers, body,
805                                                queryArgs, private$numRetries)
806             resource <- private$REST$httpParser$parseJSONResponse(response)
807
808             if(!is.null(resource$errors))
809                 stop(resource$errors)
810
811             resource
812         },
813
814         #' @description
815         #' collections_provenance is a method defined in Arvados class, it returns the collection by uuid.
816         #' @param uuid The UUID of the Collection in question.
817         #' @examples
818         #' collection <- arv$collections_provenance(collectionUUID)
819         collections_provenance = function(uuid)
820         {
821             endPoint <- stringr::str_interp("collections/${uuid}/provenance")
822             url <- paste0(private$host, endPoint)
823             headers <- list(Authorization = paste("Bearer", private$token),
824                             "Content-Type" = "application/json")
825             queryArgs <- NULL
826
827             body <- NULL
828
829             response <- private$REST$http$exec("GET", url, headers, body,
830                                                queryArgs, private$numRetries)
831             resource <- private$REST$httpParser$parseJSONResponse(response)
832
833             if(!is.null(resource$errors))
834                 stop(resource$errors)
835
836             resource
837         },
838
839         #' @description
840         #' collections_used_by is a method defined in Arvados class, it returns collection by portable_data_hash.
841         #' @param uuid The UUID of the Collection in question.
842         collections_used_by = function(uuid)
843         {
844             endPoint <- stringr::str_interp("collections/${uuid}/used_by")
845             url <- paste0(private$host, endPoint)
846             headers <- list(Authorization = paste("Bearer", private$token),
847                             "Content-Type" = "application/json")
848             queryArgs <- NULL
849
850             body <- NULL
851
852             response <- private$REST$http$exec("GET", url, headers, body,
853                                                queryArgs, private$numRetries)
854             resource <- private$REST$httpParser$parseJSONResponse(response)
855
856             if(!is.null(resource$errors))
857                 stop(resource$errors)
858
859             resource
860         },
861
862         #' @description
863         #' collections_trash is a method defined in Arvados class, it moves collection to trash.
864         #' @param uuid The UUID of the Collection in question.
865         #' @examples
866         #' arv$collections_trash(collectionUUID)
867         collections_trash = function(uuid)
868         {
869             endPoint <- stringr::str_interp("collections/${uuid}/trash")
870             url <- paste0(private$host, endPoint)
871             headers <- list(Authorization = paste("Bearer", private$token),
872                             "Content-Type" = "application/json")
873             queryArgs <- NULL
874
875             body <- NULL
876
877             response <- private$REST$http$exec("POST", url, headers, body,
878                                                queryArgs, private$numRetries)
879             resource <- private$REST$httpParser$parseJSONResponse(response)
880
881             if(!is.null(resource$errors))
882                 stop(resource$errors)
883
884             resource
885         },
886
887         #' @description
888         #' collections_untrash is a method defined in Arvados class, it moves collection from trash to project.
889         #' @param uuid The UUID of the Collection in question.
890         #' @examples
891         #' arv$collections_untrash(collectionUUID)
892         collections_untrash = function(uuid)
893         {
894             endPoint <- stringr::str_interp("collections/${uuid}/untrash")
895             url <- paste0(private$host, endPoint)
896             headers <- list(Authorization = paste("Bearer", private$token),
897                             "Content-Type" = "application/json")
898             queryArgs <- NULL
899
900             body <- NULL
901
902             response <- private$REST$http$exec("POST", url, headers, body,
903                                                queryArgs, private$numRetries)
904             resource <- private$REST$httpParser$parseJSONResponse(response)
905
906             if(!is.null(resource$errors))
907                 stop(resource$errors)
908
909             resource
910         },
911
912         #' @description
913         #' collections_list is a method defined in Arvados class.
914         #' @param filters
915         #' @param where
916         #' @param order
917         #' @param select
918         #' @param distinct
919         #' @param limit
920         #' @param offset
921         #' @param count
922         #' @param clusterID List objects on a remote federated cluster instead of the current one.
923         #' @param bypassFederation Bypass federation behavior, list items from local instance database only.
924         #' @param includeTrash Include collections whose is_trashed attribute is true.
925         #' @param includeOldVersions Include past collection versions.
926         #' @examples
927         #' collectionList <- arv$collections_list(list(list("name", "=", "Example")))
928         collections_list = function(filters = NULL,
929                                     where = NULL, order = NULL, select = NULL,
930                                     distinct = NULL, limit = "100", offset = "0",
931                                     count = "exact", clusterID = NULL, bypassFederation = NULL,
932                                     includeTrash = NULL, includeOldVersions = NULL)
933         {
934             endPoint <- stringr::str_interp("collections")
935             url <- paste0(private$host, endPoint)
936             headers <- list(Authorization = paste("Bearer", private$token),
937                             "Content-Type" = "application/json")
938             queryArgs <- list(filters = filters, where = where,
939                               order = order, select = select, distinct = distinct,
940                               limit = limit, offset = offset, count = count,
941                               clusterID = clusterID, bypassFederation = bypassFederation,
942                               includeTrash = includeTrash, includeOldVersions = includeOldVersions)
943
944             body <- NULL
945
946             response <- private$REST$http$exec("GET", url, headers, body,
947                                                queryArgs, private$numRetries)
948             resource <- private$REST$httpParser$parseJSONResponse(response)
949
950             if(!is.null(resource$errors))
951                 stop(resource$errors)
952
953             resource
954         },
955
956         #' @description
957         #' containers_get is a method defined in Arvados class.
958         #' @param uuid The UUID of the Container in question.
959         containers_get = function(uuid)
960         {
961             endPoint <- stringr::str_interp("containers/${uuid}")
962             url <- paste0(private$host, endPoint)
963             headers <- list(Authorization = paste("Bearer", private$token),
964                             "Content-Type" = "application/json")
965             queryArgs <- NULL
966
967             body <- NULL
968
969             response <- private$REST$http$exec("GET", url, headers, body,
970                                                queryArgs, private$numRetries)
971             resource <- private$REST$httpParser$parseJSONResponse(response)
972
973             if(!is.null(resource$errors))
974                 stop(resource$errors)
975
976             resource
977         },
978
979         #' @description
980         #' containers_create is a method defined in Arvados class.
981         #' @param container Container object.
982         #' @param ensureUniqueName Adjust name to ensure uniqueness instead of returning an error.
983         #' @param clusterID Create object on a remote federated cluster instead of the current one.
984         containers_create = function(container, ensureUniqueName = "false",
985                                      clusterID = NULL)
986         {
987             endPoint <- stringr::str_interp("containers")
988             url <- paste0(private$host, endPoint)
989             headers <- list(Authorization = paste("Bearer", private$token),
990                             "Content-Type" = "application/json")
991             queryArgs <- list(ensureUniqueName = ensureUniqueName,
992                               clusterID = clusterID)
993
994             if(length(container) > 0)
995                 body <- jsonlite::toJSON(list(container = container),
996                                          auto_unbox = TRUE)
997             else
998                 body <- NULL
999
1000             response <- private$REST$http$exec("POST", url, headers, body,
1001                                                queryArgs, private$numRetries)
1002             resource <- private$REST$httpParser$parseJSONResponse(response)
1003
1004             if(!is.null(resource$errors))
1005                 stop(resource$errors)
1006
1007             resource
1008         },
1009
1010         #' @description
1011         #' containers_update is a method defined in Arvados class.
1012         #' @param container Container object.
1013         #' @param uuid The UUID of the Container in question.
1014         containers_update = function(container, uuid)
1015         {
1016             endPoint <- stringr::str_interp("containers/${uuid}")
1017             url <- paste0(private$host, endPoint)
1018             headers <- list(Authorization = paste("Bearer", private$token),
1019                             "Content-Type" = "application/json")
1020             queryArgs <- NULL
1021
1022             if(length(container) > 0)
1023                 body <- jsonlite::toJSON(list(container = container),
1024                                          auto_unbox = TRUE)
1025             else
1026                 body <- NULL
1027
1028             response <- private$REST$http$exec("PUT", url, headers, body,
1029                                                queryArgs, private$numRetries)
1030             resource <- private$REST$httpParser$parseJSONResponse(response)
1031
1032             if(!is.null(resource$errors))
1033                 stop(resource$errors)
1034
1035             resource
1036         },
1037
1038         #' @description
1039         #' containers_delete is a method defined in Arvados class.
1040         #' @param uuid The UUID of the Container in question.
1041         containers_delete = function(uuid)
1042         {
1043             endPoint <- stringr::str_interp("containers/${uuid}")
1044             url <- paste0(private$host, endPoint)
1045             headers <- list(Authorization = paste("Bearer", private$token),
1046                             "Content-Type" = "application/json")
1047             queryArgs <- NULL
1048
1049             body <- NULL
1050
1051             response <- private$REST$http$exec("DELETE", url, headers, body,
1052                                                queryArgs, private$numRetries)
1053             resource <- private$REST$httpParser$parseJSONResponse(response)
1054
1055             if(!is.null(resource$errors))
1056                 stop(resource$errors)
1057
1058             resource
1059         },
1060
1061         #' @description
1062         #' containers_auth is a method defined in Arvados class.
1063         #' @param uuid The UUID of the Container in question.
1064         containers_auth = function(uuid)
1065         {
1066             endPoint <- stringr::str_interp("containers/${uuid}/auth")
1067             url <- paste0(private$host, endPoint)
1068             headers <- list(Authorization = paste("Bearer", private$token),
1069                             "Content-Type" = "application/json")
1070             queryArgs <- NULL
1071
1072             body <- NULL
1073
1074             response <- private$REST$http$exec("GET", url, headers, body,
1075                                                queryArgs, private$numRetries)
1076             resource <- private$REST$httpParser$parseJSONResponse(response)
1077
1078             if(!is.null(resource$errors))
1079                 stop(resource$errors)
1080
1081             resource
1082         },
1083
1084         #' @description
1085         #' containers_lock is a method defined in Arvados class.
1086         #' @param uuid The UUID of the Container in question.
1087         containers_lock = function(uuid)
1088         {
1089             endPoint <- stringr::str_interp("containers/${uuid}/lock")
1090             url <- paste0(private$host, endPoint)
1091             headers <- list(Authorization = paste("Bearer", private$token),
1092                             "Content-Type" = "application/json")
1093             queryArgs <- NULL
1094
1095             body <- NULL
1096
1097             response <- private$REST$http$exec("POST", url, headers, body,
1098                                                queryArgs, private$numRetries)
1099             resource <- private$REST$httpParser$parseJSONResponse(response)
1100
1101             if(!is.null(resource$errors))
1102                 stop(resource$errors)
1103
1104             resource
1105         },
1106
1107         #' @description
1108         #' containers_unlock is a method defined in Arvados class.
1109         #' @param uuid The UUID of the Container in question.
1110         containers_unlock = function(uuid)
1111         {
1112             endPoint <- stringr::str_interp("containers/${uuid}/unlock")
1113             url <- paste0(private$host, endPoint)
1114             headers <- list(Authorization = paste("Bearer", private$token),
1115                             "Content-Type" = "application/json")
1116             queryArgs <- NULL
1117
1118             body <- NULL
1119
1120             response <- private$REST$http$exec("POST", url, headers, body,
1121                                                queryArgs, private$numRetries)
1122             resource <- private$REST$httpParser$parseJSONResponse(response)
1123
1124             if(!is.null(resource$errors))
1125                 stop(resource$errors)
1126
1127             resource
1128         },
1129
1130         #' @description
1131         #' containers_secret_mounts is a method defined in Arvados class.
1132         #' @param uuid The UUID of the Container in question.
1133         containers_secret_mounts = function(uuid)
1134         {
1135             endPoint <- stringr::str_interp("containers/${uuid}/secret_mounts")
1136             url <- paste0(private$host, endPoint)
1137             headers <- list(Authorization = paste("Bearer", private$token),
1138                             "Content-Type" = "application/json")
1139             queryArgs <- NULL
1140
1141             body <- NULL
1142
1143             response <- private$REST$http$exec("GET", url, headers, body,
1144                                                queryArgs, private$numRetries)
1145             resource <- private$REST$httpParser$parseJSONResponse(response)
1146
1147             if(!is.null(resource$errors))
1148                 stop(resource$errors)
1149
1150             resource
1151         },
1152
1153         #' @description
1154         #' containers_current is a method defined in Arvados class.
1155         containers_current = function()
1156         {
1157             endPoint <- stringr::str_interp("containers/current")
1158             url <- paste0(private$host, endPoint)
1159             headers <- list(Authorization = paste("Bearer", private$token),
1160                             "Content-Type" = "application/json")
1161             queryArgs <- NULL
1162
1163             body <- NULL
1164
1165             response <- private$REST$http$exec("GET", url, headers, body,
1166                                                queryArgs, private$numRetries)
1167             resource <- private$REST$httpParser$parseJSONResponse(response)
1168
1169             if(!is.null(resource$errors))
1170                 stop(resource$errors)
1171
1172             resource
1173         },
1174
1175         #' @description
1176         #' containers_list is a method defined in Arvados class.
1177         #' @param filters
1178         #' @param where
1179         #' @param order
1180         #' @param select
1181         #' @param distinct
1182         #' @param limit
1183         #' @param offset
1184         #' @param count
1185         #' @param clusterID List objects on a remote federated cluster instead of the current one.
1186         #' @param bypassFederation Bypass federation behavior, list items from local instance database only.
1187         containers_list = function(filters = NULL,
1188                                    where = NULL, order = NULL, select = NULL,
1189                                    distinct = NULL, limit = "100", offset = "0",
1190                                    count = "exact", clusterID = NULL, bypassFederation = NULL)
1191         {
1192             endPoint <- stringr::str_interp("containers")
1193             url <- paste0(private$host, endPoint)
1194             headers <- list(Authorization = paste("Bearer", private$token),
1195                             "Content-Type" = "application/json")
1196             queryArgs <- list(filters = filters, where = where,
1197                               order = order, select = select, distinct = distinct,
1198                               limit = limit, offset = offset, count = count,
1199                               clusterID = clusterID, bypassFederation = bypassFederation)
1200
1201             body <- NULL
1202
1203             response <- private$REST$http$exec("GET", url, headers, body,
1204                                                queryArgs, private$numRetries)
1205             resource <- private$REST$httpParser$parseJSONResponse(response)
1206
1207             if(!is.null(resource$errors))
1208                 stop(resource$errors)
1209
1210             resource
1211         },
1212
1213         #' @description
1214         #' container_requests_get is a method defined in Arvados class.
1215         #' @param uuid The UUID of the containerRequest in question.
1216         container_requests_get = function(uuid)
1217         {
1218             endPoint <- stringr::str_interp("container_requests/${uuid}")
1219             url <- paste0(private$host, endPoint)
1220             headers <- list(Authorization = paste("Bearer", private$token),
1221                             "Content-Type" = "application/json")
1222             queryArgs <- NULL
1223
1224             body <- NULL
1225
1226             response <- private$REST$http$exec("GET", url, headers, body,
1227                                                queryArgs, private$numRetries)
1228             resource <- private$REST$httpParser$parseJSONResponse(response)
1229
1230             if(!is.null(resource$errors))
1231                 stop(resource$errors)
1232
1233             resource
1234         },
1235
1236         #' @description
1237         #' container_requests_create is a method defined in Arvados class.
1238         #' @param containerRequest containerRequest object.
1239         #' @param ensureUniqueName Adjust name to ensure uniqueness instead of returning an error.
1240         #' @param clusterID Create object on a remote federated cluster instead of the current one.
1241         container_requests_create = function(containerRequest,
1242                                              ensureUniqueName = "false", clusterID = NULL)
1243         {
1244             endPoint <- stringr::str_interp("container_requests")
1245             url <- paste0(private$host, endPoint)
1246             headers <- list(Authorization = paste("Bearer", private$token),
1247                             "Content-Type" = "application/json")
1248             queryArgs <- list(ensureUniqueName = ensureUniqueName,
1249                               clusterID = clusterID)
1250
1251             if(length(containerRequest) > 0)
1252                 body <- jsonlite::toJSON(list(containerRequest = containerRequest),
1253                                          auto_unbox = TRUE)
1254             else
1255                 body <- NULL
1256
1257             response <- private$REST$http$exec("POST", url, headers, body,
1258                                                queryArgs, private$numRetries)
1259             resource <- private$REST$httpParser$parseJSONResponse(response)
1260
1261             if(!is.null(resource$errors))
1262                 stop(resource$errors)
1263
1264             resource
1265         },
1266
1267         #' @description
1268         #' container_requests_update is a method defined in Arvados class.
1269         #' @param containerRequest containerRequest object.
1270         #' @param uuid The UUID of the containerRequest in question.
1271         container_requests_update = function(containerRequest, uuid)
1272         {
1273             endPoint <- stringr::str_interp("container_requests/${uuid}")
1274             url <- paste0(private$host, endPoint)
1275             headers <- list(Authorization = paste("Bearer", private$token),
1276                             "Content-Type" = "application/json")
1277             queryArgs <- NULL
1278
1279             if(length(containerRequest) > 0)
1280                 body <- jsonlite::toJSON(list(containerRequest = containerRequest),
1281                                          auto_unbox = TRUE)
1282             else
1283                 body <- NULL
1284
1285             response <- private$REST$http$exec("PUT", url, headers, body,
1286                                                queryArgs, private$numRetries)
1287             resource <- private$REST$httpParser$parseJSONResponse(response)
1288
1289             if(!is.null(resource$errors))
1290                 stop(resource$errors)
1291
1292             resource
1293         },
1294
1295         #' @description
1296         #' container_requests_delete is a method defined in Arvados class.
1297         #' @param uuid The UUID of the containerRequest in question.
1298         container_requests_delete = function(uuid)
1299         {
1300             endPoint <- stringr::str_interp("container_requests/${uuid}")
1301             url <- paste0(private$host, endPoint)
1302             headers <- list(Authorization = paste("Bearer", private$token),
1303                             "Content-Type" = "application/json")
1304             queryArgs <- NULL
1305
1306             body <- NULL
1307
1308             response <- private$REST$http$exec("DELETE", url, headers, body,
1309                                                queryArgs, private$numRetries)
1310             resource <- private$REST$httpParser$parseJSONResponse(response)
1311
1312             if(!is.null(resource$errors))
1313                 stop(resource$errors)
1314
1315             resource
1316         },
1317
1318         #' @description
1319         #' container_requests_list is a method defined in Arvados class.
1320         #' @param filters
1321         #' @param where
1322         #' @param order
1323         #' @param select
1324         #' @param distinct
1325         #' @param limit
1326         #' @param offset
1327         #' @param count
1328         #' @param clusterID List objects on a remote federated cluster instead of the current one.
1329         #' @param bypassFederation bypass federation behavior, list items from local instance database only
1330         #' @param includeTrash Include container requests whose owner project is trashed.
1331         container_requests_list = function(filters = NULL,
1332                                            where = NULL, order = NULL, select = NULL,
1333                                            distinct = NULL, limit = "100", offset = "0",
1334                                            count = "exact", clusterID = NULL, bypassFederation = NULL,
1335                                            includeTrash = NULL)
1336         {
1337             endPoint <- stringr::str_interp("container_requests")
1338             url <- paste0(private$host, endPoint)
1339             headers <- list(Authorization = paste("Bearer", private$token),
1340                             "Content-Type" = "application/json")
1341             queryArgs <- list(filters = filters, where = where,
1342                               order = order, select = select, distinct = distinct,
1343                               limit = limit, offset = offset, count = count,
1344                               clusterID = clusterID, bypassFederation = bypassFederation,
1345                               includeTrash = includeTrash)
1346
1347             body <- NULL
1348
1349             response <- private$REST$http$exec("GET", url, headers, body,
1350                                                queryArgs, private$numRetries)
1351             resource <- private$REST$httpParser$parseJSONResponse(response)
1352
1353             if(!is.null(resource$errors))
1354                 stop(resource$errors)
1355
1356             resource
1357         },
1358
1359         #' @description
1360         #' groups_get is a method defined in Arvados class.
1361         #' @param uuid The UUID of the Group in question.
1362         groups_get = function(uuid)
1363         {
1364             endPoint <- stringr::str_interp("groups/${uuid}")
1365             url <- paste0(private$host, endPoint)
1366             headers <- list(Authorization = paste("Bearer", private$token),
1367                             "Content-Type" = "application/json")
1368
1369             queryArgs <- NULL
1370
1371             body <- NULL
1372
1373             response <- private$REST$http$exec("GET", url, headers, body,
1374                                                queryArgs, private$numRetries)
1375             resource <- private$REST$httpParser$parseJSONResponse(response)
1376
1377             if(!is.null(resource$errors))
1378                 stop(resource$errors)
1379
1380             resource
1381         },
1382
1383         #' @description
1384         #' groups_create is a method defined in Arvados class that supports project creation.
1385         #' @param group Group object.
1386         #' @param ensureUniqueName Adjust name to ensure uniqueness instead of returning an error.
1387         #' @param clusterID Create object on a remote federated cluster instead of the current one.
1388         #' @param async Defer permissions update.
1389         groups_create = function(group, ensureUniqueName = "false",
1390                                  clusterID = NULL, async = "false")
1391         {
1392             endPoint <- stringr::str_interp("groups")
1393             url <- paste0(private$host, endPoint)
1394             headers <- list(Authorization = paste("Bearer", private$token),
1395                             "Content-Type" = "application/json")
1396
1397             queryArgs <- list(ensureUniqueName = ensureUniqueName,
1398                               clusterID = clusterID, async = async)
1399
1400             if(length(group) > 0)
1401                 body <- jsonlite::toJSON(list(group = group),
1402                                          auto_unbox = TRUE)
1403             else
1404                 body <- NULL
1405
1406             response <- private$REST$http$exec("POST", url, headers, body,
1407                                                queryArgs, private$numRetries)
1408
1409             resource <- private$REST$httpParser$parseJSONResponse(response)
1410
1411             if(!is.null(resource$errors)){
1412                 if (identical(sub('#.*', "", resource$errors), "//railsapi.internal/arvados/v1/groups: 422 Unprocessable Entity: ")) {
1413                 #if (identical(sub('P.*', "", resource$errors), "//railsapi.internal/arvados/v1/groups: 422 Unprocessable Entity: #\u003cActiveRecord::RecordNotUnique: ")) {
1414                     resource <- cat(format("Project of that name already exist. If you want to update it use project_update() instead"))
1415                 }else{
1416                     stop(resource$errors)
1417                 }
1418             }
1419
1420             return(resource)
1421         },
1422
1423         #' @description
1424         #' groups_update is a method defined in Arvados class.
1425         #' @param group Group object.
1426         #' @param uuid The UUID of the Group in question.
1427         #' @param async Defer permissions update.
1428         groups_update = function(group, uuid, async = "false")
1429         {
1430             endPoint <- stringr::str_interp("groups/${uuid}")
1431             url <- paste0(private$host, endPoint)
1432             headers <- list(Authorization = paste("Bearer", private$token),
1433                             "Content-Type" = "application/json")
1434
1435             queryArgs <- list(async = async)
1436
1437             if(length(group) > 0)
1438                 body <- jsonlite::toJSON(list(group = group),
1439                                          auto_unbox = TRUE)
1440             else
1441                 body <- NULL
1442
1443             response <- private$REST$http$exec("PUT", url, headers, body,
1444                                                queryArgs, private$numRetries)
1445             resource <- private$REST$httpParser$parseJSONResponse(response)
1446
1447             if(!is.null(resource$errors))
1448                 stop(resource$errors)
1449
1450             resource
1451         },
1452
1453         #' @description
1454         #' groups_delete is a method defined in Arvados class.
1455         #' @param uuid The UUID of the Group in question.
1456         groups_delete = function(uuid)
1457         {
1458             endPoint <- stringr::str_interp("groups/${uuid}")
1459             url <- paste0(private$host, endPoint)
1460             headers <- list(Authorization = paste("Bearer", private$token),
1461                             "Content-Type" = "application/json")
1462
1463             queryArgs <- NULL
1464
1465             body <- NULL
1466
1467             response <- private$REST$http$exec("DELETE", url, headers, body,
1468                                                queryArgs, private$numRetries)
1469             resource <- private$REST$httpParser$parseJSONResponse(response)
1470
1471             if(!is.null(resource$errors))
1472                 stop(resource$errors)
1473
1474             dataTime <- gsub("T.*", "", resource$delete_at)
1475             cat("The content will be deleted permanently at", dataTime)
1476
1477             resource
1478         },
1479
1480         #' @description
1481         #' groups_contents is a method defined in Arvados class.
1482         #' @param filters
1483         #' @param where
1484         #' @param order
1485         #' @param distinct
1486         #' @param limit
1487         #' @param offset
1488         #' @param count
1489         #' @param clusterID List objects on a remote federated cluster instead of the current one.
1490         #' @param bypassFederation Bypass federation behavior, list items from local instance database only.
1491         #' @param includeTrash Include items whose is_trashed attribute is true.
1492         #' @param uuid
1493         #' @param recursive Include contents from child groups recursively.
1494         #' @param include Include objects referred to by listed field in "included" (only ownerUUID).
1495         groups_contents = function(filters = NULL,
1496                                    where = NULL, order = NULL, distinct = NULL,
1497                                    limit = "100", offset = "0", count = "exact",
1498                                    clusterID = NULL, bypassFederation = NULL,
1499                                    includeTrash = NULL, uuid = NULL, recursive = NULL,
1500                                    include = NULL)
1501         {
1502             endPoint <- stringr::str_interp("groups/contents")
1503             url <- paste0(private$host, endPoint)
1504             headers <- list(Authorization = paste("Bearer", private$token),
1505                             "Content-Type" = "application/json")
1506
1507             queryArgs <- list(filters = filters, where = where,
1508                               order = order, distinct = distinct, limit = limit,
1509                               offset = offset, count = count, clusterID = clusterID,
1510                               bypassFederation = bypassFederation, includeTrash = includeTrash,
1511                               uuid = uuid, recursive = recursive, include = include)
1512
1513             body <- NULL
1514
1515             response <- private$REST$http$exec("GET", url, headers, body,
1516                                                queryArgs, private$numRetries)
1517             resource <- private$REST$httpParser$parseJSONResponse(response)
1518
1519             if(!is.null(resource$errors))
1520                 stop(resource$errors)
1521
1522             resource
1523         },
1524
1525         #' @description
1526         #' groups_shared is a method defined in Arvados class.
1527         #' @param filters
1528         #' @param where
1529         #' @param order
1530         #' @param select
1531         #' @param distinct
1532         #' @param limit
1533         #' @param offset
1534         #' @param count
1535         #' @param clusterID List objects on a remote federated cluster instead of the current one.
1536         #' @param bypassFederation Bypass federation behavior, list items from local instance database only.
1537         #' @param includeTrash Include items whose is_trashed attribute is true.
1538         #' @param include
1539         groups_shared = function(filters = NULL,
1540                                  where = NULL, order = NULL, select = NULL,
1541                                  distinct = NULL, limit = "100", offset = "0",
1542                                  count = "exact", clusterID = NULL, bypassFederation = NULL,
1543                                  includeTrash = NULL, include = NULL)
1544         {
1545             endPoint <- stringr::str_interp("groups/shared")
1546             url <- paste0(private$host, endPoint)
1547             headers <- list(Authorization = paste("Bearer", private$token),
1548                             "Content-Type" = "application/json")
1549
1550             queryArgs <- list(filters = filters, where = where,
1551                               order = order, select = select, distinct = distinct,
1552                               limit = limit, offset = offset, count = count,
1553                               clusterID = clusterID, bypassFederation = bypassFederation,
1554                               includeTrash = includeTrash, include = include)
1555
1556             body <- NULL
1557
1558             response <- private$REST$http$exec("GET", url, headers, body,
1559                                                queryArgs, private$numRetries)
1560             resource <- private$REST$httpParser$parseJSONResponse(response)
1561
1562             if(!is.null(resource$errors))
1563                 stop(resource$errors)
1564
1565             resource
1566         },
1567
1568         #' @description
1569         #' groups_trash is a method defined in Arvados class.
1570         #' @param uuid The UUID of the Group in question.
1571         groups_trash = function(uuid)
1572         {
1573             endPoint <- stringr::str_interp("groups/${uuid}/trash")
1574             url <- paste0(private$host, endPoint)
1575             headers <- list(Authorization = paste("Bearer", private$token),
1576                             "Content-Type" = "application/json")
1577
1578             queryArgs <- NULL
1579
1580             body <- NULL
1581
1582             response <- private$REST$http$exec("POST", url, headers, body,
1583                                                queryArgs, private$numRetries)
1584             resource <- private$REST$httpParser$parseJSONResponse(response)
1585
1586             if(!is.null(resource$errors))
1587                 stop(resource$errors)
1588
1589             resource
1590         },
1591
1592         #' @description
1593         #' groups_untrash is a method defined in Arvados class.
1594         #' @param uuid The UUID of the Group in question.
1595         groups_untrash = function(uuid)
1596         {
1597             endPoint <- stringr::str_interp("groups/${uuid}/untrash")
1598             url <- paste0(private$host, endPoint)
1599             headers <- list(Authorization = paste("Bearer", private$token),
1600                             "Content-Type" = "application/json")
1601
1602             queryArgs <- NULL
1603
1604             body <- NULL
1605
1606             response <- private$REST$http$exec("POST", url, headers, body,
1607                                                queryArgs, private$numRetries)
1608             resource <- private$REST$httpParser$parseJSONResponse(response)
1609
1610             if(!is.null(resource$errors))
1611                 stop(resource$errors)
1612
1613             resource
1614         },
1615
1616         #' @description
1617         #' groups_list is a method defined in Arvados class.
1618         #' @param filters
1619         #' @param where
1620         #' @param order
1621         #' @param select
1622         #' @param distinct
1623         #' @param limit
1624         #' @param offset
1625         #' @param count
1626         #' @param clusterID List objects on a remote federated cluster instead of the current one.
1627         #' @param bypassFederation Bypass federation behavior, list items from local instance database only.
1628         #' @param includeTrash Include items whose is_trashed attribute is true.
1629         groups_list = function(filters = NULL, where = NULL,
1630                                order = NULL, select = NULL, distinct = NULL,
1631                                limit = "100", offset = "0", count = "exact",
1632                                clusterID = NULL, bypassFederation = NULL,
1633                                includeTrash = NULL)
1634         {
1635             endPoint <- stringr::str_interp("groups")
1636             url <- paste0(private$host, endPoint)
1637             headers <- list(Authorization = paste("Bearer", private$token),
1638                             "Content-Type" = "application/json")
1639
1640             queryArgs <- list(filters = filters, where = where,
1641                               order = order, select = select, distinct = distinct,
1642                               limit = limit, offset = offset, count = count,
1643                               clusterID = clusterID, bypassFederation = bypassFederation,
1644                               includeTrash = includeTrash)
1645
1646             body <- NULL
1647
1648             response <- private$REST$http$exec("GET", url, headers, body,
1649                                                queryArgs, private$numRetries)
1650             resource <- private$REST$httpParser$parseJSONResponse(response)
1651
1652             if(!is.null(resource$errors))
1653                 stop(resource$errors)
1654
1655             resource
1656         },
1657
1658         #' @description
1659         #' keep_services_get is a method defined in Arvados class.
1660         #' @param uuid The UUID of the keepService in question.
1661         keep_services_get = function(uuid)
1662         {
1663             endPoint <- stringr::str_interp("keep_services/${uuid}")
1664             url <- paste0(private$host, endPoint)
1665             headers <- list(Authorization = paste("Bearer", private$token),
1666                             "Content-Type" = "application/json")
1667             queryArgs <- NULL
1668
1669             body <- NULL
1670
1671             response <- private$REST$http$exec("GET", url, headers, body,
1672                                                queryArgs, private$numRetries)
1673             resource <- private$REST$httpParser$parseJSONResponse(response)
1674
1675             if(!is.null(resource$errors))
1676                 stop(resource$errors)
1677
1678             resource
1679         },
1680
1681         #' @description
1682         #' keep_services_create is a method defined in Arvados class.
1683         #' @param keepService keepService object.
1684         #' @param ensureUniqueName Adjust name to ensure uniqueness instead of returning an error.
1685         #' @param clusterID Create object on a remote federated cluster instead of the current one.
1686         keep_services_create = function(keepService,
1687                                         ensureUniqueName = "false", clusterID = NULL)
1688         {
1689             endPoint <- stringr::str_interp("keep_services")
1690             url <- paste0(private$host, endPoint)
1691             headers <- list(Authorization = paste("Bearer", private$token),
1692                             "Content-Type" = "application/json")
1693             queryArgs <- list(ensureUniqueName = ensureUniqueName,
1694                               clusterID = clusterID)
1695
1696             if(length(keepService) > 0)
1697                 body <- jsonlite::toJSON(list(keepService = keepService),
1698                                          auto_unbox = TRUE)
1699             else
1700                 body <- NULL
1701
1702             response <- private$REST$http$exec("POST", url, headers, body,
1703                                                queryArgs, private$numRetries)
1704             resource <- private$REST$httpParser$parseJSONResponse(response)
1705
1706             if(!is.null(resource$errors))
1707                 stop(resource$errors)
1708
1709             resource
1710         },
1711
1712         #' @description
1713         #' keep_services_update is a method defined in Arvados class.
1714         #' @param keepService keepService object.
1715         #' @param uuid The UUID of the keepService in question.
1716         keep_services_update = function(keepService, uuid)
1717         {
1718             endPoint <- stringr::str_interp("keep_services/${uuid}")
1719             url <- paste0(private$host, endPoint)
1720             headers <- list(Authorization = paste("Bearer", private$token),
1721                             "Content-Type" = "application/json")
1722             queryArgs <- NULL
1723
1724             if(length(keepService) > 0)
1725                 body <- jsonlite::toJSON(list(keepService = keepService),
1726                                          auto_unbox = TRUE)
1727             else
1728                 body <- NULL
1729
1730             response <- private$REST$http$exec("PUT", url, headers, body,
1731                                                queryArgs, private$numRetries)
1732             resource <- private$REST$httpParser$parseJSONResponse(response)
1733
1734             if(!is.null(resource$errors))
1735                 stop(resource$errors)
1736
1737             resource
1738         },
1739
1740         #' @description
1741         #' keep_services_delete is a method defined in Arvados class.
1742         #' @param uuid The UUID of the keepService in question.
1743         keep_services_delete = function(uuid)
1744         {
1745             endPoint <- stringr::str_interp("keep_services/${uuid}")
1746             url <- paste0(private$host, endPoint)
1747             headers <- list(Authorization = paste("Bearer", private$token),
1748                             "Content-Type" = "application/json")
1749             queryArgs <- NULL
1750
1751             body <- NULL
1752
1753             response <- private$REST$http$exec("DELETE", url, headers, body,
1754                                                queryArgs, private$numRetries)
1755             resource <- private$REST$httpParser$parseJSONResponse(response)
1756
1757             if(!is.null(resource$errors))
1758                 stop(resource$errors)
1759
1760             resource
1761         },
1762
1763         #' @description
1764         #' keep_services_accessible is a method defined in Arvados class.
1765         keep_services_accessible = function()
1766         {
1767             endPoint <- stringr::str_interp("keep_services/accessible")
1768             url <- paste0(private$host, endPoint)
1769             headers <- list(Authorization = paste("Bearer", private$token),
1770                             "Content-Type" = "application/json")
1771             queryArgs <- NULL
1772
1773             body <- NULL
1774
1775             response <- private$REST$http$exec("GET", url, headers, body,
1776                                                queryArgs, private$numRetries)
1777             resource <- private$REST$httpParser$parseJSONResponse(response)
1778
1779             if(!is.null(resource$errors))
1780                 stop(resource$errors)
1781
1782             resource
1783         },
1784
1785         #' @description
1786         #' keep_services_list is a method defined in Arvados class.
1787         #' @param filters
1788         #' @param where
1789         #' @param order
1790         #' @param select
1791         #' @param distinct
1792         #' @param limit
1793         #' @param offset
1794         #' @param count
1795         #' @param clusterID List objects on a remote federated cluster instead of the current one.
1796         #' @param bypassFederation Bypass federation behavior, list items from local instance database only.
1797         keep_services_list = function(filters = NULL,
1798                                       where = NULL, order = NULL, select = NULL,
1799                                       distinct = NULL, limit = "100", offset = "0",
1800                                       count = "exact", clusterID = NULL, bypassFederation = NULL)
1801         {
1802             endPoint <- stringr::str_interp("keep_services")
1803             url <- paste0(private$host, endPoint)
1804             headers <- list(Authorization = paste("Bearer", private$token),
1805                             "Content-Type" = "application/json")
1806             queryArgs <- list(filters = filters, where = where,
1807                               order = order, select = select, distinct = distinct,
1808                               limit = limit, offset = offset, count = count,
1809                               clusterID = clusterID, bypassFederation = bypassFederation)
1810
1811             body <- NULL
1812
1813             response <- private$REST$http$exec("GET", url, headers, body,
1814                                                queryArgs, private$numRetries)
1815             resource <- private$REST$httpParser$parseJSONResponse(response)
1816
1817             if(!is.null(resource$errors))
1818                 stop(resource$errors)
1819
1820             resource
1821         },
1822
1823         #' @description
1824         #' project_permission_give is a method defined in Arvados class that enables sharing files with another users.
1825         #' @param type Possible options are can_read or can_write or can_manage.
1826         #' @param uuid The UUID of a project or a file.
1827         #' @param user The UUID of the person that gets the permission.
1828         #' @examples
1829         #' arv$project_permission_give(type = "can_read", uuid = objectUUID, user = userUUID)
1830         project_permission_give = function(type, uuid, user)
1831         {
1832             endPoint <- stringr::str_interp("links")
1833             url <- paste0(private$host, endPoint)
1834             headers <- list(Authorization = paste("Bearer", private$token),
1835                             "Content-Type" = "application/json")
1836             queryArgs <- NULL
1837
1838             # it is possible to make it as pasting a list to function, not a 3 arg. What's better?
1839             link <- list("link_class" = "permission", "name" = type, "head_uuid" = uuid, "tail_uuid" = user)
1840
1841             if(length(link) > 0)
1842                 body <- jsonlite::toJSON(list(link = link),
1843                                          auto_unbox = TRUE)
1844             else
1845                 body <- NULL
1846
1847             response <- private$REST$http$exec("POST", url, headers, body,
1848                                                queryArgs, private$numRetries)
1849             resource <- private$REST$httpParser$parseJSONResponse(response)
1850
1851             if(!is.null(resource$errors))
1852                 stop(resource$errors)
1853
1854             resource
1855         },
1856
1857         #' @description
1858         #' project_permission_refuse is a method defined in Arvados class that unables sharing files with another users.
1859         #' @param type Possible options are can_read or can_write or can_manage.
1860         #' @param uuid The UUID of a project or a file.
1861         #' @param user The UUID of a person that permissions are taken from.
1862         #' @examples
1863         #' arv$project_permission_refuse(type = "can_read", uuid = objectUUID, user = userUUID)
1864         project_permission_refuse = function(type, uuid, user)
1865         {
1866             examples <- self$links_list(list(list("head_uuid","=", uuid)))
1867
1868             theUser <- examples[which(sapply(examples$items, "[[", "tail_uuid") == user)]
1869             theType <- theUser$items[which(sapply(theUser$items, "[[", "name") == type)]
1870             solution <- theType[which(sapply(theType, "[[", "link_class") == 'permission')]
1871
1872             if (length(solution) == 0) {
1873                 cat(format('No permission granted'))
1874             } else {
1875                 self$links_delete(solution[[1]]$uuid)
1876             }
1877
1878         },
1879
1880         #' @description
1881         #' project_permission_update is a method defined in Arvados class that enables updating permissions.
1882         #' @param typeNew New option like can_read or can_write or can_manage.
1883         #' @param typeOld Old option.
1884         #' @param uuid The UUID of a project or a file.
1885         #' @param user The UUID of the person that the permission is being updated.
1886         #' @examples
1887         #' arv$project_permission_update(typeOld = "can_read", typeNew = "can_write", uuid = objectUUID, user = userUUID)
1888         project_permission_update = function(typeOld, typeNew, uuid, user)
1889         {
1890             link <- list("name" = typeNew)
1891
1892             examples <- self$links_list(list(list("head_uuid","=", uuid)))
1893
1894             theUser <- examples[which(sapply(examples$items, "[[", "tail_uuid") == user)]
1895             theType <- theUser$items[which(sapply(theUser$items, "[[", "name") == typeOld)]
1896             solution <- theType[which(sapply(theType, "[[", "link_class") == 'permission')]
1897
1898             if (length(solution) == 0) {
1899                 cat(format('No permission granted'))
1900             } else {
1901                 self$links_update(link, solution[[1]]$uuid)
1902             }
1903         },
1904
1905         #' @description
1906         #' project_permission_check is a method defined in Arvados class that enables checking file permissions.
1907         #' @param uuid The UUID of a project or a file.
1908         #' @param user The UUID of the person that the permission is being updated.
1909         #' @param type Possible options are can_read or can_write or can_manage.
1910         #' @examples
1911         #' arv$project_permission_check(type = "can_read", uuid = objectUUID, user = userUUID)
1912         project_permission_check = function(uuid, user, type = NULL)
1913         {
1914             examples <- self$links_list(list(list("head_uuid","=", uuid)))
1915
1916             theUser <- examples[which(sapply(examples$items, "[[", "tail_uuid") == user)]
1917
1918             if (length(type) == 0 ){
1919                 theUser
1920             } else {
1921                 theType <- theUser$items[which(sapply(theUser$items, "[[", "name") == type)]
1922                 permisions <- theType[which(sapply(theType, "[[", "link_class") == 'permission')]
1923                 print(permisions[[1]]$name)
1924             }
1925         },
1926
1927         #' @description
1928         #' links_get is a method defined in Arvados class.
1929         #' @param uuid The UUID of the Link in question.
1930         links_get = function(uuid)
1931         {
1932             endPoint <- stringr::str_interp("links/${uuid}")
1933             url <- paste0(private$host, endPoint)
1934             headers <- list(Authorization = paste("Bearer", private$token),
1935                             "Content-Type" = "application/json")
1936             queryArgs <- NULL
1937
1938             body <- NULL
1939
1940             response <- private$REST$http$exec("GET", url, headers, body,
1941                                                queryArgs, private$numRetries)
1942             resource <- private$REST$httpParser$parseJSONResponse(response)
1943
1944             if(!is.null(resource$errors))
1945                 stop(resource$errors)
1946
1947             resource
1948         },
1949
1950         #' @description
1951         #' links_create is a method defined in Arvados class.
1952         #' @param link Link object.
1953         #' @param ensureUniqueName Adjust name to ensure uniqueness instead of returning an error.
1954         #' @param clusterID Create object on a remote federated cluster instead of the current one.
1955         links_create = function(link, ensureUniqueName = "false",
1956                                 clusterID = NULL)
1957         {
1958             endPoint <- stringr::str_interp("links")
1959             url <- paste0(private$host, endPoint)
1960             headers <- list(Authorization = paste("Bearer", private$token),
1961                             "Content-Type" = "application/json")
1962             queryArgs <- list(ensureUniqueName = ensureUniqueName,
1963                               clusterID = clusterID)
1964
1965             if(length(link) > 0)
1966                 body <- jsonlite::toJSON(list(link = link),
1967                                          auto_unbox = TRUE)
1968             else
1969                 body <- NULL
1970
1971             response <- private$REST$http$exec("POST", url, headers, body,
1972                                                queryArgs, private$numRetries)
1973             resource <- private$REST$httpParser$parseJSONResponse(response)
1974
1975             if(!is.null(resource$errors))
1976                 stop(resource$errors)
1977
1978             resource
1979         },
1980
1981         #' @description
1982         #' links_update is a method defined in Arvados class.
1983         #' @param link Link object.
1984         #' @param uuid The UUID of the Link in question.
1985         links_update = function(link, uuid, async = "false")
1986         {
1987             endPoint <- stringr::str_interp("links/${uuid}")
1988             url <- paste0(private$host, endPoint)
1989             headers <- list(Authorization = paste("Bearer", private$token),
1990                             "Content-Type" = "application/json")
1991             queryArgs <- list(async = async)
1992
1993             if(length(link) > 0)
1994                 body <- jsonlite::toJSON(list(link = link),
1995                                          auto_unbox = TRUE)
1996             else
1997                 body <- NULL
1998
1999             response <- private$REST$http$exec("PUT", url, headers, body,
2000                                                queryArgs, private$numRetries)
2001             resource <- private$REST$httpParser$parseJSONResponse(response)
2002
2003             if(!is.null(resource$errors))
2004                 stop(resource$errors)
2005
2006             resource
2007         },
2008
2009         #' @description
2010         #' links_delete is a method defined in Arvados class.
2011         #' @param uuid The UUID of the Link in question.
2012         links_delete = function(uuid)
2013         {
2014             endPoint <- stringr::str_interp("links/${uuid}")
2015             url <- paste0(private$host, endPoint)
2016             headers <- list(Authorization = paste("Bearer", private$token),
2017                             "Content-Type" = "application/json")
2018             queryArgs <- NULL
2019
2020             body <- NULL
2021
2022             response <- private$REST$http$exec("DELETE", url, headers, body,
2023                                                queryArgs, private$numRetries)
2024             resource <- private$REST$httpParser$parseJSONResponse(response)
2025
2026             if(!is.null(resource$errors))
2027                 stop(resource$errors)
2028
2029             resource
2030         },
2031
2032         #' @description
2033         #' links_list is a method defined in Arvados class.
2034         #' @param filters
2035         #' @param where
2036         #' @param order
2037         #' @param select
2038         #' @param distinct
2039         #' @param limit
2040         #' @param offset
2041         #' @param count
2042         #' @param clusterID List objects on a remote federated cluster instead of the current one.
2043         #' @param bypassFederation Bypass federation behavior, list items from local instance database only.
2044         links_list = function(filters = NULL, where = NULL,
2045                               order = NULL, select = NULL, distinct = NULL,
2046                               limit = "100", offset = "0", count = "exact",
2047                               clusterID = NULL, bypassFederation = NULL)
2048         {
2049             endPoint <- stringr::str_interp("links")
2050             url <- paste0(private$host, endPoint)
2051             headers <- list(Authorization = paste("Bearer", private$token),
2052                             "Content-Type" = "application/json")
2053             queryArgs <- list(filters = filters, where = where,
2054                               order = order, select = select, distinct = distinct,
2055                               limit = limit, offset = offset, count = count,
2056                               clusterID = clusterID, bypassFederation = bypassFederation)
2057
2058             body <- NULL
2059
2060             response <- private$REST$http$exec("GET", url, headers, body,
2061                                                queryArgs, private$numRetries)
2062             resource <- private$REST$httpParser$parseJSONResponse(response)
2063
2064             if(!is.null(resource$errors))
2065                 stop(resource$errors)
2066
2067             resource
2068         },
2069
2070         #' @description
2071         #' links_get_permissions is a method defined in Arvados class.
2072         #' @param uuid The UUID of the Log in question.
2073         links_get_permissions = function(uuid)
2074         {
2075             endPoint <- stringr::str_interp("permissions/${uuid}")
2076             url <- paste0(private$host, endPoint)
2077             headers <- list(Authorization = paste("Bearer", private$token),
2078                             "Content-Type" = "application/json")
2079             queryArgs <- NULL
2080
2081             body <- NULL
2082
2083             response <- private$REST$http$exec("GET", url, headers, body,
2084                                                queryArgs, private$numRetries)
2085             resource <- private$REST$httpParser$parseJSONResponse(response)
2086
2087             if(!is.null(resource$errors))
2088                 stop(resource$errors)
2089
2090             resource
2091         },
2092
2093         #' @description
2094         #' logs_get is a method defined in Arvados class.
2095         #' @param uuid The UUID of the Log in question.
2096         logs_get = function(uuid)
2097         {
2098             endPoint <- stringr::str_interp("logs/${uuid}")
2099             url <- paste0(private$host, endPoint)
2100             headers <- list(Authorization = paste("Bearer", private$token),
2101                             "Content-Type" = "application/json")
2102             queryArgs <- NULL
2103
2104             body <- NULL
2105
2106             response <- private$REST$http$exec("GET", url, headers, body,
2107                                                queryArgs, private$numRetries)
2108             resource <- private$REST$httpParser$parseJSONResponse(response)
2109
2110             if(!is.null(resource$errors))
2111                 stop(resource$errors)
2112
2113             resource
2114         },
2115
2116         #' @description
2117         #' logs_create is a method defined in Arvados class.
2118         #' @param log Log object.
2119         #' @param ensureUniqueName Adjust name to ensure uniqueness instead of returning an error.
2120         #' @param clusterID Create object on a remote federated cluster instead of the current one.
2121         logs_create = function(log, ensureUniqueName = "false",
2122                                clusterID = NULL)
2123         {
2124             endPoint <- stringr::str_interp("logs")
2125             url <- paste0(private$host, endPoint)
2126             headers <- list(Authorization = paste("Bearer", private$token),
2127                             "Content-Type" = "application/json")
2128             queryArgs <- list(ensureUniqueName = ensureUniqueName,
2129                               clusterID = clusterID)
2130
2131             if(length(log) > 0)
2132                 body <- jsonlite::toJSON(list(log = log),
2133                                          auto_unbox = TRUE)
2134             else
2135                 body <- NULL
2136
2137             response <- private$REST$http$exec("POST", url, headers, body,
2138                                                queryArgs, private$numRetries)
2139             resource <- private$REST$httpParser$parseJSONResponse(response)
2140
2141             if(!is.null(resource$errors))
2142                 stop(resource$errors)
2143
2144             resource
2145         },
2146
2147         #' @description
2148         #' logs_update is a method defined in Arvados class.
2149         #' @param log Log object.
2150         #' @param uuid The UUID of the Log in question.
2151         logs_update = function(log, uuid)
2152         {
2153             endPoint <- stringr::str_interp("logs/${uuid}")
2154             url <- paste0(private$host, endPoint)
2155             headers <- list(Authorization = paste("Bearer", private$token),
2156                             "Content-Type" = "application/json")
2157             queryArgs <- NULL
2158
2159             if(length(log) > 0)
2160                 body <- jsonlite::toJSON(list(log = log),
2161                                          auto_unbox = TRUE)
2162             else
2163                 body <- NULL
2164
2165             response <- private$REST$http$exec("PUT", url, headers, body,
2166                                                queryArgs, private$numRetries)
2167             resource <- private$REST$httpParser$parseJSONResponse(response)
2168
2169             if(!is.null(resource$errors))
2170                 stop(resource$errors)
2171
2172             resource
2173         },
2174
2175         #' @description
2176         #' logs_delete is a method defined in Arvados class.
2177         #' @param uuid The UUID of the Log in question.
2178         logs_delete = function(uuid)
2179         {
2180             endPoint <- stringr::str_interp("logs/${uuid}")
2181             url <- paste0(private$host, endPoint)
2182             headers <- list(Authorization = paste("Bearer", private$token),
2183                             "Content-Type" = "application/json")
2184             queryArgs <- NULL
2185
2186             body <- NULL
2187
2188             response <- private$REST$http$exec("DELETE", url, headers, body,
2189                                                queryArgs, private$numRetries)
2190             resource <- private$REST$httpParser$parseJSONResponse(response)
2191
2192             if(!is.null(resource$errors))
2193                 stop(resource$errors)
2194
2195             resource
2196         },
2197
2198         #' @description
2199         #' logs_list is a method defined in Arvados class.
2200         #' @param filters
2201         #' @param where
2202         #' @param order
2203         #' @param select
2204         #' @param distinct
2205         #' @param limit
2206         #' @param offset
2207         #' @param count
2208         #' @param clusterID List objects on a remote federated cluster instead of the current one.
2209         #' @param bypassFederation Bypass federation behavior, list items from local instance database only.
2210         logs_list = function(filters = NULL, where = NULL,
2211                              order = NULL, select = NULL, distinct = NULL,
2212                              limit = "100", offset = "0", count = "exact",
2213                              clusterID = NULL, bypassFederation = NULL)
2214         {
2215             endPoint <- stringr::str_interp("logs")
2216             url <- paste0(private$host, endPoint)
2217             headers <- list(Authorization = paste("Bearer", private$token),
2218                             "Content-Type" = "application/json")
2219             queryArgs <- list(filters = filters, where = where,
2220                               order = order, select = select, distinct = distinct,
2221                               limit = limit, offset = offset, count = count,
2222                               clusterID = clusterID, bypassFederation = bypassFederation)
2223
2224             body <- NULL
2225
2226             response <- private$REST$http$exec("GET", url, headers, body,
2227                                                queryArgs, private$numRetries)
2228             resource <- private$REST$httpParser$parseJSONResponse(response)
2229
2230             if(!is.null(resource$errors))
2231                 stop(resource$errors)
2232
2233             resource
2234         },
2235
2236         #' @description
2237         #' users_get is a method defined in Arvados class.
2238         #' @param uuid The UUID of the User in question.
2239         users_get = function(uuid)
2240         {
2241             endPoint <- stringr::str_interp("users/${uuid}")
2242             url <- paste0(private$host, endPoint)
2243             headers <- list(Authorization = paste("Bearer", private$token),
2244                             "Content-Type" = "application/json")
2245             queryArgs <- NULL
2246
2247             body <- NULL
2248
2249             response <- private$REST$http$exec("GET", url, headers, body,
2250                                                queryArgs, private$numRetries)
2251             resource <- private$REST$httpParser$parseJSONResponse(response)
2252
2253             if(!is.null(resource$errors))
2254                 stop(resource$errors)
2255
2256             resource
2257         },
2258
2259         #' @description
2260         #' users_create is a method defined in Arvados class.
2261         #' @param user User object.
2262         #' @param ensureUniqueName Adjust name to ensure uniqueness instead of returning an error.
2263         #' @param clusterID Create object on a remote federated cluster instead of the current one.
2264         users_create = function(user, ensureUniqueName = "false",
2265                                 clusterID = NULL)
2266         {
2267             endPoint <- stringr::str_interp("users")
2268             url <- paste0(private$host, endPoint)
2269             headers <- list(Authorization = paste("Bearer", private$token),
2270                             "Content-Type" = "application/json")
2271             queryArgs <- list(ensureUniqueName = ensureUniqueName,
2272                               clusterID = clusterID)
2273
2274             if(length(user) > 0)
2275                 body <- jsonlite::toJSON(list(user = user),
2276                                          auto_unbox = TRUE)
2277             else
2278                 body <- NULL
2279
2280             response <- private$REST$http$exec("POST", url, headers, body,
2281                                                queryArgs, private$numRetries)
2282             resource <- private$REST$httpParser$parseJSONResponse(response)
2283
2284             if(!is.null(resource$errors))
2285                 stop(resource$errors)
2286
2287             resource
2288         },
2289
2290         #' @description
2291         #' users_update is a method defined in Arvados class.
2292         #' @param user User object.
2293         #' @param uuid The UUID of the User in question.
2294         #' @param bypassFederation
2295         users_update = function(user, uuid, bypassFederation = NULL)
2296         {
2297             endPoint <- stringr::str_interp("users/${uuid}")
2298             url <- paste0(private$host, endPoint)
2299             headers <- list(Authorization = paste("Bearer", private$token),
2300                             "Content-Type" = "application/json")
2301             queryArgs <- list(bypassFederation = bypassFederation)
2302
2303             if(length(user) > 0)
2304                 body <- jsonlite::toJSON(list(user = user),
2305                                          auto_unbox = TRUE)
2306             else
2307                 body <- NULL
2308
2309             response <- private$REST$http$exec("PUT", url, headers, body,
2310                                                queryArgs, private$numRetries)
2311             resource <- private$REST$httpParser$parseJSONResponse(response)
2312
2313             if(!is.null(resource$errors))
2314                 stop(resource$errors)
2315
2316             resource
2317         },
2318
2319         #' @description
2320         #' users_delete is a method defined in Arvados class.
2321         #' @param uuid The UUID of the User in question.
2322         users_delete = function(uuid)
2323         {
2324             endPoint <- stringr::str_interp("users/${uuid}")
2325             url <- paste0(private$host, endPoint)
2326             headers <- list(Authorization = paste("Bearer", private$token),
2327                             "Content-Type" = "application/json")
2328             queryArgs <- NULL
2329
2330             body <- NULL
2331
2332             response <- private$REST$http$exec("DELETE", url, headers, body,
2333                                                queryArgs, private$numRetries)
2334             resource <- private$REST$httpParser$parseJSONResponse(response)
2335
2336             if(!is.null(resource$errors))
2337                 stop(resource$errors)
2338
2339             resource
2340         },
2341
2342         #' @description
2343         #' users_current is a method defined in Arvados class.
2344         users_current = function()
2345         {
2346             endPoint <- stringr::str_interp("users/current")
2347             url <- paste0(private$host, endPoint)
2348             headers <- list(Authorization = paste("Bearer", private$token),
2349                             "Content-Type" = "application/json")
2350             queryArgs <- NULL
2351
2352             body <- NULL
2353
2354             response <- private$REST$http$exec("GET", url, headers, body,
2355                                                queryArgs, private$numRetries)
2356             resource <- private$REST$httpParser$parseJSONResponse(response)
2357
2358             if(!is.null(resource$errors))
2359                 stop(resource$errors)
2360
2361             resource
2362         },
2363
2364         #' @description
2365         #' users_system is a method defined in Arvados class.
2366         users_system = function()
2367         {
2368             endPoint <- stringr::str_interp("users/system")
2369             url <- paste0(private$host, endPoint)
2370             headers <- list(Authorization = paste("Bearer", private$token),
2371                             "Content-Type" = "application/json")
2372             queryArgs <- NULL
2373
2374             body <- NULL
2375
2376             response <- private$REST$http$exec("GET", url, headers, body,
2377                                                queryArgs, private$numRetries)
2378             resource <- private$REST$httpParser$parseJSONResponse(response)
2379
2380             if(!is.null(resource$errors))
2381                 stop(resource$errors)
2382
2383             resource
2384         },
2385
2386         #' @description
2387         #' users_activate is a method defined in Arvados class.
2388         #' @param uuid The UUID of the User in question.
2389         users_activate = function(uuid)
2390         {
2391             endPoint <- stringr::str_interp("users/${uuid}/activate")
2392             url <- paste0(private$host, endPoint)
2393             headers <- list(Authorization = paste("Bearer", private$token),
2394                             "Content-Type" = "application/json")
2395             queryArgs <- NULL
2396
2397             body <- NULL
2398
2399             response <- private$REST$http$exec("POST", url, headers, body,
2400                                                queryArgs, private$numRetries)
2401             resource <- private$REST$httpParser$parseJSONResponse(response)
2402
2403             if(!is.null(resource$errors))
2404                 stop(resource$errors)
2405
2406             resource
2407         },
2408
2409         #' @description
2410         #' users_setup is a method defined in Arvados class.
2411         #' @param uuid
2412         #' @param user
2413         #' @param repo_name
2414         #' @param vm_uuid
2415         #' @param send_notification_email
2416         users_setup = function(uuid = NULL, user = NULL,
2417                                repo_name = NULL, vm_uuid = NULL, send_notification_email = "false")
2418         {
2419             endPoint <- stringr::str_interp("users/setup")
2420             url <- paste0(private$host, endPoint)
2421             headers <- list(Authorization = paste("Bearer", private$token),
2422                             "Content-Type" = "application/json")
2423             queryArgs <- list(uuid = uuid, user = user,
2424                               repo_name = repo_name, vm_uuid = vm_uuid,
2425                               send_notification_email = send_notification_email)
2426
2427             body <- NULL
2428
2429             response <- private$REST$http$exec("POST", url, headers, body,
2430                                                queryArgs, private$numRetries)
2431             resource <- private$REST$httpParser$parseJSONResponse(response)
2432
2433             if(!is.null(resource$errors))
2434                 stop(resource$errors)
2435
2436             resource
2437         },
2438
2439         #' @description
2440         #' users_unsetup is a method defined in Arvados class.
2441         #' @param uuid The UUID of the User in question.
2442         users_unsetup = function(uuid)
2443         {
2444             endPoint <- stringr::str_interp("users/${uuid}/unsetup")
2445             url <- paste0(private$host, endPoint)
2446             headers <- list(Authorization = paste("Bearer", private$token),
2447                             "Content-Type" = "application/json")
2448             queryArgs <- NULL
2449
2450             body <- NULL
2451
2452             response <- private$REST$http$exec("POST", url, headers, body,
2453                                                queryArgs, private$numRetries)
2454             resource <- private$REST$httpParser$parseJSONResponse(response)
2455
2456             if(!is.null(resource$errors))
2457                 stop(resource$errors)
2458
2459             resource
2460         },
2461
2462         #' @description
2463         #' users_merge is a method defined in Arvados class.
2464         #' @param newOwnerUUID
2465         #' @param newUserToken
2466         #' @param redirectToNewUser
2467         #' @param oldUserUUID
2468         #' @param newUserUUID
2469         users_merge = function(newOwnerUUID, newUserToken = NULL,
2470                                redirectToNewUser = NULL, oldUserUUID = NULL,
2471                                newUserUUID = NULL)
2472         {
2473             endPoint <- stringr::str_interp("users/merge")
2474             url <- paste0(private$host, endPoint)
2475             headers <- list(Authorization = paste("Bearer", private$token),
2476                             "Content-Type" = "application/json")
2477             queryArgs <- list(newOwnerUUID = newOwnerUUID,
2478                               newUserToken = newUserToken, redirectToNewUser = redirectToNewUser,
2479                               oldUserUUID = oldUserUUID, newUserUUID = newUserUUID)
2480
2481             body <- NULL
2482
2483             response <- private$REST$http$exec("POST", url, headers, body,
2484                                                queryArgs, private$numRetries)
2485             resource <- private$REST$httpParser$parseJSONResponse(response)
2486
2487             if(!is.null(resource$errors))
2488                 stop(resource$errors)
2489
2490             resource
2491         },
2492
2493         #' @description
2494         #' users_list is a method defined in Arvados class.
2495         #' @param filters
2496         #' @param where
2497         #' @param order
2498         #' @param select
2499         #' @param distinct
2500         #' @param limit
2501         #' @param offset
2502         #' @param count
2503         #' @param clusterID List objects on a remote federated cluster instead of the current one.
2504         #' @param bypassFederation Bypass federation behavior, list items from local instance database only.
2505         users_list = function(filters = NULL, where = NULL,
2506                               order = NULL, select = NULL, distinct = NULL,
2507                               limit = "100", offset = "0", count = "exact",
2508                               clusterID = NULL, bypassFederation = NULL)
2509         {
2510             endPoint <- stringr::str_interp("users")
2511             url <- paste0(private$host, endPoint)
2512             headers <- list(Authorization = paste("Bearer", private$token),
2513                             "Content-Type" = "application/json")
2514             queryArgs <- list(filters = filters, where = where,
2515                               order = order, select = select, distinct = distinct,
2516                               limit = limit, offset = offset, count = count,
2517                               clusterID = clusterID, bypassFederation = bypassFederation)
2518
2519             body <- NULL
2520
2521             response <- private$REST$http$exec("GET", url, headers, body,
2522                                                queryArgs, private$numRetries)
2523             resource <- private$REST$httpParser$parseJSONResponse(response)
2524
2525             if(!is.null(resource$errors))
2526                 stop(resource$errors)
2527
2528             resource
2529         },
2530
2531         #' @description
2532         #' repositories_get is a method defined in Arvados class.
2533         #' @param uuid The UUID of the Repository in question.
2534         repositories_get = function(uuid)
2535         {
2536             endPoint <- stringr::str_interp("repositories/${uuid}")
2537             url <- paste0(private$host, endPoint)
2538             headers <- list(Authorization = paste("Bearer", private$token),
2539                             "Content-Type" = "application/json")
2540             queryArgs <- NULL
2541
2542             body <- NULL
2543
2544             response <- private$REST$http$exec("GET", url, headers, body,
2545                                                queryArgs, private$numRetries)
2546             resource <- private$REST$httpParser$parseJSONResponse(response)
2547
2548             if(!is.null(resource$errors))
2549                 stop(resource$errors)
2550
2551             resource
2552         },
2553
2554         #' @description
2555         #' repositories_create is a method defined in Arvados class.
2556         #' @param repository Repository object.
2557         #' @param ensureUniqueName Adjust name to ensure uniqueness instead of returning an error.
2558         #' @param clusterID Create object on a remote federated cluster instead of the current one.
2559         repositories_create = function(repository,
2560                                        ensureUniqueName = "false", clusterID = NULL)
2561         {
2562             endPoint <- stringr::str_interp("repositories")
2563             url <- paste0(private$host, endPoint)
2564             headers <- list(Authorization = paste("Bearer", private$token),
2565                             "Content-Type" = "application/json")
2566             queryArgs <- list(ensureUniqueName = ensureUniqueName,
2567                               clusterID = clusterID)
2568
2569             if(length(repository) > 0)
2570                 body <- jsonlite::toJSON(list(repository = repository),
2571                                          auto_unbox = TRUE)
2572             else
2573                 body <- NULL
2574
2575             response <- private$REST$http$exec("POST", url, headers, body,
2576                                                queryArgs, private$numRetries)
2577             resource <- private$REST$httpParser$parseJSONResponse(response)
2578
2579             if(!is.null(resource$errors))
2580                 stop(resource$errors)
2581
2582             resource
2583         },
2584
2585         #' @description
2586         #' repositories_update is a method defined in Arvados class.
2587         #' @param repository Repository object.
2588         #' @param uuid The UUID of the Repository in question.
2589         repositories_update = function(repository, uuid)
2590         {
2591             endPoint <- stringr::str_interp("repositories/${uuid}")
2592             url <- paste0(private$host, endPoint)
2593             headers <- list(Authorization = paste("Bearer", private$token),
2594                             "Content-Type" = "application/json")
2595             queryArgs <- NULL
2596
2597             if(length(repository) > 0)
2598                 body <- jsonlite::toJSON(list(repository = repository),
2599                                          auto_unbox = TRUE)
2600             else
2601                 body <- NULL
2602
2603             response <- private$REST$http$exec("PUT", url, headers, body,
2604                                                queryArgs, private$numRetries)
2605             resource <- private$REST$httpParser$parseJSONResponse(response)
2606
2607             if(!is.null(resource$errors))
2608                 stop(resource$errors)
2609
2610             resource
2611         },
2612
2613         #' @description
2614         #' repositories_delete is a method defined in Arvados class.
2615         #' @param uuid The UUID of the Repository in question.
2616         repositories_delete = function(uuid)
2617         {
2618             endPoint <- stringr::str_interp("repositories/${uuid}")
2619             url <- paste0(private$host, endPoint)
2620             headers <- list(Authorization = paste("Bearer", private$token),
2621                             "Content-Type" = "application/json")
2622             queryArgs <- NULL
2623
2624             body <- NULL
2625
2626             response <- private$REST$http$exec("DELETE", url, headers, body,
2627                                                queryArgs, private$numRetries)
2628             resource <- private$REST$httpParser$parseJSONResponse(response)
2629
2630             if(!is.null(resource$errors))
2631                 stop(resource$errors)
2632
2633             resource
2634         },
2635
2636         #' @description
2637         #' repositories_get_all_permissions is a method defined in Arvados class.
2638         repositories_get_all_permissions = function()
2639         {
2640             endPoint <- stringr::str_interp("repositories/get_all_permissions")
2641             url <- paste0(private$host, endPoint)
2642             headers <- list(Authorization = paste("Bearer", private$token),
2643                             "Content-Type" = "application/json")
2644             queryArgs <- NULL
2645
2646             body <- NULL
2647
2648             response <- private$REST$http$exec("GET", url, headers, body,
2649                                                queryArgs, private$numRetries)
2650             resource <- private$REST$httpParser$parseJSONResponse(response)
2651
2652             if(!is.null(resource$errors))
2653                 stop(resource$errors)
2654
2655             resource
2656         },
2657
2658         #' @description
2659         #' repositories_list is a method defined in Arvados class.
2660         #' @param filters
2661         #' @param where
2662         #' @param order
2663         #' @param select
2664         #' @param distinct
2665         #' @param limit
2666         #' @param offset
2667         #' @param count
2668         #' @param clusterID List objects on a remote federated cluster instead of the current one.
2669         #' @param bypassFederation Bypass federation behavior, list items from local instance database only.
2670         repositories_list = function(filters = NULL,
2671                                      where = NULL, order = NULL, select = NULL,
2672                                      distinct = NULL, limit = "100", offset = "0",
2673                                      count = "exact", clusterID = NULL, bypassFederation = NULL)
2674         {
2675             endPoint <- stringr::str_interp("repositories")
2676             url <- paste0(private$host, endPoint)
2677             headers <- list(Authorization = paste("Bearer", private$token),
2678                             "Content-Type" = "application/json")
2679             queryArgs <- list(filters = filters, where = where,
2680                               order = order, select = select, distinct = distinct,
2681                               limit = limit, offset = offset, count = count,
2682                               clusterID = clusterID, bypassFederation = bypassFederation)
2683
2684             body <- NULL
2685
2686             response <- private$REST$http$exec("GET", url, headers, body,
2687                                                queryArgs, private$numRetries)
2688             resource <- private$REST$httpParser$parseJSONResponse(response)
2689
2690             if(!is.null(resource$errors))
2691                 stop(resource$errors)
2692
2693             resource
2694         },
2695
2696         #' @description
2697         #' virtual_machines_get is a method defined in Arvados class.
2698         #' @param uuid The UUID of the virtualMachine in question.
2699         virtual_machines_get = function(uuid)
2700         {
2701             endPoint <- stringr::str_interp("virtual_machines/${uuid}")
2702             url <- paste0(private$host, endPoint)
2703             headers <- list(Authorization = paste("Bearer", private$token),
2704                             "Content-Type" = "application/json")
2705             queryArgs <- NULL
2706
2707             body <- NULL
2708
2709             response <- private$REST$http$exec("GET", url, headers, body,
2710                                                queryArgs, private$numRetries)
2711             resource <- private$REST$httpParser$parseJSONResponse(response)
2712
2713             if(!is.null(resource$errors))
2714                 stop(resource$errors)
2715
2716             resource
2717         },
2718
2719         #' @description
2720         #' virtual_machines_create is a method defined in Arvados class.
2721         #' @param virtualMachine virtualMachine object.
2722         #' @param ensureUniqueName Adjust name to ensure uniqueness instead of returning an error.
2723         #' @param clusterID Create object on a remote federated cluster instead of the current one.
2724         virtual_machines_create = function(virtualMachine,
2725                                            ensureUniqueName = "false", clusterID = NULL)
2726         {
2727             endPoint <- stringr::str_interp("virtual_machines")
2728             url <- paste0(private$host, endPoint)
2729             headers <- list(Authorization = paste("Bearer", private$token),
2730                             "Content-Type" = "application/json")
2731             queryArgs <- list(ensureUniqueName = ensureUniqueName,
2732                               clusterID = clusterID)
2733
2734             if(length(virtualMachine) > 0)
2735                 body <- jsonlite::toJSON(list(virtualMachine = virtualMachine),
2736                                          auto_unbox = TRUE)
2737             else
2738                 body <- NULL
2739
2740             response <- private$REST$http$exec("POST", url, headers, body,
2741                                                queryArgs, private$numRetries)
2742             resource <- private$REST$httpParser$parseJSONResponse(response)
2743
2744             if(!is.null(resource$errors))
2745                 stop(resource$errors)
2746
2747             resource
2748         },
2749
2750         #' @description
2751         #' virtual_machines_update is a method defined in Arvados class.
2752         #' @param virtualMachine virtualMachine object.
2753         #' @param uuid The UUID of the virtualMachine in question.
2754         virtual_machines_update = function(virtualMachine, uuid)
2755         {
2756             endPoint <- stringr::str_interp("virtual_machines/${uuid}")
2757             url <- paste0(private$host, endPoint)
2758             headers <- list(Authorization = paste("Bearer", private$token),
2759                             "Content-Type" = "application/json")
2760             queryArgs <- NULL
2761
2762             if(length(virtualMachine) > 0)
2763                 body <- jsonlite::toJSON(list(virtualMachine = virtualMachine),
2764                                          auto_unbox = TRUE)
2765             else
2766                 body <- NULL
2767
2768             response <- private$REST$http$exec("PUT", url, headers, body,
2769                                                queryArgs, private$numRetries)
2770             resource <- private$REST$httpParser$parseJSONResponse(response)
2771
2772             if(!is.null(resource$errors))
2773                 stop(resource$errors)
2774
2775             resource
2776         },
2777
2778         #' @description
2779         #' virtual_machines_delete is a method defined in Arvados class.
2780         #' @param uuid The UUID of the virtualMachine in question.
2781         virtual_machines_delete = function(uuid)
2782         {
2783             endPoint <- stringr::str_interp("virtual_machines/${uuid}")
2784             url <- paste0(private$host, endPoint)
2785             headers <- list(Authorization = paste("Bearer", private$token),
2786                             "Content-Type" = "application/json")
2787             queryArgs <- NULL
2788
2789             body <- NULL
2790
2791             response <- private$REST$http$exec("DELETE", url, headers, body,
2792                                                queryArgs, private$numRetries)
2793             resource <- private$REST$httpParser$parseJSONResponse(response)
2794
2795             if(!is.null(resource$errors))
2796                 stop(resource$errors)
2797
2798             resource
2799         },
2800
2801         #' @description
2802         #' virtual_machines_logins is a method defined in Arvados class.
2803         #' @param uuid The UUID of the virtualMachine in question.
2804         virtual_machines_logins = function(uuid)
2805         {
2806             endPoint <- stringr::str_interp("virtual_machines/${uuid}/logins")
2807             url <- paste0(private$host, endPoint)
2808             headers <- list(Authorization = paste("Bearer", private$token),
2809                             "Content-Type" = "application/json")
2810             queryArgs <- NULL
2811
2812             body <- NULL
2813
2814             response <- private$REST$http$exec("GET", url, headers, body,
2815                                                queryArgs, private$numRetries)
2816             resource <- private$REST$httpParser$parseJSONResponse(response)
2817
2818             if(!is.null(resource$errors))
2819                 stop(resource$errors)
2820
2821             resource
2822         },
2823
2824         #' @description
2825         #' virtual_machines_get_all_logins is a method defined in Arvados class.
2826         virtual_machines_get_all_logins = function()
2827         {
2828             endPoint <- stringr::str_interp("virtual_machines/get_all_logins")
2829             url <- paste0(private$host, endPoint)
2830             headers <- list(Authorization = paste("Bearer", private$token),
2831                             "Content-Type" = "application/json")
2832             queryArgs <- NULL
2833
2834             body <- NULL
2835
2836             response <- private$REST$http$exec("GET", url, headers, body,
2837                                                queryArgs, private$numRetries)
2838             resource <- private$REST$httpParser$parseJSONResponse(response)
2839
2840             if(!is.null(resource$errors))
2841                 stop(resource$errors)
2842
2843             resource
2844         },
2845
2846         #' @description
2847         #' virtual_machines_list is a method defined in Arvados class.
2848         #' @param filters
2849         #' @param where
2850         #' @param order
2851         #' @param select
2852         #' @param distinct
2853         #' @param limit
2854         #' @param offset
2855         #' @param count
2856         #' @param clusterID List objects on a remote federated cluster instead of the current one.
2857         #' @param bypassFederation bypass federation behavior, list items from local instance database only
2858         virtual_machines_list = function(filters = NULL,
2859                                          where = NULL, order = NULL, select = NULL,
2860                                          distinct = NULL, limit = "100", offset = "0",
2861                                          count = "exact", clusterID = NULL, bypassFederation = NULL)
2862         {
2863             endPoint <- stringr::str_interp("virtual_machines")
2864             url <- paste0(private$host, endPoint)
2865             headers <- list(Authorization = paste("Bearer", private$token),
2866                             "Content-Type" = "application/json")
2867             queryArgs <- list(filters = filters, where = where,
2868                               order = order, select = select, distinct = distinct,
2869                               limit = limit, offset = offset, count = count,
2870                               clusterID = clusterID, bypassFederation = bypassFederation)
2871
2872             body <- NULL
2873
2874             response <- private$REST$http$exec("GET", url, headers, body,
2875                                                queryArgs, private$numRetries)
2876             resource <- private$REST$httpParser$parseJSONResponse(response)
2877
2878             if(!is.null(resource$errors))
2879                 stop(resource$errors)
2880
2881             resource
2882         },
2883
2884         #' @description
2885         #' workflows_get is a method defined in Arvados class.
2886         #' @param uuid The UUID of the Workflow in question.
2887         workflows_get = function(uuid)
2888         {
2889             endPoint <- stringr::str_interp("workflows/${uuid}")
2890             url <- paste0(private$host, endPoint)
2891             headers <- list(Authorization = paste("Bearer", private$token),
2892                             "Content-Type" = "application/json")
2893             queryArgs <- NULL
2894
2895             body <- NULL
2896
2897             response <- private$REST$http$exec("GET", url, headers, body,
2898                                                queryArgs, private$numRetries)
2899             resource <- private$REST$httpParser$parseJSONResponse(response)
2900
2901             if(!is.null(resource$errors))
2902                 stop(resource$errors)
2903
2904             resource
2905         },
2906
2907         #' @description
2908         #' workflows_create is a method defined in Arvados class.
2909         #' @param workflow Workflow object.
2910         #' @param ensureUniqueName Adjust name to ensure uniqueness instead of returning an error.
2911         #' @param clusterID Create object on a remote federated cluster instead of the current one.
2912         workflows_create = function(workflow, ensureUniqueName = "false",
2913                                     clusterID = NULL)
2914         {
2915             endPoint <- stringr::str_interp("workflows")
2916             url <- paste0(private$host, endPoint)
2917             headers <- list(Authorization = paste("Bearer", private$token),
2918                             "Content-Type" = "application/json")
2919             queryArgs <- list(ensureUniqueName = ensureUniqueName,
2920                               clusterID = clusterID)
2921
2922             if(length(workflow) > 0)
2923                 body <- jsonlite::toJSON(list(workflow = workflow),
2924                                          auto_unbox = TRUE)
2925             else
2926                 body <- NULL
2927
2928             response <- private$REST$http$exec("POST", url, headers, body,
2929                                                queryArgs, private$numRetries)
2930             resource <- private$REST$httpParser$parseJSONResponse(response)
2931
2932             if(!is.null(resource$errors))
2933                 stop(resource$errors)
2934
2935             resource
2936         },
2937
2938         #' @description
2939         #' workflows_update is a method defined in Arvados class.
2940         #' @param workflow Workflow object.
2941         #' @param uuid The UUID of the Workflow in question.
2942         workflows_update = function(workflow, uuid)
2943         {
2944             endPoint <- stringr::str_interp("workflows/${uuid}")
2945             url <- paste0(private$host, endPoint)
2946             headers <- list(Authorization = paste("Bearer", private$token),
2947                             "Content-Type" = "application/json")
2948             queryArgs <- NULL
2949
2950             if(length(workflow) > 0)
2951                 body <- jsonlite::toJSON(list(workflow = workflow),
2952                                          auto_unbox = TRUE)
2953             else
2954                 body <- NULL
2955
2956             response <- private$REST$http$exec("PUT", url, headers, body,
2957                                                queryArgs, private$numRetries)
2958             resource <- private$REST$httpParser$parseJSONResponse(response)
2959
2960             if(!is.null(resource$errors))
2961                 stop(resource$errors)
2962
2963             resource
2964         },
2965
2966         #' @description
2967         #' workflows_delete is a method defined in Arvados class.
2968         #' @param uuid The UUID of the Workflow in question.
2969         workflows_delete = function(uuid)
2970         {
2971             endPoint <- stringr::str_interp("workflows/${uuid}")
2972             url <- paste0(private$host, endPoint)
2973             headers <- list(Authorization = paste("Bearer", private$token),
2974                             "Content-Type" = "application/json")
2975             queryArgs <- NULL
2976
2977             body <- NULL
2978
2979             response <- private$REST$http$exec("DELETE", url, headers, body,
2980                                                queryArgs, private$numRetries)
2981             resource <- private$REST$httpParser$parseJSONResponse(response)
2982
2983             if(!is.null(resource$errors))
2984                 stop(resource$errors)
2985
2986             resource
2987         },
2988
2989         #' @description
2990         #' workflows_list is a method defined in Arvados class.
2991         #' @param filters
2992         #' @param where
2993         #' @param order
2994         #' @param select
2995         #' @param distinct
2996         #' @param limit
2997         #' @param offset
2998         #' @param count
2999         #' @param clusterID List objects on a remote federated cluster instead of the current one.
3000         #' @param bypassFederation Bypass federation behavior, list items from local instance database only.
3001         workflows_list = function(filters = NULL,
3002                                   where = NULL, order = NULL, select = NULL,
3003                                   distinct = NULL, limit = "100", offset = "0",
3004                                   count = "exact", clusterID = NULL, bypassFederation = NULL)
3005         {
3006             endPoint <- stringr::str_interp("workflows")
3007             url <- paste0(private$host, endPoint)
3008             headers <- list(Authorization = paste("Bearer", private$token),
3009                             "Content-Type" = "application/json")
3010             queryArgs <- list(filters = filters, where = where,
3011                               order = order, select = select, distinct = distinct,
3012                               limit = limit, offset = offset, count = count,
3013                               clusterID = clusterID, bypassFederation = bypassFederation)
3014
3015             body <- NULL
3016
3017             response <- private$REST$http$exec("GET", url, headers, body,
3018                                                queryArgs, private$numRetries)
3019             resource <- private$REST$httpParser$parseJSONResponse(response)
3020
3021             if(!is.null(resource$errors))
3022                 stop(resource$errors)
3023
3024             resource
3025         },
3026
3027         #' @description
3028         #' user_agreements_get is a method defined in Arvados class.
3029         #' @param uuid The UUID of the userAgreement in question.
3030         user_agreements_get = function(uuid)
3031         {
3032             endPoint <- stringr::str_interp("user_agreements/${uuid}")
3033             url <- paste0(private$host, endPoint)
3034             headers <- list(Authorization = paste("Bearer", private$token),
3035                             "Content-Type" = "application/json")
3036             queryArgs <- NULL
3037
3038             body <- NULL
3039
3040             response <- private$REST$http$exec("GET", url, headers, body,
3041                                                queryArgs, private$numRetries)
3042             resource <- private$REST$httpParser$parseJSONResponse(response)
3043
3044             if(!is.null(resource$errors))
3045                 stop(resource$errors)
3046
3047             resource
3048         },
3049
3050         #' @description
3051         #' user_agreements_create is a method defined in Arvados class.
3052         #' @param userAgreement userAgreement object.
3053         #' @param ensureUniqueName Adjust name to ensure uniqueness instead of returning an error.
3054         #' @param clusterID Create object on a remote federated cluster instead of the current one.
3055         user_agreements_create = function(userAgreement,
3056                                           ensureUniqueName = "false", clusterID = NULL)
3057         {
3058             endPoint <- stringr::str_interp("user_agreements")
3059             url <- paste0(private$host, endPoint)
3060             headers <- list(Authorization = paste("Bearer", private$token),
3061                             "Content-Type" = "application/json")
3062             queryArgs <- list(ensureUniqueName = ensureUniqueName,
3063                               clusterID = clusterID)
3064
3065             if(length(userAgreement) > 0)
3066                 body <- jsonlite::toJSON(list(userAgreement = userAgreement),
3067                                          auto_unbox = TRUE)
3068             else
3069                 body <- NULL
3070
3071             response <- private$REST$http$exec("POST", url, headers, body,
3072                                                queryArgs, private$numRetries)
3073             resource <- private$REST$httpParser$parseJSONResponse(response)
3074
3075             if(!is.null(resource$errors))
3076                 stop(resource$errors)
3077
3078             resource
3079         },
3080
3081         #' @description
3082         #' user_agreements_update is a method defined in Arvados class.
3083         #' @param userAgreement userAgreement object.
3084         #' @param uuid The UUID of the userAgreement in question.
3085         user_agreements_update = function(userAgreement, uuid)
3086         {
3087             endPoint <- stringr::str_interp("user_agreements/${uuid}")
3088             url <- paste0(private$host, endPoint)
3089             headers <- list(Authorization = paste("Bearer", private$token),
3090                             "Content-Type" = "application/json")
3091             queryArgs <- NULL
3092
3093             if(length(userAgreement) > 0)
3094                 body <- jsonlite::toJSON(list(userAgreement = userAgreement),
3095                                          auto_unbox = TRUE)
3096             else
3097                 body <- NULL
3098
3099             response <- private$REST$http$exec("PUT", url, headers, body,
3100                                                queryArgs, private$numRetries)
3101             resource <- private$REST$httpParser$parseJSONResponse(response)
3102
3103             if(!is.null(resource$errors))
3104                 stop(resource$errors)
3105
3106             resource
3107         },
3108
3109         #' @description
3110         #' user_agreements_delete is a method defined in Arvados class.
3111         #' @param uuid The UUID of the userAgreement in question.
3112         user_agreements_delete = function(uuid)
3113         {
3114             endPoint <- stringr::str_interp("user_agreements/${uuid}")
3115             url <- paste0(private$host, endPoint)
3116             headers <- list(Authorization = paste("Bearer", private$token),
3117                             "Content-Type" = "application/json")
3118             queryArgs <- NULL
3119
3120             body <- NULL
3121
3122             response <- private$REST$http$exec("DELETE", url, headers, body,
3123                                                queryArgs, private$numRetries)
3124             resource <- private$REST$httpParser$parseJSONResponse(response)
3125
3126             if(!is.null(resource$errors))
3127                 stop(resource$errors)
3128
3129             resource
3130         },
3131
3132         #' @description
3133         #' user_agreements_signatures is a method defined in Arvados class.
3134         user_agreements_signatures = function()
3135         {
3136             endPoint <- stringr::str_interp("user_agreements/signatures")
3137             url <- paste0(private$host, endPoint)
3138             headers <- list(Authorization = paste("Bearer", private$token),
3139                             "Content-Type" = "application/json")
3140             queryArgs <- NULL
3141
3142             body <- NULL
3143
3144             response <- private$REST$http$exec("GET", url, headers, body,
3145                                                queryArgs, private$numRetries)
3146             resource <- private$REST$httpParser$parseJSONResponse(response)
3147
3148             if(!is.null(resource$errors))
3149                 stop(resource$errors)
3150
3151             resource
3152         },
3153
3154         #' @description
3155         #' user_agreements_sign is a method defined in Arvados class.
3156         user_agreements_sign = function()
3157         {
3158             endPoint <- stringr::str_interp("user_agreements/sign")
3159             url <- paste0(private$host, endPoint)
3160             headers <- list(Authorization = paste("Bearer", private$token),
3161                             "Content-Type" = "application/json")
3162             queryArgs <- NULL
3163
3164             body <- NULL
3165
3166             response <- private$REST$http$exec("POST", url, headers, body,
3167                                                queryArgs, private$numRetries)
3168             resource <- private$REST$httpParser$parseJSONResponse(response)
3169
3170             if(!is.null(resource$errors))
3171                 stop(resource$errors)
3172
3173             resource
3174         },
3175
3176         #' @description
3177         #' user_agreements_list is a method defined in Arvados class.
3178         #' @param filters
3179         #' @param where
3180         #' @param order
3181         #' @param select
3182         #' @param distinct
3183         #' @param limit
3184         #' @param offset
3185         #' @param count
3186         #' @param clusterID List objects on a remote federated cluster instead of the current one.
3187         #' @param bypassFederation Bypass federation behavior, list items from local instance database only.
3188         user_agreements_list = function(filters = NULL,
3189                                         where = NULL, order = NULL, select = NULL,
3190                                         distinct = NULL, limit = "100", offset = "0",
3191                                         count = "exact", clusterID = NULL, bypassFederation = NULL)
3192         {
3193             endPoint <- stringr::str_interp("user_agreements")
3194             url <- paste0(private$host, endPoint)
3195             headers <- list(Authorization = paste("Bearer", private$token),
3196                             "Content-Type" = "application/json")
3197             queryArgs <- list(filters = filters, where = where,
3198                               order = order, select = select, distinct = distinct,
3199                               limit = limit, offset = offset, count = count,
3200                               clusterID = clusterID, bypassFederation = bypassFederation)
3201
3202             body <- NULL
3203
3204             response <- private$REST$http$exec("GET", url, headers, body,
3205                                                queryArgs, private$numRetries)
3206             resource <- private$REST$httpParser$parseJSONResponse(response)
3207
3208             if(!is.null(resource$errors))
3209                 stop(resource$errors)
3210
3211             resource
3212         },
3213
3214         #' @description
3215         #' user_agreements_new is a method defined in Arvados class.
3216         user_agreements_new = function()
3217         {
3218             endPoint <- stringr::str_interp("user_agreements/new")
3219             url <- paste0(private$host, endPoint)
3220             headers <- list(Authorization = paste("Bearer", private$token),
3221                             "Content-Type" = "application/json")
3222             queryArgs <- NULL
3223
3224             body <- NULL
3225
3226             response <- private$REST$http$exec("GET", url, headers, body,
3227                                                queryArgs, private$numRetries)
3228             resource <- private$REST$httpParser$parseJSONResponse(response)
3229
3230             if(!is.null(resource$errors))
3231                 stop(resource$errors)
3232
3233             resource
3234         },
3235
3236         #' @description
3237         #' configs_get is a method defined in Arvados class.
3238         configs_get = function()
3239         {
3240             endPoint <- stringr::str_interp("config")
3241             url <- paste0(private$host, endPoint)
3242             headers <- list(Authorization = paste("Bearer", private$token),
3243                             "Content-Type" = "application/json")
3244             queryArgs <- NULL=
3245
3246                 body <- NULL
3247
3248             response <- private$REST$http$exec("GET", url, headers, body,
3249                                                queryArgs, private$numRetries)
3250             resource <- private$REST$httpParser$parseJSONResponse(response)
3251
3252             if(!is.null(resource$errors))
3253                 stop(resource$errors)
3254
3255             resource
3256         },
3257
3258         getHostName = function() private$host,
3259         getToken = function() private$token,
3260         setRESTService = function(newREST) private$REST <- newREST,
3261         getRESTService = function() private$REST
3262     ),
3263
3264     private = list(
3265
3266         token = NULL,
3267         host = NULL,
3268         REST = NULL,
3269         numRetries = NULL
3270     ),
3271
3272     cloneable = FALSE
3273 )
3274
3275