Help us shape the future of Go! Take the 2026 Go Developer Survey

mdai-gateway

module
v0.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2026 License: AGPL-3.0

README

Chores codecov Artifact Hub

MDAI Gateway

INSTALL

helm upgrade --install --create-namespace --namespace mdai mdai-gateway ./deployment

testdata contains

  • JSON POST bodies (to simulate data from Alert Manager)

To simulate an alert via curl

curl -X POST -H "Content-Type: application/json" -d@testdata/alert_test.json http://localhost:8081/alerts/alertmanager
curl -X POST -H "Content-Type: application/json" -d@testdata/alert_top_talkers.json http://localhost:8081/alerts/alertmanager
curl -X POST -H "Content-Type: application/json" -d@testdata/alert_anomalous_error_rate.json http://localhost:8081/alerts/alertmanager

To simulate a manual var update event via curl

Only manual variables can be updated or deleted. The sample hub below exposes manual variables such as data_string, data_boolean, data_int, data_set, and data_map.

Add to string:

curl -X POST -H "Content-Type: application/json" -d@testdata/var-test.json \
  http://localhost:8081/variables/hub/mdaihub-sample/var/data_string

Remove from string:

curl -X DELETE -H "Content-Type: application/json" -d@testdata/var-test-empty.json \
  http://localhost:8081/variables/hub/mdaihub-sample/var/data_string

Add to set:

curl -X POST -H "Content-Type: application/json" -d@testdata/var-test-set.json \
  http://localhost:8081/variables/hub/mdaihub-sample/var/data_set

Remove from set:

curl -X DELETE -H "Content-Type: application/json" -d@testdata/var-test-set.json \
  http://localhost:8081/variables/hub/mdaihub-sample/var/data_set

Add to map:

curl -X POST -H "Content-Type: application/json" -d@testdata/var-test-map.json \
  http://localhost:8081/variables/hub/mdaihub-sample/var/data_map

Remove from map:

curl -X DELETE -H "Content-Type: application/json" -d@testdata/var-test-map-delete.json \
  http://localhost:8081/variables/hub/mdaihub-sample/var/data_map

API

Variables Schema API

List variables
All hubs

request:

GET /variables/list

response:

{hubName:{variableName: schema}}

example:

{
  "mdaihub-sample": {
    "data_string": {
      "type": "manual",
      "dataType": "string",
      "storageType": "mdai-valkey",
      "serializeAs": [{"name": "DATA_STRING"}]
    },
    "computed_string": {
      "type": "computed",
      "dataType": "string",
      "storageType": "mdai-valkey",
      "serializeAs": [{"name": "COMPUTED_STRING"}]
    },
    "meta_priority_list": {
      "type": "meta",
      "dataType": "metaPriorityList",
      "storageType": "mdai-valkey",
      "variableRefs": ["data_string", "data_set"],
      "serializeAs": [{"name": "META_PRIORITY_LIST"}]
    }
  }
}
Given hub

request:

GET /variables/list/hub/{hubName}

response:

{variableName: schema}

example:

{
  "data_boolean": {
    "type": "manual",
    "dataType": "boolean",
    "storageType": "mdai-valkey",
    "serializeAs": [{"name": "DATA_BOOLEAN"}]
  },
  "meta_hash_set": {
    "type": "meta",
    "dataType": "metaHashSet",
    "storageType": "mdai-valkey",
    "variableRefs": ["data_string", "data_set"],
    "serializeAs": [{"name": "META_HASH_SET"}]
  }
}
Get variable value(s)
All values for a hub

request:

GET /variables/values/hub/{hubName}

response:

{
  "data_string": "string value",
  "data_boolean": true,
  "data_int": 123,
  "data_set": ["service1", "service2"],
  "data_map": {"attrib.111": "value.111"},
  "computed_string": "derived value",
  "meta_hash_set": "service|critical",
  "meta_priority_list": ["default", "service_list"]
}
Single variable

request:

GET /variables/values/hub/{hubName}/var/{varName}

response:

{"data_string":"string value"}
{"data_boolean":true}
{"data_int":123}
{"data_set":["service1","service2"]}
{"data_map":{"attrib.111":"value.111","attrib.222":"value.222"}}
{"meta_hash_set":"service|critical"}
{"meta_priority_list":["default","service_list"]}
{"computed_string":"derived value"}

If the variable exists in the schema but has neither a stored value nor a declared default, the API returns 404 Not Found with body "variable has no value". The bulk endpoint (GET /variables/values/hub/{hubName}) keeps the {name: null} shape for absent variables so the response covers every declared variable in one map.

Set variable value(s)

request:

POST /variables/hub/{hubName}/var/{varName}

Only variables with type manual can be updated. Computed and meta variables return 409 Conflict with:

"only manual variables can be updated or deleted"
payloads:

string:

{"data": variableValue}

examples: {"data": "string_value"}

boolean:

{"data": variableValue}

examples: {"data": true}

integer:

{"data": variableValue}

examples: {"data": 123}

set:

{"data":[elementValue]}

example: {"data":["service1", "service2"]}

map:

{"data":{elementKey: elementValue}}

example: {"data":{"attrib.111": "value.111", "attrib.222": "value.222"}}

Delete variable value(s)

request:

DELETE /variables/hub/{hubName}/var/{varName}

Only variables with schema type: "manual" can be deleted. Computed and meta variables return 409 Conflict with:

"only manual variables can be updated or deleted"

DELETE means different things depending on the variable's dataType:

dataType Semantics Body
string, int, float, boolean Whole-key removal. The variable's stored value is deleted; subsequent reads fall back to the declared default (if any) or return 404. Not required. Any JSON body sent is ignored.
set Element-level SREM. Removes the listed elements from the stored set. The set itself is removed by Valkey only when its last element is removed. Required: {"data": ["elementValue", …]}.
map Element-level HDEL. Removes the listed keys from the stored hash. The hash itself is removed by Valkey only when its last key is removed. Required: {"data": ["elementKey", …]}.

There is no whole-key delete for set or map via this endpoint — to clear a collection entirely, remove its elements.

Examples

Scalars (no body needed):

DELETE /variables/hub/my-hub/var/sampling_rate
DELETE /variables/hub/my-hub/var/enabled

Set (element-level):

DELETE /variables/hub/my-hub/var/services
{"data": ["service1", "service2"]}

Map (element-level):

DELETE /variables/hub/my-hub/var/attribs
{"data": ["attrib.111", "attrib.222"]}

Directories

Path Synopsis
cmd
mdai-gateway command
internal
mock
Package mock and its sub packages contains mocks that will be used for testing purposes.
Package mock and its sub packages contains mocks that will be used for testing purposes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL