Fix using value mapping from zabbix, closes #1222

This commit is contained in:
Alexander Zobnin
2021-08-10 13:41:56 +03:00
parent 8efc020f33
commit 00e33fcc49
5 changed files with 72 additions and 6 deletions

View File

@@ -397,6 +397,22 @@ func (ds *Zabbix) GetAllGroups(ctx context.Context) ([]Group, error) {
return groups, err
}
func (ds *Zabbix) GetValueMappings(ctx context.Context) ([]ValueMap, error) {
params := ZabbixAPIParams{
"output": "extend",
"selectMappings": "extend",
}
result, err := ds.Request(ctx, &ZabbixAPIRequest{Method: "valuemap.get", Params: params})
if err != nil {
return nil, err
}
var valuemaps []ValueMap
err = convertTo(result, &valuemaps)
return valuemaps, err
}
func (ds *Zabbix) GetVersion(ctx context.Context) (int, error) {
result, err := ds.request(ctx, "apiinfo.version", ZabbixAPIParams{})
if err != nil {

View File

@@ -99,3 +99,14 @@ type Application struct {
Name string `json:"name"`
ID string `json:"applicationid"`
}
type ValueMap struct {
ID string `json:"valuemapid"`
Name string `json:"name"`
Mappings []ValueMapping `json:"mappings"`
}
type ValueMapping struct {
Value string `json:"value"`
NewValue string `json:"newvalue"`
}