Skip to content

Commit

Permalink
Make ACL methods chainable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Sneeringer committed Mar 22, 2017
1 parent 486163e commit 66551ba
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions storage/google/cloud/storage/acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def grant(self, role):
:param role: The role to add to the entity.
"""
self.roles.add(role)
return self

def revoke(self, role):
"""Remove a role from the entity.
Expand All @@ -144,30 +145,31 @@ def revoke(self, role):
"""
if role in self.roles:
self.roles.remove(role)
return self

def grant_read(self):
"""Grant read access to the current entity."""
self.grant(_ACLEntity.READER_ROLE)
return self.grant(_ACLEntity.READER_ROLE)

def grant_write(self):
"""Grant write access to the current entity."""
self.grant(_ACLEntity.WRITER_ROLE)
return self.grant(_ACLEntity.WRITER_ROLE)

def grant_owner(self):
"""Grant owner access to the current entity."""
self.grant(_ACLEntity.OWNER_ROLE)
return self.grant(_ACLEntity.OWNER_ROLE)

def revoke_read(self):
"""Revoke read access from the current entity."""
self.revoke(_ACLEntity.READER_ROLE)
return self.revoke(_ACLEntity.READER_ROLE)

def revoke_write(self):
"""Revoke write access from the current entity."""
self.revoke(_ACLEntity.WRITER_ROLE)
return self.revoke(_ACLEntity.WRITER_ROLE)

def revoke_owner(self):
"""Revoke owner access from the current entity."""
self.revoke(_ACLEntity.OWNER_ROLE)
return self.revoke(_ACLEntity.OWNER_ROLE)


class ACL(object):
Expand Down

0 comments on commit 66551ba

Please sign in to comment.