fix(influxdb): label mappings reference label ID, resource ID, and resource type now
parent
ead0cb3dcf
commit
72679393b9
14
label.go
14
label.go
|
@ -67,18 +67,28 @@ func (l *Label) Validate() error {
|
|||
// LabelMapping is used to map resource to its labels.
|
||||
// It should not be shared directly over the HTTP API.
|
||||
type LabelMapping struct {
|
||||
LabelID *ID `json:"labelID"`
|
||||
ResourceID *ID
|
||||
LabelID ID `json:"labelID"`
|
||||
ResourceID ID
|
||||
ResourceType
|
||||
}
|
||||
|
||||
// Validate returns an error if the mapping is invalid.
|
||||
func (l *LabelMapping) Validate() error {
|
||||
|
||||
// todo(leodido) > check LabelID is valid too?
|
||||
|
||||
if !l.ResourceID.Valid() {
|
||||
return &Error{
|
||||
Code: EInvalid,
|
||||
Msg: "resourceID is required",
|
||||
}
|
||||
}
|
||||
if err := l.ResourceType.Valid(); err != nil {
|
||||
return &Error{
|
||||
Code: EInvalid,
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue