Skip to content

Latest commit

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

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.

Source code: https://codeberg.org/aedge/spicedb-python

Getting started

Initialize the client:

fromspicedbimportSpiceDB, SpiceRelationshipclient=SpiceDB("https://api.spicedb.example.net/", "API_KEY")

Set up a schema:

awaitclient.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"}
awaitclient.bulk(
create=[
SpiceRelationship(team, "parent", cool_project),
SpiceRelationship(alice, "admin", team),
SpiceRelationship(bob, "member", team),
],
)

Check permissions:

awaitclient.authorize(alice, "edit", cool_project) # => Trueawaitclient.authorize(bob, "edit", cool_project) # => False

List resources:

awaitclient.list(alice, "edit", "project") # => ["cool_project"]

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors