Metadata-Version: 2.1
Name: spicedb
Version: 0.1.0a2
Summary: An unofficial SpiceDB client for Python.
Home-page: https://spicedb-python.aedge.dev/
Author: Alexander Pushkov
Author-email: ale@aedge.dev
Requires-Python: >=3.12,<4.0
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: AsyncIO
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: httpx (>=0.27.0,<0.28.0)
Project-URL: Repository, https://gitlab.com/aedge/spicedb-python
Description-Content-Type: text/markdown

# 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:

```py
from spicedb import SpiceDB, SpiceRelationship

client = SpiceDB("https://api.spicedb.example.net/", "API_KEY")
```

Set up a schema:

```py
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:

```py
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:

```py
await client.authorize(alice, "edit", cool_project)  # => True
await client.authorize(bob, "edit", cool_project)    # => False
```

List resources:

```py
await client.list(alice, "edit", "project")  # => ["cool_project"]
```

