Skip to content

Commit

Permalink
initial files
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperraemaekers committed Jul 9, 2024
0 parents commit a5cb2b3
Show file tree
Hide file tree
Showing 29 changed files with 6,402 additions and 0 deletions.
16 changes: 16 additions & 0 deletions PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Metadata-Version: 2.1
Name: weheat_backend_client
Version: 2024.6.19
Summary: Weheat Backend
Home-page: https://github.com/wefabricate/wh-pubic-backend-client
Author: Jesper Raemaekers
Author-email: [email protected]
Keywords: OpenAPI,OpenAPI-Generator,Weheat Backend
Description-Content-Type: text/markdown
Requires-Dist: urllib3<2.1.0,>=1.25.3
Requires-Dist: python-dateutil
Requires-Dist: pydantic>=2
Requires-Dist: typing-extensions>=4.7.1

This is a client for the Weheat backend

87 changes: 87 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Weheat backend client

This is a client for the Weheat backend. It is automatically generated from the OpenAPI specification.

## Requirements.

Python 3.7+

## Installation & Usage

You can install directly using:

```sh
pip install weheat_backend_client
```

Then import the package:
```python
import weheat_backend_client
```



## Getting Started

After installation, you can now use the client to interact with the Weheat backend.

```python
import datetime
from keycloak import KeycloakOpenID # install with pip install python-keycloak
from weheat_backend_client import ApiClient, Configuration, HeatPumpApi, HeatPumpLogApi, EnergyLogApi

# input your information here
auth_url = 'https://auth.weheat.nl/auth/'
api_url = 'https://api.weheat.nl'
realm_name = 'Weheat'
my_client_id = 'WeheatCommunityAPI' # client ID and secret provided by Weheat
my_client_secret = ''
username = '' # username and password used for the online portal
password = ''
my_heat_pump_id = '' # your heat pump UUID

# Get the access token from keycloak
keycloak_open_id = KeycloakOpenID(server_url=auth_url,
client_id=my_client_id,
realm_name=realm_name,
client_secret_key=my_client_secret)

token_response = keycloak_open_id.token(username, password)
keycloak_open_id.logout(token_response['refresh_token'])

# Create the cinfiguration object
config = Configuration(host=api_url, access_token=token_response['access_token'])

# with the client the APIs can be accessed
with ApiClient(configuration=config) as client:
# Getting all heat pumps that the user has access to
response = HeatPumpApi(client).api_v1_heat_pumps_get_with_http_info()

if response.status_code == 200:
print(f'My heat pump: {response.data}')

# Getting the latest log of the heat pump
response = HeatPumpLogApi(client).api_v1_heat_pumps_heat_pump_id_logs_latest_get_with_http_info(
heat_pump_id=my_heat_pump_id)

if response.status_code == 200:
print(f'My heat pump logs: {response.data}')

# Getting the energy logs of the heat pump in a specific period
# interval can be "Minute", "FiveMinute", "FifteenMinute", "Hour", "Day", "Week", "Month", "Year"
response = EnergyLogApi(client).api_v1_energy_logs_heat_pump_id_get_with_http_info(heat_pump_id=my_heat_pump_id,
start_time=datetime.datetime(2024, 6,
22, 0, 0,
0),
end_time=datetime.datetime(2024, 6, 22,
15, 0, 0),
interval='Hour')

if response.status_code == 200:
print(f'My energy logs: {response.data}')


```



45 changes: 45 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import datetime
from keycloak import KeycloakOpenID # install with pip install python-keycloak
from weheat_backend_client import ApiClient, Configuration, HeatPumpApi, HeatPumpLogApi, EnergyLogApi

auth_url = 'https://auth.weheat.nl/auth/'
api_url = 'https://api.weheat.nl'
realm_name = 'Weheat'
my_client_id = 'WeheatCommunityAPI' # client ID and secret provided by Weheat
my_client_secret = ''
username = '' # username and password used for the online portal
password = ''
my_heat_pump_id = '' # your heat pump UUID

keycloak_open_id = KeycloakOpenID(server_url=auth_url,
client_id=my_client_id,
realm_name=realm_name,
client_secret_key=my_client_secret)

token_response = keycloak_open_id.token(username, password)
keycloak_open_id.logout(token_response['refresh_token'])

config = Configuration(host=api_url, access_token=token_response['access_token'])

with ApiClient(configuration=config) as client:
response = HeatPumpApi(client).api_v1_heat_pumps_get_with_http_info()

if response.status_code == 200:
print(f'My heat pump: {response.data}')

response = HeatPumpLogApi(client).api_v1_heat_pumps_heat_pump_id_logs_latest_get_with_http_info(
heat_pump_id=my_heat_pump_id)

if response.status_code == 200:
print(f'My heat pump logs: {response.data}')

response = EnergyLogApi(client).api_v1_energy_logs_heat_pump_id_get_with_http_info(heat_pump_id=my_heat_pump_id,
start_time=datetime.datetime(2024, 6,
22, 0, 0,
0),
end_time=datetime.datetime(2024, 6, 22,
15, 0, 0),
interval='Hour')

if response.status_code == 200:
print(f'My energy logs: {response.data}')
30 changes: 30 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[tool.poetry]
name = "weheat_backend_client"
version = "2024.06.19"
description = "Weheat Backend"
authors = ["Jesper Raemaekers <[email protected]>"]
license = "NoLicense"
readme = "README.md"
repository = "https://github.com/wefabricate/wh-pubic-backend-client"
keywords = ["OpenAPI", "OpenAPI-Generator", "Weheat Backend"]
include = ["weheat_backend_client/py.typed"]

[tool.poetry.dependencies]
python = "^3.7"

urllib3 = ">= 1.25.3"
python-dateutil = ">=2.8.2"
pydantic = ">=2"
typing-extensions = ">=4.7.1"

[tool.poetry.dev-dependencies]
pytest = ">=7.2.1"
tox = ">=3.9.0"
flake8 = ">=4.0.0"

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.pylint.'MESSAGES CONTROL']
extension-pkg-whitelist = "pydantic"
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[flake8]
max-line-length = 99

[egg_info]
tag_build =
tag_date = 0

49 changes: 49 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# coding: utf-8

"""
Weheat Backend
This is the backend for the Weheat project
The version of the OpenAPI document: v1
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501


from setuptools import setup, find_packages # noqa: H301

# To install the library, run the following
#
# python setup.py install
#
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools
NAME = "weheat_backend_client"
VERSION = "2024.06.19"
PYTHON_REQUIRES = ">=3.7"
REQUIRES = [
"urllib3 >= 1.25.3, < 2.1.0",
"python-dateutil",
"pydantic >= 2",
"typing-extensions >= 4.7.1",
]

setup(
name=NAME,
version=VERSION,
description="Weheat Backend client",
author="Jesper Raemaekers",
author_email="[email protected]",
url="https://github.com/wefabricate/wh-pubic-backend-client",
keywords=["OpenAPI", "OpenAPI-Generator", "Weheat Backend"],
install_requires=REQUIRES,
packages=find_packages(exclude=["test", "tests"]),
include_package_data=True,
long_description_content_type='text/markdown',
long_description="""\
This is the backend for the Weheat project
""", # noqa: E501
package_data={"weheat_backend_client": ["py.typed"]},
)
42 changes: 42 additions & 0 deletions weheat_backend_client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# coding: utf-8

# flake8: noqa

"""
Weheat Backend
This is the backend for the Weheat project
The version of the OpenAPI document: v1
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501


__version__ = "2024.06.19"

# import apis into sdk package
from weheat_backend_client.api.energy_log_api import EnergyLogApi
from weheat_backend_client.api.heat_pump_api import HeatPumpApi
from weheat_backend_client.api.heat_pump_log_api import HeatPumpLogApi

# import ApiClient
from weheat_backend_client.api_response import ApiResponse
from weheat_backend_client.api_client import ApiClient
from weheat_backend_client.configuration import Configuration
from weheat_backend_client.exceptions import OpenApiException
from weheat_backend_client.exceptions import ApiTypeError
from weheat_backend_client.exceptions import ApiValueError
from weheat_backend_client.exceptions import ApiKeyError
from weheat_backend_client.exceptions import ApiAttributeError
from weheat_backend_client.exceptions import ApiException

# import models into sdk package
from weheat_backend_client.models.device_state import DeviceState
from weheat_backend_client.models.energy_view_dto import EnergyViewDto
from weheat_backend_client.models.heat_pump_log_view_dto import HeatPumpLogViewDto
from weheat_backend_client.models.raw_heat_pump_log_dto import RawHeatPumpLogDto
from weheat_backend_client.models.read_all_heat_pump_dto import ReadAllHeatPumpDto
from weheat_backend_client.models.read_heat_pump_dto import ReadHeatPumpDto

6 changes: 6 additions & 0 deletions weheat_backend_client/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# flake8: noqa

# import apis into api package
from weheat_backend_client.api.energy_log_api import EnergyLogApi
from weheat_backend_client.api.heat_pump_api import HeatPumpApi
from weheat_backend_client.api.heat_pump_log_api import HeatPumpLogApi
Loading

0 comments on commit a5cb2b3

Please sign in to comment.