carconnectivity-plugin-restapi 0.1a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- carconnectivity_plugin_restapi-0.1a1/.flake8 +2 -0
- carconnectivity_plugin_restapi-0.1a1/.github/ISSUE_TEMPLATE/bug_report.md +33 -0
- carconnectivity_plugin_restapi-0.1a1/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- carconnectivity_plugin_restapi-0.1a1/.github/dependabot.yml +11 -0
- carconnectivity_plugin_restapi-0.1a1/.github/workflows/build.yml +59 -0
- carconnectivity_plugin_restapi-0.1a1/.github/workflows/build_and_publish.yml +33 -0
- carconnectivity_plugin_restapi-0.1a1/.github/workflows/codeql-analysis.yml +58 -0
- carconnectivity_plugin_restapi-0.1a1/.gitignore +67 -0
- carconnectivity_plugin_restapi-0.1a1/LICENSE +21 -0
- carconnectivity_plugin_restapi-0.1a1/Makefile +18 -0
- carconnectivity_plugin_restapi-0.1a1/PKG-INFO +171 -0
- carconnectivity_plugin_restapi-0.1a1/README.md +142 -0
- carconnectivity_plugin_restapi-0.1a1/doc/Config.md +75 -0
- carconnectivity_plugin_restapi-0.1a1/pyproject.toml +58 -0
- carconnectivity_plugin_restapi-0.1a1/setup.cfg +4 -0
- carconnectivity_plugin_restapi-0.1a1/setup_requirements.txt +3 -0
- carconnectivity_plugin_restapi-0.1a1/src/carconnectivity_plugin_restapi.egg-info/PKG-INFO +171 -0
- carconnectivity_plugin_restapi-0.1a1/src/carconnectivity_plugin_restapi.egg-info/SOURCES.txt +28 -0
- carconnectivity_plugin_restapi-0.1a1/src/carconnectivity_plugin_restapi.egg-info/dependency_links.txt +1 -0
- carconnectivity_plugin_restapi-0.1a1/src/carconnectivity_plugin_restapi.egg-info/requires.txt +7 -0
- carconnectivity_plugin_restapi-0.1a1/src/carconnectivity_plugin_restapi.egg-info/top_level.txt +1 -0
- carconnectivity_plugin_restapi-0.1a1/src/carconnectivity_plugins/restapi/__init__.py +1 -0
- carconnectivity_plugin_restapi-0.1a1/src/carconnectivity_plugins/restapi/_version.py +34 -0
- carconnectivity_plugin_restapi-0.1a1/src/carconnectivity_plugins/restapi/api/__init__.py +1 -0
- carconnectivity_plugin_restapi-0.1a1/src/carconnectivity_plugins/restapi/api/app.py +213 -0
- carconnectivity_plugin_restapi-0.1a1/src/carconnectivity_plugins/restapi/plugin.py +140 -0
- carconnectivity_plugin_restapi-0.1a1/src/carconnectivity_plugins/restapi/ui/__init__.py +0 -0
- carconnectivity_plugin_restapi-0.1a1/src/carconnectivity_plugins/restapi/ui/plugin_ui.py +35 -0
- carconnectivity_plugin_restapi-0.1a1/test/integration_test/carConnectivity.json +16 -0
- carconnectivity_plugin_restapi-0.1a1/tests/test_plugin.py +387 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
title: ''
|
|
5
|
+
labels: bug
|
|
6
|
+
assignees: tillsteinbach
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Describe the bug**
|
|
11
|
+
A clear and concise description of what the bug is.
|
|
12
|
+
|
|
13
|
+
**To Reproduce**
|
|
14
|
+
Steps to reproduce the behavior:
|
|
15
|
+
1. Go to '...'
|
|
16
|
+
2. Click on '....'
|
|
17
|
+
3. Scroll down to '....'
|
|
18
|
+
4. See error
|
|
19
|
+
|
|
20
|
+
**Expected behavior**
|
|
21
|
+
A clear and concise description of what you expected to happen.
|
|
22
|
+
|
|
23
|
+
**Screenshots**
|
|
24
|
+
If applicable, add screenshots to help explain your problem.
|
|
25
|
+
|
|
26
|
+
**Logs**
|
|
27
|
+
IF applicable logs that show the problem. Please take care to remove any confidential data from the logs (e.g. your vehicles VIN number, usernames or passwords)
|
|
28
|
+
|
|
29
|
+
- OS: [e.g. Windows, Linux, MacOS, ...]
|
|
30
|
+
- Version used [e.g. 0.6.2]
|
|
31
|
+
|
|
32
|
+
**Additional context**
|
|
33
|
+
Add any other context about the problem here.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest an idea for this project
|
|
4
|
+
title: ''
|
|
5
|
+
labels: enhancement
|
|
6
|
+
assignees: tillsteinbach
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Is your feature request related to a problem? Please describe.**
|
|
11
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
12
|
+
|
|
13
|
+
**Describe the solution you'd like**
|
|
14
|
+
A clear and concise description of what you want to happen.
|
|
15
|
+
|
|
16
|
+
**Describe alternatives you've considered**
|
|
17
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
|
18
|
+
|
|
19
|
+
**Additional context**
|
|
20
|
+
Add any other context or screenshots about the feature request here.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
name: Build Python Package
|
|
2
|
+
|
|
3
|
+
# Controls when the action will run.
|
|
4
|
+
on:
|
|
5
|
+
# Triggers the workflow on push or pull request events but only for the master branch
|
|
6
|
+
push:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
tags:
|
|
9
|
+
- "v*"
|
|
10
|
+
paths:
|
|
11
|
+
- .github/workflows/build.yml
|
|
12
|
+
- '**.py'
|
|
13
|
+
- 'pyproject.toml'
|
|
14
|
+
pull_request:
|
|
15
|
+
paths:
|
|
16
|
+
- .github/workflows/build.yml
|
|
17
|
+
- '**.py'
|
|
18
|
+
- 'pyproject.toml'
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
build-python:
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
strategy:
|
|
24
|
+
matrix:
|
|
25
|
+
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
|
|
26
|
+
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v6
|
|
29
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
30
|
+
uses: actions/setup-python@v6
|
|
31
|
+
with:
|
|
32
|
+
python-version: ${{ matrix.python-version }}
|
|
33
|
+
- name: Install dependencies
|
|
34
|
+
run: |
|
|
35
|
+
python -m pip install --upgrade pip
|
|
36
|
+
if [ -f setup_requirements.txt ]; then pip install -r setup_requirements.txt; fi
|
|
37
|
+
python -m pip install build
|
|
38
|
+
- name: Build
|
|
39
|
+
run: |
|
|
40
|
+
python -m build
|
|
41
|
+
- name: Install built package
|
|
42
|
+
run: |
|
|
43
|
+
pip install dist/*.whl
|
|
44
|
+
- name: Run
|
|
45
|
+
run: |
|
|
46
|
+
set +e
|
|
47
|
+
output=$(carconnectivity test/integration_test/carConnectivity.json 2>&1)
|
|
48
|
+
echo "$output" | grep -q 'Invalid port specified in config ("port" out of range, must be 1-65535)'
|
|
49
|
+
if [ $? -ne 0 ]; then
|
|
50
|
+
echo "$output"
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
53
|
+
set -e
|
|
54
|
+
- name: Lint
|
|
55
|
+
run: |
|
|
56
|
+
make lint
|
|
57
|
+
# - name: Test
|
|
58
|
+
# run: |
|
|
59
|
+
# make test
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Build and Upload Python Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
pypi-publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
environment:
|
|
12
|
+
name: pypi
|
|
13
|
+
url: https://pypi.org/p/carconnectivity-plugin-restapi
|
|
14
|
+
permissions:
|
|
15
|
+
id-token: write
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v6
|
|
19
|
+
with:
|
|
20
|
+
fetch-depth: 0
|
|
21
|
+
- name: Set up Python
|
|
22
|
+
uses: actions/setup-python@v6
|
|
23
|
+
with:
|
|
24
|
+
python-version: "3.x"
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: |
|
|
27
|
+
python -m pip install --upgrade pip
|
|
28
|
+
python -m pip install build twine
|
|
29
|
+
- name: Build
|
|
30
|
+
run: |
|
|
31
|
+
python -m build
|
|
32
|
+
- name: Publish package distributions to PyPI
|
|
33
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
name: "CodeQL"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
paths:
|
|
6
|
+
- '**.py'
|
|
7
|
+
schedule:
|
|
8
|
+
- cron: '33 5 * * 0'
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
analyze:
|
|
12
|
+
name: Analyze
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
permissions:
|
|
15
|
+
actions: read
|
|
16
|
+
contents: read
|
|
17
|
+
security-events: write
|
|
18
|
+
|
|
19
|
+
strategy:
|
|
20
|
+
fail-fast: false
|
|
21
|
+
matrix:
|
|
22
|
+
language: [ 'python' ]
|
|
23
|
+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
|
24
|
+
# Learn more:
|
|
25
|
+
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
|
26
|
+
|
|
27
|
+
steps:
|
|
28
|
+
- name: Checkout repository
|
|
29
|
+
uses: actions/checkout@v6
|
|
30
|
+
|
|
31
|
+
# Initializes the CodeQL tools for scanning.
|
|
32
|
+
- name: Initialize CodeQL
|
|
33
|
+
uses: github/codeql-action/init@v4
|
|
34
|
+
with:
|
|
35
|
+
languages: ${{ matrix.language }}
|
|
36
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
37
|
+
# By default, queries listed here will override any specified in a config file.
|
|
38
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
39
|
+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
|
40
|
+
|
|
41
|
+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
|
42
|
+
# If this step fails, then you should remove it and run the build manually (see below)
|
|
43
|
+
- name: Autobuild
|
|
44
|
+
uses: github/codeql-action/autobuild@v4
|
|
45
|
+
|
|
46
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
|
47
|
+
# 📚 https://git.io/JvXDl
|
|
48
|
+
|
|
49
|
+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
|
50
|
+
# and modify them (or add more) to build your code if your project
|
|
51
|
+
# uses a compiled language
|
|
52
|
+
|
|
53
|
+
#- run: |
|
|
54
|
+
# make bootstrap
|
|
55
|
+
# make release
|
|
56
|
+
|
|
57
|
+
- name: Perform CodeQL Analysis
|
|
58
|
+
uses: github/codeql-action/analyze@v4
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Distribution / packaging
|
|
7
|
+
.Python
|
|
8
|
+
build/
|
|
9
|
+
develop-eggs/
|
|
10
|
+
dist/
|
|
11
|
+
downloads/
|
|
12
|
+
eggs/
|
|
13
|
+
.eggs/
|
|
14
|
+
lib/
|
|
15
|
+
lib64/
|
|
16
|
+
parts/
|
|
17
|
+
sdist/
|
|
18
|
+
var/
|
|
19
|
+
wheels/
|
|
20
|
+
pip-wheel-metadata/
|
|
21
|
+
share/python-wheels/
|
|
22
|
+
*.egg-info/
|
|
23
|
+
.installed.cfg
|
|
24
|
+
*.egg
|
|
25
|
+
MANIFEST
|
|
26
|
+
|
|
27
|
+
# PyInstaller
|
|
28
|
+
*.manifest
|
|
29
|
+
*.spec
|
|
30
|
+
|
|
31
|
+
# Installer logs
|
|
32
|
+
pip-log.txt
|
|
33
|
+
pip-delete-this-directory.txt
|
|
34
|
+
|
|
35
|
+
# Unit test / coverage reports
|
|
36
|
+
htmlcov/
|
|
37
|
+
.tox/
|
|
38
|
+
.nox/
|
|
39
|
+
.coverage
|
|
40
|
+
.coverage.*
|
|
41
|
+
.cache
|
|
42
|
+
nosetests.xml
|
|
43
|
+
coverage.xml
|
|
44
|
+
*.cover
|
|
45
|
+
*.py,cover
|
|
46
|
+
.hypothesis/
|
|
47
|
+
.pytest_cache/
|
|
48
|
+
|
|
49
|
+
# Environments
|
|
50
|
+
.env
|
|
51
|
+
.venv
|
|
52
|
+
env/
|
|
53
|
+
venv/
|
|
54
|
+
ENV/
|
|
55
|
+
env.bak/
|
|
56
|
+
venv.bak/
|
|
57
|
+
|
|
58
|
+
# mypy
|
|
59
|
+
.mypy_cache/
|
|
60
|
+
.dmypy.json
|
|
61
|
+
dmypy.json
|
|
62
|
+
|
|
63
|
+
# Pyre type checker
|
|
64
|
+
.pyre/
|
|
65
|
+
|
|
66
|
+
# Version file generated by setuptools-scm
|
|
67
|
+
src/carconnectivity_plugins/restapi/_version.py
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Till Steinbach
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
BLUE='\033[0;34m'
|
|
2
|
+
NC='\033[0m' # No Color
|
|
3
|
+
|
|
4
|
+
test:
|
|
5
|
+
@pytest
|
|
6
|
+
|
|
7
|
+
lint:
|
|
8
|
+
@echo "\n${BLUE}Running Pylint against source and test files...${NC}\n"
|
|
9
|
+
@pylint ./src
|
|
10
|
+
@echo "\n${BLUE}Running Flake8 against source and test files...${NC}\n"
|
|
11
|
+
@flake8
|
|
12
|
+
@echo "\n${BLUE}Running Bandit against source files...${NC}\n"
|
|
13
|
+
@bandit -c pyproject.toml -r .
|
|
14
|
+
|
|
15
|
+
clean:
|
|
16
|
+
rm -rf .pytest_cache .coverage .pytest_cache coverage.xml coverage_html_report
|
|
17
|
+
|
|
18
|
+
.PHONY: clean test
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: carconnectivity-plugin-restapi
|
|
3
|
+
Version: 0.1a1
|
|
4
|
+
Summary: CarConnectivity plugin providing a REST API
|
|
5
|
+
Author: Till Steinbach
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
9
|
+
Classifier: Intended Audience :: System Administrators
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Topic :: Utilities
|
|
17
|
+
Classifier: Topic :: System :: Monitoring
|
|
18
|
+
Classifier: Topic :: Home Automation
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: carconnectivity>=0.11.6
|
|
23
|
+
Requires-Dist: Werkzeug~=3.1.3
|
|
24
|
+
Requires-Dist: Flask~=3.1.2
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
27
|
+
Requires-Dist: pytest-mock; extra == "dev"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# CarConnectivity Plugin for a REST API
|
|
31
|
+
|
|
32
|
+
[](https://github.com/tillsteinbach/CarConnectivity-plugin-restapi/)
|
|
33
|
+
[](https://github.com/tillsteinbach/CarConnectivity-plugin-restapi/blob/master/LICENSE)
|
|
34
|
+
[](https://github.com/tillsteinbach/CarConnectivity-plugin-restapi/issues)
|
|
35
|
+
|
|
36
|
+
## CarConnectivity will become the successor of [WeConnect-python](https://github.com/tillsteinbach/WeConnect-python) in 2025 with similar functionality but support for other brands beyond Volkswagen!
|
|
37
|
+
|
|
38
|
+
[CarConnectivity](https://github.com/tillsteinbach/CarConnectivity) is a python API to connect to various car services. This plugin provides a REST API that allows other clients to interact with CarConnectivity's object tree.
|
|
39
|
+
|
|
40
|
+
## Supported operations
|
|
41
|
+
- **GET** data from CarConnectivity's object tree
|
|
42
|
+
- **PUT** writable attributes (change values)
|
|
43
|
+
- **POST** commands with their arguments
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
```bash
|
|
47
|
+
pip install carconnectivity-plugin-restapi
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Configuration
|
|
51
|
+
Add the plugin to your `carconnectivity.json` configuration file:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"carConnectivity": {
|
|
56
|
+
"connectors": [...],
|
|
57
|
+
"plugins": [
|
|
58
|
+
{
|
|
59
|
+
"type": "restapi",
|
|
60
|
+
"config": {
|
|
61
|
+
"host": "0.0.0.0",
|
|
62
|
+
"port": 40000,
|
|
63
|
+
"username": "admin",
|
|
64
|
+
"password": "secretpassword"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Multiple users
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"carConnectivity": {
|
|
76
|
+
"plugins": [
|
|
77
|
+
{
|
|
78
|
+
"type": "restapi",
|
|
79
|
+
"config": {
|
|
80
|
+
"port": 40000,
|
|
81
|
+
"users": [
|
|
82
|
+
{"username": "user1", "password": "pass1"},
|
|
83
|
+
{"username": "user2", "password": "pass2"}
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### HTTPS
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"carConnectivity": {
|
|
96
|
+
"plugins": [
|
|
97
|
+
{
|
|
98
|
+
"type": "restapi",
|
|
99
|
+
"config": {
|
|
100
|
+
"port": 40000,
|
|
101
|
+
"https": true,
|
|
102
|
+
"ssl_certificate_file": "/path/to/cert.pem",
|
|
103
|
+
"ssl_certificate_key_file": "/path/to/key.pem",
|
|
104
|
+
"username": "admin",
|
|
105
|
+
"password": "secret"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## API Usage
|
|
114
|
+
|
|
115
|
+
All endpoints require HTTP Basic Authentication.
|
|
116
|
+
|
|
117
|
+
### GET — retrieve data
|
|
118
|
+
```
|
|
119
|
+
GET http://localhost:40000/<path>
|
|
120
|
+
```
|
|
121
|
+
Returns the object or attribute at `<path>` in the CarConnectivity object tree as JSON.
|
|
122
|
+
An empty path (`/`) returns the entire tree.
|
|
123
|
+
|
|
124
|
+
Example:
|
|
125
|
+
```bash
|
|
126
|
+
curl -u admin:secret http://localhost:40000/garage/WVWZZZAUZLW123456/charging/connector/connection_state
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### PUT — set a writable attribute
|
|
130
|
+
```
|
|
131
|
+
PUT http://localhost:40000/<path>
|
|
132
|
+
Content-Type: application/json
|
|
133
|
+
|
|
134
|
+
{"value": <new_value>}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Example:
|
|
138
|
+
```bash
|
|
139
|
+
curl -u admin:secret -X PUT -H "Content-Type: application/json" \
|
|
140
|
+
-d '{"value": 80}' \
|
|
141
|
+
http://localhost:40000/garage/WVWZZZAUZLW123456/charging/settings/target_level
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### POST — execute a command
|
|
145
|
+
```
|
|
146
|
+
POST http://localhost:40000/<path>
|
|
147
|
+
Content-Type: application/json
|
|
148
|
+
|
|
149
|
+
{"value": <command_arguments>}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Example:
|
|
153
|
+
```bash
|
|
154
|
+
curl -u admin:secret -X POST -H "Content-Type: application/json" \
|
|
155
|
+
-d '{"value": "start"}' \
|
|
156
|
+
http://localhost:40000/garage/WVWZZZAUZLW123456/climatization/commands/start-stop
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Configuration parameters
|
|
160
|
+
|
|
161
|
+
| Parameter | Description | Default |
|
|
162
|
+
|-----------|-------------|---------|
|
|
163
|
+
| `host` | Host/IP to listen on | `0.0.0.0` |
|
|
164
|
+
| `port` | Port to listen on | `40000` |
|
|
165
|
+
| `username` | Single user username | — |
|
|
166
|
+
| `password` | Single user password | — |
|
|
167
|
+
| `users` | List of `{username, password}` objects | — |
|
|
168
|
+
| `https` | Enable HTTPS | `false` |
|
|
169
|
+
| `ssl_certificate_file` | Path to SSL certificate file | — |
|
|
170
|
+
| `ssl_certificate_key_file` | Path to SSL private key file | — |
|
|
171
|
+
| `log_level` | Log level (`DEBUG`, `INFO`, `WARNING`, `ERROR`) | `ERROR` |
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# CarConnectivity Plugin for a REST API
|
|
2
|
+
|
|
3
|
+
[](https://github.com/tillsteinbach/CarConnectivity-plugin-restapi/)
|
|
4
|
+
[](https://github.com/tillsteinbach/CarConnectivity-plugin-restapi/blob/master/LICENSE)
|
|
5
|
+
[](https://github.com/tillsteinbach/CarConnectivity-plugin-restapi/issues)
|
|
6
|
+
|
|
7
|
+
## CarConnectivity will become the successor of [WeConnect-python](https://github.com/tillsteinbach/WeConnect-python) in 2025 with similar functionality but support for other brands beyond Volkswagen!
|
|
8
|
+
|
|
9
|
+
[CarConnectivity](https://github.com/tillsteinbach/CarConnectivity) is a python API to connect to various car services. This plugin provides a REST API that allows other clients to interact with CarConnectivity's object tree.
|
|
10
|
+
|
|
11
|
+
## Supported operations
|
|
12
|
+
- **GET** data from CarConnectivity's object tree
|
|
13
|
+
- **PUT** writable attributes (change values)
|
|
14
|
+
- **POST** commands with their arguments
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
```bash
|
|
18
|
+
pip install carconnectivity-plugin-restapi
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Configuration
|
|
22
|
+
Add the plugin to your `carconnectivity.json` configuration file:
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"carConnectivity": {
|
|
27
|
+
"connectors": [...],
|
|
28
|
+
"plugins": [
|
|
29
|
+
{
|
|
30
|
+
"type": "restapi",
|
|
31
|
+
"config": {
|
|
32
|
+
"host": "0.0.0.0",
|
|
33
|
+
"port": 40000,
|
|
34
|
+
"username": "admin",
|
|
35
|
+
"password": "secretpassword"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Multiple users
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"carConnectivity": {
|
|
47
|
+
"plugins": [
|
|
48
|
+
{
|
|
49
|
+
"type": "restapi",
|
|
50
|
+
"config": {
|
|
51
|
+
"port": 40000,
|
|
52
|
+
"users": [
|
|
53
|
+
{"username": "user1", "password": "pass1"},
|
|
54
|
+
{"username": "user2", "password": "pass2"}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### HTTPS
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"carConnectivity": {
|
|
67
|
+
"plugins": [
|
|
68
|
+
{
|
|
69
|
+
"type": "restapi",
|
|
70
|
+
"config": {
|
|
71
|
+
"port": 40000,
|
|
72
|
+
"https": true,
|
|
73
|
+
"ssl_certificate_file": "/path/to/cert.pem",
|
|
74
|
+
"ssl_certificate_key_file": "/path/to/key.pem",
|
|
75
|
+
"username": "admin",
|
|
76
|
+
"password": "secret"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## API Usage
|
|
85
|
+
|
|
86
|
+
All endpoints require HTTP Basic Authentication.
|
|
87
|
+
|
|
88
|
+
### GET — retrieve data
|
|
89
|
+
```
|
|
90
|
+
GET http://localhost:40000/<path>
|
|
91
|
+
```
|
|
92
|
+
Returns the object or attribute at `<path>` in the CarConnectivity object tree as JSON.
|
|
93
|
+
An empty path (`/`) returns the entire tree.
|
|
94
|
+
|
|
95
|
+
Example:
|
|
96
|
+
```bash
|
|
97
|
+
curl -u admin:secret http://localhost:40000/garage/WVWZZZAUZLW123456/charging/connector/connection_state
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### PUT — set a writable attribute
|
|
101
|
+
```
|
|
102
|
+
PUT http://localhost:40000/<path>
|
|
103
|
+
Content-Type: application/json
|
|
104
|
+
|
|
105
|
+
{"value": <new_value>}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Example:
|
|
109
|
+
```bash
|
|
110
|
+
curl -u admin:secret -X PUT -H "Content-Type: application/json" \
|
|
111
|
+
-d '{"value": 80}' \
|
|
112
|
+
http://localhost:40000/garage/WVWZZZAUZLW123456/charging/settings/target_level
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### POST — execute a command
|
|
116
|
+
```
|
|
117
|
+
POST http://localhost:40000/<path>
|
|
118
|
+
Content-Type: application/json
|
|
119
|
+
|
|
120
|
+
{"value": <command_arguments>}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Example:
|
|
124
|
+
```bash
|
|
125
|
+
curl -u admin:secret -X POST -H "Content-Type: application/json" \
|
|
126
|
+
-d '{"value": "start"}' \
|
|
127
|
+
http://localhost:40000/garage/WVWZZZAUZLW123456/climatization/commands/start-stop
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Configuration parameters
|
|
131
|
+
|
|
132
|
+
| Parameter | Description | Default |
|
|
133
|
+
|-----------|-------------|---------|
|
|
134
|
+
| `host` | Host/IP to listen on | `0.0.0.0` |
|
|
135
|
+
| `port` | Port to listen on | `40000` |
|
|
136
|
+
| `username` | Single user username | — |
|
|
137
|
+
| `password` | Single user password | — |
|
|
138
|
+
| `users` | List of `{username, password}` objects | — |
|
|
139
|
+
| `https` | Enable HTTPS | `false` |
|
|
140
|
+
| `ssl_certificate_file` | Path to SSL certificate file | — |
|
|
141
|
+
| `ssl_certificate_key_file` | Path to SSL private key file | — |
|
|
142
|
+
| `log_level` | Log level (`DEBUG`, `INFO`, `WARNING`, `ERROR`) | `ERROR` |
|