@@ -45,7 +45,11 @@ Content <- R6::R6Class(
45
45
# ' @param bundle_id The bundle identifer.
46
46
# ' @param filename Where to write the result.
47
47
# ' @param overwrite Overwrite an existing filename.
48
- bundle_download = function (bundle_id , filename = tempfile(pattern = " bundle" , fileext = " .tar.gz" ), overwrite = FALSE ) {
48
+ bundle_download = function (
49
+ bundle_id ,
50
+ filename = tempfile(pattern = " bundle" , fileext = " .tar.gz" ),
51
+ overwrite = FALSE
52
+ ) {
49
53
url <- v1_url(" content" , self $ get_content()$ guid , " bundles" , bundle_id , " download" )
50
54
self $ get_connect()$ GET(url , httr :: write_disk(filename , overwrite = overwrite ), parser = " raw" )
51
55
return (filename )
@@ -285,7 +289,7 @@ Content <- R6::R6Class(
285
289
is_rendered = function () {
286
290
self $ content $ app_mode %in% c(" rmd-static" , " jupyter-static" , " quarto-static" )
287
291
},
288
-
292
+
289
293
# ' @field is_interactive TRUE if this is a rendered content type, otherwise FALSE.
290
294
is_interactive = function () {
291
295
interactive_app_modes <- c(
@@ -513,7 +517,14 @@ content_title <- function(connect, guid, default = "Unknown Content") {
513
517
}
514
518
515
519
# ' @importFrom uuid UUIDgenerate
516
- content_ensure <- function (connect , name = uuid :: UUIDgenerate(), title = name , guid = NULL , ... , .permitted = c(" new" , " existing" )) {
520
+ content_ensure <- function (
521
+ connect ,
522
+ name = uuid :: UUIDgenerate(),
523
+ title = name ,
524
+ guid = NULL ,
525
+ ... ,
526
+ .permitted = c(" new" , " existing" )
527
+ ) {
517
528
if (! is.null(guid )) {
518
529
# guid-based deployment
519
530
# just in case we get a 404 back...
@@ -577,7 +588,7 @@ content_ensure <- function(connect, name = uuid::UUIDgenerate(), title = name, g
577
588
578
589
# ' Get Jobs
579
590
# '
580
- # ' \ lifecycle{ experimental} Retrieve details about jobs associated with a `content_item`.
591
+ # ' `r lifecycle::badge(' experimental')` Retrieve details about jobs associated with a `content_item`.
581
592
# ' "Jobs" in Posit Connect are content executions
582
593
# '
583
594
# ' @param content A Content object, as returned by `content_item()`
@@ -708,7 +719,7 @@ content_delete <- function(content, force = FALSE) {
708
719
content_update <- function (content , ... ) {
709
720
validate_R6_class(content , " Content" )
710
721
711
- res <- content $ update(... )
722
+ content $ update(... )
712
723
713
724
content $ get_content_remote()
714
725
@@ -747,7 +758,10 @@ content_update_owner <- function(content, owner_guid) {
747
758
# ' @export
748
759
verify_content_name <- function (name ) {
749
760
if (grepl(" [^\\ -\\ _a-zA-Z0-9]" , name , perl = TRUE ) || nchar(name ) < 3 || nchar(name ) > 64 ) {
750
- stop(glue :: glue(" ERROR: content name '{name}' must be between 3 and 64 alphanumeric characters, dashes, and underscores" ))
761
+ stop(glue :: glue(
762
+ " ERROR: content name '{name}' must be between 3 and 64 alphanumeric characters, " ,
763
+ " dashes, and underscores"
764
+ ))
751
765
}
752
766
return (name )
753
767
}
@@ -831,7 +845,7 @@ content_add_user <- function(content, guid, role = c("viewer", "owner")) {
831
845
validate_R6_class(content , " Content" )
832
846
role <- .define_role(role )
833
847
834
- res <- purrr :: map(guid , ~ .content_add_permission_impl(content , " user" , .x , role ))
848
+ purrr :: map(guid , ~ .content_add_permission_impl(content , " user" , .x , role ))
835
849
836
850
return (content )
837
851
}
@@ -840,10 +854,9 @@ content_add_user <- function(content, guid, role = c("viewer", "owner")) {
840
854
# ' @export
841
855
content_add_group <- function (content , guid , role = c(" viewer" , " owner" )) {
842
856
validate_R6_class(content , " Content" )
843
- existing <- .get_permission(content , " group" , guid )
844
857
role <- .define_role(role )
845
858
846
- res <- purrr :: map(guid , ~ .content_add_permission_impl(content = content , type = " group" , guid = .x , role = role ))
859
+ purrr :: map(guid , ~ .content_add_permission_impl(content = content , type = " group" , guid = .x , role = role ))
847
860
848
861
return (content )
849
862
}
@@ -885,15 +898,15 @@ content_add_group <- function(content, guid, role = c("viewer", "owner")) {
885
898
# ' @export
886
899
content_delete_user <- function (content , guid ) {
887
900
validate_R6_class(content , " Content" )
888
- res <- purrr :: map(guid , ~ .content_delete_permission_impl(content = content , type = " user" , guid = .x ))
901
+ purrr :: map(guid , ~ .content_delete_permission_impl(content = content , type = " user" , guid = .x ))
889
902
return (content )
890
903
}
891
904
892
905
# ' @rdname permissions
893
906
# ' @export
894
907
content_delete_group <- function (content , guid ) {
895
908
validate_R6_class(content , " Content" )
896
- res <- purrr :: map(guid , ~ .content_delete_permission_impl(content = content , type = " group" , guid = .x ))
909
+ purrr :: map(guid , ~ .content_delete_permission_impl(content = content , type = " group" , guid = .x ))
897
910
return (content )
898
911
}
899
912
@@ -957,33 +970,36 @@ get_content_permissions <- function(content, add_owner = TRUE) {
957
970
}
958
971
959
972
# ' Render a content item.
960
- # '
973
+ # '
961
974
# ' @description Submit a request to render a content item. Once submitted, the
962
975
# ' server runs an asynchronous process to render the content. This might be
963
976
# ' useful if content needs to be updated after its source data has changed,
964
977
# ' especially if this doesn't happen on a regular schedule.
965
- # '
978
+ # '
966
979
# ' Only valid for rendered content (e.g., most Quarto documents, Jupyter
967
980
# ' notebooks, R Markdown reports).
968
- # '
981
+ # '
969
982
# ' @param content The content item you wish to render.
970
983
# ' @param variant_key If a variant key is provided, render that variant. Otherwise, render the default variant.
971
984
# ' @return A [VariantTask] object that can be used to track completion of the render.
972
- # '
985
+ # '
973
986
# ' @examples
974
987
# ' \dontrun{
975
988
# ' client <- connect()
976
989
# ' item <- content_item(client, "951bf3ad-82d0-4bca-bba8-9b27e35c49fa")
977
990
# ' task <- content_render(item)
978
991
# ' poll_task(task)
979
992
# ' }
980
- # '
993
+ # '
981
994
# ' @export
982
995
content_render <- function (content , variant_key = NULL ) {
983
996
scoped_experimental_silence()
984
997
validate_R6_class(content , " Content" )
985
998
if (! content $ is_rendered ) {
986
- stop(glue :: glue(" Render not supported for application mode: {content$content$app_mode}. Did you mean content_restart()?" ))
999
+ stop(glue :: glue(
1000
+ " Render not supported for application mode: {content$content$app_mode}. " ,
1001
+ " Did you mean content_restart()?"
1002
+ ))
987
1003
}
988
1004
if (is.null(variant_key )) {
989
1005
target_variant <- get_variant(content , " default" )
@@ -992,42 +1008,52 @@ content_render <- function(content, variant_key = NULL) {
992
1008
}
993
1009
render_task <- target_variant $ render()
994
1010
995
- VariantTask $ new(connect = content $ connect , content = content $ content , key = target_variant $ key , task = render_task )
1011
+ VariantTask $ new(
1012
+ connect = content $ connect ,
1013
+ content = content $ content ,
1014
+ key = target_variant $ key ,
1015
+ task = render_task
1016
+ )
996
1017
}
997
1018
998
1019
# ' Restart a content item.
999
- # '
1020
+ # '
1000
1021
# ' @description Submit a request to restart a content item. Once submitted, the
1001
1022
# ' server performs an asynchronous request to kill all processes associated with
1002
1023
# ' the content item, starting new processes as needed. This might be useful if
1003
1024
# ' the application relies on data that is loaded at startup, or if its memory
1004
1025
# ' usage has grown over time.
1005
- # '
1026
+ # '
1006
1027
# ' Note that users interacting with certain types of applications may have their
1007
1028
# ' workflows interrupted.
1008
- # '
1029
+ # '
1009
1030
# ' Only valid for interactive content (e.g., applications, APIs).
1010
- # '
1031
+ # '
1011
1032
# ' @param content The content item you wish to restart.
1012
- # '
1033
+ # '
1013
1034
# ' @examples
1014
1035
# ' \dontrun{
1015
1036
# ' client <- connect()
1016
1037
# ' item <- content_item(client, "8f37d6e0-3395-4a2c-aa6a-d7f2fe1babd0")
1017
1038
# ' content_restart(item)
1018
1039
# ' }
1019
- # '
1040
+ # '
1020
1041
# ' @importFrom rlang :=
1021
1042
# ' @export
1022
1043
content_restart <- function (content ) {
1023
1044
validate_R6_class(content , " Content" )
1024
1045
if (! content $ is_interactive ) {
1025
- stop(glue :: glue(" Restart not supported for application mode: {content$content$app_mode}. Did you mean content_render()?" ))
1046
+ stop(glue :: glue(
1047
+ " Restart not supported for application mode: {content$content$app_mode}. " ,
1048
+ " Did you mean content_render()?"
1049
+ ))
1026
1050
}
1027
1051
unix_epoch_in_seconds <- as.integer(Sys.time())
1028
- env_var_name <- glue :: glue( " _CONNECT_RESTART_{unix_epoch_in_seconds} " )
1052
+ # nolint start: object_usage_linter, object_name_linter
1029
1053
# https://rlang.r-lib.org/reference/glue-operators.html#using-glue-syntax-in-packages
1054
+ env_var_name <- glue :: glue(" _CONNECT_RESTART_{unix_epoch_in_seconds}" )
1030
1055
content $ environment_set(" {env_var_name}" : = unix_epoch_in_seconds )
1031
1056
content $ environment_set(" {env_var_name}" : = NA )
1057
+ # nolint end
1032
1058
invisible (NULL )
1033
1059
}
0 commit comments