mirror of
https://github.com/ClusterCockpit/cc-metric-store.git
synced 2024-12-27 09:19:06 +01:00
Make type-ids strings
This commit is contained in:
parent
db099605ec
commit
5f8fc36b5f
30
api.go
30
api.go
@ -194,14 +194,14 @@ type ApiQueryResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ApiQuery struct {
|
type ApiQuery struct {
|
||||||
Metric string `json:"metric"`
|
Metric string `json:"metric"`
|
||||||
Hostname string `json:"host"`
|
Hostname string `json:"host"`
|
||||||
Aggregate bool `json:"aggreg"`
|
Aggregate bool `json:"aggreg"`
|
||||||
ScaleFactor Float `json:"scale-by,omitempty"`
|
ScaleFactor Float `json:"scale-by,omitempty"`
|
||||||
Type *string `json:"type,omitempty"`
|
Type *string `json:"type,omitempty"`
|
||||||
TypeIds []int `json:"type-ids,omitempty"`
|
TypeIds []string `json:"type-ids,omitempty"`
|
||||||
SubType *string `json:"subtype,omitempty"`
|
SubType *string `json:"subtype,omitempty"`
|
||||||
SubTypeIds []int `json:"subtype-ids,omitempty"`
|
SubTypeIds []string `json:"subtype-ids,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleQuery(rw http.ResponseWriter, r *http.Request) {
|
func handleQuery(rw http.ResponseWriter, r *http.Request) {
|
||||||
@ -235,22 +235,22 @@ func handleQuery(rw http.ResponseWriter, r *http.Request) {
|
|||||||
sel := Selector{{String: req.Cluster}, {String: query.Hostname}}
|
sel := Selector{{String: req.Cluster}, {String: query.Hostname}}
|
||||||
if query.Type != nil {
|
if query.Type != nil {
|
||||||
if len(query.TypeIds) == 1 {
|
if len(query.TypeIds) == 1 {
|
||||||
sel = append(sel, SelectorElement{String: fmt.Sprintf("%s%d", *query.Type, query.TypeIds[0])})
|
sel = append(sel, SelectorElement{String: *query.Type + query.TypeIds[0]})
|
||||||
} else {
|
} else {
|
||||||
ids := make([]string, len(query.TypeIds))
|
ids := make([]string, len(query.TypeIds))
|
||||||
for i, id := range query.TypeIds {
|
for i, id := range query.TypeIds {
|
||||||
ids[i] = fmt.Sprintf("%s%d", *query.Type, id)
|
ids[i] = *query.Type + id
|
||||||
}
|
}
|
||||||
sel = append(sel, SelectorElement{Group: ids})
|
sel = append(sel, SelectorElement{Group: ids})
|
||||||
}
|
}
|
||||||
|
|
||||||
if query.SubType != nil {
|
if query.SubType != nil {
|
||||||
if len(query.SubTypeIds) == 1 {
|
if len(query.SubTypeIds) == 1 {
|
||||||
sel = append(sel, SelectorElement{String: fmt.Sprintf("%s%d", *query.SubType, query.SubTypeIds[0])})
|
sel = append(sel, SelectorElement{String: *query.SubType + query.SubTypeIds[0]})
|
||||||
} else {
|
} else {
|
||||||
ids := make([]string, len(query.SubTypeIds))
|
ids := make([]string, len(query.SubTypeIds))
|
||||||
for i, id := range query.SubTypeIds {
|
for i, id := range query.SubTypeIds {
|
||||||
ids[i] = fmt.Sprintf("%s%d", *query.SubType, id)
|
ids[i] = *query.SubType + id
|
||||||
}
|
}
|
||||||
sel = append(sel, SelectorElement{Group: ids})
|
sel = append(sel, SelectorElement{Group: ids})
|
||||||
}
|
}
|
||||||
@ -263,14 +263,14 @@ func handleQuery(rw http.ResponseWriter, r *http.Request) {
|
|||||||
for _, subTypeId := range query.SubTypeIds {
|
for _, subTypeId := range query.SubTypeIds {
|
||||||
sels = append(sels, Selector{
|
sels = append(sels, Selector{
|
||||||
{String: req.Cluster}, {String: query.Hostname},
|
{String: req.Cluster}, {String: query.Hostname},
|
||||||
{String: fmt.Sprintf("%s%d", *query.Type, typeId)},
|
{String: *query.Type + typeId},
|
||||||
{String: fmt.Sprintf("%s%d", *query.SubType, subTypeId)}})
|
{String: *query.SubType + subTypeId}})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sels = append(sels, Selector{
|
sels = append(sels, Selector{
|
||||||
{String: req.Cluster},
|
{String: req.Cluster},
|
||||||
{String: query.Hostname},
|
{String: query.Hostname},
|
||||||
{String: fmt.Sprintf("%s%d", *query.Type, typeId)}})
|
{String: *query.Type + typeId}})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ components:
|
|||||||
type-ids:
|
type-ids:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: integer
|
type: string
|
||||||
aggreg:
|
aggreg:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: 'If true, every query result will have exactly one element. Otherwise, the data for every requested type-id/sub-type-id is provided seperately'
|
description: 'If true, every query result will have exactly one element. Otherwise, the data for every requested type-id/sub-type-id is provided seperately'
|
||||||
|
Loading…
Reference in New Issue
Block a user