Modified construction of built-in yang types.
[controller.git] / opendaylight / sal / yang-prototype / code-generator / yang-model-parser-impl / src / test / resources / model / testfile2.yang
1 module types2 {
2     yang-version 1;
3     namespace "urn:simple.types.data.demo";
4     prefix "t2";
5     
6     organization "opendaylight";
7     contact "http://www.opendaylight.org/";
8     
9     description "This is types-data test description";
10
11     revision "2013-02-27" {
12         reference " WILL BE DEFINED LATER";
13     }
14     
15     typedef my-base-int32-type {
16         type int32 {
17             range "2..20";
18         }
19     }
20
21     typedef my-type1 {
22         type my-base-int32-type {
23             range "3..9|11..max";
24         }
25         units "mile";
26         default "11";
27     }
28     
29     typedef my-custom-string {
30         type string {
31             pattern "[a-k]*";
32             length "5..11";
33         }
34     }
35     
36     typedef my-string-type {
37         type my-custom-string {
38             length "5..10";
39         }
40     }
41     
42     typedef my-string-type2 {
43         type my-string-type {
44             pattern "[b-u]*";
45         }
46     }
47
48     typedef my-string-type-ext {
49         type my-string-type2 {
50             pattern "[e-z]*";
51         }
52     }
53
54     typedef my-int-type {
55         type int32 {
56             range "10..20";
57         }
58     }
59     
60     typedef my-int-type2 {
61         type my-int-type {
62             range "12..18";
63         }
64     }
65     
66     typedef my-int-type-ext {
67         type my-int-type2 {
68             range "14..16";
69         }
70     }
71     
72     typedef my-decimal-type {
73         type decimal64 {
74             fraction-digits 6;
75         }
76     }
77     
78     typedef my-decimal-type-ext {
79         type decimal64 {
80             fraction-digits 5;
81         }
82     }
83
84     typedef my-union {
85         type union {
86             type int16 {
87                 range "1..100";
88             }
89             type int32;
90         }
91     }
92
93     typedef my-union-ext {
94         type my-union;
95     }
96
97     typedef nested-union1 {
98         type nested-union2;
99     }
100
101     typedef nested-union2 {
102         type union {
103             type my-union-ext;
104             type string;
105         }
106     }
107
108     leaf if-name {
109         type leafref {
110             path "/interface/name";
111         }
112     }
113      
114     leaf name {
115         type string;
116     }
117     
118     leaf count {
119         type int8 {
120             range "1..10";
121         }
122     }
123      
124     leaf nested-type-leaf {
125         type my-type1;
126     }
127     
128     extension c-define {
129         description
130         "Takes as argument a name string.
131         Makes the code generator use the given name in the
132         #define.";
133         argument "name" {
134             yin-element "true";
135         }
136     }
137     
138     container system {
139         leaf user {
140             type string;
141         }
142     }
143     
144     grouping target {
145         anyxml data {
146             config true;
147             description "Copy of the source datastore subset.";
148             mandatory false;
149             must "test-condition-text";
150             reference "test-no-reference";
151             status "obsolete";
152             when "test-when-text";
153         }
154         choice how {
155             description "test choice description";
156             default interval;
157             case interval {
158                 leaf interval {
159                     type uint16;
160                     default 30;
161                     units minutes;
162                 }
163             }
164             case daily {
165                 leaf daily {
166                     type empty;
167                 }
168                 leaf time-of-day {
169                     type string;
170                     units 24-hour-clock;
171                     default 1am;
172                 }
173             }
174         }
175         leaf address {
176             type string;
177             description "Target IP address";
178         }
179         container port {
180             description "Target port container";
181         }
182         list addresses {
183             key "id";
184             leaf id {
185                 type int8;
186             }
187         }
188         grouping target-inner {
189             description "target-inner default description";
190             leaf inner-grouping-id {
191                 type int8;
192             }
193         }
194         typedef group-type {
195             type my-decimal-type;
196         }
197     }
198
199     container peer {
200         container destination {
201             uses target {
202                 refine address {
203                     default "1.2.3.4";
204                     description "description of address defined by refine";
205                     reference "address reference added by refine";
206                     config false;
207                     mandatory true;
208                     must "ifType != 'ethernet' or " +
209                             "(ifType = 'ethernet' and ifMTU = 1500)" {
210                         error-message "An ethernet MTU must be 1500";
211                     }
212                 }
213                 refine port {
214                     description "description of port defined by refine";
215                     reference "port reference added by refine";
216                     config false;
217                     presence "presence is required";
218                 }
219                 refine addresses {
220                     description "description of addresses defined by refine";
221                     reference "addresses reference added by refine";
222                     config false;
223                     min-elements 2;
224                     max-elements 12;
225                 }
226                 refine target-inner {
227                     description "new target-inner grouping description";
228                 }
229                 refine group-type {
230                     description "new group-type description";
231                     reference "new group-type reference";
232                 }
233             }
234         }
235     }
236     
237     container interfaces {
238          list ifEntry {
239              key "ifIndex";
240
241              leaf ifIndex {
242                  type uint32;
243                  units minutes;
244              }
245              
246              leaf ifMtu {
247                  type int32;
248              }
249              
250              min-elements 1;
251              max-elements 11;
252          }
253     }
254
255 }