Metadata-Version: 2.1
Name: disruptive
Version: 0.2.3
Summary: Disruptive Technologies Python API.
Home-page: https://github.com/disruptive-technologies/disruptive-python
Author: Disruptive Technologies Research AS
Author-email: developer-support@disruptive-technologies.com
License: UNKNOWN
Project-URL: Documentation, https://developer.disruptive-technologies.com/api/libraries/python/
Project-URL: Developers Page, https://developer.disruptive-technologies.com/docs/
Keywords: disruptive,technologies,dt,rest,api
Platform: UNKNOWN
Classifier: Natural Language :: English
Classifier: License :: OSI Approved :: MIT License
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: requests (<3.0.0,>=2.19.0)
Requires-Dist: pyjwt (<3.0.0,>=2.0.0)
Provides-Extra: dev
Requires-Dist: setuptools (>=54.2.0) ; extra == 'dev'
Requires-Dist: wheel (>=0.36.2) ; extra == 'dev'
Requires-Dist: pytest (>=6.2.2) ; extra == 'dev'
Requires-Dist: pytest-mock (>=3.5.1) ; extra == 'dev'
Requires-Dist: mypy (>=0.812) ; extra == 'dev'
Requires-Dist: flake8 (>=3.9.0) ; extra == 'dev'
Requires-Dist: sphinx (==3.5.3) ; extra == 'dev'
Requires-Dist: sphinx-autodoc-typehints (==1.11.1) ; extra == 'dev'
Requires-Dist: matplotlib (>=3.0.0) ; extra == 'dev'

# Disruptive Technologies Python API

![build](https://github.com/disruptive-technologies/disruptive-python/actions/workflows/build.yml/badge.svg)
![python](https://img.shields.io/badge/python-3.7%2C%203.8%2C%203.9-blue)
![coverage](https://img.shields.io/badge/coverage-87%25-green)

## Documentation

- [Python API Reference](https://developer.disruptive-technologies.com/api/libraries/python/)
- [Developer Documentation](https://developer.disruptive-technologies.com/docs/)

## Installation

The package can be installed through pip:

```sh
pip install --upgrade disruptive
```

or from source:

```sh
pip install .
```

### Requirements

- Python 3.7+

## Authentication

Using [Service Account](https://developer.disruptive-technologies.com/docs/service-accounts/introduction-to-service-accounts) credentials, setting `disruptive.default_auth` authenticates the package:

```python
import disruptive as dt
dt.default_auth = dt.Auth.serviceaccount(key_id, secret, email)
```

## Usage

API methods are grouped under various resource names on the form `disruptive.<Resource>.<method>()`.

```python
# Fetch a specific temperature sensor from a project.
sensor = dt.Device.get_device(device_id)

# Print the sensor information, listing all available attributes.
print(sensor)

# Set a new label on the sensor.
dt.Device.set_label(sensor.device_id, sensor.project_id, key='nb#', value='99')

# Get touch- and temperature event history the last 24 hours for the sensor.
history = dt.EventHistory.list_events(
    sensor.device_id,
    sensor.project_id,
    event_types=['touch', 'temperature']
)

# Set up a real-time event stream for the sensor.
for new_event in dt.Stream.device(sensor.device_id, sensor.project_id):
    # Print the data in new events as they arrive.
    print(new_event.data)
```

## Logging
Information about outbound requests and their response can be printed to console by setting:
```python
dt.log = True
```

## Examples
A few examples showcasing various uses for the package has been provided. They do not require additional dependencies and can, provided the package has been installed, be run by:
```sh
python example_name.py
```
or from root using the source code:
```sh
python -m examples.example_name
```

## Exceptions
If a request is unsuccessful or has been provided with invalid parameters, an exception is raised. A list of available exceptions are available in the [API Reference](https://developer.disruptive-technologies.com/api/libraries/python/).

## Development

Set up the development virtualenv environment:
```
make
```

Run unit-tests against the currently active python version:
```
make test
```

Lint the package code using MyPy and flake8:
```
make lint
```

Build the sphinx documentation:
```
make docs
```

Build the package distribution:
```
make build
```


