Metadata-Version: 2.1
Name: temporal-lib-py
Version: 0.1.1
Summary: A wrapper library for candid-based temporal authentication
License: AGPL-3.0
Author: gtato
Author-email: genc.tato@canonical.com
Requires-Python: >=3.8,<4.0
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: macaroonbakery (>=1.3.1,<2.0.0)
Requires-Dist: pycryptodome (>=3.15.0,<4.0.0)
Requires-Dist: temporalio (==0.1b1)
Description-Content-Type: text/markdown

# temporal-lib-py
This library provides a partial wrapper for the *Client.connect* method from [temporalio/sdk-python](https://github.com/temporalio/sdk-python/tree/main/temporalio) by adding candid-based authentication and encryption.


## Building

This library uses [poetry](https://github.com/python-poetry/poetry) for packaging and managing dependencies.
To build the wheel file simply run:
```bash
poetry build -f wheel
```


## Usage

The following code shows how a client connection is created using by using the original (vanilla) temporalio sdk:
```python
from temporalio.client import Client
async def main():
    client = await Client.connect("localhost:7233")
    ...
```
In order to add authorization and encryption capabilities to this client we replace the connect call as following:
```python
from temporallib.connection import Connection, Options
from temporallib.auth import AuthOptions, KeyPair
from temporallib.encryption import EncryptionOptions
async def main():
    # alternatively options could be loaded from a yalm file as the one showed below
    cfg = Options(
        host="localhost:7233",
        auth=AuthOptions(keys=KeyPair(...))
        encryption=EncryptionOptions(key="key")
        ...
    )
    client = await Connection.connect(cfg)
	...
```
The structure of the YAML file which can be used to construct the Options is as following:
```yaml
host: 'localhost:7233'
queue: 'test-queue'
namespace: 'test'
encryption:
  key: 'HLCeMJLLiyLrUOukdThNgRfyraIXZk918rtp5VX/uwI='
auth:
  macaroon_url: 'http://localhost:7888/macaroon'
  username: 'test'
  keys:
    private: 'MTIzNDU2NzgxMjM0NTY3ODEyMzQ1Njc4MTIzNDU2Nzg='
    public: 'ODc2NTQzMjE4NzY1NDMyMTg3NjU0MzIxODc2NTQzMjE='
tls_root_cas: |
  'base64 certificate'
```

## Samples
More examples of workflows using this library can be found here:
- [temporal-lib-samples]( https://github.com/canonical/temporal-lib-samples)

