blob: 44baf805feb3cbe17c4e4437069ad6c2dd9f7ede [file] [log] [blame]
Václav Kubernát73109382018-09-14 19:52:03 +02001module example-schema {
Václav Kubernáta8789602020-07-20 15:18:19 +02002 yang-version 1.1;
Václav Kubernát73109382018-09-14 19:52:03 +02003 prefix aha;
4 namespace "http://example.com";
5
Václav Kubernátab612e92019-11-26 19:51:31 +01006 import other-module {
7 prefix other;
8 }
9
Václav Kubernátda8e4b92020-02-04 11:56:30 +010010 container inventory {
11 container stuff {
12 presence true;
13 }
14 }
15
Václav Kubernát134d78f2019-09-03 16:42:29 +020016 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át73109382018-09-14 19:52:03 +020041 type int32;
42 }
43
Václav Kubernát134d78f2019-09-03 16:42:29 +020044 leaf leafInt64 {
45 type int64;
46 }
47
Václav Kubernát73109382018-09-14 19:52:03 +020048 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át9cfcd872020-02-18 12:34:02 +010061 units "nm";
Václav Kubernát73109382018-09-14 19:52:03 +020062 type decimal64 {
63 fraction-digits 9;
64 }
65 }
66
67 container pContainer {
68 presence true;
69 }
70
Václav Kubernát45f4a822019-05-29 21:10:50 +020071 list person {
72 key 'name';
73 leaf name {
74 type string;
75 }
76 }
77
Václav Kubernát3efb5ca2019-10-09 20:07:40 +020078 leaf bossPerson {
79 type leafref {
80 path '../aha:person/name';
81 }
82 }
83
Václav Kubernát2984f442020-02-20 17:43:35 +010084 leaf unionIntString {
85 type union {
86 type int32;
87 type string;
88 }
89 }
90
Václav Kubernát1ae24f42020-12-01 02:32:04 +010091 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át7d82da72019-04-11 15:16:38 +0200101 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át6ee84792020-01-24 01:43:36 +0100115
116 grouping targets_def {
117 list targets {
118 key 'city';
119 leaf city {
120 type string;
121 }
122 }
123 }
124
Václav Kubernáte7248b22020-06-26 15:38:59 +0200125 rpc fire {
126 input {
127 leaf whom {
128 type leafref {
129 path '/aha:person/name';
130 }
131 }
132 }
133 }
134
Jan Kundrát6ee84792020-01-24 01:43:36 +0100135 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átab612e92019-11-26 19:51:31 +0100169
Václav Kubernát2edfe542021-02-03 08:08:29 +0100170 rpc setIp {
171 input {
172 leaf ip {
173 mandatory true;
174 type string;
175 }
176 }
177 }
178
Václav Kubernátab612e92019-11-26 19:51:31 +0100179 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áta8789602020-07-20 15:18:19 +0200207
208 action shutdown {
209 output {
210 leaf success {
211 mandatory true;
212 type boolean;
213 }
214 }
215 }
Václav Kubernátab612e92019-11-26 19:51:31 +0100216 }
217
218 list org {
219 key 'department';
220 leaf department {
221 type string;
222 }
223
224 list people {
225 key 'name';
226 leaf name {
227 type string;
228 }
229
230 list computers {
231 key 'type';
232 leaf type {
233 type enumeration {
234 enum PC;
235 enum laptop;
236 enum server;
237 }
238 }
239 }
240 }
241 }
242
243 augment "/other:parking-lot" {
244 list cars {
245 key 'id';
246 leaf id {
247 type int32;
248 }
249 }
250 }
Jan Kundrátbb525b42020-02-04 11:56:59 +0100251
252 leaf temperature {
253 type int32;
254 config false;
255 }
Jan Kundrát0d8abd12020-05-07 02:00:14 +0200256
257 identity Animal {
258 }
259
260 identity Mammal {
261 base "Animal";
262 }
263
264 identity Dog {
265 base "Mammal";
266 }
267
268 identity Whale {
269 base "Mammal";
270 }
271
272 identity Velociraptor {
273 base "Animal";
274 }
275
276 leaf beast {
277 type identityref {
278 base "Animal";
279 }
280 }
Jan Kundrát68985442020-05-07 02:15:34 +0200281
282 leaf blob {
283 type binary;
284 }
Jan Kundrát379bb572020-05-07 03:23:13 +0200285
286 leaf dummy {
287 type empty;
288 }
Václav Kubernát5b8a8f32020-05-20 00:57:22 +0200289
290 leaf-list addresses {
291 type string;
292 }
Václav Kubernátbf65dd72020-05-28 02:32:31 +0200293
294 leaf-list protocols {
295 type string;
296 ordered-by user;
297 }
298
299 list players {
300 key "name";
301 ordered-by user;
302 leaf name {
303 type string;
304 }
305 }
Václav Kubernát70d7f7a2020-06-23 14:40:40 +0200306
307 list point {
308 key "x y";
309 leaf x {
310 type int32;
311 }
312 leaf y {
313 type int32;
314 }
315 }
Václav Kubernát19097f32020-10-05 10:08:29 +0200316
317 leaf flags {
318 type bits {
319 bit carry;
320 bit zero;
321 bit sign;
322 bit parity;
323 }
324 }
Václav Kubernátf90a0b52020-11-06 05:53:03 +0100325
326 container users {
327 config false;
328 list userList {
329 leaf name {
330 type string;
331 }
332 leaf otherfield {
333 type string;
334 }
335 }
336 }
337
Václav Kubernát73109382018-09-14 19:52:03 +0200338}