-
Notifications
You must be signed in to change notification settings - Fork 1
/
complex-types.yaml
158 lines (150 loc) · 4.96 KB
/
complex-types.yaml
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# YANG complex-types Specifications
# The YANG complex-types module provides additional language
# extensions according to [RFC
# 6095](http://tools.ietf.org/html/rfc6095). These extensions provide
# mechanisms to manage the `complex-type` schema definitions which
# essentially allows a given YANG data schema module to describe more
# than one data models and to build relationships between the data
# models.
specification:
complex-types:
extension:
complex-type:
scope:
abstract: 0..1
container: 0..n
description: 0..1
extends: 0..1
grouping: 0..n
if-feature: 0..n
key: 0..1
instance: 0..n
instance-list: 0..n
leaf: 0..n
leaf-list: 0..n
reference: 0..1
refine: 0..n
uses: 0..n
parent-scope:
module: 0..n
submodule: 0..n
preprocess: !coffee/function |
(arg, params, ctx) ->
synth = @resolve 'synthesizer'
@define 'complex-type', arg, switch
when params.extends?
ctype = params.extends
delete params.extends
delete params.key if (ctype.get 'key')?
(synth ctype) params, -> @set name: arg
else
synth.Model params, -> @set name: arg
construct: !coffee/function |
(arg, params, children) ->
ct = (@resolve 'complex-type', arg)
if children.type?
ct.bind (children.type.get 'bindings')
delete children.type
ct.bind children
for target, changes of params.refine
target = target.replace '/','.'
ct.rebind target, (prev) -> prev.merge changes
null
abstract:
extends:
scope:
description: 0..1
reference: 0..1
status: 0..1
preprocess: !coffee/function |
(arg, params, ctx) ->
ctx.extends = @resolve 'complex-type', arg
unless ctx.extends?
throw @error "unable to resolve dependent complex-type '#{arg}'", 'extends'
construct: !coffee/function |
(arg, params, children, ctx) ->
ctx.type = @resolve 'complex-type', arg
null
instance:
scope:
augment: 0..n
choice: 0..n
config: 0..1
container: 0..n
description: 0..1
if-feature: 0..n
instance: 0..n
instance-list: 0..n
instance-type: 1
leaf: 0..n
leaf-list: 0..n
list: 0..n
mandatory: 0..1
must: 0..n
reference: 0..1
status: 0..1
when: 0..1
parent-scope:
module: 0..n
submodule: 0..n
container: 0..n
grouping: 0..n
input: 0..n
output: 0..n
construct: !coffee/function |
(arg, params, children) ->
synth = @resolve 'synthesizer'
Model = children.type
delete children.type
((synth Model) params).bind children
instance-list:
scope:
augment: 0..n
choice: 0..n
config: 0..1
container: 0..n
description: 0..1
if-feature: 0..n
instance: 0..n
instance-list: 0..n
instance-type: 1
leaf: 0..n
leaf-list: 0..n
list: 0..n
min-elements: 0..n
max-elements: 0..n
must: 0..n
reference: 0..1
status: 0..1
when: 0..1
parent-scope:
module: 0..n
submodule: 0..n
container: 0..n
grouping: 0..n
input: 0..n
output: 0..n
construct: !coffee/function |
(arg, params, children) ->
synth = @resolve 'synthesizer'
Model = children.type
delete children.type
unless (Model.get 'key')?
throw @error "missing 'key' for #{Model.get 'name'} used in instance-list"
item = ((synth Model) null).bind children
#item = (class extends Model).bind children
(synth.List params).set type: item, key: (item.get 'key')
instance-type:
parent-scope:
type: 0..1
construct: !coffee/function |
(arg, params, children, ctx) ->
ctx.type = (@resolve 'complex-type', arg)
unless ctx.type?
throw @error "unable to resolve '#{arg}' complex-type instance"
null
# module:
# construct: !coffee/function |
# (arg, params, children, ctx, self) ->
# (self.origin.construct.apply this, arguments)
# .merge models: (@resolve 'complex-type')