Bharat saraswal | 6a5911f | 2016-08-02 18:43:16 +0530 | [diff] [blame^] | 1 | module typedef { |
| 2 | |
| 3 | yang-version "1"; |
| 4 | namespace "http://rob.sh/yang/test/list"; |
| 5 | prefix "foo"; |
| 6 | |
| 7 | import remote { prefix defn; } |
| 8 | |
| 9 | organization "BugReports Inc"; |
| 10 | contact "A bug reporter"; |
| 11 | |
| 12 | description |
| 13 | "A test module"; |
| 14 | revision 2014-01-01 { |
| 15 | description "april-fools"; |
| 16 | reference "fooled-you"; |
| 17 | } |
| 18 | |
| 19 | typedef derived-string-type { |
| 20 | type string; |
| 21 | } |
| 22 | |
| 23 | typedef restricted-integer-type { |
| 24 | type uint16 { |
| 25 | range 0..64; |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | typedef bgp-session-direction { |
| 30 | type enumeration { |
| 31 | enum INBOUND; |
| 32 | enum OUTBOUND; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | typedef new-string-type { |
| 37 | type string; |
| 38 | default "defaultValue"; |
| 39 | } |
| 40 | |
| 41 | typedef restricted-inherit { |
| 42 | type string { |
| 43 | pattern "^a.*"; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | typedef restricted-int-inherit { |
| 48 | type int8 { |
| 49 | range 0..100; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | typedef parent-union { |
| 54 | type union { |
| 55 | type string { |
| 56 | pattern "a.*"; |
| 57 | } |
| 58 | type string { |
| 59 | pattern "b.*"; |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | typedef child-union { |
| 65 | type union { |
| 66 | type parent-union; |
| 67 | type string { |
| 68 | pattern "z.*"; |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | typedef union-included { |
| 74 | type union { |
| 75 | type string { |
| 76 | pattern "a.*"; |
| 77 | } |
| 78 | type string { |
| 79 | pattern "b.*"; |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | identity identity_base; |
| 85 | identity IDONE { |
| 86 | base "identity_base"; |
| 87 | } |
| 88 | |
| 89 | identity IDTWO { |
| 90 | base "identity_base"; |
| 91 | } |
| 92 | |
| 93 | typedef identity_one { |
| 94 | type identityref { |
| 95 | base identity_base; |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | typedef referenced-leaf { |
| 100 | type leafref { |
| 101 | path "/container/target"; |
| 102 | require-instance false; |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | grouping scoped-typedef { |
| 107 | typedef scoped-type { |
| 108 | type string { |
| 109 | pattern "a.*"; |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | leaf scoped-leaf { |
| 114 | type scoped-type; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | container container { |
| 119 | description |
| 120 | "A container"; |
| 121 | |
| 122 | leaf-list target { |
| 123 | type string; |
| 124 | description |
| 125 | "A target leaf for leafref checks"; |
| 126 | } |
| 127 | |
| 128 | leaf string { |
| 129 | type derived-string-type; |
| 130 | } |
| 131 | |
| 132 | leaf integer { |
| 133 | type restricted-integer-type; |
| 134 | } |
| 135 | |
| 136 | leaf stringdefault { |
| 137 | type derived-string-type; |
| 138 | default "aDefaultValue"; |
| 139 | } |
| 140 | |
| 141 | leaf integerdefault { |
| 142 | type restricted-integer-type; |
| 143 | default 10; |
| 144 | } |
| 145 | |
| 146 | leaf new-string { |
| 147 | type new-string-type; |
| 148 | } |
| 149 | |
| 150 | leaf remote-new-type { |
| 151 | type defn:remote-definition; |
| 152 | } |
| 153 | |
| 154 | leaf session-dir { |
| 155 | type bgp-session-direction; |
| 156 | } |
| 157 | |
| 158 | leaf remote-local-type { |
| 159 | type defn:remote-local-definition; |
| 160 | } |
| 161 | |
| 162 | leaf inheritance { |
| 163 | type restricted-inherit { |
| 164 | pattern ".*k"; |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | leaf int-inheritance { |
| 169 | type restricted-int-inherit { |
| 170 | range 2..5; |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | leaf-list stacked-union { |
| 175 | type child-union; |
| 176 | } |
| 177 | |
| 178 | leaf include-of-include-definition { |
| 179 | type defn:hybrid-definition; |
| 180 | } |
| 181 | |
| 182 | leaf identity-one-typedef { |
| 183 | type identity_one; |
| 184 | } |
| 185 | |
| 186 | leaf union-with-union { |
| 187 | type union { |
| 188 | type union-included; |
| 189 | type string { |
| 190 | pattern "q.*"; |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | leaf reference { |
| 196 | type referenced-leaf; |
| 197 | } |
| 198 | |
| 199 | uses scoped-typedef; |
| 200 | } |
| 201 | } |