def insert_default_object_acl(self, entity, role): """Insert (or update) a new default ObjectAccessControl entry for this bucket. :param entity:str the name of the entity to insert. :param role:str the new role :return: the dictionary representing the new ObjectAccessControl. :rtype: dict """ entity = testbench_utils.canonical_entity_name(entity) email = '' if entity.startswith('user-'): email = email.replace('user-', '', 1) # Replace or insert the entry. indexed = testbench_utils.index_acl(self.metadata.get('defaultObjectAcl', [])) indexed[entity] = { 'bucket': self.name, 'email': email, 'entity': entity, 'etag': self.metadata.get('etag', 'XYZ='), 'id': self.metadata.get('id', '') + '/' + entity, 'kind': 'storage#objectAccessControl', 'role': role, 'selfLink': self.metadata.get('selfLink') + '/acl/' + entity } self.metadata['defaultObjectAcl'] = indexed.values() return indexed[entity]
def insert_acl(self, entity, role): """Insert (or update) a new AccessControl entry for this object. :param entity:str the name of the entity to insert. :param role:str the new role :return: the dictionary representing the new AccessControl metadata. :rtype:dict """ entity = testbench_utils.canonical_entity_name(entity) email = "" if entity.startswith("user-"): email = entity # Replace or insert the entry. indexed = testbench_utils.index_acl(self.metadata.get("acl", [])) indexed[entity] = { "bucket": self.bucket_name, "email": email, "entity": entity, "entity_id": "", "etag": self.metadata.get("etag", "XYZ="), "generation": str(self.generation), "id": self.metadata.get("id", "") + "/" + entity, "kind": "storage#objectAccessControl", "object": self.name, "role": role, "selfLink": self.metadata.get("selfLink") + "/acl/" + entity, } self.metadata["acl"] = list(indexed.values()) return indexed[entity]
def delete_default_object_acl(self, entity): """Delete a single default ObjectAccessControl entry from this bucket. :param entity:str the name of the entity. :rtype:NoneType """ entity = testbench_utils.canonical_entity_name(entity) indexed = testbench_utils.index_acl(self.metadata.get('defaultObjectAcl', [])) indexed.pop(entity) self.metadata['defaultObjectAcl'] = indexed.values()
def delete_acl(self, entity): """Delete a single AccessControl entry from the Object revision. :param entity:str the name of the entity. :rtype:NoneType """ entity = testbench_utils.canonical_entity_name(entity) indexed = testbench_utils.index_acl(self.metadata.get('acl', [])) indexed.pop(entity) self.metadata['acl'] = indexed.values()
def delete_acl(self, entity): """ Delete a single BucketAccessControl entry from this bucket. :param entity:str the name of the entity. :rtype:NoneType """ entity = testbench_utils.canonical_entity_name(entity) indexed = testbench_utils.index_acl(self.metadata.get("acl", [])) indexed.pop(entity) self.metadata["acl"] = list(indexed.values())
def insert_acl(self, entity, role): """Insert (or update) a new BucketAccessControl entry for this bucket. :param entity:str the name of the entity to insert. :param role:str the new role :return: the dictionary representing the new AccessControl metadata. :rtype: dict """ entity, entry = self.create_acl_entry(entity, role) # Replace or insert the entry. indexed = testbench_utils.index_acl(self.metadata.get('acl', [])) indexed[entity] = entry self.metadata['acl'] = indexed.values() return entry