idnits 2.17.1 draft-ietf-netconf-restconf-07.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Line 1922 has weird spacing: '... method entry...' == Line 2795 has weird spacing: '...ncoding strin...' == Line 2796 has weird spacing: '...ocation inet:...' == Line 3671 has weird spacing: '...ocation str...' == Line 3681 has weird spacing: '...w index uin...' == (1 more instance...) == The document seems to lack the recommended RFC 2119 boilerplate, even if it appears to use RFC 2119 keywords. (The document does seem to have the reference to RFC 2119 which the ID-Checklist requires). -- The document date (July 6, 2015) is 3214 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Outdated reference: A later version (-06) exists of draft-ietf-netconf-yang-library-01 == Outdated reference: A later version (-10) exists of draft-ietf-netmod-yang-json-04 == Outdated reference: A later version (-07) exists of draft-ietf-netmod-yang-metadata-01 ** Obsolete normative reference: RFC 2396 (Obsoleted by RFC 3986) ** Obsolete normative reference: RFC 2818 (Obsoleted by RFC 9110) ** Obsolete normative reference: RFC 5246 (Obsoleted by RFC 8446) ** Obsolete normative reference: RFC 5988 (Obsoleted by RFC 8288) ** Obsolete normative reference: RFC 6125 (Obsoleted by RFC 9525) ** Obsolete normative reference: RFC 6536 (Obsoleted by RFC 8341) ** Obsolete normative reference: RFC 7158 (Obsoleted by RFC 7159) ** Obsolete normative reference: RFC 7230 (Obsoleted by RFC 9110, RFC 9112) ** Obsolete normative reference: RFC 7231 (Obsoleted by RFC 9110) ** Obsolete normative reference: RFC 7232 (Obsoleted by RFC 9110) ** Obsolete normative reference: RFC 7235 (Obsoleted by RFC 9110) ** Obsolete normative reference: RFC 7320 (Obsoleted by RFC 8820) -- Possible downref: Non-RFC (?) normative reference: ref. 'XPath' == Outdated reference: A later version (-14) exists of draft-ietf-netconf-yang-patch-05 Summary: 12 errors (**), 0 flaws (~~), 12 warnings (==), 3 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group A. Bierman 3 Internet-Draft YumaWorks 4 Intended status: Standards Track M. Bjorklund 5 Expires: January 7, 2016 Tail-f Systems 6 K. Watsen 7 Juniper Networks 8 July 6, 2015 10 RESTCONF Protocol 11 draft-ietf-netconf-restconf-07 13 Abstract 15 This document describes an HTTP-based protocol that provides a 16 programmatic interface for accessing data defined in YANG, using the 17 datastores defined in NETCONF. 19 Status of This Memo 21 This Internet-Draft is submitted in full conformance with the 22 provisions of BCP 78 and BCP 79. 24 Internet-Drafts are working documents of the Internet Engineering 25 Task Force (IETF). Note that other groups may also distribute 26 working documents as Internet-Drafts. The list of current Internet- 27 Drafts is at http://datatracker.ietf.org/drafts/current/. 29 Internet-Drafts are draft documents valid for a maximum of six months 30 and may be updated, replaced, or obsoleted by other documents at any 31 time. It is inappropriate to use Internet-Drafts as reference 32 material or to cite them other than as "work in progress." 34 This Internet-Draft will expire on January 7, 2016. 36 Copyright Notice 38 Copyright (c) 2015 IETF Trust and the persons identified as the 39 document authors. All rights reserved. 41 This document is subject to BCP 78 and the IETF Trust's Legal 42 Provisions Relating to IETF Documents 43 (http://trustee.ietf.org/license-info) in effect on the date of 44 publication of this document. Please review these documents 45 carefully, as they describe your rights and restrictions with respect 46 to this document. Code Components extracted from this document must 47 include Simplified BSD License text as described in Section 4.e of 48 the Trust Legal Provisions and are provided without warranty as 49 described in the Simplified BSD License. 51 Table of Contents 53 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 54 1.1. Simple Subset of NETCONF Functionality . . . . . . . . . 5 55 1.2. Data Model Driven API . . . . . . . . . . . . . . . . . . 6 56 1.3. Coexistence with NETCONF . . . . . . . . . . . . . . . . 7 57 1.4. Terminology . . . . . . . . . . . . . . . . . . . . . . . 8 58 1.4.1. NETCONF . . . . . . . . . . . . . . . . . . . . . . . 8 59 1.4.2. HTTP . . . . . . . . . . . . . . . . . . . . . . . . 8 60 1.4.3. YANG . . . . . . . . . . . . . . . . . . . . . . . . 9 61 1.4.4. Terms . . . . . . . . . . . . . . . . . . . . . . . . 10 62 1.4.5. URI Template . . . . . . . . . . . . . . . . . . . . 11 63 1.4.6. Tree Diagrams . . . . . . . . . . . . . . . . . . . . 11 64 2. Transport Protocol Requirements . . . . . . . . . . . . . . . 12 65 2.1. Integrity and Confidentiality . . . . . . . . . . . . . . 12 66 2.2. HTTPS with X.509v3 Certificates . . . . . . . . . . . . . 12 67 2.3. Certificate Validation . . . . . . . . . . . . . . . . . 12 68 2.4. Authenticated Server Identity . . . . . . . . . . . . . . 12 69 2.5. Authenticated Client Identity . . . . . . . . . . . . . . 12 70 3. Resources . . . . . . . . . . . . . . . . . . . . . . . . . . 13 71 3.1. Root Resource Discovery . . . . . . . . . . . . . . . . . 14 72 3.2. RESTCONF Resource Types . . . . . . . . . . . . . . . . . 15 73 3.3. API Resource . . . . . . . . . . . . . . . . . . . . . . 15 74 3.3.1. {+restconf}/data . . . . . . . . . . . . . . . . . . 16 75 3.3.2. {+restconf}/operations . . . . . . . . . . . . . . . 17 76 3.4. Datastore Resource . . . . . . . . . . . . . . . . . . . 17 77 3.4.1. Edit Collision Detection . . . . . . . . . . . . . . 18 78 3.5. Data Resource . . . . . . . . . . . . . . . . . . . . . . 18 79 3.5.1. Encoding Data Resource Identifiers in the Request URI 19 80 3.5.2. Defaults Handling . . . . . . . . . . . . . . . . . . 22 81 3.6. Operation Resource . . . . . . . . . . . . . . . . . . . 22 82 3.6.1. Encoding Operation Input Parameters . . . . . . . . . 23 83 3.6.2. Encoding Operation Output Parameters . . . . . . . . 24 84 3.6.3. Encoding Operation Errors . . . . . . . . . . . . . . 25 85 3.7. Schema Resource . . . . . . . . . . . . . . . . . . . . . 25 86 3.8. Event Stream Resource . . . . . . . . . . . . . . . . . . 26 87 3.9. Errors Media Type . . . . . . . . . . . . . . . . . . . . 27 88 4. Operations . . . . . . . . . . . . . . . . . . . . . . . . . 27 89 4.1. OPTIONS . . . . . . . . . . . . . . . . . . . . . . . . . 28 90 4.2. HEAD . . . . . . . . . . . . . . . . . . . . . . . . . . 28 91 4.3. GET . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 92 4.4. POST . . . . . . . . . . . . . . . . . . . . . . . . . . 29 93 4.4.1. Create Resource Mode . . . . . . . . . . . . . . . . 30 94 4.4.2. Invoke Operation Mode . . . . . . . . . . . . . . . . 31 95 4.5. PUT . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 96 4.6. PATCH . . . . . . . . . . . . . . . . . . . . . . . . . . 32 97 4.6.1. Plain Patch . . . . . . . . . . . . . . . . . . . . . 33 98 4.7. DELETE . . . . . . . . . . . . . . . . . . . . . . . . . 34 99 4.8. Query Parameters . . . . . . . . . . . . . . . . . . . . 34 100 4.8.1. The "content" Query Parameter . . . . . . . . . . . . 35 101 4.8.2. The "depth" Query Parameter . . . . . . . . . . . . . 36 102 4.8.3. The "fields" Query Parameter . . . . . . . . . . . . 36 103 4.8.4. The "insert" Query Parameter . . . . . . . . . . . . 37 104 4.8.5. The "point" Query Parameter . . . . . . . . . . . . . 38 105 4.8.6. The "filter" Query Parameter . . . . . . . . . . . . 38 106 4.8.7. The "start-time" Query Parameter . . . . . . . . . . 39 107 4.8.8. The "stop-time" Query Parameter . . . . . . . . . . . 40 108 4.8.9. The "with-defaults" Query Parameter . . . . . . . . . 40 109 5. Messages . . . . . . . . . . . . . . . . . . . . . . . . . . 41 110 5.1. Request URI Structure . . . . . . . . . . . . . . . . . . 41 111 5.2. Message Headers . . . . . . . . . . . . . . . . . . . . . 43 112 5.3. Message Encoding . . . . . . . . . . . . . . . . . . . . 44 113 5.4. RESTCONF Meta-Data . . . . . . . . . . . . . . . . . . . 44 114 5.5. Return Status . . . . . . . . . . . . . . . . . . . . . . 44 115 5.6. Message Caching . . . . . . . . . . . . . . . . . . . . . 45 116 6. Notifications . . . . . . . . . . . . . . . . . . . . . . . . 45 117 6.1. Server Support . . . . . . . . . . . . . . . . . . . . . 45 118 6.2. Event Streams . . . . . . . . . . . . . . . . . . . . . . 45 119 6.3. Subscribing to Receive Notifications . . . . . . . . . . 48 120 6.3.1. NETCONF Event Stream . . . . . . . . . . . . . . . . 49 121 6.4. Receiving Event Notifications . . . . . . . . . . . . . . 49 122 7. Error Reporting . . . . . . . . . . . . . . . . . . . . . . . 51 123 7.1. Error Response Message . . . . . . . . . . . . . . . . . 53 124 8. RESTCONF module . . . . . . . . . . . . . . . . . . . . . . . 55 125 9. RESTCONF Monitoring . . . . . . . . . . . . . . . . . . . . . 61 126 9.1. restconf-state/capabilities . . . . . . . . . . . . . . . 61 127 9.1.1. Query Parameter URIs . . . . . . . . . . . . . . . . 62 128 9.1.2. The "defaults" Protocol Capability URI . . . . . . . 62 129 9.2. restconf-state/streams . . . . . . . . . . . . . . . . . 63 130 9.3. RESTCONF Monitoring Module . . . . . . . . . . . . . . . 63 131 10. YANG Module Library . . . . . . . . . . . . . . . . . . . . . 67 132 10.1. modules . . . . . . . . . . . . . . . . . . . . . . . . 67 133 10.1.1. modules/module . . . . . . . . . . . . . . . . . . . 68 134 11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 68 135 11.1. The "restconf" Relation Type . . . . . . . . . . . . . . 68 136 11.2. YANG Module Registry . . . . . . . . . . . . . . . . . . 68 137 11.3. application/yang Media Sub Types . . . . . . . . . . . . 69 138 11.4. RESTCONF Capability URNs . . . . . . . . . . . . . . . . 70 139 12. Security Considerations . . . . . . . . . . . . . . . . . . . 71 140 13. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 72 141 14. References . . . . . . . . . . . . . . . . . . . . . . . . . 72 142 14.1. Normative References . . . . . . . . . . . . . . . . . . 72 143 14.2. Informative References . . . . . . . . . . . . . . . . . 75 145 Appendix A. Change Log . . . . . . . . . . . . . . . . . . . . . 75 146 A.1. 06 - 07 . . . . . . . . . . . . . . . . . . . . . . . . . 75 147 A.2. 05 - 06 . . . . . . . . . . . . . . . . . . . . . . . . . 76 148 A.3. 04 - 05 . . . . . . . . . . . . . . . . . . . . . . . . . 76 149 A.4. 03 - 04 . . . . . . . . . . . . . . . . . . . . . . . . . 76 150 A.5. 02 - 03 . . . . . . . . . . . . . . . . . . . . . . . . . 77 151 A.6. 01 - 02 . . . . . . . . . . . . . . . . . . . . . . . . . 78 152 A.7. 00 - 01 . . . . . . . . . . . . . . . . . . . . . . . . . 78 153 A.8. bierman:restconf-04 to ietf:restconf-00 . . . . . . . . . 79 154 Appendix B. Open Issues . . . . . . . . . . . . . . . . . . . . 79 155 Appendix C. Example YANG Module . . . . . . . . . . . . . . . . 80 156 C.1. example-jukebox YANG Module . . . . . . . . . . . . . . . 80 157 Appendix D. RESTCONF Message Examples . . . . . . . . . . . . . 86 158 D.1. Resource Retrieval Examples . . . . . . . . . . . . . . . 86 159 D.1.1. Retrieve the Top-level API Resource . . . . . . . . . 86 160 D.1.2. Retrieve The Server Module Information . . . . . . . 87 161 D.1.3. Retrieve The Server Capability Information . . . . . 88 162 D.2. Edit Resource Examples . . . . . . . . . . . . . . . . . 89 163 D.2.1. Create New Data Resources . . . . . . . . . . . . . . 89 164 D.2.2. Detect Resource Entity Tag Change . . . . . . . . . . 90 165 D.2.3. Edit a Datastore Resource . . . . . . . . . . . . . . 91 166 D.3. Query Parameter Examples . . . . . . . . . . . . . . . . 92 167 D.3.1. "content" Parameter . . . . . . . . . . . . . . . . . 92 168 D.3.2. "depth" Parameter . . . . . . . . . . . . . . . . . . 95 169 D.3.3. "fields" Parameter . . . . . . . . . . . . . . . . . 98 170 D.3.4. "insert" Parameter . . . . . . . . . . . . . . . . . 99 171 D.3.5. "point" Parameter . . . . . . . . . . . . . . . . . . 100 172 D.3.6. "filter" Parameter . . . . . . . . . . . . . . . . . 101 173 D.3.7. "start-time" Parameter . . . . . . . . . . . . . . . 101 174 D.3.8. "stop-time" Parameter . . . . . . . . . . . . . . . . 101 175 D.3.9. "with-defaults" Parameter . . . . . . . . . . . . . . 102 176 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 103 178 1. Introduction 180 There is a need for standard mechanisms to allow Web applications to 181 access the configuration data, operational data, data-model specific 182 protocol operations, and event notifications within a networking 183 device, in a modular and extensible manner. 185 This document describes an HTTP [RFC7230] based protocol called 186 RESTCONF, for accessing data defined in YANG [RFC6020], using 187 datastores defined in NETCONF [RFC6241]. 189 The NETCONF protocol defines configuration datastores and a set of 190 Create, Retrieve, Update, Delete (CRUD) operations that can be used 191 to access these datastores. The YANG language defines the syntax and 192 semantics of datastore content, operational data, protocol 193 operations, and event notifications. RESTCONF uses HTTP operations 194 to provide CRUD operations on a NETCONF datastore containing YANG- 195 defined data. Since NETCONF protocol operations are not relevant, 196 the user should not need any prior knowledge of NETCONF in order to 197 use RESTCONF. 199 Configuration data and state data are exposed as resources that can 200 be retrieved with the GET method. Resources representing 201 configuration data can be modified with the DELETE, PATCH, POST, and 202 PUT methods. Data is encoded with either XML [W3C.REC-xml-20081126] 203 or JSON [RFC7158]. 205 Data-model specific protocol operations defined with the YANG "rpc" 206 statement can be invoked with the POST method. Data-model specific 207 event notifications defined with the YANG "notification" statement 208 can be accessed. 210 1.1. Simple Subset of NETCONF Functionality 212 An HTTP-based management protocol does not need to mirror the 213 functionality of the NETCONF protocol, but it needs to be compatible 214 with NETCONF. A simplified transaction model is needed that allows 215 basic CRUD operations on a hierarchy of conceptual resources. This 216 represents a limited subset of the transaction capabilities of the 217 NETCONF protocol. 219 The HTTP POST, PUT, PATCH, and DELETE methods are used to edit data 220 resources represented by YANG data models. These basic edit 221 operations allow the running configuration to be altered in an all- 222 or-none fashion. This is similar to the "rollback-on-error" 223 capability in NETCONF. Edits are usually applied to one data 224 resource instance at a time. 226 The base RESTCONF protocol is intentionally simple to allow 227 deployment for as many use cases as possible. Additional 228 functionality can be defined in external documents, outside the scope 229 of this document. 231 RESTCONF is not intended to replace NETCONF, but rather provide an 232 additional simplified interface that follows REST principles and is 233 compatible with a resource-oriented device abstraction. 235 The following figure shows the system components: 237 +-----------+ +-----------------+ 238 | Web app | <-------> | | 239 +-----------+ HTTP | network device | 240 | | 241 +-----------+ | +-----------+ | 242 | NMS app | <-------> | | datastore | | 243 +-----------+ NETCONF | +-----------+ | 244 +-----------------+ 246 1.2. Data Model Driven API 248 RESTCONF combines the simplicity of the HTTP protocol with the 249 predictability and automation potential of a schema-driven API. 250 Using YANG, a client can predict all resource endpoints, much like 251 using URI Templates [RFC6570], but in a more holistic manner. This 252 strategy obviates the need for responses provided by the server to 253 contain HATEOAS links, originally described in Roy Fielding's 254 doctoral dissertation [rest-dissertation]. 256 In contrast, a REST client using HATEOAS principles would not use any 257 data modeling language to define the application-specific content of 258 the API. The client would need to discover each new child resource 259 as it traverses the URIs to discover the server capabilities. This 260 approach has the following significant weaknesses with regards to 261 control of complex networking devices: 263 o inefficient performance: configuration APIs will be quite complex 264 and may require thousands of protocol messages to discover all the 265 schema information. Typically the data type information has to be 266 passed in the protocol messages, which is also wasteful overhead. 268 o no data model richness: without a data model, the schema-level 269 semantics and validation constraints are not available to the 270 application. 272 o no tool automation: API automation tools need some sort of content 273 schema to function. Such tools can automate various programming 274 and documentation tasks related to specific data models. 276 Data models such as YANG modules serve as an "API contract" that will 277 be honored by the server. An application designer can code to the 278 data model, knowing in advance important details about the exact 279 protocol operations and datastore content a conforming server 280 implementation will support. 282 RESTCONF provides the YANG module capability information supported by 283 the server, in case the client wants to use it. The URIs for custom 284 protocol operations and datastore content are predictable, based on 285 the YANG module definitions. 287 Operational experience with CLI and SNMP indicates that operators 288 learn the 'location' of specific service or device related data and 289 do not expect such information to be arbitrary and discovered each 290 time the client opens a management session to a server. 292 The RESTCONF protocol operates on a conceptual datastore defined with 293 the YANG data modeling language. The server lists each YANG module 294 it supports using the "ietf-yang-library" YANG module, defined in 295 [I-D.ietf-netconf-yang-library]. The server MUST implement the 296 "ietf-yang-library" module, which SHOULD identify all the YANG 297 modules used by the server. 299 The conceptual datastore contents, data-model-specific operations and 300 event notifications are identified by this set of YANG modules. All 301 RESTCONF content identified as either a data resource, operation 302 resource, or event stream resource is defined with the YANG language. 304 The classification of data as configuration or non-configuration is 305 derived from the YANG "config" statement. Data ordering behavior is 306 derived from the YANG "ordered-by" statement. 308 The RESTCONF datastore editing model is simple and direct, similar to 309 the behavior of the :writable-running capability in NETCONF. Each 310 RESTCONF edit of a datastore resource is activated upon successful 311 completion of the transaction. 313 1.3. Coexistence with NETCONF 315 RESTCONF can be implemented on a device that supports NETCONF. 317 If the device supports :writable-running, all edits to configuration 318 nodes in {+restconf}/data are performed in the running configuration 319 datastore. 321 Otherwise, if the device supports :candidate, all edits to 322 configuration nodes in {+restconf}/data are performed in the 323 candidate configuration datastore. The candidate is automatically 324 committed to running after a successful edit. 326 If the device supports :startup, the device automatically copies the 327 content of running to startup after running has been updated as a 328 consequence of a RESTCONF edit operation. 330 If a datastore that would be modified by a RESTCONF operation has an 331 active lock, the RESTCONF edit operation MUST fail with a 409 332 (Conflict) error code. 334 1.4. Terminology 336 The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 337 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 338 "OPTIONAL" in this document are to be interpreted as described in BCP 339 14, [RFC2119]. 341 1.4.1. NETCONF 343 The following terms are defined in [RFC6241]: 345 o candidate configuration datastore 347 o client 349 o configuration data 351 o datastore 353 o configuration datastore 355 o protocol operation 357 o running configuration datastore 359 o server 361 o startup configuration datastore 363 o state data 365 o user 367 1.4.2. HTTP 369 The following terms are defined in [RFC3986]: 371 o fragment 373 o path 375 o query 377 The following terms are defined in [RFC7230]: 379 o header 381 o message-body 383 o request-line 385 o request URI 387 o status-line 389 The following terms are defined in [RFC7231]: 391 o method 393 o request 395 o resource 397 The following terms are defined in [RFC7232]: 399 o entity tag 401 1.4.3. YANG 403 The following terms are defined in [RFC6020]: 405 o container 407 o data node 409 o key leaf 411 o leaf 413 o leaf-list 415 o list 417 o presence container (or P-container) 419 o RPC operation (now called protocol operation) 421 o non-presence container (or NP-container) 423 o ordered-by system 425 o ordered-by user 427 1.4.4. Terms 429 The following terms are used within this document: 431 o API resource: a resource with the media type "application/ 432 yang.api+xml" or "application/yang.api+json". 434 o data resource: a resource with the media type "application/ 435 yang.data+xml" or "application/yang.data+json". Containers, 436 leafs, list entries and anyxml nodes can be data resources. 438 o datastore resource: a resource with the media type "application/ 439 yang.datastore+xml" or "application/yang.datastore+json". 440 Represents a datastore. 442 o edit operation: a RESTCONF operation on a data resource using 443 either a POST, PUT, PATCH, or DELETE method. 445 o event stream resource: This resource represents an SSE (Server- 446 Sent Events) event stream. The content consists of text using the 447 media type "text/event-stream", as defined by the HTML5 448 specification. Each event represents one message 449 generated by the server. It contains a conceptual system or data- 450 model specific event that is delivered within an event 451 notification stream. Also called a "stream resource". 453 o media-type: HTTP uses Internet media types [RFC2046] in the 454 Content-Type and Accept header fields in order to provide open and 455 extensible data typing and type negotiation. 457 o operation: the conceptual RESTCONF operation for a message, 458 derived from the HTTP method, request URI, headers, and message- 459 body. 461 o operation resource: a resource with the media type "application/ 462 yang.operation+xml" or "application/yang.operation+json". 464 o patch: a generic PATCH request on the target datastore or data 465 resource. The media type of the message-body content will 466 identify the patch type in use. 468 o plain patch: a specific PATCH request type that can be used for 469 simple merge operations. 471 o query parameter: a parameter (and its value if any), encoded 472 within the query component of the request URI. 474 o RESTCONF capability: An optional RESTCONF protocol feature 475 supported by the server, which is identified by an IANA registered 476 NETCONF Capability URI, and advertised with an entry in the 477 "capability" leaf-list in Section 9.3. 479 o retrieval request: a request using the GET or HEAD methods. 481 o target resource: the resource that is associated with a particular 482 message, identified by the "path" component of the request URI. 484 o schema resource: a resource with the media type "application/ 485 yang". The YANG representation of the schema can be retrieved by 486 the client with the GET method. 488 o stream list: the set of data resource instances that describe the 489 event stream resources available from the server. This 490 information is defined in the "ietf-restconf-monitoring" module as 491 the "stream" list. It can be retrieved using the target resource 492 "{+restconf}/data/ietf-restconf-monitoring:restconf-state/streams/ 493 stream". The stream list contains information about each stream, 494 such as the URL to retrieve the event stream data. 496 1.4.5. URI Template 498 Throughout this document, the URI template [RFC6570] syntax 499 "{+restconf}" is used to refer to the RESTCONF API entry point 500 outside of an example. See Section 3.1 for details. 502 For simplicity, all of the examples in this document assume 503 "/restconf" as the discovered RESTCONF API root path. 505 1.4.6. Tree Diagrams 507 A simplified graphical representation of the data model is used in 508 this document. The meaning of the symbols in these diagrams is as 509 follows: 511 o Brackets "[" and "]" enclose list keys. 513 o Abbreviations before data node names: "rw" means configuration 514 data (read-write) and "ro" state data (read-only). 516 o Symbols after data node names: "?" means an optional node, "!" 517 means a presence container, and "*" denotes a list and leaf-list. 519 o Parentheses enclose choice and case nodes, and case nodes are also 520 marked with a colon (":"). 522 o Ellipsis ("...") stands for contents of subtrees that are not 523 shown. 525 2. Transport Protocol Requirements 527 2.1. Integrity and Confidentiality 529 HTTP [RFC7230] is an application layer protocol that may be layered 530 on any reliable transport-layer protocol. RESTCONF is defined on top 531 of HTTP, but due to the sensitive nature of the information conveyed, 532 RESTCONF requires that the transport-layer protocol provides both 533 data integrity and confidentiality, such as are provided by the TLS 534 protocol [RFC5246]. 536 2.2. HTTPS with X.509v3 Certificates 538 Given the nearly ubiquitous support for HTTP over TLS [RFC7230], 539 RESTCONF implementations MUST support the "https" URI scheme, which 540 has the IANA assigned default port 443. Consistent with the 541 exclusive use of X.509v3 certificates for NETCONF over TLS 542 [draft-ietf-netconf-rfc5539bis-10], use of certificates in RESTCONF 543 is also limited to X.509v3 certificates. 545 2.3. Certificate Validation 547 When presented an X.509 certificate, the RESTCONF peer MUST use X.509 548 certificate path validation [RFC5280] to verify the integrity of the 549 certificate. The presented X.509 certificate MAY also be considered 550 valid if it matches a locally configured certificate fingerprint. If 551 X.509 certificate path validation fails and the presented X.509 552 certificate does not match a locally configured certificate 553 fingerprint, the connection MUST be terminated as defined in 554 [RFC5246]. 556 2.4. Authenticated Server Identity 558 The RESTCONF client MUST carefully examine the certificate presented 559 by the RESTCONF server to determine if it meets the client's 560 expectations. The RESTCONF client MUST check the identity of the 561 server according to Section 6 of [RFC6125], including processing the 562 outcome as described in Section 6.6 of [RFC6125]. 564 2.5. Authenticated Client Identity 566 The RESTCONF server MUST authenticate client access to any protected 567 resource using HTTP Authentication [RFC7235]. If the RESTCONF client 568 is not authenticated to access a resource, the server MUST send a 569 response with status code 401 (Unauthorized) and a WWW-Authenticate 570 header field containing at least one challenge applicable to the 571 target resource. The RESTCONF server MAY advertise support for any 572 number of authentication schemes but, in order to ensure 573 interoperability, the RESTCONF server MUST advertise at least one of 574 the following authentication schemes: 576 o Basic [draft-ietf-httpauth-basicauth-update-03] 578 o Digest [draft-ietf-httpauth-digest-09] 580 o ClientCertificate [draft-thomson-httpbis-cant-01] 582 These authentication schemes are selected for to their similarity to 583 the authentication schemes supported by NETCONF. In particular, the 584 Basic and Digest authentication schemes both directly provide an 585 identity and verification of a shared secret, much like NETCONF over 586 SSH, when using the SSH "password" authentication method [RFC4252]. 587 Similarly, the ClientCertificate authentication scheme is much like 588 NETCONF over TLS's use of X.509 client-certificates. When using the 589 ClientCertificate authentication scheme, the RESTCONF server MUST 590 derive the identity of the RESTCONF client using the algorithm 591 defined in Section 7 of [draft-ietf-netconf-rfc5539bis-10]. 593 The RESTCONF client identity determined from any HTTP authentication 594 scheme is hereafter known as the "RESTCONF username" and subject to 595 the NETCONF Access Control Module (NACM) [RFC6536]. 597 3. Resources 599 The RESTCONF protocol operates on a hierarchy of resources, starting 600 with the top-level API resource itself (Section 3.1). Each resource 601 represents a manageable component within the device. 603 A resource can be considered a collection of conceptual data and the 604 set of allowed methods on that data. It can contain nested child 605 resources. The child resource types and methods allowed on them are 606 data-model specific. 608 A resource has its own media type identifier, represented by the 609 "Content-Type" header in the HTTP response message. A resource can 610 contain zero or more nested resources. A resource can be created and 611 deleted independently of its parent resource, as long as the parent 612 resource exists. 614 All RESTCONF resources are defined in this document except specific 615 datastore contents, protocol operations, and event notifications. 616 The syntax and semantics for these resource types are defined in YANG 617 modules. 619 The RESTCONF resources are accessed via a set of URIs defined in this 620 document. The set of YANG modules supported by the server will 621 determine the data model specific operations, top-level data node 622 resources, and event notification messages supported by the server. 624 The RESTCONF protocol does not include a resource discovery 625 mechanism. Instead, the definitions within the YANG modules 626 advertised by the server are used to construct a predictable 627 operation or data resource identifier. 629 3.1. Root Resource Discovery 631 In line with the best practices defined by [RFC7320], RESTCONF 632 enables deployments to specify where the RESTCONF API is located. 633 When first connecting to a RESTCONF server, a RESTCONF client MUST 634 determine the root of the RESTCONF API. The client discovers this by 635 getting the "/.well-known/host-meta" resource ([RFC6415]) and using 636 the element containing the "restconf" attribute : 638 Request 639 ------- 640 GET /.well-known/host-meta users HTTP/1.1 641 Host: example.com 642 Accept: application/xrd+xml 644 Response 645 -------- 646 HTTP/1.1 200 OK 647 Content-Type: application/xrd+xml 648 Content-Length: nnn 650 651 652 654 Once discovering the RESTCONF API root, the client MUST prepend it to 655 any subsequent request to a RESTCONF resource. For instance, using 656 the "/restconf" path discovered above, the client can now determine 657 the operations supported by the the server. In this example a custom 658 "play" operation is supported: 660 Request 661 ------- 662 GET /restconf/operations HTTP/1.1 663 Host: example.com 664 Accept: application/yang.api+json 666 Response 667 -------- 668 HTTP/1.1 200 OK 669 Date: Mon, 23 Apr 2012 17:01:00 GMT 670 Server: example-server 671 Cache-Control: no-cache 672 Pragma: no-cache 673 Last-Modified: Sun, 22 Apr 2012 01:00:14 GMT 674 Content-Type: application/yang.api+json 676 { "operations" : { "play" : [ null ] } } 678 3.2. RESTCONF Resource Types 680 The RESTCONF protocol defines a set of application specific media 681 types to identify each of the available resource types. The 682 following resource types are defined in RESTCONF: 684 +-----------+---------------------------------+ 685 | Resource | Media Type | 686 +-----------+---------------------------------+ 687 | API | application/yang.api+xml | 688 | | application/yang.api+json | 689 | Datastore | application/yang.datastore+xml | 690 | | application/yang.datastore+json | 691 | Data | application/yang.data+xml | 692 | | application/yang.data+json | 693 | Errors | application/yang.errors+xml | 694 | | application/yang.errors+json | 695 | Operation | application/yang.operation+xml | 696 | | application/yang.operation+json | 697 | Schema | application/yang | 698 +-----------+---------------------------------+ 700 RESTCONF Media Types 702 3.3. API Resource 704 The API resource contains the entry points for the RESTCONF datastore 705 and operation resources. It is the top-level resource located at 706 {+restconf} and has the media type "application/yang.api+xml" or 707 "application/yang.api+json". 709 YANG Tree Diagram for an API Resource: 711 +--rw restconf 712 +--rw data 713 +--rw operations 715 The "application/yang.api" restconf-media-type extension in the 716 "ietf-restconf" module defined in Section 8 is used to specify the 717 structure and syntax of the conceptual child resources within the API 718 resource. 720 The API resource can be retrieved with the GET method. 722 This resource has the following child resources: 724 +----------------+--------------------------------+ 725 | Child Resource | Description | 726 +----------------+--------------------------------+ 727 | data | Contains all data resources | 728 | operations | Data-model specific operations | 729 +----------------+--------------------------------+ 731 RESTCONF API Resource 733 3.3.1. {+restconf}/data 735 This mandatory resource represents the combined configuration and 736 operational data resources that can be accessed by a client. It 737 cannot be created or deleted by the client. The datastore resource 738 type is defined in Section 3.4. 740 Example: 742 This example request by the client would retrieve only the non- 743 configuration data nodes that exist within the "library" resource, 744 using the "content" query parameter (see Section 4.8.1). 746 GET /restconf/data/example-jukebox:jukebox/library 747 ?content=nonconfig HTTP/1.1 748 Host: example.com 749 Accept: application/yang.data+xml 751 The server might respond: 753 HTTP/1.1 200 OK 754 Date: Mon, 23 Apr 2012 17:01:30 GMT 755 Server: example-server 756 Cache-Control: no-cache 757 Pragma: no-cache 758 Content-Type: application/yang.data+xml 760 761 42 762 59 763 374 764 766 3.3.2. {+restconf}/operations 768 This optional resource is a container that provides access to the 769 data-model specific protocol operations supported by the server. The 770 server MAY omit this resource if no data-model specific operations 771 are advertised. 773 Any data-model specific operations defined in the YANG modules 774 advertised by the server MAY be available as child nodes of this 775 resource. 777 Operation resources are defined in Section 3.6. 779 3.4. Datastore Resource 781 The "{+restconf}/data" subtree represents the datastore resource 782 type, which is a collection of configuration and operational data 783 nodes. 785 This resource type is an abstraction of the system's underlying 786 datastore implementation. It is used to simplify resource editing 787 for the client. The RESTCONF datastore resource is a conceptual 788 collection of all configuration and operational data that is present 789 on the device. 791 Configuration edit transaction management and configuration 792 persistence are handled by the server and not controlled by the 793 client. A datastore resource can only be written directly with the 794 PATCH method. Each RESTCONF edit of a datastore resource is saved to 795 non-volatile storage in an implementation-specific matter by the 796 server. 798 3.4.1. Edit Collision Detection 800 Two "edit collision detection" mechanisms are provided in RESTCONF, 801 for datastore and data resources. 803 3.4.1.1. Timestamp 805 The last change time is maintained and the "Last-Modified" 806 ([RFC7232], Section 2.2) header is returned in the response for a 807 retrieval request. The "If-Unmodified-Since" header can be used in 808 edit operation requests to cause the server to reject the request if 809 the resource has been modified since the specified timestamp. 811 The server MUST maintain a last-modified timestamp for the top-level 812 {+restconf}/data resource and SHOULD maintain last-modified 813 timestamps for descendant resources. For all resources, the server 814 MUST return the "Last-Modified" header when the resource is retrieved 815 with the GET or HEAD methods. If the server does not maintain a 816 timestamp for a resource, it MUST return the timestamp of the 817 resource's ancestor, a process that may recurse up to the top-level 818 {+restconf}/data resource. Only changes to configuration data 819 resources within the datastore affect the timestamp. 821 3.4.1.2. Entity tag 823 A unique opaque string is maintained and the "ETag" ([RFC7232], 824 Section 2.3) header is returned in the response for a retrieval 825 request. The "If-Match" header can be used in edit operation 826 requests to cause the server to reject the request if the resource 827 entity tag does not match the specified value. 829 The server MUST maintain an entity tag for the top-level 830 {+restconf}/data resource and SHOULD maintain entity tags for 831 descendant resources. For all resources, the server MUST return the 832 "ETag" header when the resource is retrieved with the GET or HEAD 833 methods. If the server does not maintain an entity tag for a 834 resource, it MUST return the entity tag of the resource's ancestor, a 835 process that may recurse up to the top-level {+restconf}/data 836 resource. Only changes to configuration data resources within the 837 datastore affect the entity tag. 839 3.5. Data Resource 841 A data resource represents a YANG data node that is a descendant node 842 of a datastore resource. Each YANG-defined data node can be uniquely 843 targeted by the request-line of an HTTP operation. Containers, 844 leafs, list entries and anyxml nodes are data resources. 846 The representation maintained for each data resource is the YANG 847 defined subtree for that node. HTTP operations on a data resource 848 affect both the targeted data node and all its descendants, if any. 850 For configuration data resources, the server MAY maintain a last- 851 modified timestamp for the resource, and return the "Last-Modified" 852 header when it is retrieved with the GET or HEAD methods. If 853 maintained, the resource timestamp MUST be set to the current time 854 whenever the resource or any configuration resource within the 855 resource is altered. 857 For configuration data resources, the server MAY maintain a resource 858 entity tag for the resource, and return the "ETag" header when it is 859 retrieved as the target resource with the GET or HEAD methods. If 860 maintained, the resource entity tag MUST be updated whenever the 861 resource or any configuration resource within the resource is 862 altered. 864 A data resource can be retrieved with the GET method. Data resources 865 are accessed via the "{+restconf}/data" entry point. This sub-tree 866 is used to retrieve and edit data resources. 868 A configuration data resource can be altered by the client with some 869 or all of the edit operations, depending on the target resource and 870 the specific operation. Refer to Section 4 for more details on edit 871 operations. 873 The resource definition version for a data resource is identified by 874 the revision date of the YANG module containing the YANG definition 875 for the data resource. 877 3.5.1. Encoding Data Resource Identifiers in the Request URI 879 In YANG, data nodes are named with an absolute XPath expression, 880 defined in [XPath], starting from the document root to the target 881 resource. In RESTCONF, URL encoded path expressions are used 882 instead. 884 A predictable location for a data resource is important, since 885 applications will code to the YANG data model module, which uses 886 static naming and defines an absolute path location for all data 887 nodes. 889 A RESTCONF data resource identifier is not an XPath expression. It 890 is encoded from left to right, starting with the top-level data node, 891 according to the "api-path" rule in Section 3.5.1.1. The node name 892 of each ancestor of the target resource node is encoded in order, 893 ending with the node name for the target resource. 895 If a data node in the path expression is a YANG list node, then the 896 key values for the list (if any) MUST be encoded according to the 897 following rules: 899 o The key leaf values for a data resource representing a YANG list 900 MUST be encoded using one path segment [RFC3986]. 902 o If there is only one key leaf value, the path segment is 903 constructed by having the list name followed by an "=" followed by 904 the single key leaf value. 906 o If there are multiple key leaf values, the value of each leaf 907 identified in the "key" statement is encoded in the order 908 specified in the YANG "key" statement, with a comma separating 909 them. 911 o The key value is specified as a string, using the canonical 912 representation for the YANG data type. Any reserved characters 913 MUST be encoded with escape sequences, according to [RFC2396], 914 Section 2.4. 916 o All the components in the "key" statement MUST be encoded. 917 Partial instance identifiers are not supported. 919 o Quoted strings are supported in the key leaf values. Quoted 920 strings MUST be used to express empty strings. (example: 921 list=foo,'',baz). 923 o The "list-instance" ABNF rule defined in Section 3.5.1.1 924 represents the syntax of a list instance identifier. 926 o Resource URI values returned in Location headers for data 927 resources MUST identify the module name, even if there are no 928 conflicting local names when the resource is created. This 929 ensures the correct resource will be identified even if the server 930 loads a new module that the old client does not know about. 932 Examples: 934 container top { 935 list list1 { 936 key "key1 key2 key3"; 937 ... 938 list list2 { 939 key "key4 key5"; 940 ... 941 leaf X { type string; } 942 } 943 } 944 } 946 For the above YANG definition, URI with key leaf values will be 947 encoded as follows (line wrapped for display purposes only): 949 /restconf/data/example-top:top/list1=key1val,key2val,key3val3/ 950 list2=key4val,key5val/X 952 3.5.1.1. ABNF For Data Resource Identifiers 954 The "api-path" ABNF syntax is used to construct RESTCONF path 955 identifiers: 957 api-path = "/" | 958 ("/" api-identifier 959 0*("/" (api-identifier | list-instance ))) 961 api-identifier = [module-name ":"] identifier ;; note 1 963 module-name = identifier 965 list-instance = api-identifier "=" key-value ["," key-value]* 967 key-value = string ;; note 1 969 string = 971 ;; An identifier MUST NOT start with 972 ;; (('X'|'x') ('M'|'m') ('L'|'l')) 973 identifier = (ALPHA / "_") 974 *(ALPHA / DIGIT / "_" / "-" / ".") 976 Note 1: The syntax for "api-identifier" and "key-value" MUST conform 977 to the JSON identifier encoding rules in Section 4 of 978 [I-D.ietf-netmod-yang-json]. 980 3.5.2. Defaults Handling 982 RESTCONF requires that a server report its default handling mode (see 983 Section 9.1.2 for details). If the optional "with-defaults" query 984 parameter is supported by the server, a client may use it to control 985 retrieval of default values (see Section 4.8.9 for details). 987 If the target of a GET method is a data node that represents a leaf 988 that has a default value, and the leaf has not been given a value 989 yet, the server MUST return the default value that is in use by the 990 server. 992 If the target of a GET method is a data node that represents a 993 container or list that has any child resources with default values, 994 for the child resources that have not been given value yet, the 995 server MAY return the default values that are in use by the server, 996 in accordance with its reported default handing mode and query 997 parameters passed by the client. 999 3.6. Operation Resource 1001 An operation resource represents a protocol operation defined with 1002 the YANG "rpc" statement. It is invoked using a POST method on the 1003 operation resource. 1005 POST {+restconf}/operations/ 1007 The field identifies the module name and rpc identifier 1008 string for the desired operation. 1010 For example, if "module-A" defined a "reset" operation, then invoking 1011 the operation from "module-A" would be requested as follows: 1013 POST /restconf/operations/module-A:reset HTTP/1.1 1014 Server example.com 1016 If the "rpc" statement has an "input" section, then a message-body 1017 MAY be sent by the client in the request, otherwise the request 1018 message MUST NOT include a message-body. 1020 If the operation is successfully invoked, and if the "rpc" statement 1021 has an "output" section, then a message-body MAY be sent by the 1022 server in the response, otherwise the response message MUST NOT 1023 include a message-body in the response message, and MUST send a "204 1024 No Content" status-line instead. 1026 If the operation is not successfully invoked, then a message-body 1027 SHOULD be sent by the server, containing an "errors" resource, as 1028 defined in Section 3.9. 1030 3.6.1. Encoding Operation Input Parameters 1032 If the "rpc" statement has an "input" section, then the "input" node 1033 is provided in the message-body, corresponding to the YANG data 1034 definition statements within the "input" section. 1036 Example: 1038 The following YANG definition is used for the examples in this 1039 section. 1041 module example-ops { 1042 namespace "https://example.com/ns/example-ops"; 1043 prefix "ops"; 1045 rpc reboot { 1046 input { 1047 leaf delay { 1048 units seconds; 1049 type uint32; 1050 default 0; 1051 } 1052 leaf message { type string; } 1053 leaf language { type string; } 1054 } 1055 } 1057 rpc get-reboot-info { 1058 output { 1059 leaf reboot-time { 1060 units seconds; 1061 type uint32; 1062 } 1063 leaf message { type string; } 1064 leaf language { type string; } 1065 } 1066 } 1067 } 1069 The client might send the following POST request message: 1071 POST /restconf/operations/example-ops:reboot HTTP/1.1 1072 Host: example.com 1073 Content-Type: application/yang.operation+xml 1074 1075 600 1076 Going down for system maintenance 1077 en-US 1078 1080 The server might respond: 1082 HTTP/1.1 204 No Content 1083 Date: Mon, 25 Apr 2012 11:01:00 GMT 1084 Server: example-server 1086 3.6.2. Encoding Operation Output Parameters 1088 If the "rpc" statement has an "output" section, then the "output" 1089 node is provided in the message-body, corresponding to the YANG data 1090 definition statements within the "output" section. 1092 Example: 1094 The "example-ops" YANG module defined in Section 3.6.1 is used for 1095 the examples in this section. 1097 The client might send the following POST request message: 1099 POST /restconf/operations/example-ops:get-reboot-info HTTP/1.1 1100 Host: example.com 1101 Accept: application/yang.operation+json 1103 The server might respond: 1105 HTTP/1.1 200 OK 1106 Date: Mon, 25 Apr 2012 11:10:30 GMT 1107 Server: example-server 1108 Content-Type: application/yang.operation+json 1110 { 1111 "example-ops:output" : { 1112 "reboot-time" : 30, 1113 "message" : "Going down for system maintenance", 1114 "language" : "en-US" 1115 } 1116 } 1118 3.6.3. Encoding Operation Errors 1120 If any errors occur while attempting to invoke the operation, then an 1121 "errors" data structure is returned with the appropriate error 1122 status. 1124 Using the "reset" operation example above, the client might send the 1125 following POST request message: 1127 POST /restconf/operations/example-ops:reboot HTTP/1.1 1128 Host: example.com 1129 Content-Type: application/yang.operation+xml 1131 1132 -33 1133 Going down for system maintenance 1134 en-US 1135 1137 The server might respond with an "invalid-value" error: 1139 HTTP/1.1 400 Bad Request 1140 Date: Mon, 25 Apr 2012 11:10:30 GMT 1141 Server: example-server 1142 Content-Type: application/yang.errors+xml 1144 1145 1146 protocol 1147 invalid-value 1148 1149 err:input/err:delay 1150 1151 Invalid input parameter 1152 1153 1155 3.7. Schema Resource 1157 The server can optionally support retrieval of the YANG modules it 1158 supports, using the "ietf-yang-library" module, defined in 1159 [I-D.ietf-netconf-yang-library]. 1161 To retrieve a YANG module, a client first needs to get the URL for 1162 retrieving the schema. 1164 The client might send the following GET request message: 1166 GET /restconf/data/ietf-yang-library:modules/module= 1167 example-jukebox,2014-07-03/schema HTTP/1.1 1168 Host: example.com 1169 Accept: application/yang.data+json 1171 The server might respond: 1173 HTTP/1.1 200 OK 1174 Date: Mon, 25 Apr 2012 11:10:30 GMT 1175 Server: example-server 1176 Content-Type: application/yang.data+json 1178 { 1179 "ietf-yang-library:schema": 1180 "https://example.com/mymodules/example-jukebox/2015-06-04" 1181 } 1183 Next the client needs to retrieve the actual YANG schema. 1185 The client might send the following GET request message: 1187 GET https://example.com/mymodules/example-jukebox/2015-06-04 1188 HTTP/1.1 1189 Host: example.com 1190 Accept: application/yang 1192 The server might respond: 1194 module example-jukebox { 1196 // contents of YANG module deleted for this example... 1198 } 1200 3.8. Event Stream Resource 1202 An "event stream" resource represents a source for system generated 1203 event notifications. Each stream is created and modified by the 1204 server only. A client can retrieve a stream resource or initiate a 1205 long-poll server sent event stream, using the procedure specified in 1206 Section 6.3. 1208 A notification stream functions according to the NETCONF 1209 Notifications specification [RFC5277]. The available streams can be 1210 retrieved from the stream list, which specifies the syntax and 1211 semantics of a stream resource. 1213 3.9. Errors Media Type 1215 An "errors" media type is a collection of error information that is 1216 sent as the message-body in a server response message, if an error 1217 occurs while processing a request message. It is not considered a 1218 resource type because no instances can be retrieved with a GET 1219 request. 1221 The "ietf-restconf" YANG module contains the "application/ 1222 yang.errors" restconf-media-type extension which specifies the syntax 1223 and semantics of an "errors" media type. RESTCONF error handling 1224 behavior is defined in Section 7. 1226 4. Operations 1228 The RESTCONF protocol uses HTTP methods to identify the CRUD 1229 operation requested for a particular resource. 1231 The following table shows how the RESTCONF operations relate to 1232 NETCONF protocol operations: 1234 +----------+--------------------------------------------+ 1235 | RESTCONF | NETCONF | 1236 +----------+--------------------------------------------+ 1237 | OPTIONS | none | 1238 | HEAD | none | 1239 | GET | , | 1240 | POST | (operation="create") | 1241 | PUT | (operation="create/replace") | 1242 | PATCH | (operation="merge") | 1243 | DELETE | (operation="delete") | 1244 +----------+--------------------------------------------+ 1246 Table 1: CRUD Methods in RESTCONF 1248 The NETCONF "remove" operation attribute is not supported by the HTTP 1249 DELETE method. The resource must exist or the DELETE method will 1250 fail. The PATCH method is equivalent to a "merge" operation when 1251 using a plain patch (see Section 4.6.1), other media-types may 1252 provide more granular control. 1254 Access control mechanisms may be used to limit what operations can be 1255 used. In particular, RESTCONF is compatible with the NETCONF Access 1256 Control Model (NACM) [RFC6536], as there is a specific mapping 1257 between RESTCONF and NETCONF operations, defined in Table 1. The 1258 resource path needs to be converted internally by the server to the 1259 corresponding YANG instance-identifier. Using this information, the 1260 server can apply the NACM access control rules to RESTCONF messages. 1262 The server MUST NOT allow any operation to any resources that the 1263 client is not authorized to access. 1265 Implementation of all methods (except PATCH) are defined in 1266 [RFC7231]. This section defines the RESTCONF protocol usage for each 1267 HTTP method. 1269 4.1. OPTIONS 1271 The OPTIONS method is sent by the client to discover which methods 1272 are supported by the server for a specific resource (e.g., GET, POST, 1273 DELETE, etc.). 1275 The server SHOULD implement this method, however the same information 1276 could be extracted from the YANG modules and the RESTCONF protocol 1277 specification. 1279 If the PATCH method is supported, then the "Accept-Patch" header MUST 1280 be supported and returned in the response to the OPTIONS request, as 1281 defined in [RFC5789]. 1283 4.2. HEAD 1285 The HEAD method is sent by the client to retrieve just the headers 1286 that would be returned for the comparable GET method, without the 1287 response message-body. It is supported for all resource types, 1288 except operation resources. 1290 The request MUST contain a request URI that contains at least the 1291 entry point. The same query parameters supported by the GET method 1292 are supported by the HEAD method. 1294 The access control behavior is enforced as if the method was GET 1295 instead of HEAD. The server MUST respond the same as if the method 1296 was GET instead of HEAD, except that no response message-body is 1297 included. 1299 4.3. GET 1301 The GET method is sent by the client to retrieve data and meta-data 1302 for a resource. It is supported for all resource types, except 1303 operation resources. The request MUST contain a request URI that 1304 contains at least the entry point. 1306 The server MUST NOT return any data resources for which the user does 1307 not have read privileges. If the user is not authorized to read the 1308 target resource, an error response containing a "403 Forbidden" or 1309 "404 Not Found" status-line is returned to the client. 1311 If the user is authorized to read some but not all of the target 1312 resource, the unauthorized content is omitted from the response 1313 message-body, and the authorized content is returned to the client. 1315 Example: 1317 The client might request the response headers for an XML 1318 representation of the "library" resource: 1320 GET /restconf/data/example-jukebox:jukebox/ 1321 library/artist=Foo%20Fighters/album HTTP/1.1 1322 Host: example.com 1323 Accept: application/yang.data+xml 1325 The server might respond: 1327 HTTP/1.1 200 OK 1328 Date: Mon, 23 Apr 2012 17:02:40 GMT 1329 Server: example-server 1330 Content-Type: application/yang.data+xml 1331 Cache-Control: no-cache 1332 Pragma: no-cache 1333 ETag: a74eefc993a2b 1334 Last-Modified: Mon, 23 Apr 2012 11:02:14 GMT 1336 1337 Wasting Light 1338 1339 g:alternative 1340 1341 2011 1342 1344 4.4. POST 1346 The POST method is sent by the client to create a data resource or 1347 invoke an operation resource. The server uses the target resource 1348 media type to determine how to process the request. 1350 +-----------+------------------------------------------------+ 1351 | Type | Description | 1352 +-----------+------------------------------------------------+ 1353 | Datastore | Create a top-level configuration data resource | 1354 | Data | Create a configuration data child resource | 1355 | Operation | Invoke a protocol operation | 1356 +-----------+------------------------------------------------+ 1358 Resource Types that Support POST 1360 4.4.1. Create Resource Mode 1362 If the target resource type is a datastore or data resource, then the 1363 POST is treated as a request to create a top-level resource or child 1364 resource, respectively. The message-body is expected to contain the 1365 content of a child resource to create within the parent (target 1366 resource). The data-model for the child tree is the subtree is 1367 defined by YANG for the child resource. 1369 The "insert" and "point" query parameters are supported by the POST 1370 method for datastore and data resource types, as specified in the 1371 YANG definition in Section 8. 1373 If the POST method succeeds, a "201 Created" status-line is returned 1374 and there is no response message-body. A "Location" header 1375 identifying the child resource that was created MUST be present in 1376 the response in this case. 1378 If the user is not authorized to create the target resource, an error 1379 response containing a "403 Forbidden" or "404 Not Found" status-line 1380 is returned to the client. All other error responses are handled 1381 according to the procedures defined in Section 7. 1383 Example: 1385 To create a new "jukebox" resource, the client might send: 1387 POST /restconf/data HTTP/1.1 1388 Host: example.com 1389 Content-Type: application/yang.data+json 1391 { "example-jukebox:jukebox" : [null] } 1393 If the resource is created, the server might respond as follows. 1394 Note that the "Location" header line is wrapped for display purposes 1395 only: 1397 HTTP/1.1 201 Created 1398 Date: Mon, 23 Apr 2012 17:01:00 GMT 1399 Server: example-server 1400 Location: https://example.com/restconf/data/ 1401 example-jukebox:jukebox 1402 Last-Modified: Mon, 23 Apr 2012 17:01:00 GMT 1403 ETag: b3a3e673be2 1405 Refer to Appendix D.2.1 for more resource creation examples. 1407 4.4.2. Invoke Operation Mode 1409 If the target resource type is an operation resource, then the POST 1410 method is treated as a request to invoke that operation. The 1411 message-body (if any) is processed as the operation input parameters. 1412 Refer to Section 3.6 for details on operation resources. 1414 If the POST request succeeds, a "200 OK" status-line is returned if 1415 there is a response message-body, and a "204 No Content" status-line 1416 is returned if there is no response message-body. 1418 If the user is not authorized to invoke the target operation, an 1419 error response containing a "403 Forbidden" or "404 Not Found" 1420 status-line is returned to the client. All other error responses are 1421 handled according to the procedures defined in Section 7. 1423 Example: 1425 In this example, the client is invoking the "play" operation defined 1426 in the "example-jukebox" YANG module. 1428 A client might send a "play" request as follows: 1430 POST /restconf/operations/example-jukebox:play HTTP/1.1 1431 Host: example.com 1432 Content-Type: application/yang.operation+json 1434 { 1435 "example-jukebox:input" : { 1436 "playlist" : "Foo-One", 1437 "song-number" : 2 1438 } 1439 } 1441 The server might respond: 1443 HTTP/1.1 204 No Content 1444 Date: Mon, 23 Apr 2012 17:50:00 GMT 1445 Server: example-server 1447 4.5. PUT 1449 The PUT method is sent by the client to create or replace the target 1450 resource. 1452 The only target resource media type that supports PUT is the data 1453 resource. The message-body is expected to contain the content used 1454 to create or replace the target resource. 1456 The "insert" (Section 4.8.4) and "point" (Section 4.8.5) query 1457 parameters are supported by the PUT method for data resources. 1459 Consistent with [RFC7231], if the PUT request creates a new resource, 1460 a "201 Created" status-line is returned. If an existing resource is 1461 modified, either "200 OK" or "204 No Content" are returned. 1463 If the user is not authorized to create or replace the target 1464 resource an error response containing a "403 Forbidden" or "404 Not 1465 Found" status-line is returned to the client. All other error 1466 responses are handled according to the procedures defined in 1467 Section 7. 1469 Example: 1471 An "album" child resource defined in the "example-jukebox" YANG 1472 module is replaced or created if it does not already exist. 1474 To replace the "album" resource contents, the client might send as 1475 follows. Note that the request-line is wrapped for display purposes 1476 only: 1478 PUT /restconf/data/example-jukebox:jukebox/ 1479 library/artist=Foo%20Fighters/album=Wasting%20Light HTTP/1.1 1480 Host: example.com 1481 Content-Type: application/yang.data+json 1483 { 1484 "example-jukebox:album" : { 1485 "name" : "Wasting Light", 1486 "genre" : "example-jukebox:alternative", 1487 "year" : 2011 1488 } 1489 } 1491 If the resource is updated, the server might respond: 1493 HTTP/1.1 204 No Content 1494 Date: Mon, 23 Apr 2012 17:04:00 GMT 1495 Server: example-server 1496 Last-Modified: Mon, 23 Apr 2012 17:04:00 GMT 1497 ETag: b27480aeda4c 1499 4.6. PATCH 1501 RESTCONF uses the HTTP PATCH method defined in [RFC5789] to provide 1502 an extensible framework for resource patching mechanisms. It is 1503 optional to implement by the server. Each patch type needs a unique 1504 media type. Zero or more PATCH media types MAY be supported by the 1505 server. The media types supported by a server can be discovered by 1506 the client by sending an OPTIONS request (see Section 4.1). 1508 If the target resource instance does not exist, the server MUST NOT 1509 create it. 1511 If the PATCH request succeeds, a "200 OK" status-line is returned if 1512 there is a message-body, and "204 No Content" is returned if no 1513 response message-body is sent. 1515 If the user is not authorized to alter the target resource an error 1516 response containing a "403 Forbidden" or "404 Not Found" status-line 1517 is returned to the client. All other error responses are handled 1518 according to the procedures defined in Section 7. 1520 4.6.1. Plain Patch 1522 The plain patch mechanism merges the contents of the message body 1523 with the target resource. If the target resource is a datastore 1524 resource (see Section 3.4), the message body MUST be either 1525 application/yang.datastore+xml or application/yang.datastore+json. 1526 If then the target resource is a data resource (see Section 3.5), 1527 then the message body MUST be either application/yang.data+xml or 1528 application/yang.data+json. 1530 Plain patch can used to create or update, but not delete, a child 1531 resource within the target resource. Please see 1532 [I-D.ietf-netconf-yang-patch] for an alternate media-type supporting 1533 more granular control. The YANG Patch Media Type allows multiple 1534 sub-operations (e.g., merge, delete) within a single PATCH operation. 1536 Example: 1538 To replace just the "year" field in the "album" resource (instead of 1539 replacing the entire resource with the PUT method), the client might 1540 send a plain patch as follows. Note that the request-line is wrapped 1541 for display purposes only: 1543 PATCH /restconf/data/example-jukebox:jukebox/ 1544 library/artist=Foo%20Fighters/album=Wasting%20Light HTTP/1.1 1545 Host: example.com 1546 If-Match: b8389233a4c 1547 Content-Type: application/yang.data+xml 1549 1550 2011 1551 1553 If the field is updated, the server might respond: 1555 HTTP/1.1 204 No Content 1556 Date: Mon, 23 Apr 2012 17:49:30 GMT 1557 Server: example-server 1558 Last-Modified: Mon, 23 Apr 2012 17:49:30 GMT 1559 ETag: b2788923da4c 1561 4.7. DELETE 1563 The DELETE method is used to delete the target resource. If the 1564 DELETE request succeeds, a "204 No Content" status-line is returned, 1565 and there is no response message-body. 1567 If the user is not authorized to delete the target resource then an 1568 error response containing a "403 Forbidden" or "404 Not Found" 1569 status-line is returned to the client. All other error responses are 1570 handled according to the procedures defined in Section 7. 1572 Example: 1574 To delete a resource such as the "album" resource, the client might 1575 send: 1577 DELETE /restconf/data/example-jukebox:jukebox/ 1578 library/artist=Foo%20Fighters/album=Wasting%20Light HTTP/1.1 1579 Host: example.com 1581 If the resource is deleted, the server might respond: 1583 HTTP/1.1 204 No Content 1584 Date: Mon, 23 Apr 2012 17:49:40 GMT 1585 Server: example-server 1587 4.8. Query Parameters 1589 Each RESTCONF operation allows zero or more query parameters to be 1590 present in the request URI. The specific parameters that are allowed 1591 depends on the resource type, and sometimes the specific target 1592 resource used, in the request. 1594 +---------------+---------+-----------------------------------------+ 1595 | Name | Methods | Description | 1596 +---------------+---------+-----------------------------------------+ 1597 | content | GET | Select config and/or non-config data | 1598 | | | resources | 1599 | depth | GET | Request limited sub-tree depth in the | 1600 | | | reply content | 1601 | fields | GET | Request a subset of the target resource | 1602 | | | contents | 1603 | filter | GET | Boolean notification filter for event | 1604 | | | stream resources | 1605 | insert | POST, | Insertion mode for user-ordered data | 1606 | | PUT | resources | 1607 | point | POST, | Insertion point for user-ordered data | 1608 | | PUT | resources | 1609 | start-time | GET | Replay buffer start time for event | 1610 | | | stream resources | 1611 | stop-time | GET | Replay buffer stop time for event | 1612 | | | stream resources | 1613 | with-defaults | GET | Control retrieval of default values | 1614 +---------------+---------+-----------------------------------------+ 1616 RESTCONF Query Parameters 1618 Query parameters can be given in any order. Each parameter can 1619 appear at most once in a request URI. A default value may apply if 1620 the parameter is missing. 1622 Refer to Appendix D.3 for examples of query parameter usage. 1624 If vendors define additional query parameters, they SHOULD use a 1625 prefix (such as the enterprise or organization name) for query 1626 parameter names in order to avoid collisions with other parameters. 1628 4.8.1. The "content" Query Parameter 1630 The "content" parameter controls how descendant nodes of the 1631 requested data nodes will be processed in the reply. 1633 The allowed values are: 1635 +-----------+-----------------------------------------------------+ 1636 | Value | Description | 1637 +-----------+-----------------------------------------------------+ 1638 | config | Return only configuration descendant data nodes | 1639 | nonconfig | Return only non-configuration descendant data nodes | 1640 | all | Return all descendant data nodes | 1641 +-----------+-----------------------------------------------------+ 1643 This parameter is only allowed for GET methods on datastore and data 1644 resources. A 400 Bad Request error is returned if used for other 1645 methods or resource types. 1647 The default value is determined by the "config" statement value of 1648 the requested data nodes. If the "config" value is "false", then the 1649 default for the "content" parameter is "nonconfig". If "config" is 1650 "true" then the default for the "content" parameter is "config". 1652 This query parameter MUST be supported by the server. 1654 4.8.2. The "depth" Query Parameter 1656 The "depth" parameter is used to specify the number of nest levels 1657 returned in a response for a GET method. The first nest-level 1658 consists of the requested data node itself. Any child nodes which 1659 are contained within a parent node have a depth value that is 1 1660 greater than its parent. 1662 The value of the "depth" parameter is either an integer between 1 and 1663 65535, or the string "unbounded". "unbounded" is the default. 1665 This parameter is only allowed for GET methods on API, datastore, and 1666 data resources. A 400 Bad Request error is returned if it used for 1667 other methods or resource types. 1669 By default, the server will include all sub-resources within a 1670 retrieved resource, which have the same resource type as the 1671 requested resource. Only one level of sub-resources with a different 1672 media type than the target resource will be returned. 1674 If the "depth" query parameter URI is listed in the "capability" 1675 leaf-list in Section 9.3, then the server supports the "depth" query 1676 parameter. 1678 4.8.3. The "fields" Query Parameter 1680 The "fields" query parameter is used to optionally identify data 1681 nodes within the target resource to be retrieved in a GET method. 1682 The client can use this parameter to retrieve a subset of all nodes 1683 in a resource. 1685 A value of the "fields" query parameter matches the following rule: 1687 fields-expr = path '(' fields-expr / '*' ')' / 1688 path ';' fields-expr / 1689 path 1690 path = api-identifier [ '/' path ] 1692 "api-identifier" is defined in Section 3.5.1.1. 1694 ";" is used to select multiple nodes. For example, to retrieve only 1695 the "genre" and "year" of an album, use: "fields=genre;year". 1697 Parentheses are used to specify sub-selectors of a node. For 1698 example, to retrieve only the "label" and "catalogue-number" of an 1699 album, use: "fields=admin(label;catalogue-number)". 1701 "/" is used in a path to retrieve a child node of a node. For 1702 example, to retrieve only the "label" of an album, use: 1703 "fields=admin/label". 1705 This parameter is only allowed for GET methods on api, datastore, and 1706 data resources. A 400 Bad Request error is returned if used for 1707 other methods or resource types. 1709 If the "fields" query parameter URI is listed in the "capability" 1710 leaf-list in Section 9.3, then the server supports the "fields" 1711 parameter. 1713 4.8.4. The "insert" Query Parameter 1715 The "insert" parameter is used to specify how a resource should be 1716 inserted within a user-ordered list. 1718 The allowed values are: 1720 +--------+----------------------------------------------------------+ 1721 | Value | Description | 1722 +--------+----------------------------------------------------------+ 1723 | first | Insert the new data as the new first entry. | 1724 | last | Insert the new data as the new last entry. | 1725 | before | Insert the new data before the insertion point, as | 1726 | | specified by the value of the "point" parameter. | 1727 | after | Insert the new data after the insertion point, as | 1728 | | specified by the value of the "point" parameter. | 1729 +--------+----------------------------------------------------------+ 1731 The default value is "last". 1733 This parameter is only supported for the POST and PUT methods. It is 1734 also only supported if the target resource is a data resource, and 1735 that data represents a YANG list or leaf-list that is ordered by the 1736 user. 1738 If the values "before" or "after" are used, then a "point" query 1739 parameter for the insertion parameter MUST also be present, or a 400 1740 Bad Request error is returned. 1742 The "insert" query parameter MUST be supported by the server. 1744 4.8.5. The "point" Query Parameter 1746 The "point" parameter is used to specify the insertion point for a 1747 data resource that is being created or moved within a user ordered 1748 list or leaf-list. 1750 The value of the "point" parameter is a string that identifies the 1751 path to the insertion point object. The format is the same as a 1752 target resource URI string. 1754 This parameter is only supported for the POST and PUT methods. It is 1755 also only supported if the target resource is a data resource, and 1756 that data represents a YANG list or leaf-list that is ordered by the 1757 user. 1759 If the "insert" query parameter is not present, or has a value other 1760 than "before" or "after", then a 400 Bad Request error is returned. 1762 This parameter contains the instance identifier of the resource to be 1763 used as the insertion point for a POST or PUT method. 1765 The "point" query parameter MUST be supported by the server. 1767 4.8.6. The "filter" Query Parameter 1769 The "filter" parameter is used to indicate which subset of all 1770 possible events are of interest. If not present, all events not 1771 precluded by other parameters will be sent. 1773 This parameter is only allowed for GET methods on a text/event-stream 1774 data resource. A 400 Bad Request error is returned if used for other 1775 methods or resource types. 1777 The format of this parameter is an XPath 1.0 expression, and is 1778 evaluated in the following context: 1780 o The set of namespace declarations is the set of prefix and 1781 namespace pairs for all supported YANG modules, where the prefix 1782 is the YANG module name, and the namespace is as defined by the 1783 "namespace" statement in the YANG module. 1785 o The function library is the core function library defined in XPath 1786 1.0. 1788 o The set of variable bindings is empty. 1790 o The context node is the root node. 1792 The filter is used as defined in [RFC5277], Section 3.6. If the 1793 boolean result of the expression is true when applied to the 1794 conceptual "notification" document root, then the event notification 1795 is delivered to the client. 1797 If the "filter" query parameter URI is listed in the "capability" 1798 leaf-list in Section 9.3, then the server supports the "filter" query 1799 parameter. 1801 4.8.7. The "start-time" Query Parameter 1803 The "start-time" parameter is used to trigger the notification replay 1804 feature and indicate that the replay should start at the time 1805 specified. If the stream does not support replay, per the 1806 "replay-support" attribute returned by stream list entry for the 1807 stream resource, then the server MUST return the HTTP error code 400 1808 Bad Request. 1810 The value of the "start-time" parameter is of type "date-and-time", 1811 defined in the "ietf-yang" YANG module [RFC6991]. 1813 This parameter is only allowed for GET methods on a text/event-stream 1814 data resource. A 400 Bad Request error is returned if used for other 1815 methods or resource types. 1817 If this parameter is not present, then a replay subscription is not 1818 being requested. It is not valid to specify start times that are 1819 later than the current time. If the value specified is earlier than 1820 the log can support, the replay will begin with the earliest 1821 available notification. 1823 If this query parameter is supported by the server, then the "replay" 1824 query parameter URI MUST be listed in the "capability" leaf-list in 1825 Section 9.3. The "stop-time" query parameter MUST also be supported 1826 by the server. 1828 If the "replay-support" leaf is present in the "stream" entry 1829 (defined in Section 9.3) then the server MUST support the 1830 "start-time" and "stop-time" query parameters for that stream. 1832 4.8.8. The "stop-time" Query Parameter 1834 The "stop-time" parameter is used with the replay feature to indicate 1835 the newest notifications of interest. This parameter MUST be used 1836 with and have a value later than the "start-time" parameter. 1838 The value of the "stop-time" parameter is of type "date-and-time", 1839 defined in the "ietf-yang" YANG module [RFC6991]. 1841 This parameter is only allowed for GET methods on a text/event-stream 1842 data resource. A 400 Bad Request error is returned if used for other 1843 methods or resource types. 1845 If this parameter is not present, the notifications will continue 1846 until the subscription is terminated. Values in the future are 1847 valid. 1849 If this query parameter is supported by the server, then the "replay" 1850 query parameter URI MUST be listed in the "capability" leaf-list in 1851 Section 9.3. The "start-time" query parameter MUST also be supported 1852 by the server. 1854 If the "replay-support" leaf is present in the "stream" entry 1855 (defined in Section 9.3) then the server MUST support the 1856 "start-time" and "stop-time" query parameters for that stream. 1858 4.8.9. The "with-defaults" Query Parameter 1860 The "with-defaults" parameter is used to specify how information 1861 about default data nodes should be returned in response to GET 1862 requests on data resources. 1864 If the server supports this capability, then it MUST implement the 1865 behavior in Section 4.5.1 of [RFC6243], except applied to the 1866 RESTCONF GET operation, instead of the NETCONF operations. 1868 +-------------------+-----------------------------------------------+ 1869 | Value | Description | 1870 +-------------------+-----------------------------------------------+ 1871 | report-all | All data nodes are reported | 1872 | trim | Data nodes set to the YANG default are not | 1873 | | reported | 1874 | explicit | Data nodes set by the client are not reported | 1875 | report-all-tagged | All data nodes are reported and defaults are | 1876 | | tagged | 1877 +-------------------+-----------------------------------------------+ 1878 If the "with-defaults" parameter is set to "report-all" then the 1879 server MUST adhere to the defaults reporting behavior defined in 1880 Section 3.1 of [RFC6243]. 1882 If the "with-defaults" parameter is set to "trim" then the server 1883 MUST adhere to the defaults reporting behavior defined in Section 3.2 1884 of [RFC6243]. 1886 If the "with-defaults" parameter is set to "explicit" then the server 1887 MUST adhere to the defaults reporting behavior defined in Section 3.3 1888 of [RFC6243]. 1890 If the "with-defaults" parameter is set to "report-all-tagged" then 1891 the server MUST adhere to the defaults reporting behavior defined in 1892 Section 3.4 of [RFC6243]. 1894 If the "with-defaults" parameter is not present then the server MUST 1895 adhere to the defaults reporting behavior defined in its "basic-mode" 1896 parameter for the "defaults" protocol capability URI, defined in 1897 Section 9.1.2. 1899 If the server includes the "with-defaults" query parameter URI in the 1900 "capability" leaf-list in Section 9.3, then the "with-defaults" query 1901 parameter MUST be supported. 1903 5. Messages 1905 The RESTCONF protocol uses HTTP entities for messages. A single HTTP 1906 message corresponds to a single protocol method. Most messages can 1907 perform a single task on a single resource, such as retrieving a 1908 resource or editing a resource. The exception is the PATCH method, 1909 which allows multiple datastore edits within a single message. 1911 5.1. Request URI Structure 1913 Resources are represented with URIs following the structure for 1914 generic URIs in [RFC3986]. 1916 A RESTCONF operation is derived from the HTTP method and the request 1917 URI, using the following conceptual fields: 1919 //?# 1920 ^ ^ ^ ^ ^ 1921 | | | | | 1922 method entry resource query fragment 1924 M M O O I 1926 M=mandatory, O=optional, I=ignored 1928 replaced by client with real values 1930 o method: the HTTP method identifying the RESTCONF operation 1931 requested by the client, to act upon the target resource specified 1932 in the request URI. RESTCONF operation details are described in 1933 Section 4. 1935 o entry: the root of the RESTCONF API configured on this HTTP 1936 server, discovered by getting the ".well-known/host-meta" 1937 resource, as described in Section 3.1. 1939 o resource: the path expression identifying the resource that is 1940 being accessed by the operation. If this field is not present, 1941 then the target resource is the API itself, represented by the 1942 media type "application/yang.api". 1944 o query: the set of parameters associated with the RESTCONF message. 1945 These have the familiar form of "name=value" pairs. Most query 1946 parameters are optional to implement by the server and optional to 1947 use by the client. Each optional query parameter is identified by 1948 a URI. The server MUST list the optional query parameter URIs it 1949 supports in the "capabilities" list defined in Section 9.3. 1951 There is a specific set of parameters defined, although the server 1952 MAY choose to support query parameters not defined in this document. 1953 The contents of the any query parameter value MUST be encoded 1954 according to [RFC2396], Section 3.4. Any reserved characters MUST be 1955 encoded with escape sequences, according to [RFC2396], Section 2.4. 1957 o fragment: This field is not used by the RESTCONF protocol. 1959 When new resources are created by the client, a "Location" header is 1960 returned, which identifies the path of the newly created resource. 1961 The client MUST use this exact path identifier to access the resource 1962 once it has been created. 1964 The "target" of an operation is a resource. The "path" field in the 1965 request URI represents the target resource for the operation. 1967 5.2. Message Headers 1969 There are several HTTP header lines utilized in RESTCONF messages. 1970 Messages are not limited to the HTTP headers listed in this section. 1972 HTTP defines which header lines are required for particular 1973 circumstances. Refer to each operation definition section in 1974 Section 4 for examples on how particular headers are used. 1976 There are some request headers that are used within RESTCONF, usually 1977 applied to data resources. The following tables summarize the 1978 headers most relevant in RESTCONF message requests: 1980 +---------------------+---------------------------------------------+ 1981 | Name | Description | 1982 +---------------------+---------------------------------------------+ 1983 | Accept | Response Content-Types that are acceptable | 1984 | Content-Type | The media type of the request body | 1985 | Host | The host address of the server | 1986 | If-Match | Only perform the action if the entity | 1987 | | matches ETag | 1988 | If-Modified-Since | Only perform the action if modified since | 1989 | | time | 1990 | If-Unmodified-Since | Only perform the action if un-modified | 1991 | | since time | 1992 +---------------------+---------------------------------------------+ 1994 RESTCONF Request Headers 1996 The following tables summarize the headers most relevant in RESTCONF 1997 message responses: 1999 +---------------+---------------------------------------------------+ 2000 | Name | Description | 2001 +---------------+---------------------------------------------------+ 2002 | Allow | Valid actions when 405 error returned | 2003 | Cache-Control | The cache control parameters for the response | 2004 | Content-Type | The media type of the response message-body | 2005 | Date | The date and time the message was sent | 2006 | ETag | An identifier for a specific version of a | 2007 | | resource | 2008 | Last-Modified | The last modified date and time of a resource | 2009 | Location | The resource identifier for a newly created | 2010 | | resource | 2011 +---------------+---------------------------------------------------+ 2013 RESTCONF Response Headers 2015 5.3. Message Encoding 2017 RESTCONF messages are encoded in HTTP according to [RFC7230]. The 2018 "utf-8" character set is used for all messages. RESTCONF message 2019 content is sent in the HTTP message-body. 2021 Content is encoded in either JSON or XML format. A server MUST 2022 support XML encoding and MAY support JSON encoding. XML encoding 2023 rules for data nodes are defined in [RFC6020]. The same encoding 2024 rules are used for all XML content. JSON encoding rules are defined 2025 in [I-D.ietf-netmod-yang-json]. This encoding is valid JSON, but 2026 also has special encoding rules to identify module namespaces and 2027 provide consistent type processing of YANG data. 2029 Request input content encoding format is identified with the Content- 2030 Type header. This field MUST be present if a message-body is sent by 2031 the client. 2033 Response output content encoding format is identified with the Accept 2034 header in the request, or if is not specified, the request input 2035 encoding format is used. If there was no request input, then the 2036 default output encoding is XML. File extensions encoded in the 2037 request are not used to identify format encoding. 2039 5.4. RESTCONF Meta-Data 2041 The RESTCONF protocol needs to retrieve the same meta-data that is 2042 used in the NETCONF protocol. Information about default leafs, last- 2043 modified timestamps, etc. are commonly used to annotate 2044 representations of the datastore contents. This meta-data is not 2045 defined in the YANG schema because it applies to the datastore, and 2046 is common across all data nodes. 2048 This information is encoded as attributes in XML. JSON encoding of 2049 meta-data is defined in [I-D.ietf-netmod-yang-metadata]. 2051 5.5. Return Status 2053 Each message represents some sort of resource access. An HTTP 2054 "status-line" header line is returned for each request. If a 4xx or 2055 5xx range status code is returned in the status-line, then the error 2056 information will be returned in the response, according to the format 2057 defined in Section 7.1. 2059 5.6. Message Caching 2061 Since the datastore contents change at unpredictable times, responses 2062 from a RESTCONF server generally SHOULD NOT be cached. 2064 The server SHOULD include a "Cache-Control" header in every response 2065 that specifies whether the response should be cached. A "Pragma" 2066 header specifying "no-cache" MAY also be sent in case the 2067 "Cache-Control" header is not supported. 2069 Instead of using HTTP caching, the client SHOULD track the "ETag" 2070 and/or "Last-Modified" headers returned by the server for the 2071 datastore resource (or data resource if the server supports it). A 2072 retrieval request for a resource can include the "If-None-Match" and/ 2073 or "If-Modified-Since" headers, which will cause the server to return 2074 a "304 Not Modified" status-line if the resource has not changed. 2075 The client MAY use the HEAD method to retrieve just the message 2076 headers, which SHOULD include the "ETag" and "Last-Modified" headers, 2077 if this meta-data is maintained for the target resource. 2079 6. Notifications 2081 The RESTCONF protocol supports YANG-defined event notifications. The 2082 solution preserves aspects of NETCONF Event Notifications [RFC5277] 2083 while utilizing the Server-Sent Events [W3C.CR-eventsource-20121211] 2084 transport strategy. 2086 6.1. Server Support 2088 A RESTCONF server is not required to support RESTCONF notifications. 2089 Clients may determine if a server supports RESTCONF notifications by 2090 using the HTTP operation OPTIONS, HEAD, or GET on the stream list. 2091 The server does not support RESTCONF notifications if an HTTP error 2092 code is returned (e.g., 404 Not Found). 2094 6.2. Event Streams 2096 A RESTCONF server that supports notifications will populate a stream 2097 resource for each notification delivery service access point. A 2098 RESTCONF client can retrieve the list of supported event streams from 2099 a RESTCONF server using the GET operation on the stream list. 2101 The "restconf-state/streams" container definition in the 2102 "ietf-restconf-monitoring" module (defined in Section 9.3) is used to 2103 specify the structure and syntax of the conceptual child resources 2104 within the "streams" resource. 2106 For example: 2108 The client might send the following request: 2110 GET /restconf/data/ietf-restconf-monitoring:restconf-state/ 2111 streams HTTP/1.1 2112 Host: example.com 2113 Accept: application/yang.data+xml 2115 The server might send the following response: 2117 HTTP/1.1 200 OK 2118 Content-Type: application/yang.api+xml 2119 2121 2122 NETCONF 2123 default NETCONF event stream 2124 2125 true 2126 2127 2007-07-08T00:00:00Z 2128 2129 2130 xml 2131 https://example.com/streams/NETCONF 2132 2133 2134 2135 json 2136 https://example.com/streams/NETCONF-JSON 2137 2138 2139 2140 2141 SNMP 2142 SNMP notifications 2143 false 2144 2145 xml 2146 https://example.com/streams/SNMP 2147 2148 2149 2150 syslog-critical 2151 Critical and higher severity 2152 2153 true 2154 2155 2007-07-01T00:00:00Z 2156 2157 2158 xml 2159 2160 https://example.com/streams/syslog-critical 2161 2162 2163 2164 2166 6.3. Subscribing to Receive Notifications 2168 RESTCONF clients can determine the URL for the subscription resource 2169 (to receive notifications) by sending an HTTP GET request for the 2170 "location" leaf with the stream list entry. The value returned by 2171 the server can be used for the actual notification subscription. 2173 The client will send an HTTP GET request for the URL returned by the 2174 server with the "Accept" type "text/event-stream". 2176 The server will treat the connection as an event stream, using the 2177 Server Sent Events [W3C.CR-eventsource-20121211] transport strategy. 2179 The server MAY support query parameters for a GET method on this 2180 resource. These parameters are specific to each notification stream. 2182 For example: 2184 The client might send the following request: 2186 GET /restconf/data/ietf-restconf-monitoring:restconf-state/ 2187 streams/stream=NETCONF/access=xml/location HTTP/1.1 2188 Host: example.com 2189 Accept: application/yang.data+xml 2191 The server might send the following response: 2193 HTTP/1.1 200 OK 2194 Content-Type: application/yang.api+xml 2196 2198 https://example.com/streams/NETCONF 2199 2201 The RESTCONF client can then use this URL value to start monitoring 2202 the event stream: 2204 GET /streams/NETCONF HTTP/1.1 2205 Host: example.com 2206 Accept: text/event-stream 2207 Cache-Control: no-cache 2208 Connection: keep-alive 2210 A RESTCONF client MAY request the server compress the events using 2211 the HTTP header field "Accept-Encoding". For instance: 2213 GET /streams/NETCONF HTTP/1.1 2214 Host: example.com 2215 Accept: text/event-stream 2216 Cache-Control: no-cache 2217 Connection: keep-alive 2218 Accept-Encoding: gzip, deflate 2220 6.3.1. NETCONF Event Stream 2222 The server SHOULD support the "NETCONF" notification stream defined 2223 in [RFC5277]. For this stream, RESTCONF notification subscription 2224 requests MAY specify parameters indicating the events it wishes to 2225 receive. These query parameters are optional to implement, and only 2226 available if the server supports them. 2228 +------------+---------+-------------------------+ 2229 | Name | Section | Description | 2230 +------------+---------+-------------------------+ 2231 | start-time | 4.8.7 | replay event start time | 2232 | stop-time | 4.8.8 | replay event stop time | 2233 | filter | 4.8.6 | boolean content filter | 2234 +------------+---------+-------------------------+ 2236 NETCONF Stream Query Parameters 2238 The semantics and syntax for these query parameters are defined in 2239 the sections listed above. The YANG encoding MUST be converted to 2240 URL-encoded string for use in the request URI. 2242 Refer to Appendix D.3.6 for filter parameter examples. 2244 6.4. Receiving Event Notifications 2246 RESTCONF notifications are encoded according to the definition of the 2247 event stream. The NETCONF stream defined in [RFC5277] is encoded in 2248 XML format. 2250 The structure of the event data is based on the "notification" 2251 element definition in Section 4 of [RFC5277]. It MUST conform to the 2252 schema for the "notification" element in Section 4 of [RFC5277], 2253 except the XML namespace for this element is defined as: 2255 urn:ietf:params:xml:ns:yang:ietf-restconf 2257 For JSON encoding purposes, the module name for the "notification" 2258 element is "ietf-restconf". 2260 Two child nodes within the "notification" container are expected, 2261 representing the event time and the event payload. The "event-time" 2262 node is defined within the "ietf-restconf" module namespace. The 2263 name and namespace of the payload element are determined by the YANG 2264 module containing the notification-stmt. 2266 In the following example, the YANG module "example-mod" is used: 2268 module example-mod { 2269 namespace "http://example.com/event/1.0"; 2271 notification event { 2272 leaf event-class { type string; } 2273 container reporting-entity { 2274 leaf card { type string; } 2275 } 2276 leaf severity { type string; } 2277 } 2278 } 2280 An example SSE event notification encoded using XML: 2282 data: 2284 data: 2013-12-21T00:01:00Z 2285 data: 2286 data: fault 2287 data: 2288 data: Ethernet0 2289 data: 2290 data: major 2291 data: 2292 data: 2294 An example SSE event notification encoded using JSON: 2296 data: { 2297 data: "ietf-restconf:notification": { 2298 data: "event-time": "2013-12-21T00:01:00Z", 2299 data: "example-mod:event": { 2300 data: "event-class": "fault", 2301 data: "reporting-entity": { "card": "Ethernet0" }, 2302 data: "severity": "major" 2303 data: } 2304 data: } 2305 data: } 2307 Alternatively, since neither XML nor JSON are whitespace sensitive, 2308 the above messages can be encoded onto a single line. For example: 2310 For example: ('\' line wrapping added for formatting only) 2312 XML: 2314 data: 2013-12-21T00:01:00ZfaultEthernet0\ 2318 major 2320 JSON: 2322 data: {"ietf-restconf:notification":{"event-time":"2013-12-21\ 2323 T00:01:00Z","example-mod:event":{"event-class": "fault","repor\ 2324 tingEntity":{"card":"Ethernet0"},"severity":"major"}}} 2326 The SSE specifications supports the following additional fields: 2327 event, id and retry. A RESTCONF server MAY send the "retry" field 2328 and, if it does, RESTCONF clients SHOULD use it. A RESTCONF server 2329 SHOULD NOT send the "event" or "id" fields, as there are no 2330 meaningful values that could be used for them that would not be 2331 redundant to the contents of the notification itself. RESTCONF 2332 servers that do not send the "id" field also do not need to support 2333 the HTTP header "Last-Event-Id". RESTCONF servers that do send the 2334 "id" field MUST still support the "startTime" query parameter as the 2335 preferred means for a client to specify where to restart the event 2336 stream. 2338 7. Error Reporting 2340 HTTP status-lines are used to report success or failure for RESTCONF 2341 operations. The element returned in NETCONF error 2342 responses contains some useful information. This error information 2343 is adapted for use in RESTCONF, and error information is returned for 2344 "4xx" class of status codes. 2346 The following table summarizes the return status codes used 2347 specifically by RESTCONF operations: 2349 +---------------------------+---------------------------------------+ 2350 | Status-Line | Description | 2351 +---------------------------+---------------------------------------+ 2352 | 100 Continue | POST accepted, 201 should follow | 2353 | 200 OK | Success with response message-body | 2354 | 201 Created | POST to create a resource success | 2355 | 202 Accepted | POST to create a resource accepted | 2356 | 204 No Content | Success without response message-body | 2357 | 304 Not Modified | Conditional operation not done | 2358 | 400 Bad Request | Invalid request message | 2359 | 403 Forbidden | Access to resource denied | 2360 | 404 Not Found | Resource target or resource node not | 2361 | | found | 2362 | 405 Method Not Allowed | Method not allowed for target | 2363 | | resource | 2364 | 409 Conflict | Resource or lock in use | 2365 | 412 Precondition Failed | Conditional method is false | 2366 | 413 Request Entity Too | too-big error | 2367 | Large | | 2368 | 414 Request-URI Too Large | too-big error | 2369 | 415 Unsupported Media | non RESTCONF media type | 2370 | Type | | 2371 | 500 Internal Server Error | operation-failed | 2372 | 501 Not Implemented | unknown-operation | 2373 | 503 Service Unavailable | Recoverable server error | 2374 +---------------------------+---------------------------------------+ 2376 HTTP Status Codes used in RESTCONF 2378 Since an operation resource is defined with a YANG "rpc" statement, a 2379 mapping between the NETCONF value and the HTTP status 2380 code is needed. The specific error condition and response code to 2381 use are data-model specific and might be contained in the YANG 2382 "description" statement for the "rpc" statement. 2384 +-------------------------+-------------+ 2385 | | status code | 2386 +-------------------------+-------------+ 2387 | in-use | 409 | 2388 | invalid-value | 400 | 2389 | too-big | 413 | 2390 | missing-attribute | 400 | 2391 | bad-attribute | 400 | 2392 | unknown-attribute | 400 | 2393 | bad-element | 400 | 2394 | unknown-element | 400 | 2395 | unknown-namespace | 400 | 2396 | access-denied | 403 | 2397 | lock-denied | 409 | 2398 | resource-denied | 409 | 2399 | rollback-failed | 500 | 2400 | data-exists | 409 | 2401 | data-missing | 409 | 2402 | operation-not-supported | 501 | 2403 | operation-failed | 500 | 2404 | partial-operation | 500 | 2405 | malformed-message | 400 | 2406 +-------------------------+-------------+ 2408 Mapping from error-tag to status code 2410 7.1. Error Response Message 2412 When an error occurs for a request message on a data resource or an 2413 operation resource, and a "4xx" class of status codes (except for 2414 status code "403 Forbidden"), then the server SHOULD send a response 2415 message-body containing the information described by the "errors" 2416 container definition within the YANG module Section 8. The Content- 2417 Type of this response message MUST be application/yang.errors (see 2418 example below). 2420 The client MAY specify the desired encoding for error messages by 2421 specifying the appropriate media-type in the Accept header. If no 2422 error media is specified, the server MUST assume that "application/ 2423 yang.errors+xml" was specified. All of the examples in this 2424 document, except for the one below, assume the default XML encoding 2425 will be returned if there is an error. 2427 YANG Tree Diagram for Data: 2429 +--ro errors 2430 +--ro error 2431 +--ro error-type enumeration 2432 +--ro error-tag string 2433 +--ro error-app-tag? string 2434 +--ro error-path? instance-identifier 2435 +--ro error-message? string 2436 +--ro error-info 2438 The semantics and syntax for RESTCONF error messages are defined in 2439 the "application/yang.errors" restconf-media-type extension in 2440 Section 8. 2442 Examples: 2444 The following example shows an error returned for an "lock-denied" 2445 error that can occur if a NETCONF client has locked a datastore. The 2446 RESTCONF client is attempting to delete a data resource. Note that 2447 an Accept header is used to specify the desired encoding for the 2448 error message. This example's use of the Accept header is especially 2449 notable since the DELETE method typically doesn't return a message- 2450 body and hence Accept headers are typically not passed. 2452 DELETE /restconf/data/example-jukebox:jukebox/ 2453 library/artist=Foo%20Fighters/album=Wasting%20Light HTTP/1.1 2454 Host: example.com 2455 Accept: application/yang.errors+json 2457 The server might respond: 2459 HTTP/1.1 409 Conflict 2460 Date: Mon, 23 Apr 2012 17:11:00 GMT 2461 Server: example-server 2462 Content-Type: application/yang.errors+json 2464 { 2465 "ietf-restconf:errors": { 2466 "error": { 2467 "error-type": "protocol", 2468 "error-tag": "lock-denied", 2469 "error-message": "Lock failed, lock already held" 2470 } 2471 } 2472 } 2474 The following example shows an error returned for a "data-exists" 2475 error on a data resource. The "jukebox" resource already exists so 2476 it cannot be created. 2478 The client might send: 2480 POST /restconf/data/example-jukebox:jukebox HTTP/1.1 2481 Host: example.com 2483 The server might respond (some lines wrapped for display purposes): 2485 HTTP/1.1 409 Conflict 2486 Date: Mon, 23 Apr 2012 17:11:00 GMT 2487 Server: example-server 2488 Content-Type: application/yang.errors+xml 2490 2491 2492 protocol 2493 data-exists 2494 2497 /rc:restconf/rc:data/jb:jukebox 2498 2499 2500 Data already exists, cannot create new resource 2501 2502 2503 2505 8. RESTCONF module 2507 The "ietf-restconf" module defines conceptual definitions within an 2508 extension and two groupings, which are not meant to be implemented as 2509 datastore contents by a server. E.g., the "restconf" container is 2510 not intended to be implemented as a top-level data node (under the 2511 "/restconf/data" entry point). 2513 RFC Ed.: update the date below with the date of RFC publication and 2514 remove this note. 2516 file "ietf-restconf@2015-06-04.yang" 2518 module ietf-restconf { 2519 namespace "urn:ietf:params:xml:ns:yang:ietf-restconf"; 2520 prefix "rc"; 2522 organization 2523 "IETF NETCONF (Network Configuration) Working Group"; 2525 contact 2526 "WG Web: 2527 WG List: 2529 WG Chair: Mehmet Ersue 2530 2532 WG Chair: Mahesh Jethanandani 2533 2535 Editor: Andy Bierman 2536 2538 Editor: Martin Bjorklund 2539 2541 Editor: Kent Watsen 2542 "; 2544 description 2545 "This module contains conceptual YANG specifications 2546 for basic RESTCONF media type definitions used in 2547 RESTCONF protocol messages. 2549 Note that the YANG definitions within this module do not 2550 represent configuration data of any kind. 2551 The 'restconf-media-type' YANG extension statement 2552 provides a normative syntax for XML and JSON message 2553 encoding purposes. 2555 Copyright (c) 2015 IETF Trust and the persons identified as 2556 authors of the code. All rights reserved. 2558 Redistribution and use in source and binary forms, with or 2559 without modification, is permitted pursuant to, and subject 2560 to the license terms contained in, the Simplified BSD License 2561 set forth in Section 4.c of the IETF Trust's Legal Provisions 2562 Relating to IETF Documents 2563 (http://trustee.ietf.org/license-info). 2565 This version of this YANG module is part of RFC XXXX; see 2566 the RFC itself for full legal notices."; 2568 // RFC Ed.: replace XXXX with actual RFC number and remove this 2569 // note. 2571 // RFC Ed.: remove this note 2572 // Note: extracted from draft-ietf-netconf-restconf-06.txt 2573 // RFC Ed.: update the date below with the date of RFC publication 2574 // and remove this note. 2575 revision 2015-06-04 { 2576 description 2577 "Initial revision."; 2578 reference 2579 "RFC XXXX: RESTCONF Protocol."; 2580 } 2582 extension restconf-media-type { 2583 argument media-type-id { 2584 yin-element true; 2585 } 2586 // RFC Ed.: replace draft-ietf-netmod-yang-json with RFC number 2587 // in the description below, and remove this note. 2588 description 2589 "This extension is used to specify a YANG data structure which 2590 represents a conceptual RESTCONF media type. 2591 Data definition statements within this extension specify 2592 the generic syntax for the specific media type. 2594 YANG is mapped to specific encoding formats outside the 2595 scope of this extension statement. RFC 6020 defines XML 2596 encoding rules for all RESTCONF media types that use 2597 the '+xml' suffix. draft-ietf-netmod-yang-json defines 2598 JSON encoding rules for all RESTCONF media types that 2599 use the '+json' suffix. 2601 The 'media-type-id' parameter value identifies the media type 2602 that is being defined. It contains the string associated 2603 with the generic media type, i.e., no suffix is specified. 2605 This extension is ignored unless it appears as a top-level 2606 statement. It SHOULD contain data definition statements 2607 that result in exactly one container data node definition. 2608 This allows compliant translation to an XML instance 2609 document for each media type. 2611 The module name and namespace value for the YANG module using 2612 the extension statement is assigned to instance document data 2613 conforming to the data definition statements within 2614 this extension. 2616 The sub-statements of this extension MUST follow the 2617 'data-def-stmt' rule in the YANG ABNF. 2619 The XPath document root is the extension statement itself, 2620 such that the child nodes of the document root are 2621 represented by the data-def-stmt sub-statements within 2622 this extension. This conceptual document is the context 2623 for the following YANG statements: 2625 - must-stmt 2626 - when-stmt 2627 - path-stmt 2628 - min-elements-stmt 2629 - max-elements-stmt 2630 - mandatory-stmt 2631 - unique-stmt 2632 - ordered-by 2633 - instance-identifier data type 2635 The following data-def-stmt sub-statements have special 2636 meaning when used within a restconf-resource extension 2637 statement. 2639 - The list-stmt is not required to have a key-stmt defined. 2640 - The if-feature-stmt is ignored if present. 2641 - The config-stmt is ignored if present. 2642 - The available identity values for any 'identityref' 2643 leaf or leaf-list nodes is limited to the module 2644 containing this extension statement, and the modules 2645 imported into that module. 2646 "; 2647 } 2649 rc:restconf-media-type "application/yang.errors" { 2650 uses errors; 2651 } 2653 rc:restconf-media-type "application/yang.api" { 2654 uses restconf; 2655 } 2657 grouping errors { 2658 description 2659 "A grouping that contains a YANG container 2660 representing the syntax and semantics of a 2661 YANG Patch errors report within a response message."; 2663 container errors { 2664 description 2665 "Represents an error report returned by the server if 2666 a request results in an error."; 2668 list error { 2669 description 2670 "An entry containing information about one 2671 specific error that occurred while processing 2672 a RESTCONF request."; 2673 reference "RFC 6241, Section 4.3"; 2675 leaf error-type { 2676 type enumeration { 2677 enum transport { 2678 description "The transport layer"; 2679 } 2680 enum rpc { 2681 description "The rpc or notification layer"; 2682 } 2683 enum protocol { 2684 description "The protocol operation layer"; 2685 } 2686 enum application { 2687 description "The server application layer"; 2688 } 2689 } 2690 mandatory true; 2691 description 2692 "The protocol layer where the error occurred."; 2693 } 2695 leaf error-tag { 2696 type string; 2697 mandatory true; 2698 description 2699 "The enumerated error tag."; 2700 } 2702 leaf error-app-tag { 2703 type string; 2704 description 2705 "The application-specific error tag."; 2706 } 2708 leaf error-path { 2709 type instance-identifier; 2710 description 2711 "The YANG instance identifier associated 2712 with the error node."; 2713 } 2715 leaf error-message { 2716 type string; 2717 description 2718 "A message describing the error."; 2719 } 2721 anyxml error-info { 2722 description 2723 "Arbitrary XML that represents a container 2724 of additional information for the error report."; 2725 } 2726 } 2727 } 2728 } 2730 grouping restconf { 2731 description 2732 "Conceptual container representing the 2733 application/yang.api resource type."; 2735 container restconf { 2736 description 2737 "Conceptual container representing the 2738 application/yang.api resource type."; 2740 container data { 2741 description 2742 "Container representing the application/yang.datastore 2743 resource type. Represents the conceptual root of all 2744 operational data and configuration data supported by 2745 the server. The child nodes of this container can be 2746 any data resource (application/yang.data), which are 2747 defined as top-level data nodes from the YANG modules 2748 advertised by the server in the ietf-restconf-monitoring 2749 module."; 2750 } 2752 container operations { 2753 description 2754 "Container for all operation resources 2755 (application/yang.operation), 2757 Each resource is represented as an empty leaf with the 2758 name of the RPC operation from the YANG rpc statement. 2760 E.g.; 2762 POST /restconf/operations/show-log-errors 2764 leaf show-log-errors { 2765 type empty; 2766 } 2767 "; 2768 } 2769 } 2770 } 2772 } 2774 2776 9. RESTCONF Monitoring 2778 The "ietf-restconf-monitoring" module provides information about the 2779 RESTCONF protocol capabilities and event notification streams 2780 available from the server. A RESTCONF server MUST implement the 2781 "/restconf-state/capabilities" container in this module. 2783 YANG Tree Diagram for "ietf-restconf-monitoring" module: 2785 +--ro restconf-state 2786 +--ro capabilities 2787 | +--ro capability* inet:uri 2788 +--ro streams 2789 +--ro stream* [name] 2790 +--ro name string 2791 +--ro description? string 2792 +--ro replay-support? boolean 2793 +--ro replay-log-creation-time? yang:date-and-time 2794 +--ro access* [type] 2795 +--ro encoding string 2796 +--ro location inet:uri 2798 9.1. restconf-state/capabilities 2800 This mandatory container holds the RESTCONF protocol capability URIs 2801 supported by the server. 2803 The server MUST maintain a last-modified timestamp for this 2804 container, and return the "Last-Modified" header when this data node 2805 is retrieved with the GET or HEAD methods. 2807 The server SHOULD maintain an entity-tag for this container, and 2808 return the "ETag" header when this data node is retrieved with the 2809 GET or HEAD methods. 2811 The server MUST include a "capability" URI leaf-list entry for the 2812 "defaults" mode used by the server, defined in Section 9.1.2. 2814 The server MUST include a "capability" URI leaf-list entry 2815 identifying each supported optional protocol feature. This includes 2816 optional query parameters and MAY include other capability URIs 2817 defined outside this document. 2819 9.1.1. Query Parameter URIs 2821 A new set of RESTCONF Capability URIs are defined to identify the 2822 specific query parameters (defined in Section 4.8) supported by the 2823 server. 2825 The server MUST include a "capability" leaf-list entry for each 2826 optional query parameter that it supports. 2828 +------------+--------+---------------------------------------------+ 2829 | Name | Sectio | URI | 2830 | | n | | 2831 +------------+--------+---------------------------------------------+ 2832 | depth | 4.8.2 | urn:ietf:params:restconf:capability:depth:1 | 2833 | | | .0 | 2834 | fields | 4.8.3 | urn:ietf:params:restconf:capability:fields: | 2835 | | | 1.0 | 2836 | filter | 4.8.6 | urn:ietf:params:restconf:capability:filter: | 2837 | | | 1.0 | 2838 | replay | 4.8.7 | urn:ietf:params:restconf:capability:replay: | 2839 | | 4.8.8 | 1.0 | 2840 | with- | 4.8.9 | urn:ietf:params:restconf:capability:with- | 2841 | defaults | | defaults:1.0 | 2842 +------------+--------+---------------------------------------------+ 2844 RESTCONF Query Parameter URIs 2846 9.1.2. The "defaults" Protocol Capability URI 2848 This URI identifies the defaults handling mode that is used by the 2849 server for processing default leafs in requests for data resources. 2850 A parameter named "basic-mode" is required for this capability URI. 2851 The "basic-mode" definitions are specified in the "With-Defaults 2852 Capability for NETCONF" [RFC6243]. 2854 +----------+--------------------------------------------------+ 2855 | Name | URI | 2856 +----------+--------------------------------------------------+ 2857 | defaults | urn:ietf:params:restconf:capability:defaults:1.0 | 2858 +----------+--------------------------------------------------+ 2860 RESTCONF defaults capability URI 2862 This protocol capability URI MUST be supported by the server, and 2863 MUST be listed in the "capability" leaf-list in Section 9.3. 2865 +------------+------------------------------------------------------+ 2866 | Value | Description | 2867 +------------+------------------------------------------------------+ 2868 | report-all | No data nodes are considered default | 2869 | trim | Values set to the YANG default-stmt value are | 2870 | | default | 2871 | explicit | Values set by the client are never considered | 2872 | | default | 2873 +------------+------------------------------------------------------+ 2875 If the "basic-mode" is set to "report-all" then the server MUST 2876 adhere to the defaults handling behavior defined in Section 2.1 of 2877 [RFC6243]. 2879 If the "basic-mode" is set to "trim" then the server MUST adhere to 2880 the defaults handling behavior defined in Section 2.2 of [RFC6243]. 2882 If the "basic-mode" is set to "explicit" then the server MUST adhere 2883 to the defaults handling behavior defined in Section 2.3 of 2884 [RFC6243]. 2886 Example: (split for display purposes only) 2888 urn:ietf:params:restconf:capability:defaults:1.0? 2889 basic-mode=explicit 2891 9.2. restconf-state/streams 2893 This optional container provides access to the event notification 2894 streams supported by the server. The server MAY omit this container 2895 if no event notification streams are supported. 2897 The server will populate this container with a stream list entry for 2898 each stream type it supports. Each stream contains a leaf called 2899 "events" which contains a URI that represents an event stream 2900 resource. 2902 Stream resources are defined in Section 3.8. Notifications are 2903 defined in Section 6. 2905 9.3. RESTCONF Monitoring Module 2907 The "ietf-restconf-monitoring" module defines monitoring information 2908 for the RESTCONF protocol. 2910 The "ietf-yang-types" and "ietf-inet-types" modules from [RFC6991] 2911 are used by this module for some type definitions. 2913 RFC Ed.: update the date below with the date of RFC publication and 2914 remove this note. 2916 file "ietf-restconf-monitoring@2015-06-19.yang" 2918 module ietf-restconf-monitoring { 2919 namespace "urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring"; 2920 prefix "rcmon"; 2922 import ietf-yang-types { prefix yang; } 2923 import ietf-inet-types { prefix inet; } 2925 organization 2926 "IETF NETCONF (Network Configuration) Working Group"; 2928 contact 2929 "WG Web: 2930 WG List: 2932 WG Chair: Mehmet Ersue 2933 2935 WG Chair: Mahesh Jethanandani 2936 2938 Editor: Andy Bierman 2939 2941 Editor: Martin Bjorklund 2942 2944 Editor: Kent Watsen 2945 "; 2947 description 2948 "This module contains monitoring information for the 2949 RESTCONF protocol. 2951 Copyright (c) 2015 IETF Trust and the persons identified as 2952 authors of the code. All rights reserved. 2954 Redistribution and use in source and binary forms, with or 2955 without modification, is permitted pursuant to, and subject 2956 to the license terms contained in, the Simplified BSD License 2957 set forth in Section 4.c of the IETF Trust's Legal Provisions 2958 Relating to IETF Documents 2959 (http://trustee.ietf.org/license-info). 2961 This version of this YANG module is part of RFC XXXX; see 2962 the RFC itself for full legal notices."; 2964 // RFC Ed.: replace XXXX with actual RFC number and remove this 2965 // note. 2967 // RFC Ed.: remove this note 2968 // Note: extracted from draft-ietf-netconf-restconf-06.txt 2970 // RFC Ed.: update the date below with the date of RFC publication 2971 // and remove this note. 2972 revision 2015-06-19 { 2973 description 2974 "Initial revision."; 2975 reference 2976 "RFC XXXX: RESTCONF Protocol."; 2977 } 2979 container restconf-state { 2980 config false; 2981 description 2982 "Contains RESTCONF protocol monitoring information."; 2984 container capabilities { 2985 description 2986 "Contains a list of protocol capability URIs"; 2988 leaf-list capability { 2989 type inet:uri; 2990 description "A RESTCONF protocol capability URI."; 2991 } 2992 } 2994 container streams { 2995 description 2996 "Container representing the notification event streams 2997 supported by the server."; 2998 reference 2999 "RFC 5277, Section 3.4, element."; 3001 list stream { 3002 key name; 3003 description 3004 "Each entry describes an event stream supported by 3005 the server."; 3007 leaf name { 3008 type string; 3009 description "The stream name"; 3010 reference "RFC 5277, Section 3.4, element."; 3011 } 3013 leaf description { 3014 type string; 3015 description "Description of stream content"; 3016 reference 3017 "RFC 5277, Section 3.4, element."; 3018 } 3020 leaf replay-support { 3021 type boolean; 3022 description 3023 "Indicates if replay buffer supported for this stream. 3024 If 'true', then the server MUST support the 'start-time' 3025 and 'stop-time' query parameters for this stream."; 3026 reference 3027 "RFC 5277, Section 3.4, element."; 3028 } 3030 leaf replay-log-creation-time { 3031 when "../replay-support" { 3032 description 3033 "Only present if notification replay is supported"; 3034 } 3035 type yang:date-and-time; 3036 description 3037 "Indicates the time the replay log for this stream 3038 was created."; 3039 reference 3040 "RFC 5277, Section 3.4, 3041 element."; 3042 } 3044 list access { 3045 key encoding; 3046 min-elements 1; 3047 description 3048 "The server will create an entry in this list for each 3049 encoding format that is supported for this stream. 3050 The media type 'application/yang.stream' is expected 3051 for all event streams. This list identifies the 3052 sub-types supported for this stream."; 3054 leaf encoding { 3055 type string; 3056 description 3057 "This is the secondary encoding format within the 3058 'text/event-stream' encoding used by all streams. 3059 The type 'xml' is supported for the media type 3060 'application/yang.stream+xml'. The type 'json' 3061 is supported for the media type 3062 'application/yang.stream+json'."; 3064 } 3066 leaf location { 3067 type inet:uri; 3068 mandatory true; 3069 description 3070 "Contains a URL that represents the entry point 3071 for establishing notification delivery via server 3072 sent events."; 3073 } 3074 } 3075 } 3076 } 3077 } 3079 } 3081 3083 10. YANG Module Library 3085 The "ietf-yang-library" module defined in 3086 [I-D.ietf-netconf-yang-library] provides information about the YANG 3087 modules and submodules used by the RESTCONF server. Implementation 3088 is mandatory for RESTCONF servers. All YANG modules and submodules 3089 used by the server MUST be identified in the YANG module library. 3091 10.1. modules 3093 This mandatory container holds the identifiers for the YANG data 3094 model modules supported by the server. 3096 The server MUST maintain a last-modified timestamp for this 3097 container, and return the "Last-Modified" header when this data node 3098 is retrieved with the GET or HEAD methods. 3100 The server SHOULD maintain an entity-tag for this container, and 3101 return the "ETag" header when this data node is retrieved with the 3102 GET or HEAD methods. 3104 10.1.1. modules/module 3106 This mandatory list contains one entry for each YANG data model 3107 module supported by the server. There MUST be an instance of this 3108 list for every YANG module that is used by the server. 3110 The contents of this list are defined in the "module" YANG list 3111 statement in [I-D.ietf-netconf-yang-library]. 3113 The server MAY maintain a last-modified timestamp for each instance 3114 of this list entry, and return the "Last-Modified" header when this 3115 data node is retrieved with the GET or HEAD methods. If not 3116 supported then the timestamp for the parent "modules" container MAY 3117 be used instead. 3119 The server MAY maintain an entity-tag for each instance of this list 3120 entry, and return the "ETag" header when this data node is retrieved 3121 with the GET or HEAD methods. If not supported then the timestamp 3122 for the parent "modules" container MAY be used instead. 3124 11. IANA Considerations 3126 11.1. The "restconf" Relation Type 3128 This specification registers the "restconf" relation type in the Link 3129 Relation Type Registry defined by [RFC5988]: 3131 Relation Name: restconf 3133 Description: Identifies the root of RESTCONF API as configured 3134 on this HTTP server. The "restconf" relation 3135 defines the root of the API defined in RFCXXXX. 3136 Subsequent revisions of RESTCONF will use alternate 3137 relation values to support protocol versioning. 3139 Reference: RFC XXXX 3141 ` 3143 11.2. YANG Module Registry 3145 This document registers two URIs in the IETF XML registry [RFC3688]. 3146 Following the format in RFC 3688, the following registration is 3147 requested to be made. 3149 URI: urn:ietf:params:xml:ns:yang:ietf-restconf 3150 Registrant Contact: The NETMOD WG of the IETF. 3151 XML: N/A, the requested URI is an XML namespace. 3153 URI: urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring 3154 Registrant Contact: The NETMOD WG of the IETF. 3155 XML: N/A, the requested URI is an XML namespace. 3157 This document registers two YANG modules in the YANG Module Names 3158 registry [RFC6020]. 3160 name: ietf-restconf 3161 namespace: urn:ietf:params:xml:ns:yang:ietf-restconf 3162 prefix: rc 3163 // RFC Ed.: replace XXXX with RFC number and remove this note 3164 reference: RFC XXXX 3166 name: ietf-restconf-monitoring 3167 namespace: urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring 3168 prefix: rcmon 3169 // RFC Ed.: replace XXXX with RFC number and remove this note 3170 reference: RFC XXXX 3172 11.3. application/yang Media Sub Types 3174 The parent MIME media type for RESTCONF resources is application/ 3175 yang, which is defined in [RFC6020]. This document defines the 3176 following sub-types for this media type. 3178 - api 3179 - data 3180 - datastore 3181 - errors 3182 - operation 3183 - stream 3185 Type name: application 3187 Subtype name: yang.xxx 3189 Required parameters: none 3191 Optional parameters: See section 4.8 in RFC XXXX 3193 Encoding considerations: 8-bit 3195 Security considerations: See Section 12 in RFC XXXX 3197 Interoperability considerations: none 3199 // RFC Ed.: replace XXXX with RFC number and remove this note 3200 Published specification: RFC XXXX 3202 11.4. RESTCONF Capability URNs 3204 [Note to RFC Editor: 3205 The RESTCONF Protocol Capability Registry does not yet exist; 3206 Need to ask IANA to create it; remove this note for publication 3207 ] 3209 This document defines a registry for RESTCONF capability identifiers. 3210 The name of the registry is "RESTCONF Capability URNs". The registry 3211 shall record for each entry: 3213 o the name of the RESTCONF capability. By convention, this name is 3214 prefixed with the colon ':' character. 3216 o the URN for the RESTCONF capability. 3218 This document registers several capability identifiers in "RESTCONF 3219 Capability URNs" registry: 3221 Index 3222 Capability Identifier 3223 ------------------------ 3225 :defaults 3226 urn:ietf:params:restconf:capability:defaults:1.0 3228 :depth 3229 urn:ietf:params:restconf:capability:depth:1.0 3231 :fields 3232 urn:ietf:params:restconf:capability:fields:1.0 3234 :filter 3235 urn:ietf:params:restconf:capability:filter:1.0 3237 :replay 3238 urn:ietf:params:restconf:capability:replay:1.0 3240 :with-defaults 3241 urn:ietf:params:restconf:capability:with-defaults:1.0 3243 12. Security Considerations 3245 This section provides security considerations for the resources 3246 defined by the RESTCONF protocol. Security considerations for HTTPS 3247 are defined in [RFC2818]. Security considerations for the content 3248 manipulated by RESTCONF can be found in the documents defining data 3249 models. 3251 This document does not specify an authentication scheme, but it does 3252 require that an authenticated NETCONF username be associated with 3253 each HTTP request. The authentication scheme MAY be implemented in 3254 the underlying transport layer (e.g., client certificates) or within 3255 the HTTP layer (e.g., Basic Auth, OAuth, etc.). RESTCONF does not 3256 itself define an authentication mechanism. Authentication MUST occur 3257 in a lower layer. Implementors SHOULD provide a comprehensive 3258 authorization scheme with RESTCONF and ensure that the resulting 3259 NETCONF username is made available to the RESTCONF server. 3261 Authorization of individual user access to operations and data MAY be 3262 configured via NETCONF Access Control Model (NACM) [RFC6536], as 3263 specified in Section 4. 3265 Configuration information is by its very nature sensitive. Its 3266 transmission in the clear and without integrity checking leaves 3267 devices open to classic eavesdropping and false data injection 3268 attacks. Configuration information often contains passwords, user 3269 names, service descriptions, and topological information, all of 3270 which are sensitive. Because of this, this protocol SHOULD be 3271 implemented carefully with adequate attention to all manner of attack 3272 one might expect to experience with other management interfaces. 3274 Different environments may well allow different rights prior to and 3275 then after authentication. When an operation is not properly 3276 authorized, the RESTCONF server MUST return HTTP error status code 3277 401 Unauthorized. Note that authorization information can be 3278 exchanged in the form of configuration information, which is all the 3279 more reason to ensure the security of the connection. 3281 13. Acknowledgements 3283 The authors would like to thank the following people for their 3284 contributions to this document: Ladislav Lhotka, Juergen 3285 Schoenwaelder, Rex Fernando, Robert Wilton, and Jonathan Hansford. 3287 14. References 3289 14.1. Normative References 3291 [I-D.ietf-netconf-yang-library] 3292 Bierman, A., Bjorklund, M., and K. Watsen, "YANG Module 3293 Library", draft-ietf-netconf-yang-library-01 (work in 3294 progress), July 2015. 3296 [I-D.ietf-netmod-yang-json] 3297 Lhotka, L., "JSON Encoding of Data Modeled with YANG", 3298 draft-ietf-netmod-yang-json-04 (work in progress), June 3299 2015. 3301 [I-D.ietf-netmod-yang-metadata] 3302 Lhotka, L., "Defining and Using Metadata with YANG", 3303 draft-ietf-netmod-yang-metadata-01 (work in progress), 3304 June 2015. 3306 [RFC2046] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 3307 Extensions (MIME) Part Two: Media Types", RFC 2046, 3308 November 1996. 3310 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 3311 Requirement Levels", BCP 14, RFC 2119, March 1997. 3313 [RFC2396] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 3314 Resource Identifiers (URI): Generic Syntax", RFC 2396, 3315 August 1998. 3317 [RFC2818] Rescorla, E., "The IETF XML Registry", RFC 2818, May 2000. 3319 [RFC3688] Mealling, M., "The IETF XML Registry", BCP 81, RFC 3688, 3320 January 2004. 3322 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 3323 Resource Identifier (URI): Generic Syntax", STD 66, RFC 3324 3986, January 2005. 3326 [RFC4252] Ylonen, T. and C. Lonvick, "The Secure Shell (SSH) 3327 Authentication Protocol", RFC 4252, January 2006. 3329 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 3330 (TLS) Protocol Version 1.2", RFC 5246, August 2008. 3332 [RFC5277] Chisholm, S. and H. Trevino, "NETCONF Event 3333 Notifications", RFC 5277, July 2008. 3335 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 3336 Housley, R., and T. Polk, "Internet X.509 Public Key 3337 Infrastructure Certificate and Certificate Revocation List 3338 (CRL) Profile", RFC 5280, May 2008. 3340 [RFC5789] Dusseault, L. and J. Snell, "PATCH Method for HTTP", RFC 3341 5789, March 2010. 3343 [RFC5988] Nottingham, M., "Web Linking", RFC 5988, October 2010. 3345 [RFC6020] Bjorklund, M., "YANG - A Data Modeling Language for the 3346 Network Configuration Protocol (NETCONF)", RFC 6020, 3347 October 2010. 3349 [RFC6125] Saint-Andre, P. and J. Hodges, "Representation and 3350 Verification of Domain-Based Application Service Identity 3351 within Internet Public Key Infrastructure Using X.509 3352 (PKIX) Certificates in the Context of Transport Layer 3353 Security (TLS)", RFC 6125, March 2011. 3355 [RFC6241] Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed., 3356 and A. Bierman, Ed., "Network Configuration Protocol 3357 (NETCONF)", RFC 6241, June 2011. 3359 [RFC6243] Bierman, A. and B. Lengyel, "With-defaults Capability for 3360 NETCONF", RFC 6243, June 2011. 3362 [RFC6415] Hammer-Lahav, E. and B. Cook, "Web Host Metadata", RFC 3363 6415, October 2011. 3365 [RFC6536] Bierman, A. and M. Bjorklund, "Network Configuration 3366 Protocol (NETCONF) Access Control Model", RFC 6536, March 3367 2012. 3369 [RFC6570] Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., 3370 and D. Orchard, "URI Template", RFC 6570, March 2012. 3372 [RFC6991] Schoenwaelder, J., "Common YANG Data Types", RFC 6991, 3373 July 2013. 3375 [RFC7158] Bray, T., Ed., "The JSON Data Interchange Format", RFC 3376 7158, March 2013. 3378 [RFC7230] Fielding, R. and J. Reschke, "Hypertext Transfer Protocol 3379 (HTTP/1.1): Message Syntax and Routing", RFC 7230, June 3380 2014. 3382 [RFC7231] Fielding, R. and J. Reschke, "Hypertext Transfer Protocol 3383 (HTTP/1.1): Semantics and Content", RFC 7231, June 2014. 3385 [RFC7232] Fielding, R. and J. Reschke, "Hypertext Transfer Protocol 3386 (HTTP/1.1): Conditional Requests", RFC 7232, June 2014. 3388 [RFC7235] Fielding, R. and J. Reschke, "Hypertext Transfer Protocol 3389 (HTTP/1.1): Authentication", RFC 7235, June 2014. 3391 [RFC7320] Nottingham, M., "URI Design and Ownership", BCP 190, RFC 3392 7320, July 2014. 3394 [W3C.CR-eventsource-20121211] 3395 Hickson, I., "Server-Sent Events", World Wide Web 3396 Consortium CR CR-eventsource-20121211, December 2012, 3397 . 3399 [W3C.REC-xml-20081126] 3400 Yergeau, F., Maler, E., Paoli, J., Sperberg-McQueen, C., 3401 and T. Bray, "Extensible Markup Language (XML) 1.0 (Fifth 3402 Edition)", World Wide Web Consortium Recommendation REC- 3403 xml-20081126, November 2008, 3404 . 3406 [XPath] Clark, J. and S. DeRose, "XML Path Language (XPath) 3407 Version 1.0", World Wide Web Consortium Recommendation 3408 REC-xpath-19991116, November 1999, 3409 . 3411 [draft-ietf-httpauth-basicauth-update-03] 3412 Reschke, J., "The 'Basic' HTTP Authentication Scheme", 3413 draft-ietf-httpauth-basicauth-update-03 (work in 3414 progress), Dec 2014. 3416 [draft-ietf-httpauth-digest-09] 3417 Shekh-Yusef, R., Reschke, D., and S. Bremer, "HTTP Digest 3418 Access Authentication", draft-ietf-httpauth-digest-09 3419 (work in progress), Dec 2014. 3421 [draft-ietf-netconf-rfc5539bis-10] 3422 Badra, M., Luchuk, A., and J. Schoenwaelder, "Using the 3423 NETCONF Protocol over Transport Layer Security (TLS) with 3424 Mutual X.509 Authentication", draft-ietf-netconf- 3425 rfc5539bis-10 (work in progress), Dec 2014. 3427 [draft-thomson-httpbis-cant-01] 3428 Thomson, M., "Client Authentication over New TLS 3429 Connection", draft-thomson-httpbis-cant-01 (work in 3430 progress), Jul 2014. 3432 14.2. Informative References 3434 [I-D.ietf-netconf-yang-patch] 3435 Bierman, A., Bjorklund, M., and K. Watsen, "YANG Patch 3436 Media Type", draft-ietf-netconf-yang-patch-05 (work in 3437 progress), July 2015. 3439 [rest-dissertation] 3440 Fielding, R., "Architectural Styles and the Design of 3441 Network-based Software Architectures", 2000. 3443 Appendix A. Change Log 3445 -- RFC Ed.: remove this section before publication. 3447 The RESTCONF issue tracker can be found here: https://github.com/ 3448 netconf-wg/restconf/issues 3450 A.1. 06 - 07 3452 o fixed all issues identified in email from Jernej Tuljak in netconf 3453 email 2015-06-22 3455 o fixed error example bug where error-urlpath was still used. 3456 Changed to error-path. 3458 o added mention of YANG Patch and informative reference 3460 A.2. 05 - 06 3462 o fixed RESTCONF issue #23 (ietf-restconf-monitoring bug) 3464 A.3. 04 - 05 3466 o changed term 'notification event' to 'event notification' 3468 o removed intro text about framework and meta-model 3470 o removed early mention of API resources 3472 o removed term unified datastore and cleaned up text about NETCONF 3473 datastores 3475 o removed text about not immediate persistence of edits 3477 o removed RESTCONF-specific data-resource-identifier typedef and its 3478 usage 3480 o clarified encoding of key leafs 3482 o changed several examples from JSON to XML encoding 3484 o made 'insert' and 'point' query parameters mandatory to implement 3486 o removed ":insert" capability URI 3488 o renamed stream/encoding to stream/access 3490 o renamed stream/encoding/type to stream/access/encoding 3492 o renamed stream/encoding/events to stream/access/location 3494 o changed XPath from informative to normative reference 3496 o changed rest-dissertation from normative to informative reference 3498 o changed example-jukebox playlist 'id' from a data-resource- 3499 identifier to a leafref pointing at the song name 3501 A.4. 03 - 04 3503 o renamed 'select' to 'fields' (#1) 3505 o moved collection resource and page capability to draft-ietf- 3506 netconf-restconf-collection-00 (#3) 3508 o added mandatory "defaults" protocol capability URI (#4) 3510 o added optional "with-defaults" query parameter URI (#4) 3512 o clarified authentication procedure (#9) 3514 o moved ietf-yang-library module to draft-ietf-netconf-yang- 3515 library-00 (#13) 3517 o clarified that JSON encoding of module name in a URI MUST follow 3518 the netmod-yang-json encoding rules (#14) 3520 o added restconf-media-type extension (#15) 3522 o remove "content" query parameter URI and made this parameter 3523 mandatory (#16) 3525 o clarified datastore usage 3527 o changed lock-denied error example 3529 o added with-defaults query parameter example 3531 o added term "RESTCONF Capability" 3533 o changed NETCONF Capability URI registry usage to new RESTCONF 3534 Capability URI Registry usage 3536 A.5. 02 - 03 3538 o added collection resource 3540 o added "page" query parameter capability 3542 o added "limit" and "offset" query parameters, which are available 3543 if the "page" capability is supported 3545 o added "stream list" term 3547 o fixed bugs in some examples 3549 o added "encoding" list within the "stream" list to allow different 3550 URLs for XML and JSON encoding. 3552 o made XML MUST implement and JSON MAY implement for servers 3554 o re-add JSON notification examples (previously removed) 3555 o updated JSON references 3557 A.6. 01 - 02 3559 o moved query parameter definitions from the YANG module back to the 3560 plain text sections 3562 o made all query parameters optional to implement 3564 o defined query parameter capability URI 3566 o moved 'streams' to new YANG module (ietf-restconf-monitoring) 3568 o added 'capabilities' container to new YANG module (ietf-restconf- 3569 monitoring) 3571 o moved 'modules' container to new YANG module (ietf-yang-library) 3573 o added new leaf 'module-set-id' (ietf-yang-library) 3575 o added new leaf 'conformance' (ietf-yang-library) 3577 o changed 'schema' leaf to type inet:uri that returns the location 3578 of the YANG schema (instead of returning the schema directly) 3580 o changed 'events' leaf to type inet:uri that returns the location 3581 of the event stream resource (instead of returning events 3582 directly) 3584 o changed examples for yang.api resource since the monitoring 3585 information is no longer in this resource 3587 o closed issue #1 'select parameter' since no objections to the 3588 proposed syntax 3590 o closed "encoding of list keys" issue since no objection to new 3591 encoding of list keys in a target resource URI. 3593 o moved open issues list to the issue tracker on github 3595 A.7. 00 - 01 3597 o fixed content=nonconfig example (non-config was incorrect) 3599 o closed open issue 'message-id'. There is no need for a message-id 3600 field, and RFC 2392 does not apply. 3602 o closed open issue 'server support verification'. The headers used 3603 by RESTCONF are widely supported. 3605 o removed encoding rules from section on RESTCONF Meta-Data. This 3606 is now defined in "I-D.lhotka-netmod-yang-json". 3608 o added media type application/yang.errors to map to errors YANG 3609 grouping. Updated error examples to use new media type. 3611 o closed open issue 'additional datastores'. Support may be added 3612 in the future to identify new datastores. 3614 o closed open issue 'PATCH media type discovery'. The section on 3615 PATCH has an added sentence on the Accept-Patch header. 3617 o closed open issue 'YANG to resource mapping'. Current mapping of 3618 all data nodes to resources will be used in order to allow 3619 mandatory DELETE support. The PATCH operation is optional, as 3620 well as the YANG Patch media type. 3622 o closed open issue '_self links for HATEOAS support'. It was 3623 decided that they are redundant because they can be derived from 3624 the YANG module for the specific data. 3626 o added explanatory text for the 'select' parameter. 3628 o added RESTCONF Path Resolution section for discovering the root of 3629 the RESTCONF API using the /.well-known/host-meta. 3631 o added an "error" media type to for structured error messages 3633 o added Secure Transport section requiring TLS 3635 o added Security Considerations section 3637 o removed all references to "REST-like" 3639 A.8. bierman:restconf-04 to ietf:restconf-00 3641 o updated open issues section 3643 Appendix B. Open Issues 3645 -- RFC Ed.: remove this section before publication. 3647 The RESTCONF issues are tracked on github.com: 3649 https://github.com/netconf-wg/restconf/issues 3651 Appendix C. Example YANG Module 3653 The example YANG module used in this document represents a simple 3654 media jukebox interface. 3656 YANG Tree Diagram for "example-jukebox" Module 3658 +--rw jukebox! 3659 +--rw library 3660 | +--rw artist* [name] 3661 | | +--rw name string 3662 | | +--rw album* [name] 3663 | | +--rw name string 3664 | | +--rw genre? identityref 3665 | | +--rw year? uint16 3666 | | +--rw admin 3667 | | | +--rw label? string 3668 | | | +--rw catalogue-number? string 3669 | | +--rw song* [name] 3670 | | +--rw name string 3671 | | +--rw location string 3672 | | +--rw format? string 3673 | | +--rw length? uint32 3674 | +--ro artist-count? uint32 3675 | +--ro album-count? uint32 3676 | +--ro song-count? uint32 3677 +--rw playlist* [name] 3678 | +--rw name string 3679 | +--rw description? string 3680 | +--rw song* [index] 3681 | +--rw index uint32 3682 | +--rw id leafref 3683 +--rw player 3684 +--rw gap? decimal64 3686 rpcs: 3688 +---x play 3689 +--ro input 3690 +--ro playlist string 3691 +--ro song-number uint32 3693 C.1. example-jukebox YANG Module 3695 module example-jukebox { 3697 namespace "http://example.com/ns/example-jukebox"; 3698 prefix "jbox"; 3699 organization "Example, Inc."; 3700 contact "support at example.com"; 3701 description "Example Jukebox Data Model Module"; 3702 revision "2015-04-04" { 3703 description "Initial version."; 3704 reference "example.com document 1-4673"; 3705 } 3707 identity genre { 3708 description "Base for all genre types"; 3709 } 3711 // abbreviated list of genre classifications 3712 identity alternative { 3713 base genre; 3714 description "Alternative music"; 3715 } 3716 identity blues { 3717 base genre; 3718 description "Blues music"; 3719 } 3720 identity country { 3721 base genre; 3722 description "Country music"; 3723 } 3724 identity jazz { 3725 base genre; 3726 description "Jazz music"; 3727 } 3728 identity pop { 3729 base genre; 3730 description "Pop music"; 3731 } 3732 identity rock { 3733 base genre; 3734 description "Rock music"; 3735 } 3737 container jukebox { 3738 presence 3739 "An empty container indicates that the jukebox 3740 service is available"; 3742 description 3743 "Represents a jukebox resource, with a library, playlists, 3744 and a play operation."; 3746 container library { 3747 description "Represents the jukebox library resource."; 3749 list artist { 3750 key name; 3752 description 3753 "Represents one artist resource within the 3754 jukebox library resource."; 3756 leaf name { 3757 type string { 3758 length "1 .. max"; 3759 } 3760 description "The name of the artist."; 3761 } 3763 list album { 3764 key name; 3766 description 3767 "Represents one album resource within one 3768 artist resource, within the jukebox library."; 3770 leaf name { 3771 type string { 3772 length "1 .. max"; 3773 } 3774 description "The name of the album."; 3775 } 3777 leaf genre { 3778 type identityref { base genre; } 3779 description 3780 "The genre identifying the type of music on 3781 the album."; 3782 } 3784 leaf year { 3785 type uint16 { 3786 range "1900 .. max"; 3787 } 3788 description "The year the album was released"; 3789 } 3791 container admin { 3792 description 3793 "Administrative information for the album."; 3795 leaf label { 3796 type string; 3797 description "The label that released the album."; 3798 } 3799 leaf catalogue-number { 3800 type string; 3801 description "The album's catalogue number."; 3802 } 3803 } 3805 list song { 3806 key name; 3808 description 3809 "Represents one song resource within one 3810 album resource, within the jukebox library."; 3812 leaf name { 3813 type string { 3814 length "1 .. max"; 3815 } 3816 description "The name of the song"; 3817 } 3818 leaf location { 3819 type string; 3820 mandatory true; 3821 description 3822 "The file location string of the 3823 media file for the song"; 3824 } 3825 leaf format { 3826 type string; 3827 description 3828 "An identifier string for the media type 3829 for the file associated with the 3830 'location' leaf for this entry."; 3831 } 3832 leaf length { 3833 type uint32; 3834 units "seconds"; 3835 description 3836 "The duration of this song in seconds."; 3837 } 3838 } // end list 'song' 3839 } // end list 'album' 3840 } // end list 'artist' 3842 leaf artist-count { 3843 type uint32; 3844 units "songs"; 3845 config false; 3846 description "Number of artists in the library"; 3847 } 3848 leaf album-count { 3849 type uint32; 3850 units "albums"; 3851 config false; 3852 description "Number of albums in the library"; 3853 } 3854 leaf song-count { 3855 type uint32; 3856 units "songs"; 3857 config false; 3858 description "Number of songs in the library"; 3859 } 3860 } // end library 3862 list playlist { 3863 key name; 3865 description 3866 "Example configuration data resource"; 3868 leaf name { 3869 type string; 3870 description 3871 "The name of the playlist."; 3872 } 3873 leaf description { 3874 type string; 3875 description 3876 "A comment describing the playlist."; 3877 } 3878 list song { 3879 key index; 3880 ordered-by user; 3882 description 3883 "Example nested configuration data resource"; 3885 leaf index { // not really needed 3886 type uint32; 3887 description 3888 "An arbitrary integer index for this playlist song."; 3889 } 3890 leaf id { 3891 type leafref { 3892 path "/jbox:jukebox/jbox:library/jbox:artist/" + 3893 "jbox:album/jbox:song/jbox:name"; 3894 } 3895 mandatory true; 3896 description 3897 "Song identifier. Must identify an instance of 3898 /jukebox/library/artist/album/song/name."; 3899 } 3900 } 3901 } 3903 container player { 3904 description 3905 "Represents the jukebox player resource."; 3907 leaf gap { 3908 type decimal64 { 3909 fraction-digits 1; 3910 range "0.0 .. 2.0"; 3911 } 3912 units "tenths of seconds"; 3913 description "Time gap between each song"; 3914 } 3915 } 3916 } 3918 rpc play { 3919 description "Control function for the jukebox player"; 3920 input { 3921 leaf playlist { 3922 type string; 3923 mandatory true; 3924 description "playlist name"; 3925 } 3926 leaf song-number { 3927 type uint32; 3928 mandatory true; 3929 description "Song number in playlist to play"; 3930 } 3931 } 3932 } 3933 } 3935 Appendix D. RESTCONF Message Examples 3937 The examples within this document use the normative YANG module 3938 defined in Section 8 and the non-normative example YANG module 3939 defined in Appendix C.1. 3941 This section shows some typical RESTCONF message exchanges. 3943 D.1. Resource Retrieval Examples 3945 D.1.1. Retrieve the Top-level API Resource 3947 The client may start by retrieving the top-level API resource, using 3948 the entry point URI "{+restconf}". 3950 GET /restconf HTTP/1.1 3951 Host: example.com 3952 Accept: application/yang.api+json 3954 The server might respond as follows: 3956 HTTP/1.1 200 OK 3957 Date: Mon, 23 Apr 2012 17:01:00 GMT 3958 Server: example-server 3959 Content-Type: application/yang.api+json 3961 { 3962 "ietf-restconf:restconf": { 3963 "data" : [ null ], 3964 "operations" : { 3965 "play" : [ null ] 3966 } 3967 } 3968 } 3970 To request that the response content to be encoded in XML, the 3971 "Accept" header can be used, as in this example request: 3973 GET /restconf HTTP/1.1 3974 Host: example.com 3975 Accept: application/yang.api+xml 3977 The server will return the same response either way, which might be 3978 as follows : 3980 HTTP/1.1 200 OK 3981 Date: Mon, 23 Apr 2012 17:01:00 GMT 3982 Server: example-server 3983 Cache-Control: no-cache 3984 Pragma: no-cache 3985 Content-Type: application/yang.api+xml 3987 3988 3989 3990 3991 3992 3994 D.1.2. Retrieve The Server Module Information 3996 In this example the client is retrieving the modules information from 3997 the server in JSON format: 3999 GET /restconf/data/ietf-yang-library:modules HTTP/1.1 4000 Host: example.com 4001 Accept: application/yang.data+json 4003 The server might respond as follows. 4005 HTTP/1.1 200 OK 4006 Date: Mon, 23 Apr 2012 17:01:00 GMT 4007 Server: example-server 4008 Cache-Control: no-cache 4009 Pragma: no-cache 4010 Last-Modified: Sun, 22 Apr 2012 01:00:14 GMT 4011 Content-Type: application/yang.data+json 4013 { 4014 "ietf-yang-library:modules": { 4015 "module": [ 4016 { 4017 "name" : "foo", 4018 "revision" : "2012-01-02", 4019 "schema" : "https://example.com/mymodules/foo/2012-01-02", 4020 "namespace" : "http://example.com/ns/foo", 4021 "feature" : [ "feature1", "feature2" ], 4022 "conformance" : "implement" 4023 }, 4024 { 4025 "name" : "foo-types", 4026 "revision" : "2012-01-05", 4027 "schema" : 4029 "https://example.com/mymodules/foo-types/2012-01-05", 4030 "schema" : [null], 4031 "namespace" : "http://example.com/ns/foo-types", 4032 "conformance" : "import" 4033 }, 4034 { 4035 "name" : "bar", 4036 "revision" : "2012-11-05", 4037 "schema" : "https://example.com/mymodules/bar/2012-11-05", 4038 "namespace" : "http://example.com/ns/bar", 4039 "feature" : [ "bar-ext" ], 4040 "conformance" : "implement", 4041 "submodule" : [ 4042 { 4043 "name" : "bar-submod1", 4044 "revision" : "2012-11-05", 4045 "schema" : 4046 "https://example.com/mymodules/bar-submod1/2012-11-05" 4047 }, 4048 { 4049 "name" : "bar-submod2", 4050 "revision" : "2012-11-05", 4051 "schema" : 4052 "https://example.com/mymodules/bar-submod2/2012-11-05" 4053 } 4054 ] 4055 } 4056 ] 4057 } 4058 } 4060 D.1.3. Retrieve The Server Capability Information 4062 In this example the client is retrieving the capability information 4063 from the server in JSON format, and the server supports all the 4064 RESTCONF query parameters, plus one vendor parameter: 4066 GET /restconf/data/ietf-restconf-monitoring:restconf-state/ 4067 capabilities HTTP/1.1 4068 Host: example.com 4069 Accept: application/yang.data+xml 4071 The server might respond as follows. The extra whitespace in 4072 'capability' elements for display purposes only. 4074 HTTP/1.1 200 OK 4075 Date: Mon, 23 Apr 2012 17:02:00 GMT 4076 Server: example-server 4077 Cache-Control: no-cache 4078 Pragma: no-cache 4079 Last-Modified: Sun, 22 Apr 2012 01:00:14 GMT 4080 Content-Type: application/yang.data+xml 4082 4083 4084 urn:ietf:params:restconf:capability:depth:1.0 4085 4086 4087 urn:ietf:params:restconf:capability:fields:1.0 4088 4089 4090 urn:ietf:params:restconf:capability:filter:1.0 4091 4092 4093 urn:ietf:params:restconf:capability:start-time:1.0 4094 4095 4096 urn:ietf:params:restconf:capability:stop-time:1.0 4097 4098 4099 http://example.com/capabilities/myparam 4100 4101 4103 D.2. Edit Resource Examples 4105 D.2.1. Create New Data Resources 4107 To create a new "artist" resource within the "library" resource, the 4108 client might send the following request. 4110 POST /restconf/data/example-jukebox:jukebox/library HTTP/1.1 4111 Host: example.com 4112 Content-Type: application/yang.data+json 4114 { 4115 "example-jukebox:artist" : { 4116 "name" : "Foo Fighters" 4117 } 4118 } 4120 If the resource is created, the server might respond as follows. 4121 Note that the "Location" header line is wrapped for display purposes 4122 only: 4124 HTTP/1.1 201 Created 4125 Date: Mon, 23 Apr 2012 17:02:00 GMT 4126 Server: example-server 4127 Location: https://example.com/restconf/data/ 4128 example-jukebox:jukebox/library/artist=Foo%20Fighters 4129 Last-Modified: Mon, 23 Apr 2012 17:02:00 GMT 4130 ETag: b3830f23a4c 4132 To create a new "album" resource for this artist within the "jukebox" 4133 resource, the client might send the following request. Note that the 4134 request URI header line is wrapped for display purposes only: 4136 POST /restconf/data/example-jukebox:jukebox/ 4137 library/artist=Foo%20Fighters HTTP/1.1 4138 Host: example.com 4139 Content-Type: application/yang.data+json 4141 { 4142 "example-jukebox:album" : { 4143 "name" : "Wasting Light", 4144 "genre" : "example-jukebox:alternative", 4145 "year" : 2012 # note this is the wrong date 4146 } 4147 } 4149 If the resource is created, the server might respond as follows. 4150 Note that the "Location" header line is wrapped for display purposes 4151 only: 4153 HTTP/1.1 201 Created 4154 Date: Mon, 23 Apr 2012 17:03:00 GMT 4155 Server: example-server 4156 Location: https://example.com/restconf/data/ 4157 example-jukebox:jukebox/library/artist=Foo%20Fighters/ 4158 album=Wasting%20Light 4159 Last-Modified: Mon, 23 Apr 2012 17:03:00 GMT 4160 ETag: b8389233a4c 4162 D.2.2. Detect Resource Entity Tag Change 4164 In this example, the server just supports the mandatory datastore 4165 last-changed timestamp. The client has previously retrieved the 4166 "Last-Modified" header and has some value cached to provide in the 4167 following request to patch an "album" list entry with key value 4168 "Wasting Light". Only the "year" field is being updated. 4170 PATCH /restconf/data/example-jukebox:jukebox/ 4171 library/artist=Foo%20Fighters/album=Wasting%20Light/year 4172 HTTP/1.1 4173 Host: example.com 4174 If-Unmodified-Since: Mon, 23 Apr 2012 17:01:00 GMT 4175 Content-Type: application/yang.data+json 4177 { "example-jukebox:year" : "2011" } 4179 In this example the datastore resource has changed since the time 4180 specified in the "If-Unmodified-Since" header. The server might 4181 respond: 4183 HTTP/1.1 412 Precondition Failed 4184 Date: Mon, 23 Apr 2012 19:01:00 GMT 4185 Server: example-server 4186 Last-Modified: Mon, 23 Apr 2012 17:45:00 GMT 4187 ETag: b34aed893a4c 4189 D.2.3. Edit a Datastore Resource 4191 In this example, the client modifies two different data nodes by 4192 sending a PATCH to the datastore resource: 4194 PATCH /restconf/data HTTP/1.1 4195 Host: example.com 4196 Content-Type: application/yang.datastore+xml 4197 4198 4199 4200 4201 Foo Fighters 4202 4203 Wasting Light 4204 2011 4205 4206 4207 4208 Nick Cave 4209 4210 Tender Prey 4211 1988 4212 4213 4214 4215 4216 4218 D.3. Query Parameter Examples 4220 D.3.1. "content" Parameter 4222 The "content" parameter is used to select the type of data child 4223 resources (configuration and/or not configuration) that are returned 4224 by the server for a GET method request. 4226 In this example, a simple YANG list that has configuration and non- 4227 configuration child resources. 4229 container events 4230 list event { 4231 key name; 4232 leaf name { type string; } 4233 leaf description { type string; } 4234 leaf event-count { 4235 type uint32; 4236 config false; 4237 } 4238 } 4239 } 4241 Example 1: content=all 4243 To retrieve all the child resources, the "content" parameter is set 4244 to "all". The client might send: 4246 GET /restconf/data/example-events:events?content=all 4247 HTTP/1.1 4248 Host: example.com 4249 Accept: application/yang.data+json 4251 The server might respond: 4253 HTTP/1.1 200 OK 4254 Date: Mon, 23 Apr 2012 17:11:30 GMT 4255 Server: example-server 4256 Cache-Control: no-cache 4257 Pragma: no-cache 4258 Content-Type: application/yang.data+json 4260 { 4261 "example-events:events" : { 4262 "event" : [ 4263 { 4264 "name" : "interface-up", 4265 "description" : "Interface up notification count", 4266 "event-count" : 42 4267 }, 4268 { 4269 "name" : "interface-down", 4270 "description" : "Interface down notification count", 4271 "event-count" : 4 4272 } 4273 ] 4274 } 4275 } 4277 Example 2: content=config 4279 To retrieve only the configuration child resources, the "content" 4280 parameter is set to "config" or omitted since this is the default 4281 value. Note that the "ETag" and "Last-Modified" headers are only 4282 returned if the content parameter value is "config". 4284 GET /restconf/data/example-events:events?content=config 4285 HTTP/1.1 4286 Host: example.com 4287 Accept: application/yang.data+json 4289 The server might respond: 4291 HTTP/1.1 200 OK 4292 Date: Mon, 23 Apr 2012 17:11:30 GMT 4293 Server: example-server 4294 Last-Modified: Mon, 23 Apr 2012 13:01:20 GMT 4295 ETag: eeeada438af 4296 Cache-Control: no-cache 4297 Pragma: no-cache 4298 Content-Type: application/yang.data+json 4300 { 4301 "example-events:events" : { 4302 "event" : [ 4303 { 4304 "name" : "interface-up", 4305 "description" : "Interface up notification count" 4306 }, 4307 { 4308 "name" : "interface-down", 4309 "description" : "Interface down notification count" 4310 } 4311 ] 4312 } 4313 } 4315 Example 3: content=nonconfig 4317 To retrieve only the non-configuration child resources, the "content" 4318 parameter is set to "nonconfig". Note that configuration ancestors 4319 (if any) and list key leafs (if any) are also returned. The client 4320 might send: 4322 GET /restconf/data/example-events:events?content=nonconfig 4323 HTTP/1.1 4324 Host: example.com 4325 Accept: application/yang.data+json 4327 The server might respond: 4329 HTTP/1.1 200 OK 4330 Date: Mon, 23 Apr 2012 17:11:30 GMT 4331 Server: example-server 4332 Cache-Control: no-cache 4333 Pragma: no-cache 4334 Content-Type: application/yang.data+json 4336 { 4337 "example-events:events" : { 4338 "event" : [ 4339 { 4340 "name" : "interface-up", 4341 "event-count" : 42 4342 }, 4343 { 4344 "name" : "interface-down", 4345 "event-count" : 4 4346 } 4347 ] 4348 } 4349 } 4351 D.3.2. "depth" Parameter 4353 The "depth" parameter is used to limit the number of levels of child 4354 resources that are returned by the server for a GET method request. 4356 The depth parameter starts counting levels at the level of the target 4357 resource that is specified, so that a depth level of "1" includes 4358 just the target resource level itself. A depth level of "2" includes 4359 the target resource level and its child nodes. 4361 This example shows how different values of the "depth" parameter 4362 would affect the reply content for retrieval of the top-level 4363 "jukebox" data resource. 4365 Example 1: depth=unbounded 4367 To retrieve all the child resources, the "depth" parameter is not 4368 present or set to the default value "unbounded". Note that some 4369 strings are wrapped for display purposes only. 4371 GET /restconf/data/example-jukebox:jukebox?depth=unbounded 4372 HTTP/1.1 4373 Host: example.com 4374 Accept: application/yang.data+json 4376 The server might respond: 4378 HTTP/1.1 200 OK 4379 Date: Mon, 23 Apr 2012 17:11:30 GMT 4380 Server: example-server 4381 Cache-Control: no-cache 4382 Pragma: no-cache 4383 Content-Type: application/yang.data+json 4385 { 4386 "example-jukebox:jukebox" : { 4387 "library" : { 4388 "artist" : [ 4389 { 4390 "name" : "Foo Fighters", 4391 "album" : [ 4392 { 4393 "name" : "Wasting Light", 4394 "genre" : "example-jukebox:alternative", 4395 "year" : 2011, 4396 "song" : [ 4397 { 4398 "name" : "Wasting Light", 4399 "location" : 4400 "/media/foo/a7/wasting-light.mp3", 4401 "format" : "MP3", 4402 "length" " 286 4403 }, 4404 { 4405 "name" : "Rope", 4406 "location" : "/media/foo/a7/rope.mp3", 4407 "format" : "MP3", 4408 "length" " 259 4409 } 4410 ] 4411 } 4412 ] 4413 } 4414 ] 4415 }, 4416 "playlist" : [ 4417 { 4418 "name" : "Foo-One", 4419 "description" : "example playlist 1", 4420 "song" : [ 4421 { 4422 "index" : 1, 4423 "id" : "https://example.com/restconf/data/ 4424 example-jukebox:jukebox/library/artist= 4425 Foo%20Fighters/album=Wasting%20Light/ 4426 song=Rope" 4427 }, 4428 { 4429 "index" : 2, 4430 "id" : "https://example.com/restconf/data/ 4431 example-jukebox:jukebox/library/artist= 4432 Foo%20Fighters/album=Wasting%20Light/song= 4433 Bridge%20Burning" 4434 } 4435 ] 4436 } 4437 ], 4438 "player" : { 4439 "gap" : 0.5 4440 } 4441 } 4442 } 4444 Example 2: depth=1 4446 To determine if 1 or more resource instances exist for a given target 4447 resource, the value "1" is used. 4449 GET /restconf/data/example-jukebox:jukebox?depth=1 HTTP/1.1 4450 Host: example.com 4451 Accept: application/yang.data+json 4453 The server might respond: 4455 HTTP/1.1 200 OK 4456 Date: Mon, 23 Apr 2012 17:11:30 GMT 4457 Server: example-server 4458 Cache-Control: no-cache 4459 Pragma: no-cache 4460 Content-Type: application/yang.data+json 4462 { 4463 "example-jukebox:jukebox" : [null] 4464 } 4466 Example 3: depth=3 4468 To limit the depth level to the target resource plus 2 child resource 4469 layers the value "3" is used. 4471 GET /restconf/data/example-jukebox:jukebox?depth=3 HTTP/1.1 4472 Host: example.com 4473 Accept: application/yang.data+json 4475 The server might respond: 4477 HTTP/1.1 200 OK 4478 Date: Mon, 23 Apr 2012 17:11:30 GMT 4479 Server: example-server 4480 Cache-Control: no-cache 4481 Pragma: no-cache 4482 Content-Type: application/yang.data+json 4484 { 4485 "example-jukebox:jukebox" : { 4486 "library" : { 4487 "artist" : [ null ] 4488 }, 4489 "playlist" : [ 4490 { 4491 "name" : "Foo-One", 4492 "description" : "example playlist 1", 4493 "song" : [ null ] 4494 } 4495 ], 4496 "player" : { 4497 "gap" : 0.5 4498 } 4499 } 4500 } 4502 D.3.3. "fields" Parameter 4504 In this example the client is retrieving the API resource, but 4505 retrieving only the "name" and "revision" nodes from each module, in 4506 JSON format: 4508 GET /restconf/data?fields=modules/module(name;revision) HTTP/1.1 4509 Host: example.com 4510 Accept: application/yang.data+json 4512 The server might respond as follows. 4514 HTTP/1.1 200 OK 4515 Date: Mon, 23 Apr 2012 17:01:00 GMT 4516 Server: example-server 4517 Content-Type: application/yang.data+json 4519 { 4520 "ietf-yang-library:modules": { 4521 "module": [ 4522 { 4523 "name" : "example-jukebox", 4524 "revision" : "2015-06-04" 4525 }, 4526 { 4527 "name" : "ietf-inet-types", 4528 "revision" : "2013-07-15" 4529 }, 4530 { 4531 "name" : "ietf-restconf-monitoring", 4532 "revision" : "2015-06-19" 4533 }, 4534 { 4535 "name" : "ietf-yang-library", 4536 "revision" : "2015-07-03" 4537 }, 4538 { 4539 "name" : "ietf-yang-types", 4540 "revision" : "2013-07-15" 4541 } 4543 ] 4544 } 4545 } 4547 D.3.4. "insert" Parameter 4549 In this example, a new first entry in the "Foo-One" playlist is being 4550 created. 4552 Request from client: 4554 POST /restconf/data/example-jukebox:jukebox/ 4555 playlist=Foo-One?insert=first HTTP/1.1 4556 Host: example.com 4557 Content-Type: application/yang.data+json 4559 { 4560 "example-jukebox:song" : { 4561 "index" : 1, 4562 "id" : "/example-jukebox:jukebox/library/ 4563 artist=Foo%20Fighters/album=Wasting%20Light/song=Rope" 4564 } 4565 } 4567 Response from server: 4569 HTTP/1.1 201 Created 4570 Date: Mon, 23 Apr 2012 13:01:20 GMT 4571 Server: example-server 4572 Last-Modified: Mon, 23 Apr 2012 13:01:20 GMT 4573 Location: https://example.com/restconf/data/ 4574 example-jukebox:jukebox/playlist=Foo-One/song=1 4575 ETag: eeeada438af 4577 D.3.5. "point" Parameter 4579 In this example, the client is inserting a new "song" resource within 4580 an "album" resource after another song. The request URI is split for 4581 display purposes only. 4583 Request from client: 4585 POST /restconf/data/example-jukebox:jukebox/ 4586 library/artist=Foo%20Fighters/album=Wasting%20Light? 4587 insert=after&point=%2Fexample-jukebox%3Ajukebox%2F 4588 library%2Fartist%2FFoo%20Fighters%2Falbum%2F 4589 Wasting%20Light%2Fsong%2FBridge%20Burning HTTP/1.1 4590 Host: example.com 4591 Content-Type: application/yang.data+json 4593 { 4594 "example-jukebox:song" : { 4595 "name" : "Rope", 4596 "location" : "/media/foo/a7/rope.mp3", 4597 "format" : "MP3", 4598 "length" : 259 4599 } 4600 } 4602 Response from server: 4604 HTTP/1.1 204 No Content 4606 1. Date: Mon, 23 Apr 2012 13:01:20 GMT Server: example-server Last- 4607 Modified: Mon, 23 Apr 2012 13:01:20 GMT ETag: abcada438af 4609 D.3.6. "filter" Parameter 4611 The following URIs show some examples of notification filter 4612 specifications (lines wrapped for display purposes only): 4614 // filter = /event/event-class='fault' 4615 GET /mystreams/NETCONF?filter=%2Fevent%2Fevent-class%3D'fault' 4617 // filter = /event/severity<=4 4618 GET /mystreams/NETCONF?filter=%2Fevent%2Fseverity%3C%3D4 4620 // filter = /linkUp|/linkDown 4621 GET /mystreams/SNMP?filter=%2FlinkUp%7C%2FlinkDown 4623 // filter = /*/reporting-entity/card!='Ethernet0' 4624 GET /mystreams/NETCONF? 4625 filter=%2F*%2Freporting-entity%2Fcard%21%3D'Ethernet0' 4627 // filter = /*/email-addr[contains(.,'company.com')] 4628 GET /mystreams/critical-syslog? 4629 filter=%2F*%2Femail-addr[contains(.%2C'company.com')] 4631 // Note: the module name is used as prefix. 4632 // filter = (/example-mod:event1/name='joe' and 4633 // /example-mod:event1/status='online') 4634 GET /mystreams/NETCONF? 4635 filter=(%2Fexample-mod%3Aevent1%2Fname%3D'joe'%20and 4636 %20%2Fexample-mod%3Aevent1%2Fstatus%3D'online') 4638 D.3.7. "start-time" Parameter 4640 // start-time = 2014-10-25T10:02:00Z 4641 GET /mystreams/NETCONF?start-time=2014-10-25T10%3A02%3A00Z 4643 D.3.8. "stop-time" Parameter 4645 // stop-time = 2014-10-25T12:31:00Z 4646 GET /mystreams/NETCONF?stop-time=2014-10-25T12%3A31%3A00Z 4648 D.3.9. "with-defaults" Parameter 4650 Assume the same data model as defined in Appendix A.1 of [RFC6243]. 4651 Assume the same data set as defined in Appendix A.2 of [RFC6243]. If 4652 the server defaults-uri basic-mode is "trim", the the following 4653 request for interface "eth1" might be as follows: 4655 Without query parameter: 4657 GET /restconf/data/interfaces/interface=eth1 HTTP/1.1 4658 Host: example.com 4659 Accept: application/yang.data+json 4661 The server might respond as follows. 4663 HTTP/1.1 200 OK 4664 Date: Mon, 23 Apr 2012 17:01:00 GMT 4665 Server: example-server 4666 Content-Type: application/yang.data+json 4668 { 4669 "example:interface": [ 4670 { 4671 "name" : "eth1", 4672 "status" : "up" 4673 } 4674 ] 4675 } 4677 Note that the "mtu" leaf is missing because it is set to the default 4678 "1500", and the server defaults handling basic-mode is "trim". 4680 With query parameter: 4682 GET /restconf/data/interfaces/interface=eth1 4683 ?with-defaults=report-all HTTP/1.1 4684 Host: example.com 4685 Accept: application/yang.data+json 4687 The server might respond as follows. 4689 HTTP/1.1 200 OK 4690 Date: Mon, 23 Apr 2012 17:01:00 GMT 4691 Server: example-server 4692 Content-Type: application/yang.data+json 4694 { 4695 "example:interface": [ 4696 { 4697 "name" : "eth1", 4698 "mtu" : 1500, 4699 "status" : "up" 4700 } 4701 ] 4702 } 4704 Note that the server returns the "mtu" leaf because the "report-all" 4705 mode was requested with the "with-defaults" query parameter. 4707 Authors' Addresses 4709 Andy Bierman 4710 YumaWorks 4712 Email: andy@yumaworks.com 4714 Martin Bjorklund 4715 Tail-f Systems 4717 Email: mbj@tail-f.com 4719 Kent Watsen 4720 Juniper Networks 4722 Email: kwatsen@juniper.net