-
Notifications
You must be signed in to change notification settings - Fork 8
Labels
sdkUsed for automationUsed for automation
Description
Related Recipe Issue: https://github.com/rstudio/connect/issues/28826
Current recipe code: https://docs.posit.co/connect/cookbook/content-access-controls/revoking-access-from-a-group/
from posit import connect
#### User-defined inputs ####
# 1. specify the guid for the content item
content_guid = "CONTENT_GUID_HERE"
# 2. specify either the guid or name for the group to be removed (group_name will be used if group_guid is blank)
group_guid = ""
group_name = "GROUP_NAME_HERE"
############################
client = connect.Client()
# search by group_name to find the group_guid if blank
if not group_guid and group_name:
group_match = client.get("/v1/groups", params={"prefix": group_name}).json()
if not group_match["results"]:
raise Exception("Invalid group name")
elif len(group_match["results"]) != 1:
raise Exception("More than one group name found, ensure you enter a unique name")
else:
group_guid = group_match["results"][0]["guid"]
elif not group_name:
raise Exception("Either group_guid or group_name must be specified")
# For the specified content item remove the desired user
for perm in client.content.get(content_guid).permissions.find():
if perm.principal_guid == group_guid:
perm.delete()
# Confirm new permissions
client.content.get(content_guid).permissions.find()Metadata
Metadata
Assignees
Labels
sdkUsed for automationUsed for automation