Bug 6867: Extend yang statement parser to support different yang versions
[yangtools.git] / yang / yang-parser-impl / src / test / resources / rfc7950 / model / foo.yang
1 module foo {
2     yang-version 1.1;
3     namespace "urn:opendaylight.foo";
4     prefix "foo";
5
6     import bar {
7         prefix "br";
8         revision-date 2013-07-03;
9     }
10
11     import baz {
12         prefix "bz";
13         revision-date 2013-02-27;
14     }
15
16     include subfoo {
17         revision-date "2013-02-27";
18     }
19
20     organization "opendaylight";
21     contact "http://www.opendaylight.org/";
22
23     revision "2013-02-27" {
24         reference " WILL BE DEFINED LATER";
25     }
26
27     typedef identifier {
28         type int32;
29     }
30
31     leaf int32-leaf {
32         type br:int32-ext2 {
33             range "12..max";
34         }
35     }
36
37     leaf string-leaf {
38         type br:string-ext4;
39     }
40
41     leaf invalid-pattern-string-leaf {
42         type br:invalid-string-pattern;
43     }
44
45     leaf invalid-direct-string-pattern-def-leaf {
46         type string {
47             pattern "[[A-1*-%22!^^}";
48         }
49     }
50
51     leaf multiple-pattern-string-leaf {
52         type br:multiple-pattern-string;
53     }
54
55     leaf multiple-pattern-direct-string-def-leaf {
56         type string {
57             pattern "[e-z]*";
58             pattern "[[A-1*-%22!^^}";
59             pattern "[a-d]*";
60         }
61     }
62
63     leaf length-leaf {
64         type br:string-ext2 {
65             length "7..max";
66         }
67     }
68
69     leaf decimal-leaf {
70         type br:my-decimal-type {
71             fraction-digits 4;
72         }
73     }
74
75     leaf decimal-leaf2 {
76         type br:my-decimal-type;
77     }
78
79     container ext {
80         bz:c-define "MY_INTERFACES";
81     }
82
83     leaf union-leaf {
84         type br:my-union-ext;
85     }
86
87     deviation /br:interfaces/br:ifEntry {
88         deviate add {
89             default "admin";
90             config "true";
91         }
92         reference "system/user ref";
93     }
94
95     leaf custom-union-leaf {
96         type bz:union1;
97     }
98
99     container transfer {
100         choice how {
101             default interval;
102             container input {
103             }
104             list output {
105                 leaf id {
106                     type string;
107                 }
108             }
109             case interval {
110                 leaf interval {
111                     type uint16;
112                     default 30;
113                     units minutes;
114                 }
115             }
116             case daily {
117                 leaf daily {
118                     type empty;
119                 }
120                 leaf time-of-day {
121                     type string;
122                     units 24-hour-clock;
123                     default 1am;
124                 }
125             }
126             case manual {
127                 leaf manual {
128                     type empty;
129                 }
130             }
131         }
132     }
133
134     anyxml datas {
135         description
136           "Copy of the source typesstore subset that matched
137            the filter criteria (if any).  An empty types container
138            indicates that the request did not produce any results.";
139         status obsolete;
140     }
141
142     augment "/br:interfaces/br:ifEntry/bz:augment-holder" {
143         when "if:ifType='ds0'";
144         leaf ds0ChannelNumber {
145             type string;
146         }
147         leaf interface-id {
148             type leafref {
149                 path "/if:interfaces/if:interface/if:name";
150             }
151         }
152         leaf my-type {
153             type br:int32-ext2;
154         }
155         container schemas {
156         }
157         choice odl {
158             leaf id {
159                 type int8;
160             }
161             case node1 {
162                 description "node1";
163             }
164             case node2 {
165                 description "node2";
166             }
167             container node3 {
168                 description "node3";
169             }
170         }
171     }
172
173     container mycont {
174         container innercont {
175             typedef mytype {
176                 type string;
177             }
178             leaf myleaf {
179                 type mytype;
180             }
181         }
182     }
183
184     uses bz:target {
185         augment "how/interval" {
186             description "inner augment";
187             leaf name {
188                 type string;
189             }
190         }
191     }
192
193     container peer {
194         container destination {
195             uses bz:target {
196                 refine address {
197                     default "1.2.3.4";
198                     description "IP address of target node";
199                     reference "address reference added by refine";
200                     config false;
201                     mandatory false;
202                     must "ifType != 'ethernet' or " +
203                             "(ifType = 'ethernet' and ifMTU = 1500)" {
204                         error-message "An ethernet MTU must be 1500";
205                     }
206                     foo:mountpoint "mnt-extension";
207                 }
208                 refine port {
209                     description "description of port defined by refine";
210                     reference "port reference added by refine";
211                     config false;
212                     presence "presence is required";
213                 }
214                 refine "addresses" {
215                     description "description of addresses defined by refine";
216                     reference "addresses reference added by refine";
217                     config false;
218                     min-elements 2;
219                     max-elements unbounded;
220                 }
221                 refine addresses/id {
222                     description "id of address";
223                 }
224             }
225         }
226     }
227
228     extension mountpoint {
229         description "enter point";
230         argument "name" {
231             yin-element "true";
232         }
233     }
234
235 }