Beispiel #1
0
def create_object_acl_from_default_object_acl(object_name, generation,
                                              default_object_acl, context):
    acl = resources_pb2.ObjectAccessControl()
    acl.CopyFrom(default_object_acl)
    acl.id = hashlib.md5((acl.bucket + object_name + str(generation) +
                          acl.entity + acl.role).encode("utf-8")).hexdigest()
    acl.etag = acl.id
    acl.object = object_name
    acl.generation = generation
    return acl
Beispiel #2
0
def create_default_object_acl(bucket_name, entity, role, context):
    entity = get_canonical_entity(entity)
    if role not in ["OWNER", "READER"]:
        utils.error.invaild("Role %s for object acl" % role, context)
    etag = hashlib.md5(
        (bucket_name + entity + role +
         "storage#objectAccessControl").encode("utf-8")).hexdigest()
    acl = resources_pb2.ObjectAccessControl(
        role=role,
        etag=etag,
        bucket=bucket_name,
        entity=entity,
        entity_id=hashlib.md5(entity.encode("utf-8")).hexdigest(),
        email=__extract_email(entity),
        domain=__extract_domain(entity),
        project_team={
            "project_number": PROJECT_NUMBER,
            "team": __extract_team(entity)
        },
    )
    return acl