Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to remove all viewers and collaborators from a piece of content #93

Closed
jonkeane opened this issue Mar 14, 2024 · 3 comments
Closed

Comments

@jonkeane
Copy link
Collaborator

Some folks would like a quick and easy way to revoke access to a piece of content. This can be accomplished today with the API one by one (though not yet with the SDK IIUC). But it would be nice to make a wrapper that encapsulates this functionality so someone can remove all of the users + viewers with one SDK call. We might add an API for this bulk action, but we can implement this SDK side before and see if it works for folks.

A possible sketch (though not a mandate):

from posit.connect import Client

con = Client()
content_to_clean = con.content.get(id = "...")
content_to_clean.remove_shares(viewers = True, collaborators = True) # I'm assuming these would actually both be True by default, but for clarity have them listed here.

We've had requests for this in the Connect UI as well

@nealrichardson
Copy link
Collaborator

Following #101, this would be something like:

for perm in con.content.get(id).permissions.find():
    if perm.role == "viewer":
        perm.delete()

You could wrap that in a function, but it might also be better suited as a cookbook recipe.

@tdstein
Copy link
Collaborator

tdstein commented Apr 3, 2024

@jonkeane - this is now possible via the snippet @nealrichardson provided above.

@nealrichardson
Copy link
Collaborator

I filed posit-dev/connect-cookbook#5 in case we want to make a recipe for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants