Metadata-Version: 2.1
Name: punkr
Version: 0.1
Summary: Bunkr operations wrapper
Home-page: UNKNOWN
Author: off-the-grid-inc
Author-email: accounts@off-the-grid.io
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown

# Punkr


Punkr (Python Bunkr) is a python wrapper around the RPC server running whithin the Bunkr daemon. It requires the daemon to be running in order to send the Bunkr operations.

#### Punkr class

`Punkr` class is the main structure to use. It can work either in a synchronous or in a asynchronous way. All methods have their own async replica, they can be identified by the `async_*` prefix in the method names.

The available commands are:

* create
* write
* access
* delete
* new-text-secret
* sign-ecdsa


## Examples

```python
if __name__ == "__main__":
    import asyncio
    from punkr import Punkr, PunkrException

    # create a connection to the local Bunkr RPC server
    punkr = Punkr("127.0.0.1", 7860)
    try:
        # create a new text secret (synchronously)
        print(punkr.new_text_secret("MySuperSecret", '"secret created from punkr"'))
        commands = (
            ("access", {"secret_name": "MySuperSecret"}), # This is the structure of a batch command argument
            ("access", {"secret_name": "MySuperSecret"}),
            ("access", {"secret_name": "MySuperSecret"}),
        )
        # create corutine to access the secret (asynchronously, order of results is not guaranteed) 
        async def async_test():
            async for result in punkr.async_batch_commands(*commands):
                print(result)
        # run corutine
        asyncio.run(async_test())
        # run corutine and get the results (order of result is guaranteed, but not ordered of execution)
        results1 = asyncio.run(punkr.async_ordered_batch_commands(*commands))
        print(results1)
        # execute a synchronous batch, ordered of execution and results ir guaranteed
        results2 = punkr.batch_commands(*commands)
        print(results2)
        assert results1 == results2
    except PunkrException as e:
        print(e)
    finally:
        # delete the secret (synchronously)
        punkr.delete("MySuperSecret")
```





Copyright (c) [2019] [Off-the-grid-inc]

