Metadata-Version: 2.4
Name: seven2one
Version: 9.1.0
Summary: Functions to interact with the Seven2one TechStack
Home-page: http://www.seven2one.de
Author: Seven2one Informationssysteme GmbH
Author-email: info@seven2one.de
License: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas<2.0.0,>=1.4.2
Requires-Dist: gql==3.0.0
Requires-Dist: pytz==2024.1
Requires-Dist: tzlocal==5.2
Requires-Dist: pyperclip==1.9.0
Requires-Dist: loguru==0.7.2
Requires-Dist: pika==1.3.2
Requires-Dist: requests==2.32.3
Requires-Dist: requests_toolbelt==1.0.0
Requires-Dist: requests_oauthlib==2.0.0
Requires-Dist: rfc3339==6.2
Requires-Dist: numpy==1.24.4
Requires-Dist: setuptools==71.1.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Usage

## Local Installation

For local development, the package can be installed locally in editable mode:

```bash
pip install -e .
```

This will also install the required dependencies, taken from the setup.py, install_requires section (which will also be installed if this package is later installed via pip).
If you want to just test the dependencies, you can install them using the requirements.txt file:

```bash
pip install -r requirements.txt
```

The requirements.txt and setup.py files should be kept in sync, so that the package can be installed in the same way in the production environment. Unfortunatelly, the setup.py file does not support the use of the requirements.txt file, so the dependencies have to be listed in both files.

## Connect

Interactive with client id from your OAuth 2 provider:

```python
from seven2one import TechStack
client = TechStack(host, client_id)
```

In unattended scripts via service account:

```python
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

```python
client.inventories()
client.items('appartments', references=True)
client.inventoryProperties('appartments')
client.propertyList('appartments', references=True, dataTypes=True)
```

## Write operations

### Create inventory

```python
properties = [
   {
        'dataType': 'DATE_TIME_OFFSET',
        'name': 'fieldDATETIMEOFFSET',
        'nullable': True
    },
    {
        'dataType': 'BOOLEAN',
        'name': 'fieldBOOLEAN',
        'nullable': True
    }
]

client.createInventory('testInventory', properties)
```

### Add (basic) items

```python
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 | |
