An unofficial SpiceDB client for Python.
Project description
spicedb-python
An unofficial SpiceDB client for Python.
pip install spicedb
Note that this is a very unstable package and the API is subject to change.
Getting started
Initialize the client:
from spicedb import SpiceDB, SpiceRelationship
client = SpiceDB("https://api.spicedb.example.net/", "API_KEY")
Set up a schema:
await client.write_schema("""
definition user {}
definition team {
relation admin: user
relation member: user
}
definition project {
relation parent: team
permission view = parent->member
permission edit = parent->admin
}
""")
Create some relationships:
alice = {"type": "user", "id": "alice"}
bob = {"type": "user", "id": "bob"}
team = {"type": "team", "id": "acme-co"}
cool_project = {"type": "project", "id": "cool_project"}
await client.bulk(
create=[
SpiceRelationship(team, "parent", cool_project),
SpiceRelationship(alice, "admin", team),
SpiceRelationship(bob, "member", team),
],
)
Check permissions:
await client.authorize(alice, "edit", cool_project) # => True
await client.authorize(bob, "edit", cool_project) # => False
List resources:
await client.list(alice, "edit", "project") # => ["cool_project"]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
spicedb-0.1.0a1.tar.gz
(8.0 kB
view hashes)
Built Distribution
Close
Hashes for spicedb-0.1.0a1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c9c9a035ad902fa800b0d32d5c72f6ea76aacf41a4b644c51d0e05b5d591043 |
|
MD5 | a5f03b6f34d66330b0da4aaf8a1aa859 |
|
BLAKE2b-256 | bae2988061990d5b8947648499c7b707148d53ee320a35c045d61f4863727d6c |