-
Notifications
You must be signed in to change notification settings - Fork 20
/
interface-type.go
64 lines (51 loc) · 1.74 KB
/
interface-type.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package tosca_v2_0
import (
"github.com/tliron/puccini/tosca"
)
//
// InterfaceType
//
// [TOSCA-v2.0] @ ?
// [TOSCA-Simple-Profile-YAML-v1.3] @ 3.7.5
// [TOSCA-Simple-Profile-YAML-v1.2] @ 3.7.5
// [TOSCA-Simple-Profile-YAML-v1.1] @ 3.6.5
// [TOSCA-Simple-Profile-YAML-v1.0] @ 3.6.4
//
type InterfaceType struct {
*Type `name:"interface type"`
InputDefinitions PropertyDefinitions `read:"inputs,PropertyDefinition" inherit:"inputs,Parent"`
OperationDefinitions OperationDefinitions `read:"operations,OperationDefinition" inherit:"operations,Parent"`
NotificationDefinitions NotificationDefinitions `read:"notifications,NotificationDefinition" inherit:"notifications,Parent"` // introduced in TOSCA 1.3
Parent *InterfaceType `lookup:"derived_from,ParentName" json:"-" yaml:"-"`
}
func NewInterfaceType(context *tosca.Context) *InterfaceType {
return &InterfaceType{
Type: NewType(context),
InputDefinitions: make(PropertyDefinitions),
OperationDefinitions: make(OperationDefinitions),
NotificationDefinitions: make(NotificationDefinitions),
}
}
// tosca.Reader signature
func ReadInterfaceType(context *tosca.Context) tosca.EntityPtr {
self := NewInterfaceType(context)
context.ValidateUnsupportedFields(context.ReadFields(self))
return self
}
// tosca.Hierarchical interface
func (self *InterfaceType) GetParent() tosca.EntityPtr {
return self.Parent
}
// tosca.Inherits interface
func (self *InterfaceType) Inherit() {
logInherit.Debugf("interface type: %s", self.Name)
if self.Parent == nil {
return
}
self.InputDefinitions.Inherit(self.Parent.InputDefinitions)
self.OperationDefinitions.Inherit(self.Parent.OperationDefinitions)
}
//
// InterfaceTypes
//
type InterfaceTypes []*InterfaceType