Usage
Local Installation
For local development, the package can be installed using Poetry (it will create a virtual environment automatically):
# Install Poetry if not already installed
pip install poetry
# Install dependencies and set up the package in development mode
poetry install
# (Optional) Activate the virtual environment via poetry and start a python shell
# to interactively test the package
poetry run python
Or with Virtualenv:
# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows use `.venv\Scripts\activate`
pip install -e .
Adding New Dependencies
To add a new dependency to the project:
poetry add <package-name>
To lock all dependencies to their current versions:
poetry lock
This ensures reproducible installations for everyone using the project.
Connect
Interactive with client id from your OAuth 2 provider:
from seven2one import TechStack
client = TechStack(host, client_id)
In unattended scripts via service account:
from seven2one import TechStack
client = TechStack(host, client_id, service_account_name='my-serviceuser', service_account_secret='some token')
Logging
By default the Python lib writes logs to console and to the server the user connects to.
Configure log levels and server endpoint by environment variables if needed:
| Variable | Description | Default |
|---|---|---|
| LOGLEVEL | Set the log level for console output | 'INFO' |
| LOGLEVEL_SERVER | Set the log level for logs sent to the server (Loki). Log levels are 'ERROR', 'WARNING', 'INFO' and 'DEBUG'. | 'ERROR' |
| LOG_TO_SERVER | Disable logging to Loki server | 'TRUE' |
| LOG_SERVER | Overwrite the log server endpoint if e.g. running inside the same cluster | 'https://{host}/logging/loki/api/v1/push' |
Basic read operations
client.inventories()
client.items('appartments', references=True)
client.inventoryProperties('appartments')
client.propertyList('appartments', references=True, dataTypes=True)
Write operations
Create inventory
properties = [
{
'dataType': 'DATE_TIME_OFFSET',
'name': 'fieldDATETIMEOFFSET',
'nullable': True
},
{
'dataType': 'BOOLEAN',
'name': 'fieldBOOLEAN',
'nullable': True
}
]
client.createInventory('testInventory', properties)
Add (basic) items
items = [
{
"fieldSTRING": "bla",
"fieldDECIMAL": 0,
"fieldLONG": 0,
"fieldINT": 0,
"fieldBOOLEAN": True,
"fieldDATETIME": "2021-09-14T00:00:00.000Z",
"fieldDATETIMEOFFSET": "2021-09-14T00:00:00.000Z"
}
]
addBasicItems('testInventory', items)
Advanced
To change one or more used service endpoints (e.g. for tests against custom deployments) you can overwrite them by environment variables. You have to provide complete URL's.
| Environment variable | Description | Example |
|---|---|---|
| IDENDITYPROVIDER_URL | Identity provider base url | https://authentik.mytechstack |
| DYNAMIC_OBJECTS_ENDPOINT | DynO graphQL endpoint | https://run.integrationtest.s2o.dev/itest-375545a3-dynamic-objects/graphql/ |
| AUTOMATION_ENDPOINT | Automation service graphQL endpoint | |
| SCHEDULE_ENDPOINT | Schedule service graphQL endpoint | |
| PROGRAMMING_ENDPOINT | Programming service graphQL endpoint | |
| TIMESERIES_ENDPOINT | TimeSeries gateway graphQL endpoint | |
| LOGGING_ENDPOINT | Logging reverse proxy endpoint | http://mytechstack:8123/loki/api/v1/push |
| AUTHORIZATION_ENDPOINT | Authorization service graphQL endpoint |
Release files for seven2one 9.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| seven2one-9.3.1.tar.gz | 94.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| seven2one-9.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 204.4 kB
Release files / seven2one-9.3.1.tar.gz
| Download URL | seven2one-9.3.1.tar.gz |
|---|---|
| Size | 94.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0238f48e889f13c595032e03fb62ae8cb4cbfc6c71c52dd27f184066adb454b9
|
|
BLAKE2b-256 checksum How to use checksums |
01c147105aa20a3a5c9a3f3e19c1f5d98fb004f7b40de85f6fa7c659c53e520d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.0 CPython/3.10.12 Linux/5.15.0-161-generic
|
Release files / seven2one-9.3.1-py3-none-any.whl
| Download URL | seven2one-9.3.1-py3-none-any.whl |
|---|---|
| Size | 109.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d581e77b4d2f8af1d061473b14d3144f2b3a963482a77b37bcff6562c714ba71
|
|
BLAKE2b-256 checksum How to use checksums |
b86ff0acafe75c5c02cb535ac22b58276de10633a2ecd731646a8a284bf5d155
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.0 CPython/3.10.12 Linux/5.15.0-161-generic
|