You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/greendigit_cim_messenger.rst
+34-35Lines changed: 34 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,63 +7,62 @@ energy consumption metrics in cASO.
7
7
Overview
8
8
--------
9
9
10
-
The GreenDIGIT CIM messenger sends `EnergyRecord` objects to the GreenDIGIT
10
+
The GreenDIGIT CIM messenger sends ``EnergyRecord`` objects to the GreenDIGIT
11
11
Common Information Model (CIM) Service. The messenger supports authentication
12
12
via bearer token and allows publishing energy consumption data from cASO extractors
13
13
to SZTAKI CIM endpoints.
14
14
15
-
Additionally, the messenger verifies SSL certificates and endpoint availability
15
+
Additionally, the messenger verifies SSL certificates and endpoint availability
16
16
before publishing to ensure reliability in production environments.
17
17
18
18
Configuration
19
19
-------------
20
20
21
21
To use the GreenDIGIT CIM messenger, add the following configuration to your
22
-
`caso.conf` file:
22
+
``caso.conf`` file:
23
23
24
-
```ini
25
-
[DEFAULT]
26
-
# Add the messenger to your list of messengers
27
-
messengers = greendigit_cim
24
+
.. code-block:: ini
28
25
29
-
[greendigit_cim]
30
-
# Base URL of SZTAKI GreenDIGIT CIM Service.
31
-
# Specific endpoints for authentication (/gd-cim-api/v1/token) and publishing (/gd-cim-api/v1/submit)
32
-
# will be constructed internally by the messenger.
33
-
base_url = https://greendigit-cim.sztaki.hu
26
+
[DEFAULT]
27
+
# Add the messenger to your list of messengers
28
+
messengers = greendigit_cim
34
29
35
-
# Credentials used to obtain the bearer token
36
-
email = user@example.org
37
-
password = secret-password
30
+
[greendigit_cim]
31
+
# Base URL of SZTAKI GreenDIGIT CIM Service.
32
+
# Specific endpoints for authentication (/gd-cim-api/v1/token) and publishing (/gd-cim-api/v1/submit)
33
+
# will be constructed internally by the messenger.
34
+
base_url = https://greendigit-cim.sztaki.hu
38
35
39
-
# SSL verification (recommended for production)
40
-
verify_ssl = true
36
+
# Credentials used to obtain the bearer token
37
+
email = user@example.org
38
+
password = secret-password
41
39
42
-
[messenger_greendigit_cim]
43
-
# Only energy records will be published to this messenger
44
-
record_types = energy
45
-
```
40
+
# SSL verification (recommended for production)
41
+
verify_ssl = true
42
+
43
+
[messenger_greendigit_cim]
44
+
# Only energy records will be published to this messenger
45
+
record_types = energy
46
46
47
47
How it Works
48
48
------------
49
49
50
50
The GreenDIGIT CIM messenger performs the following steps:
51
51
52
52
1. **Verify Endpoints**: Checks that the authentication and publishing endpoints are reachable and that SSL certificates are valid.
53
-
2. **Authenticate**: Uses the configured base URL and the credentials provided in caso.conf
54
-
to obtain a bearer token from `/gd-cim-api/v1/token`.
55
-
3. **Serialize Records**: Converts `EnergyRecord` objects to JSON using field mappings consistent with cASO standards.
56
-
4. **Publish Records**: Sends the JSON payload to `/gd-cim-api/v1/submit` via HTTP POST with the bearer token in the Authorization header.
57
-
5. **Logging:** Records the number of published records and HTTP response status.
53
+
2. **Authenticate**: Uses the configured base URL and the credentials provided in ``caso.conf`` to obtain a bearer token from ``/gd-cim-api/v1/token``.
54
+
3. **Serialize Records**: Converts ``EnergyRecord`` objects to JSON using field mappings consistent with cASO standards.
55
+
4. **Publish Records**: Sends the JSON payload to ``/gd-cim-api/v1/submit`` via HTTP POST with the bearer token in the ``Authorization`` header.
56
+
5. **Logging**: Records the number of published records and HTTP response status.
58
57
59
58
Testing
60
59
-------
61
60
62
61
To test the messenger:
63
62
64
63
1. Verify that the SZTAKI CIM endpoints are reachable from the host running cASO.
65
-
2. EEnsure the credentials are correctly set in `caso.conf`.
66
-
3. Run cASO in `--dry-run` mode to preview `EnergyRecord` objects without publishing.
64
+
2. Ensure the credentials are correctly set in ``caso.conf``.
65
+
3. Run cASO in ``--dry-run`` mode to preview ``EnergyRecord`` objects without publishing.
67
66
4. Check logs for successful publication messages or errors.
68
67
69
68
Troubleshooting
@@ -72,25 +71,25 @@ Troubleshooting
72
71
**Authentication errors:**
73
72
74
73
- Ensure credentials are correct.
75
-
- Verify network connectivity to base URL.
76
-
- Ensure the endpoint accepts GET requests.
74
+
- Verify network connectivity to ``base_url``.
75
+
- Ensure the authentication endpoint is reachable.
77
76
78
77
**Publishing errors:**
79
78
80
79
- Check that the publish endpoint is reachable.
81
-
- Validate that JSON serialization of `EnergyRecord` is correct.
80
+
- Validate that JSON serialization of ``EnergyRecord`` is correct.
82
81
- Review HTTP status codes in logs for hints.
83
82
84
83
**No records published:**
85
84
86
-
- Ensure extractors have generated `EnergyRecord` objects.
87
-
- Confirm that the messenger is listed in `messengers` in `[DEFAULT]` section.
85
+
- Ensure extractors have generated ``EnergyRecord`` objects.
86
+
- Confirm that the messenger is listed in ``messengers`` in the ``[DEFAULT]`` section.
88
87
89
88
Technical Details
90
89
-----------------
91
90
92
91
- Uses bearer token authentication.
93
-
- Records are serialized using `model_dump_json` with aliases and excluding `None` values.
94
-
- HTTP POST to `/gd-cim-api/submit` includes a JSON array of `EnergyRecord` objects.
92
+
- Records are serialized using ``model_dump_json`` with aliases and excluding ``None`` values.
93
+
- HTTP POST to ``/gd-cim-api/v1/submit`` includes a JSON array of ``EnergyRecord`` objects.
95
94
- Verifies SSL and endpoint availability before publishing.
96
95
- Logs the number of records sent and HTTP response status.
0 commit comments