Esempio n. 1
0
 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
Esempio n. 2
0
 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] = []
Esempio n. 3
0
 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")
Esempio n. 4
0
 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")
Esempio n. 5
0
 def edit_bucket_template(self, template_id, **kwargs):
     """
     Modifies the template
     """
     if template_id == 1:
         return None
     else:
         raise NotFoundError("Template not found")
Esempio n. 6
0
 def get_bucket(self, name):
     """
     Retrieve a bucket from the list
     """
     try:
         return self.buckets[name]
     except KeyError:
         raise NotFoundError("Bucket not found")
Esempio n. 7
0
 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")