1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669
|
<pre>Internet Engineering Task Force (IETF) A. Bierman
Request for Comments: 8040 YumaWorks
Category: Standards Track M. Bjorklund
ISSN: 2070-1721 Tail-f Systems
K. Watsen
Juniper Networks
January 2017
<span class="h1">RESTCONF Protocol</span>
Abstract
This document describes an HTTP-based protocol that provides a
programmatic interface for accessing data defined in YANG, using the
datastore concepts defined in the Network Configuration Protocol
(NETCONF).
Status of This Memo
This is an Internet Standards Track document.
This document is a product of the Internet Engineering Task Force
(IETF). It represents the consensus of the IETF community. It has
received public review and has been approved for publication by the
Internet Engineering Steering Group (IESG). Further information on
Internet Standards is available in <a href="./rfc7841#section-2">Section 2 of RFC 7841</a>.
Information about the current status of this document, any errata,
and how to provide feedback on it may be obtained at
<a href="http://www.rfc-editor.org/info/rfc8040">http://www.rfc-editor.org/info/rfc8040</a>.
Copyright Notice
Copyright (c) 2017 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to <a href="https://www.rfc-editor.org/bcp/bcp78">BCP 78</a> and the IETF Trust's Legal
Provisions Relating to IETF Documents
(<a href="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</a>) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.
<span class="grey">Bierman, et al. Standards Track [Page 1]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-2" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
Table of Contents
<a href="#section-1">1</a>. Introduction ....................................................<a href="#page-5">5</a>
<a href="#section-1.1">1.1</a>. Terminology ................................................<a href="#page-5">5</a>
<a href="#section-1.1.1">1.1.1</a>. NETCONF .............................................<a href="#page-6">6</a>
<a href="#section-1.1.2">1.1.2</a>. HTTP ................................................<a href="#page-6">6</a>
<a href="#section-1.1.3">1.1.3</a>. YANG ................................................<a href="#page-7">7</a>
<a href="#section-1.1.4">1.1.4</a>. NETCONF Notifications ...............................<a href="#page-7">7</a>
<a href="#section-1.1.5">1.1.5</a>. Terms ...............................................<a href="#page-8">8</a>
<a href="#section-1.1.6">1.1.6</a>. URI Template and Examples ..........................<a href="#page-10">10</a>
<a href="#section-1.1.7">1.1.7</a>. Tree Diagrams ......................................<a href="#page-11">11</a>
<a href="#section-1.2">1.2</a>. Subset of NETCONF Functionality ...........................<a href="#page-11">11</a>
<a href="#section-1.3">1.3</a>. Data-Model-Driven API .....................................<a href="#page-12">12</a>
<a href="#section-1.4">1.4</a>. Coexistence with NETCONF ..................................<a href="#page-13">13</a>
<a href="#section-1.5">1.5</a>. RESTCONF Extensibility ....................................<a href="#page-14">14</a>
<a href="#section-2">2</a>. Transport Protocol .............................................<a href="#page-15">15</a>
<a href="#section-2.1">2.1</a>. Integrity and Confidentiality .............................<a href="#page-15">15</a>
<a href="#section-2.2">2.2</a>. HTTPS with X.509v3 Certificates ...........................<a href="#page-16">16</a>
<a href="#section-2.3">2.3</a>. Certificate Validation ....................................<a href="#page-16">16</a>
<a href="#section-2.4">2.4</a>. Authenticated Server Identity .............................<a href="#page-16">16</a>
<a href="#section-2.5">2.5</a>. Authenticated Client Identity .............................<a href="#page-16">16</a>
<a href="#section-3">3</a>. Resources ......................................................<a href="#page-17">17</a>
<a href="#section-3.1">3.1</a>. Root Resource Discovery ...................................<a href="#page-18">18</a>
<a href="#section-3.2">3.2</a>. RESTCONF Media Types ......................................<a href="#page-20">20</a>
<a href="#section-3.3">3.3</a>. API Resource ..............................................<a href="#page-20">20</a>
<a href="#section-3.3.1">3.3.1</a>. {+restconf}/data ...................................<a href="#page-21">21</a>
<a href="#section-3.3.2">3.3.2</a>. {+restconf}/operations .............................<a href="#page-22">22</a>
<a href="#section-3.3.3">3.3.3</a>. {+restconf}/yang-library-version ...................<a href="#page-22">22</a>
<a href="#section-3.4">3.4</a>. Datastore Resource ........................................<a href="#page-23">23</a>
<a href="#section-3.4.1">3.4.1</a>. Edit Collision Prevention ..........................<a href="#page-23">23</a>
<a href="#section-3.5">3.5</a>. Data Resource .............................................<a href="#page-24">24</a>
<a href="#section-3.5.1">3.5.1</a>. Timestamp ..........................................<a href="#page-25">25</a>
<a href="#section-3.5.2">3.5.2</a>. Entity-Tag .........................................<a href="#page-25">25</a>
3.5.3. Encoding Data Resource Identifiers in the
Request URI ........................................<a href="#page-26">26</a>
<a href="#section-3.5.4">3.5.4</a>. Default Handling ...................................<a href="#page-29">29</a>
<a href="#section-3.6">3.6</a>. Operation Resource ........................................<a href="#page-30">30</a>
<a href="#section-3.6.1">3.6.1</a>. Encoding Operation Resource Input Parameters .......<a href="#page-31">31</a>
<a href="#section-3.6.2">3.6.2</a>. Encoding Operation Resource Output Parameters ......<a href="#page-36">36</a>
<a href="#section-3.6.3">3.6.3</a>. Encoding Operation Resource Errors .................<a href="#page-38">38</a>
<a href="#section-3.7">3.7</a>. Schema Resource ...........................................<a href="#page-40">40</a>
<a href="#section-3.8">3.8</a>. Event Stream Resource .....................................<a href="#page-41">41</a>
<a href="#section-3.9">3.9</a>. "errors" YANG Data Template ...............................<a href="#page-41">41</a>
<a href="#section-4">4</a>. RESTCONF Methods ...............................................<a href="#page-42">42</a>
<a href="#section-4.1">4.1</a>. OPTIONS ...................................................<a href="#page-43">43</a>
<a href="#section-4.2">4.2</a>. HEAD ......................................................<a href="#page-43">43</a>
<a href="#section-4.3">4.3</a>. GET .......................................................<a href="#page-43">43</a>
<a href="#section-4.4">4.4</a>. POST ......................................................<a href="#page-45">45</a>
<span class="grey">Bierman, et al. Standards Track [Page 2]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-3" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<a href="#section-4.4.1">4.4.1</a>. Create Resource Mode ...............................<a href="#page-45">45</a>
<a href="#section-4.4.2">4.4.2</a>. Invoke Operation Mode ..............................<a href="#page-47">47</a>
<a href="#section-4.5">4.5</a>. PUT .......................................................<a href="#page-48">48</a>
<a href="#section-4.6">4.6</a>. PATCH .....................................................<a href="#page-50">50</a>
<a href="#section-4.6.1">4.6.1</a>. Plain Patch ........................................<a href="#page-50">50</a>
<a href="#section-4.7">4.7</a>. DELETE ....................................................<a href="#page-51">51</a>
<a href="#section-4.8">4.8</a>. Query Parameters ..........................................<a href="#page-52">52</a>
<a href="#section-4.8.1">4.8.1</a>. The "content" Query Parameter ......................<a href="#page-54">54</a>
<a href="#section-4.8.2">4.8.2</a>. The "depth" Query Parameter ........................<a href="#page-54">54</a>
<a href="#section-4.8.3">4.8.3</a>. The "fields" Query Parameter .......................<a href="#page-55">55</a>
<a href="#section-4.8.4">4.8.4</a>. The "filter" Query Parameter .......................<a href="#page-56">56</a>
<a href="#section-4.8.5">4.8.5</a>. The "insert" Query Parameter .......................<a href="#page-57">57</a>
<a href="#section-4.8.6">4.8.6</a>. The "point" Query Parameter ........................<a href="#page-57">57</a>
<a href="#section-4.8.7">4.8.7</a>. The "start-time" Query Parameter ...................<a href="#page-58">58</a>
<a href="#section-4.8.8">4.8.8</a>. The "stop-time" Query Parameter ....................<a href="#page-58">58</a>
<a href="#section-4.8.9">4.8.9</a>. The "with-defaults" Query Parameter ................<a href="#page-59">59</a>
<a href="#section-5">5</a>. Messages .......................................................<a href="#page-60">60</a>
<a href="#section-5.1">5.1</a>. Request URI Structure .....................................<a href="#page-61">61</a>
<a href="#section-5.2">5.2</a>. Message Encoding ..........................................<a href="#page-62">62</a>
<a href="#section-5.3">5.3</a>. RESTCONF Metadata .........................................<a href="#page-63">63</a>
<a href="#section-5.3.1">5.3.1</a>. XML Metadata Encoding Example ......................<a href="#page-64">64</a>
<a href="#section-5.3.2">5.3.2</a>. JSON Metadata Encoding Example .....................<a href="#page-65">65</a>
<a href="#section-5.4">5.4</a>. Return Status .............................................<a href="#page-65">65</a>
<a href="#section-5.5">5.5</a>. Message Caching ...........................................<a href="#page-66">66</a>
<a href="#section-6">6</a>. Notifications ..................................................<a href="#page-66">66</a>
<a href="#section-6.1">6.1</a>. Server Support ............................................<a href="#page-66">66</a>
<a href="#section-6.2">6.2</a>. Event Streams .............................................<a href="#page-67">67</a>
<a href="#section-6.3">6.3</a>. Subscribing to Receive Notifications ......................<a href="#page-68">68</a>
<a href="#section-6.3.1">6.3.1</a>. NETCONF Event Stream ...............................<a href="#page-70">70</a>
<a href="#section-6.4">6.4</a>. Receiving Event Notifications .............................<a href="#page-70">70</a>
<a href="#section-7">7</a>. Error Reporting ................................................<a href="#page-73">73</a>
<a href="#section-7.1">7.1</a>. Error Response Message ....................................<a href="#page-75">75</a>
<a href="#section-8">8</a>. RESTCONF Module ................................................<a href="#page-79">79</a>
<a href="#section-9">9</a>. RESTCONF Monitoring ............................................<a href="#page-85">85</a>
<a href="#section-9.1">9.1</a>. restconf-state/capabilities ...............................<a href="#page-86">86</a>
<a href="#section-9.1.1">9.1.1</a>. Query Parameter URIs ...............................<a href="#page-87">87</a>
<a href="#section-9.1.2">9.1.2</a>. The "defaults" Protocol Capability URI .............<a href="#page-87">87</a>
<a href="#section-9.2">9.2</a>. restconf-state/streams ....................................<a href="#page-88">88</a>
<a href="#section-9.3">9.3</a>. RESTCONF Monitoring Module ................................<a href="#page-89">89</a>
<a href="#section-10">10</a>. YANG Module Library ...........................................<a href="#page-93">93</a>
<a href="#section-10.1">10.1</a>. modules-state/module .....................................<a href="#page-93">93</a>
<a href="#section-11">11</a>. IANA Considerations ...........................................<a href="#page-94">94</a>
<a href="#section-11.1">11.1</a>. The "restconf" Relation Type .............................<a href="#page-94">94</a>
<a href="#section-11.2">11.2</a>. Registrations for New URIs and YANG Modules ..............<a href="#page-94">94</a>
<a href="#section-11.3">11.3</a>. Media Types ..............................................<a href="#page-95">95</a>
<a href="#section-11.3.1">11.3.1</a>. Media Type "application/yang-data+xml" ............<a href="#page-95">95</a>
<a href="#section-11.3.2">11.3.2</a>. Media Type "application/yang-data+json" ...........<a href="#page-96">96</a>
<span class="grey">Bierman, et al. Standards Track [Page 3]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-4" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<a href="#section-11.4">11.4</a>. RESTCONF Capability URNs .................................<a href="#page-97">97</a>
<a href="#section-11.5">11.5</a>. Registration of "restconf" URN Sub-namespace .............<a href="#page-98">98</a>
<a href="#section-12">12</a>. Security Considerations .......................................<a href="#page-99">99</a>
<a href="#section-13">13</a>. References ...................................................<a href="#page-100">100</a>
<a href="#section-13.1">13.1</a>. Normative References ....................................<a href="#page-100">100</a>
<a href="#section-13.2">13.2</a>. Informative References ..................................<a href="#page-104">104</a>
<a href="#appendix-A">Appendix A</a>. Example YANG Module ..................................<a href="#page-105">105</a>
<a href="#appendix-A.1">A.1</a>. "example-jukebox" YANG Module .............................<a href="#page-106">106</a>
<a href="#appendix-B">Appendix B</a>. RESTCONF Message Examples ............................<a href="#page-112">112</a>
<a href="#appendix-B.1">B.1</a>. Resource Retrieval Examples ...............................<a href="#page-112">112</a>
<a href="#appendix-B.1.1">B.1.1</a>. Retrieve the Top-Level API Resource ...................<a href="#page-112">112</a>
<a href="#appendix-B.1.2">B.1.2</a>. Retrieve the Server Module Information ................<a href="#page-114">114</a>
<a href="#appendix-B.1.3">B.1.3</a>. Retrieve the Server Capability Information ............<a href="#page-117">117</a>
<a href="#appendix-B.2">B.2</a>. Data Resource and Datastore Resource Examples .............<a href="#page-118">118</a>
<a href="#appendix-B.2.1">B.2.1</a>. Create New Data Resources .............................<a href="#page-118">118</a>
<a href="#appendix-B.2.2">B.2.2</a>. Detect Datastore Resource Entity-Tag Change ...........<a href="#page-119">119</a>
<a href="#appendix-B.2.3">B.2.3</a>. Edit a Datastore Resource .............................<a href="#page-121">121</a>
<a href="#appendix-B.2.4">B.2.4</a>. Replace a Datastore Resource ..........................<a href="#page-122">122</a>
<a href="#appendix-B.2.5">B.2.5</a>. Edit a Data Resource ..................................<a href="#page-122">122</a>
<a href="#appendix-B.3">B.3</a>. Query Parameter Examples ..................................<a href="#page-123">123</a>
<a href="#appendix-B.3.1">B.3.1</a>. "content" Parameter ...................................<a href="#page-123">123</a>
<a href="#appendix-B.3.2">B.3.2</a>. "depth" Parameter .....................................<a href="#page-126">126</a>
<a href="#appendix-B.3.3">B.3.3</a>. "fields" Parameter ....................................<a href="#page-130">130</a>
<a href="#appendix-B.3.4">B.3.4</a>. "insert" Parameter ....................................<a href="#page-132">132</a>
<a href="#appendix-B.3.5">B.3.5</a>. "point" Parameter .....................................<a href="#page-133">133</a>
<a href="#appendix-B.3.6">B.3.6</a>. "filter" Parameter ....................................<a href="#page-134">134</a>
<a href="#appendix-B.3.7">B.3.7</a>. "start-time" Parameter ................................<a href="#page-134">134</a>
<a href="#appendix-B.3.8">B.3.8</a>. "stop-time" Parameter .................................<a href="#page-135">135</a>
<a href="#appendix-B.3.9">B.3.9</a>. "with-defaults" Parameter .............................<a href="#page-135">135</a>
Acknowledgements .................................................<a href="#page-137">137</a>
Authors' Addresses ...............................................<a href="#page-137">137</a>
<span class="grey">Bierman, et al. Standards Track [Page 4]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-5" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h2"><a class="selflink" id="section-1" href="#section-1">1</a>. Introduction</span>
There is a need for standard mechanisms to allow Web applications to
access the configuration data, state data, data-model-specific Remote
Procedure Call (RPC) operations, and event notifications within a
networking device, in a modular and extensible manner.
This document defines a protocol based on HTTP [<a href="./rfc7230" title=""Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing"">RFC7230</a>] called
"RESTCONF", for configuring data defined in YANG version 1 [<a href="./rfc6020" title=""YANG - A Data Modeling Language for the Network Configuration Protocol (NETCONF)"">RFC6020</a>]
or YANG version 1.1 [<a href="./rfc7950" title=""The YANG 1.1 Data Modeling Language"">RFC7950</a>], using the datastore concepts defined
in the Network Configuration Protocol (NETCONF) [<a href="./rfc6241" title=""Network Configuration Protocol (NETCONF)"">RFC6241</a>].
NETCONF defines configuration datastores and a set of Create, Read,
Update, Delete (CRUD) operations that can be used to access these
datastores. NETCONF also defines a protocol for invoking these
operations. The YANG language defines the syntax and semantics of
datastore content, configuration, state data, RPC operations, and
event notifications.
RESTCONF uses HTTP methods to provide CRUD operations on a conceptual
datastore containing YANG-defined data, which is compatible with a
server that implements NETCONF datastores.
If a RESTCONF server is co-located with a NETCONF server, then there
are protocol interactions with the NETCONF protocol; these
interactions are described in <a href="#section-1.4">Section 1.4</a>. The RESTCONF server MAY
provide access to specific datastores using operation resources, as
described in <a href="#section-3.6">Section 3.6</a>. The RESTCONF protocol does not specify any
mandatory operation resources. The semantics of each operation
resource determine if and how datastores are accessed.
Configuration data and state data are exposed as resources that can
be retrieved with the GET method. Resources representing
configuration data can be modified with the DELETE, PATCH, POST, and
PUT methods. Data is encoded with either XML [<a href="#ref-W3C.REC-xml-20081126">W3C.REC-xml-20081126</a>]
or JSON [<a href="./rfc7159" title=""The JavaScript Object Notation (JSON) Data Interchange Format"">RFC7159</a>].
Data-model-specific RPC operations defined with the YANG "rpc" or
"action" statements can be invoked with the POST method. Data-model-
specific event notifications defined with the YANG "notification"
statement can be accessed.
<span class="h3"><a class="selflink" id="section-1.1" href="#section-1.1">1.1</a>. Terminology</span>
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in [<a href="./rfc2119" title=""Key words for use in RFCs to Indicate Requirement Levels"">RFC2119</a>].
<span class="grey">Bierman, et al. Standards Track [Page 5]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-6" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h4"><a class="selflink" id="section-1.1.1" href="#section-1.1.1">1.1.1</a>. NETCONF</span>
The following terms are defined in [<a href="./rfc6241" title=""Network Configuration Protocol (NETCONF)"">RFC6241</a>]:
o candidate configuration datastore
o configuration data
o datastore
o configuration datastore
o running configuration datastore
o startup configuration datastore
o state data
o user
<span class="h4"><a class="selflink" id="section-1.1.2" href="#section-1.1.2">1.1.2</a>. HTTP</span>
The following terms are defined in [<a href="./rfc3986" title=""Uniform Resource Identifier (URI): Generic Syntax"">RFC3986</a>]:
o fragment
o path
o query
The following terms are defined in [<a href="./rfc7230" title=""Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing"">RFC7230</a>]:
o header field
o message-body
o request-line
o request URI
o status-line
<span class="grey">Bierman, et al. Standards Track [Page 6]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-7" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The following terms are defined in [<a href="./rfc7231" title=""Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content"">RFC7231</a>]:
o method
o request
o resource
The following term is defined in [<a href="./rfc7232" title=""Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests"">RFC7232</a>]:
o entity-tag
<span class="h4"><a class="selflink" id="section-1.1.3" href="#section-1.1.3">1.1.3</a>. YANG</span>
The following terms are defined in [<a href="./rfc7950" title=""The YANG 1.1 Data Modeling Language"">RFC7950</a>]:
o action
o container
o data node
o key leaf
o leaf
o leaf-list
o list
o mandatory node
o ordered-by user
o presence container
o RPC operation
o top-level data node
<span class="h4"><a class="selflink" id="section-1.1.4" href="#section-1.1.4">1.1.4</a>. NETCONF Notifications</span>
The following term is defined in [<a href="./rfc5277" title=""NETCONF Event Notifications"">RFC5277</a>]:
o notification replay
<span class="grey">Bierman, et al. Standards Track [Page 7]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-8" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h4"><a class="selflink" id="section-1.1.5" href="#section-1.1.5">1.1.5</a>. Terms</span>
The following terms are used within this document:
o API resource: the resource that models the RESTCONF root resource
and the sub-resources to access YANG-defined content. It is
defined with the YANG data template named "yang-api" in the
"ietf-restconf" module.
o client: a RESTCONF client.
o data resource: a resource that models a YANG data node. It is
defined with YANG data definition statements.
o datastore resource: the resource that models a programmatic
interface using NETCONF datastore concepts. By default, RESTCONF
methods access a unified view of the underlying datastore
implementation on the server. It is defined as a sub-resource
within the API resource.
o edit operation: a RESTCONF operation on a data resource using
either a POST, PUT, PATCH, or DELETE method. This is not the same
as the NETCONF edit operation (i.e., one of the values for the
"nc:operation" attribute: "create", "replace", "merge", "delete",
or "remove").
o event stream resource: a resource that represents an SSE
(Server-Sent Events) event stream. The content consists of text
using the media type "text/event-stream", as defined by the SSE
specification [<a href="#ref-W3C.REC-eventsource-20150203">W3C.REC-eventsource-20150203</a>]. Event stream
contents are described in <a href="#section-3.8">Section 3.8</a>.
o media type: HTTP uses Internet media types [<a href="./rfc2046" title=""Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types"">RFC2046</a>] in the
"Content-Type" and "Accept" header fields in order to provide open
and extensible data typing and type negotiation.
o NETCONF client: a client that implements the NETCONF protocol.
Called "client" in [<a href="./rfc6241" title=""Network Configuration Protocol (NETCONF)"">RFC6241</a>].
o NETCONF server: a server that implements the NETCONF protocol.
Called "server" in [<a href="./rfc6241" title=""Network Configuration Protocol (NETCONF)"">RFC6241</a>].
o operation: the conceptual RESTCONF operation for a message,
derived from the HTTP method, request URI, header fields, and
message-body.
<span class="grey">Bierman, et al. Standards Track [Page 8]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-9" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
o operation resource: a resource that models a data-model-specific
operation that is in turn defined with a YANG "rpc" or "action"
statement. It is invoked with the POST method.
o patch: a PATCH method on the target datastore or data resource.
The media type of the message-body content will identify the patch
type in use.
o plain patch: a specific media type for use with the PATCH method;
see <a href="#section-4.6.1">Section 4.6.1</a>. It can be used for simple "merge" edit
operations. It is specified by a request Content-Type of
"application/yang-data+xml" or "application/yang-data+json".
o query parameter: a parameter (and its value, if any), encoded
within the query component of the request URI.
o resource type: one of the RESTCONF resource classes defined in
this document. One of "api", "datastore", "data", "operation",
"schema", or "event stream".
o RESTCONF capability: an optional RESTCONF protocol feature that is
advertised by a particular server if the feature is supported on
that server. The feature is identified by an IANA-registered
NETCONF Capability URI and advertised with an entry in the
"capability" leaf-list defined in <a href="#section-9.3">Section 9.3</a>.
o RESTCONF client: a client that implements the RESTCONF protocol.
o RESTCONF server: a server that implements the RESTCONF protocol.
o retrieval request: a request using the GET or HEAD methods.
o schema resource: a resource that is used by the client to retrieve
a YANG schema with the GET method. It has a representation with
the media type "application/yang".
o server: a RESTCONF server.
o "stream" list: the set of data resource instances that describe
the event stream resources available from the server. This
information is defined in the "ietf-restconf-monitoring" module as
the "stream" list. It can be retrieved using the target resource
"{+restconf}/data/ietf-restconf-monitoring:restconf-state/streams/
stream". The "stream" list contains information about each
stream, such as the URL to retrieve the event stream data.
o stream resource: an event stream resource.
<span class="grey">Bierman, et al. Standards Track [Page 9]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-10" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
o target resource: the resource that is associated with a particular
message, identified by the "path" component of the request URI.
o yang-data extension: a YANG external statement that conforms to
the "yang-data" extension statement, found in <a href="#section-8">Section 8</a>. The
yang-data extension is used to define YANG data structures that
are meant to be used as YANG data templates. These data
structures are not intended to be implemented as part of a
configuration datastore or as an operational state within the
server, so normal YANG data definition statements cannot be used.
o YANG data template: a schema for modeling protocol message
components as conceptual data structures using YANG. This allows
the messages to be defined in an encoding-independent manner.
Each YANG data template is defined with the "yang-data" extension,
found in <a href="#section-8">Section 8</a>. Representations of instances conforming to a
particular YANG data template can be defined for YANG. The XML
representation is defined in YANG version 1.1 [<a href="./rfc7950" title=""The YANG 1.1 Data Modeling Language"">RFC7950</a>] and
supported with the "application/yang-data+xml" media type. The
JSON representation is defined in "JSON Encoding of Data Modeled
with YANG" [<a href="./rfc7951" title=""JSON Encoding of Data Modeled with YANG"">RFC7951</a>] and supported with the
"application/yang-data+json" media type.
<span class="h4"><a class="selflink" id="section-1.1.6" href="#section-1.1.6">1.1.6</a>. URI Template and Examples</span>
Throughout this document, the URI template [<a href="./rfc6570" title=""URI Template"">RFC6570</a>] syntax
"{+restconf}" is used to refer to the RESTCONF root resource outside
of an example. See <a href="#section-3.1">Section 3.1</a> for details.
For simplicity, all of the examples in this document use "/restconf"
as the discovered RESTCONF API root path. Many of the examples
throughout the document are based on the "example-jukebox" YANG
module defined in <a href="#appendix-A.1">Appendix A.1</a>.
Many protocol header lines and message-body text within examples
throughout the document are split into multiple lines for display
purposes only. When a line ends with a backslash ("\") as the last
character, the line is wrapped for display purposes. It is to be
considered to be joined to the next line by deleting the backslash,
the following line break, and the leading whitespace of the
next line.
<span class="grey">Bierman, et al. Standards Track [Page 10]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-11" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h4"><a class="selflink" id="section-1.1.7" href="#section-1.1.7">1.1.7</a>. Tree Diagrams</span>
A simplified graphical representation of the data model is used in
this document. The meanings of the symbols in these diagrams are as
follows:
o Brackets "[" and "]" enclose list keys.
o Abbreviations before data node names: "rw" means configuration
data (read-write), "ro" means state data (read-only), and "x"
means operation resource (executable).
o Symbols after data node names: "?" means an optional node, "!"
means a presence container, and "*" denotes a list and leaf-list.
o Parentheses enclose choice and case nodes, and case nodes are also
marked with a colon (":").
o Ellipsis ("...") stands for contents of subtrees that are not
shown.
<span class="h3"><a class="selflink" id="section-1.2" href="#section-1.2">1.2</a>. Subset of NETCONF Functionality</span>
RESTCONF does not need to mirror the full functionality of the
NETCONF protocol, but it does need to be compatible with NETCONF.
RESTCONF achieves this by implementing a subset of the interaction
capabilities provided by the NETCONF protocol -- for instance, by
eliminating datastores and explicit locking.
RESTCONF uses HTTP methods to implement the equivalent of NETCONF
operations, enabling basic CRUD operations on a hierarchy of
conceptual resources.
The HTTP POST, PUT, PATCH, and DELETE methods are used to edit data
resources represented by YANG data models. These basic edit
operations allow the running configuration to be altered by a
RESTCONF client.
RESTCONF is not intended to replace NETCONF, but rather to provide an
HTTP interface that follows Representational State Transfer (REST)
principles [<a href="#ref-REST-Dissertation">REST-Dissertation</a>] and is compatible with the NETCONF
datastore model.
<span class="grey">Bierman, et al. Standards Track [Page 11]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-12" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h3"><a class="selflink" id="section-1.3" href="#section-1.3">1.3</a>. Data-Model-Driven API</span>
RESTCONF combines the simplicity of HTTP with the predictability and
automation potential of a schema-driven API. Knowing the YANG
modules used by the server, a client can derive all management
resource URLs and the proper structure of all RESTCONF requests and
responses. This strategy obviates the need for responses provided by
the server to contain Hypermedia as the Engine of Application State
(HATEOAS) links, originally described in Roy Fielding's doctoral
dissertation [<a href="#ref-REST-Dissertation">REST-Dissertation</a>], because the client can determine
the links it needs from the YANG modules.
RESTCONF utilizes the YANG library [<a href="./rfc7895" title=""YANG Module Library"">RFC7895</a>] to allow a client to
discover the YANG module conformance information for the server, in
case the client wants to use it.
The server can optionally support the retrieval of the YANG modules
it uses, as identified in its YANG library. See <a href="#section-3.7">Section 3.7</a> for
details.
The URIs for data-model-specific RPC operations and datastore content
are predictable, based on the YANG module definitions.
The RESTCONF protocol operates on a conceptual datastore defined with
the YANG data modeling language. The server lists each YANG module
it supports using the "ietf-yang-library" YANG module defined in
[<a href="./rfc7895" title=""YANG Module Library"">RFC7895</a>]. The server MUST implement the "ietf-yang-library" module,
which MUST identify all of the YANG modules used by the server, in
the "modules-state/module" list. The conceptual datastore contents,
data-model-specific RPC operations, and event notifications are
identified by this set of YANG modules.
The classification of data as configuration data or non-configuration
data is derived from the YANG "config" statement. Behavior related
to the ordering of data is derived from the YANG "ordered-by"
statement. Non-configuration data is also called "state data".
The RESTCONF datastore editing model is simple and direct, similar to
the behavior of the :writable-running capability in NETCONF. Each
RESTCONF edit of a data resource within the datastore resource is
activated upon successful completion of the edit.
<span class="grey">Bierman, et al. Standards Track [Page 12]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-13" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h3"><a class="selflink" id="section-1.4" href="#section-1.4">1.4</a>. Coexistence with NETCONF</span>
RESTCONF can be implemented on a device that supports the NETCONF
protocol.
The following figure shows the system components if a RESTCONF server
is co-located with a NETCONF server:
+-----------+ +-----------------+
| Web app | <-------> | |
+-----------+ RESTCONF | network device |
| |
+-----------+ | +-----------+ |
| NETCONF | <-------> | | datastore | |
| Client | NETCONF | | | |
+-----------+ | +-----------+ |
+-----------------+
The following figure shows the system components if a RESTCONF server
is implemented in a device that does not have a NETCONF server:
+-----------+ +-----------------+
| Web app | <-------> | |
+-----------+ RESTCONF | network device |
| |
+-----------------+
There are interactions between the NETCONF protocol and RESTCONF
protocol related to edit operations. It is possible that locks are
in use on a RESTCONF server, even though RESTCONF cannot manipulate
locks. In such a case, the RESTCONF protocol will not be granted
write access to data resources within a datastore.
If the NETCONF server supports :writable-running, all edits to
configuration nodes in {+restconf}/data are performed in the running
configuration datastore. The URI template "{+restconf}" is defined
in <a href="#section-1.1.6">Section 1.1.6</a>.
Otherwise, if the device supports :candidate, all edits to
configuration nodes in {+restconf}/data are performed in the
candidate configuration datastore. The candidate MUST be
automatically committed to running immediately after each successful
edit. Any edits from other sources that are in the candidate
datastore will also be committed. If a confirmed commit procedure is
in progress by any NETCONF client, then any new commit will act as
the confirming commit. If the NETCONF server is expecting a
<span class="grey">Bierman, et al. Standards Track [Page 13]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-14" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
"persist-id" parameter to complete the confirmed commit procedure,
then the RESTCONF edit operation MUST fail with a "409 Conflict"
status-line. The error-tag "in-use" is used in this case.
If the NETCONF server supports :startup, the RESTCONF server MUST
automatically update the non-volatile startup configuration
datastore, after the "running" datastore has been altered as a
consequence of a RESTCONF edit operation.
If a datastore that would be modified by a RESTCONF operation has an
active lock from a NETCONF client, the RESTCONF edit operation MUST
fail with a "409 Conflict" status-line. The error-tag value "in-use"
is returned in this case.
<span class="h3"><a class="selflink" id="section-1.5" href="#section-1.5">1.5</a>. RESTCONF Extensibility</span>
There are two extensibility mechanisms built into RESTCONF:
o protocol version
o optional capabilities
This document defines version 1 of the RESTCONF protocol. If a
future version of this protocol is defined, then that document will
specify how the new version of RESTCONF is identified. It is
expected that a different RESTCONF root resource will be used, which
will be located using a different link relation (see <a href="#section-3.1">Section 3.1</a>).
The server will advertise all protocol versions that it supports in
its host-meta data.
In this example, the server supports both RESTCONF version 1 and a
fictitious version 2.
The client might send the following:
GET /.well-known/host-meta HTTP/1.1
Host: example.com
Accept: application/xrd+xml
<span class="grey">Bierman, et al. Standards Track [Page 14]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-15" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The server might respond as follows:
HTTP/1.1 200 OK
Content-Type: application/xrd+xml
Content-Length: nnn
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>
<Link rel='restconf' href='/restconf'/>
<Link rel='restconf2' href='/restconf2'/>
</XRD>
RESTCONF also supports a server-defined list of optional
capabilities, which are listed by a server using the
"ietf-restconf-monitoring" module defined in <a href="#section-9.3">Section 9.3</a>. This
document defines several query parameters in <a href="#section-4.8">Section 4.8</a>. Each
optional parameter has a corresponding capability URI, defined in
<a href="#section-9.1.1">Section 9.1.1</a>, that is advertised by the server if supported.
The "capability" leaf-list can identify any sort of server extension.
Currently, this extension mechanism is used to identify optional
query parameters that are supported, but it is not limited to that
purpose. For example, the "defaults" URI defined in <a href="#section-9.1.2">Section 9.1.2</a>
specifies a mandatory URI identifying server default-handling
behavior.
A new sub-resource type could be identified with a capability if it
is optional to implement. Mandatory protocol features and new
resource types require a new revision of the RESTCONF protocol.
<span class="h2"><a class="selflink" id="section-2" href="#section-2">2</a>. Transport Protocol</span>
<span class="h3"><a class="selflink" id="section-2.1" href="#section-2.1">2.1</a>. Integrity and Confidentiality</span>
HTTP [<a href="./rfc7230" title=""Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing"">RFC7230</a>] is an application-layer protocol that may be layered
on any reliable transport-layer protocol. RESTCONF is defined on top
of HTTP, but due to the sensitive nature of the information conveyed,
RESTCONF requires that the transport-layer protocol provide both data
integrity and confidentiality. A RESTCONF server MUST support the
Transport Layer Security (TLS) protocol [<a href="./rfc5246" title=""The Transport Layer Security (TLS) Protocol Version 1.2"">RFC5246</a>] and SHOULD adhere
to [<a href="./rfc7525" title=""Recommendations for Secure Use of Transport Layer Security (TLS) and Datagram Transport Layer Security (DTLS)"">RFC7525</a>]. The RESTCONF protocol MUST NOT be used over HTTP
without using the TLS protocol.
RESTCONF does not require a specific version of HTTP. However, it is
RECOMMENDED that at least HTTP/1.1 [<a href="./rfc7230" title=""Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing"">RFC7230</a>] be supported by all
implementations.
<span class="grey">Bierman, et al. Standards Track [Page 15]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-16" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h3"><a class="selflink" id="section-2.2" href="#section-2.2">2.2</a>. HTTPS with X.509v3 Certificates</span>
Given the nearly ubiquitous support for HTTP over TLS [<a href="./rfc7230" title=""Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing"">RFC7230</a>],
RESTCONF implementations MUST support the "https" URI scheme, which
has the IANA-assigned default port 443.
RESTCONF servers MUST present an X.509v3-based certificate when
establishing a TLS connection with a RESTCONF client. The use of
X.509v3-based certificates is consistent with NETCONF over TLS
[<a href="./rfc7589" title=""Using the NETCONF Protocol over Transport Layer Security (TLS) with Mutual X.509 Authentication"">RFC7589</a>].
<span class="h3"><a class="selflink" id="section-2.3" href="#section-2.3">2.3</a>. Certificate Validation</span>
The RESTCONF client MUST either (1) use X.509 certificate path
validation [<a href="./rfc5280" title=""Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile"">RFC5280</a>] to verify the integrity of the RESTCONF server's
TLS certificate or (2) match the server's TLS certificate with a
certificate obtained by a trusted mechanism (e.g., a pinned
certificate). If X.509 certificate path validation fails and the
presented X.509 certificate does not match a certificate obtained by
a trusted mechanism, the connection MUST be terminated, as described
in <a href="./rfc5246#section-7.2.1">Section 7.2.1 of [RFC5246]</a>.
<span class="h3"><a class="selflink" id="section-2.4" href="#section-2.4">2.4</a>. Authenticated Server Identity</span>
The RESTCONF client MUST check the identity of the server according
to <a href="./rfc2818#section-3.1">Section 3.1 of [RFC2818]</a>.
<span class="h3"><a class="selflink" id="section-2.5" href="#section-2.5">2.5</a>. Authenticated Client Identity</span>
The RESTCONF server MUST authenticate client access to any protected
resource. If the RESTCONF client is not authenticated, the server
SHOULD send an HTTP response with a "401 Unauthorized" status-line,
as defined in <a href="./rfc7235#section-3.1">Section 3.1 of [RFC7235]</a>. The error-tag value
"access-denied" is used in this case.
To authenticate a client, a RESTCONF server SHOULD require
authentication based on TLS client certificates (<a href="./rfc5246#section-7.4.6">Section 7.4.6 of
[RFC5246]</a>). If certificate-based authentication is not feasible
(e.g., because one cannot build the required PKI for clients), then
HTTP authentication MAY be used. In the latter case, one of the HTTP
authentication schemes defined in the "Hypertext Transfer Protocol
(HTTP) Authentication Scheme Registry" (<a href="./rfc7235#section-5.1">Section 5.1 in [RFC7235]</a>)
MUST be used.
A server MAY also support the combination of both client certificates
and an HTTP client authentication scheme, with the determination of
how to process this combination left as an implementation decision.
<span class="grey">Bierman, et al. Standards Track [Page 16]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-17" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The RESTCONF client identity derived from the authentication
mechanism used is hereafter known as the "RESTCONF username" and
subject to the NETCONF Access Control Model (NACM) [<a href="./rfc6536" title=""Network Configuration Protocol (NETCONF) Access Control Model"">RFC6536</a>]. When a
client certificate is presented, the RESTCONF username MUST be
derived using the algorithm defined in <a href="./rfc7589#section-7">Section 7 of [RFC7589]</a>. For
all other cases, when HTTP authentication is used, the RESTCONF
username MUST be provided by the HTTP authentication scheme used.
<span class="h2"><a class="selflink" id="section-3" href="#section-3">3</a>. Resources</span>
The RESTCONF protocol operates on a hierarchy of resources, starting
with the top-level API resource itself (<a href="#section-3.1">Section 3.1</a>). Each resource
represents a manageable component within the device.
A resource can be considered as a collection of data and the set of
allowed methods on that data. It can contain nested child resources.
The child resource types and the methods allowed on them are specific
to the data model.
A resource has a representation associated with a media type
identifier, as represented by the "Content-Type" header field in the
HTTP response message. A resource has one or more representations,
each associated with a different media type. When a representation
of a resource is sent in an HTTP message, the associated media type
is given in the "Content-Type" header. A resource can contain zero
or more nested resources. A resource can be created and deleted
independently of its parent resource, as long as the parent resource
exists.
The RESTCONF resources are accessed via a set of URIs defined in this
document. The set of YANG modules supported by the server will
determine the data-model-specific RPC operations, top-level data
nodes, and event notification messages supported by the server.
The RESTCONF protocol does not include a data resource discovery
mechanism. Instead, the definitions within the YANG modules
advertised by the server are used to construct an RPC operation or
data resource identifier.
<span class="grey">Bierman, et al. Standards Track [Page 17]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-18" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h3"><a class="selflink" id="section-3.1" href="#section-3.1">3.1</a>. Root Resource Discovery</span>
In line with the best practices defined by [<a href="./rfc7320" title=""URI Design and Ownership"">RFC7320</a>], RESTCONF
enables deployments to specify where the RESTCONF API is located.
When first connecting to a RESTCONF server, a RESTCONF client MUST
determine the root of the RESTCONF API. There MUST be exactly one
"restconf" link relation returned by the device.
The client discovers this by getting the "/.well-known/host-meta"
resource ([<a href="./rfc6415" title=""Web Host Metadata"">RFC6415</a>]) and using the <Link> element containing the
"restconf" attribute:
Example returning /restconf:
The client might send the following:
GET /.well-known/host-meta HTTP/1.1
Host: example.com
Accept: application/xrd+xml
The server might respond as follows:
HTTP/1.1 200 OK
Content-Type: application/xrd+xml
Content-Length: nnn
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>
<Link rel='restconf' href='/restconf'/>
</XRD>
After discovering the RESTCONF API root, the client MUST use this
value as the initial part of the path in the request URI, in any
subsequent request for a RESTCONF resource.
In this example, the client would use the path "/restconf" as the
RESTCONF root resource.
Example returning /top/restconf:
The client might send the following:
GET /.well-known/host-meta HTTP/1.1
Host: example.com
Accept: application/xrd+xml
<span class="grey">Bierman, et al. Standards Track [Page 18]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-19" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The server might respond as follows:
HTTP/1.1 200 OK
Content-Type: application/xrd+xml
Content-Length: nnn
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>
<Link rel='restconf' href='/top/restconf'/>
</XRD>
In this example, the client would use the path "/top/restconf" as the
RESTCONF root resource.
The client can now determine the operation resources supported by the
server. In this example, a custom "play" operation is supported:
The client might send the following:
GET /top/restconf/operations HTTP/1.1
Host: example.com
Accept: application/yang-data+json
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Cache-Control: no-cache
Last-Modified: Thu, 26 Jan 2017 16:00:14 GMT
Content-Type: application/yang-data+json
{ "operations" : { "example-jukebox:play" : [null] } }
If the Extensible Resource Descriptor (XRD) contains more than one
link relation, then only the relation named "restconf" is relevant to
this specification.
Note that any given endpoint (host:port) can only support one
RESTCONF server, due to the root resource discovery mechanism. This
limits the number of RESTCONF servers that can run concurrently on a
host, since each server must use a different port.
<span class="grey">Bierman, et al. Standards Track [Page 19]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-20" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h3"><a class="selflink" id="section-3.2" href="#section-3.2">3.2</a>. RESTCONF Media Types</span>
The RESTCONF protocol defines two application-specific media types to
identify representations of data that conforms to the schema for a
particular YANG construct.
This document defines media types for XML and JSON serialization
of YANG data. Other documents MAY define other media types for
different serializations of YANG data. The
"application/yang-data+xml" media type is defined in <a href="#section-11.3.1">Section 11.3.1</a>.
The "application/yang-data+json" media type is defined in
<a href="#section-11.3.2">Section 11.3.2</a>.
<span class="h3"><a class="selflink" id="section-3.3" href="#section-3.3">3.3</a>. API Resource</span>
The API resource contains the RESTCONF root resource for the RESTCONF
datastore and operation resources. It is the top-level resource
located at {+restconf} and has the media type
"application/yang-data+xml" or "application/yang-data+json".
YANG tree diagram for an API resource:
+---- {+restconf}
+---- data
| ...
+---- operations?
| ...
+--ro yang-library-version string
The "yang-api" YANG data template is defined using the "yang-data"
extension in the "ietf-restconf" module, found in <a href="#section-8">Section 8</a>. It
specifies the structure and syntax of the conceptual child resources
within the API resource.
The API resource can be retrieved with the GET method.
The {+restconf} root resource name used in responses representing the
root of the "ietf-restconf" module MUST identify the "ietf-restconf"
YANG module. For example, a request to GET the root resource
"/restconf" in JSON format will return a representation of the API
resource named "ietf-restconf:restconf".
<span class="grey">Bierman, et al. Standards Track [Page 20]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-21" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
This resource has the following child resources:
+----------------------+---------------------------------+
| Child Resource | Description |
+----------------------+---------------------------------+
| data | Contains all data resources |
| operations | Data-model-specific operations |
| yang-library-version | "ietf-yang-library" module date |
+----------------------+---------------------------------+
RESTCONF API Resource
<span class="h4"><a class="selflink" id="section-3.3.1" href="#section-3.3.1">3.3.1</a>. {+restconf}/data</span>
This mandatory resource represents the combined configuration and
state data resources that can be accessed by a client. It cannot be
created or deleted by the client. The datastore resource type is
defined in <a href="#section-3.4">Section 3.4</a>.
Example:
This example request by the client would retrieve only the
non-configuration data nodes that exist within the "library"
resource, using the "content" query parameter (see <a href="#section-4.8.1">Section 4.8.1</a>).
GET /restconf/data/example-jukebox:jukebox/library\
?content=nonconfig HTTP/1.1
Host: example.com
Accept: application/yang-data+xml
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Cache-Control: no-cache
Content-Type: application/yang-data+xml
<library xmlns="https://example.com/ns/example-jukebox">
<artist-count>42</artist-count>
<album-count>59</album-count>
<song-count>374</song-count>
</library>
<span class="grey">Bierman, et al. Standards Track [Page 21]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-22" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h4"><a class="selflink" id="section-3.3.2" href="#section-3.3.2">3.3.2</a>. {+restconf}/operations</span>
This optional resource is a container that provides access to the
data-model-specific RPC operations supported by the server. The
server MAY omit this resource if no data-model-specific RPC
operations are advertised.
Any data-model-specific RPC operations defined in the YANG modules
advertised by the server MUST be available as child nodes of this
resource.
The access point for each RPC operation is represented as an empty
leaf. If an operation resource is retrieved, the empty leaf
representation is returned by the server.
Operation resources are defined in <a href="#section-3.6">Section 3.6</a>.
<span class="h4"><a class="selflink" id="section-3.3.3" href="#section-3.3.3">3.3.3</a>. {+restconf}/yang-library-version</span>
This mandatory leaf identifies the revision date of the
"ietf-yang-library" YANG module that is implemented by this server.
In the example that follows, the revision date for the module version
found in [<a href="./rfc7895" title=""YANG Module Library"">RFC7895</a>] is used.
Example:
GET /restconf/yang-library-version HTTP/1.1
Host: example.com
Accept: application/yang-data+xml
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Cache-Control: no-cache
Content-Type: application/yang-data+xml
<yang-library-version
xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">\
2016-06-21\
</yang-library-version>
<span class="grey">Bierman, et al. Standards Track [Page 22]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-23" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h3"><a class="selflink" id="section-3.4" href="#section-3.4">3.4</a>. Datastore Resource</span>
The "{+restconf}/data" subtree represents the datastore resource,
which is a collection of configuration data and state data nodes.
This resource type is an abstraction of the system's underlying
datastore implementation. The client uses it to edit and retrieve
data resources, as the conceptual root of all configuration and state
data that is present on the device.
Configuration edit transaction management and configuration
persistence are handled by the server and not controlled by the
client. A datastore resource can be written directly with the POST
and PATCH methods. Each RESTCONF edit of a datastore resource is
saved to non-volatile storage by the server if the server supports
non-volatile storage of configuration data, as described in
<a href="#section-1.4">Section 1.4</a>.
If the datastore resource represented by the "{+restconf}/data"
subtree is retrieved, then the datastore and its contents are
returned by the server. The datastore is represented by a node named
"data" in the "ietf-restconf" module namespace.
<span class="h4"><a class="selflink" id="section-3.4.1" href="#section-3.4.1">3.4.1</a>. Edit Collision Prevention</span>
Two edit collision detection and prevention mechanisms are provided
in RESTCONF for the datastore resource: a timestamp and an
entity-tag. Any change to configuration data resources updates the
timestamp and entity-tag of the datastore resource. In addition, the
RESTCONF server MUST return an error if the datastore is locked by an
external source (e.g., NETCONF server).
<span class="h5"><a class="selflink" id="section-3.4.1.1" href="#section-3.4.1.1">3.4.1.1</a>. Timestamp</span>
The last change time is maintained, and the "Last-Modified" header
field (<a href="./rfc7232#section-2.2">Section 2.2 of [RFC7232]</a>) is returned in the response for a
retrieval request. The "If-Unmodified-Since" header field
(<a href="./rfc7232#section-3.4">Section 3.4 of [RFC7232]</a>) can be used in edit operation requests to
cause the server to reject the request if the resource has been
modified since the specified timestamp.
The server SHOULD maintain a last-modified timestamp for the
datastore resource, defined in <a href="#section-3.4">Section 3.4</a>. This timestamp is only
affected by configuration child data resources and MUST NOT be
updated for changes to non-configuration child data resources.
Last-modified timestamps for data resources are discussed in
<a href="#section-3.5">Section 3.5</a>.
<span class="grey">Bierman, et al. Standards Track [Page 23]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-24" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
If the RESTCONF server is co-located with a NETCONF server, then the
last-modified timestamp MUST be for the "running" datastore. Note
that it is possible that other protocols can cause the last-modified
timestamp to be updated. Such mechanisms are out of scope for this
document.
<span class="h5"><a class="selflink" id="section-3.4.1.2" href="#section-3.4.1.2">3.4.1.2</a>. Entity-Tag</span>
The server MUST maintain a unique opaque entity-tag for the datastore
resource and MUST return it in the "ETag" (<a href="./rfc7232#section-2.3">Section 2.3 of [RFC7232]</a>)
header in the response for a retrieval request. The client MAY use
an "If-Match" header in edit operation requests to cause the server
to reject the request if the resource entity-tag does not match the
specified value.
The server MUST maintain an entity-tag for the top-level
{+restconf}/data resource. This entity-tag is only affected by
configuration data resources and MUST NOT be updated for changes to
non-configuration data. Entity-tags for data resources are discussed
in <a href="#section-3.5">Section 3.5</a>. Note that each representation (e.g., XML vs. JSON)
requires a different entity-tag.
If the RESTCONF server is co-located with a NETCONF server, then this
entity-tag MUST be for the "running" datastore. Note that it is
possible that other protocols can cause the entity-tag to be updated.
Such mechanisms are out of scope for this document.
<span class="h5"><a class="selflink" id="section-3.4.1.3" href="#section-3.4.1.3">3.4.1.3</a>. Update Procedure</span>
Changes to configuration data resources affect the timestamp and
entity-tag for that resource, any ancestor data resources, and the
datastore resource.
For example, an edit to disable an interface might be done by setting
the leaf "/interfaces/interface/enabled" to "false". The "enabled"
data node and its ancestors (one "interface" list instance, and the
"interfaces" container) are considered to be changed. The datastore
is considered to be changed when any top-level configuration data
node is changed (e.g., "interfaces").
<span class="h3"><a class="selflink" id="section-3.5" href="#section-3.5">3.5</a>. Data Resource</span>
A data resource represents a YANG data node that is a descendant node
of a datastore resource. Each YANG-defined data node can be uniquely
targeted by the request-line of an HTTP method. Containers, leafs,
leaf-list entries, list entries, anydata nodes, and anyxml nodes are
data resources.
<span class="grey">Bierman, et al. Standards Track [Page 24]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-25" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The representation maintained for each data resource is the
YANG-defined subtree for that node. HTTP methods on a data resource
affect both the targeted data node and all of its descendants,
if any.
A data resource can be retrieved with the GET method. Data resources
are accessed via the "{+restconf}/data" URI. This subtree is used to
retrieve and edit data resources.
<span class="h4"><a class="selflink" id="section-3.5.1" href="#section-3.5.1">3.5.1</a>. Timestamp</span>
For configuration data resources, the server MAY maintain a
last-modified timestamp for the resource and return the
"Last-Modified" header field when it is retrieved with the GET or
HEAD methods.
The "Last-Modified" header field can be used by a RESTCONF client in
subsequent requests, within the "If-Modified-Since" and
"If-Unmodified-Since" header fields.
If maintained, the resource timestamp MUST be set to the current time
whenever the resource or any configuration resource within the
resource is altered. If not maintained, then the resource timestamp
for the datastore MUST be used instead. If the RESTCONF server is
co-located with a NETCONF server, then the last-modified timestamp
for a configuration data resource MUST represent the instance within
the "running" datastore.
This timestamp is only affected by configuration data resources and
MUST NOT be updated for changes to non-configuration data.
<span class="h4"><a class="selflink" id="section-3.5.2" href="#section-3.5.2">3.5.2</a>. Entity-Tag</span>
For configuration data resources, the server SHOULD maintain a
resource entity-tag for each resource and return the "ETag" header
field when it is retrieved as the target resource with the GET or
HEAD methods. If maintained, the resource entity-tag MUST be updated
whenever the resource or any configuration resource within the
resource is altered. If not maintained, then the resource entity-tag
for the datastore MUST be used instead.
The "ETag" header field can be used by a RESTCONF client in
subsequent requests, within the "If-Match" and "If-None-Match" header
fields.
<span class="grey">Bierman, et al. Standards Track [Page 25]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-26" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
This entity-tag is only affected by configuration data resources and
MUST NOT be updated for changes to non-configuration data. If the
RESTCONF server is co-located with a NETCONF server, then the
entity-tag for a configuration data resource MUST represent the
instance within the "running" datastore.
<span class="h4"><a class="selflink" id="section-3.5.3" href="#section-3.5.3">3.5.3</a>. Encoding Data Resource Identifiers in the Request URI</span>
In YANG, data nodes can be identified with an absolute XPath
expression, defined in [<a href="#ref-XPath" title=""XML Path Language (XPath) Version 1.0"">XPath</a>], starting from the document root to
the target resource. In RESTCONF, URI-encoded path expressions are
used instead.
A predictable location for a data resource is important, since
applications will code to the YANG data model module, which uses
static naming and defines an absolute path location for all data
nodes.
A RESTCONF data resource identifier is encoded from left to right,
starting with the top-level data node, according to the "api-path"
rule in <a href="#section-3.5.3.1">Section 3.5.3.1</a>. The node name of each ancestor of the
target resource node is encoded in order, ending with the node name
for the target resource. If a node in the path is defined in a
module other than its parent node or its parent is the datastore,
then the module name followed by a colon character (":") MUST be
prepended to the node name in the resource identifier. See
<a href="#section-3.5.3.1">Section 3.5.3.1</a> for details.
If a data node in the path expression is a YANG leaf-list node, then
the leaf-list value MUST be encoded according to the following rules:
o The identifier for the leaf-list MUST be encoded using one path
segment [<a href="./rfc3986" title=""Uniform Resource Identifier (URI): Generic Syntax"">RFC3986</a>].
o The path segment is constructed by having the leaf-list name,
followed by an "=" character, followed by the leaf-list value
(e.g., /restconf/data/top-leaflist=fred).
o The leaf-list value is specified as a string, using the canonical
representation for the YANG data type. Any reserved characters
MUST be percent-encoded, according to Sections <a href="#section-2.1">2.1</a> and <a href="#section-2.5">2.5</a> of
[<a href="./rfc3986" title=""Uniform Resource Identifier (URI): Generic Syntax"">RFC3986</a>].
<span class="grey">Bierman, et al. Standards Track [Page 26]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-27" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
o YANG 1.1 allows duplicate leaf-list values for non-configuration
data. In this case, there is no mechanism to specify the exact
matching leaf-list instance.
o The comma (",") character is percent-encoded [<a href="./rfc3986" title=""Uniform Resource Identifier (URI): Generic Syntax"">RFC3986</a>], even
though multiple key values are not possible for a leaf-list. This
is more consistent and avoids special processing rules.
If a data node in the path expression is a YANG list node, then the
key values for the list (if any) MUST be encoded according to the
following rules:
o The key leaf values for a data resource representing a YANG list
MUST be encoded using one path segment [<a href="./rfc3986" title=""Uniform Resource Identifier (URI): Generic Syntax"">RFC3986</a>].
o If there is only one key leaf value, the path segment is
constructed by having the list name, followed by an "=" character,
followed by the single key leaf value.
o If there are multiple key leaf values, the path segment is
constructed by having the list name, followed by the value of each
leaf identified in the "key" statement, encoded in the order
specified in the YANG "key" statement. Each key leaf value except
the last one is followed by a comma character.
o The key value is specified as a string, using the canonical
representation for the YANG data type. Any reserved characters
MUST be percent-encoded, according to Sections <a href="#section-2.1">2.1</a> and <a href="#section-2.5">2.5</a> of
[<a href="./rfc3986" title=""Uniform Resource Identifier (URI): Generic Syntax"">RFC3986</a>]. The comma (",") character MUST be percent-encoded if
it is present in the key value.
o All of the components in the "key" statement MUST be encoded.
Partial instance identifiers are not supported.
o Missing key values are not allowed, so two consecutive commas are
interpreted as a comma, followed by a zero-length string, followed
by a comma. For example, "list1=foo,,baz" would be interpreted as
a list named "list1" with three key values, and the second key
value is a zero-length string.
o Note that non-configuration lists are not required to define keys.
In this case, a single list instance cannot be accessed.
o The "list-instance" Augmented Backus-Naur Form (ABNF) [<a href="./rfc5234" title=""Augmented BNF for Syntax Specifications: ABNF"">RFC5234</a>]
rule defined in <a href="#section-3.5.3.1">Section 3.5.3.1</a> represents the syntax of a list
instance identifier.
<span class="grey">Bierman, et al. Standards Track [Page 27]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-28" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
Examples:
container top {
list list1 {
key "key1 key2 key3";
...
list list2 {
key "key4 key5";
...
leaf X { type string; }
}
}
leaf-list Y {
type uint32;
}
}
For the above YANG definition, the container "top" is defined in the
"example-top" YANG module, and a target resource URI for leaf "X"
would be encoded as follows:
/restconf/data/example-top:top/list1=key1,key2,key3/\
list2=key4,key5/X
For the above YANG definition, a target resource URI for
leaf-list "Y" would be encoded as follows:
/restconf/data/example-top:top/Y=instance-value
The following example shows how reserved characters are
percent-encoded within a key value. The value of "key1" contains
a comma, single-quote, double-quote, colon, double-quote, space,
and forward slash (,'":" /). Note that double-quote is not a
reserved character and does not need to be percent-encoded. The
value of "key2" is the empty string, and the value of "key3" is the
string "foo".
Example URL:
/restconf/data/example-top:top/list1=%2C%27"%3A"%20%2F,,foo
<span class="h5"><a class="selflink" id="section-3.5.3.1" href="#section-3.5.3.1">3.5.3.1</a>. ABNF for Data Resource Identifiers</span>
The "api-path" ABNF [<a href="./rfc5234" title=""Augmented BNF for Syntax Specifications: ABNF"">RFC5234</a>] syntax is used to construct RESTCONF
path identifiers. Note that this syntax is used for all resources,
and the API path starts with the RESTCONF root resource. Data
resources are required to be identified under the "{+restconf}/data"
subtree.
<span class="grey">Bierman, et al. Standards Track [Page 28]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-29" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
An identifier is not allowed to start with the case-insensitive
string "XML", according to YANG identifier rules. The syntax for
"api-identifier" and "key-value" MUST conform to the JSON identifier
encoding rules in <a href="./rfc7951#section-4">Section 4 of [RFC7951]</a>: The RESTCONF root resource
path is required. Additional sub-resource identifiers are optional.
The characters in a key value string are constrained, and some
characters need to be percent-encoded, as described in <a href="#section-3.5.3">Section 3.5.3</a>.
api-path = root *("/" (api-identifier / list-instance))
root = string ;; replacement string for {+restconf}
api-identifier = [module-name ":"] identifier
module-name = identifier
list-instance = api-identifier "=" key-value *("," key-value)
key-value = string ;; constrained chars are percent-encoded
string = <an unquoted string>
identifier = (ALPHA / "_")
*(ALPHA / DIGIT / "_" / "-" / ".")
<span class="h4"><a class="selflink" id="section-3.5.4" href="#section-3.5.4">3.5.4</a>. Default Handling</span>
RESTCONF requires that a server report its default-handling mode (see
<a href="#section-9.1.2">Section 9.1.2</a> for details). If the optional "with-defaults" query
parameter is supported by the server, a client may use it to control
the retrieval of default values (see <a href="#section-4.8.9">Section 4.8.9</a> for details).
If a leaf or leaf-list is missing from the configuration and there is
a YANG-defined default for that data resource, then the server MUST
use the YANG-defined default as the configured value.
If the target of a GET method is a data node that represents a leaf
or leaf-list that has a default value and the leaf or leaf-list has
not been instantiated yet, the server MUST return the default value
or values that are in use by the server. In this case, the server
MUST ignore its "basic-mode", described in <a href="#section-4.8.9">Section 4.8.9</a>, and return
the default value.
If the target of a GET method is a data node that represents a
container or list that has any child resources with default values,
for the child resources that have not been given values yet, the
<span class="grey">Bierman, et al. Standards Track [Page 29]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-30" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
server MAY return the default values that are in use by the server in
accordance with its reported default-handling mode and query
parameters passed by the client.
<span class="h3"><a class="selflink" id="section-3.6" href="#section-3.6">3.6</a>. Operation Resource</span>
An operation resource represents an RPC operation defined with the
YANG "rpc" statement or a data-model-specific action defined with a
YANG "action" statement. It is invoked using a POST method on the
operation resource.
An RPC operation is invoked as:
POST {+restconf}/operations/<operation>
The <operation> field identifies the module name and rpc identifier
string for the desired operation.
For example, if "module-A" defined a "reset" RPC operation, then
invoking the operation would be requested as follows:
POST /restconf/operations/module-A:reset HTTP/1.1
Server: example.com
An action is invoked as:
POST {+restconf}/data/<data-resource-identifier>/<action>
where <data-resource-identifier> contains the path to the data node
where the action is defined, and <action> is the name of the action.
For example, if "module-A" defined a "reset-all" action in the
container "interfaces", then invoking this action would be requested
as follows:
POST /restconf/data/module-A:interfaces/reset-all HTTP/1.1
Server: example.com
If the RPC operation is invoked without errors and if the "rpc" or
"action" statement has no "output" section, the response message
MUST NOT include a message-body and MUST send a "204 No Content"
status-line instead.
All operation resources representing RPC operations supported by the
server MUST be identified in the "{+restconf}/operations" subtree,
defined in <a href="#section-3.3.2">Section 3.3.2</a>. Operation resources representing YANG
actions are not identified in this subtree, since they are invoked
using a URI within the "{+restconf}/data" subtree.
<span class="grey">Bierman, et al. Standards Track [Page 30]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-31" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h4"><a class="selflink" id="section-3.6.1" href="#section-3.6.1">3.6.1</a>. Encoding Operation Resource Input Parameters</span>
If the "rpc" or "action" statement has an "input" section, then
instances of these input parameters are encoded in the module
namespace where the "rpc" or "action" statement is defined, in an XML
element or JSON object named "input", which is in the module
namespace where the "rpc" or "action" statement is defined.
If the "rpc" or "action" statement has an "input" section and the
"input" object tree contains any child data nodes that are considered
mandatory nodes, then a message-body MUST be sent by the client in
the request.
If the "rpc" or "action" statement has an "input" section and the
"input" object tree does not contain any child nodes that are
considered mandatory nodes, then a message-body MAY be sent by the
client in the request.
If the "rpc" or "action" statement has no "input" section, the
request message MUST NOT include a message-body.
Examples:
The following YANG module is used for the RPC operation examples in
this section.
module example-ops {
namespace "https://example.com/ns/example-ops";
prefix "ops";
organization "Example, Inc.";
contact "support at example.com";
description "Example Operations Data Model Module.";
revision "2016-07-07" {
description "Initial version.";
reference "example.com document 3-3373.";
}
<span class="grey">Bierman, et al. Standards Track [Page 31]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-32" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
rpc reboot {
description "Reboot operation.";
input {
leaf delay {
type uint32;
units "seconds";
default 0;
description
"Number of seconds to wait before initiating the
reboot operation.";
}
leaf message {
type string;
description
"Log message to display when reboot is started.";
}
leaf language {
type string;
description "Language identifier string.";
reference "<a href="./rfc5646">RFC 5646</a>.";
}
}
}
<span class="grey">Bierman, et al. Standards Track [Page 32]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-33" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
rpc get-reboot-info {
description
"Retrieve parameters used in the last reboot operation.";
output {
leaf reboot-time {
type uint32;
description
"The 'delay' parameter used in the last reboot
operation.";
}
leaf message {
type string;
description
"The 'message' parameter used in the last reboot
operation.";
}
leaf language {
type string;
description
"The 'language' parameter used in the last reboot
operation.";
}
}
}
}
The following YANG module is used for the YANG action examples in
this section.
module example-actions {
yang-version 1.1;
namespace "https://example.com/ns/example-actions";
prefix "act";
import ietf-yang-types { prefix yang; }
organization "Example, Inc.";
contact "support at example.com";
description "Example Actions Data Model Module.";
revision "2016-07-07" {
description "Initial version.";
reference "example.com document 2-9973.";
}
<span class="grey">Bierman, et al. Standards Track [Page 33]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-34" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
container interfaces {
description "System interfaces.";
list interface {
key name;
description "One interface entry.";
leaf name {
type string;
description "Interface name.";
}
action reset {
description "Reset an interface.";
input {
leaf delay {
type uint32;
units "seconds";
default 0;
description
"Number of seconds to wait before starting the
interface reset.";
}
}
}
action get-last-reset-time {
description
"Retrieve the last interface reset time.";
output {
leaf last-reset {
type yang:date-and-time;
mandatory true;
description
"Date and time of the last interface reset, or
the last reboot time of the device.";
}
}
}
}
}
}
<span class="grey">Bierman, et al. Standards Track [Page 34]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-35" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
RPC Input Example:
The client might send the following POST request message to invoke
the "reboot" RPC operation:
POST /restconf/operations/example-ops:reboot HTTP/1.1
Host: example.com
Content-Type: application/yang-data+xml
<input xmlns="https://example.com/ns/example-ops">
<delay>600</delay>
<message>Going down for system maintenance</message>
<language>en-US</language>
</input>
The server might respond as follows:
HTTP/1.1 204 No Content
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
The same example request message is shown here using JSON encoding:
POST /restconf/operations/example-ops:reboot HTTP/1.1
Host: example.com
Content-Type: application/yang-data+json
{
"example-ops:input" : {
"delay" : 600,
"message" : "Going down for system maintenance",
"language" : "en-US"
}
}
Action Input Example:
The client might send the following POST request message to invoke
the "reset" action:
POST /restconf/data/example-actions:interfaces/\
interface=eth0/reset HTTP/1.1
Host: example.com
Content-Type: application/yang-data+xml
<input xmlns="https://example.com/ns/example-actions">
<delay>600</delay>
</input>
<span class="grey">Bierman, et al. Standards Track [Page 35]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-36" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The server might respond as follows:
HTTP/1.1 204 No Content
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
The same example request message is shown here using JSON encoding:
POST /restconf/data/example-actions:interfaces/\
interface=eth0/reset HTTP/1.1
Host: example.com
Content-Type: application/yang-data+json
{ "example-actions:input" : {
"delay" : 600
}
}
<span class="h4"><a class="selflink" id="section-3.6.2" href="#section-3.6.2">3.6.2</a>. Encoding Operation Resource Output Parameters</span>
If the "rpc" or "action" statement has an "output" section, then
instances of these output parameters are encoded in the module
namespace where the "rpc" or "action" statement is defined, in an XML
element or JSON object named "output", which is in the module
namespace where the "rpc" or "action" statement is defined.
If the RPC operation is invoked without errors, and if the "rpc" or
"action" statement has an "output" section and the "output" object
tree contains any child data nodes that are considered mandatory
nodes, then a response message-body MUST be sent by the server in the
response.
If the RPC operation is invoked without errors, and if the "rpc" or
"action" statement has an "output" section and the "output" object
tree does not contain any child nodes that are considered mandatory
nodes, then a response message-body MAY be sent by the server in the
response.
The request URI is not returned in the response. Knowledge of the
request URI may be needed to associate the output with the specific
"rpc" or "action" statement used in the request.
<span class="grey">Bierman, et al. Standards Track [Page 36]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-37" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
Examples:
RPC Output Example:
The "example-ops" YANG module defined in <a href="#section-3.6.1">Section 3.6.1</a> is used for
this example.
The client might send the following POST request message to invoke
the "get-reboot-info" operation:
POST /restconf/operations/example-ops:get-reboot-info HTTP/1.1
Host: example.com
Accept: application/yang-data+json
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Content-Type: application/yang-data+json
{
"example-ops:output" : {
"reboot-time" : 30,
"message" : "Going down for system maintenance",
"language" : "en-US"
}
}
The same response is shown here using XML encoding:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Content-Type: application/yang-data+xml
<output xmlns="https://example.com/ns/example-ops">
<reboot-time>30</reboot-time>
<message>Going down for system maintenance</message>
<language>en-US</language>
</output>
<span class="grey">Bierman, et al. Standards Track [Page 37]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-38" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
Action Output Example:
The "example-actions" YANG module defined in <a href="#section-3.6.1">Section 3.6.1</a> is used
for this example.
The client might send the following POST request message to invoke
the "get-last-reset-time" action:
POST /restconf/data/example-actions:interfaces/\
interface=eth0/get-last-reset-time HTTP/1.1
Host: example.com
Accept: application/yang-data+json
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Content-Type: application/yang-data+json
{
"example-actions:output" : {
"last-reset" : "2015-10-10T02:14:11Z"
}
}
<span class="h4"><a class="selflink" id="section-3.6.3" href="#section-3.6.3">3.6.3</a>. Encoding Operation Resource Errors</span>
If any errors occur while attempting to invoke the operation or
action, then an "errors" media type is returned with the appropriate
error status.
If (1) the RPC operation input is not valid or (2) the RPC operation
is invoked but errors occur, then a message-body containing an
"errors" resource MUST be sent by the server, as defined in
<a href="#section-3.9">Section 3.9</a>.
<span class="grey">Bierman, et al. Standards Track [Page 38]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-39" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
Using the "reboot" RPC operation from the example in <a href="#section-3.6.1">Section 3.6.1</a>,
the client might send the following POST request message:
POST /restconf/operations/example-ops:reboot HTTP/1.1
Host: example.com
Content-Type: application/yang-data+xml
<input xmlns="https://example.com/ns/example-ops">
<delay>-33</delay>
<message>Going down for system maintenance</message>
<language>en-US</language>
</input>
The server might respond with an "invalid-value" error:
HTTP/1.1 400 Bad Request
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Content-Type: application/yang-data+xml
<errors xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
<error>
<error-type>protocol</error-type>
<error-tag>invalid-value</error-tag>
<error-path xmlns:ops="https://example.com/ns/example-ops">
/ops:input/ops:delay
</error-path>
<error-message>Invalid input parameter</error-message>
</error>
</errors>
<span class="grey">Bierman, et al. Standards Track [Page 39]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-40" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The same response is shown here using JSON encoding:
HTTP/1.1 400 Bad Request
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Content-Type: application/yang-data+json
{ "ietf-restconf:errors" : {
"error" : [
{
"error-type" : "protocol",
"error-tag" : "invalid-value",
"error-path" : "/example-ops:input/delay",
"error-message" : "Invalid input parameter"
}
]
}
}
<span class="h3"><a class="selflink" id="section-3.7" href="#section-3.7">3.7</a>. Schema Resource</span>
The server can optionally support the retrieval of the YANG modules
it uses. If retrieval is supported, then the "schema" leaf MUST be
present in the associated "module" list entry, defined in [<a href="./rfc7895" title=""YANG Module Library"">RFC7895</a>].
To retrieve a YANG module, a client first needs to get the URL for
retrieving the schema, which is stored in the "schema" leaf. Note
that there is no required structure for this URL. The URL value
shown below is just an example.
The client might send the following GET request message:
GET /restconf/data/ietf-yang-library:modules-state/\
module=example-jukebox,2016-08-15/schema HTTP/1.1
Host: example.com
Accept: application/yang-data+json
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Content-Type: application/yang-data+json
{
"ietf-yang-library:schema" :
"https://example.com/mymodules/example-jukebox/2016-08-15"
}
<span class="grey">Bierman, et al. Standards Track [Page 40]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-41" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
Next, the client needs to retrieve the actual YANG schema.
The client might send the following GET request message:
GET https://example.com/mymodules/example-jukebox/\
2016-08-15 HTTP/1.1
Host: example.com
Accept: application/yang
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Content-Type: application/yang
// entire YANG module contents deleted for this example...
<span class="h3"><a class="selflink" id="section-3.8" href="#section-3.8">3.8</a>. Event Stream Resource</span>
An event stream resource represents a source for system-generated
event notifications. Each stream is created and modified by the
server only. A client can retrieve a stream resource or initiate a
long-poll server-sent event stream [<a href="#ref-W3C.REC-eventsource-20150203">W3C.REC-eventsource-20150203</a>],
using the procedure specified in <a href="#section-6.3">Section 6.3</a>.
An event stream functions according to the "NETCONF Event
Notifications" specification [<a href="./rfc5277" title=""NETCONF Event Notifications"">RFC5277</a>]. The available streams can be
retrieved from the "stream" list, which specifies the syntax and
semantics of the stream resources.
<span class="h3"><a class="selflink" id="section-3.9" href="#section-3.9">3.9</a>. "errors" YANG Data Template</span>
The "errors" YANG data template models a collection of error
information that is sent as the message-body in a server response
message if an error occurs while processing a request message. It is
not considered as a resource type because no instances can be
retrieved with a GET request.
The "ietf-restconf" YANG module contains the "yang-errors" YANG data
template, which specifies the syntax and semantics of an "errors"
container within a RESTCONF response. RESTCONF error-handling
behavior is defined in <a href="#section-7">Section 7</a>.
<span class="grey">Bierman, et al. Standards Track [Page 41]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-42" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h2"><a class="selflink" id="section-4" href="#section-4">4</a>. RESTCONF Methods</span>
The RESTCONF protocol uses HTTP methods to identify the CRUD
operations requested for a particular resource.
The following table shows how the RESTCONF operations relate to
NETCONF protocol operations.
+----------+-------------------------------------------------------+
| RESTCONF | NETCONF |
+----------+-------------------------------------------------------+
| OPTIONS | none |
| | |
| HEAD | <get-config>, <get> |
| | |
| GET | <get-config>, <get> |
| | |
| POST | <edit-config> (nc:operation="create") |
| | |
| POST | invoke an RPC operation |
| | |
| PUT | <copy-config> (PUT on datastore) |
| | |
| PUT | <edit-config> (nc:operation="create/replace") |
| | |
| PATCH | <edit-config> (nc:operation depends on PATCH content) |
| | |
| DELETE | <edit-config> (nc:operation="delete") |
+----------+-------------------------------------------------------+
CRUD Methods in RESTCONF
The "remove" edit operation attribute for the NETCONF <edit-config>
RPC operation is not supported by the HTTP DELETE method. The
resource must exist or the DELETE method will fail. The PATCH method
is equivalent to a "merge" edit operation when using a plain patch
(see <a href="#section-4.6.1">Section 4.6.1</a>); other media types may provide more granular
control.
Access control mechanisms are used to limit what CRUD operations can
be used. In particular, RESTCONF is compatible with the NETCONF
Access Control Model (NACM) [<a href="./rfc6536" title=""Network Configuration Protocol (NETCONF) Access Control Model"">RFC6536</a>], as there is a specific mapping
between RESTCONF and NETCONF operations. The resource path needs to
be converted internally by the server to the corresponding YANG
instance identifier. Using this information, the server can apply
the NACM access control rules to RESTCONF messages.
<span class="grey">Bierman, et al. Standards Track [Page 42]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-43" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The server MUST NOT allow any RESTCONF operation for any resources
that the client is not authorized to access.
The implementation of all methods (except PATCH [<a href="./rfc5789" title=""PATCH Method for HTTP"">RFC5789</a>]) is defined
in [<a href="./rfc7231" title=""Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content"">RFC7231</a>]. This section defines the RESTCONF protocol usage for
each HTTP method.
<span class="h3"><a class="selflink" id="section-4.1" href="#section-4.1">4.1</a>. OPTIONS</span>
The OPTIONS method is sent by the client to discover which methods
are supported by the server for a specific resource (e.g., GET, POST,
DELETE). The server MUST implement this method.
The "Accept-Patch" header field MUST be supported and returned in the
response to the OPTIONS request, as defined in [<a href="./rfc5789" title=""PATCH Method for HTTP"">RFC5789</a>].
<span class="h3"><a class="selflink" id="section-4.2" href="#section-4.2">4.2</a>. HEAD</span>
The RESTCONF server MUST support the HEAD method. The HEAD method is
sent by the client to retrieve just the header fields (which contain
the metadata for a resource) that would be returned for the
comparable GET method, without the response message-body. It is
supported for all resources that support the GET method.
The request MUST contain a request URI that contains at least the
root resource. The same query parameters supported by the GET method
are supported by the HEAD method.
The access control behavior is enforced as if the method was GET
instead of HEAD. The server MUST respond the same as if the method
was GET instead of HEAD, except that no response message-body is
included.
<span class="h3"><a class="selflink" id="section-4.3" href="#section-4.3">4.3</a>. GET</span>
The RESTCONF server MUST support the GET method. The GET method is
sent by the client to retrieve data and metadata for a resource. It
is supported for all resource types, except operation resources. The
request MUST contain a request URI that contains at least the root
resource.
The server MUST NOT return any data resources for which the user does
not have read privileges. If the user is not authorized to read the
target resource, an error response containing a "401 Unauthorized"
status-line SHOULD be returned. The error-tag value "access-denied"
is returned in this case. A server MAY return a "404 Not Found"
status-line, as described in <a href="./rfc7231#section-6.5.4">Section 6.5.4 in [RFC7231]</a>. The
error-tag value "invalid-value" is returned in this case.
<span class="grey">Bierman, et al. Standards Track [Page 43]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-44" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
If the user is authorized to read some but not all of the target
resource, the unauthorized content is omitted from the response
message-body, and the authorized content is returned to the client.
If any content is returned to the client, then the server MUST send a
valid response message-body. More than one element MUST NOT be
returned for XML encoding. If multiple elements are sent in a JSON
message-body, then they MUST be sent as a JSON array. In this case,
any timestamp or entity-tag returned in the response MUST be
associated with the first element returned.
If a retrieval request for a data resource representing a YANG
leaf-list or list object identifies more than one instance and XML
encoding is used in the response, then an error response containing a
"400 Bad Request" status-line MUST be returned by the server. The
error-tag value "invalid-value" is used in this case. Note that a
non-configuration list is not required to define any keys. In this
case, the retrieval of a single list instance is not possible.
If a retrieval request for a data resource represents an instance
that does not exist, then an error response containing a "404 Not
Found" status-line MUST be returned by the server. The error-tag
value "invalid-value" is used in this case.
If the target resource of a retrieval request is for an operation
resource, then a "405 Method Not Allowed" status-line MUST be
returned by the server. The error-tag value
"operation-not-supported" is used in this case.
Note that the way that access control is applied to data resources
may not be completely compatible with HTTP caching. The
"Last-Modified" and "ETag" header fields maintained for a data
resource are not affected by changes to the access control rules for
that data resource. It is possible for the representation of a data
resource that is visible to a particular client to be changed without
detection via the "Last-Modified" or "ETag" values.
Example:
The client might request the response header fields for an XML
representation of a specific "album" resource:
GET /restconf/data/example-jukebox:jukebox/\
library/artist=Foo%20Fighters/album=Wasting%20Light HTTP/1.1
Host: example.com
Accept: application/yang-data+xml
<span class="grey">Bierman, et al. Standards Track [Page 44]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-45" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Content-Type: application/yang-data+xml
Cache-Control: no-cache
ETag: "a74eefc993a2b"
Last-Modified: Thu, 26 Jan 2017 14:02:14 GMT
<album xmlns="http://example.com/ns/example-jukebox"
xmlns:jbox="http://example.com/ns/example-jukebox">
<name>Wasting Light</name>
<genre>jbox:alternative</genre>
<year>2011</year>
</album>
Refer to <a href="#appendix-B.1">Appendix B.1</a> for more resource retrieval examples.
<span class="h3"><a class="selflink" id="section-4.4" href="#section-4.4">4.4</a>. POST</span>
The RESTCONF server MUST support the POST method. The POST method is
sent by the client to create a data resource or invoke an operation
resource. The server uses the target resource type to determine how
to process the request.
+-----------+------------------------------------------------+
| Type | Description |
+-----------+------------------------------------------------+
| Datastore | Create a top-level configuration data resource |
| Data | Create a configuration data child resource |
| Operation | Invoke an RPC operation |
+-----------+------------------------------------------------+
Resource Types That Support POST
<span class="h4"><a class="selflink" id="section-4.4.1" href="#section-4.4.1">4.4.1</a>. Create Resource Mode</span>
If the target resource type is a datastore or data resource, then the
POST is treated as a request to create a top-level resource or child
resource, respectively. The message-body is expected to contain the
content of a child resource to create within the parent (target
resource). The message-body MUST contain exactly one instance of the
expected data resource. The data model for the child tree is the
subtree, as defined by YANG for the child resource.
<span class="grey">Bierman, et al. Standards Track [Page 45]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-46" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The "insert" (<a href="#section-4.8.5">Section 4.8.5</a>) and "point" (<a href="#section-4.8.6">Section 4.8.6</a>) query
parameters MUST be supported by the POST method for datastore and
data resources. These parameters are only allowed if the list or
leaf-list is "ordered-by user".
If the POST method succeeds, a "201 Created" status-line is returned
and there is no response message-body. A "Location" header field
identifying the child resource that was created MUST be present in
the response in this case.
If the data resource already exists, then the POST request MUST fail
and a "409 Conflict" status-line MUST be returned. The error-tag
value "resource-denied" is used in this case.
If the user is not authorized to create the target resource, an error
response containing a "403 Forbidden" status-line SHOULD be returned.
The error-tag value "access-denied" is used in this case. A server
MAY return a "404 Not Found" status-line, as described in
<a href="./rfc7231#section-6.5.4">Section 6.5.4 in [RFC7231]</a>. The error-tag value "invalid-value" is
used in this case. All other error responses are handled according
to the procedures defined in <a href="#section-7">Section 7</a>.
Example:
To create a new "jukebox" resource, the client might send the
following:
POST /restconf/data HTTP/1.1
Host: example.com
Content-Type: application/yang-data+json
{ "example-jukebox:jukebox" : {} }
If the resource is created, the server might respond as follows:
HTTP/1.1 201 Created
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Location: https://example.com/restconf/data/\
example-jukebox:jukebox
Last-Modified: Thu, 26 Jan 2017 20:56:30 GMT
ETag: "b3a3e673be2"
Refer to <a href="#appendix-B.2.1">Appendix B.2.1</a> for more resource creation examples.
<span class="grey">Bierman, et al. Standards Track [Page 46]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-47" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h4"><a class="selflink" id="section-4.4.2" href="#section-4.4.2">4.4.2</a>. Invoke Operation Mode</span>
If the target resource type is an operation resource, then the POST
method is treated as a request to invoke that operation. The
message-body (if any) is processed as the operation input parameters.
Refer to <a href="#section-3.6">Section 3.6</a> for details on operation resources.
If the POST request succeeds, a "200 OK" status-line is returned if
there is a response message-body, and a "204 No Content" status-line
is returned if there is no response message-body.
If the user is not authorized to invoke the target operation, an
error response containing a "403 Forbidden" status-line SHOULD be
returned. The error-tag value "access-denied" is used in this case.
A server MAY return a "404 Not Found" status-line, as described in
<a href="./rfc7231#section-6.5.4">Section 6.5.4 in [RFC7231]</a>. All other error responses are handled
according to the procedures defined in <a href="#section-7">Section 7</a>.
Example:
In this example, the client is invoking the "play" operation defined
in the "example-jukebox" YANG module.
A client might send a "play" request as follows:
POST /restconf/operations/example-jukebox:play HTTP/1.1
Host: example.com
Content-Type: application/yang-data+json
{
"example-jukebox:input" : {
"playlist" : "Foo-One",
"song-number" : 2
}
}
The server might respond as follows:
HTTP/1.1 204 No Content
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
<span class="grey">Bierman, et al. Standards Track [Page 47]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-48" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h3"><a class="selflink" id="section-4.5" href="#section-4.5">4.5</a>. PUT</span>
The RESTCONF server MUST support the PUT method. The PUT method is
sent by the client to create or replace the target data resource. A
request message-body MUST be present, representing the new data
resource, or the server MUST return a "400 Bad Request" status-line.
The error-tag value "invalid-value" is used in this case.
Both the POST and PUT methods can be used to create data resources.
The difference is that for POST, the client does not provide the
resource identifier for the resource that will be created. The
target resource for the POST method for resource creation is the
parent of the new resource. The target resource for the PUT method
for resource creation is the new resource.
The PUT method MUST be supported for data and datastore resources. A
PUT on the datastore resource is used to replace the entire contents
of the datastore. A PUT on a data resource only replaces that data
resource within the datastore.
The "insert" (<a href="#section-4.8.5">Section 4.8.5</a>) and "point" (<a href="#section-4.8.6">Section 4.8.6</a>) query
parameters MUST be supported by the PUT method for data resources.
These parameters are only allowed if the list or leaf-list is
"ordered-by user".
Consistent with [<a href="./rfc7231" title=""Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content"">RFC7231</a>], if the PUT request creates a new resource,
a "201 Created" status-line is returned. If an existing resource is
modified, a "204 No Content" status-line is returned.
If the user is not authorized to create or replace the target
resource, an error response containing a "403 Forbidden" status-line
SHOULD be returned. The error-tag value "access-denied" is used in
this case.
A server MAY return a "404 Not Found" status-line, as described in
<a href="./rfc7231#section-6.5.4">Section 6.5.4 in [RFC7231]</a>. The error-tag value "invalid-value" is
used in this case. All other error responses are handled according
to the procedures defined in <a href="#section-7">Section 7</a>.
If the target resource represents a YANG leaf-list, then the PUT
method MUST NOT change the value of the leaf-list instance.
If the target resource represents a YANG list instance, then the key
leaf values, in message-body representation, MUST be the same as the
key leaf values in the request URI. The PUT method MUST NOT be used
to change the key leaf values for a data resource instance.
<span class="grey">Bierman, et al. Standards Track [Page 48]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-49" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
Example:
An "album" child resource defined in the "example-jukebox" YANG
module is replaced, or it is created if it does not already exist.
To replace the "album" resource contents, the client might send the
following:
PUT /restconf/data/example-jukebox:jukebox/\
library/artist=Foo%20Fighters/album=Wasting%20Light HTTP/1.1
Host: example.com
Content-Type: application/yang-data+json
{
"example-jukebox:album" : [
{
"name" : "Wasting Light",
"genre" : "example-jukebox:alternative",
"year" : 2011
}
]
}
If the resource is updated, the server might respond as follows:
HTTP/1.1 204 No Content
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Last-Modified: Thu, 26 Jan 2017 20:56:30 GMT
ETag: "b27480aeda4c"
The same request is shown here using XML encoding:
PUT /restconf/data/example-jukebox:jukebox/\
library/artist=Foo%20Fighters/album=Wasting%20Light HTTP/1.1
Host: example.com
Content-Type: application/yang-data+xml
<album xmlns="http://example.com/ns/example-jukebox"
xmlns:jbox="http://example.com/ns/example-jukebox">
<name>Wasting Light</name>
<genre>jbox:alternative</genre>
<year>2011</year>
</album>
Refer to <a href="#appendix-B.2.4">Appendix B.2.4</a> for an example using the PUT method to
replace the contents of the datastore resource.
<span class="grey">Bierman, et al. Standards Track [Page 49]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-50" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h3"><a class="selflink" id="section-4.6" href="#section-4.6">4.6</a>. PATCH</span>
The RESTCONF server MUST support the PATCH method for a plain patch
and MAY support additional media types. The media types for the
PATCH method supported by the server can be discovered by the client
by sending an OPTIONS request and examining the "Accept-Patch" header
field in the response (see <a href="#section-4.1">Section 4.1</a>).
RESTCONF uses the HTTP PATCH method defined in [<a href="./rfc5789" title=""PATCH Method for HTTP"">RFC5789</a>] to provide
an extensible framework for resource patching mechanisms. Each patch
mechanism needs a unique media type.
This document defines one patch mechanism (<a href="#section-4.6.1">Section 4.6.1</a>). Another
patch mechanism, the YANG Patch mechanism, is defined in
[<a href="#ref-YANG-Patch">YANG-Patch</a>]. Other patch mechanisms may be defined by future
specifications.
If the target resource instance does not exist, the server MUST NOT
create it.
If the PATCH request succeeds, a "200 OK" status-line is returned if
there is a message-body, and "204 No Content" is returned if no
response message-body is sent.
If the user is not authorized to alter the target resource, an error
response containing a "403 Forbidden" status-line SHOULD be returned.
A server MAY return a "404 Not Found" status-line, as described in
<a href="./rfc7231#section-6.5.4">Section 6.5.4 in [RFC7231]</a>. The error-tag value "invalid-value" is
used in this case. All other error responses are handled according
to the procedures defined in <a href="#section-7">Section 7</a>.
<span class="h4"><a class="selflink" id="section-4.6.1" href="#section-4.6.1">4.6.1</a>. Plain Patch</span>
The plain patch mechanism merges the contents of the message-body
with the target resource. The message-body for a plain patch MUST be
present and MUST be represented by the media type
"application/yang-data+xml" or "application/yang-data+json".
Plain patch can be used to create or update, but not delete, a child
resource within the target resource. Please see [<a href="#ref-YANG-Patch">YANG-Patch</a>] for an
alternate media type supporting the ability to delete child
resources. The YANG Patch media type allows multiple suboperations
(e.g., "merge", "delete") within a single PATCH method.
If the target resource represents a YANG leaf-list, then the PATCH
method MUST NOT change the value of the leaf-list instance.
<span class="grey">Bierman, et al. Standards Track [Page 50]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-51" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
If the target resource represents a YANG list instance, then the key
leaf values, in message-body representation, MUST be the same as the
key leaf values in the request URI. The PATCH method MUST NOT be
used to change the key leaf values for a data resource instance.
After the plain patch is processed by the server, a response will be
returned to the client, as specified in <a href="#section-4.6">Section 4.6</a>.
Example:
To replace just the "year" field in the "album" resource (instead of
replacing the entire resource with the PUT method), the client might
send a plain patch as follows:
PATCH /restconf/data/example-jukebox:jukebox/\
library/artist=Foo%20Fighters/album=Wasting%20Light HTTP/1.1
Host: example.com
If-Match: "b8389233a4c"
Content-Type: application/yang-data+xml
<album xmlns="http://example.com/ns/example-jukebox">
<year>2011</year>
</album>
If the field is updated, the server might respond as follows:
HTTP/1.1 204 No Content
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Last-Modified: Thu, 26 Jan 2017 20:56:30 GMT
ETag: "b2788923da4c"
<span class="h3"><a class="selflink" id="section-4.7" href="#section-4.7">4.7</a>. DELETE</span>
The RESTCONF server MUST support the DELETE method. The DELETE
method is used to delete the target resource. If the DELETE request
succeeds, a "204 No Content" status-line is returned.
If the user is not authorized to delete the target resource, then an
error response containing a "403 Forbidden" status-line SHOULD be
returned. The error-tag value "access-denied" is returned in this
case. A server MAY return a "404 Not Found" status-line, as
described in <a href="./rfc7231#section-6.5.4">Section 6.5.4 in [RFC7231]</a>. The error-tag value
"invalid-value" is returned in this case. All other error responses
are handled according to the procedures defined in <a href="#section-7">Section 7</a>.
<span class="grey">Bierman, et al. Standards Track [Page 51]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-52" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
If the target resource represents a configuration leaf-list or list
data node, then it MUST represent a single YANG leaf-list or list
instance. The server MUST NOT use the DELETE method to delete more
than one such instance.
Example:
To delete the "album" resource with the key "Wasting Light", the
client might send the following:
DELETE /restconf/data/example-jukebox:jukebox/\
library/artist=Foo%20Fighters/album=Wasting%20Light HTTP/1.1
Host: example.com
If the resource is deleted, the server might respond as follows:
HTTP/1.1 204 No Content
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
<span class="h3"><a class="selflink" id="section-4.8" href="#section-4.8">4.8</a>. Query Parameters</span>
Each RESTCONF operation allows zero or more query parameters to be
present in the request URI. Which specific parameters are allowed
will depend on the resource type, and sometimes the specific target
resource used, in the request.
o Query parameters can be given in any order.
o Each parameter can appear at most once in a request URI.
o If more than one instance of a query parameter is present, then a
"400 Bad Request" status-line MUST be returned by the server. The
error-tag value "invalid-value" is returned in this case.
o A default value may apply if the parameter is missing.
o Query parameter names and values are case sensitive.
o A server MUST return an error with a "400 Bad Request" status-line
if a query parameter is unexpected. The error-tag value
"invalid-value" is returned in this case.
<span class="grey">Bierman, et al. Standards Track [Page 52]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-53" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
+---------------+---------+-----------------------------------------+
| Name | Methods | Description |
+---------------+---------+-----------------------------------------+
| content | GET, | Select config and/or non-config data |
| | HEAD | resources |
| | | |
| depth | GET, | Request limited subtree depth in the |
| | HEAD | reply content |
| | | |
| fields | GET, | Request a subset of the target resource |
| | HEAD | contents |
| | | |
| filter | GET, | Boolean notification filter for event |
| | HEAD | stream resources |
| | | |
| insert | POST, | Insertion mode for "ordered-by user" |
| | PUT | data resources |
| | | |
| point | POST, | Insertion point for "ordered-by user" |
| | PUT | data resources |
| | | |
| start-time | GET, | Replay buffer start time for event |
| | HEAD | stream resources |
| | | |
| stop-time | GET, | Replay buffer stop time for event |
| | HEAD | stream resources |
| | | |
| with-defaults | GET, | Control the retrieval of default values |
| | HEAD | |
+---------------+---------+-----------------------------------------+
RESTCONF Query Parameters
Refer to <a href="#appendix-B.3">Appendix B.3</a> for examples of query parameter usage.
If vendors define additional query parameters, they SHOULD use a
prefix (such as the enterprise or organization name) for query
parameter names in order to avoid collisions with other parameters.
<span class="grey">Bierman, et al. Standards Track [Page 53]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-54" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h4"><a class="selflink" id="section-4.8.1" href="#section-4.8.1">4.8.1</a>. The "content" Query Parameter</span>
The "content" query parameter controls how descendant nodes of the
requested data nodes will be processed in the reply.
The allowed values are:
+-----------+-----------------------------------------------------+
| Value | Description |
+-----------+-----------------------------------------------------+
| config | Return only configuration descendant data nodes |
| | |
| nonconfig | Return only non-configuration descendant data nodes |
| | |
| all | Return all descendant data nodes |
+-----------+-----------------------------------------------------+
This parameter is only allowed for GET methods on datastore and data
resources. A "400 Bad Request" status-line is returned if used for
other methods or resource types.
If this query parameter is not present, the default value is "all".
This query parameter MUST be supported by the server.
<span class="h4"><a class="selflink" id="section-4.8.2" href="#section-4.8.2">4.8.2</a>. The "depth" Query Parameter</span>
The "depth" query parameter is used to limit the depth of subtrees
returned by the server. Data nodes with a "depth" value greater than
the "depth" parameter are not returned in a response for a GET
method.
The requested data node has a depth level of "1". If the "fields"
parameter (<a href="#section-4.8.3">Section 4.8.3</a>) is used to select descendant data nodes,
then these nodes and all of their ancestor nodes have a "depth" value
of "1". (This has the effect of including the nodes specified by the
fields, even if the "depth" value is less than the actual depth level
of the specified fields.) Any other child node has a "depth" value
that is 1 greater than its parent.
The value of the "depth" parameter is either an integer between 1 and
65535 or the string "unbounded". "unbounded" is the default.
This parameter is only allowed for GET methods on API, datastore, and
data resources. A "400 Bad Request" status-line is returned if used
for other methods or resource types.
<span class="grey">Bierman, et al. Standards Track [Page 54]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-55" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
By default, the server will include all sub-resources within a
retrieved resource that have the same resource type as the requested
resource. The exception is the datastore resource. If this resource
type is retrieved, then by default the datastore and all child data
resources are returned.
If the "depth" query parameter URI is listed in the "capability"
leaf-list defined in <a href="#section-9.3">Section 9.3</a>, then the server supports the
"depth" query parameter.
<span class="h4"><a class="selflink" id="section-4.8.3" href="#section-4.8.3">4.8.3</a>. The "fields" Query Parameter</span>
The "fields" query parameter is used to optionally identify data
nodes within the target resource to be retrieved in a GET method.
The client can use this parameter to retrieve a subset of all nodes
in a resource.
The server will return a message-body representing the target
resource, with descendant nodes pruned as specified in the
"fields-expr" value. The server does not return a set of separate
sub-resources.
A value of the "fields" query parameter matches the following rule:
fields-expr = path "(" fields-expr ")" / path ";" fields-expr / path
path = api-identifier [ "/" path ]
"api-identifier" is defined in <a href="#section-3.5.3.1">Section 3.5.3.1</a>.
";" is used to select multiple nodes. For example, to retrieve only
the "genre" and "year" of an album, use "fields=genre;year".
Parentheses are used to specify sub-selectors of a node. Note that
there is no path separator character "/" between a "path" field and a
left parenthesis character "(".
For example, assume that the target resource is the "album" list. To
retrieve only the "label" and "catalogue-number" of the "admin"
container within an album, use
"fields=admin(label;catalogue-number)".
"/" is used in a path to retrieve a child node of a node. For
example, to retrieve only the "label" of an album, use
"fields=admin/label".
This parameter is only allowed for GET methods on API, datastore, and
data resources. A "400 Bad Request" status-line is returned if used
for other methods or resource types.
<span class="grey">Bierman, et al. Standards Track [Page 55]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-56" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
If the "fields" query parameter URI is listed in the "capability"
leaf-list defined in <a href="#section-9.3">Section 9.3</a>, then the server supports the
"fields" parameter.
<span class="h4"><a class="selflink" id="section-4.8.4" href="#section-4.8.4">4.8.4</a>. The "filter" Query Parameter</span>
The "filter" query parameter is used to indicate which subset of all
possible events is of interest. If not present, all events not
precluded by other parameters will be sent.
This parameter is only allowed for GET methods on an event stream
resource. A "400 Bad Request" status-line is returned if used for
other methods or resource types.
The format of this parameter is an XPath 1.0 expression [<a href="#ref-XPath" title=""XML Path Language (XPath) Version 1.0"">XPath</a>] and
is evaluated in the following context:
o The set of namespace declarations is the set of prefix and
namespace pairs for all supported YANG modules, where the prefix
is the YANG module name and the namespace is as defined by the
"namespace" statement in the YANG module.
o The function library is the core function library defined in
XPath 1.0, plus any functions defined by the data model.
o The set of variable bindings is empty.
o The context node is the root node.
The "filter" query parameter is used as defined in <a href="./rfc5277#section-3.6">Section 3.6 of
[RFC5277]</a>. If the boolean result of the expression is "true" when
applied to the conceptual "notification" document root, then the
event notification is delivered to the client.
If the "filter" query parameter URI is listed in the "capability"
leaf-list defined in <a href="#section-9.3">Section 9.3</a>, then the server supports the
"filter" query parameter.
<span class="grey">Bierman, et al. Standards Track [Page 56]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-57" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h4"><a class="selflink" id="section-4.8.5" href="#section-4.8.5">4.8.5</a>. The "insert" Query Parameter</span>
The "insert" query parameter is used to specify how a resource should
be inserted within an "ordered-by user" list.
The allowed values are:
+--------+----------------------------------------------------------+
| Value | Description |
+--------+----------------------------------------------------------+
| first | Insert the new data as the new first entry. |
| | |
| last | Insert the new data as the new last entry. |
| | |
| before | Insert the new data before the insertion point, as |
| | specified by the value of the "point" parameter. |
| | |
| after | Insert the new data after the insertion point, as |
| | specified by the value of the "point" parameter. |
+--------+----------------------------------------------------------+
The default value is "last".
This parameter is only supported for the POST and PUT methods. It is
also only supported if the target resource is a data resource, and
that data represents a YANG list or leaf-list that is
"ordered-by user".
If the values "before" or "after" are used, then a "point" query
parameter for the "insert" query parameter MUST also be present, or a
"400 Bad Request" status-line is returned.
The "insert" query parameter MUST be supported by the server.
<span class="h4"><a class="selflink" id="section-4.8.6" href="#section-4.8.6">4.8.6</a>. The "point" Query Parameter</span>
The "point" query parameter is used to specify the insertion point
for a data resource that is being created or moved within an
"ordered-by user" list or leaf-list.
The value of the "point" parameter is a string that identifies the
path to the insertion point object. The format is the same as a
target resource URI string.
This parameter is only supported for the POST and PUT methods. It is
also only supported if the target resource is a data resource, and
that data represents a YANG list or leaf-list that is
"ordered-by user".
<span class="grey">Bierman, et al. Standards Track [Page 57]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-58" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
If the "insert" query parameter is not present or has a value other
than "before" or "after", then a "400 Bad Request" status-line is
returned.
This parameter contains the instance identifier of the resource to be
used as the insertion point for a POST or PUT method.
The "point" query parameter MUST be supported by the server.
<span class="h4"><a class="selflink" id="section-4.8.7" href="#section-4.8.7">4.8.7</a>. The "start-time" Query Parameter</span>
The "start-time" query parameter is used to trigger the notification
replay feature defined in [<a href="./rfc5277" title=""NETCONF Event Notifications"">RFC5277</a>] and indicate that the replay
should start at the time specified. If the stream does not support
replay per the "replay-support" attribute returned by the
"stream" list entry for the stream resource, then the server MUST
return a "400 Bad Request" status-line.
The value of the "start-time" parameter is of type "date-and-time",
defined in the "ietf-yang-types" YANG module [<a href="./rfc6991" title=""Common YANG Data Types"">RFC6991</a>].
This parameter is only allowed for GET methods on a
"text/event-stream" data resource. A "400 Bad Request" status-line
is returned if used for other methods or resource types.
If this parameter is not present, then a replay subscription is not
being requested. It is not valid to specify start times that are
later than the current time. If the value specified is earlier than
the log can support, the replay will begin with the earliest
available notification. A client can obtain a server's current time
by examining the "Date" header field that the server returns in
response messages, according to [<a href="./rfc7231" title=""Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content"">RFC7231</a>].
If this query parameter is supported by the server, then the "replay"
query parameter URI MUST be listed in the "capability" leaf-list
defined in <a href="#section-9.3">Section 9.3</a>, and the "stop-time" query parameter MUST also
be supported by the server.
If the "replay-support" leaf has the value "true" in the "stream"
entry (defined in <a href="#section-9.3">Section 9.3</a>), then the server MUST support the
"start-time" and "stop-time" query parameters for that stream.
<span class="h4"><a class="selflink" id="section-4.8.8" href="#section-4.8.8">4.8.8</a>. The "stop-time" Query Parameter</span>
The "stop-time" query parameter is used with the replay feature to
indicate the newest notifications of interest. This parameter MUST
be used with, and have a value later than, the "start-time"
parameter.
<span class="grey">Bierman, et al. Standards Track [Page 58]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-59" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The value of the "stop-time" parameter is of type "date-and-time",
defined in the "ietf-yang-types" YANG module [<a href="./rfc6991" title=""Common YANG Data Types"">RFC6991</a>].
This parameter is only allowed for GET methods on a
"text/event-stream" data resource. A "400 Bad Request" status-line
is returned if used for other methods or resource types.
If this parameter is not present, the notifications will continue
until the subscription is terminated. Values in the future are
valid.
If this query parameter is supported by the server, then the "replay"
query parameter URI MUST be listed in the "capability" leaf-list
defined in <a href="#section-9.3">Section 9.3</a>, and the "start-time" query parameter MUST
also be supported by the server.
If the "replay-support" leaf is present in the "stream" entry
(defined in <a href="#section-9.3">Section 9.3</a>), then the server MUST support the
"start-time" and "stop-time" query parameters for that stream.
<span class="h4"><a class="selflink" id="section-4.8.9" href="#section-4.8.9">4.8.9</a>. The "with-defaults" Query Parameter</span>
The "with-defaults" query parameter is used to specify how
information about default data nodes should be returned in response
to GET requests on data resources.
If the server supports this capability, then it MUST implement the
behavior described in <a href="./rfc6243#section-4.5.1">Section 4.5.1 of [RFC6243]</a>, except applied to
the RESTCONF GET operation instead of the NETCONF operations.
+-------------------+-----------------------------------------------+
| Value | Description |
+-------------------+-----------------------------------------------+
| report-all | All data nodes are reported |
| | |
| trim | Data nodes set to the YANG default are not |
| | reported |
| | |
| explicit | Data nodes set to the YANG default by the |
| | client are reported |
| | |
| report-all-tagged | All data nodes are reported, and defaults are |
| | tagged |
+-------------------+-----------------------------------------------+
If the "with-defaults" parameter is set to "report-all", then the
server MUST adhere to the default-reporting behavior defined in
<a href="./rfc6243#section-3.1">Section 3.1 of [RFC6243]</a>.
<span class="grey">Bierman, et al. Standards Track [Page 59]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-60" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
If the "with-defaults" parameter is set to "trim", then the server
MUST adhere to the default-reporting behavior defined in <a href="./rfc6243#section-3.2">Section 3.2
of [RFC6243]</a>.
If the "with-defaults" parameter is set to "explicit", then the
server MUST adhere to the default-reporting behavior defined in
<a href="./rfc6243#section-3.3">Section 3.3 of [RFC6243]</a>.
If the "with-defaults" parameter is set to "report-all-tagged", then
the server MUST adhere to the default-reporting behavior defined in
<a href="./rfc6243#section-3.4">Section 3.4 of [RFC6243]</a>. Metadata is reported by the server as
specified in <a href="#section-5.3">Section 5.3</a>. The XML encoding for the "default"
attribute sent by the server for default nodes is defined in
<a href="./rfc6243#section-6">Section 6 of [RFC6243]</a>. The JSON encoding for the "default"
attribute MUST use the same values, as defined in [<a href="./rfc6243" title=""With-defaults Capability for NETCONF"">RFC6243</a>], but
encoded according to the rules in [<a href="./rfc7952" title=""Defining and Using Metadata with YANG"">RFC7952</a>]. The module name
"ietf-netconf-with-defaults" MUST be used for the "default"
attribute.
If the "with-defaults" parameter is not present, then the server MUST
adhere to the default-reporting behavior defined in its "basic-mode"
parameter for the "defaults" protocol capability URI, defined in
<a href="#section-9.1.2">Section 9.1.2</a>.
If the server includes the "with-defaults" query parameter URI in the
"capability" leaf-list defined in <a href="#section-9.3">Section 9.3</a>, then the
"with-defaults" query parameter MUST be supported.
Since the server does not report the "also-supported" parameter as
described in <a href="./rfc6243#section-4.3">Section 4.3 of [RFC6243]</a>, it is possible that some
values for the "with-defaults" parameter will not be supported. If
the server does not support the requested value of the
"with-defaults" parameter, the server MUST return a response with a
"400 Bad Request" status-line. The error-tag value "invalid-value"
is used in this case.
<span class="h2"><a class="selflink" id="section-5" href="#section-5">5</a>. Messages</span>
The RESTCONF protocol uses HTTP messages. A single HTTP message
corresponds to a single protocol method. Most messages can perform a
single task on a single resource, such as retrieving a resource or
editing a resource. The exception is the PATCH method, which allows
multiple datastore edits within a single message.
<span class="grey">Bierman, et al. Standards Track [Page 60]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-61" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h3"><a class="selflink" id="section-5.1" href="#section-5.1">5.1</a>. Request URI Structure</span>
Resources are represented with URIs following the structure for
generic URIs in [<a href="./rfc3986" title=""Uniform Resource Identifier (URI): Generic Syntax"">RFC3986</a>].
A RESTCONF operation is derived from the HTTP method and the request
URI, using the following conceptual fields:
<OP> /<restconf>/<path>?<query>
^ ^ ^ ^
| | | |
method entry resource query
M M O O
M=mandatory, O=optional
where:
<OP> is the HTTP method
<restconf> is the RESTCONF root resource
<path> is the target resource URI
<query> is the query parameter list
o method: the HTTP method identifying the RESTCONF operation
requested by the client, to act upon the target resource specified
in the request URI. RESTCONF operation details are described in
<a href="#section-4">Section 4</a>.
o entry: the root of the RESTCONF API configured on this HTTP
server, discovered by getting the "/.well-known/host-meta"
resource, as described in <a href="#section-3.1">Section 3.1</a>.
o resource: the path expression identifying the resource that is
being accessed by the RESTCONF operation. If this field is not
present, then the target resource is the API itself, represented
by the YANG data template named "yang-api", found in <a href="#section-8">Section 8</a>.
o query: the set of parameters associated with the RESTCONF message;
see <a href="./rfc3986#section-3.4">Section 3.4 of [RFC3986]</a>. RESTCONF parameters have the
familiar form of "name=value" pairs. Most query parameters are
optional to implement by the server and optional to use by the
client. Each optional query parameter is identified by a URI.
The server MUST list the optional query parameter URIs it supports
in the "capability" leaf-list defined in <a href="#section-9.3">Section 9.3</a>.
<span class="grey">Bierman, et al. Standards Track [Page 61]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-62" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
There is a specific set of parameters defined, although the server
MAY choose to support query parameters not defined in this document.
The contents of any query parameter value MUST be encoded according
to <a href="./rfc3986#section-3.4">Section 3.4 of [RFC3986]</a>. Any reserved characters MUST be
percent-encoded, according to Sections <a href="#section-2.1">2.1</a> and <a href="#section-2.5">2.5</a> of [<a href="./rfc3986" title=""Uniform Resource Identifier (URI): Generic Syntax"">RFC3986</a>].
Note that the fragment component is not used by the RESTCONF
protocol. The fragment is excluded from the target URI by a server,
as described in <a href="./rfc7230#section-5.1">Section 5.1 of [RFC7230]</a>.
When new resources are created by the client, a "Location" header
field is returned, which identifies the path of the newly created
resource. The client uses this exact path identifier to access the
resource once it has been created.
The target of a RESTCONF operation is a resource. The "path" field
in the request URI represents the target resource for the RESTCONF
operation.
Refer to <a href="#appendix-B">Appendix B</a> for examples of RESTCONF request URIs.
<span class="h3"><a class="selflink" id="section-5.2" href="#section-5.2">5.2</a>. Message Encoding</span>
RESTCONF messages are encoded in HTTP according to [<a href="./rfc7230" title=""Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing"">RFC7230</a>]. The
"utf-8" character set is used for all messages. RESTCONF message
content is sent in the HTTP message-body.
Content is encoded in either JSON or XML format. A server MUST
support one of either XML or JSON encoding. A server MAY support
both XML and JSON encoding. A client will need to support both XML
and JSON to interoperate with all RESTCONF servers.
XML encoding rules for data nodes are defined in [<a href="./rfc7950" title=""The YANG 1.1 Data Modeling Language"">RFC7950</a>]. The same
encoding rules are used for all XML content. JSON encoding rules are
defined in [<a href="./rfc7951" title=""JSON Encoding of Data Modeled with YANG"">RFC7951</a>]. Additional JSON encoding rules for metadata
are defined in [<a href="./rfc7952" title=""Defining and Using Metadata with YANG"">RFC7952</a>]. This encoding is valid JSON, but it also
has special encoding rules to identify module namespaces and provide
consistent type processing of YANG data.
<span class="grey">Bierman, et al. Standards Track [Page 62]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-63" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The request input content encoding format is identified with the
"Content-Type" header field. This field MUST be present if a
message-body is sent by the client.
The server MUST support the "Accept" header field and the "406 Not
Acceptable" status-line, as defined in [<a href="./rfc7231" title=""Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content"">RFC7231</a>]. The response
output content encoding formats that the client will accept are
identified with the "Accept" header field in the request. If it is
not specified, the request input encoding format SHOULD be used, or
the server MAY choose any supported content encoding format.
If there was no request input, then the default output encoding is
XML or JSON, depending on server preference. File extensions encoded
in the request are not used to identify format encoding.
A client can determine if the RESTCONF server supports an encoding
format by sending a request using a specific format in the
"Content-Type" and/or "Accept" header field. If the server does not
support the requested input encoding for a request, then it MUST
return an error response with a "415 Unsupported Media Type"
status-line. If the server does not support any of the requested
output encodings for a request, then it MUST return an error response
with a "406 Not Acceptable" status-line.
<span class="h3"><a class="selflink" id="section-5.3" href="#section-5.3">5.3</a>. RESTCONF Metadata</span>
The RESTCONF protocol needs to support the retrieval of the same
metadata that is used in the NETCONF protocol. Information about
default leafs, last-modified timestamps, etc. is commonly used to
annotate representations of the datastore contents.
With the XML encoding, the metadata is encoded as attributes in XML,
according to Section 3.3 of [<a href="#ref-W3C.REC-xml-20081126">W3C.REC-xml-20081126</a>]. With the JSON
encoding, the metadata is encoded as specified in [<a href="./rfc7952" title=""Defining and Using Metadata with YANG"">RFC7952</a>].
<span class="grey">Bierman, et al. Standards Track [Page 63]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-64" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The following examples are based on the example in <a href="#appendix-B.3.9">Appendix B.3.9</a>.
The "report-all-tagged" mode for the "with-defaults" query parameter
requires that a "default" attribute be returned for default nodes.
These examples show that attribute for the "mtu" leaf.
<span class="h4"><a class="selflink" id="section-5.3.1" href="#section-5.3.1">5.3.1</a>. XML Metadata Encoding Example</span>
GET /restconf/data/interfaces/interface=eth1
?with-defaults=report-all-tagged HTTP/1.1
Host: example.com
Accept: application/yang-data+xml
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Content-Type: application/yang-data+xml
<interface
xmlns="urn:example.com:params:xml:ns:yang:example-interface">
<name>eth1</name>
<mtu xmlns:wd="urn:ietf:params:xml:ns:netconf:default:1.0"
wd:default="true">1500</mtu>
<status>up</status>
</interface>
<span class="grey">Bierman, et al. Standards Track [Page 64]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-65" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h4"><a class="selflink" id="section-5.3.2" href="#section-5.3.2">5.3.2</a>. JSON Metadata Encoding Example</span>
Note that <a href="./rfc6243">RFC 6243</a> defines the "default" attribute with the
XML Schema Definition (XSD), not YANG, so the YANG module name has to
be assigned instead of derived from the YANG module. The value
"ietf-netconf-with-defaults" is assigned for JSON metadata encoding.
GET /restconf/data/interfaces/interface=eth1\
?with-defaults=report-all-tagged HTTP/1.1
Host: example.com
Accept: application/yang-data+json
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Content-Type: application/yang-data+json
{
"example:interface" : [
{
"name" : "eth1",
"mtu" : 1500,
"@mtu" : {
"ietf-netconf-with-defaults:default" : true
},
"status" : "up"
}
]
}
<span class="h3"><a class="selflink" id="section-5.4" href="#section-5.4">5.4</a>. Return Status</span>
Each message represents some sort of resource access. An HTTP
"status-line" header field is returned for each request. If a status
code in the "4xx" range is returned in the status-line, then the
error information SHOULD be returned in the response, according to
the format defined in <a href="#section-7.1">Section 7.1</a>. If a status code in the "5xx"
range is returned in the status-line, then the error information MAY
be returned in the response, according to the format defined in
<a href="#section-7.1">Section 7.1</a>. If a status code in the "1xx", "2xx", or "3xx" range is
returned in the status-line, then error information MUST NOT be
returned in the response, since these ranges do not represent error
conditions.
<span class="grey">Bierman, et al. Standards Track [Page 65]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-66" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h3"><a class="selflink" id="section-5.5" href="#section-5.5">5.5</a>. Message Caching</span>
Since the datastore contents change at unpredictable times, responses
from a RESTCONF server generally SHOULD NOT be cached.
The server MUST include a "Cache-Control" header field in every
response that specifies whether the response should be cached.
Instead of relying on HTTP caching, the client SHOULD track the
"ETag" and/or "Last-Modified" header fields returned by the server
for the datastore resource (or data resource, if the server supports
it). A retrieval request for a resource can include the
"If-None-Match" and/or "If-Modified-Since" header fields, which will
cause the server to return a "304 Not Modified" status-line if the
resource has not changed. The client MAY use the HEAD method to
retrieve just the message header fields, which SHOULD include the
"ETag" and "Last-Modified" header fields, if this metadata is
maintained for the target resource.
Note that access control can be applied to data resources, such that
the values in the "Last-Modified" and "ETag" headers maintained for a
data resource may not be reliable, as described in <a href="#section-4.3">Section 4.3</a>.
<span class="h2"><a class="selflink" id="section-6" href="#section-6">6</a>. Notifications</span>
The RESTCONF protocol supports YANG-defined event notifications. The
solution preserves aspects of NETCONF event notifications [<a href="./rfc5277" title=""NETCONF Event Notifications"">RFC5277</a>]
while utilizing the Server-Sent Events [<a href="#ref-W3C.REC-eventsource-20150203">W3C.REC-eventsource-20150203</a>]
transport strategy.
<span class="h3"><a class="selflink" id="section-6.1" href="#section-6.1">6.1</a>. Server Support</span>
A RESTCONF server MAY support RESTCONF notifications. Clients may
determine if a server supports RESTCONF notifications by using the
HTTP OPTIONS, HEAD, or GET method on the "stream" list. The server
does not support RESTCONF notifications if an HTTP error code is
returned (e.g., a "404 Not Found" status-line).
<span class="grey">Bierman, et al. Standards Track [Page 66]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-67" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h3"><a class="selflink" id="section-6.2" href="#section-6.2">6.2</a>. Event Streams</span>
A RESTCONF server that supports notifications will populate a stream
resource for each notification delivery service access point. A
RESTCONF client can retrieve the list of supported event streams from
a RESTCONF server using the GET method on the "stream" list.
The "restconf-state/streams" container definition in the
"ietf-restconf-monitoring" module (defined in <a href="#section-9.3">Section 9.3</a>) is used to
specify the structure and syntax of the conceptual child resources
within the "streams" resource.
For example:
The client might send the following request:
GET /restconf/data/ietf-restconf-monitoring:restconf-state/\
streams HTTP/1.1
Host: example.com
Accept: application/yang-data+xml
The server might send the following response:
HTTP/1.1 200 OK
Content-Type: application/yang-data+xml
<streams
xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring">
<stream>
<name>NETCONF</name>
<description>default NETCONF event stream</description>
<replay-support>true</replay-support>
<replay-log-creation-time>\
2007-07-08T00:00:00Z\
</replay-log-creation-time>
<access>
<encoding>xml</encoding>
<location>https://example.com/streams/NETCONF\
</location>
</access>
<access>
<encoding>json</encoding>
<location>https://example.com/streams/NETCONF-JSON\
</location>
</access>
</stream>
<span class="grey">Bierman, et al. Standards Track [Page 67]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-68" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<stream>
<name>SNMP</name>
<description>SNMP notifications</description>
<replay-support>false</replay-support>
<access>
<encoding>xml</encoding>
<location>https://example.com/streams/SNMP</location>
</access>
</stream>
<stream>
<name>syslog-critical</name>
<description>Critical and higher severity</description>
<replay-support>true</replay-support>
<replay-log-creation-time>
2007-07-01T00:00:00Z
</replay-log-creation-time>
<access>
<encoding>xml</encoding>
<location>\
https://example.com/streams/syslog-critical\
</location>
</access>
</stream>
</streams>
<span class="h3"><a class="selflink" id="section-6.3" href="#section-6.3">6.3</a>. Subscribing to Receive Notifications</span>
RESTCONF clients can determine the URL for the subscription resource
(to receive notifications) by sending an HTTP GET request for the
"location" leaf with the "stream" list entry. The value returned by
the server can be used for the actual notification subscription.
The client will send an HTTP GET request for the URL returned by the
server with the "Accept" type "text/event-stream".
The server will treat the connection as an event stream, using the
Server-Sent Events [<a href="#ref-W3C.REC-eventsource-20150203">W3C.REC-eventsource-20150203</a>] transport strategy.
The server MAY support query parameters for a GET method on this
resource. These parameters are specific to each event stream.
<span class="grey">Bierman, et al. Standards Track [Page 68]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-69" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
For example:
The client might send the following request:
GET /restconf/data/ietf-restconf-monitoring:restconf-state/\
streams/stream=NETCONF/access=xml/location HTTP/1.1
Host: example.com
Accept: application/yang-data+xml
The server might send the following response:
HTTP/1.1 200 OK
Content-Type: application/yang-data+xml
<location
xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring">\
https://example.com/streams/NETCONF\
</location>
The RESTCONF client can then use this URL value to start monitoring
the event stream:
GET /streams/NETCONF HTTP/1.1
Host: example.com
Accept: text/event-stream
Cache-Control: no-cache
Connection: keep-alive
A RESTCONF client MAY request that the server compress the events
using the HTTP header field "Accept-Encoding". For instance:
GET /streams/NETCONF HTTP/1.1
Host: example.com
Accept: text/event-stream
Cache-Control: no-cache
Connection: keep-alive
Accept-Encoding: gzip, deflate
<span class="grey">Bierman, et al. Standards Track [Page 69]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-70" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h4"><a class="selflink" id="section-6.3.1" href="#section-6.3.1">6.3.1</a>. NETCONF Event Stream</span>
The server SHOULD support the NETCONF event stream defined in
<a href="./rfc5277#section-3.2.3">Section 3.2.3 of [RFC5277]</a>. The notification messages for this
stream are encoded in XML.
The server MAY support additional streams that represent the semantic
content of the NETCONF event stream, but using a representation with
a different media type.
The server MAY support the "start-time", "stop-time", and "filter"
query parameters, defined in <a href="#section-4.8">Section 4.8</a>. Refer to <a href="#appendix-B.3.6">Appendix B.3.6</a>
for filter parameter examples.
<span class="h3"><a class="selflink" id="section-6.4" href="#section-6.4">6.4</a>. Receiving Event Notifications</span>
RESTCONF notifications are encoded according to the definition of the
event stream.
The structure of the event data is based on the <notification>
element definition in <a href="./rfc5277#section-4">Section 4 of [RFC5277]</a>. It MUST conform to the
schema for the <notification> element in <a href="./rfc5277#section-4">Section 4 of [RFC5277]</a>,
using the XML namespace as defined in the XSD as follows:
urn:ietf:params:xml:ns:netconf:notification:1.0
For JSON-encoding purposes, the module name for the "notification"
element is "ietf-restconf".
Two child nodes within the "notification" container are expected,
representing the event time and the event payload. The "eventTime"
node is defined within the same XML namespace as the <notification>
element. It is defined to be within the "ietf-restconf" module
namespace for JSON-encoding purposes.
The name and namespace of the payload element are determined by the
YANG module containing the notification-stmt representing the
notification message.
<span class="grey">Bierman, et al. Standards Track [Page 70]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-71" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
In the following example, the YANG module "example-mod" is used:
module example-mod {
namespace "http://example.com/event/1.0";
prefix ex;
organization "Example, Inc.";
contact "support at example.com";
description "Example Notification Data Model Module.";
revision "2016-07-07" {
description "Initial version.";
reference "example.com document 2-9976.";
}
notification event {
description "Example notification event.";
leaf event-class {
type string;
description "Event class identifier.";
}
container reporting-entity {
description "Event specific information.";
leaf card {
type string;
description "Line card identifier.";
}
}
leaf severity {
type string;
description "Event severity description.";
}
}
}
An example SSE event notification encoded using XML:
data: <notification
data: xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
data: <eventTime>2013-12-21T00:01:00Z</eventTime>
data: <event xmlns="http://example.com/event/1.0">
data: <event-class>fault</event-class>
data: <reporting-entity>
data: <card>Ethernet0</card>
data: </reporting-entity>
data: <severity>major</severity>
data: </event>
data: </notification>
<span class="grey">Bierman, et al. Standards Track [Page 71]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-72" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
An example SSE event notification encoded using JSON:
data: {
data: "ietf-restconf:notification" : {
data: "eventTime" : "2013-12-21T00:01:00Z",
data: "example-mod:event" : {
data: "event-class" : "fault",
data: "reporting-entity" : { "card" : "Ethernet0" },
data: "severity" : "major"
data: }
data: }
data: }
Alternatively, since neither XML nor JSON is whitespace sensitive,
the above messages can be encoded onto a single line. For example:
XML:
data: <notification xmlns="urn:ietf:params:xml:ns:netconf:notif\
ication:1.0"><eventTime>2013-12-21T00:01:00Z</eventTime><event \
xmlns="http://example.com/event/1.0"><event-class>fault</event-\
class><reportingEntity><card>Ethernet0</card></reporting-entity>\
<severity>major</severity></event></notification>
JSON:
data: {"ietf-restconf:notification":{"eventTime":"2013-12-21\
T00:01:00Z","example-mod:event":{"event-class": "fault","repor\
tingEntity":{"card":"Ethernet0"},"severity":"major"}}}
The SSE specification supports the following additional fields:
"event", "id", and "retry". A RESTCONF server MAY send the "retry"
field, and if it does, RESTCONF clients SHOULD use it. A RESTCONF
server SHOULD NOT send the "event" or "id" fields, as there are no
meaningful values that could be used for them that would not be
redundant to the contents of the notification itself. RESTCONF
servers that do not send the "id" field also do not need to support
the HTTP header field "Last-Event-ID" [<a href="#ref-W3C.REC-eventsource-20150203">W3C.REC-eventsource-20150203</a>].
RESTCONF servers that do send the "id" field SHOULD support the
"start-time" query parameter as the preferred means for a client to
specify where to restart the event stream.
<span class="grey">Bierman, et al. Standards Track [Page 72]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-73" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h2"><a class="selflink" id="section-7" href="#section-7">7</a>. Error Reporting</span>
HTTP status codes are used to report success or failure for RESTCONF
operations. The error information that NETCONF error responses
contain in the <rpc-error> element is adapted for use in RESTCONF,
and <errors> data tree information is returned for the "4xx" and
"5xx" classes of status codes.
Since an operation resource is defined with a YANG "rpc" statement
and an action is defined with a YANG "action" statement, a mapping
from the NETCONF <error-tag> value to the HTTP status code is needed.
The specific error-tag and response code to use are specific to the
data model and might be contained in the YANG "description" statement
for the "action" or "rpc" statement.
<span class="grey">Bierman, et al. Standards Track [Page 73]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-74" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
+-------------------------+------------------+
| error-tag | status code |
+-------------------------+------------------+
| in-use | 409 |
| | |
| invalid-value | 400, 404, or 406 |
| | |
| (request) too-big | 413 |
| | |
| (response) too-big | 400 |
| | |
| missing-attribute | 400 |
| | |
| bad-attribute | 400 |
| | |
| unknown-attribute | 400 |
| | |
| bad-element | 400 |
| | |
| unknown-element | 400 |
| | |
| unknown-namespace | 400 |
| | |
| access-denied | 401 or 403 |
| | |
| lock-denied | 409 |
| | |
| resource-denied | 409 |
| | |
| rollback-failed | 500 |
| | |
| data-exists | 409 |
| | |
| data-missing | 409 |
| | |
| operation-not-supported | 405 or 501 |
| | |
| operation-failed | 412 or 500 |
| | |
| partial-operation | 500 |
| | |
| malformed-message | 400 |
+-------------------------+------------------+
Mapping from <error-tag> to Status Code
<span class="grey">Bierman, et al. Standards Track [Page 74]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-75" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h3"><a class="selflink" id="section-7.1" href="#section-7.1">7.1</a>. Error Response Message</span>
When an error occurs for a request message on any resource type and
the status code that will be returned is in the "4xx" range (except
for status code "403 Forbidden"), the server SHOULD send a response
message-body containing the information described by the
"yang-errors" YANG data template within the "ietf-restconf" module
found in <a href="#section-8">Section 8</a>. The Content-Type of this response message MUST
be "application/yang-data", plus, optionally, a structured syntax
name suffix.
The client SHOULD specify the desired encoding(s) for response
messages by specifying the appropriate media type(s) in the
"Accept" header. If the client did not specify an "Accept" header,
then the same structured syntax name suffix used in the request
message SHOULD be used, or the server MAY choose any supported
message-encoding format. If there is no request message, the server
MUST select "application/yang-data+xml" or
"application/yang-data+json", depending on server preference. All of
the examples in this document, except for the one below, assume that
XML encoding will be returned if there is an error.
YANG tree diagram for <errors> data:
+---- errors
+---- error*
+---- error-type enumeration
+---- error-tag string
+---- error-app-tag? string
+---- error-path? instance-identifier
+---- error-message? string
+---- error-info?
The semantics and syntax for RESTCONF error messages are defined with
the "yang-errors" YANG data template extension, found in <a href="#section-8">Section 8</a>.
<span class="grey">Bierman, et al. Standards Track [Page 75]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-76" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
Examples:
The following example shows an error returned for a "lock-denied"
error that can occur if a NETCONF client has locked a datastore. The
RESTCONF client is attempting to delete a data resource. Note that
an "Accept" header field is used to specify the desired encoding for
the error message. There would be no response message-body content
if this operation was successful.
DELETE /restconf/data/example-jukebox:jukebox/\
library/artist=Foo%20Fighters/album=Wasting%20Light HTTP/1.1
Host: example.com
Accept: application/yang-data+json
<span class="grey">Bierman, et al. Standards Track [Page 76]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-77" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The server might respond as follows:
HTTP/1.1 409 Conflict
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Content-Type: application/yang-data+json
{
"ietf-restconf:errors" : {
"error" : [
{
"error-type" : "protocol",
"error-tag" : "lock-denied",
"error-message" : "Lock failed; lock already held"
}
]
}
}
The following example shows an error returned for a "data-exists"
error on a data resource. The "jukebox" resource already exists, so
it cannot be created.
The client might send the following:
POST /restconf/data/example-jukebox:jukebox HTTP/1.1
Host: example.com
<span class="grey">Bierman, et al. Standards Track [Page 77]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-78" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The server might respond as follows:
HTTP/1.1 409 Conflict
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Content-Type: application/yang-data+xml
<errors xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
<error>
<error-type>protocol</error-type>
<error-tag>data-exists</error-tag>
<error-path
xmlns:rc="urn:ietf:params:xml:ns:yang:ietf-restconf"
xmlns:jbox="https://example.com/ns/example-jukebox">\
/rc:restconf/rc:data/jbox:jukebox
</error-path>
<error-message>
Data already exists; cannot create new resource
</error-message>
</error>
</errors>
<span class="grey">Bierman, et al. Standards Track [Page 78]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-79" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h2"><a class="selflink" id="section-8" href="#section-8">8</a>. RESTCONF Module</span>
The "ietf-restconf" module defines conceptual definitions within an
extension and two groupings, which are not meant to be implemented as
datastore contents by a server. For example, the "restconf"
container is not intended to be implemented as a top-level data node
(under the "/restconf/data" URI).
Note that the "ietf-restconf" module does not have any
protocol-accessible objects, so no YANG tree diagram is shown.
<CODE BEGINS>
file "ietf-restconf@2017-01-26.yang"
module ietf-restconf {
yang-version 1.1;
namespace "urn:ietf:params:xml:ns:yang:ietf-restconf";
prefix "rc";
organization
"IETF NETCONF (Network Configuration) Working Group";
contact
"WG Web: <<a href="https://datatracker.ietf.org/wg/netconf/">https://datatracker.ietf.org/wg/netconf/</a>>
WG List: <mailto:netconf@ietf.org>
Author: Andy Bierman
<mailto:andy@yumaworks.com>
Author: Martin Bjorklund
<mailto:mbj@tail-f.com>
Author: Kent Watsen
<mailto:kwatsen@juniper.net>";
description
"This module contains conceptual YANG specifications
for basic RESTCONF media type definitions used in
RESTCONF protocol messages.
Note that the YANG definitions within this module do not
represent configuration data of any kind.
The 'restconf-media-type' YANG extension statement
provides a normative syntax for XML and JSON
message-encoding purposes.
<span class="grey">Bierman, et al. Standards Track [Page 79]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-80" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
Copyright (c) 2017 IETF Trust and the persons identified as
authors of the code. All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, is permitted pursuant to, and subject
to the license terms contained in, the Simplified BSD License
set forth in <a href="#section-4">Section 4</a>.c of the IETF Trust's Legal Provisions
Relating to IETF Documents
(<a href="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</a>).
This version of this YANG module is part of <a href="./rfc8040">RFC 8040</a>; see
the RFC itself for full legal notices.";
revision 2017-01-26 {
description
"Initial revision.";
reference
"<a href="./rfc8040">RFC 8040</a>: RESTCONF Protocol.";
}
extension yang-data {
argument name {
yin-element true;
}
description
"This extension is used to specify a YANG data template that
represents conceptual data defined in YANG. It is
intended to describe hierarchical data independent of
protocol context or specific message-encoding format.
Data definition statements within a yang-data extension
specify the generic syntax for the specific YANG data
template, whose name is the argument of the 'yang-data'
extension statement.
Note that this extension does not define a media type.
A specification using this extension MUST specify the
message-encoding rules, including the content media type.
The mandatory 'name' parameter value identifies the YANG
data template that is being defined. It contains the
template name.
This extension is ignored unless it appears as a top-level
statement. It MUST contain data definition statements
that result in exactly one container data node definition.
An instance of a YANG data template can thus be translated
into an XML instance document, whose top-level element
corresponds to the top-level container.
<span class="grey">Bierman, et al. Standards Track [Page 80]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-81" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The module name and namespace values for the YANG module using
the extension statement are assigned to instance document data
conforming to the data definition statements within
this extension.
The substatements of this extension MUST follow the
'data-def-stmt' rule in the YANG ABNF.
The XPath document root is the extension statement itself,
such that the child nodes of the document root are
represented by the data-def-stmt substatements within
this extension. This conceptual document is the context
for the following YANG statements:
- must-stmt
- when-stmt
- path-stmt
- min-elements-stmt
- max-elements-stmt
- mandatory-stmt
- unique-stmt
- ordered-by
- instance-identifier data type
The following data-def-stmt substatements are constrained
when used within a 'yang-data' extension statement.
- The list-stmt is not required to have a key-stmt defined.
- The if-feature-stmt is ignored if present.
- The config-stmt is ignored if present.
- The available identity values for any 'identityref'
leaf or leaf-list nodes are limited to the module
containing this extension statement and the modules
imported into that module.
";
}
rc:yang-data yang-errors {
uses errors;
}
rc:yang-data yang-api {
uses restconf;
}
<span class="grey">Bierman, et al. Standards Track [Page 81]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-82" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
grouping errors {
description
"A grouping that contains a YANG container
representing the syntax and semantics of a
YANG Patch error report within a response message.";
container errors {
description
"Represents an error report returned by the server if
a request results in an error.";
list error {
description
"An entry containing information about one
specific error that occurred while processing
a RESTCONF request.";
reference
"<a href="./rfc6241#section-4.3">RFC 6241, Section 4.3</a>.";
leaf error-type {
type enumeration {
enum transport {
description
"The transport layer.";
}
enum rpc {
description
"The rpc or notification layer.";
}
enum protocol {
description
"The protocol operation layer.";
}
enum application {
description
"The server application layer.";
}
}
mandatory true;
description
"The protocol layer where the error occurred.";
}
<span class="grey">Bierman, et al. Standards Track [Page 82]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-83" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
leaf error-tag {
type string;
mandatory true;
description
"The enumerated error-tag.";
}
leaf error-app-tag {
type string;
description
"The application-specific error-tag.";
}
leaf error-path {
type instance-identifier;
description
"The YANG instance identifier associated
with the error node.";
}
leaf error-message {
type string;
description
"A message describing the error.";
}
anydata error-info {
description
"This anydata value MUST represent a container with
zero or more data nodes representing additional
error information.";
}
}
}
}
grouping restconf {
description
"Conceptual grouping representing the RESTCONF
root resource.";
container restconf {
description
"Conceptual container representing the RESTCONF
root resource.";
<span class="grey">Bierman, et al. Standards Track [Page 83]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-84" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
container data {
description
"Container representing the datastore resource.
Represents the conceptual root of all state data
and configuration data supported by the server.
The child nodes of this container can be any data
resources that are defined as top-level data nodes
from the YANG modules advertised by the server in
the 'ietf-yang-library' module.";
}
container operations {
description
"Container for all operation resources.
Each resource is represented as an empty leaf with the
name of the RPC operation from the YANG 'rpc' statement.
For example, the 'system-restart' RPC operation defined
in the 'ietf-system' module would be represented as
an empty leaf in the 'ietf-system' namespace. This is
a conceptual leaf and will not actually be found in
the module:
module ietf-system {
leaf system-reset {
type empty;
}
}
To invoke the 'system-restart' RPC operation:
POST /restconf/operations/ietf-system:system-restart
To discover the RPC operations supported by the server:
GET /restconf/operations
In XML, the YANG module namespace identifies the module:
<system-restart
xmlns='urn:ietf:params:xml:ns:yang:ietf-system'/>
In JSON, the YANG module name identifies the module:
{ 'ietf-system:system-restart' : [null] }
";
}
<span class="grey">Bierman, et al. Standards Track [Page 84]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-85" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
leaf yang-library-version {
type string {
pattern '\d{4}-\d{2}-\d{2}';
}
config false;
mandatory true;
description
"Identifies the revision date of the 'ietf-yang-library'
module that is implemented by this RESTCONF server.
Indicates the year, month, and day in YYYY-MM-DD
numeric format.";
}
}
}
}
<CODE ENDS>
<span class="h2"><a class="selflink" id="section-9" href="#section-9">9</a>. RESTCONF Monitoring</span>
The "ietf-restconf-monitoring" module provides information about the
RESTCONF protocol capabilities and event streams available from the
server. A RESTCONF server MUST implement the
"ietf-restconf-monitoring" module.
YANG tree diagram for the "ietf-restconf-monitoring" module:
+--ro restconf-state
+--ro capabilities
| +--ro capability* inet:uri
+--ro streams
+--ro stream* [name]
+--ro name string
+--ro description? string
+--ro replay-support? boolean
+--ro replay-log-creation-time? yang:date-and-time
+--ro access* [encoding]
+--ro encoding string
+--ro location inet:uri
<span class="grey">Bierman, et al. Standards Track [Page 85]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-86" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h3"><a class="selflink" id="section-9.1" href="#section-9.1">9.1</a>. restconf-state/capabilities</span>
This mandatory container holds the RESTCONF protocol capability URIs
supported by the server.
The server MAY maintain a last-modified timestamp for this container
and return the "Last-Modified" header field when this data node is
retrieved with the GET or HEAD methods. Note that the last-modified
timestamp for the datastore resource is not affected by changes to
this subtree.
The server SHOULD maintain an entity-tag for this container and
return the "ETag" header field when this data node is retrieved with
the GET or HEAD methods. Note that the entity-tag for the datastore
resource is not affected by changes to this subtree.
The server MUST include a "capability" URI leaf-list entry for the
"defaults" mode used by the server, defined in <a href="#section-9.1.2">Section 9.1.2</a>.
The server MUST include a "capability" URI leaf-list entry
identifying each supported optional protocol feature. This includes
optional query parameters and MAY include other capability URIs
defined outside this document.
<span class="grey">Bierman, et al. Standards Track [Page 86]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-87" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h4"><a class="selflink" id="section-9.1.1" href="#section-9.1.1">9.1.1</a>. Query Parameter URIs</span>
A new set of RESTCONF Capability URIs are defined to identify the
specific query parameters (defined in <a href="#section-4.8">Section 4.8</a>) supported by the
server.
The server MUST include a "capability" leaf-list entry for each
optional query parameter that it supports.
+----------------+---------+---------------------------------------+
| Name | Section | URI |
| | | |
+----------------+---------+---------------------------------------+
| depth | 4.8.2 | urn:ietf:params:restconf:capability: |
| | | depth:1.0 |
| | | |
| fields | 4.8.3 | urn:ietf:params:restconf:capability: |
| | | fields:1.0 |
| | | |
| filter | 4.8.4 | urn:ietf:params:restconf:capability: |
| | | filter:1.0 |
| | | |
| replay | 4.8.7 | urn:ietf:params:restconf:capability: |
| | 4.8.8 | replay:1.0 |
| | | |
| with-defaults | 4.8.9 | urn:ietf:params:restconf:capability: |
| | | with-defaults:1.0 |
+----------------+---------+---------------------------------------+
RESTCONF Query Parameter URIs
<span class="h4"><a class="selflink" id="section-9.1.2" href="#section-9.1.2">9.1.2</a>. The "defaults" Protocol Capability URI</span>
This URI identifies the "basic-mode" default-handling mode that is
used by the server for processing default leafs in requests for data
resources. This protocol capability URI MUST be supported by the
server and MUST be listed in the "capability" leaf-list defined in
<a href="#section-9.3">Section 9.3</a>.
+----------+--------------------------------------------------+
| Name | URI |
+----------+--------------------------------------------------+
| defaults | urn:ietf:params:restconf:capability:defaults:1.0 |
+----------+--------------------------------------------------+
RESTCONF "defaults" Capability URI
<span class="grey">Bierman, et al. Standards Track [Page 87]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-88" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The URI MUST contain a query parameter named "basic-mode" with one of
the values listed below:
+------------+------------------------------------------------------+
| Value | Description |
+------------+------------------------------------------------------+
| report-all | No data nodes are considered default |
| | |
| trim | Values set to the YANG default-stmt value are |
| | default |
| | |
| explicit | Values set by the client are never considered |
| | default |
+------------+------------------------------------------------------+
The "basic-mode" definitions are specified in "With-defaults
Capability for NETCONF" [<a href="./rfc6243" title=""With-defaults Capability for NETCONF"">RFC6243</a>].
If the "basic-mode" is set to "report-all", then the server MUST
adhere to the default-handling behavior defined in <a href="./rfc6243#section-2.1">Section 2.1 of
[RFC6243]</a>.
If the "basic-mode" is set to "trim", then the server MUST adhere to
the default-handling behavior defined in <a href="./rfc6243#section-2.2">Section 2.2 of [RFC6243]</a>.
If the "basic-mode" is set to "explicit", then the server MUST adhere
to the default-handling behavior defined in <a href="./rfc6243#section-2.3">Section 2.3 of [RFC6243]</a>.
Example (split for display purposes only):
urn:ietf:params:restconf:capability:defaults:1.0?
basic-mode=explicit
<span class="h3"><a class="selflink" id="section-9.2" href="#section-9.2">9.2</a>. restconf-state/streams</span>
This optional container provides access to the event streams
supported by the server. The server MAY omit this container if no
event streams are supported.
The server will populate this container with a "stream" list entry
for each stream type it supports. Each stream contains a leaf called
"events", which contains a URI that represents an event stream
resource.
Stream resources are defined in <a href="#section-3.8">Section 3.8</a>. Notifications are
defined in <a href="#section-6">Section 6</a>.
<span class="grey">Bierman, et al. Standards Track [Page 88]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-89" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h3"><a class="selflink" id="section-9.3" href="#section-9.3">9.3</a>. RESTCONF Monitoring Module</span>
The "ietf-restconf-monitoring" module defines monitoring information
for the RESTCONF protocol.
The "ietf-yang-types" and "ietf-inet-types" modules from [<a href="./rfc6991" title=""Common YANG Data Types"">RFC6991</a>]
are used by this module for some type definitions.
<CODE BEGINS>
file "ietf-restconf-monitoring@2017-01-26.yang"
module ietf-restconf-monitoring {
namespace "urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring";
prefix "rcmon";
import ietf-yang-types { prefix yang; }
import ietf-inet-types { prefix inet; }
organization
"IETF NETCONF (Network Configuration) Working Group";
contact
"WG Web: <<a href="https://datatracker.ietf.org/wg/netconf/">https://datatracker.ietf.org/wg/netconf/</a>>
WG List: <mailto:netconf@ietf.org>
Author: Andy Bierman
<mailto:andy@yumaworks.com>
Author: Martin Bjorklund
<mailto:mbj@tail-f.com>
Author: Kent Watsen
<mailto:kwatsen@juniper.net>";
<span class="grey">Bierman, et al. Standards Track [Page 89]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-90" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
description
"This module contains monitoring information for the
RESTCONF protocol.
Copyright (c) 2017 IETF Trust and the persons identified as
authors of the code. All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, is permitted pursuant to, and subject
to the license terms contained in, the Simplified BSD License
set forth in <a href="#section-4">Section 4</a>.c of the IETF Trust's Legal Provisions
Relating to IETF Documents
(<a href="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</a>).
This version of this YANG module is part of <a href="./rfc8040">RFC 8040</a>; see
the RFC itself for full legal notices.";
revision 2017-01-26 {
description
"Initial revision.";
reference
"<a href="./rfc8040">RFC 8040</a>: RESTCONF Protocol.";
}
container restconf-state {
config false;
description
"Contains RESTCONF protocol monitoring information.";
container capabilities {
description
"Contains a list of protocol capability URIs.";
leaf-list capability {
type inet:uri;
description
"A RESTCONF protocol capability URI.";
}
}
<span class="grey">Bierman, et al. Standards Track [Page 90]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-91" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
container streams {
description
"Container representing the notification event streams
supported by the server.";
reference
"<a href="./rfc5277#section-3.4">RFC 5277, Section 3.4</a>, <streams> element.";
list stream {
key name;
description
"Each entry describes an event stream supported by
the server.";
leaf name {
type string;
description
"The stream name.";
reference
"<a href="./rfc5277#section-3.4">RFC 5277, Section 3.4</a>, <name> element.";
}
leaf description {
type string;
description
"Description of stream content.";
reference
"<a href="./rfc5277#section-3.4">RFC 5277, Section 3.4</a>, <description> element.";
}
leaf replay-support {
type boolean;
default false;
description
"Indicates if replay buffer is supported for this stream.
If 'true', then the server MUST support the 'start-time'
and 'stop-time' query parameters for this stream.";
reference
"<a href="./rfc5277#section-3.4">RFC 5277, Section 3.4</a>, <replaySupport> element.";
}
<span class="grey">Bierman, et al. Standards Track [Page 91]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-92" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
leaf replay-log-creation-time {
when "../replay-support" {
description
"Only present if notification replay is supported.";
}
type yang:date-and-time;
description
"Indicates the time the replay log for this stream
was created.";
reference
"<a href="./rfc5277#section-3.4">RFC 5277, Section 3.4</a>, <replayLogCreationTime>
element.";
}
list access {
key encoding;
min-elements 1;
description
"The server will create an entry in this list for each
encoding format that is supported for this stream.
The media type 'text/event-stream' is expected
for all event streams. This list identifies the
subtypes supported for this stream.";
leaf encoding {
type string;
description
"This is the secondary encoding format within the
'text/event-stream' encoding used by all streams.
The type 'xml' is supported for XML encoding.
The type 'json' is supported for JSON encoding.";
}
<span class="grey">Bierman, et al. Standards Track [Page 92]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-93" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
leaf location {
type inet:uri;
mandatory true;
description
"Contains a URL that represents the entry point
for establishing notification delivery via
server-sent events.";
}
}
}
}
}
}
<CODE ENDS>
<span class="h2"><a class="selflink" id="section-10" href="#section-10">10</a>. YANG Module Library</span>
The "ietf-yang-library" module defined in [<a href="./rfc7895" title=""YANG Module Library"">RFC7895</a>] provides
information about the YANG modules and submodules used by the
RESTCONF server. Implementation is mandatory for RESTCONF servers.
All YANG modules and submodules used by the server MUST be identified
in the YANG module library.
<span class="h3"><a class="selflink" id="section-10.1" href="#section-10.1">10.1</a>. modules-state/module</span>
This mandatory list contains one entry for each YANG data model
module supported by the server. There MUST be an instance of this
list for every YANG module that is used by the server.
The contents of this list are defined in the "module" YANG list
statement in [<a href="./rfc7895" title=""YANG Module Library"">RFC7895</a>].
Note that there are no protocol-accessible objects in the
"ietf-restconf" module to implement, but it is possible that a server
will list the "ietf-restconf" module in the YANG library if it is
imported (directly or indirectly) by an implemented module.
<span class="grey">Bierman, et al. Standards Track [Page 93]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-94" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h2"><a class="selflink" id="section-11" href="#section-11">11</a>. IANA Considerations</span>
<span class="h3"><a class="selflink" id="section-11.1" href="#section-11.1">11.1</a>. The "restconf" Relation Type</span>
This specification registers the "restconf" relation type in the
"Link Relation Types" registry defined by [<a href="./rfc5988" title=""Web Linking"">RFC5988</a>]:
Relation Name: restconf
Description: Identifies the root of the RESTCONF API as configured
on this HTTP server. The "restconf" relation
defines the root of the API defined in <a href="./rfc8040">RFC 8040</a>.
Subsequent revisions of RESTCONF will use alternate
relation values to support protocol versioning.
Reference: <a href="./rfc8040">RFC 8040</a>
<span class="h3"><a class="selflink" id="section-11.2" href="#section-11.2">11.2</a>. Registrations for New URIs and YANG Modules</span>
This document registers two URIs as namespaces in the "IETF XML
Registry" [<a href="./rfc3688" title=""The IETF XML Registry"">RFC3688</a>]:
URI: urn:ietf:params:xml:ns:yang:ietf-restconf
Registrant Contact: The IESG.
XML: N/A; the requested URI is an XML namespace.
URI: urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring
Registrant Contact: The IESG.
XML: N/A; the requested URI is an XML namespace.
This document registers two YANG modules in the "YANG Module Names"
registry [<a href="./rfc6020" title=""YANG - A Data Modeling Language for the Network Configuration Protocol (NETCONF)"">RFC6020</a>]:
name: ietf-restconf
namespace: urn:ietf:params:xml:ns:yang:ietf-restconf
prefix: rc
reference: <a href="./rfc8040">RFC 8040</a>
name: ietf-restconf-monitoring
namespace: urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring
prefix: rcmon
reference: <a href="./rfc8040">RFC 8040</a>
<span class="grey">Bierman, et al. Standards Track [Page 94]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-95" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h3"><a class="selflink" id="section-11.3" href="#section-11.3">11.3</a>. Media Types</span>
<span class="h4"><a class="selflink" id="section-11.3.1" href="#section-11.3.1">11.3.1</a>. Media Type "application/yang-data+xml"</span>
Type name: application
Subtype name: yang-data+xml
Required parameters: None
Optional parameters: None
Encoding considerations: 8-bit
Each conceptual YANG data node is encoded according to the
XML Encoding Rules and Canonical Format for the specific
YANG data node type defined in [<a href="./rfc7950" title=""The YANG 1.1 Data Modeling Language"">RFC7950</a>].
Security considerations: Security considerations related
to the generation and consumption of RESTCONF messages
are discussed in <a href="./rfc8040#section-12">Section 12 of RFC 8040</a>.
Additional security considerations are specific to the
semantics of particular YANG data models. Each YANG module
is expected to specify security considerations for the
YANG data defined in that module.
Interoperability considerations: <a href="./rfc8040">RFC 8040</a> specifies the
format of conforming messages and the interpretation
thereof.
Published specification: <a href="./rfc8040">RFC 8040</a>
Applications that use this media type: Instance document
data parsers used within a protocol or automation tool
that utilize YANG-defined data structures.
Fragment identifier considerations: Fragment identifiers for
this type are not defined. All YANG data nodes are
accessible as resources using the path in the request URI.
Additional information:
Deprecated alias names for this type: N/A
Magic number(s): N/A
File extension(s): None
Macintosh file type code(s): "TEXT"
Person & email address to contact for further information: See
the Authors' Addresses section of <a href="./rfc8040">RFC 8040</a>.
<span class="grey">Bierman, et al. Standards Track [Page 95]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-96" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
Intended usage: COMMON
Restrictions on usage: N/A
Author: See the Authors' Addresses section of <a href="./rfc8040">RFC 8040</a>.
Change controller: Internet Engineering Task Force
(mailto:iesg@ietf.org).
Provisional registration? (standards tree only): no
<span class="h4"><a class="selflink" id="section-11.3.2" href="#section-11.3.2">11.3.2</a>. Media Type "application/yang-data+json"</span>
Type name: application
Subtype name: yang-data+json
Required parameters: None
Optional parameters: None
Encoding considerations: 8-bit
Each conceptual YANG data node is encoded according to
[<a href="./rfc7951" title=""JSON Encoding of Data Modeled with YANG"">RFC7951</a>]. A metadata annotation is encoded according to
[<a href="./rfc7952" title=""Defining and Using Metadata with YANG"">RFC7952</a>].
Security considerations: Security considerations related
to the generation and consumption of RESTCONF messages
are discussed in <a href="./rfc8040#section-12">Section 12 of RFC 8040</a>.
Additional security considerations are specific to the
semantics of particular YANG data models. Each YANG module
is expected to specify security considerations for the
YANG data defined in that module.
Interoperability considerations: <a href="./rfc8040">RFC 8040</a> specifies the format
of conforming messages and the interpretation thereof.
Published specification: <a href="./rfc8040">RFC 8040</a>
Applications that use this media type: Instance document
data parsers used within a protocol or automation tool
that utilize YANG-defined data structures.
Fragment identifier considerations: The syntax and semantics
of fragment identifiers are the same as the syntax and semantics
specified for the "application/json" media type.
<span class="grey">Bierman, et al. Standards Track [Page 96]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-97" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
Additional information:
Deprecated alias names for this type: N/A
Magic number(s): N/A
File extension(s): None
Macintosh file type code(s): "TEXT"
Person & email address to contact for further information: See
the Authors' Addresses section of <a href="./rfc8040">RFC 8040</a>.
Intended usage: COMMON
Restrictions on usage: N/A
Author: See the Authors' Addresses section of <a href="./rfc8040">RFC 8040</a>.
Change controller: Internet Engineering Task Force
(mailto:iesg@ietf.org).
Provisional registration? (standards tree only): no
<span class="h3"><a class="selflink" id="section-11.4" href="#section-11.4">11.4</a>. RESTCONF Capability URNs</span>
This document defines a registry for RESTCONF capability identifiers.
The name of the registry is "RESTCONF Capability URNs". The review
policy for this registry is "IETF Review" [<a href="./rfc5226" title="">RFC5226</a>]. The registry
shall record the following for each entry:
o the name of the RESTCONF capability. By convention, this name
begins with the colon (":") character.
o the URN for the RESTCONF capability.
o the reference for the document registering the value.
<span class="grey">Bierman, et al. Standards Track [Page 97]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-98" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
This document registers several capability identifiers in the
"RESTCONF Capability URNs" registry:
Index Capability Identifier
---------------------------------------------------------------------
:defaults urn:ietf:params:restconf:capability:defaults:1.0
:depth urn:ietf:params:restconf:capability:depth:1.0
:fields urn:ietf:params:restconf:capability:fields:1.0
:filter urn:ietf:params:restconf:capability:filter:1.0
:replay urn:ietf:params:restconf:capability:replay:1.0
:with-defaults urn:ietf:params:restconf:capability:with-defaults:1.0
<span class="h3"><a class="selflink" id="section-11.5" href="#section-11.5">11.5</a>. Registration of "restconf" URN Sub-namespace</span>
IANA has registered a new URN sub-namespace within the "IETF URN
Sub-namespace for Registered Protocol Parameter Identifiers" registry
defined in [<a href="./rfc3553" title=""An IETF URN Sub-namespace for Registered Protocol Parameters"">RFC3553</a>].
Registry Name: restconf
Specification: <a href="./rfc8040">RFC 8040</a>
Repository: "RESTCONF Capability URNs" registry (<a href="#section-11.4">Section 11.4</a>)
Index value: Sub-parameters MUST be specified in UTF-8, using
standard URI encoding where necessary.
<span class="grey">Bierman, et al. Standards Track [Page 98]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-99" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h2"><a class="selflink" id="section-12" href="#section-12">12</a>. Security Considerations</span>
<a href="#section-2.1">Section 2.1</a> states that "a RESTCONF server MUST support the TLS
protocol [<a href="./rfc5246" title=""The Transport Layer Security (TLS) Protocol Version 1.2"">RFC5246</a>]." This language leaves open the possibility that
a RESTCONF server might also support future versions of the TLS
protocol. Of specific concern, TLS 1.3 [<a href="#ref-TLS1.3" title=""The Transport Layer Security (TLS) Protocol Version 1.3"">TLS1.3</a>] introduces support
for 0-RTT handshakes that can lead to security issues for RESTCONF
APIs, as described in <a href="#appendix-B.1">Appendix B.1</a> of the TLS 1.3 document. It is
therefore RECOMMENDED that RESTCONF servers do not support 0-RTT at
all (not even for idempotent requests) until an update to this RFC
guides otherwise.
<a href="#section-2.5">Section 2.5</a> recommends authentication based on TLS client
certificates but allows the use of any authentication scheme defined
in the "Hypertext Transfer Protocol (HTTP) Authentication Scheme
Registry". Implementations need to be aware that the strengths of
these methods vary greatly and that some may be considered
experimental. Selection of any of these schemes SHOULD be performed
after reading the Security Considerations section of the RFC
associated with the scheme's registry entry.
The "ietf-restconf-monitoring" YANG module defined in this memo is
designed to be accessed via the NETCONF protocol [<a href="./rfc6241" title=""Network Configuration Protocol (NETCONF)"">RFC6241</a>]. The
lowest NETCONF layer is the secure transport layer, and the
mandatory-to-implement secure transport is Secure Shell (SSH)
[<a href="./rfc6242" title=""Using the NETCONF Protocol over Secure Shell (SSH)"">RFC6242</a>]. The NETCONF access control model [<a href="./rfc6536" title=""Network Configuration Protocol (NETCONF) Access Control Model"">RFC6536</a>] provides the
means to restrict access for particular NETCONF users to a
preconfigured subset of all available NETCONF protocol operations and
content.
The lowest RESTCONF layer is HTTPS, and the mandatory-to-implement
secure transport is TLS [<a href="./rfc5246" title=""The Transport Layer Security (TLS) Protocol Version 1.2"">RFC5246</a>]. The RESTCONF protocol uses the
NETCONF access control model [<a href="./rfc6536" title=""Network Configuration Protocol (NETCONF) Access Control Model"">RFC6536</a>], which provides the means to
restrict access for particular RESTCONF users to a preconfigured
subset of all available RESTCONF protocol operations and content.
This section provides security considerations for the resources
defined by the RESTCONF protocol. Security considerations for HTTPS
are defined in [<a href="./rfc7230" title=""Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing"">RFC7230</a>]. Aside from the "ietf-restconf-monitoring"
module (<a href="#section-9">Section 9</a>) and the "ietf-yang-library" module (<a href="#section-10">Section 10</a>),
RESTCONF does not specify which YANG modules a server needs to
support. Security considerations for the other modules manipulated
by RESTCONF can be found in the documents defining those YANG
modules.
Configuration information is by its very nature sensitive. Its
transmission in the clear and without integrity checking leaves
devices open to classic eavesdropping and false data injection
<span class="grey">Bierman, et al. Standards Track [Page 99]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-100" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
attacks. Configuration information often contains passwords, user
names, service descriptions, and topological information, all of
which are sensitive. There are many patterns of attack that have
been observed through operational practice with existing management
interfaces. It would be wise for implementers to research them and
take them into account when implementing this protocol.
Different environments may well allow different rights prior to, and
then after, authentication. When a RESTCONF operation is not
properly authorized, the RESTCONF server MUST return a "401
Unauthorized" status-line. Note that authorization information can
be exchanged in the form of configuration information, which is all
the more reason to ensure the security of the connection. Note that
it is possible for a client to detect configuration changes in data
resources it is not authorized to access by monitoring changes in the
"ETag" and "Last-Modified" header fields returned by the server for
the datastore resource.
A RESTCONF server implementation SHOULD attempt to prevent system
disruption due to excessive resource consumption required to fulfill
edit requests via the POST, PUT, and PATCH methods. On such an
implementation, it may be possible to construct an attack that
attempts to consume all available memory or other resource types.
<span class="h2"><a class="selflink" id="section-13" href="#section-13">13</a>. References</span>
<span class="h3"><a class="selflink" id="section-13.1" href="#section-13.1">13.1</a>. Normative References</span>
[<a id="ref-RFC2046">RFC2046</a>] Freed, N. and N. Borenstein, "Multipurpose Internet Mail
Extensions (MIME) Part Two: Media Types", <a href="./rfc2046">RFC 2046</a>,
DOI 10.17487/RFC2046, November 1996,
<<a href="http://www.rfc-editor.org/info/rfc2046">http://www.rfc-editor.org/info/rfc2046</a>>.
[<a id="ref-RFC2119">RFC2119</a>] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", <a href="https://www.rfc-editor.org/bcp/bcp14">BCP 14</a>, <a href="./rfc2119">RFC 2119</a>,
DOI 10.17487/RFC2119, March 1997,
<<a href="http://www.rfc-editor.org/info/rfc2119">http://www.rfc-editor.org/info/rfc2119</a>>.
[<a id="ref-RFC3553">RFC3553</a>] Mealling, M., Masinter, L., Hardie, T., and G. Klyne, "An
IETF URN Sub-namespace for Registered Protocol
Parameters", <a href="https://www.rfc-editor.org/bcp/bcp73">BCP 73</a>, <a href="./rfc3553">RFC 3553</a>, DOI 10.17487/RFC3553,
June 2003, <<a href="http://www.rfc-editor.org/info/rfc3553">http://www.rfc-editor.org/info/rfc3553</a>>.
[<a id="ref-RFC3688">RFC3688</a>] Mealling, M., "The IETF XML Registry", <a href="https://www.rfc-editor.org/bcp/bcp81">BCP 81</a>, <a href="./rfc3688">RFC 3688</a>,
DOI 10.17487/RFC3688, January 2004,
<<a href="http://www.rfc-editor.org/info/rfc3688">http://www.rfc-editor.org/info/rfc3688</a>>.
<span class="grey">Bierman, et al. Standards Track [Page 100]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-101" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
[<a id="ref-RFC3986">RFC3986</a>] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform
Resource Identifier (URI): Generic Syntax", STD 66,
<a href="./rfc3986">RFC 3986</a>, DOI 10.17487/RFC3986, January 2005,
<<a href="http://www.rfc-editor.org/info/rfc3986">http://www.rfc-editor.org/info/rfc3986</a>>.
[<a id="ref-RFC5234">RFC5234</a>] Crocker, D., Ed., and P. Overell, "Augmented BNF for
Syntax Specifications: ABNF", STD 68, <a href="./rfc5234">RFC 5234</a>,
DOI 10.17487/RFC5234, January 2008,
<<a href="http://www.rfc-editor.org/info/rfc5234">http://www.rfc-editor.org/info/rfc5234</a>>.
[<a id="ref-RFC5246">RFC5246</a>] Dierks, T. and E. Rescorla, "The Transport Layer Security
(TLS) Protocol Version 1.2", <a href="./rfc5246">RFC 5246</a>,
DOI 10.17487/RFC5246, August 2008,
<<a href="http://www.rfc-editor.org/info/rfc5246">http://www.rfc-editor.org/info/rfc5246</a>>.
[<a id="ref-RFC5277">RFC5277</a>] Chisholm, S. and H. Trevino, "NETCONF Event
Notifications", <a href="./rfc5277">RFC 5277</a>, DOI 10.17487/RFC5277, July 2008,
<<a href="http://www.rfc-editor.org/info/rfc5277">http://www.rfc-editor.org/info/rfc5277</a>>.
[<a id="ref-RFC5280">RFC5280</a>] Cooper, D., Santesson, S., Farrell, S., Boeyen, S.,
Housley, R., and W. Polk, "Internet X.509 Public Key
Infrastructure Certificate and Certificate Revocation List
(CRL) Profile", <a href="./rfc5280">RFC 5280</a>, DOI 10.17487/RFC5280, May 2008,
<<a href="http://www.rfc-editor.org/info/rfc5280">http://www.rfc-editor.org/info/rfc5280</a>>.
[<a id="ref-RFC5789">RFC5789</a>] Dusseault, L. and J. Snell, "PATCH Method for HTTP",
<a href="./rfc5789">RFC 5789</a>, DOI 10.17487/RFC5789, March 2010,
<<a href="http://www.rfc-editor.org/info/rfc5789">http://www.rfc-editor.org/info/rfc5789</a>>.
[<a id="ref-RFC5988">RFC5988</a>] Nottingham, M., "Web Linking", <a href="./rfc5988">RFC 5988</a>,
DOI 10.17487/RFC5988, October 2010,
<<a href="http://www.rfc-editor.org/info/rfc5988">http://www.rfc-editor.org/info/rfc5988</a>>.
[<a id="ref-RFC6020">RFC6020</a>] Bjorklund, M., Ed., "YANG - A Data Modeling Language for
the Network Configuration Protocol (NETCONF)", <a href="./rfc6020">RFC 6020</a>,
DOI 10.17487/RFC6020, October 2010,
<<a href="http://www.rfc-editor.org/info/rfc6020">http://www.rfc-editor.org/info/rfc6020</a>>.
[<a id="ref-RFC6241">RFC6241</a>] Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed.,
and A. Bierman, Ed., "Network Configuration Protocol
(NETCONF)", <a href="./rfc6241">RFC 6241</a>, DOI 10.17487/RFC6241, June 2011,
<<a href="http://www.rfc-editor.org/info/rfc6241">http://www.rfc-editor.org/info/rfc6241</a>>.
[<a id="ref-RFC6242">RFC6242</a>] Wasserman, M., "Using the NETCONF Protocol over Secure
Shell (SSH)", <a href="./rfc6242">RFC 6242</a>, DOI 10.17487/RFC6242, June 2011,
<<a href="http://www.rfc-editor.org/info/rfc6242">http://www.rfc-editor.org/info/rfc6242</a>>.
<span class="grey">Bierman, et al. Standards Track [Page 101]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-102" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
[<a id="ref-RFC6243">RFC6243</a>] Bierman, A. and B. Lengyel, "With-defaults Capability for
NETCONF", <a href="./rfc6243">RFC 6243</a>, DOI 10.17487/RFC6243, June 2011,
<<a href="http://www.rfc-editor.org/info/rfc6243">http://www.rfc-editor.org/info/rfc6243</a>>.
[<a id="ref-RFC6415">RFC6415</a>] Hammer-Lahav, E., Ed., and B. Cook, "Web Host Metadata",
<a href="./rfc6415">RFC 6415</a>, DOI 10.17487/RFC6415, October 2011,
<<a href="http://www.rfc-editor.org/info/rfc6415">http://www.rfc-editor.org/info/rfc6415</a>>.
[<a id="ref-RFC6536">RFC6536</a>] Bierman, A. and M. Bjorklund, "Network Configuration
Protocol (NETCONF) Access Control Model", <a href="./rfc6536">RFC 6536</a>,
DOI 10.17487/RFC6536, March 2012,
<<a href="http://www.rfc-editor.org/info/rfc6536">http://www.rfc-editor.org/info/rfc6536</a>>.
[<a id="ref-RFC6570">RFC6570</a>] Gregorio, J., Fielding, R., Hadley, M., Nottingham, M.,
and D. Orchard, "URI Template", <a href="./rfc6570">RFC 6570</a>,
DOI 10.17487/RFC6570, March 2012,
<<a href="http://www.rfc-editor.org/info/rfc6570">http://www.rfc-editor.org/info/rfc6570</a>>.
[<a id="ref-RFC6991">RFC6991</a>] Schoenwaelder, J., Ed., "Common YANG Data Types",
<a href="./rfc6991">RFC 6991</a>, DOI 10.17487/RFC6991, July 2013,
<<a href="http://www.rfc-editor.org/info/rfc6991">http://www.rfc-editor.org/info/rfc6991</a>>.
[<a id="ref-RFC7159">RFC7159</a>] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data
Interchange Format", <a href="./rfc7159">RFC 7159</a>, DOI 10.17487/RFC7159,
March 2014, <<a href="http://www.rfc-editor.org/info/rfc7159">http://www.rfc-editor.org/info/rfc7159</a>>.
[<a id="ref-RFC7230">RFC7230</a>] Fielding, R., Ed., and J. Reschke, Ed., "Hypertext
Transfer Protocol (HTTP/1.1): Message Syntax and Routing",
<a href="./rfc7230">RFC 7230</a>, DOI 10.17487/RFC7230, June 2014,
<<a href="http://www.rfc-editor.org/info/rfc7230">http://www.rfc-editor.org/info/rfc7230</a>>.
[<a id="ref-RFC7231">RFC7231</a>] Fielding, R., Ed., and J. Reschke, Ed., "Hypertext
Transfer Protocol (HTTP/1.1): Semantics and Content",
<a href="./rfc7231">RFC 7231</a>, DOI 10.17487/RFC7231, June 2014,
<<a href="http://www.rfc-editor.org/info/rfc7231">http://www.rfc-editor.org/info/rfc7231</a>>.
[<a id="ref-RFC7232">RFC7232</a>] Fielding, R., Ed., and J. Reschke, Ed., "Hypertext
Transfer Protocol (HTTP/1.1): Conditional Requests",
<a href="./rfc7232">RFC 7232</a>, DOI 10.17487/RFC7232, June 2014,
<<a href="http://www.rfc-editor.org/info/rfc7232">http://www.rfc-editor.org/info/rfc7232</a>>.
[<a id="ref-RFC7235">RFC7235</a>] Fielding, R., Ed., and J. Reschke, Ed., "Hypertext
Transfer Protocol (HTTP/1.1): Authentication", <a href="./rfc7235">RFC 7235</a>,
DOI 10.17487/RFC7235, June 2014,
<<a href="http://www.rfc-editor.org/info/rfc7235">http://www.rfc-editor.org/info/rfc7235</a>>.
<span class="grey">Bierman, et al. Standards Track [Page 102]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-103" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
[<a id="ref-RFC7320">RFC7320</a>] Nottingham, M., "URI Design and Ownership", <a href="https://www.rfc-editor.org/bcp/bcp190">BCP 190</a>,
<a href="./rfc7320">RFC 7320</a>, DOI 10.17487/RFC7320, July 2014,
<<a href="http://www.rfc-editor.org/info/rfc7320">http://www.rfc-editor.org/info/rfc7320</a>>.
[<a id="ref-RFC7525">RFC7525</a>] Sheffer, Y., Holz, R., and P. Saint-Andre,
"Recommendations for Secure Use of Transport Layer
Security (TLS) and Datagram Transport Layer Security
(DTLS)", <a href="https://www.rfc-editor.org/bcp/bcp195">BCP 195</a>, <a href="./rfc7525">RFC 7525</a>, DOI 10.17487/RFC7525,
May 2015, <<a href="http://www.rfc-editor.org/info/rfc7525">http://www.rfc-editor.org/info/rfc7525</a>>.
[<a id="ref-RFC7589">RFC7589</a>] Badra, M., Luchuk, A., and J. Schoenwaelder, "Using the
NETCONF Protocol over Transport Layer Security (TLS) with
Mutual X.509 Authentication", <a href="./rfc7589">RFC 7589</a>,
DOI 10.17487/RFC7589, June 2015,
<<a href="http://www.rfc-editor.org/info/rfc7589">http://www.rfc-editor.org/info/rfc7589</a>>.
[<a id="ref-RFC7895">RFC7895</a>] Bierman, A., Bjorklund, M., and K. Watsen, "YANG Module
Library", <a href="./rfc7895">RFC 7895</a>, DOI 10.17487/RFC7895, June 2016,
<<a href="http://www.rfc-editor.org/info/rfc7895">http://www.rfc-editor.org/info/rfc7895</a>>.
[<a id="ref-RFC7950">RFC7950</a>] Bjorklund, M., Ed., "The YANG 1.1 Data Modeling Language",
<a href="./rfc7950">RFC 7950</a>, DOI 10.17487/RFC7950, August 2016,
<<a href="http://www.rfc-editor.org/info/rfc7950">http://www.rfc-editor.org/info/rfc7950</a>>.
[<a id="ref-RFC7951">RFC7951</a>] Lhotka, L., "JSON Encoding of Data Modeled with YANG",
<a href="./rfc7951">RFC 7951</a>, DOI 10.17487/RFC7951, August 2016,
<<a href="http://www.rfc-editor.org/info/rfc7951">http://www.rfc-editor.org/info/rfc7951</a>>.
[<a id="ref-RFC7952">RFC7952</a>] Lhotka, L., "Defining and Using Metadata with YANG",
<a href="./rfc7952">RFC 7952</a>, DOI 10.17487/RFC7952, August 2016,
<<a href="http://www.rfc-editor.org/info/rfc7952">http://www.rfc-editor.org/info/rfc7952</a>>.
[<a id="ref-W3C.REC-eventsource-20150203">W3C.REC-eventsource-20150203</a>]
Hickson, I., "Server-Sent Events", World Wide Web
Consortium Recommendation REC-eventsource-20150203,
February 2015,
<<a href="http://www.w3.org/TR/2015/REC-eventsource-20150203">http://www.w3.org/TR/2015/REC-eventsource-20150203</a>>.
<span class="grey">Bierman, et al. Standards Track [Page 103]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-104" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
[<a id="ref-W3C.REC-xml-20081126">W3C.REC-xml-20081126</a>]
Bray, T., Paoli, J., Sperberg-McQueen, M., Maler, E.,
and F. Yergeau, "Extensible Markup Language (XML) 1.0
(Fifth Edition)", World Wide Web Consortium Recommendation
REC-xml-20081126, November 2008,
<<a href="http://www.w3.org/TR/2008/REC-xml-20081126">http://www.w3.org/TR/2008/REC-xml-20081126</a>>.
[<a id="ref-XPath">XPath</a>] Clark, J. and S. DeRose, "XML Path Language (XPath)
Version 1.0", World Wide Web Consortium Recommendation
REC-xpath-19991116, November 1999,
<<a href="http://www.w3.org/TR/1999/REC-xpath-19991116">http://www.w3.org/TR/1999/REC-xpath-19991116</a>>.
<span class="h3"><a class="selflink" id="section-13.2" href="#section-13.2">13.2</a>. Informative References</span>
[<a id="ref-REST-Dissertation">REST-Dissertation</a>]
Fielding, R., "Architectural Styles and the Design of
Network-based Software Architectures", 2000.
[<a id="ref-RFC2818">RFC2818</a>] Rescorla, E., "HTTP Over TLS", <a href="./rfc2818">RFC 2818</a>,
DOI 10.17487/RFC2818, May 2000,
<<a href="http://www.rfc-editor.org/info/rfc2818">http://www.rfc-editor.org/info/rfc2818</a>>.
[<a id="ref-RFC5226">RFC5226</a>] Narten, T. and H. Alvestrand, "Guidelines for Writing an
IANA Considerations Section in RFCs", <a href="https://www.rfc-editor.org/bcp/bcp26">BCP 26</a>, <a href="./rfc5226">RFC 5226</a>,
DOI 10.17487/RFC5226, May 2008,
<<a href="http://www.rfc-editor.org/info/rfc5226">http://www.rfc-editor.org/info/rfc5226</a>>.
[<a id="ref-TLS1.3">TLS1.3</a>] Rescorla, E., "The Transport Layer Security (TLS) Protocol
Version 1.3", Work in Progress, <a href="./draft-ietf-tls-tls13-18">draft-ietf-tls-tls13-18</a>,
October 2016.
[<a id="ref-YANG-Patch">YANG-Patch</a>]
Bierman, A., Bjorklund, M., and K. Watsen, "YANG Patch
Media Type", Work in Progress,
<a href="./draft-ietf-netconf-yang-patch-14">draft-ietf-netconf-yang-patch-14</a>, November 2016.
<span class="grey">Bierman, et al. Standards Track [Page 104]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-105" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h2"><a class="selflink" id="appendix-A" href="#appendix-A">Appendix A</a>. Example YANG Module</span>
The example YANG module used in this document represents a simple
media jukebox interface.
YANG tree diagram for the "example-jukebox" module:
+--rw jukebox!
+--rw library
| +--rw artist* [name]
| | +--rw name string
| | +--rw album* [name]
| | +--rw name string
| | +--rw genre? identityref
| | +--rw year? uint16
| | +--rw admin
| | | +--rw label? string
| | | +--rw catalogue-number? string
| | +--rw song* [name]
| | +--rw name string
| | +--rw location string
| | +--rw format? string
| | +--rw length? uint32
| +--ro artist-count? uint32
| +--ro album-count? uint32
| +--ro song-count? uint32
+--rw playlist* [name]
| +--rw name string
| +--rw description? string
| +--rw song* [index]
| +--rw index uint32
| +--rw id instance-identifier
+--rw player
+--rw gap? decimal64
rpcs:
+---x play
+--ro input
+--ro playlist string
+--ro song-number uint32
<span class="grey">Bierman, et al. Standards Track [Page 105]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-106" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h3"><a class="selflink" id="appendix-A.1" href="#appendix-A.1">A.1</a>. "example-jukebox" YANG Module</span>
module example-jukebox {
namespace "http://example.com/ns/example-jukebox";
prefix "jbox";
organization "Example, Inc.";
contact "support at example.com";
description "Example Jukebox Data Model Module.";
revision "2016-08-15" {
description "Initial version.";
reference "example.com document 1-4673.";
}
identity genre {
description
"Base for all genre types.";
}
// abbreviated list of genre classifications
identity alternative {
base genre;
description
"Alternative music.";
}
identity blues {
base genre;
description
"Blues music.";
}
identity country {
base genre;
description
"Country music.";
}
identity jazz {
base genre;
description
"Jazz music.";
}
identity pop {
base genre;
description
"Pop music.";
}
<span class="grey">Bierman, et al. Standards Track [Page 106]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-107" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
identity rock {
base genre;
description
"Rock music.";
}
container jukebox {
presence
"An empty container indicates that the jukebox
service is available.";
description
"Represents a 'jukebox' resource, with a library, playlists,
and a 'play' operation.";
container library {
description
"Represents the 'jukebox' library resource.";
list artist {
key name;
description
"Represents one 'artist' resource within the
'jukebox' library resource.";
leaf name {
type string {
length "1 .. max";
}
description
"The name of the artist.";
}
list album {
key name;
description
"Represents one 'album' resource within one
'artist' resource, within the jukebox library.";
leaf name {
type string {
length "1 .. max";
}
description
"The name of the album.";
}
<span class="grey">Bierman, et al. Standards Track [Page 107]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-108" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
leaf genre {
type identityref { base genre; }
description
"The genre identifying the type of music on
the album.";
}
leaf year {
type uint16 {
range "1900 .. max";
}
description
"The year the album was released.";
}
container admin {
description
"Administrative information for the album.";
leaf label {
type string;
description
"The label that released the album.";
}
leaf catalogue-number {
type string;
description
"The album's catalogue number.";
}
}
list song {
key name;
description
"Represents one 'song' resource within one
'album' resource, within the jukebox library.";
leaf name {
type string {
length "1 .. max";
}
description
"The name of the song.";
}
<span class="grey">Bierman, et al. Standards Track [Page 108]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-109" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
leaf location {
type string;
mandatory true;
description
"The file location string of the
media file for the song.";
}
leaf format {
type string;
description
"An identifier string for the media type
for the file associated with the
'location' leaf for this entry.";
}
leaf length {
type uint32;
units "seconds";
description
"The duration of this song in seconds.";
}
} // end list 'song'
} // end list 'album'
} // end list 'artist'
leaf artist-count {
type uint32;
units "artists";
config false;
description
"Number of artists in the library.";
}
leaf album-count {
type uint32;
units "albums";
config false;
description
"Number of albums in the library.";
}
leaf song-count {
type uint32;
units "songs";
config false;
description
"Number of songs in the library.";
}
} // end library
<span class="grey">Bierman, et al. Standards Track [Page 109]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-110" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
list playlist {
key name;
description
"Example configuration data resource.";
leaf name {
type string;
description
"The name of the playlist.";
}
leaf description {
type string;
description
"A comment describing the playlist.";
}
list song {
key index;
ordered-by user;
description
"Example nested configuration data resource.";
leaf index { // not really needed
type uint32;
description
"An arbitrary integer index for this playlist song.";
}
leaf id {
type instance-identifier;
mandatory true;
description
"Song identifier. Must identify an instance of
/jukebox/library/artist/album/song/name.";
}
}
}
<span class="grey">Bierman, et al. Standards Track [Page 110]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-111" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
container player {
description
"Represents the jukebox player resource.";
leaf gap {
type decimal64 {
fraction-digits 1;
range "0.0 .. 2.0";
}
units "tenths of seconds";
description
"Time gap between each song.";
}
}
}
rpc play {
description
"Control function for the jukebox player.";
input {
leaf playlist {
type string;
mandatory true;
description
"The playlist name.";
}
leaf song-number {
type uint32;
mandatory true;
description
"Song number in playlist to play.";
}
}
}
}
<span class="grey">Bierman, et al. Standards Track [Page 111]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-112" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h2"><a class="selflink" id="appendix-B" href="#appendix-B">Appendix B</a>. RESTCONF Message Examples</span>
The examples within this document use the normative YANG module
"ietf-restconf" as defined in <a href="#section-8">Section 8</a> and the non-normative example
YANG module "example-jukebox" as defined in <a href="#appendix-A.1">Appendix A.1</a>.
This section shows some typical RESTCONF message exchanges.
<span class="h3"><a class="selflink" id="appendix-B.1" href="#appendix-B.1">B.1</a>. Resource Retrieval Examples</span>
<span class="h4"><a class="selflink" id="appendix-B.1.1" href="#appendix-B.1.1">B.1.1</a>. Retrieve the Top-Level API Resource</span>
The client starts by retrieving the RESTCONF root resource:
GET /.well-known/host-meta HTTP/1.1
Host: example.com
Accept: application/xrd+xml
<span class="grey">Bierman, et al. Standards Track [Page 112]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-113" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The server might respond as follows:
HTTP/1.1 200 OK
Content-Type: application/xrd+xml
Content-Length: nnn
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>
<Link rel='restconf' href='/restconf'/>
</XRD>
The client may then retrieve the top-level API resource, using the
root resource "/restconf".
GET /restconf HTTP/1.1
Host: example.com
Accept: application/yang-data+json
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Content-Type: application/yang-data+json
{
"ietf-restconf:restconf" : {
"data" : {},
"operations" : {},
"yang-library-version" : "2016-06-21"
}
}
To request that the response content be encoded in XML, the "Accept"
header can be used, as in this example request:
GET /restconf HTTP/1.1
Host: example.com
Accept: application/yang-data+xml
<span class="grey">Bierman, et al. Standards Track [Page 113]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-114" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The server will return the same conceptual data either way, which
might be as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Cache-Control: no-cache
Content-Type: application/yang-data+xml
<restconf xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
<data/>
<operations/>
<yang-library-version>2016-06-21</yang-library-version>
</restconf>
<span class="h4"><a class="selflink" id="appendix-B.1.2" href="#appendix-B.1.2">B.1.2</a>. Retrieve the Server Module Information</span>
It is possible that the YANG library module will change over time.
The client can retrieve the revision date of the "ietf-yang-library"
module supported by the server from the API resource, as described in
the previous section.
In this example, the client is retrieving the module information from
the server in JSON format:
GET /restconf/data/ietf-yang-library:modules-state HTTP/1.1
Host: example.com
Accept: application/yang-data+json
<span class="grey">Bierman, et al. Standards Track [Page 114]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-115" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Cache-Control: no-cache
Last-Modified: Thu, 26 Jan 2017 14:00:14 GMT
Content-Type: application/yang-data+json
{
"ietf-yang-library:modules-state" : {
"module-set-id" : "5479120c17a619545ea6aff7aa19838b036ebbd7",
"module" : [
{
"name" : "foo",
"revision" : "2012-01-02",
"schema" : "https://example.com/modules/foo/2012-01-02",
"namespace" : "http://example.com/ns/foo",
"feature" : [ "feature1", "feature2" ],
"deviation" : [
{
"name" : "foo-dev",
"revision" : "2012-02-16"
}
],
"conformance-type" : "implement"
},
{
"name" : "ietf-yang-library",
"revision" : "2016-06-21",
"schema" : "https://example.com/modules/\
ietf-yang-library/2016-06-21",
"namespace" :
"urn:ietf:params:xml:ns:yang:ietf-yang-library",
"conformance-type" : "implement"
},
{
"name" : "foo-types",
"revision" : "2012-01-05",
"schema" :
"https://example.com/modules/foo-types/2012-01-05",
"namespace" : "http://example.com/ns/foo-types",
"conformance-type" : "import"
},
<span class="grey">Bierman, et al. Standards Track [Page 115]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-116" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
{
"name" : "bar",
"revision" : "2012-11-05",
"schema" : "https://example.com/modules/bar/2012-11-05",
"namespace" : "http://example.com/ns/bar",
"feature" : [ "bar-ext" ],
"conformance-type" : "implement",
"submodule" : [
{
"name" : "bar-submod1",
"revision" : "2012-11-05",
"schema" :
"https://example.com/modules/bar-submod1/2012-11-05"
},
{
"name" : "bar-submod2",
"revision" : "2012-11-05",
"schema" :
"https://example.com/modules/bar-submod2/2012-11-05"
}
]
}
]
}
}
<span class="grey">Bierman, et al. Standards Track [Page 116]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-117" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h4"><a class="selflink" id="appendix-B.1.3" href="#appendix-B.1.3">B.1.3</a>. Retrieve the Server Capability Information</span>
In this example, the client is retrieving the capability information
from the server in XML format, and the server supports all of the
RESTCONF query parameters, plus one vendor parameter:
GET /restconf/data/ietf-restconf-monitoring:restconf-state/\
capabilities HTTP/1.1
Host: example.com
Accept: application/yang-data+xml
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Cache-Control: no-cache
Last-Modified: Thu, 26 Jan 2017 16:00:14 GMT
Content-Type: application/yang-data+xml
<capabilities
xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring">
<capability>\
urn:ietf:params:restconf:capability:defaults:1.0?\
basic-mode=explicit\
</capability>
<capability>\
urn:ietf:params:restconf:capability:with-defaults:1.0\
</capability>
<capability>\
urn:ietf:params:restconf:capability:depth:1.0\
</capability>
<capability>\
urn:ietf:params:restconf:capability:fields:1.0\
</capability>
<capability>\
urn:ietf:params:restconf:capability:filter:1.0\
</capability>
<capability>\
urn:ietf:params:restconf:capability:start-time:1.0\
</capability>
<capability>\
urn:ietf:params:restconf:capability:stop-time:1.0\
</capability>
<capability>\
http://example.com/capabilities/myparam\
</capability>
</capabilities>
<span class="grey">Bierman, et al. Standards Track [Page 117]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-118" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h3"><a class="selflink" id="appendix-B.2" href="#appendix-B.2">B.2</a>. Data Resource and Datastore Resource Examples</span>
<span class="h4"><a class="selflink" id="appendix-B.2.1" href="#appendix-B.2.1">B.2.1</a>. Create New Data Resources</span>
To create a new "artist" resource within the "library" resource, the
client might send the following request:
POST /restconf/data/example-jukebox:jukebox/library HTTP/1.1
Host: example.com
Content-Type: application/yang-data+json
{
"example-jukebox:artist" : [
{
"name" : "Foo Fighters"
}
]
}
If the resource is created, the server might respond as follows:
HTTP/1.1 201 Created
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Location: https://example.com/restconf/data/\
example-jukebox:jukebox/library/artist=Foo%20Fighters
Last-Modified: Thu, 26 Jan 2017 20:56:30 GMT
ETag: "b3830f23a4c"
<span class="grey">Bierman, et al. Standards Track [Page 118]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-119" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
To create a new "album" resource for this artist within the "jukebox"
resource, the client might send the following request:
POST /restconf/data/example-jukebox:jukebox/\
library/artist=Foo%20Fighters HTTP/1.1
Host: example.com
Content-Type: application/yang-data+xml
<album xmlns="http://example.com/ns/example-jukebox">
<name>Wasting Light</name>
<year>2011</year>
</album>
If the resource is created, the server might respond as follows:
HTTP/1.1 201 Created
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Location: https://example.com/restconf/data/\
example-jukebox:jukebox/library/artist=Foo%20Fighters/\
album=Wasting%20Light
Last-Modified: Thu, 26 Jan 2017 20:56:30 GMT
ETag: "b8389233a4c"
<span class="h4"><a class="selflink" id="appendix-B.2.2" href="#appendix-B.2.2">B.2.2</a>. Detect Datastore Resource Entity-Tag Change</span>
In this example, the server just supports the datastore last-changed
timestamp. Assume that the client has cached the "Last-Modified"
header from the response to the previous request. This value is used
as in the "If-Unmodified-Since" header in the following request to
patch an "album" list entry with a key value of "Wasting Light".
Only the "genre" field is being updated.
PATCH /restconf/data/example-jukebox:jukebox/\
library/artist=Foo%20Fighters/album=Wasting%20Light/\
genre HTTP/1.1
Host: example.com
If-Unmodified-Since: Thu, 26 Jan 2017 20:56:30 GMT
Content-Type: application/yang-data+json
{ "example-jukebox:genre" : "example-jukebox:alternative" }
<span class="grey">Bierman, et al. Standards Track [Page 119]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-120" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
In this example, the datastore resource has changed since the time
specified in the "If-Unmodified-Since" header. The server might
respond as follows:
HTTP/1.1 412 Precondition Failed
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Last-Modified: Thu, 26 Jan 2017 19:41:00 GMT
ETag: "b34aed893a4c"
<span class="grey">Bierman, et al. Standards Track [Page 120]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-121" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h4"><a class="selflink" id="appendix-B.2.3" href="#appendix-B.2.3">B.2.3</a>. Edit a Datastore Resource</span>
In this example, assume that there is a top-level data resource named
"system" from the example-system module, and this container has a
child leaf called "enable-jukebox-streaming":
container system {
leaf enable-jukebox-streaming {
type boolean;
}
}
In this example, PATCH is used by the client to modify two top-level
resources at once, in order to enable jukebox streaming and add an
"album" sub-resource to each of two "artist" resources:
PATCH /restconf/data HTTP/1.1
Host: example.com
Content-Type: application/yang-data+xml
<data xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
<system xmlns="http://example.com/ns/example-system">
<enable-jukebox-streaming>true</enable-jukebox-streaming>
</system>
<jukebox xmlns="http://example.com/ns/example-jukebox">
<library>
<artist>
<name>Foo Fighters</name>
<album>
<name>One by One</name>
<year>2012</year>
</album>
</artist>
<artist>
<name>Nick Cave and the Bad Seeds</name>
<album>
<name>Tender Prey</name>
<year>1988</year>
</album>
</artist>
</library>
</jukebox>
</data>
<span class="grey">Bierman, et al. Standards Track [Page 121]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-122" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h4"><a class="selflink" id="appendix-B.2.4" href="#appendix-B.2.4">B.2.4</a>. Replace a Datastore Resource</span>
In this example, the entire configuration datastore contents are
being replaced. Any child nodes not present in the <data> element
but present in the server will be deleted.
PUT /restconf/data HTTP/1.1
Host: example.com
Content-Type: application/yang-data+xml
<data xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
<jukebox xmlns="http://example.com/ns/example-jukebox">
<library>
<artist>
<name>Foo Fighters</name>
<album>
<name>One by One</name>
<year>2012</year>
</album>
</artist>
<artist>
<name>Nick Cave and the Bad Seeds</name>
<album>
<name>Tender Prey</name>
<year>1988</year>
</album>
</artist>
</library>
</jukebox>
</data>
<span class="h4"><a class="selflink" id="appendix-B.2.5" href="#appendix-B.2.5">B.2.5</a>. Edit a Data Resource</span>
In this example, the client modifies one data node by adding an
"album" sub-resource by sending a PATCH for the data resource:
PATCH /restconf/data/example-jukebox:jukebox/library/\
artist=Nick%20Cave%20and%20the%20Bad%20Seeds HTTP/1.1
Host: example.com
Content-Type: application/yang-data+xml
<artist xmlns="http://example.com/ns/example-jukebox">
<name>Nick Cave and the Bad Seeds</name>
<album>
<name>The Good Son</name>
<year>1990</year>
</album>
</artist>
<span class="grey">Bierman, et al. Standards Track [Page 122]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-123" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h3"><a class="selflink" id="appendix-B.3" href="#appendix-B.3">B.3</a>. Query Parameter Examples</span>
<span class="h4"><a class="selflink" id="appendix-B.3.1" href="#appendix-B.3.1">B.3.1</a>. "content" Parameter</span>
The "content" parameter is used to select the types of data child
resources (configuration and/or non-configuration) that are returned
by the server for a GET method request.
In this example, a simple YANG list is used that has configuration
and non-configuration child resources.
container events {
list event {
key name;
leaf name { type string; }
leaf description { type string; }
leaf event-count {
type uint32;
config false;
}
}
}
<span class="grey">Bierman, et al. Standards Track [Page 123]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-124" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
Example 1: content=all
To retrieve all of the child resources, the "content" parameter is
set to "all", or omitted, since this is the default value. The
client might send the following:
GET /restconf/data/example-events:events?\
content=all HTTP/1.1
Host: example.com
Accept: application/yang-data+json
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Cache-Control: no-cache
Content-Type: application/yang-data+json
{
"example-events:events" : {
"event" : [
{
"name" : "interface-up",
"description" : "Interface up notification count",
"event-count" : 42
},
{
"name" : "interface-down",
"description" : "Interface down notification count",
"event-count" : 4
}
]
}
}
<span class="grey">Bierman, et al. Standards Track [Page 124]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-125" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
Example 2: content=config
To retrieve only the configuration child resources, the "content"
parameter is set to "config". Note that the "ETag" and
"Last-Modified" headers are only returned if the "content" parameter
value is "config".
GET /restconf/data/example-events:events?\
content=config HTTP/1.1
Host: example.com
Accept: application/yang-data+json
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Last-Modified: Thu, 26 Jan 2017 16:45:20 GMT
ETag: "eeeada438af"
Cache-Control: no-cache
Content-Type: application/yang-data+json
{
"example-events:events" : {
"event" : [
{
"name" : "interface-up",
"description" : "Interface up notification count"
},
{
"name" : "interface-down",
"description" : "Interface down notification count"
}
]
}
}
<span class="grey">Bierman, et al. Standards Track [Page 125]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-126" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
Example 3: content=nonconfig
To retrieve only the non-configuration child resources, the "content"
parameter is set to "nonconfig". Note that configuration ancestors
(if any) and list key leafs (if any) are also returned. The client
might send the following:
GET /restconf/data/example-events:events?\
content=nonconfig HTTP/1.1
Host: example.com
Accept: application/yang-data+json
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Cache-Control: no-cache
Content-Type: application/yang-data+json
{
"example-events:events" : {
"event" : [
{
"name" : "interface-up",
"event-count" : 42
},
{
"name" : "interface-down",
"event-count" : 4
}
]
}
}
<span class="h4"><a class="selflink" id="appendix-B.3.2" href="#appendix-B.3.2">B.3.2</a>. "depth" Parameter</span>
The "depth" parameter is used to limit the number of levels of child
resources that are returned by the server for a GET method request.
The "depth" parameter starts counting levels at the level of the
target resource that is specified, so that a depth level of "1"
includes just the target resource level itself. A depth level of "2"
includes the target resource level and its child nodes.
<span class="grey">Bierman, et al. Standards Track [Page 126]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-127" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
This example shows how different values of the "depth" parameter
would affect the reply content for the retrieval of the top-level
"jukebox" data resource.
Example 1: depth=unbounded
To retrieve all of the child resources, the "depth" parameter is not
present or is set to the default value "unbounded".
GET /restconf/data/example-jukebox:jukebox?\
depth=unbounded HTTP/1.1
Host: example.com
Accept: application/yang-data+json
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Cache-Control: no-cache
Content-Type: application/yang-data+json
{
"example-jukebox:jukebox" : {
"library" : {
"artist" : [
{
"name" : "Foo Fighters",
"album" : [
{
"name" : "Wasting Light",
"genre" : "example-jukebox:alternative",
"year" : 2011,
"song" : [
{
"name" : "Wasting Light",
"location" :
"/media/foo/a7/wasting-light.mp3",
"format" : "MP3",
"length" : 286
},
<span class="grey">Bierman, et al. Standards Track [Page 127]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-128" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
{
"name" : "Rope",
"location" : "/media/foo/a7/rope.mp3",
"format" : "MP3",
"length" : 259
}
]
}
]
}
]
},
"playlist" : [
{
"name" : "Foo-One",
"description" : "example playlist 1",
"song" : [
{
"index" : 1,
"id" : "/example-jukebox:jukebox/library\
/artist[name='Foo Fighters']\
/album[name='Wasting Light']\
/song[name='Rope']"
},
{
"index" : 2,
"id" : "/example-jukebox:jukebox/library\
/artist[name='Foo Fighters']\
/album[name='Wasting Light']\
/song[name='Bridge Burning']"
}
]
}
],
"player" : {
"gap" : 0.5
}
}
}
<span class="grey">Bierman, et al. Standards Track [Page 128]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-129" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
Example 2: depth=1
To determine if one or more resource instances exist for a given
target resource, the value "1" is used.
GET /restconf/data/example-jukebox:jukebox?depth=1 HTTP/1.1
Host: example.com
Accept: application/yang-data+json
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Cache-Control: no-cache
Content-Type: application/yang-data+json
{
"example-jukebox:jukebox" : {}
}
<span class="grey">Bierman, et al. Standards Track [Page 129]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-130" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
Example 3: depth=3
To limit the depth level to the target resource plus two child
resource layers, the value "3" is used.
GET /restconf/data/example-jukebox:jukebox?depth=3 HTTP/1.1
Host: example.com
Accept: application/yang-data+json
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Cache-Control: no-cache
Content-Type: application/yang-data+json
{
"example-jukebox:jukebox" : {
"library" : {
"artist" : {}
},
"playlist" : [
{
"name" : "Foo-One",
"description" : "example playlist 1",
"song" : {}
}
],
"player" : {
"gap" : 0.5
}
}
}
<span class="h4"><a class="selflink" id="appendix-B.3.3" href="#appendix-B.3.3">B.3.3</a>. "fields" Parameter</span>
In this example, the client is retrieving the datastore resource in
JSON format, but retrieving only the "modules-state/module" list, and
only the "name" and "revision" nodes from each list entry. Note that
the top node returned by the server matches the target resource node
(which is "data" in this example). The "module-set-id" leaf is not
returned because it is not selected in the fields expression.
<span class="grey">Bierman, et al. Standards Track [Page 130]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-131" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
GET /restconf/data?fields=ietf-yang-library:modules-state/\
module(name;revision) HTTP/1.1
Host: example.com
Accept: application/yang-data+json
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Content-Type: application/yang-data+json
{
"ietf-restconf:data" : {
"ietf-yang-library:modules-state" : {
"module" : [
{
"name" : "example-jukebox",
"revision" : "2016-08-15"
},
{
"name" : "ietf-inet-types",
"revision" : "2013-07-15"
},
{
"name" : "ietf-restconf-monitoring",
"revision" : "2017-01-26"
},
{
"name" : "ietf-yang-library",
"revision" : "2016-06-21"
},
{
"name" : "ietf-yang-types",
"revision" : "2013-07-15"
}
]
}
}
}
<span class="grey">Bierman, et al. Standards Track [Page 131]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-132" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h4"><a class="selflink" id="appendix-B.3.4" href="#appendix-B.3.4">B.3.4</a>. "insert" Parameter</span>
In this example, a new first song entry in the "Foo-One" playlist is
being created.
Request from client:
POST /restconf/data/example-jukebox:jukebox/\
playlist=Foo-One?insert=first HTTP/1.1
Host: example.com
Content-Type: application/yang-data+json
{
"example-jukebox:song" : [
{
"index" : 1,
"id" : "/example-jukebox:jukebox/library\
/artist[name='Foo Fighters']\
/album[name='Wasting Light']\
/song[name='Rope']"
}
]
}
Response from server:
HTTP/1.1 201 Created
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Last-Modified: Thu, 26 Jan 2017 20:56:30 GMT
Location: https://example.com/restconf/data/\
example-jukebox:jukebox/playlist=Foo-One/song=1
ETag: "eeeada438af"
<span class="grey">Bierman, et al. Standards Track [Page 132]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-133" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h4"><a class="selflink" id="appendix-B.3.5" href="#appendix-B.3.5">B.3.5</a>. "point" Parameter</span>
In this example, the client is inserting a new song entry in the
"Foo-One" playlist after the first song.
Request from client:
POST /restconf/data/example-jukebox:jukebox/\
playlist=Foo-One?insert=after&point=\
%2Fexample-jukebox%3Ajukebox\
%2Fplaylist%3DFoo-One%2Fsong%3D1 HTTP/1.1
Host: example.com
Content-Type: application/yang-data+json
{
"example-jukebox:song" : [
{
"index" : 2,
"id" : "/example-jukebox:jukebox/library\
/artist[name='Foo Fighters']\
/album[name='Wasting Light']\
/song[name='Bridge Burning']"
}
]
}
Response from server:
HTTP/1.1 201 Created
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Last-Modified: Thu, 26 Jan 2017 20:56:30 GMT
Location: https://example.com/restconf/data/\
example-jukebox:jukebox/playlist=Foo-One/song=2
ETag: "abcada438af"
<span class="grey">Bierman, et al. Standards Track [Page 133]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-134" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h4"><a class="selflink" id="appendix-B.3.6" href="#appendix-B.3.6">B.3.6</a>. "filter" Parameter</span>
The following URIs show some examples of notification filter
specifications:
// filter = /event/event-class='fault'
GET /streams/NETCONF?filter=%2Fevent%2Fevent-class%3D'fault'
// filter = /event/severity<=4
GET /streams/NETCONF?filter=%2Fevent%2Fseverity%3C%3D4
// filter = /linkUp|/linkDown
GET /streams/SNMP?filter=%2FlinkUp%7C%2FlinkDown
// filter = /*/reporting-entity/card!='Ethernet0'
GET /streams/NETCONF?\
filter=%2F*%2Freporting-entity%2Fcard%21%3D'Ethernet0'
// filter = /*/email-addr[contains(.,'company.com')]
GET /streams/critical-syslog?\
filter=%2F*%2Femail-addr[contains(.%2C'company.com')]
// Note: The module name is used as the prefix.
// filter = (/example-mod:event1/name='joe' and
// /example-mod:event1/status='online')
GET /streams/NETCONF?\
filter=(%2Fexample-mod%3Aevent1%2Fname%3D'joe'%20and\
%20%2Fexample-mod%3Aevent1%2Fstatus%3D'online')
// To get notifications from just two modules (e.g., m1 + m2)
// filter=(/m1:* or /m2:*)
GET /streams/NETCONF?filter=(%2Fm1%3A*%20or%20%2Fm2%3A*)
<span class="h4"><a class="selflink" id="appendix-B.3.7" href="#appendix-B.3.7">B.3.7</a>. "start-time" Parameter</span>
The following URI shows an example of the "start-time" query
parameter:
// start-time = 2014-10-25T10:02:00Z
GET /streams/NETCONF?start-time=2014-10-25T10%3A02%3A00Z
<span class="grey">Bierman, et al. Standards Track [Page 134]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-135" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
<span class="h4"><a class="selflink" id="appendix-B.3.8" href="#appendix-B.3.8">B.3.8</a>. "stop-time" Parameter</span>
The following URI shows an example of the "stop-time" query
parameter:
// start-time = 2014-10-25T10:02:00Z
// stop-time = 2014-10-25T12:31:00Z
GET /mystreams/NETCONF?start-time=2014-10-25T10%3A02%3A00Z\
&stop-time=2014-10-25T12%3A31%3A00Z
<span class="h4"><a class="selflink" id="appendix-B.3.9" href="#appendix-B.3.9">B.3.9</a>. "with-defaults" Parameter</span>
Assume that the server implements the module "example" defined in
<a href="./rfc6243#appendix-A.1">Appendix A.1 of [RFC6243]</a>, and assume that the server's datastore is
as defined in <a href="./rfc6243#appendix-A.2">Appendix A.2 of [RFC6243]</a>.
If the server's "basic-mode" parameter in the "defaults" protocol
capability URI (<a href="#section-9.1.2">Section 9.1.2</a>) is "trim", the following request for
interface "eth1" might be as follows:
Without query parameter:
GET /restconf/data/example:interfaces/interface=eth1 HTTP/1.1
Host: example.com
Accept: application/yang-data+json
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Content-Type: application/yang-data+json
{
"example:interface" : [
{
"name" : "eth1",
"status" : "up"
}
]
}
Note that the "mtu" leaf is missing because it is set to the default
"1500", and the server's default-handling "basic-mode" parameter is
"trim".
<span class="grey">Bierman, et al. Standards Track [Page 135]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-136" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
With query parameter:
GET /restconf/data/example:interfaces/interface=eth1\
?with-defaults=report-all HTTP/1.1
Host: example.com
Accept: application/yang-data+json
The server might respond as follows:
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Content-Type: application/yang-data+json
{
"example:interface" : [
{
"name" : "eth1",
"mtu" : 1500,
"status" : "up"
}
]
}
Note that the server returns the "mtu" leaf because the "report-all"
mode was requested with the "with-defaults" query parameter.
<span class="grey">Bierman, et al. Standards Track [Page 136]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-137" ></span>
<span class="grey"><a href="./rfc8040">RFC 8040</a> RESTCONF January 2017</span>
Acknowledgements
The authors would like to thank the following people for their
contributions to this document: Ladislav Lhotka, Juergen
Schoenwaelder, Rex Fernando, Robert Wilton, and Jonathan Hansford.
The authors would like to thank the following people for their
excellent technical reviews of this document: Mehmet Ersue, Mahesh
Jethanandani, Qin Wu, Joe Clarke, Bert Wijnen, Ladislav Lhotka,
Rodney Cummings, Frank Xialiang, Tom Petch, Robert Sparks, Balint
Uveges, Randy Presuhn, Sue Hares, Mark Nottingham, Benoit Claise,
Dale Worley, and Lionel Morand.
Contributions to this material by Andy Bierman are based upon work
supported by the United States Army, Space & Terrestrial
Communications Directorate (S&TCD) under Contract
No. W15P7T-13-C-A616. Any opinions, findings, and conclusions or
recommendations expressed in this material are those of the author(s)
and do not necessarily reflect the views of the S&TCD.
Authors' Addresses
Andy Bierman
YumaWorks
Email: andy@yumaworks.com
Martin Bjorklund
Tail-f Systems
Email: mbj@tail-f.com
Kent Watsen
Juniper Networks
Email: kwatsen@juniper.net
Bierman, et al. Standards Track [Page 137]
</pre>
|