Skip to content

[SDK release] Generated SDK code based on data-link 0.3.15-sdk.5 API changes #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 87 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,99 +1,125 @@
# Databox bindings for Python
# databox-api
Push API resources Open API documentation

[![Build Status](https://travis-ci.org/databox/databox-python.svg?branch=master)](https://travis-ci.org/databox/databox-python)
[![PyPI version](https://badge.fury.io/py/databox.svg)](https://badge.fury.io/py/databox)
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

## Setup
- API version: 0.3.15-sdk.5
- Package version: 2.2.3
- Generator version: 7.6.0
- Build package: org.openapitools.codegen.languages.PythonClientCodegen

You can install this package by cloning this directory and running:
## Requirements.

```bash
python setup.py install
```
Python 3.7+

You can also add following line to `requirements.txt` and get latest master:
## Installation & Usage
### pip install

````
git+https://github.com/databox/databox-python.git
````
If the python package is hosted on a repository, you can install directly using:

And run `pip install --upgrade -r requirements.txt`. Or just:
```sh
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
```
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`)

Then import the package:
```python
import databox
```
pip install databox

### Setuptools

Install via [Setuptools](http://pypi.python.org/pypi/setuptools).

```sh
python setup.py install --user
```
(or `sudo python setup.py install` to install the package for all users)

## Getting Databox access tokens
Then import the package:
```python
import databox
```

When in Databox Designer go to Data Manager and create new connection. Select "Push custom data" and enter a connection name.
### Tests

## Using the Databox Python library
Execute `pytest` to run the tests.

To use databox-python libary you have to pass access token to client. You can do this when initialising `Client` or by setting `DATABOX_PUSH_TOKEN` environment variable.
## Getting Started

Using `Client` and `push` to push data directly:
Please follow the [installation procedure](#installation--usage) and then run the following:

```python
from databox import Client

client = Client('<access token>')
client.push('sales.total', 1447.0)
client.push('orders.total', 32, date='2015-01-01 09:00:00')
client.push('orders.total', 34, attributes={
'something': 1447,
})
import databox
from databox.rest import ApiException
from pprint import pprint

```
# Defining the host is optional and defaults to https://push.databox.com
# See configuration.py for a list of all supported configuration parameters.
configuration = databox.Configuration(
host = "https://push.databox.com"
)

Inserting multiple matrices with one `insert_all`:
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

```python
client.insert_all([
{'key': 'temp.boston', 'value': 51},
{'key': 'temp.boston', 'value': 49, 'date': '2015-01-01 17:00:00'},
{'key': 'sales.total', 'value': 3000},
])
```
# Configure HTTP basic authorization: basicAuth
configuration = databox.Configuration(
username = os.environ["USERNAME"],
password = os.environ["PASSWORD"]
)


# Enter a context with an instance of the API client
with databox.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = databox.DefaultApi(api_client)

try:
api_instance.data_delete()
except ApiException as e:
print("Exception when calling DefaultApi->data_delete: %s\n" % e)

Retriving information from last push with `last_push`:
```python
print client.last_push()
```

Libary can be used with shorthand methods:
## Documentation for API Endpoints

All URIs are relative to *https://push.databox.com*

```python
from databox import push, insert_all, last_push
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*DefaultApi* | [**data_delete**](docs/DefaultApi.md#data_delete) | **DELETE** /data |
*DefaultApi* | [**data_metric_key_delete**](docs/DefaultApi.md#data_metric_key_delete) | **DELETE** /data/{metricKey} |
*DefaultApi* | [**data_post**](docs/DefaultApi.md#data_post) | **POST** /data |
*DefaultApi* | [**metrickeys_get**](docs/DefaultApi.md#metrickeys_get) | **GET** /metrickeys |
*DefaultApi* | [**metrickeys_post**](docs/DefaultApi.md#metrickeys_post) | **POST** /metrickeys |
*DefaultApi* | [**ping_get**](docs/DefaultApi.md#ping_get) | **GET** /ping |

push('sales.total', 1448.9)
print last_push(token)
```

## Development and testing
## Documentation For Models

- [ApiResponse](docs/ApiResponse.md)
- [PushData](docs/PushData.md)
- [PushDataAttribute](docs/PushDataAttribute.md)
- [State](docs/State.md)


Using virtualenv:
<a id="documentation-for-authorization"></a>
## Documentation For Authorization

mkvirtualenv --no-site-packages databox-python
workon databox-python
pip install --upgrade -r requirements.txt

Running test suite with unittest:
Authentication schemes defined for the API:
<a id="basicAuth"></a>
### basicAuth

python -munittest discover -p -t . 'test*' -v
- **Type**: HTTP basic authentication

You can also check working [example.py](example.py).

## Examples and use-cases
- [Simple Python example](example.py)
- [Advanced Python example with MySQL](https://github.com/databox/databox-python-sql)
- For general documentation and examples check [developers.databox.com](https://developers.databox.com)
## Author

## Authors and contributions

- [Vlada Petrović](https://github.com/VladaPetrovic)
- [Oto Brglez](https://github.com/otobrglez)

## Licence

- [MIT](LICENSE.txt)
38 changes: 38 additions & 0 deletions src/.github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# NOTE: This file is auto generated by OpenAPI Generator.
# URL: https://openapi-generator.tech
#
# ref: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: databox Python package

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
66 changes: 66 additions & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
venv/
.venv/
.python-version
.pytest_cache

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

#Ipython Notebook
.ipynb_checkpoints
31 changes: 31 additions & 0 deletions src/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# NOTE: This file is auto generated by OpenAPI Generator.
# URL: https://openapi-generator.tech
#
# ref: https://docs.gitlab.com/ee/ci/README.html
# ref: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml

stages:
- test

.pytest:
stage: test
script:
- pip install -r requirements.txt
- pip install -r test-requirements.txt
- pytest --cov=databox

pytest-3.7:
extends: .pytest
image: python:3.7-alpine
pytest-3.8:
extends: .pytest
image: python:3.8-alpine
pytest-3.9:
extends: .pytest
image: python:3.9-alpine
pytest-3.10:
extends: .pytest
image: python:3.10-alpine
pytest-3.11:
extends: .pytest
image: python:3.11-alpine
23 changes: 23 additions & 0 deletions src/.openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
38 changes: 38 additions & 0 deletions src/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.github/workflows/python.yml
.gitignore
.gitlab-ci.yml
.openapi-generator-ignore
.travis.yml
README.md
databox/__init__.py
databox/api/__init__.py
databox/api/default_api.py
databox/api_client.py
databox/api_response.py
databox/configuration.py
databox/exceptions.py
databox/models/__init__.py
databox/models/api_response.py
databox/models/push_data.py
databox/models/push_data_attribute.py
databox/models/state.py
databox/py.typed
databox/rest.py
docs/ApiResponse.md
docs/DefaultApi.md
docs/PushData.md
docs/PushDataAttribute.md
docs/State.md
git_push.sh
pyproject.toml
requirements.txt
setup.cfg
setup.py
test-requirements.txt
test/__init__.py
test/test_api_response.py
test/test_default_api.py
test/test_push_data.py
test/test_push_data_attribute.py
test/test_state.py
tox.ini
1 change: 1 addition & 0 deletions src/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.6.0
Loading