Serve event contraints via API

This commit is contained in:
Denis Arh
2021-03-18 08:20:55 +01:00
parent 85c5ac4943
commit 261ad71460
11 changed files with 1167 additions and 37 deletions
@@ -4,14 +4,10 @@ package rest
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// {{ .Source }}
func getEventTypeDefinitions() []eventTypeDef {
return []eventTypeDef{
{{ range .Definitions }}
// {{ printf "%#v" .Imports }}
{{ range $r := .Resources }}
{{ template "eventTypeDefinitions" dict "res" $r "type" "on" "types" .On }}
{{ template "eventTypeDefinitions" dict "res" $r "type" "before" "types" .BeforeAfter }}
@@ -37,6 +33,13 @@ func getEventTypeDefinitions() []eventTypeDef {
{{ end }}
{{ end }}
},
Constraints: []eventTypeConstraintDef{
{{ range $.res.Constraints }}
{
Name: {{ printf "%q" .Name }},
},
{{ end }}
},
},
{{ end }}
{{ end }}
+9 -4
View File
@@ -38,10 +38,11 @@ type (
// used for filename
ResourceFile string
On []string `yaml:"on"`
BeforeAfter []string `yaml:"ba"`
Properties []*eventProps `yaml:"props"`
Result string `yaml:"result"`
On []string `yaml:"on"`
BeforeAfter []string `yaml:"ba"`
Properties []*eventProps `yaml:"props"`
Constraints []*eventConstraint `yaml:"constraints"`
Result string `yaml:"result"`
}
eventProps struct {
@@ -58,6 +59,10 @@ type (
// Do not allow change of the variable through
Immutable bool
}
eventConstraint struct {
Name string
}
)
func procEvents(mm ...string) (dd []*eventsDef, err error) {