SHM API Transport¶
io ¶
API client for the shm extension.
This module exposes :class:ShmAPI as the low-level entry point
for SHM transport and persistence helpers.
Examples:
Classes¶
ShmEndpoints
dataclass
¶
ShmEndpoints(
api_subdir="/shm/routes/",
sensor_type="sensortype",
sensor="sensor",
sensor_calibration="sensorcalibration",
signal="signal",
signal_history="signalhistory",
signal_calibration="signalcalibration",
derived_signal="derivedsignal",
derived_signal_history="derivedsignalhistory",
derived_signal_calibration="derivedsignalcalibration",
)
ShmAPI ¶
Bases: API
Low-level API client for the SHM extension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_subdir
|
str
|
API sub-path appended to the base root. |
"/shm/routes/"
|
**kwargs
|
Any
|
Forwarded to :class: |
{}
|
Examples:
Source code in src/owi/metadatabase/shm/io.py
Functions¶
ping ¶
Return a basic health response.
Examples:
get_signal ¶
Return a single SHM signal by its backend signal identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal_id
|
str
|
Backend-facing SHM signal identifier. |
required |
**kwargs
|
QueryValue
|
Additional query parameters forwarded to the SHM route. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parent-SDK-style result dictionary containing |
Examples:
>>> from unittest.mock import patch
>>> api = ShmAPI(token="dummy")
>>> with patch.object(
... ShmAPI,
... "process_data",
... return_value=(pd.DataFrame([{"id": 7, "signal_id": "SG-01"}]), {"existance": True, "id": 7}),
... ):
... result = api.get_signal("SG-01")
>>> result["id"]
7
Source code in src/owi/metadatabase/shm/io.py
get_sensor_type ¶
Return a single SHM sensor type by query parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
QueryValue
|
Query parameters forwarded to the SHM sensor-type route. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parent-SDK-style result dictionary containing |
Source code in src/owi/metadatabase/shm/io.py
get_sensor ¶
Return a single SHM sensor by query parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
QueryValue
|
Query parameters forwarded to the SHM sensor route. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parent-SDK-style result dictionary containing |
Source code in src/owi/metadatabase/shm/io.py
get_sensor_calibration ¶
Return a single SHM sensor calibration by query parameters.
get_signal_history ¶
Return a single SHM signal history row by query parameters.
get_signal_calibration ¶
Return a single SHM signal calibration by query parameters.
get_derived_signal ¶
Return a single SHM derived signal by query parameters.
get_derived_signal_history ¶
Return a single SHM derived signal history row by query parameters.
get_derived_signal_calibration ¶
Return a single SHM derived signal calibration by query parameters.
create_signal ¶
Create a signal record.
Examples:
>>> from unittest.mock import patch
>>> api = ShmAPI(token="dummy")
>>> with patch.object(ShmAPI, "_mutate_resource", return_value={"id": 12, "exists": True}) as mocker:
... result = api.create_signal({"signal_id": "SG-01"})
>>> mocker.assert_called_once_with(api.endpoints.signal, {"signal_id": "SG-01"})
>>> result["id"]
12
Source code in src/owi/metadatabase/shm/io.py
create_signal_history ¶
create_signal_calibration ¶
create_derived_signal ¶
create_derived_signal_history ¶
Create a derived signal history record.
patch_derived_signal_history ¶
Patch a derived signal history record by id.
Source code in src/owi/metadatabase/shm/io.py
create_derived_signal_calibration ¶
Create a derived signal calibration record.
list_sensor_types ¶
Return all SHM sensor types matching the query parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
QueryValue
|
Query parameters forwarded to the sensor-type list route. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parent-SDK-style result dictionary containing |
Source code in src/owi/metadatabase/shm/io.py
list_sensors ¶
Return all SHM sensors matching the query parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
QueryValue
|
Query parameters forwarded to the sensor list route. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parent-SDK-style result dictionary containing |
Source code in src/owi/metadatabase/shm/io.py
list_sensor_calibrations ¶
Return all SHM sensor calibrations matching the query parameters.
list_signals ¶
list_signal_history ¶
Return all SHM signal history rows matching the query parameters.
list_signal_calibrations ¶
Return all SHM signal calibrations matching the query parameters.
list_derived_signals ¶
Return all SHM derived signals matching the query parameters.
list_derived_signal_history ¶
Return all SHM derived signal history rows matching the query parameters.
list_derived_signal_calibrations ¶
Return all SHM derived signal calibrations matching the query parameters.
Source code in src/owi/metadatabase/shm/io.py
create_sensor_type ¶
Create a sensor type record, optionally with an image attachment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Mapping[str, Any]
|
Form fields for the sensor type resource. |
required |
files
|
Mapping[str, Any] | None
|
Optional file mapping (e.g. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parent-SDK-style result dictionary. |
Source code in src/owi/metadatabase/shm/io.py
create_sensor ¶
Create a sensor record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Mapping[str, Any]
|
JSON payload for the sensor resource. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parent-SDK-style result dictionary. |
Source code in src/owi/metadatabase/shm/io.py
create_sensor_calibration ¶
Create a sensor calibration record, optionally with a PDF attachment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Mapping[str, Any]
|
Form fields for the sensor calibration resource. |
required |
files
|
Mapping[str, Any] | None
|
Optional file mapping (e.g. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parent-SDK-style result dictionary. |