@@ -47,7 +47,9 @@ Connect <- R6::R6Class(
47
47
initialize = function (server , api_key ) {
48
48
message(glue :: glue(" Defining Connect with server: {server}" ))
49
49
if (is.null(httr :: parse_url(server )$ scheme )) {
50
- stop(glue :: glue(" ERROR: Please provide a protocol (http / https). You gave: {server}" ))
50
+ stop(glue :: glue(
51
+ " ERROR: Please provide a protocol (http / https). You gave: {server}"
52
+ ))
51
53
}
52
54
self $ server <- base :: sub(" ^(.*)/$" , " \\ 1" , server )
53
55
self $ api_key <- api_key
@@ -179,13 +181,22 @@ Connect <- R6::R6Class(
179
181
# ' @param parser How the response is parsed. If `NULL`, the `httr_response`
180
182
# ' will be returned. Otherwise, the argument is forwarded to
181
183
# ' `httr::content(res, as = parser)`.
182
- PUT = function (path ,
183
- body = " {}" ,
184
- ... ,
185
- url = self $ api_url(path ),
186
- encode = " json" ,
187
- parser = " parsed" ) {
188
- self $ request(" PUT" , url , parser = parser , body = body , encode = encode , ... )
184
+ PUT = function (
185
+ path ,
186
+ body = " {}" ,
187
+ ... ,
188
+ url = self $ api_url(path ),
189
+ encode = " json" ,
190
+ parser = " parsed"
191
+ ) {
192
+ self $ request(
193
+ " PUT" ,
194
+ url ,
195
+ parser = parser ,
196
+ body = body ,
197
+ encode = encode ,
198
+ ...
199
+ )
189
200
},
190
201
191
202
# ' @description Perform an HTTP HEAD request of the named API path.
@@ -220,13 +231,22 @@ Connect <- R6::R6Class(
220
231
# ' @param parser How the response is parsed. If `NULL`, the `httr_response`
221
232
# ' will be returned. Otherwise, the argument is forwarded to
222
233
# ' `httr::content(res, as = parser)`.
223
- PATCH = function (path ,
224
- body = " {}" ,
225
- ... ,
226
- url = self $ api_url(path ),
227
- encode = " json" ,
228
- parser = " parsed" ) {
229
- self $ request(" PATCH" , url , parser = parser , body = body , encode = encode , ... )
234
+ PATCH = function (
235
+ path ,
236
+ body = " {}" ,
237
+ ... ,
238
+ url = self $ api_url(path ),
239
+ encode = " json" ,
240
+ parser = " parsed"
241
+ ) {
242
+ self $ request(
243
+ " PATCH" ,
244
+ url ,
245
+ parser = parser ,
246
+ body = body ,
247
+ encode = encode ,
248
+ ...
249
+ )
230
250
},
231
251
232
252
# ' @description Perform an HTTP POST request of the named API path.
@@ -239,13 +259,22 @@ Connect <- R6::R6Class(
239
259
# ' @param parser How the response is parsed. If `NULL`, the `httr_response`
240
260
# ' will be returned. Otherwise, the argument is forwarded to
241
261
# ' `httr::content(res, as = parser)`.
242
- POST = function (path ,
243
- body = " {}" ,
244
- ... ,
245
- url = self $ api_url(path ),
246
- encode = " json" ,
247
- parser = " parsed" ) {
248
- self $ request(" POST" , url , parser = parser , body = body , encode = encode , ... )
262
+ POST = function (
263
+ path ,
264
+ body = " {}" ,
265
+ ... ,
266
+ url = self $ api_url(path ),
267
+ encode = " json" ,
268
+ parser = " parsed"
269
+ ) {
270
+ self $ request(
271
+ " POST" ,
272
+ url ,
273
+ parser = parser ,
274
+ body = body ,
275
+ encode = encode ,
276
+ ...
277
+ )
249
278
},
250
279
251
280
# ' @description Perform an HTTP GET request of the "me" server endpoint.
@@ -363,15 +392,23 @@ Connect <- R6::R6Class(
363
392
# ' @param .collapse How multiple filters are combined.
364
393
# ' @param .limit The limit.
365
394
# ' @param page_size The page size.
366
- get_apps = function (filter = NULL , .collapse = " &" , .limit = Inf , page_size = 25 ) {
395
+ get_apps = function (
396
+ filter = NULL ,
397
+ .collapse = " &" ,
398
+ .limit = Inf ,
399
+ page_size = 25
400
+ ) {
367
401
path <- unversioned_url(" applications" )
368
402
query <- list (
369
403
count = min(page_size , .limit )
370
404
)
371
405
if (! is.null(filter )) {
372
- query $ filter <- paste(sapply(seq_along(filter ), function (i ) {
373
- sprintf(" %s:%s" , names(filter )[i ], filter [[i ]])
374
- }), collapse = .collapse )
406
+ query $ filter <- paste(
407
+ sapply(seq_along(filter ), function (i ) {
408
+ sprintf(" %s:%s" , names(filter )[i ], filter [[i ]])
409
+ }),
410
+ collapse = .collapse
411
+ )
375
412
}
376
413
377
414
prg <- optional_progress_bar(
@@ -453,7 +490,12 @@ Connect <- R6::R6Class(
453
490
# ' @param owner_guid The target content owner.
454
491
# ' @param name The target name.
455
492
# ' @param include Additional response fields.
456
- content = function (guid = NULL , owner_guid = NULL , name = NULL , include = " tags,owner" ) {
493
+ content = function (
494
+ guid = NULL ,
495
+ owner_guid = NULL ,
496
+ name = NULL ,
497
+ include = " tags,owner"
498
+ ) {
457
499
if (! is.null(guid )) {
458
500
return (self $ GET(v1_url(" content" , guid )))
459
501
}
@@ -553,14 +595,16 @@ Connect <- R6::R6Class(
553
595
# ' @param user_must_set_password Indicates that user sets password on first login.
554
596
# ' @param user_role Role for user.
555
597
# ' @param unique_id Identifier for user.
556
- users_create = function (username ,
557
- email ,
558
- first_name = NULL ,
559
- last_name = NULL ,
560
- password = NULL ,
561
- user_must_set_password = NULL ,
562
- user_role = NULL ,
563
- unique_id = NULL ) {
598
+ users_create = function (
599
+ username ,
600
+ email ,
601
+ first_name = NULL ,
602
+ last_name = NULL ,
603
+ password = NULL ,
604
+ user_must_set_password = NULL ,
605
+ user_role = NULL ,
606
+ unique_id = NULL
607
+ ) {
564
608
path <- v1_url(" users" )
565
609
self $ POST(
566
610
path = path ,
@@ -708,14 +752,16 @@ Connect <- R6::R6Class(
708
752
# ' @param previous Previous item.
709
753
# ' @param nxt Next item.
710
754
# ' @param asc_order Indicates ascending result order.
711
- inst_content_visits = function (content_guid = NULL ,
712
- min_data_version = NULL ,
713
- from = NULL ,
714
- to = NULL ,
715
- limit = 500 ,
716
- previous = NULL ,
717
- nxt = NULL ,
718
- asc_order = TRUE ) {
755
+ inst_content_visits = function (
756
+ content_guid = NULL ,
757
+ min_data_version = NULL ,
758
+ from = NULL ,
759
+ to = NULL ,
760
+ limit = 500 ,
761
+ previous = NULL ,
762
+ nxt = NULL ,
763
+ asc_order = TRUE
764
+ ) {
719
765
path <- v1_url(" instrumentation" , " content" , " visits" )
720
766
query <- list (
721
767
content_guid = content_guid ,
@@ -744,14 +790,16 @@ Connect <- R6::R6Class(
744
790
# ' @param previous Previous item.
745
791
# ' @param nxt Next item.
746
792
# ' @param asc_order Indicates ascending result order.
747
- inst_shiny_usage = function (content_guid = NULL ,
748
- min_data_version = NULL ,
749
- from = NULL ,
750
- to = NULL ,
751
- limit = 500 ,
752
- previous = NULL ,
753
- nxt = NULL ,
754
- asc_order = TRUE ) {
793
+ inst_shiny_usage = function (
794
+ content_guid = NULL ,
795
+ min_data_version = NULL ,
796
+ from = NULL ,
797
+ to = NULL ,
798
+ limit = 500 ,
799
+ previous = NULL ,
800
+ nxt = NULL ,
801
+ asc_order = TRUE
802
+ ) {
755
803
path <- v1_url(" instrumentation" , " shiny" , " usage" )
756
804
query <- list (
757
805
content_guid = content_guid ,
@@ -785,7 +833,9 @@ Connect <- R6::R6Class(
785
833
warn_experimental(" repo_account" )
786
834
parsed_url <- httr :: parse_url(host )
787
835
if (is.null(parsed_url $ scheme ) || is.null(parsed_url $ hostname )) {
788
- stop(glue :: glue(" Scheme and hostname must be provided (i.e. 'https://github.com'). You provided '{host}'" ))
836
+ stop(glue :: glue(
837
+ " Scheme and hostname must be provided (i.e. 'https://github.com'). You provided '{host}'"
838
+ ))
789
839
}
790
840
host <- glue :: glue(parsed_url $ scheme , " ://" , parsed_url $ hostname )
791
841
path <- unversioned_url(" repo" , " account" )
@@ -815,7 +865,11 @@ Connect <- R6::R6Class(
815
865
# ' @param start Starting time.
816
866
# ' @param end Ending time.
817
867
# ' @param detailed Indicates detailed schedule information.
818
- schedules = function (start = Sys.time(), end = Sys.time() + 60 * 60 * 24 * 7 , detailed = FALSE ) {
868
+ schedules = function (
869
+ start = Sys.time(),
870
+ end = Sys.time() + 60 * 60 * 24 * 7 ,
871
+ detailed = FALSE
872
+ ) {
819
873
warn_experimental(" schedules" )
820
874
url <- v1_url(" experimental" , " schedules" )
821
875
query_params <- list (
@@ -860,7 +914,12 @@ Connect <- R6::R6Class(
860
914
# ' @param previous Previous item.
861
915
# ' @param nxt Next item.
862
916
# ' @param asc_order Indicates ascending result order.
863
- audit_logs = function (limit = 500 , previous = NULL , nxt = NULL , asc_order = TRUE ) {
917
+ audit_logs = function (
918
+ limit = 500 ,
919
+ previous = NULL ,
920
+ nxt = NULL ,
921
+ asc_order = TRUE
922
+ ) {
864
923
path <- v1_url(" audit_logs" )
865
924
query <- list (
866
925
limit = valid_page_size(limit ),
@@ -880,7 +939,11 @@ Connect <- R6::R6Class(
880
939
881
940
# ' @description Get R installations.
882
941
server_settings_r = function () {
883
- lifecycle :: deprecate_soft(" 0.3.1" , " Connect$server_settings_r()" , " get_runtimes()" )
942
+ lifecycle :: deprecate_soft(
943
+ " 0.3.1" ,
944
+ " Connect$server_settings_r()" ,
945
+ " get_runtimes()"
946
+ )
884
947
self $ GET(v1_url(" server_settings" , " r" ))
885
948
},
886
949
@@ -964,13 +1027,14 @@ Connect <- R6::R6Class(
964
1027
# '
965
1028
# ' @export
966
1029
connect <- function (
967
- server = Sys.getenv(paste0(prefix , " _SERVER" ), NA_character_ ),
968
- api_key = Sys.getenv(paste0(prefix , " _API_KEY" ), NA_character_ ),
969
- token ,
970
- token_local_testing_key = api_key ,
971
- prefix = " CONNECT" ,
972
- ... ,
973
- .check_is_fatal = TRUE ) {
1030
+ server = Sys.getenv(paste0(prefix , " _SERVER" ), NA_character_ ),
1031
+ api_key = Sys.getenv(paste0(prefix , " _API_KEY" ), NA_character_ ),
1032
+ token ,
1033
+ token_local_testing_key = api_key ,
1034
+ prefix = " CONNECT" ,
1035
+ ... ,
1036
+ .check_is_fatal = TRUE
1037
+ ) {
974
1038
if (is.null(api_key ) || is.na(api_key ) || nchar(api_key ) == 0 ) {
975
1039
msg <- " Invalid (empty) API key. Please provide a valid API key"
976
1040
if (.check_is_fatal ) {
0 commit comments