@@ -219,10 +219,14 @@ Content <- R6::R6Class(
219219 self $ connect $ GET(url )
220220 },
221221 # ' @description Add a principal to the ACL for this content.
222- # ' @param principal_guid GUID for the target user or group.
222+ # ' @param principal_guid GUID for the target user or group. When
223+ # ' `principal_type = "user"`, can also be a `connect_user` object.
223224 # ' @param principal_type Acting on user or group.
224225 # ' @param role The kind of content access.
225226 permissions_add = function (principal_guid , principal_type , role ) {
227+ if (principal_type == " user" ) {
228+ principal_guid <- get_user_guid(principal_guid )
229+ }
226230 url <- v1_url(" content" , self $ content $ guid , " permissions" )
227231 self $ connect $ POST(
228232 url ,
@@ -235,10 +239,14 @@ Content <- R6::R6Class(
235239 },
236240 # ' @description Alter a principal in the ACL for this content.
237241 # ' @param id The target identifier.
238- # ' @param principal_guid GUID for the target user or group.
242+ # ' @param principal_guid GUID for the target user or group. When
243+ # ' `principal_type = "user"`, can also be a `connect_user` object.
239244 # ' @param principal_type Acting on user or group.
240245 # ' @param role The kind of content access.
241246 permissions_update = function (id , principal_guid , principal_type , role ) {
247+ if (principal_type == " user" ) {
248+ principal_guid <- get_user_guid(principal_guid )
249+ }
242250 url <- v1_url(" content" , self $ content $ guid , " permissions" , id )
243251 self $ connect $ PUT(
244252 url ,
@@ -954,7 +962,6 @@ set_run_as <- function(content, run_as, run_as_current_user = FALSE) {
954962 return (content )
955963}
956964
957-
958965# ' Delete Content
959966# '
960967# ' Delete a content item. WARNING: This action deletes all history, configuration,
@@ -1007,8 +1014,8 @@ content_delete <- function(content, force = FALSE) {
10071014# ' @param content An R6 content item
10081015# ' @param ... Settings up update that are passed along to Posit Connect
10091016# ' @param access_type One of "all", "logged_in", or "acl"
1010- # ' @param owner_guid The GUID of a user who is a publisher, so that they can
1011- # ' become the new owner of the content
1017+ # ' @param owner The GUID of a user who is a publisher, so that they can
1018+ # ' become the new owner of the content. Can also be a `connect_user` object.
10121019# '
10131020# ' @return An R6 content item
10141021# '
@@ -1040,7 +1047,8 @@ content_update_access_type <- function(
10401047
10411048# ' @rdname content_update
10421049# ' @export
1043- content_update_owner <- function (content , owner_guid ) {
1050+ content_update_owner <- function (content , owner ) {
1051+ owner_guid <- get_user_guid(owner )
10441052 content_update(content = content , owner_guid = owner_guid )
10451053}
10461054
@@ -1103,7 +1111,6 @@ unlock_content <- function(content) {
11031111 return (content )
11041112}
11051113
1106-
11071114# ' Verify Content Name
11081115# '
11091116# ' Ensures that a content name fits the specifications / requirements of Posit
@@ -1178,7 +1185,6 @@ delete_bundle <- function(content, bundle_id) {
11781185 return (content )
11791186}
11801187
1181-
11821188# ' Content permissions
11831189# '
11841190# ' Get or set content permissions for a content item
@@ -1199,8 +1205,12 @@ delete_bundle <- function(content, bundle_id) {
11991205# ' This makes it easier to find / isolate this record.
12001206# '
12011207# ' @param content An R6 content object
1202- # ' @param guid The guid associated with either a user (for `content_add_user`) or group (for `content_add_group`)
1203- # ' @param role The role to assign to a user. Either "viewer" or "owner." Defaults to "viewer"
1208+ # ' @param user The guid associated with either a user (for `content_add_user`)
1209+ # ' or group (for `content_add_group`). Can also be a list of `connect_user`
1210+ # ' objects.
1211+ # ' @param guid The guid associated with a group.
1212+ # ' @param role The role to assign to a user. Either "viewer" or "owner."
1213+ # ' Defaults to "viewer"
12041214# ' @param add_owner Optional. Whether to include the owner in returned
12051215# ' permission sets. Default is TRUE. The owner will have an NA_character_
12061216# ' permission "id"
@@ -1209,10 +1219,11 @@ delete_bundle <- function(content, bundle_id) {
12091219# ' @rdname permissions
12101220# ' @family content functions
12111221# ' @export
1212- content_add_user <- function (content , guid , role = c(" viewer" , " owner" )) {
1222+ content_add_user <- function (content , user , role = c(" viewer" , " owner" )) {
12131223 validate_R6_class(content , " Content" )
12141224 role <- .define_role(role )
12151225
1226+ guid <- purrr :: map_chr(user , get_user_guid )
12161227 purrr :: map(guid , ~ .content_add_permission_impl(content , " user" , .x , role ))
12171228
12181229 return (content )
@@ -1278,8 +1289,9 @@ content_add_group <- function(content, guid, role = c("viewer", "owner")) {
12781289
12791290# ' @rdname permissions
12801291# ' @export
1281- content_delete_user <- function (content , guid ) {
1292+ content_delete_user <- function (content , user ) {
12821293 validate_R6_class(content , " Content" )
1294+ guid <- purrr :: map_chr(user , get_user_guid )
12831295 purrr :: map(
12841296 guid ,
12851297 ~ .content_delete_permission_impl(
@@ -1331,8 +1343,9 @@ content_delete_group <- function(content, guid) {
13311343
13321344# ' @rdname permissions
13331345# ' @export
1334- get_user_permission <- function (content , guid , add_owner = TRUE ) {
1346+ get_user_permission <- function (content , user , add_owner = TRUE ) {
13351347 validate_R6_class(content , " Content" )
1348+ guid <- get_user_guid(user )
13361349 res <- .get_permission(content , " user" , guid , add_owner = add_owner )
13371350 if (length(res ) > 0 ) {
13381351 return (res [[1 ]])
@@ -1361,7 +1374,6 @@ get_group_permission <- function(content, guid) {
13611374 }
13621375}
13631376
1364-
13651377# ' @rdname permissions
13661378# ' @export
13671379get_content_permissions <- function (content , add_owner = TRUE ) {
0 commit comments