2021-12-09 21:54:22 +01:00
|
|
|
import asyncio
|
2021-09-19 20:35:34 +02:00
|
|
|
import fabapi
|
2022-04-28 20:57:40 +02:00
|
|
|
import fabapi.user_system
|
2021-12-09 21:54:22 +01:00
|
|
|
|
|
|
|
async def main():
|
2022-03-14 00:04:28 +01:00
|
|
|
session = await fabapi.connect("localhost", 59661, "Testuser", "secret")
|
2022-04-28 20:59:36 +02:00
|
|
|
info = session.machineSystem.info
|
|
|
|
ma = await info.getMachineURN("urn:fabaccess:resource:Another").a_wait()
|
2022-03-14 00:07:32 +01:00
|
|
|
print(ma)
|
2021-12-09 21:54:22 +01:00
|
|
|
|
2022-04-28 20:57:40 +02:00
|
|
|
# Add an user with the given roles
|
|
|
|
roles = [
|
|
|
|
"somerole", "testrole"
|
|
|
|
]
|
|
|
|
user = await fabapi.user_system.add_user(session.userSystem, "ANewUser", "ANewSecret", roles=roles)
|
2022-04-28 20:59:36 +02:00
|
|
|
print("ANewUser obj: ", user)
|
2022-04-28 20:57:40 +02:00
|
|
|
|
|
|
|
# As you can see, Roles were attached
|
2022-04-28 20:59:36 +02:00
|
|
|
r = await user.info.listRoles().a_wait()
|
|
|
|
print("ANewUser roles: ", r)
|
2022-04-28 20:57:40 +02:00
|
|
|
|
|
|
|
# Delete the same user again
|
|
|
|
await fabapi.user_system.del_user(session.userSystem, "ANewUser")
|
|
|
|
|
2021-12-09 21:54:22 +01:00
|
|
|
if __name__ == "__main__":
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
loop.run_until_complete(main())
|