Metadata-Version: 2.1
Name: authzed
Version: 0.3.0
Summary: Client library for the Authzed service.
Author: Authzed
Author-email: support@authzed.com
Requires-Python: >=3.6,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Dist: async_generator (>=1.10,<2.0)
Requires-Dist: dataclasses (>=0.6); python_version < "3.7"
Requires-Dist: grpcio (==1.34.0)
Requires-Dist: mock (>=4.0.3,<5.0.0)
Requires-Dist: protobuf (>=3.14.0,<4.0.0)
Requires-Dist: protoc-gen-validate (>=0.4.1,<0.5.0)
Requires-Dist: typing-extensions (>=3.7.4,<4.0.0)
Description-Content-Type: text/markdown

# Authzed Python Client

This repository houses the Python client library for Authzed.

The library maintains various versions the Authzed gRPC APIs.
You can find more info on each API on the [Authzed API reference documentation].
Additionally, Protobuf API documentation can be found on the [Buf Registry Authzed API repository].

[Authzed API Reference documentation]: https://docs.authzed.com/reference/api
[Buf Registry Authzed API repository]: https://buf.build/authzed/api/docs/main

Supported API versions:
- v1alpha1
- v0
- arrakisclient (v0 Legacy ORM)

## Installation

```
pip install authzed
```

## Example

Everything API specific is in its respective `authzed.api.VERSION` module.
`grpcutil` contains functionality for making interacting with gRPC simple.

```python
from authzed.api.v1alpha1 import Client, ReadSchemaRequest
from grpcutil import bearer_token_credentials


client = Client("grpc.authzed.com:443", bearer_token_credentials("mytoken"))
resp = client.ReadSchema(ReadSchemaRequest(object_definitions_names=["example/user"]))
print(resp.object_definitions)
```

If an event loop is running when the client is initialized, all functions calls are async:

```python
import asyncio

from authzed.api.v1alpha1 import Client, ReadSchemaRequest
from grpcutil import bearer_token_credentials


async def async_new_client():
    # Within an async context, the client's methods are all async:
    client = Client("grpc.authzed.com:443", bearer_token_credentials("mytoken"))
    resp = await client.ReadSchema(ReadSchemaRequest(object_definitions_names=["example/user"]))
    print(resp)

loop = asyncio.get_event_loop()
try:
    loop.run_until_complete(async_new_client())
finally:
    loop.close()
```

## Full Examples

Full examples for each version of the API can be found in the [examples directory](examples).

