def add_bucket_acl(self, bucket, user, access=None): if not bucket in self.buckets.keys(): raise NotFoundError("Bucket not found") elif not user in self.users.keys(): raise NotFoundError("Bucket not found") else: self.users[user].permissions[bucket] = access
def delete_bucket_acl(self, bucket, user): """ Remove user's permission from a bucket Args: bucket (str): bucket name user (str): user name Returns: None """ if not bucket in self.buckets.keys(): raise NotFoundError("Bucket not found") elif not user in self.users.keys(): raise NotFoundError("Bucket not found") else: self.users[user].permissions[bucket] = []
def delete_user(self, name): """ Removes a user from the list """ if name in self.users.keys(): del self.users[name] else: raise NotFoundError("User doesn't exists")
def has_bucket_access(self, bucket, username): """ Check permissions on a user and a bucket """ try: return bucket in self.users[username].permissions.keys() except KeyError: raise NotFoundError("User not found")
def edit_bucket_template(self, template_id, **kwargs): """ Modifies the template """ if template_id == 1: return None else: raise NotFoundError("Template not found")
def get_bucket(self, name): """ Retrieve a bucket from the list """ try: return self.buckets[name] except KeyError: raise NotFoundError("Bucket not found")
def delete_all_keypairs(self, name): """ Deletes all keypairs from a user """ try: self.users[name].keys = [] except KeyError: raise NotFoundError("The user doesn't exist")