Václav Kubernát | 7310938 | 2018-09-14 19:52:03 +0200 | [diff] [blame] | 1 | module example-schema { |
Václav Kubernát | a878960 | 2020-07-20 15:18:19 +0200 | [diff] [blame] | 2 | yang-version 1.1; |
Václav Kubernát | 7310938 | 2018-09-14 19:52:03 +0200 | [diff] [blame] | 3 | prefix aha; |
4 | namespace "http://example.com"; | ||||
5 | |||||
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 6 | import other-module { |
7 | prefix other; | ||||
8 | } | ||||
9 | |||||
Václav Kubernát | da8e4b9 | 2020-02-04 11:56:30 +0100 | [diff] [blame] | 10 | container inventory { |
11 | container stuff { | ||||
12 | presence true; | ||||
13 | } | ||||
14 | } | ||||
15 | |||||
Václav Kubernát | 134d78f | 2019-09-03 16:42:29 +0200 | [diff] [blame] | 16 | leaf leafUInt8 { |
17 | type uint8; | ||||
18 | } | ||||
19 | |||||
20 | leaf leafUInt16 { | ||||
21 | type uint16; | ||||
22 | } | ||||
23 | |||||
24 | leaf leafUInt32 { | ||||
25 | type uint32; | ||||
26 | } | ||||
27 | |||||
28 | leaf leafUInt64 { | ||||
29 | type uint64; | ||||
30 | } | ||||
31 | |||||
32 | leaf leafInt8 { | ||||
33 | type int8; | ||||
34 | } | ||||
35 | |||||
36 | leaf leafInt16 { | ||||
37 | type int16; | ||||
38 | } | ||||
39 | |||||
40 | leaf leafInt32 { | ||||
Václav Kubernát | 7310938 | 2018-09-14 19:52:03 +0200 | [diff] [blame] | 41 | type int32; |
42 | } | ||||
43 | |||||
Václav Kubernát | 134d78f | 2019-09-03 16:42:29 +0200 | [diff] [blame] | 44 | leaf leafInt64 { |
45 | type int64; | ||||
46 | } | ||||
47 | |||||
Václav Kubernát | 7310938 | 2018-09-14 19:52:03 +0200 | [diff] [blame] | 48 | leaf leafString { |
49 | type string; | ||||
50 | } | ||||
51 | |||||
52 | leaf leafEnum { | ||||
53 | type enumeration { | ||||
54 | enum lol; | ||||
55 | enum data; | ||||
56 | enum coze; | ||||
57 | } | ||||
58 | } | ||||
59 | |||||
60 | leaf leafDecimal { | ||||
Václav Kubernát | 9cfcd87 | 2020-02-18 12:34:02 +0100 | [diff] [blame] | 61 | units "nm"; |
Václav Kubernát | 7310938 | 2018-09-14 19:52:03 +0200 | [diff] [blame] | 62 | type decimal64 { |
63 | fraction-digits 9; | ||||
64 | } | ||||
65 | } | ||||
66 | |||||
67 | container pContainer { | ||||
68 | presence true; | ||||
69 | } | ||||
70 | |||||
Václav Kubernát | 45f4a82 | 2019-05-29 21:10:50 +0200 | [diff] [blame] | 71 | list person { |
72 | key 'name'; | ||||
73 | leaf name { | ||||
74 | type string; | ||||
75 | } | ||||
76 | } | ||||
77 | |||||
Václav Kubernát | 3efb5ca | 2019-10-09 20:07:40 +0200 | [diff] [blame] | 78 | leaf bossPerson { |
79 | type leafref { | ||||
80 | path '../aha:person/name'; | ||||
81 | } | ||||
82 | } | ||||
83 | |||||
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 84 | leaf unionIntString { |
85 | type union { | ||||
86 | type int32; | ||||
87 | type string; | ||||
88 | } | ||||
89 | } | ||||
90 | |||||
Václav Kubernát | 1ae24f4 | 2020-12-01 02:32:04 +0100 | [diff] [blame] | 91 | typedef myType { |
92 | type int32; | ||||
93 | description "My type."; | ||||
94 | } | ||||
95 | |||||
96 | leaf typedefedLeaf { | ||||
97 | type myType; | ||||
98 | description "This is a typedefed leaf."; | ||||
99 | } | ||||
100 | |||||
Václav Kubernát | 7d82da7 | 2019-04-11 15:16:38 +0200 | [diff] [blame] | 101 | grouping upAndDown { |
102 | leaf up { | ||||
103 | type boolean; | ||||
104 | } | ||||
105 | leaf down { | ||||
106 | type boolean; | ||||
107 | } | ||||
108 | } | ||||
109 | |||||
110 | uses upAndDown; | ||||
111 | |||||
112 | container lol { | ||||
113 | uses upAndDown; | ||||
114 | } | ||||
Jan Kundrát | 6ee8479 | 2020-01-24 01:43:36 +0100 | [diff] [blame] | 115 | |
116 | grouping targets_def { | ||||
117 | list targets { | ||||
118 | key 'city'; | ||||
119 | leaf city { | ||||
120 | type string; | ||||
121 | } | ||||
122 | } | ||||
123 | } | ||||
124 | |||||
Václav Kubernát | e7248b2 | 2020-06-26 15:38:59 +0200 | [diff] [blame] | 125 | rpc fire { |
126 | input { | ||||
127 | leaf whom { | ||||
128 | type leafref { | ||||
129 | path '/aha:person/name'; | ||||
130 | } | ||||
131 | } | ||||
132 | } | ||||
133 | } | ||||
134 | |||||
Jan Kundrát | 6ee8479 | 2020-01-24 01:43:36 +0100 | [diff] [blame] | 135 | rpc launch-nukes { |
136 | input { | ||||
137 | container payload { | ||||
138 | leaf kilotons { | ||||
139 | type uint64; | ||||
140 | mandatory true; | ||||
141 | units "kilotons"; | ||||
142 | } | ||||
143 | } | ||||
144 | leaf description { | ||||
145 | type string; | ||||
146 | } | ||||
147 | container cities { | ||||
148 | presence true; | ||||
149 | uses targets_def; | ||||
150 | } | ||||
151 | } | ||||
152 | output { | ||||
153 | leaf blast-radius { | ||||
154 | type uint32; | ||||
155 | units "m"; | ||||
156 | } | ||||
157 | leaf actual-yield { | ||||
158 | type uint64; | ||||
159 | units "kilotons"; | ||||
160 | } | ||||
161 | container damaged-places { | ||||
162 | presence true; | ||||
163 | uses targets_def; | ||||
164 | } | ||||
165 | } | ||||
166 | } | ||||
167 | |||||
168 | rpc noop {} | ||||
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 169 | |
Václav Kubernát | 2edfe54 | 2021-02-03 08:08:29 +0100 | [diff] [blame] | 170 | rpc setIp { |
171 | input { | ||||
172 | leaf ip { | ||||
173 | mandatory true; | ||||
174 | type string; | ||||
175 | } | ||||
176 | } | ||||
177 | } | ||||
178 | |||||
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 179 | list selectedNumbers { |
180 | key 'value'; | ||||
181 | leaf value { | ||||
182 | type int8; | ||||
183 | } | ||||
184 | } | ||||
185 | |||||
186 | list animalWithColor { | ||||
187 | key 'name color'; | ||||
188 | leaf name { | ||||
189 | type string; | ||||
190 | } | ||||
191 | leaf color { | ||||
192 | type string; | ||||
193 | } | ||||
194 | } | ||||
195 | |||||
196 | list ports { | ||||
197 | key 'name'; | ||||
198 | leaf name { | ||||
199 | type enumeration { | ||||
200 | enum A; | ||||
201 | enum B; | ||||
202 | enum C; | ||||
203 | enum D; | ||||
204 | enum E; | ||||
205 | } | ||||
206 | } | ||||
Václav Kubernát | a878960 | 2020-07-20 15:18:19 +0200 | [diff] [blame] | 207 | |
208 | action shutdown { | ||||
Václav Kubernát | 94bb7cf | 2021-02-03 09:59:39 +0100 | [diff] [blame] | 209 | input { |
210 | leaf force { | ||||
211 | mandatory true; | ||||
212 | type boolean; | ||||
213 | } | ||||
214 | } | ||||
Václav Kubernát | a878960 | 2020-07-20 15:18:19 +0200 | [diff] [blame] | 215 | output { |
216 | leaf success { | ||||
217 | mandatory true; | ||||
218 | type boolean; | ||||
219 | } | ||||
220 | } | ||||
221 | } | ||||
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 222 | } |
223 | |||||
224 | list org { | ||||
225 | key 'department'; | ||||
226 | leaf department { | ||||
227 | type string; | ||||
228 | } | ||||
229 | |||||
230 | list people { | ||||
231 | key 'name'; | ||||
232 | leaf name { | ||||
233 | type string; | ||||
234 | } | ||||
235 | |||||
236 | list computers { | ||||
237 | key 'type'; | ||||
238 | leaf type { | ||||
239 | type enumeration { | ||||
240 | enum PC; | ||||
241 | enum laptop; | ||||
242 | enum server; | ||||
243 | } | ||||
244 | } | ||||
245 | } | ||||
246 | } | ||||
247 | } | ||||
248 | |||||
249 | augment "/other:parking-lot" { | ||||
250 | list cars { | ||||
251 | key 'id'; | ||||
252 | leaf id { | ||||
253 | type int32; | ||||
254 | } | ||||
255 | } | ||||
256 | } | ||||
Jan Kundrát | bb525b4 | 2020-02-04 11:56:59 +0100 | [diff] [blame] | 257 | |
258 | leaf temperature { | ||||
259 | type int32; | ||||
260 | config false; | ||||
261 | } | ||||
Jan Kundrát | 0d8abd1 | 2020-05-07 02:00:14 +0200 | [diff] [blame] | 262 | |
263 | identity Animal { | ||||
264 | } | ||||
265 | |||||
266 | identity Mammal { | ||||
267 | base "Animal"; | ||||
268 | } | ||||
269 | |||||
270 | identity Dog { | ||||
271 | base "Mammal"; | ||||
272 | } | ||||
273 | |||||
274 | identity Whale { | ||||
275 | base "Mammal"; | ||||
276 | } | ||||
277 | |||||
278 | identity Velociraptor { | ||||
279 | base "Animal"; | ||||
280 | } | ||||
281 | |||||
282 | leaf beast { | ||||
283 | type identityref { | ||||
284 | base "Animal"; | ||||
285 | } | ||||
286 | } | ||||
Jan Kundrát | 6898544 | 2020-05-07 02:15:34 +0200 | [diff] [blame] | 287 | |
288 | leaf blob { | ||||
289 | type binary; | ||||
290 | } | ||||
Jan Kundrát | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 291 | |
292 | leaf dummy { | ||||
293 | type empty; | ||||
294 | } | ||||
Václav Kubernát | 5b8a8f3 | 2020-05-20 00:57:22 +0200 | [diff] [blame] | 295 | |
296 | leaf-list addresses { | ||||
297 | type string; | ||||
298 | } | ||||
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 299 | |
300 | leaf-list protocols { | ||||
301 | type string; | ||||
302 | ordered-by user; | ||||
303 | } | ||||
304 | |||||
305 | list players { | ||||
306 | key "name"; | ||||
307 | ordered-by user; | ||||
308 | leaf name { | ||||
309 | type string; | ||||
310 | } | ||||
311 | } | ||||
Václav Kubernát | 70d7f7a | 2020-06-23 14:40:40 +0200 | [diff] [blame] | 312 | |
313 | list point { | ||||
314 | key "x y"; | ||||
315 | leaf x { | ||||
316 | type int32; | ||||
317 | } | ||||
318 | leaf y { | ||||
319 | type int32; | ||||
320 | } | ||||
321 | } | ||||
Václav Kubernát | 19097f3 | 2020-10-05 10:08:29 +0200 | [diff] [blame] | 322 | |
323 | leaf flags { | ||||
324 | type bits { | ||||
325 | bit carry; | ||||
326 | bit zero; | ||||
327 | bit sign; | ||||
328 | bit parity; | ||||
329 | } | ||||
330 | } | ||||
Václav Kubernát | f90a0b5 | 2020-11-06 05:53:03 +0100 | [diff] [blame] | 331 | |
332 | container users { | ||||
333 | config false; | ||||
334 | list userList { | ||||
335 | leaf name { | ||||
336 | type string; | ||||
337 | } | ||||
338 | leaf otherfield { | ||||
339 | type string; | ||||
340 | } | ||||
341 | } | ||||
342 | } | ||||
343 | |||||
Václav Kubernát | 7310938 | 2018-09-14 19:52:03 +0200 | [diff] [blame] | 344 | } |