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.0a2.tar.gz
(8.1 kB
view details)
Built Distribution
File details
Details for the file spicedb-0.1.0a2.tar.gz
.
File metadata
- Download URL: spicedb-0.1.0a2.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.8.10-400.asahi.fc39.aarch64+16k
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7a116cdace39bc79c11b938099607d6fa4e23784ada02b6f480856505a961d8 |
|
MD5 | 3a11ebde299192434a6adae819793053 |
|
BLAKE2b-256 | 463455fd8153805d83f7a85c49e8fb76acb73b1cdaf8fc6a98aff9c45f4cb5e4 |
File details
Details for the file spicedb-0.1.0a2-py3-none-any.whl
.
File metadata
- Download URL: spicedb-0.1.0a2-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.8.10-400.asahi.fc39.aarch64+16k
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd53dfa3831674a0310e8da840b56b61e9ae90b6f9b6e85aaa0886525d4455eb |
|
MD5 | 093314b7fcfff61d7fb5161084bd1073 |
|
BLAKE2b-256 | de275a51d0de947ad3dd3df88d054e9d1c75b8361257c3cf4f32533cb89acb49 |