juniconnlib-core 1.1.1__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.
Files changed (37) hide show
  1. juniconnlib_core-1.1.1/.gitignore +133 -0
  2. juniconnlib_core-1.1.1/.gitlab-ci.yml +81 -0
  3. juniconnlib_core-1.1.1/LICENSE +14 -0
  4. juniconnlib_core-1.1.1/MANIFEST.in +8 -0
  5. juniconnlib_core-1.1.1/PKG-INFO +187 -0
  6. juniconnlib_core-1.1.1/README.md +132 -0
  7. juniconnlib_core-1.1.1/pyproject.toml +63 -0
  8. juniconnlib_core-1.1.1/ruff.toml +12 -0
  9. juniconnlib_core-1.1.1/setup.cfg +4 -0
  10. juniconnlib_core-1.1.1/src/juniconnlib_core/__init__.py +81 -0
  11. juniconnlib_core-1.1.1/src/juniconnlib_core/_version.py +34 -0
  12. juniconnlib_core-1.1.1/src/juniconnlib_core/data_models/__init__.py +0 -0
  13. juniconnlib_core-1.1.1/src/juniconnlib_core/data_models/basic_models.py +150 -0
  14. juniconnlib_core-1.1.1/src/juniconnlib_core/data_models/fiware_models.py +277 -0
  15. juniconnlib_core-1.1.1/src/juniconnlib_core/modules/__init__.py +0 -0
  16. juniconnlib_core-1.1.1/src/juniconnlib_core/modules/devtools.py +106 -0
  17. juniconnlib_core-1.1.1/src/juniconnlib_core/modules/fiware_iota_communicators.py +349 -0
  18. juniconnlib_core-1.1.1/src/juniconnlib_core/modules/fiware_iota_device_provisioner.py +448 -0
  19. juniconnlib_core-1.1.1/src/juniconnlib_core/modules/fiware_ocb_communicators.py +545 -0
  20. juniconnlib_core-1.1.1/src/juniconnlib_core/modules/fiware_ocb_entity_provisioner.py +266 -0
  21. juniconnlib_core-1.1.1/src/juniconnlib_core/modules/fiware_subscriptions.py +674 -0
  22. juniconnlib_core-1.1.1/src/juniconnlib_core/modules/influxdb_writer.py +308 -0
  23. juniconnlib_core-1.1.1/src/juniconnlib_core/modules/json_schema_parser.py +283 -0
  24. juniconnlib_core-1.1.1/src/juniconnlib_core/utils/__init__.py +0 -0
  25. juniconnlib_core-1.1.1/src/juniconnlib_core/utils/keycloak_iota.py +411 -0
  26. juniconnlib_core-1.1.1/src/juniconnlib_core/utils/keycloak_oauth.py +168 -0
  27. juniconnlib_core-1.1.1/src/juniconnlib_core/utils/keycloak_ocb.py +553 -0
  28. juniconnlib_core-1.1.1/src/juniconnlib_core/utils/location_fiware_provisioner.py +690 -0
  29. juniconnlib_core-1.1.1/src/juniconnlib_core/utils/logging.py +85 -0
  30. juniconnlib_core-1.1.1/src/juniconnlib_core/utils/meta.py +27 -0
  31. juniconnlib_core-1.1.1/src/juniconnlib_core/utils/mqtt.py +179 -0
  32. juniconnlib_core-1.1.1/src/juniconnlib_core/utils/validators.py +60 -0
  33. juniconnlib_core-1.1.1/src/juniconnlib_core.egg-info/PKG-INFO +187 -0
  34. juniconnlib_core-1.1.1/src/juniconnlib_core.egg-info/SOURCES.txt +35 -0
  35. juniconnlib_core-1.1.1/src/juniconnlib_core.egg-info/dependency_links.txt +1 -0
  36. juniconnlib_core-1.1.1/src/juniconnlib_core.egg-info/requires.txt +22 -0
  37. juniconnlib_core-1.1.1/src/juniconnlib_core.egg-info/top_level.txt +1 -0
@@ -0,0 +1,133 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs_old/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
86
+ __pypackages__/
87
+
88
+ # Celery stuff
89
+ celerybeat-schedule
90
+ celerybeat.pid
91
+
92
+ # SageMath parsed files
93
+ *.sage.py
94
+
95
+ # Environments
96
+ .env
97
+ .venv
98
+ env/
99
+ venv/
100
+ ENV/
101
+ env.bak/
102
+ venv.bak/
103
+
104
+ # Spyder project settings
105
+ .spyderproject
106
+ .spyproject
107
+
108
+ # Rope project settings
109
+ .ropeproject
110
+
111
+ # mkdocs documentation
112
+ /site
113
+
114
+ # mypy
115
+ .mypy_cache/
116
+ .dmypy.json
117
+ dmypy.json
118
+
119
+ # Pyre type checker
120
+ .pyre/
121
+
122
+ # pytype static type analyzer
123
+ .pytype/
124
+
125
+ # Cython debug symbols
126
+ cython_debug/
127
+
128
+ # PyCharm
129
+ .idea/
130
+
131
+ # Custom additions
132
+ /tests/configs/*inttest_credentials_file.json
133
+ /src/juniconnlib_core/_version.py
@@ -0,0 +1,81 @@
1
+ workflow:
2
+ rules:
3
+ - if: $CI_COMMIT_TAG
4
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
5
+ - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
6
+ when: never
7
+ - if: $CI_COMMIT_BRANCH
8
+
9
+ variables:
10
+ FF_NETWORK_PER_BUILD: 1 # Necessary for the FIWARE stack created during testing
11
+
12
+ .ci_component_job_mode: &ci_component_job_mode "artifacts"
13
+
14
+
15
+ include:
16
+ - project: iek-10/public/developer-tools/gitlab-ci-templates
17
+ ref: main
18
+ file:
19
+ - services/fiware-services.yml
20
+ - component: $CI_SERVER_FQDN/iek-10/public/developer-tools/gitlab-ci-components/python/lint@v2.7.1
21
+ inputs:
22
+ allow_stage_failure: false
23
+ - component: $CI_SERVER_FQDN/iek-10/public/developer-tools/gitlab-ci-components/python/build@v2.7.1
24
+ inputs:
25
+ image_tag: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/python:3.12
26
+ job_mode: *ci_component_job_mode
27
+ - component: $CI_SERVER_FQDN/iek-10/public/developer-tools/gitlab-ci-components/python/test@v2.7.1
28
+ inputs:
29
+ job_mode: *ci_component_job_mode
30
+ pytest_services:
31
+ - !reference [.fiware-services, services]
32
+ pytest_python_versions:
33
+ - "3.11"
34
+ - "3.12"
35
+ pytest_before_script:
36
+ - |
37
+ cat <<EOF > tests/configs/keycloak_inttest_credentials_file.json
38
+ {
39
+ "username": "${KEYCLOAK_INTTEST_USERNAME}",
40
+ "password": "${KEYCLOAK_INTTEST_PASSWORD}"
41
+ }
42
+ EOF
43
+ - !reference [.fiware-services, validation]
44
+ - !reference [.fiware-services, test]
45
+ pytest_disable_parallel_testing: true
46
+ # Currently Tests can only run sequential to prevent test failing, e.g.:
47
+ # - FAILED tests/test_int_ocb_communicators.py::TestIntegrationHttpCommunicatorWithOAuth::test_posting_attribute_updates - AttributeError: 'ContextEntity' object has no attribute 'classicAttribute'
48
+ # - FAILED tests/test_int_subscription_handler.py::TestIntegrationMqttHandler::test_posting_with_oauth - AssertionError: assert 0 == 1
49
+ # - ERROR tests/test_int_ocb_communicators.py::TestIntegrationHttpCommunicatorWithOAuth::test_entity_callback - requests.exceptions.HTTPError: 404
50
+ - component: $CI_SERVER_FQDN/iek-10/public/developer-tools/gitlab-ci-components/python/security@v2.7.1
51
+ inputs:
52
+ allow_stage_failure: false
53
+ job_mode: *ci_component_job_mode
54
+ - component: $CI_SERVER_FQDN/iek-10/public/developer-tools/gitlab-ci-components/python/doc@v2.7.1
55
+ inputs:
56
+ generate_doc_versioned_doc: true
57
+ generate_doc_versioned_doc_selection:
58
+ - v*
59
+ - main
60
+ always_publish_docs: true
61
+ fileserver_publish_enabled: true
62
+ - component: $CI_SERVER_FQDN/iek-10/public/developer-tools/gitlab-ci-components/python/publish@v2.7.1
63
+ inputs:
64
+ trigger_on_tags_only: false
65
+ job_mode: *ci_component_job_mode
66
+ - component: $CI_SERVER_FQDN/iek-10/public/developer-tools/gitlab-ci-components/python/publish@v2.7.1
67
+ inputs:
68
+ job_name: publish-pypi
69
+ twine_url: $PYPI_URL
70
+ twine_username: __token__
71
+ twine_password: $PYPI_TOKEN
72
+ trigger_on_tags_only: true
73
+
74
+
75
+ stages:
76
+ - lint
77
+ - doc
78
+ - build
79
+ - test
80
+ - security
81
+ - publish
@@ -0,0 +1,14 @@
1
+ MIT License
2
+ Copyright © 2025
3
+ Institute of Climate and Energy Systems (ICE)
4
+ Energy Systems Engineering (ICE-1)
5
+ Forschungszentrum Jülich GmbH
6
+ https://www.fz-juelich.de/en/ice/ice-1
7
+ 52425 Jülich, Germany
8
+ All rights reserved.
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,8 @@
1
+ # Exclude all `.csv` and `.svg` files across the package
2
+ global-exclude *.csv *.svg
3
+
4
+ # Exclude directories
5
+ prune tests
6
+ prune docs
7
+ prune diagrams
8
+ prune examples
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: juniconnlib-core
3
+ Version: 1.1.1
4
+ Summary: Core library for FIWARE adpater agents based on EBC AgentLib.
5
+ Author-email: "ICE-1, Forschungszentrum Juelich GmbH" <ice-1-fiware-admin@fz-juelich.de>
6
+ Maintainer-email: Sascha Johnen <sa.johnen@fz-juelich.de>, Marcel Schroeder <m.schroeder@fz-juelich.de>, Jana Pick <j.pick@fz-juelich.de>
7
+ License: MIT License
8
+ Copyright © 2025
9
+ Institute of Climate and Energy Systems (ICE)
10
+ Energy Systems Engineering (ICE-1)
11
+ Forschungszentrum Jülich GmbH
12
+ https://www.fz-juelich.de/en/ice/ice-1
13
+ 52425 Jülich, Germany
14
+ All rights reserved.
15
+
16
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ Project-URL: Homepage, https://jugit.fz-juelich.de/iek-10/public/ict-platform/fiware-applications/juniconnlib-core
23
+ Project-URL: Documentation, https://apps.fz-juelich.de/ice-1/ict-platform/juniconnlib-core/
24
+ Project-URL: Repository, https://jugit.fz-juelich.de/iek-10/public/ict-platform/fiware-applications/juniconnlib-core
25
+ Project-URL: Issues, https://jugit.fz-juelich.de/iek-10/public/ict-platform/fiware-applications/juniconnlib-core/-/issues
26
+ Keywords: FIWARE,ICE-1,ICT Platform,AgentLib
27
+ Classifier: Programming Language :: Python :: 3
28
+ Classifier: Programming Language :: Python :: 3.11
29
+ Classifier: Programming Language :: Python :: 3.12
30
+ Classifier: Operating System :: OS Independent
31
+ Requires-Python: >=3.11
32
+ Description-Content-Type: text/markdown
33
+ License-File: LICENSE
34
+ Requires-Dist: pydantic
35
+ Requires-Dist: paho-mqtt~=2.0.0
36
+ Requires-Dist: requests~=2.32.0
37
+ Requires-Dist: httpx~=0.27.2
38
+ Requires-Dist: filip
39
+ Requires-Dist: agentlib~=0.8.2
40
+ Requires-Dist: fidere
41
+ Requires-Dist: influxdb-client~=1.47.0
42
+ Requires-Dist: semantic_version
43
+ Provides-Extra: test
44
+ Requires-Dist: pytest==8.3.4; extra == "test"
45
+ Requires-Dist: pytest-mock~=3.14.0; extra == "test"
46
+ Provides-Extra: doc
47
+ Requires-Dist: sphinx~=8.0.2; extra == "doc"
48
+ Requires-Dist: sphinx-versioned-docs~=1.4.0; extra == "doc"
49
+ Requires-Dist: sphinx_rtd_theme~=3.0.2; extra == "doc"
50
+ Requires-Dist: sphinx-autodoc-typehints~=2.5.0; extra == "doc"
51
+ Requires-Dist: sphinxcontrib-napoleon~=0.7; extra == "doc"
52
+ Requires-Dist: autodoc_pydantic~=2.2.0; extra == "doc"
53
+ Requires-Dist: myst-parser~=4.0.1; extra == "doc"
54
+ Dynamic: license-file
55
+
56
+ # juniconnlib
57
+
58
+ This python library serves as core library (hence the name `juniconnlib_core`)
59
+ towards connecting all different kinds of components to a FIWARE based
60
+ infrastructure. For an overview of related projects, that are build on top
61
+ of `juniconnlib_core`, take a look at [related projects](#related-projects).
62
+
63
+ The library is built ontop of the framework
64
+ [`AgentLib`](https://github.com/RWTH-EBC/AgentLib) developed by the EBC
65
+ and RWTH Aachen and extends the functionality for interacting with the
66
+ FIWARE platform components. The main components allow for:
67
+
68
+ * Device provisioning at the IoT-Agent (JSON)
69
+ * Entity provisioning at the Orion Context Broker
70
+ * Sending and receiving messages from the IoT-Agent (JSON) using MQTT
71
+ * Posting subscriptions to the Orion Context Broker
72
+ * Sending (HTTP) and receiving data (from subscriptions with MQTT notification)
73
+ from the Orion Context Broker
74
+ * Working around JSON-Schema data models and creating devices and context
75
+ entities from these
76
+
77
+ It contains various modules for device provisioning to FIWARE and data transfer
78
+ between field devices and FIWARE.
79
+
80
+ ## Related Projects
81
+
82
+ **juniconnlib\_core** serves as a base library for a multitude of other
83
+ libraries. Most of the other projects work around the integration of different
84
+ protocols and physical devices into the FIWARE architecture. Bundling
85
+ everything that is necessary to communicate with FIWARE felt like a natural
86
+ step, so related projects just need to implement use case specific functionality.
87
+
88
+ Notable related projects are:
89
+
90
+ * OPC UA Agent: A generalized protocol Adapter between OPC UA and FIWARE NGSIv2
91
+ * LoRaWAN Agent: A generalized protocol Adapter between LoRaWAN and FIWARE NGSIv2
92
+ * Messdas Agent: A protocol adapter, that integrates data from the commercial
93
+ MESSDAS software into FIWARE NGSIv2
94
+ * And multiple other protocol converters (e.g. integration of different MODBUS
95
+ devices into the FIWARE platform)
96
+ * [FiLiP](https://github.com/RWTH-EBC/FiLiP): A python API wrapper based on pydantic
97
+ and requests for easy data validation a interaction with the FIWARE components
98
+ * [FiDERe](https://jugit.fz-juelich.de/iek-10/public/ict-platform/fiware-applications/fidere):
99
+ A library for parsing JSON schema data models that represent entities in
100
+ NGSIv2 normalized format, validating data and creating FiLiP compatible
101
+ `ContextEntity` and `Device` objects.
102
+
103
+ ## Documentation
104
+
105
+ Documentation is available at
106
+ https://apps.fz-juelich.de/ice-1/ict-platform/juniconnlib-core and is
107
+ up-to-date with the most recent release. Building and publishing of the
108
+ documentation is done via CI/CD upon tag creation and commits to the `master`
109
+ branch.
110
+
111
+ In addition, you can find a complete demonstration of the intended usage of
112
+ **juniconnlib\_core**
113
+ [here](https://jugit.fz-juelich.de/iek-10/core-projects/llec/juniconnlib/example-agent)
114
+
115
+ ## Installation
116
+
117
+ Clone the repository and into main directory and install
118
+ juniconnlib as package using pip:
119
+
120
+ ```sh
121
+ pip install .
122
+ ```
123
+
124
+ ## Tests
125
+
126
+ Testing is done automatically on commit using CI/CD, including integration
127
+ tests for most things. A dedicated FIWARE cluster is instantiated inside the
128
+ pipeline for that.
129
+
130
+ If you want to run tests locally install the optional dependencies
131
+
132
+ ```shell
133
+ pip install .[test]
134
+ ```
135
+
136
+ and make sure the `ENV` variables are set correctly. You can find an example
137
+ in `./tests/.env_example`. Finally, run using pytest
138
+
139
+ ```shell
140
+ pytest test_*.py
141
+ ```
142
+
143
+ A bit more special is Keycloak. The FIWARE cluster running during each
144
+ pipeline does not include a Keycloak for authentication (as it takes too
145
+ long to start up). Yet still integration tests for Keycloak are available,
146
+ besides the obvious mocked ones.
147
+ The integration tests for Keycloak are marked with `keycloakintegrationtest`
148
+ and if you don't have keycloak credentials or are not using authentication
149
+ at all you can skip these tests by just executing `pytest` without the
150
+ marker:
151
+
152
+ ```sh
153
+ pytest -m "not keycloakintegrationtest"
154
+ ```
155
+
156
+ As an alternative if you don't set a value for the environment variable
157
+ `KEYCLOAK_URL` the integration tests are skipped by default.
158
+ Below you can see an overview of the environment variables used for all the
159
+ integration test.
160
+
161
+ | Name | Default Value | Description |
162
+ |-----------------------------|------------------------------------------------------|---------------------------------------------------------------------------------|
163
+ | `OCB_NOAUTH_URL` | `http://orion:1026` | Orion Context Broker (unauthenticated) URL |
164
+ | `OCB_AUTH_URL` | `http://orion:1026` | Orion Context Broker (authenticated) URL |
165
+ | `IOTA_NOAUTH_URL` | `http://iot-agent-json:4041` | IoT Agent (unauthenticated) URL |
166
+ | `IOTA_AUTH_URL` | `http://iot-agent-json:4041` | IoT Agent (authenticated) URL |
167
+ | `NOAUTH_FIWARE_SERVICE` | `test_service` | FIWARE service header for unauthenticated requests |
168
+ | `NOAUTH_FIWARE_SERVICEPATH` | `/` | FIWARE service path for unauthenticated requests |
169
+ | `AUTH_FIWARE_SERVICE` | `test_auth_service` | FIWARE service header for authenticated requests |
170
+ | `AUTH_FIWARE_SERVICEPATH` | `/` | FIWARE service path for authenticated requests |
171
+ | `KEYCLOAK_URL` | `None` | Keycloak server URL, if not defined `keycloakintegrationtest`s are skipped |
172
+ | `KEYCLOAK_CREDENTIALS_FILE` | `<repo-root>/configs/keycloak_credentials_file.json` | Path to Keycloak credentials JSON file (must contain "username" and "password") |
173
+ | `OCB_CLIENT_ID` | `orion` | Keycloak client ID for Orion Context Broker |
174
+ | `IOTA_CLIENT_ID` | `iot-agent` | Keycloak client ID for IoT Agent |
175
+
176
+ An example for how the content of the Keycloak credentials file should look
177
+ is found in `./tests/config/keycloak_credentials_file.json`.
178
+
179
+ ## Contributing
180
+
181
+ Contributing to **juniconnlib_core**, and its related projects is highly
182
+ appreciated. Contributions can take all kinds of forms, but in general
183
+ everything should be done via this Repository or by contacting
184
+ [ice-1-fiware-admin@fz-juelich.de](mailto:ice-1-fiware-admin@fz-juelich.de?subject=Possible%20Contribution%20to%20Juniconnlib-Core).
185
+ If you are interested in using **juniconnlib_core** or its related project,
186
+ feel free to reach out. In case of bugs or problems, don't be shy on raising
187
+ issues or asking questions.
@@ -0,0 +1,132 @@
1
+ # juniconnlib
2
+
3
+ This python library serves as core library (hence the name `juniconnlib_core`)
4
+ towards connecting all different kinds of components to a FIWARE based
5
+ infrastructure. For an overview of related projects, that are build on top
6
+ of `juniconnlib_core`, take a look at [related projects](#related-projects).
7
+
8
+ The library is built ontop of the framework
9
+ [`AgentLib`](https://github.com/RWTH-EBC/AgentLib) developed by the EBC
10
+ and RWTH Aachen and extends the functionality for interacting with the
11
+ FIWARE platform components. The main components allow for:
12
+
13
+ * Device provisioning at the IoT-Agent (JSON)
14
+ * Entity provisioning at the Orion Context Broker
15
+ * Sending and receiving messages from the IoT-Agent (JSON) using MQTT
16
+ * Posting subscriptions to the Orion Context Broker
17
+ * Sending (HTTP) and receiving data (from subscriptions with MQTT notification)
18
+ from the Orion Context Broker
19
+ * Working around JSON-Schema data models and creating devices and context
20
+ entities from these
21
+
22
+ It contains various modules for device provisioning to FIWARE and data transfer
23
+ between field devices and FIWARE.
24
+
25
+ ## Related Projects
26
+
27
+ **juniconnlib\_core** serves as a base library for a multitude of other
28
+ libraries. Most of the other projects work around the integration of different
29
+ protocols and physical devices into the FIWARE architecture. Bundling
30
+ everything that is necessary to communicate with FIWARE felt like a natural
31
+ step, so related projects just need to implement use case specific functionality.
32
+
33
+ Notable related projects are:
34
+
35
+ * OPC UA Agent: A generalized protocol Adapter between OPC UA and FIWARE NGSIv2
36
+ * LoRaWAN Agent: A generalized protocol Adapter between LoRaWAN and FIWARE NGSIv2
37
+ * Messdas Agent: A protocol adapter, that integrates data from the commercial
38
+ MESSDAS software into FIWARE NGSIv2
39
+ * And multiple other protocol converters (e.g. integration of different MODBUS
40
+ devices into the FIWARE platform)
41
+ * [FiLiP](https://github.com/RWTH-EBC/FiLiP): A python API wrapper based on pydantic
42
+ and requests for easy data validation a interaction with the FIWARE components
43
+ * [FiDERe](https://jugit.fz-juelich.de/iek-10/public/ict-platform/fiware-applications/fidere):
44
+ A library for parsing JSON schema data models that represent entities in
45
+ NGSIv2 normalized format, validating data and creating FiLiP compatible
46
+ `ContextEntity` and `Device` objects.
47
+
48
+ ## Documentation
49
+
50
+ Documentation is available at
51
+ https://apps.fz-juelich.de/ice-1/ict-platform/juniconnlib-core and is
52
+ up-to-date with the most recent release. Building and publishing of the
53
+ documentation is done via CI/CD upon tag creation and commits to the `master`
54
+ branch.
55
+
56
+ In addition, you can find a complete demonstration of the intended usage of
57
+ **juniconnlib\_core**
58
+ [here](https://jugit.fz-juelich.de/iek-10/core-projects/llec/juniconnlib/example-agent)
59
+
60
+ ## Installation
61
+
62
+ Clone the repository and into main directory and install
63
+ juniconnlib as package using pip:
64
+
65
+ ```sh
66
+ pip install .
67
+ ```
68
+
69
+ ## Tests
70
+
71
+ Testing is done automatically on commit using CI/CD, including integration
72
+ tests for most things. A dedicated FIWARE cluster is instantiated inside the
73
+ pipeline for that.
74
+
75
+ If you want to run tests locally install the optional dependencies
76
+
77
+ ```shell
78
+ pip install .[test]
79
+ ```
80
+
81
+ and make sure the `ENV` variables are set correctly. You can find an example
82
+ in `./tests/.env_example`. Finally, run using pytest
83
+
84
+ ```shell
85
+ pytest test_*.py
86
+ ```
87
+
88
+ A bit more special is Keycloak. The FIWARE cluster running during each
89
+ pipeline does not include a Keycloak for authentication (as it takes too
90
+ long to start up). Yet still integration tests for Keycloak are available,
91
+ besides the obvious mocked ones.
92
+ The integration tests for Keycloak are marked with `keycloakintegrationtest`
93
+ and if you don't have keycloak credentials or are not using authentication
94
+ at all you can skip these tests by just executing `pytest` without the
95
+ marker:
96
+
97
+ ```sh
98
+ pytest -m "not keycloakintegrationtest"
99
+ ```
100
+
101
+ As an alternative if you don't set a value for the environment variable
102
+ `KEYCLOAK_URL` the integration tests are skipped by default.
103
+ Below you can see an overview of the environment variables used for all the
104
+ integration test.
105
+
106
+ | Name | Default Value | Description |
107
+ |-----------------------------|------------------------------------------------------|---------------------------------------------------------------------------------|
108
+ | `OCB_NOAUTH_URL` | `http://orion:1026` | Orion Context Broker (unauthenticated) URL |
109
+ | `OCB_AUTH_URL` | `http://orion:1026` | Orion Context Broker (authenticated) URL |
110
+ | `IOTA_NOAUTH_URL` | `http://iot-agent-json:4041` | IoT Agent (unauthenticated) URL |
111
+ | `IOTA_AUTH_URL` | `http://iot-agent-json:4041` | IoT Agent (authenticated) URL |
112
+ | `NOAUTH_FIWARE_SERVICE` | `test_service` | FIWARE service header for unauthenticated requests |
113
+ | `NOAUTH_FIWARE_SERVICEPATH` | `/` | FIWARE service path for unauthenticated requests |
114
+ | `AUTH_FIWARE_SERVICE` | `test_auth_service` | FIWARE service header for authenticated requests |
115
+ | `AUTH_FIWARE_SERVICEPATH` | `/` | FIWARE service path for authenticated requests |
116
+ | `KEYCLOAK_URL` | `None` | Keycloak server URL, if not defined `keycloakintegrationtest`s are skipped |
117
+ | `KEYCLOAK_CREDENTIALS_FILE` | `<repo-root>/configs/keycloak_credentials_file.json` | Path to Keycloak credentials JSON file (must contain "username" and "password") |
118
+ | `OCB_CLIENT_ID` | `orion` | Keycloak client ID for Orion Context Broker |
119
+ | `IOTA_CLIENT_ID` | `iot-agent` | Keycloak client ID for IoT Agent |
120
+
121
+ An example for how the content of the Keycloak credentials file should look
122
+ is found in `./tests/config/keycloak_credentials_file.json`.
123
+
124
+ ## Contributing
125
+
126
+ Contributing to **juniconnlib_core**, and its related projects is highly
127
+ appreciated. Contributions can take all kinds of forms, but in general
128
+ everything should be done via this Repository or by contacting
129
+ [ice-1-fiware-admin@fz-juelich.de](mailto:ice-1-fiware-admin@fz-juelich.de?subject=Possible%20Contribution%20to%20Juniconnlib-Core).
130
+ If you are interested in using **juniconnlib_core** or its related project,
131
+ feel free to reach out. In case of bugs or problems, don't be shy on raising
132
+ issues or asking questions.
@@ -0,0 +1,63 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 75.0", "setuptools_scm >= 8.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "juniconnlib-core"
7
+ dynamic = ["version"]
8
+ dependencies = [
9
+ "pydantic",
10
+ "paho-mqtt~=2.0.0",
11
+ "requests~=2.32.0",
12
+ "httpx~=0.27.2",
13
+ "filip",
14
+ "agentlib~=0.8.2",
15
+ "fidere",
16
+ "influxdb-client~=1.47.0",
17
+ "semantic_version"
18
+ ]
19
+ requires-python = ">=3.11"
20
+ authors = [
21
+ { name = "ICE-1, Forschungszentrum Juelich GmbH", email = "ice-1-fiware-admin@fz-juelich.de" },
22
+ ]
23
+ maintainers = [
24
+ { name = "Sascha Johnen", email = "sa.johnen@fz-juelich.de" },
25
+ { name = "Marcel Schroeder", email = "m.schroeder@fz-juelich.de" },
26
+ { name = "Jana Pick", email = "j.pick@fz-juelich.de" },
27
+ ]
28
+ description = "Core library for FIWARE adpater agents based on EBC AgentLib."
29
+ readme = "README.md"
30
+ license = { file = "LICENSE" }
31
+ keywords = ["FIWARE", "ICE-1", "ICT Platform", "AgentLib"]
32
+ classifiers = [
33
+ "Programming Language :: Python :: 3",
34
+ "Programming Language :: Python :: 3.11",
35
+ "Programming Language :: Python :: 3.12",
36
+ "Operating System :: OS Independent",
37
+ ]
38
+
39
+ [tool.setuptools_scm]
40
+ version_file = "src/juniconnlib_core/_version.py"
41
+ fallback_version = "0.0.0" # Only needed if no version has been released yet
42
+
43
+ [project.optional-dependencies]
44
+ test = [
45
+ "pytest==8.3.4",
46
+ "pytest-mock~=3.14.0",
47
+ ]
48
+ doc = [
49
+ "sphinx~=8.0.2",
50
+ "sphinx-versioned-docs~=1.4.0",
51
+ "sphinx_rtd_theme~=3.0.2",
52
+ "sphinx-autodoc-typehints~=2.5.0",
53
+ "sphinxcontrib-napoleon~=0.7",
54
+ "autodoc_pydantic~=2.2.0",
55
+ "myst-parser~=4.0.1",
56
+ ]
57
+
58
+ [project.urls]
59
+ Homepage = "https://jugit.fz-juelich.de/iek-10/public/ict-platform/fiware-applications/juniconnlib-core"
60
+ Documentation = "https://apps.fz-juelich.de/ice-1/ict-platform/juniconnlib-core/"
61
+ Repository = "https://jugit.fz-juelich.de/iek-10/public/ict-platform/fiware-applications/juniconnlib-core"
62
+ Issues = "https://jugit.fz-juelich.de/iek-10/public/ict-platform/fiware-applications/juniconnlib-core/-/issues"
63
+ # Changelog = ""
@@ -0,0 +1,12 @@
1
+ [lint]
2
+ exclude = ["docs/*", "examples/*"]
3
+
4
+ [lint.extend-per-file-ignores]
5
+ # Ignore 'Redefinition of unused *' and '* imported but unused'
6
+ # -> occurs when importing fixtures as they are recognized as modules in import but as variables when used
7
+ # - https://github.com/astral-sh/ruff/issues/3295
8
+ # - https://github.com/astral-sh/ruff/issues/4046
9
+ # - https://github.com/astral-sh/ruff/issues/10662
10
+ "tests/test_ocb_communicator.py" = ["F811", "F401"]
11
+ "tests/test_int_ocb_communicators.py" = ["F811", "F401"]
12
+ "tests/test_int_subscription_handler.py" = ["F811", "F401"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+