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