-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathmetadata.go
50 lines (42 loc) · 933 Bytes
/
metadata.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package anomaly
import (
"github.com/project-flogo/core/data/coerce"
)
type Settings struct {
Depth int `md:"depth"`
}
type Input struct {
Payload interface{} `md:"payload"`
}
func (r *Input) FromMap(values map[string]interface{}) error {
r.Payload = values["payload"]
return nil
}
func (r *Input) ToMap() map[string]interface{} {
return map[string]interface{}{
"payload": r.Payload,
}
}
type Output struct {
Complexity float32 `md:"complexity"`
Count int `"md:"count`
}
func (o *Output) FromMap(values map[string]interface{}) error {
complexity, err := coerce.ToFloat32(values["complexity"])
if err != nil {
return err
}
o.Complexity = complexity
count, err := coerce.ToInt(values["count"])
if err != nil {
return err
}
o.Count = count
return nil
}
func (o *Output) ToMap() map[string]interface{} {
return map[string]interface{}{
"complexity": o.Complexity,
"count": o.Count,
}
}