Exemplo n.º 1
0
async def domain_api_demo(key):
    print("Connecting to FlureeDB")
    async with aioflureedb.FlureeClient(port=8090) as flureeclient:
        print("Waiting till Fluree is ready")
        await flureeclient.health.ready()
        print("Looking up database")
        db = await flureeclient["dla/base"]
    print("Opening database")
    async with db(key) as database:
        print("Instantiating domain API")
        domain_api = aioflureedb.FlureeDomainAPI("./api_maps", database)
        print("Selecting role")
        role = domain_api.get_api_by_role("demo_role")
        print("Create transaction")
        trans1 = role.create_demo_user_role()
        print("Execute", type(trans1))
        await trans1()
        print("Create transaction")
        trans2 = role.create_demo_user(
            full_name="John Doe IV",
            email="*****@*****.**",
            pubkey="TfB5z166pcmReVA3sfEqisjgv7pX2gefff4")
        print("Execute")
        await trans2()
        print("Create transaction")
        trans3 = role.create_demo_user(
            full_name="Jane Doe IV",
            email="*****@*****.**",
            pubkey="TfB5z166pcmReVA3sfEqisjgv7pX2ge0004")
        print("Execute")
        await trans3()
        print("Run query")
        response = await role.get_demo_users()
        print(response)
Exemplo n.º 2
0
async def sql_demo():
    print("Connecting to FlureeDB")
    async with aioflureedb.FlureeClient(port=8090) as flureeclient:
        print("Waiting till Fluree is ready")
        await flureeclient.health.ready()
        state = await flureeclient.nw_state()
        print(state)
        version = await flureeclient.version()
        print(version)
Exemplo n.º 3
0
async def history_demo():
    async with aioflureedb.FlureeClient(port=8090) as flureeclient:
        await flureeclient.health.ready()
        db = await flureeclient["dla/base"]
    async with db() as database:
        result = await database.reindex.query()
        print(result)
        result = await database.history.query(
            history=["_role/id", "oidc_user"], showAuth=True)
        print(result)
Exemplo n.º 4
0
async def sql_demo():
    print("Connecting to FlureeDB")
    async with aioflureedb.FlureeClient(port=8090) as flureeclient:
        print("Waiting till Fluree is ready")
        await flureeclient.health.ready()
        print("Looking up database")
        db = await flureeclient["dla/base"]
    print("Opening database")
    async with db() as database:
        print("SparQl query")
        result = await database.sparql(
            'SELECT ?name WHERE { ?predicate fd:_predicate/type "ref". ?predicate fd:_predicate/multi true. ?predicate fd:_predicate/name ?name}'
        )
        print(result)
Exemplo n.º 5
0
async def domain_api_demo():
    print("Connecting to FlureeDB")
    async with aioflureedb.FlureeClient(port=8090) as flureeclient:
        print("Waiting till Fluree is ready")
        await flureeclient.health.ready()
        print("Looking up database")
        db = await flureeclient["dla/base"]
    print("Opening database")
    async with db() as database:
        print("Instantiating domain API")
        domain_api = aioflureedb.FlureeDomainAPI("./api_maps.json", database)
        role = domain_api.get_api_by_role("demo_role")
        print("Testing demo query")
        result = await role.roles_and_predicates()
        print(result)
Exemplo n.º 6
0
async def blocks_demo():
    print("Connecting to FlureeDB")
    async with aioflureedb.FlureeClient(port=8090) as flureeclient:
        print("Waiting till Fluree is ready")
        await flureeclient.health.ready()
        print("Looking up database")
        db = await flureeclient["dla/latestforprod"]
    print("Opening database")
    async with db() as database:
        print("Initializing monitor")
        database.monitor_init(blockmon, start_block=0, rewind=720000)
        database.monitor_register_create("_role", new_user)
        database.monitor_register_delete("_role", dropped_user)
        database.monitor_register_update("_role", updated_user)
        database.monitor_instant("journal/timestamp", journal_entry, 0)
        print("Running Monitor")
        await database.monitor_untill_stopped()
Exemplo n.º 7
0
async def fluree_demo(privkey, addr):
    print(privkey)
    print(addr)
    async with aioflureedb.FlureeClient(privkey, addr, port=8090) as flureeclient:
        print("AWAIT Ready")
        await flureeclient.health.ready()
        print("READY")
        print(await flureeclient.dbs())
        print("ENDPOINTS:", dir(flureeclient))
        print("HEALTH:", await flureeclient.health())
        print("########################################")
        print("NEWKEYS", await flureeclient.new_keys())
        print("########################################")
        new_db = await flureeclient.new_db(db_id="dev/test24")
        print("NEWDB", new_db)
        # Not working yet, need to look into del_db
        #   del_db = await flureeclient.delete_db(db_id="dev/test14")
        #   print("DELDB:", del_db)
        print("########################################")
        async for network in flureeclient:
            print("### NET:",network)
            for db in network:
                print("   -", db)
        db = await flureeclient["dla/dla"]
        # print("Network OK")
        # db = network["dla"]
        print("DB OK")
    async with db(privkey, addr) as database:
        print("Database client created")
        print("ENDPOINTS:", dir(database))
        randomuser = "******" + str(int(time.time()) % 10000)
        print("Creating user:"******"################################")
        transaction = await database.command.transaction([{"_id":"_user","username": randomuser}])
        print("================================")
        print("OK: Transaction completed,", transaction)
        try:
            result = await database.flureeql.query(
                select=["*"],
                ffrom="_user"
            )
            print("Query succeeded, user count =", len(result))
        except Exception as exp:
            print("OOPS: ", exp)
Exemplo n.º 8
0
async def fluree_demo(privkey):
    print(privkey)
    async with aioflureedb.FlureeClient(privkey, port=8090) as flureeclient:
        print("AWAIT Ready")
        await flureeclient.health.ready()
        print("READY")
        print(await flureeclient.dbs())
        print("ENDPOINTS:", dir(flureeclient))
        print("HEALTH:", await flureeclient.health())
        print("########################################")
        print("NEWKEYS", await flureeclient.new_keys())
        print("########################################")
        new_db = await flureeclient.new_db(db_id="dev/test50")
        print("NEWDB", new_db)
        # Not working yet, need to look into del_db
        #   del_db = await flureeclient.delete_db(db_id="dev/test14")
        #   print("DELDB:", del_db)
        print("########################################")
        async for network in flureeclient:
            print("### NET:", network)
            for db in network:
                print("   -", db)
        db = await flureeclient["dev/test50"]
        async with db() as database:
            await asyncio.sleep(10)
            res = await database.flureeql.query(select=["name"],
                                                ffrom="_predicate")
            print("RES1:", json.dumps(res))
            print("Creating multiquery")
            mq = database.multi_query()
            print(type(mq))
            print("Expanding multi-query")
            mq.predicates(select=["name"], ffrom="_predicate")
            print("Expanding multi-query")
            mq.collections(select=["name"], ffrom="_collection")
            print("Calling multi-query")
            result = await mq.query()
            print(result)
Exemplo n.º 9
0
async def blocks_demo(triggermap):
    async with aioflureedb.FlureeClient(port=8090) as flureeclient:
        await flureeclient.health.ready()
        db = await flureeclient["dla/base"]
    async with db() as database:
        await run_monitor(database, triggermap)