idnits 2.17.1 draft-ietf-netconf-restconf-06.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 1920 has weird spacing: '... method entry...' == Line 2793 has weird spacing: '...ncoding strin...' == Line 2794 has weird spacing: '...ocation inet:...' == Line 3656 has weird spacing: '...ocation str...' == Line 3666 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 (June 20, 2015) is 3205 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-00 == Outdated reference: A later version (-10) exists of draft-ietf-netmod-yang-json-03 == Outdated reference: A later version (-07) exists of draft-ietf-netmod-yang-metadata-00 ** 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-04 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: December 22, 2015 Tail-f Systems 6 K. Watsen 7 Juniper Networks 8 June 20, 2015 10 RESTCONF Protocol 11 draft-ietf-netconf-restconf-06 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 December 22, 2015. 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. 05 - 06 . . . . . . . . . . . . . . . . . . . . . . . . . 75 147 A.2. 04 - 05 . . . . . . . . . . . . . . . . . . . . . . . . . 75 148 A.3. 03 - 04 . . . . . . . . . . . . . . . . . . . . . . . . . 76 149 A.4. 02 - 03 . . . . . . . . . . . . . . . . . . . . . . . . . 77 150 A.5. 01 - 02 . . . . . . . . . . . . . . . . . . . . . . . . . 77 151 A.6. 00 - 01 . . . . . . . . . . . . . . . . . . . . . . . . . 78 152 A.7. bierman:restconf-04 to ietf:restconf-00 . . . . . . . . . 79 153 Appendix B. Open Issues . . . . . . . . . . . . . . . . . . . . 79 154 Appendix C. Example YANG Module . . . . . . . . . . . . . . . . 79 155 C.1. example-jukebox YANG Module . . . . . . . . . . . . . . . 80 156 Appendix D. RESTCONF Message Examples . . . . . . . . . . . . . 85 157 D.1. Resource Retrieval Examples . . . . . . . . . . . . . . . 86 158 D.1.1. Retrieve the Top-level API Resource . . . . . . . . . 86 159 D.1.2. Retrieve The Server Module Information . . . . . . . 87 160 D.1.3. Retrieve The Server Capability Information . . . . . 88 161 D.2. Edit Resource Examples . . . . . . . . . . . . . . . . . 89 162 D.2.1. Create New Data Resources . . . . . . . . . . . . . . 89 163 D.2.2. Detect Resource Entity Tag Change . . . . . . . . . . 90 164 D.2.3. Edit a Datastore Resource . . . . . . . . . . . . . . 91 165 D.3. Query Parameter Examples . . . . . . . . . . . . . . . . 92 166 D.3.1. "content" Parameter . . . . . . . . . . . . . . . . . 92 167 D.3.2. "depth" Parameter . . . . . . . . . . . . . . . . . . 95 168 D.3.3. "fields" Parameter . . . . . . . . . . . . . . . . . 98 169 D.3.4. "insert" Parameter . . . . . . . . . . . . . . . . . 99 170 D.3.5. "point" Parameter . . . . . . . . . . . . . . . . . . 100 171 D.3.6. "filter" Parameter . . . . . . . . . . . . . . . . . 101 172 D.3.7. "start-time" Parameter . . . . . . . . . . . . . . . 101 173 D.3.8. "stop-time" Parameter . . . . . . . . . . . . . . . . 101 174 D.3.9. "with-defaults" Parameter . . . . . . . . . . . . . . 102 175 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 103 177 1. Introduction 179 There is a need for standard mechanisms to allow Web applications to 180 access the configuration data, operational data, data-model specific 181 protocol operations, and event notifications within a networking 182 device, in a modular and extensible manner. 184 This document describes an HTTP [RFC7230] based protocol called 185 RESTCONF, for accessing data defined in YANG [RFC6020], using 186 datastores defined in NETCONF [RFC6241]. 188 The NETCONF protocol defines configuration datastores and a set of 189 Create, Retrieve, Update, Delete (CRUD) operations that can be used 190 to access these datastores. The YANG language defines the syntax and 191 semantics of datastore content, operational data, protocol 192 operations, and event notifications. RESTCONF uses HTTP operations 193 to provide CRUD operations on a NETCONF datastore containing YANG- 194 defined data. Since NETCONF protocol operations are not relevant, 195 the user should not need any prior knowledge of NETCONF in order to 196 use RESTCONF. 198 Configuration data and state data are exposed as resources that can 199 be retrieved with the GET method. Resources representing 200 configuration data can be modified with the DELETE, PATCH, POST, and 201 PUT methods. Data is encoded with either XML [W3C.REC-xml-20081126] 202 or JSON [RFC7158]. 204 Data-model specific protocol operations defined with the YANG "rpc" 205 statement can be invoked with the POST method. Data-model specific 206 event notifications defined with the YANG "notification" statement 207 can be accessed. 209 1.1. Simple Subset of NETCONF Functionality 211 An HTTP-based management protocol does not need to mirror the 212 functionality of the NETCONF protocol, but it needs to be compatible 213 with NETCONF. A simplified transaction model is needed that allows 214 basic CRUD operations on a hierarchy of conceptual resources. This 215 represents a limited subset of the transaction capabilities of the 216 NETCONF protocol. 218 The HTTP POST, PUT, PATCH, and DELETE methods are used to edit data 219 resources represented by YANG data models. These basic edit 220 operations allow the running configuration to be altered in an all- 221 or-none fashion. This is similar to the "rollback-on-error" 222 capability in NETCONF. Edits are usually applied to one data 223 resource instance at a time. 225 The base RESTCONF protocol is intentionally simple to allow 226 deployment for as many use cases as possible. Additional 227 functionality can be defined in external documents, outside the scope 228 of this document. 230 RESTCONF is not intended to replace NETCONF, but rather provide an 231 additional simplified interface that follows REST principles and is 232 compatible with a resource-oriented device abstraction. 234 The following figure shows the system components: 236 +-----------+ +-----------------+ 237 | Web app | <-------> | | 238 +-----------+ HTTP | network device | 239 | | 240 +-----------+ | +-----------+ | 241 | NMS app | <-------> | | datastore | | 242 +-----------+ NETCONF | +-----------+ | 243 +-----------------+ 245 1.2. Data Model Driven API 247 RESTCONF combines the simplicity of the HTTP protocol with the 248 predictability and automation potential of a schema-driven API. 249 Using YANG, a client can predict all resource endpoints, much like 250 using URI Templates [RFC6570], but in a more holistic manner. This 251 strategy obviates the need for responses provided by the server to 252 contain HATEOAS links, originally described in Roy Fielding's 253 doctoral dissertation [rest-dissertation]. 255 In contrast, a REST client using HATEOAS principles would not use any 256 data modeling language to define the application-specific content of 257 the API. The client would need to discover each new child resource 258 as it traverses the URIs to discover the server capabilities. This 259 approach has the following significant weaknesses with regards to 260 control of complex networking devices: 262 o inefficient performance: configuration APIs will be quite complex 263 and may require thousands of protocol messages to discover all the 264 schema information. Typically the data type information has to be 265 passed in the protocol messages, which is also wasteful overhead. 267 o no data model richness: without a data model, the schema-level 268 semantics and validation constraints are not available to the 269 application. 271 o no tool automation: API automation tools need some sort of content 272 schema to function. Such tools can automate various programming 273 and documentation tasks related to specific data models. 275 Data models such as YANG modules serve as an "API contract" that will 276 be honored by the server. An application designer can code to the 277 data model, knowing in advance important details about the exact 278 protocol operations and datastore content a conforming server 279 implementation will support. 281 RESTCONF provides the YANG module capability information supported by 282 the server, in case the client wants to use it. The URIs for custom 283 protocol operations and datastore content are predictable, based on 284 the YANG module definitions. 286 Operational experience with CLI and SNMP indicates that operators 287 learn the 'location' of specific service or device related data and 288 do not expect such information to be arbitrary and discovered each 289 time the client opens a management session to a server. 291 The RESTCONF protocol operates on a conceptual datastore defined with 292 the YANG data modeling language. The server lists each YANG module 293 it supports using the "ietf-yang-library" YANG module, defined in 294 [I-D.ietf-netconf-yang-library]. The server MUST implement the 295 "ietf-yang-library" module, which SHOULD identify all the YANG 296 modules used by the server. 298 The conceptual datastore contents, data-model-specific operations and 299 event notifications are identified by this set of YANG modules. All 300 RESTCONF content identified as either a data resource, operation 301 resource, or event stream resource is defined with the YANG language. 303 The classification of data as configuration or non-configuration is 304 derived from the YANG "config" statement. Data ordering behavior is 305 derived from the YANG "ordered-by" statement. 307 The RESTCONF datastore editing model is simple and direct, similar to 308 the behavior of the :writable-running capability in NETCONF. Each 309 RESTCONF edit of a datastore resource is activated upon successful 310 completion of the transaction. 312 1.3. Coexistence with NETCONF 314 RESTCONF can be implemented on a device that supports NETCONF. 316 If the device supports :writable-running, all edits to configuration 317 nodes in {+restconf}/data are performed in the running configuration 318 datastore. 320 Otherwise, if the device supports :candidate, all edits to 321 configuration nodes in {+restconf}/data are performed in the 322 candidate configuration datastore. The candidate is automatically 323 committed to running after a successful edit. 325 If the device supports :startup, the device automatically copies the 326 content of running to startup after running has been updated as a 327 consequence of a RESTCONF edit operation. 329 If a datastore that would be modified by a RESTCONF operation has an 330 active lock, the RESTCONF edit operation MUST fail with a 409 331 (Conflict) error code. 333 1.4. Terminology 335 The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 336 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 337 "OPTIONAL" in this document are to be interpreted as described in BCP 338 14, [RFC2119]. 340 1.4.1. NETCONF 342 The following terms are defined in [RFC6241]: 344 o candidate configuration datastore 346 o client 348 o configuration data 350 o datastore 352 o configuration datastore 354 o protocol operation 356 o running configuration datastore 358 o server 360 o startup configuration datastore 362 o state data 364 o user 366 1.4.2. HTTP 368 The following terms are defined in [RFC3986]: 370 o fragment 372 o path 374 o query 376 The following terms are defined in [RFC7230]: 378 o header 380 o message-body 382 o request-line 384 o request URI 386 o status-line 388 The following terms are defined in [RFC7231]: 390 o method 392 o request 394 o resource 396 The following terms are defined in [RFC7232]: 398 o entity tag 400 1.4.3. YANG 402 The following terms are defined in [RFC6020]: 404 o container 406 o data node 408 o key leaf 410 o leaf 412 o leaf-list 414 o list 416 o presence container (or P-container) 418 o RPC operation (now called protocol operation) 420 o non-presence container (or NP-container) 422 o ordered-by system 424 o ordered-by user 426 1.4.4. Terms 428 The following terms are used within this document: 430 o API resource: a resource with the media type "application/ 431 yang.api+xml" or "application/yang.api+json". 433 o data resource: a resource with the media type "application/ 434 yang.data+xml" or "application/yang.data+json". Containers, 435 leafs, list entries and anyxml nodes can be data resources. 437 o datastore resource: a resource with the media type "application/ 438 yang.datastore+xml" or "application/yang.datastore+json". 439 Represents a datastore. 441 o edit operation: a RESTCONF operation on a data resource using 442 either a POST, PUT, PATCH, or DELETE method. 444 o event stream resource: This resource represents an SSE (Server- 445 Sent Events) event stream. The content consists of text using the 446 media type "text/event-stream", as defined by the HTML5 447 specification. Each event represents one message 448 generated by the server. It contains a conceptual system or data- 449 model specific event that is delivered within an event 450 notification stream. Also called a "stream resource". 452 o media-type: HTTP uses Internet media types [RFC2046] in the 453 Content-Type and Accept header fields in order to provide open and 454 extensible data typing and type negotiation. 456 o operation: the conceptual RESTCONF operation for a message, 457 derived from the HTTP method, request URI, headers, and message- 458 body. 460 o operation resource: a resource with the media type "application/ 461 yang.operation+xml" or "application/yang.operation+json". 463 o patch: a generic PATCH request on the target datastore or data 464 resource. The media type of the message-body content will 465 identify the patch type in use. 467 o plain patch: a specific PATCH request type that can be used for 468 simple merge operations. 470 o query parameter: a parameter (and its value if any), encoded 471 within the query component of the request URI. 473 o RESTCONF capability: An optional RESTCONF protocol feature 474 supported by the server, which is identified by an IANA registered 475 NETCONF Capability URI, and advertised with an entry in the 476 "capability" leaf-list in Section 9.3. 478 o retrieval request: a request using the GET or HEAD methods. 480 o target resource: the resource that is associated with a particular 481 message, identified by the "path" component of the request URI. 483 o schema resource: a resource with the media type "application/ 484 yang". The YANG representation of the schema can be retrieved by 485 the client with the GET method. 487 o stream list: the set of data resource instances that describe the 488 event stream resources available from the server. This 489 information is defined in the "ietf-restconf-monitoring" module as 490 the "stream" list. It can be retrieved using the target resource 491 "{+restconf}/data/ietf-restconf-monitoring:restconf-state/streams/ 492 stream". The stream list contains information about each stream, 493 such as the URL to retrieve the event stream data. 495 1.4.5. URI Template 497 Throughout this document, the URI template [RFC6570] syntax 498 "{+restconf}" is used to refer to the RESTCONF API entry point 499 outside of an example. See Section 3.1 for details. 501 For simplicity, all of the examples in this document assume 502 "/restconf" as the discovered RESTCONF API root path. 504 1.4.6. Tree Diagrams 506 A simplified graphical representation of the data model is used in 507 this document. The meaning of the symbols in these diagrams is as 508 follows: 510 o Brackets "[" and "]" enclose list keys. 512 o Abbreviations before data node names: "rw" means configuration 513 data (read-write) and "ro" state data (read-only). 515 o Symbols after data node names: "?" means an optional node, "!" 516 means a presence container, and "*" denotes a list and leaf-list. 518 o Parentheses enclose choice and case nodes, and case nodes are also 519 marked with a colon (":"). 521 o Ellipsis ("...") stands for contents of subtrees that are not 522 shown. 524 2. Transport Protocol Requirements 526 2.1. Integrity and Confidentiality 528 HTTP [RFC7230] is an application layer protocol that may be layered 529 on any reliable transport-layer protocol. RESTCONF is defined on top 530 of HTTP, but due to the sensitive nature of the information conveyed, 531 RESTCONF requires that the transport-layer protocol provides both 532 data integrity and confidentiality, such as are provided by the TLS 533 protocol [RFC5246]. 535 2.2. HTTPS with X.509v3 Certificates 537 Given the nearly ubiquitous support for HTTP over TLS [RFC7230], 538 RESTCONF implementations MUST support the "https" URI scheme, which 539 has the IANA assigned default port 443. Consistent with the 540 exclusive use of X.509v3 certificates for NETCONF over TLS 541 [draft-ietf-netconf-rfc5539bis-10], use of certificates in RESTCONF 542 is also limited to X.509v3 certificates. 544 2.3. Certificate Validation 546 When presented an X.509 certificate, the RESTCONF peer MUST use X.509 547 certificate path validation [RFC5280] to verify the integrity of the 548 certificate. The presented X.509 certificate MAY also be considered 549 valid if it matches a locally configured certificate fingerprint. If 550 X.509 certificate path validation fails and the presented X.509 551 certificate does not match a locally configured certificate 552 fingerprint, the connection MUST be terminated as defined in 553 [RFC5246]. 555 2.4. Authenticated Server Identity 557 The RESTCONF client MUST carefully examine the certificate presented 558 by the RESTCONF server to determine if it meets the client's 559 expectations. The RESTCONF client MUST check the identity of the 560 server according to Section 6 of [RFC6125], including processing the 561 outcome as described in Section 6.6 of [RFC6125]. 563 2.5. Authenticated Client Identity 565 The RESTCONF server MUST authenticate client access to any protected 566 resource using HTTP Authentication [RFC7235]. If the RESTCONF client 567 is not authenticated to access a resource, the server MUST send a 568 response with status code 401 (Unauthorized) and a WWW-Authenticate 569 header field containing at least one challenge applicable to the 570 target resource. The RESTCONF server MAY advertise support for any 571 number of authentication schemes but, in order to ensure 572 interoperability, the RESTCONF server MUST advertise at least one of 573 the following authentication schemes: 575 o Basic [draft-ietf-httpauth-basicauth-update-03] 577 o Digest [draft-ietf-httpauth-digest-09] 579 o ClientCertificate [draft-thomson-httpbis-cant-01] 581 These authentication schemes are selected for to their similarity to 582 the authentication schemes supported by NETCONF. In particular, the 583 Basic and Digest authentication schemes both directly provide an 584 identity and verification of a shared secret, much like NETCONF over 585 SSH, when using the SSH "password" authentication method [RFC4252]. 586 Similarly, the ClientCertificate authentication scheme is much like 587 NETCONF over TLS's use of X.509 client-certificates. When using the 588 ClientCertificate authentication scheme, the RESTCONF server MUST 589 derive the identity of the RESTCONF client using the algorithm 590 defined in Section 7 of [draft-ietf-netconf-rfc5539bis-10]. 592 The RESTCONF client identity determined from any HTTP authentication 593 scheme is hereafter known as the "RESTCONF username" and subject to 594 the NETCONF Access Control Module (NACM) [RFC6536]. 596 3. Resources 598 The RESTCONF protocol operates on a hierarchy of resources, starting 599 with the top-level API resource itself (Section 3.1). Each resource 600 represents a manageable component within the device. 602 A resource can be considered a collection of conceptual data and the 603 set of allowed methods on that data. It can contain nested child 604 resources. The child resource types and methods allowed on them are 605 data-model specific. 607 A resource has its own media type identifier, represented by the 608 "Content-Type" header in the HTTP response message. A resource can 609 contain zero or more nested resources. A resource can be created and 610 deleted independently of its parent resource, as long as the parent 611 resource exists. 613 All RESTCONF resources are defined in this document except specific 614 datastore contents, protocol operations, and event notifications. 615 The syntax and semantics for these resource types are defined in YANG 616 modules. 618 The RESTCONF resources are accessed via a set of URIs defined in this 619 document. The set of YANG modules supported by the server will 620 determine the data model specific operations, top-level data node 621 resources, and event notification messages supported by the server. 623 The RESTCONF protocol does not include a resource discovery 624 mechanism. Instead, the definitions within the YANG modules 625 advertised by the server are used to construct a predictable 626 operation or data resource identifier. 628 3.1. Root Resource Discovery 630 In line with the best practices defined by [RFC7320], RESTCONF 631 enables deployments to specify where the RESTCONF API is located. 632 When first connecting to a RESTCONF server, a RESTCONF client MUST 633 determine the root of the RESTCONF API. The client discovers this by 634 getting the "/.well-known/host-meta" resource ([RFC6415]) and using 635 the element containing the "restconf" attribute : 637 Request 638 ------- 639 GET /.well-known/host-meta users HTTP/1.1 640 Host: example.com 641 Accept: application/xrd+xml 643 Response 644 -------- 645 HTTP/1.1 200 OK 646 Content-Type: application/xrd+xml 647 Content-Length: nnn 649 650 651 653 Once discovering the RESTCONF API root, the client MUST prepend it to 654 any subsequent request to a RESTCONF resource. For instance, using 655 the "/restconf" path discovered above, the client can now determine 656 the operations supported by the the server. In this example a custom 657 "play" operation is supported: 659 Request 660 ------- 661 GET /restconf/operations HTTP/1.1 662 Host: example.com 663 Accept: application/yang.api+json 665 Response 666 -------- 667 HTTP/1.1 200 OK 668 Date: Mon, 23 Apr 2012 17:01:00 GMT 669 Server: example-server 670 Cache-Control: no-cache 671 Pragma: no-cache 672 Last-Modified: Sun, 22 Apr 2012 01:00:14 GMT 673 Content-Type: application/yang.api+json 675 { "operations" : { "play" : [ null ] } } 677 3.2. RESTCONF Resource Types 679 The RESTCONF protocol defines a set of application specific media 680 types to identify each of the available resource types. The 681 following resource types are defined in RESTCONF: 683 +-----------+---------------------------------+ 684 | Resource | Media Type | 685 +-----------+---------------------------------+ 686 | API | application/yang.api+xml | 687 | | application/yang.api+json | 688 | Datastore | application/yang.datastore+xml | 689 | | application/yang.datastore+json | 690 | Data | application/yang.data+xml | 691 | | application/yang.data+json | 692 | Errors | application/yang.errors+xml | 693 | | application/yang.errors+json | 694 | Operation | application/yang.operation+xml | 695 | | application/yang.operation+json | 696 | Schema | application/yang | 697 +-----------+---------------------------------+ 699 RESTCONF Media Types 701 3.3. API Resource 703 The API resource contains the entry points for the RESTCONF datastore 704 and operation resources. It is the top-level resource located at 705 {+restconf} and has the media type "application/yang.api+xml" or 706 "application/yang.api+json". 708 YANG Tree Diagram for an API Resource: 710 +--rw restconf 711 +--rw data 712 +--rw operations 714 The "application/yang.api" restconf-media-type extension in the 715 "ietf-restconf" module defined in Section 8 is used to specify the 716 structure and syntax of the conceptual child resources within the API 717 resource. 719 The API resource can be retrieved with the GET method. 721 This resource has the following child resources: 723 +----------------+--------------------------------+ 724 | Child Resource | Description | 725 +----------------+--------------------------------+ 726 | data | Contains all data resources | 727 | operations | Data-model specific operations | 728 +----------------+--------------------------------+ 730 RESTCONF API Resource 732 3.3.1. {+restconf}/data 734 This mandatory resource represents the combined configuration and 735 operational data resources that can be accessed by a client. It 736 cannot be created or deleted by the client. The datastore resource 737 type is defined in Section 3.4. 739 Example: 741 This example request by the client would retrieve only the non- 742 configuration data nodes that exist within the "library" resource, 743 using the "content" query parameter (see Section 4.8.1). 745 GET /restconf/data/example-jukebox:jukebox/library 746 ?content=nonconfig HTTP/1.1 747 Host: example.com 748 Accept: application/yang.data+xml 750 The server might respond: 752 HTTP/1.1 200 OK 753 Date: Mon, 23 Apr 2012 17:01:30 GMT 754 Server: example-server 755 Cache-Control: no-cache 756 Pragma: no-cache 757 Content-Type: application/yang.data+xml 759 760 42 761 59 762 374 763 765 3.3.2. {+restconf}/operations 767 This optional resource is a container that provides access to the 768 data-model specific protocol operations supported by the server. The 769 server MAY omit this resource if no data-model specific operations 770 are advertised. 772 Any data-model specific operations defined in the YANG modules 773 advertised by the server MAY be available as child nodes of this 774 resource. 776 Operation resources are defined in Section 3.6. 778 3.4. Datastore Resource 780 The "{+restconf}/data" subtree represents the datastore resource 781 type, which is a collection of configuration and operational data 782 nodes. 784 This resource type is an abstraction of the system's underlying 785 datastore implementation. It is used to simplify resource editing 786 for the client. The RESTCONF datastore resource is a conceptual 787 collection of all configuration and operational data that is present 788 on the device. 790 Configuration edit transaction management and configuration 791 persistence are handled by the server and not controlled by the 792 client. A datastore resource can only be written directly with the 793 PATCH method. Each RESTCONF edit of a datastore resource is saved to 794 non-volatile storage in an implementation-specific matter by the 795 server. 797 3.4.1. Edit Collision Detection 799 Two "edit collision detection" mechanisms are provided in RESTCONF, 800 for datastore and data resources. 802 3.4.1.1. Timestamp 804 The last change time is maintained and the "Last-Modified" 805 ([RFC7232], Section 2.2) header is returned in the response for a 806 retrieval request. The "If-Unmodified-Since" header can be used in 807 edit operation requests to cause the server to reject the request if 808 the resource has been modified since the specified timestamp. 810 The server MUST maintain a last-modified timestamp for the top-level 811 {+restconf}/data resource and SHOULD maintain last-modified 812 timestamps for descendant resources. For all resources, the server 813 MUST return the "Last-Modified" header when the resource is retrieved 814 with the GET or HEAD methods. If the server does not maintain a 815 timestamp for a resource, it MUST return the timestamp of the 816 resource's ancestor, a process that may recurse up to the top-level 817 {+restconf}/data resource. Only changes to configuration data 818 resources within the datastore affect the timestamp. 820 3.4.1.2. Entity tag 822 A unique opaque string is maintained and the "ETag" ([RFC7232], 823 Section 2.3) header is returned in the response for a retrieval 824 request. The "If-Match" header can be used in edit operation 825 requests to cause the server to reject the request if the resource 826 entity tag does not match the specified value. 828 The server MUST maintain an entity tag for the top-level 829 {+restconf}/data resource and SHOULD maintain entity tags for 830 descendant resources. For all resources, the server MUST return the 831 "ETag" header when the resource is retrieved with the GET or HEAD 832 methods. If the server does not maintain an entity tag for a 833 resource, it MUST return the entity tag of the resource's ancestor, a 834 process that may recurse up to the top-level {+restconf}/data 835 resource. Only changes to configuration data resources within the 836 datastore affect the entity tag. 838 3.5. Data Resource 840 A data resource represents a YANG data node that is a descendant node 841 of a datastore resource. Each YANG-defined data node can be uniquely 842 targeted by the request-line of an HTTP operation. Containers, 843 leafs, list entries and anyxml nodes are data resources. 845 The representation maintained for each data resource is the YANG 846 defined subtree for that node. HTTP operations on a data resource 847 affect both the targeted data node and all its descendants, if any. 849 For configuration data resources, the server MAY maintain a last- 850 modified timestamp for the resource, and return the "Last-Modified" 851 header when it is retrieved with the GET or HEAD methods. If 852 maintained, the resource timestamp MUST be set to the current time 853 whenever the resource or any configuration resource within the 854 resource is altered. 856 For configuration data resources, the server MAY maintain a resource 857 entity tag for the resource, and return the "ETag" header when it is 858 retrieved as the target resource with the GET or HEAD methods. If 859 maintained, the resource entity tag MUST be updated whenever the 860 resource or any configuration resource within the resource is 861 altered. 863 A data resource can be retrieved with the GET method. Data resources 864 are accessed via the "{+restconf}/data" entry point. This sub-tree 865 is used to retrieve and edit data resources. 867 A configuration data resource can be altered by the client with some 868 or all of the edit operations, depending on the target resource and 869 the specific operation. Refer to Section 4 for more details on edit 870 operations. 872 The resource definition version for a data resource is identified by 873 the revision date of the YANG module containing the YANG definition 874 for the data resource. 876 3.5.1. Encoding Data Resource Identifiers in the Request URI 878 In YANG, data nodes are named with an absolute XPath expression, 879 defined in [XPath], starting from the document root to the target 880 resource. In RESTCONF, URL encoded path expressions are used 881 instead. 883 A predictable location for a data resource is important, since 884 applications will code to the YANG data model module, which uses 885 static naming and defines an absolute path location for all data 886 nodes. 888 A RESTCONF data resource identifier is not an XPath expression. It 889 is encoded from left to right, starting with the top-level data node, 890 according to the "api-path" rule in Section 3.5.1.1. The node name 891 of each ancestor of the target resource node is encoded in order, 892 ending with the node name for the target resource. 894 If a data node in the path expression is a YANG list node, then the 895 key values for the list (if any) MUST be encoded according to the 896 following rules: 898 o The key leaf values for a data resource representing a YANG list 899 MUST be encoded using one path segment [RFC3986]. 901 o If there is only one key leaf value, the path segment is 902 constructed by having the list name followed by an "=" followed by 903 the single key leaf value. 905 o If there are multiple key leaf values, the value of each leaf 906 identified in the "key" statement is encoded in the order 907 specified in the YANG "key" statement, with a comma separating 908 them. 910 o The key value is specified as a string, using the canonical 911 representation for the YANG data type. Any reserved characters 912 MUST be encoded with escape sequences, according to [RFC2396], 913 Section 2.4. 915 o All the components in the "key" statement MUST be encoded. 916 Partial instance identifiers are not supported. 918 o Quoted strings are supported in the key leaf values. Quoted 919 strings MUST be used to express empty strings. (example: 920 list=foo,'',baz). 922 o The "list-instance" ABNF rule defined in Section 3.5.1.1 923 represents the syntax of a list instance identifier. 925 o Resource URI values returned in Location headers for data 926 resources MUST identify the module name, even if there are no 927 conflicting local names when the resource is created. This 928 ensures the correct resource will be identified even if the server 929 loads a new module that the old client does not know about. 931 Examples: 933 container top { 934 list list1 { 935 key "key1 key2 key3"; 936 ... 937 list list2 { 938 key "key4 key5"; 939 ... 940 leaf X { type string; } 941 } 942 } 943 } 945 For the above YANG definition, URI with key leaf values will be 946 encoded as follows (line wrapped for display purposes only): 948 /restconf/data/example-top:top/list1=key1val,key2val,key3val3/ 949 list2=key4val,key5val/X 951 3.5.1.1. ABNF For Data Resource Identifiers 953 The "api-path" ABNF syntax is used to construct RESTCONF path 954 identifiers: 956 api-path = "/" | 957 ("/" api-identifier 958 0*("/" (api-identifier | list-instance ))) 960 api-identifier = [module-name ":"] identifier ;; note 1 962 module-name = identifier 964 list-instance = api-identifier "=" key-value ["," key-value]* 966 key-value = string ;; note 1 968 string = 970 ;; An identifier MUST NOT start with 971 ;; (('X'|'x') ('M'|'m') ('L'|'l')) 972 identifier = (ALPHA / "_") 973 *(ALPHA / DIGIT / "_" / "-" / ".") 975 Note 1: The syntax for "api-identifier" and "key-value" MUST conform 976 to the JSON identifier encoding rules in Section 4 of 977 [I-D.ietf-netmod-yang-json]. 979 3.5.2. Defaults Handling 981 RESTCONF requires that a server report its default handling mode (see 982 Section 9.1.2 for details). If the optional "with-defaults" query 983 parameter is supported by the server, a client may use it to control 984 retrieval of default values (see Section 4.8.9 for details). 986 If the target of a GET method is a data node that represents a leaf 987 that has a default value, and the leaf has not been given a value 988 yet, the server MUST return the default value that is in use by the 989 server. 991 If the target of a GET method is a data node that represents a 992 container or list that has any child resources with default values, 993 for the child resources that have not been given value yet, the 994 server MAY return the default values that are in use by the server, 995 in accordance with its reported default handing mode and query 996 parameters passed by the client. 998 3.6. Operation Resource 1000 An operation resource represents a protocol operation defined with 1001 the YANG "rpc" statement. It is invoked using a POST method on the 1002 operation resource. 1004 POST {+restconf}/operations/ 1006 The field identifies the module name and rpc identifier 1007 string for the desired operation. 1009 For example, if "module-A" defined a "reset" operation, then invoking 1010 the operation from "module-A" would be requested as follows: 1012 POST /restconf/operations/module-A:reset HTTP/1.1 1013 Server example.com 1015 If the "rpc" statement has an "input" section, then a message-body 1016 MAY be sent by the client in the request, otherwise the request 1017 message MUST NOT include a message-body. 1019 If the operation is successfully invoked, and if the "rpc" statement 1020 has an "output" section, then a message-body MAY be sent by the 1021 server in the response, otherwise the response message MUST NOT 1022 include a message-body in the response message, and MUST send a "204 1023 No Content" status-line instead. 1025 If the operation is not successfully invoked, then a message-body 1026 SHOULD be sent by the server, containing an "errors" resource, as 1027 defined in Section 3.9. 1029 3.6.1. Encoding Operation Input Parameters 1031 If the "rpc" statement has an "input" section, then the "input" node 1032 is provided in the message-body, corresponding to the YANG data 1033 definition statements within the "input" section. 1035 Example: 1037 The following YANG definition is used for the examples in this 1038 section. 1040 module example-ops { 1041 namespace "https://example.com/ns/example-ops"; 1042 prefix "ops"; 1044 rpc reboot { 1045 input { 1046 leaf delay { 1047 units seconds; 1048 type uint32; 1049 default 0; 1050 } 1051 leaf message { type string; } 1052 leaf language { type string; } 1053 } 1054 } 1056 rpc get-reboot-info { 1057 output { 1058 leaf reboot-time { 1059 units seconds; 1060 type uint32; 1061 } 1062 leaf message { type string; } 1063 leaf language { type string; } 1064 } 1065 } 1066 } 1068 The client might send the following POST request message: 1070 POST /restconf/operations/example-ops:reboot HTTP/1.1 1071 Host: example.com 1072 Content-Type: application/yang.operation+xml 1073 1074 600 1075 Going down for system maintenance 1076 en-US 1077 1079 The server might respond: 1081 HTTP/1.1 204 No Content 1082 Date: Mon, 25 Apr 2012 11:01:00 GMT 1083 Server: example-server 1085 3.6.2. Encoding Operation Output Parameters 1087 If the "rpc" statement has an "output" section, then the "output" 1088 node is provided in the message-body, corresponding to the YANG data 1089 definition statements within the "output" section. 1091 Example: 1093 The "example-ops" YANG module defined in Section 3.6.1 is used for 1094 the examples in this section. 1096 The client might send the following POST request message: 1098 POST /restconf/operations/example-ops:get-reboot-info HTTP/1.1 1099 Host: example.com 1100 Accept: application/yang.operation+json 1102 The server might respond: 1104 HTTP/1.1 200 OK 1105 Date: Mon, 25 Apr 2012 11:10:30 GMT 1106 Server: example-server 1107 Content-Type: application/yang.operation+json 1109 { 1110 "example-ops:output" : { 1111 "reboot-time" : 30, 1112 "message" : "Going down for system maintenance", 1113 "language" : "en-US" 1114 } 1115 } 1117 3.6.3. Encoding Operation Errors 1119 If any errors occur while attempting to invoke the operation, then an 1120 "errors" data structure is returned with the appropriate error 1121 status. 1123 Using the "reset" operation example above, the client might send the 1124 following POST request message: 1126 POST /restconf/operations/example-ops:reboot HTTP/1.1 1127 Host: example.com 1128 Content-Type: application/yang.operation+xml 1130 1131 -33 1132 Going down for system maintenance 1133 en-US 1134 1136 The server might respond with an "invalid-value" error: 1138 HTTP/1.1 400 Bad Request 1139 Date: Mon, 25 Apr 2012 11:10:30 GMT 1140 Server: example-server 1141 Content-Type: application/yang.errors+xml 1143 1144 1145 protocol 1146 invalid-value 1147 1148 err:input/err:delay 1149 1150 Invalid input parameter 1151 1152 1154 3.7. Schema Resource 1156 The server can optionally support retrieval of the YANG modules it 1157 supports, using the "ietf-yang-library" module, defined in 1158 [I-D.ietf-netconf-yang-library]. 1160 To retrieve a YANG module, a client first needs to get the URL for 1161 retrieving the schema. 1163 The client might send the following GET request message: 1165 GET /restconf/data/ietf-yang-library:modules/module= 1166 example-jukebox,2014-07-03/schema HTTP/1.1 1167 Host: example.com 1168 Accept: application/yang.data+json 1170 The server might respond: 1172 HTTP/1.1 200 OK 1173 Date: Mon, 25 Apr 2012 11:10:30 GMT 1174 Server: example-server 1175 Content-Type: application/yang.data+json 1177 { 1178 "ietf-yang-library:schema": 1179 "https://example.com/mymodules/example-jukebox/2015-06-04" 1180 } 1182 Next the client needs to retrieve the actual YANG schema. 1184 The client might send the following GET request message: 1186 GET https://example.com/mymodules/example-jukebox/2015-06-04 1187 HTTP/1.1 1188 Host: example.com 1189 Accept: application/yang 1191 The server might respond: 1193 module example-jukebox { 1195 // contents of YANG module deleted for this example... 1197 } 1199 3.8. Event Stream Resource 1201 An "event stream" resource represents a source for system generated 1202 event notifications. Each stream is created and modified by the 1203 server only. A client can retrieve a stream resource or initiate a 1204 long-poll server sent event stream, using the procedure specified in 1205 Section 6.3. 1207 A notification stream functions according to the NETCONF 1208 Notifications specification [RFC5277]. The available streams can be 1209 retrieved from the stream list, which specifies the syntax and 1210 semantics of a stream resource. 1212 3.9. Errors Media Type 1214 An "errors" media type is a collection of error information that is 1215 sent as the message-body in a server response message, if an error 1216 occurs while processing a request message. It is not considered a 1217 resource type because no instances can be retrieved with a GET 1218 request. 1220 The "ietf-restconf" YANG module contains the "application/ 1221 yang.errors" restconf-media-type extension which specifies the syntax 1222 and semantics of an "errors" media type. RESTCONF error handling 1223 behavior is defined in Section 7. 1225 4. Operations 1227 The RESTCONF protocol uses HTTP methods to identify the CRUD 1228 operation requested for a particular resource. 1230 The following table shows how the RESTCONF operations relate to 1231 NETCONF protocol operations: 1233 +----------+--------------------------------------------+ 1234 | RESTCONF | NETCONF | 1235 +----------+--------------------------------------------+ 1236 | OPTIONS | none | 1237 | HEAD | none | 1238 | GET | , | 1239 | POST | (operation="create") | 1240 | PUT | (operation="create/replace") | 1241 | PATCH | (operation="merge") | 1242 | DELETE | (operation="delete") | 1243 +----------+--------------------------------------------+ 1245 Table 1: CRUD Methods in RESTCONF 1247 The NETCONF "remove" operation attribute is not supported by the HTTP 1248 DELETE method. The resource must exist or the DELETE method will 1249 fail. The PATCH method is equivalent to a "merge" operation when 1250 using a plain patch (see Section 4.6.1), other media-types may 1251 provide more granular control. 1253 Access control mechanisms may be used to limit what operations can be 1254 used. In particular, RESTCONF is compatible with the NETCONF Access 1255 Control Model (NACM) [RFC6536], as there is a specific mapping 1256 between RESTCONF and NETCONF operations, defined in Table 1. The 1257 resource path needs to be converted internally by the server to the 1258 corresponding YANG instance-identifier. Using this information, the 1259 server can apply the NACM access control rules to RESTCONF messages. 1261 The server MUST NOT allow any operation to any resources that the 1262 client is not authorized to access. 1264 Implementation of all methods (except PATCH) are defined in 1265 [RFC7231]. This section defines the RESTCONF protocol usage for each 1266 HTTP method. 1268 4.1. OPTIONS 1270 The OPTIONS method is sent by the client to discover which methods 1271 are supported by the server for a specific resource (e.g., GET, POST, 1272 DELETE, etc.). 1274 The server SHOULD implement this method, however the same information 1275 could be extracted from the YANG modules and the RESTCONF protocol 1276 specification. 1278 If the PATCH method is supported, then the "Accept-Patch" header MUST 1279 be supported and returned in the response to the OPTIONS request, as 1280 defined in [RFC5789]. 1282 4.2. HEAD 1284 The HEAD method is sent by the client to retrieve just the headers 1285 that would be returned for the comparable GET method, without the 1286 response message-body. It is supported for all resource types, 1287 except operation resources. 1289 The request MUST contain a request URI that contains at least the 1290 entry point. The same query parameters supported by the GET method 1291 are supported by the HEAD method. 1293 The access control behavior is enforced as if the method was GET 1294 instead of HEAD. The server MUST respond the same as if the method 1295 was GET instead of HEAD, except that no response message-body is 1296 included. 1298 4.3. GET 1300 The GET method is sent by the client to retrieve data and meta-data 1301 for a resource. It is supported for all resource types, except 1302 operation resources. The request MUST contain a request URI that 1303 contains at least the entry point. 1305 The server MUST NOT return any data resources for which the user does 1306 not have read privileges. If the user is not authorized to read the 1307 target resource, an error response containing a "403 Forbidden" or 1308 "404 Not Found" status-line is returned to the client. 1310 If the user is authorized to read some but not all of the target 1311 resource, the unauthorized content is omitted from the response 1312 message-body, and the authorized content is returned to the client. 1314 Example: 1316 The client might request the response headers for a JSON 1317 representation of the "library" resource: 1319 GET /restconf/data/example-jukebox:jukebox/ 1320 library/artist=Foo%20Fighters/album HTTP/1.1 1321 Host: example.com 1322 Accept: application/yang.data+xml 1324 The server might respond: 1326 HTTP/1.1 200 OK 1327 Date: Mon, 23 Apr 2012 17:02:40 GMT 1328 Server: example-server 1329 Content-Type: application/yang.data+xml 1330 Cache-Control: no-cache 1331 Pragma: no-cache 1332 ETag: a74eefc993a2b 1333 Last-Modified: Mon, 23 Apr 2012 11:02:14 GMT 1335 1336 Wasting Light 1337 1338 g:alternative 1339 1340 2011 1341 1343 4.4. POST 1345 The POST method is sent by the client to create a data resource or 1346 invoke an operation resource. The server uses the target resource 1347 media type to determine how to process the request. 1349 +-----------+------------------------------------------------+ 1350 | Type | Description | 1351 +-----------+------------------------------------------------+ 1352 | Datastore | Create a top-level configuration data resource | 1353 | Data | Create a configuration data child resource | 1354 | Operation | Invoke a protocol operation | 1355 +-----------+------------------------------------------------+ 1357 Resource Types that Support POST 1359 4.4.1. Create Resource Mode 1361 If the target resource type is a datastore or data resource, then the 1362 POST is treated as a request to create a top-level resource or child 1363 resource, respectively. The message-body is expected to contain the 1364 content of a child resource to create within the parent (target 1365 resource). The data-model for the child tree is the subtree is 1366 defined by YANG for the child resource. 1368 The "insert" and "point" query parameters are supported by the POST 1369 method for datastore and data resource types, as specified in the 1370 YANG definition in Section 8. 1372 If the POST method succeeds, a "201 Created" status-line is returned 1373 and there is no response message-body. A "Location" header 1374 identifying the child resource that was created MUST be present in 1375 the response in this case. 1377 If the user is not authorized to create the target resource, an error 1378 response containing a "403 Forbidden" or "404 Not Found" status-line 1379 is returned to the client. All other error responses are handled 1380 according to the procedures defined in Section 7. 1382 Example: 1384 To create a new "jukebox" resource, the client might send: 1386 POST /restconf/data HTTP/1.1 1387 Host: example.com 1388 Content-Type: application/yang.data+json 1390 { "example-jukebox:jukebox" : [null] } 1392 If the resource is created, the server might respond as follows. 1393 Note that the "Location" header line is wrapped for display purposes 1394 only: 1396 HTTP/1.1 201 Created 1397 Date: Mon, 23 Apr 2012 17:01:00 GMT 1398 Server: example-server 1399 Location: https://example.com/restconf/data/ 1400 example-jukebox:jukebox 1401 Last-Modified: Mon, 23 Apr 2012 17:01:00 GMT 1402 ETag: b3a3e673be2 1404 Refer to Appendix D.2.1 for more resource creation examples. 1406 4.4.2. Invoke Operation Mode 1408 If the target resource type is an operation resource, then the POST 1409 method is treated as a request to invoke that operation. The 1410 message-body (if any) is processed as the operation input parameters. 1411 Refer to Section 3.6 for details on operation resources. 1413 If the POST request succeeds, a "200 OK" status-line is returned if 1414 there is a response message-body, and a "204 No Content" status-line 1415 is returned if there is no response message-body. 1417 If the user is not authorized to invoke the target operation, an 1418 error response containing a "403 Forbidden" or "404 Not Found" 1419 status-line is returned to the client. All other error responses are 1420 handled according to the procedures defined in Section 7. 1422 Example: 1424 In this example, the client is invoking the "play" operation defined 1425 in the "example-jukebox" YANG module. 1427 A client might send a "play" request as follows: 1429 POST /restconf/operations/example-jukebox:play HTTP/1.1 1430 Host: example.com 1431 Content-Type: application/yang.operation+json 1433 { 1434 "example-jukebox:input" : { 1435 "playlist" : "Foo-One", 1436 "song-number" : 2 1437 } 1438 } 1440 The server might respond: 1442 HTTP/1.1 204 No Content 1443 Date: Mon, 23 Apr 2012 17:50:00 GMT 1444 Server: example-server 1446 4.5. PUT 1448 The PUT method is sent by the client to create or replace the target 1449 resource. 1451 The only target resource media type that supports PUT is the data 1452 resource. The message-body is expected to contain the content used 1453 to create or replace the target resource. 1455 The "insert" (Section 4.8.4) and "point" (Section 4.8.5) query 1456 parameters are supported by the PUT method for data resources. 1458 Consistent with [RFC7231], if the PUT request creates a new resource, 1459 a "201 Created" status-line is returned. If an existing resource is 1460 modified, either "200 OK" or "204 No Content" are returned. 1462 If the user is not authorized to create or replace the target 1463 resource an error response containing a "403 Forbidden" or "404 Not 1464 Found" status-line is returned to the client. All other error 1465 responses are handled according to the procedures defined in 1466 Section 7. 1468 Example: 1470 An "album" child resource defined in the "example-jukebox" YANG 1471 module is replaced or created if it does not already exist. 1473 To replace the "album" resource contents, the client might send as 1474 follows. Note that the request-line is wrapped for display purposes 1475 only: 1477 PUT /restconf/data/example-jukebox:jukebox/ 1478 library/artist=Foo%20Fighters/album=Wasting%20Light HTTP/1.1 1479 Host: example.com 1480 Content-Type: application/yang.data+json 1482 { 1483 "example-jukebox:album" : { 1484 "name" : "Wasting Light", 1485 "genre" : "example-jukebox:alternative", 1486 "year" : 2011 1487 } 1488 } 1490 If the resource is updated, the server might respond: 1492 HTTP/1.1 204 No Content 1493 Date: Mon, 23 Apr 2012 17:04:00 GMT 1494 Server: example-server 1495 Last-Modified: Mon, 23 Apr 2012 17:04:00 GMT 1496 ETag: b27480aeda4c 1498 4.6. PATCH 1500 RESTCONF uses the HTTP PATCH method defined in [RFC5789] to provide 1501 an extensible framework for resource patching mechanisms. It is 1502 optional to implement by the server. Each patch type needs a unique 1503 media type. Zero or more PATCH media types MAY be supported by the 1504 server. The media types supported by a server can be discovered by 1505 the client by sending an OPTIONS request (see Section 4.1). 1507 If the target resource instance does not exist, the server MUST NOT 1508 create it. 1510 If the PATCH request succeeds, a "200 OK" status-line is returned if 1511 there is a message-body, and "204 No Content" is returned if no 1512 response message-body is sent. 1514 If the user is not authorized to alter the target resource an error 1515 response containing a "403 Forbidden" or "404 Not Found" status-line 1516 is returned to the client. All other error responses are handled 1517 according to the procedures defined in Section 7. 1519 4.6.1. Plain Patch 1521 The plain patch mechanism merges the contents of the message body 1522 with the target resource. If the target resource is a datastore 1523 resource (see Section 3.4), the message body MUST be either 1524 application/yang.datastore+xml or application/yang.datastore+json. 1525 If then the target resource is a data resource (see Section 3.5), 1526 then the message body MUST be either application/yang.data+xml or 1527 application/yang.data+json. 1529 Plain patch can used to create or update, but not delete, a child 1530 resource within the target resource. Please see 1531 [I-D.ietf-netconf-yang-patch] for an alternate media-type supporting 1532 more granular control. 1534 Example: 1536 To replace just the "year" field in the "album" resource (instead of 1537 replacing the entire resource with the PUT method), the client might 1538 send a plain patch as follows. Note that the request-line is wrapped 1539 for display purposes only: 1541 PATCH /restconf/data/example-jukebox:jukebox/ 1542 library/artist=Foo%20Fighters/album=Wasting%20Light HTTP/1.1 1543 Host: example.com 1544 If-Match: b8389233a4c 1545 Content-Type: application/yang.data+xml 1547 1548 2011 1549 1551 If the field is updated, the server might respond: 1553 HTTP/1.1 204 No Content 1554 Date: Mon, 23 Apr 2012 17:49:30 GMT 1555 Server: example-server 1556 Last-Modified: Mon, 23 Apr 2012 17:49:30 GMT 1557 ETag: b2788923da4c 1559 4.7. DELETE 1561 The DELETE method is used to delete the target resource. If the 1562 DELETE request succeeds, a "204 No Content" status-line is returned, 1563 and there is no response message-body. 1565 If the user is not authorized to delete the target resource then an 1566 error response containing a "403 Forbidden" or "404 Not Found" 1567 status-line is returned to the client. All other error responses are 1568 handled according to the procedures defined in Section 7. 1570 Example: 1572 To delete a resource such as the "album" resource, the client might 1573 send: 1575 DELETE /restconf/data/example-jukebox:jukebox/ 1576 library/artist=Foo%20Fighters/album=Wasting%20Light HTTP/1.1 1577 Host: example.com 1579 If the resource is deleted, the server might respond: 1581 HTTP/1.1 204 No Content 1582 Date: Mon, 23 Apr 2012 17:49:40 GMT 1583 Server: example-server 1585 4.8. Query Parameters 1587 Each RESTCONF operation allows zero or more query parameters to be 1588 present in the request URI. The specific parameters that are allowed 1589 depends on the resource type, and sometimes the specific target 1590 resource used, in the request. 1592 +---------------+---------+-----------------------------------------+ 1593 | Name | Methods | Description | 1594 +---------------+---------+-----------------------------------------+ 1595 | content | GET | Select config and/or non-config data | 1596 | | | resources | 1597 | depth | GET | Request limited sub-tree depth in the | 1598 | | | reply content | 1599 | fields | GET | Request a subset of the target resource | 1600 | | | contents | 1601 | filter | GET | Boolean notification filter for event | 1602 | | | stream resources | 1603 | insert | POST, | Insertion mode for user-ordered data | 1604 | | PUT | resources | 1605 | point | POST, | Insertion point for user-ordered data | 1606 | | PUT | resources | 1607 | start-time | GET | Replay buffer start time for event | 1608 | | | stream resources | 1609 | stop-time | GET | Replay buffer stop time for event | 1610 | | | stream resources | 1611 | with-defaults | GET | Control retrieval of default values | 1612 +---------------+---------+-----------------------------------------+ 1614 RESTCONF Query Parameters 1616 Query parameters can be given in any order. Each parameter can 1617 appear at most once in a request URI. A default value may apply if 1618 the parameter is missing. 1620 Refer to Appendix D.3 for examples of query parameter usage. 1622 If vendors define additional query parameters, they SHOULD use a 1623 prefix (such as the enterprise or organization name) for query 1624 parameter names in order to avoid collisions with other parameters. 1626 4.8.1. The "content" Query Parameter 1628 The "content" parameter controls how descendant nodes of the 1629 requested data nodes will be processed in the reply. 1631 The allowed values are: 1633 +-----------+-----------------------------------------------------+ 1634 | Value | Description | 1635 +-----------+-----------------------------------------------------+ 1636 | config | Return only configuration descendant data nodes | 1637 | nonconfig | Return only non-configuration descendant data nodes | 1638 | all | Return all descendant data nodes | 1639 +-----------+-----------------------------------------------------+ 1641 This parameter is only allowed for GET methods on datastore and data 1642 resources. A 400 Bad Request error is returned if used for other 1643 methods or resource types. 1645 The default value is determined by the "config" statement value of 1646 the requested data nodes. If the "config" value is "false", then the 1647 default for the "content" parameter is "nonconfig". If "config" is 1648 "true" then the default for the "content" parameter is "config". 1650 This query parameter MUST be supported by the server. 1652 4.8.2. The "depth" Query Parameter 1654 The "depth" parameter is used to specify the number of nest levels 1655 returned in a response for a GET method. The first nest-level 1656 consists of the requested data node itself. Any child nodes which 1657 are contained within a parent node have a depth value that is 1 1658 greater than its parent. 1660 The value of the "depth" parameter is either an integer between 1 and 1661 65535, or the string "unbounded". "unbounded" is the default. 1663 This parameter is only allowed for GET methods on API, datastore, and 1664 data resources. A 400 Bad Request error is returned if it used for 1665 other methods or resource types. 1667 By default, the server will include all sub-resources within a 1668 retrieved resource, which have the same resource type as the 1669 requested resource. Only one level of sub-resources with a different 1670 media type than the target resource will be returned. 1672 If the "depth" query parameter URI is listed in the "capability" 1673 leaf-list in Section 9.3, then the server supports the "depth" query 1674 parameter. 1676 4.8.3. The "fields" Query Parameter 1678 The "fields" query parameter is used to optionally identify data 1679 nodes within the target resource to be retrieved in a GET method. 1680 The client can use this parameter to retrieve a subset of all nodes 1681 in a resource. 1683 A value of the "fields" query parameter matches the following rule: 1685 fields-expr = path '(' fields-expr / '*' ')' / 1686 path ';' fields-expr / 1687 path 1688 path = api-identifier [ '/' path ] 1690 "api-identifier" is defined in Section 3.5.1.1. 1692 ";" is used to select multiple nodes. For example, to retrieve only 1693 the "genre" and "year" of an album, use: "fields=genre;year". 1695 Parentheses are used to specify sub-selectors of a node. For 1696 example, to retrieve only the "label" and "catalogue-number" of an 1697 album, use: "fields=admin(label;catalogue-number)". 1699 "/" is used in a path to retrieve a child node of a node. For 1700 example, to retrieve only the "label" of an album, use: 1701 "fields=admin/label". 1703 This parameter is only allowed for GET methods on api, datastore, and 1704 data resources. A 400 Bad Request error is returned if used for 1705 other methods or resource types. 1707 If the "fields" query parameter URI is listed in the "capability" 1708 leaf-list in Section 9.3, then the server supports the "fields" 1709 parameter. 1711 4.8.4. The "insert" Query Parameter 1713 The "insert" parameter is used to specify how a resource should be 1714 inserted within a user-ordered list. 1716 The allowed values are: 1718 +--------+----------------------------------------------------------+ 1719 | Value | Description | 1720 +--------+----------------------------------------------------------+ 1721 | first | Insert the new data as the new first entry. | 1722 | last | Insert the new data as the new last entry. | 1723 | before | Insert the new data before the insertion point, as | 1724 | | specified by the value of the "point" parameter. | 1725 | after | Insert the new data after the insertion point, as | 1726 | | specified by the value of the "point" parameter. | 1727 +--------+----------------------------------------------------------+ 1729 The default value is "last". 1731 This parameter is only supported for the POST and PUT methods. It is 1732 also only supported if the target resource is a data resource, and 1733 that data represents a YANG list or leaf-list that is ordered by the 1734 user. 1736 If the values "before" or "after" are used, then a "point" query 1737 parameter for the insertion parameter MUST also be present, or a 400 1738 Bad Request error is returned. 1740 The "insert" query parameter MUST be supported by the server. 1742 4.8.5. The "point" Query Parameter 1744 The "point" parameter is used to specify the insertion point for a 1745 data resource that is being created or moved within a user ordered 1746 list or leaf-list. 1748 The value of the "point" parameter is a string that identifies the 1749 path to the insertion point object. The format is the same as a 1750 target resource URI string. 1752 This parameter is only supported for the POST and PUT methods. It is 1753 also only supported if the target resource is a data resource, and 1754 that data represents a YANG list or leaf-list that is ordered by the 1755 user. 1757 If the "insert" query parameter is not present, or has a value other 1758 than "before" or "after", then a 400 Bad Request error is returned. 1760 This parameter contains the instance identifier of the resource to be 1761 used as the insertion point for a POST or PUT method. 1763 The "point" query parameter MUST be supported by the server. 1765 4.8.6. The "filter" Query Parameter 1767 The "filter" parameter is used to indicate which subset of all 1768 possible events are of interest. If not present, all events not 1769 precluded by other parameters will be sent. 1771 This parameter is only allowed for GET methods on a text/event-stream 1772 data resource. A 400 Bad Request error is returned if used for other 1773 methods or resource types. 1775 The format of this parameter is an XPath 1.0 expression, and is 1776 evaluated in the following context: 1778 o The set of namespace declarations is the set of prefix and 1779 namespace pairs for all supported YANG modules, where the prefix 1780 is the YANG module name, and the namespace is as defined by the 1781 "namespace" statement in the YANG module. 1783 o The function library is the core function library defined in XPath 1784 1.0. 1786 o The set of variable bindings is empty. 1788 o The context node is the root node. 1790 The filter is used as defined in [RFC5277], Section 3.6. If the 1791 boolean result of the expression is true when applied to the 1792 conceptual "notification" document root, then the event notification 1793 is delivered to the client. 1795 If the "filter" query parameter URI is listed in the "capability" 1796 leaf-list in Section 9.3, then the server supports the "filter" query 1797 parameter. 1799 4.8.7. The "start-time" Query Parameter 1801 The "start-time" parameter is used to trigger the notification replay 1802 feature and indicate that the replay should start at the time 1803 specified. If the stream does not support replay, per the 1804 "replay-support" attribute returned by stream list entry for the 1805 stream resource, then the server MUST return the HTTP error code 400 1806 Bad Request. 1808 The value of the "start-time" parameter is of type "date-and-time", 1809 defined in the "ietf-yang" YANG module [RFC6991]. 1811 This parameter is only allowed for GET methods on a text/event-stream 1812 data resource. A 400 Bad Request error is returned if used for other 1813 methods or resource types. 1815 If this parameter is not present, then a replay subscription is not 1816 being requested. It is not valid to specify start times that are 1817 later than the current time. If the value specified is earlier than 1818 the log can support, the replay will begin with the earliest 1819 available notification. 1821 If this query parameter is supported by the server, then the "replay" 1822 query parameter URI MUST be listed in the "capability" leaf-list in 1823 Section 9.3. The "stop-time" query parameter MUST also be supported 1824 by the server. 1826 If the "replay-support" leaf is present in the "stream" entry 1827 (defined in Section 9.3) then the server MUST support the 1828 "start-time" and "stop-time" query parameters for that stream. 1830 4.8.8. The "stop-time" Query Parameter 1832 The "stop-time" parameter is used with the replay feature to indicate 1833 the newest notifications of interest. This parameter MUST be used 1834 with and have a value later than the "start-time" parameter. 1836 The value of the "stop-time" parameter is of type "date-and-time", 1837 defined in the "ietf-yang" YANG module [RFC6991]. 1839 This parameter is only allowed for GET methods on a text/event-stream 1840 data resource. A 400 Bad Request error is returned if used for other 1841 methods or resource types. 1843 If this parameter is not present, the notifications will continue 1844 until the subscription is terminated. Values in the future are 1845 valid. 1847 If this query parameter is supported by the server, then the "replay" 1848 query parameter URI MUST be listed in the "capability" leaf-list in 1849 Section 9.3. The "start-time" query parameter MUST also be supported 1850 by the server. 1852 If the "replay-support" leaf is present in the "stream" entry 1853 (defined in Section 9.3) then the server MUST support the 1854 "start-time" and "stop-time" query parameters for that stream. 1856 4.8.9. The "with-defaults" Query Parameter 1858 The "with-defaults" parameter is used to specify how information 1859 about default data nodes should be returned in response to GET 1860 requests on data resources. 1862 If the server supports this capability, then it MUST implement the 1863 behavior in Section 4.5.1 of [RFC6243], except applied to the 1864 RESTCONF GET operation, instead of the NETCONF operations. 1866 +-------------------+-----------------------------------------------+ 1867 | Value | Description | 1868 +-------------------+-----------------------------------------------+ 1869 | report-all | All data nodes are reported | 1870 | trim | Data nodes set to the YANG default are not | 1871 | | reported | 1872 | explicit | Data nodes set by the client are not reported | 1873 | report-all-tagged | All data nodes are reported and defaults are | 1874 | | tagged | 1875 +-------------------+-----------------------------------------------+ 1876 If the "with-defaults" parameter is set to "report-all" then the 1877 server MUST adhere to the defaults reporting behavior defined in 1878 Section 3.1 of [RFC6243]. 1880 If the "with-defaults" parameter is set to "trim" then the server 1881 MUST adhere to the defaults reporting behavior defined in Section 3.2 1882 of [RFC6243]. 1884 If the "with-defaults" parameter is set to "explicit" then the server 1885 MUST adhere to the defaults reporting behavior defined in Section 3.3 1886 of [RFC6243]. 1888 If the "with-defaults" parameter is set to "report-all-tagged" then 1889 the server MUST adhere to the defaults reporting behavior defined in 1890 Section 3.4 of [RFC6243]. 1892 If the "with-defaults" parameter is not present then the server MUST 1893 adhere to the defaults reporting behavior defined in its "basic-mode" 1894 parameter for the "defaults" protocol capability URI, defined in 1895 Section 9.1.2. 1897 If the server includes the "with-defaults" query parameter URI in the 1898 "capability" leaf-list in Section 9.3, then the "with-defaults" query 1899 parameter MUST be supported. 1901 5. Messages 1903 The RESTCONF protocol uses HTTP entities for messages. A single HTTP 1904 message corresponds to a single protocol method. Most messages can 1905 perform a single task on a single resource, such as retrieving a 1906 resource or editing a resource. The exception is the PATCH method, 1907 which allows multiple datastore edits within a single message. 1909 5.1. Request URI Structure 1911 Resources are represented with URIs following the structure for 1912 generic URIs in [RFC3986]. 1914 A RESTCONF operation is derived from the HTTP method and the request 1915 URI, using the following conceptual fields: 1917 //?# 1918 ^ ^ ^ ^ ^ 1919 | | | | | 1920 method entry resource query fragment 1922 M M O O I 1924 M=mandatory, O=optional, I=ignored 1926 replaced by client with real values 1928 o method: the HTTP method identifying the RESTCONF operation 1929 requested by the client, to act upon the target resource specified 1930 in the request URI. RESTCONF operation details are described in 1931 Section 4. 1933 o entry: the root of the RESTCONF API configured on this HTTP 1934 server, discovered by getting the ".well-known/host-meta" 1935 resource, as described in Section 3.1. 1937 o resource: the path expression identifying the resource that is 1938 being accessed by the operation. If this field is not present, 1939 then the target resource is the API itself, represented by the 1940 media type "application/yang.api". 1942 o query: the set of parameters associated with the RESTCONF message. 1943 These have the familiar form of "name=value" pairs. All query 1944 parameters are optional to implement by the server and optional to 1945 use by the client. Each query parameter is identified by a URI. 1946 The server MUST list the query parameter URIs it supports in the 1947 "capabilities" list defined in Section 9.3. 1949 There is a specific set of parameters defined, although the server 1950 MAY choose to support query parameters not defined in this document. 1951 The contents of the any query parameter value MUST be encoded 1952 according to [RFC2396], Section 3.4. Any reserved characters MUST be 1953 encoded with escape sequences, according to [RFC2396], Section 2.4. 1955 o fragment: This field is not used by the RESTCONF protocol. 1957 When new resources are created by the client, a "Location" header is 1958 returned, which identifies the path of the newly created resource. 1959 The client MUST use this exact path identifier to access the resource 1960 once it has been created. 1962 The "target" of an operation is a resource. The "path" field in the 1963 request URI represents the target resource for the operation. 1965 5.2. Message Headers 1967 There are several HTTP header lines utilized in RESTCONF messages. 1968 Messages are not limited to the HTTP headers listed in this section. 1970 HTTP defines which header lines are required for particular 1971 circumstances. Refer to each operation definition section in 1972 Section 4 for examples on how particular headers are used. 1974 There are some request headers that are used within RESTCONF, usually 1975 applied to data resources. The following tables summarize the 1976 headers most relevant in RESTCONF message requests: 1978 +---------------------+---------------------------------------------+ 1979 | Name | Description | 1980 +---------------------+---------------------------------------------+ 1981 | Accept | Response Content-Types that are acceptable | 1982 | Content-Type | The media type of the request body | 1983 | Host | The host address of the server | 1984 | If-Match | Only perform the action if the entity | 1985 | | matches ETag | 1986 | If-Modified-Since | Only perform the action if modified since | 1987 | | time | 1988 | If-Unmodified-Since | Only perform the action if un-modified | 1989 | | since time | 1990 +---------------------+---------------------------------------------+ 1992 RESTCONF Request Headers 1994 The following tables summarize the headers most relevant in RESTCONF 1995 message responses: 1997 +---------------+---------------------------------------------------+ 1998 | Name | Description | 1999 +---------------+---------------------------------------------------+ 2000 | Allow | Valid actions when 405 error returned | 2001 | Cache-Control | The cache control parameters for the response | 2002 | Content-Type | The media type of the response message-body | 2003 | Date | The date and time the message was sent | 2004 | ETag | An identifier for a specific version of a | 2005 | | resource | 2006 | Last-Modified | The last modified date and time of a resource | 2007 | Location | The resource identifier for a newly created | 2008 | | resource | 2009 +---------------+---------------------------------------------------+ 2011 RESTCONF Response Headers 2013 5.3. Message Encoding 2015 RESTCONF messages are encoded in HTTP according to [RFC7230]. The 2016 "utf-8" character set is used for all messages. RESTCONF message 2017 content is sent in the HTTP message-body. 2019 Content is encoded in either JSON or XML format. A server MUST 2020 support XML encoding and MAY support JSON encoding. XML encoding 2021 rules for data nodes are defined in [RFC6020]. The same encoding 2022 rules are used for all XML content. JSON encoding rules are defined 2023 in [I-D.ietf-netmod-yang-json]. This encoding is valid JSON, but 2024 also has special encoding rules to identify module namespaces and 2025 provide consistent type processing of YANG data. 2027 Request input content encoding format is identified with the Content- 2028 Type header. This field MUST be present if a message-body is sent by 2029 the client. 2031 Response output content encoding format is identified with the Accept 2032 header in the request, or if is not specified, the request input 2033 encoding format is used. If there was no request input, then the 2034 default output encoding is XML. File extensions encoded in the 2035 request are not used to identify format encoding. 2037 5.4. RESTCONF Meta-Data 2039 The RESTCONF protocol needs to retrieve the same meta-data that is 2040 used in the NETCONF protocol. Information about default leafs, last- 2041 modified timestamps, etc. are commonly used to annotate 2042 representations of the datastore contents. This meta-data is not 2043 defined in the YANG schema because it applies to the datastore, and 2044 is common across all data nodes. 2046 This information is encoded as attributes in XML. JSON encoding of 2047 meta-data is defined in [I-D.ietf-netmod-yang-metadata]. 2049 5.5. Return Status 2051 Each message represents some sort of resource access. An HTTP 2052 "status-line" header line is returned for each request. If a 4xx or 2053 5xx range status code is returned in the status-line, then the error 2054 information will be returned in the response, according to the format 2055 defined in Section 7.1. 2057 5.6. Message Caching 2059 Since the datastore contents change at unpredictable times, responses 2060 from a RESTCONF server generally SHOULD NOT be cached. 2062 The server SHOULD include a "Cache-Control" header in every response 2063 that specifies whether the response should be cached. A "Pragma" 2064 header specifying "no-cache" MAY also be sent in case the 2065 "Cache-Control" header is not supported. 2067 Instead of using HTTP caching, the client SHOULD track the "ETag" 2068 and/or "Last-Modified" headers returned by the server for the 2069 datastore resource (or data resource if the server supports it). A 2070 retrieval request for a resource can include the "If-None-Match" and/ 2071 or "If-Modified-Since" headers, which will cause the server to return 2072 a "304 Not Modified" status-line if the resource has not changed. 2073 The client MAY use the HEAD method to retrieve just the message 2074 headers, which SHOULD include the "ETag" and "Last-Modified" headers, 2075 if this meta-data is maintained for the target resource. 2077 6. Notifications 2079 The RESTCONF protocol supports YANG-defined event notifications. The 2080 solution preserves aspects of NETCONF Event Notifications [RFC5277] 2081 while utilizing the Server-Sent Events [W3C.CR-eventsource-20121211] 2082 transport strategy. 2084 6.1. Server Support 2086 A RESTCONF server is not required to support RESTCONF notifications. 2087 Clients may determine if a server supports RESTCONF notifications by 2088 using the HTTP operation OPTIONS, HEAD, or GET on the stream list. 2089 The server does not support RESTCONF notifications if an HTTP error 2090 code is returned (e.g., 404 Not Found). 2092 6.2. Event Streams 2094 A RESTCONF server that supports notifications will populate a stream 2095 resource for each notification delivery service access point. A 2096 RESTCONF client can retrieve the list of supported event streams from 2097 a RESTCONF server using the GET operation on the stream list. 2099 The "restconf-state/streams" container definition in the 2100 "ietf-restconf-monitoring" module (defined in Section 9.3) is used to 2101 specify the structure and syntax of the conceptual child resources 2102 within the "streams" resource. 2104 For example: 2106 The client might send the following request: 2108 GET /restconf/data/ietf-restconf-monitoring:restconf-state/ 2109 streams HTTP/1.1 2110 Host: example.com 2111 Accept: application/yang.data+xml 2113 The server might send the following response: 2115 HTTP/1.1 200 OK 2116 Content-Type: application/yang.api+xml 2117 2119 2120 NETCONF 2121 default NETCONF event stream 2122 2123 true 2124 2125 2007-07-08T00:00:00Z 2126 2127 2128 xml 2129 https://example.com/streams/NETCONF 2130 2131 2132 2133 json 2134 https://example.com/streams/NETCONF-JSON 2135 2136 2137 2138 2139 SNMP 2140 SNMP notifications 2141 false 2142 2143 xml 2144 https://example.com/streams/SNMP 2145 2146 2147 2148 syslog-critical 2149 Critical and higher severity 2150 2151 true 2152 2153 2007-07-01T00:00:00Z 2154 2155 2156 xml 2157 2158 https://example.com/streams/syslog-critical 2159 2160 2161 2162 2164 6.3. Subscribing to Receive Notifications 2166 RESTCONF clients can determine the URL for the subscription resource 2167 (to receive notifications) by sending an HTTP GET request for the 2168 "location" leaf with the stream list entry. The value returned by 2169 the server can be used for the actual notification subscription. 2171 The client will send an HTTP GET request for the URL returned by the 2172 server with the "Accept" type "text/event-stream". 2174 The server will treat the connection as an event stream, using the 2175 Server Sent Events [W3C.CR-eventsource-20121211] transport strategy. 2177 The server MAY support query parameters for a GET method on this 2178 resource. These parameters are specific to each notification stream. 2180 For example: 2182 The client might send the following request: 2184 GET /restconf/data/ietf-restconf-monitoring:restconf-state/ 2185 streams/stream=NETCONF/access=xml/location HTTP/1.1 2186 Host: example.com 2187 Accept: application/yang.data+xml 2189 The server might send the following response: 2191 HTTP/1.1 200 OK 2192 Content-Type: application/yang.api+xml 2194 2196 https://example.com/streams/NETCONF 2197 2199 The RESTCONF client can then use this URL value to start monitoring 2200 the event stream: 2202 GET /streams/NETCONF HTTP/1.1 2203 Host: example.com 2204 Accept: text/event-stream 2205 Cache-Control: no-cache 2206 Connection: keep-alive 2208 A RESTCONF client MAY request the server compress the events using 2209 the HTTP header field "Accept-Encoding". For instance: 2211 GET /streams/NETCONF HTTP/1.1 2212 Host: example.com 2213 Accept: text/event-stream 2214 Cache-Control: no-cache 2215 Connection: keep-alive 2216 Accept-Encoding: gzip, deflate 2218 6.3.1. NETCONF Event Stream 2220 The server SHOULD support the "NETCONF" notification stream defined 2221 in [RFC5277]. For this stream, RESTCONF notification subscription 2222 requests MAY specify parameters indicating the events it wishes to 2223 receive. These query parameters are optional to implement, and only 2224 available if the server supports them. 2226 +------------+---------+-------------------------+ 2227 | Name | Section | Description | 2228 +------------+---------+-------------------------+ 2229 | start-time | 4.8.7 | replay event start time | 2230 | stop-time | 4.8.8 | replay event stop time | 2231 | filter | 4.8.6 | boolean content filter | 2232 +------------+---------+-------------------------+ 2234 NETCONF Stream Query Parameters 2236 The semantics and syntax for these query parameters are defined in 2237 the sections listed above. The YANG encoding MUST be converted to 2238 URL-encoded string for use in the request URI. 2240 Refer to Appendix D.3.6 for filter parameter examples. 2242 6.4. Receiving Event Notifications 2244 RESTCONF notifications are encoded according to the definition of the 2245 event stream. The NETCONF stream defined in [RFC5277] is encoded in 2246 XML format. 2248 The structure of the event data is based on the "notification" 2249 element definition in Section 4 of [RFC5277]. It MUST conform to the 2250 schema for the "notification" element in Section 4 of [RFC5277], 2251 except the XML namespace for this element is defined as: 2253 urn:ietf:params:xml:ns:yang:ietf-restconf 2255 For JSON encoding purposes, the module name for the "notification" 2256 element is "ietf-restconf". 2258 Two child nodes within the "notification" container are expected, 2259 representing the event time and the event payload. The "event-time" 2260 node is defined within the "ietf-restconf" module namespace. The 2261 name and namespace of the payload element are determined by the YANG 2262 module containing the notification-stmt. 2264 In the following example, the YANG module "example-mod" is used: 2266 module example-mod { 2267 namespace "http://example.com/event/1.0"; 2269 notification event { 2270 leaf event-class { type string; } 2271 container reporting-entity { 2272 leaf card { type string; } 2273 } 2274 leaf severity { type string; } 2275 } 2276 } 2278 An example SSE event notification encoded using XML: 2280 data: 2282 data: 2013-12-21T00:01:00Z 2283 data: 2284 data: fault 2285 data: 2286 data: Ethernet0 2287 data: 2288 data: major 2289 data: 2290 data: 2292 An example SSE event notification encoded using JSON: 2294 data: { 2295 data: "ietf-restconf:notification": { 2296 data: "event-time": "2013-12-21T00:01:00Z", 2297 data: "example-mod:event": { 2298 data: "event-class": "fault", 2299 data: "reporting-entity": { "card": "Ethernet0" }, 2300 data: "severity": "major" 2301 data: } 2302 data: } 2303 data: } 2305 Alternatively, since neither XML nor JSON are whitespace sensitive, 2306 the above messages can be encoded onto a single line. For example: 2308 For example: ('\' line wrapping added for formatting only) 2310 XML: 2312 data: 2013-12-21T00:01:00ZfaultEthernet0\ 2316 major 2318 JSON: 2320 data: {"ietf-restconf:notification":{"event-time":"2013-12-21\ 2321 T00:01:00Z","example-mod:event":{"event-class": "fault","repor\ 2322 tingEntity":{"card":"Ethernet0"},"severity":"major"}}} 2324 The SSE specifications supports the following additional fields: 2325 event, id and retry. A RESTCONF server MAY send the "retry" field 2326 and, if it does, RESTCONF clients SHOULD use it. A RESTCONF server 2327 SHOULD NOT send the "event" or "id" fields, as there are no 2328 meaningful values that could be used for them that would not be 2329 redundant to the contents of the notification itself. RESTCONF 2330 servers that do not send the "id" field also do not need to support 2331 the HTTP header "Last-Event-Id". RESTCONF servers that do send the 2332 "id" field MUST still support the "startTime" query parameter as the 2333 preferred means for a client to specify where to restart the event 2334 stream. 2336 7. Error Reporting 2338 HTTP status-lines are used to report success or failure for RESTCONF 2339 operations. The element returned in NETCONF error 2340 responses contains some useful information. This error information 2341 is adapted for use in RESTCONF, and error information is returned for 2342 "4xx" class of status codes. 2344 The following table summarizes the return status codes used 2345 specifically by RESTCONF operations: 2347 +---------------------------+---------------------------------------+ 2348 | Status-Line | Description | 2349 +---------------------------+---------------------------------------+ 2350 | 100 Continue | POST accepted, 201 should follow | 2351 | 200 OK | Success with response message-body | 2352 | 201 Created | POST to create a resource success | 2353 | 202 Accepted | POST to create a resource accepted | 2354 | 204 No Content | Success without response message-body | 2355 | 304 Not Modified | Conditional operation not done | 2356 | 400 Bad Request | Invalid request message | 2357 | 403 Forbidden | Access to resource denied | 2358 | 404 Not Found | Resource target or resource node not | 2359 | | found | 2360 | 405 Method Not Allowed | Method not allowed for target | 2361 | | resource | 2362 | 409 Conflict | Resource or lock in use | 2363 | 412 Precondition Failed | Conditional method is false | 2364 | 413 Request Entity Too | too-big error | 2365 | Large | | 2366 | 414 Request-URI Too Large | too-big error | 2367 | 415 Unsupported Media | non RESTCONF media type | 2368 | Type | | 2369 | 500 Internal Server Error | operation-failed | 2370 | 501 Not Implemented | unknown-operation | 2371 | 503 Service Unavailable | Recoverable server error | 2372 +---------------------------+---------------------------------------+ 2374 HTTP Status Codes used in RESTCONF 2376 Since an operation resource is defined with a YANG "rpc" statement, a 2377 mapping between the NETCONF value and the HTTP status 2378 code is needed. The specific error condition and response code to 2379 use are data-model specific and might be contained in the YANG 2380 "description" statement for the "rpc" statement. 2382 +-------------------------+-------------+ 2383 | | status code | 2384 +-------------------------+-------------+ 2385 | in-use | 409 | 2386 | invalid-value | 400 | 2387 | too-big | 413 | 2388 | missing-attribute | 400 | 2389 | bad-attribute | 400 | 2390 | unknown-attribute | 400 | 2391 | bad-element | 400 | 2392 | unknown-element | 400 | 2393 | unknown-namespace | 400 | 2394 | access-denied | 403 | 2395 | lock-denied | 409 | 2396 | resource-denied | 409 | 2397 | rollback-failed | 500 | 2398 | data-exists | 409 | 2399 | data-missing | 409 | 2400 | operation-not-supported | 501 | 2401 | operation-failed | 500 | 2402 | partial-operation | 500 | 2403 | malformed-message | 400 | 2404 +-------------------------+-------------+ 2406 Mapping from error-tag to status code 2408 7.1. Error Response Message 2410 When an error occurs for a request message on a data resource or an 2411 operation resource, and a "4xx" class of status codes (except for 2412 status code "403 Forbidden"), then the server SHOULD send a response 2413 message-body containing the information described by the "errors" 2414 container definition within the YANG module Section 8. The Content- 2415 Type of this response message MUST be application/yang.errors (see 2416 example below). 2418 The client MAY specify the desired encoding for error messages by 2419 specifying the appropriate media-type in the Accept header. If no 2420 error media is specified, the server MUST assume that "application/ 2421 yang.errors+xml" was specified. All of the examples in this 2422 document, except for the one below, assume the default XML encoding 2423 will be returned if there is an error. 2425 YANG Tree Diagram for Data: 2427 +--ro errors 2428 +--ro error 2429 +--ro error-type enumeration 2430 +--ro error-tag string 2431 +--ro error-app-tag? string 2432 +--ro error-path? instance-identifier 2433 +--ro error-message? string 2434 +--ro error-info 2436 The semantics and syntax for RESTCONF error messages are defined in 2437 the "application/yang.errors" restconf-media-type extension in 2438 Section 8. 2440 Examples: 2442 The following example shows an error returned for an "lock-denied" 2443 error that can occur if a NETCONF client has locked a datastore. The 2444 RESTCONF client is attempting to delete a data resource. Note that 2445 an Accept header is used to specify the desired encoding for the 2446 error message. This example's use of the Accept header is especially 2447 notable since the DELETE method typically doesn't return a message- 2448 body and hence Accept headers are typically not passed. 2450 DELETE /restconf/data/example-jukebox:jukebox/ 2451 library/artist=Foo%20Fighters/album=Wasting%20Light HTTP/1.1 2452 Host: example.com 2453 Accept: application/yang.errors+json 2455 The server might respond: 2457 HTTP/1.1 409 Conflict 2458 Date: Mon, 23 Apr 2012 17:11:00 GMT 2459 Server: example-server 2460 Content-Type: application/yang.errors+json 2462 { 2463 "ietf-restconf:errors": { 2464 "error": { 2465 "error-type": "protocol", 2466 "error-tag": "lock-denied", 2467 "error-message": "Lock failed, lock already held" 2468 } 2469 } 2470 } 2472 The following example shows an error returned for a "data-exists" 2473 error on a data resource. The "jukebox" resource already exists so 2474 it cannot be created. 2476 The client might send: 2478 POST /restconf/data/example-jukebox:jukebox HTTP/1.1 2479 Host: example.com 2481 The server might respond: 2483 HTTP/1.1 409 Conflict 2484 Date: Mon, 23 Apr 2012 17:11:00 GMT 2485 Server: example-server 2486 Content-Type: application/yang.errors+json 2488 { 2489 "ietf-restconf:errors": { 2490 "error": { 2491 "error-type": "protocol", 2492 "error-tag": "data-exists", 2493 "error-urlpath": "https://example.com/restconf/data/ 2494 example-jukebox:jukebox", 2495 "error-message": 2496 "Data already exists, cannot create new resource" 2497 } 2498 } 2499 } 2501 8. RESTCONF module 2503 The "ietf-restconf" module defines conceptual definitions within an 2504 extension and two groupings, which are not meant to be implemented as 2505 datastore contents by a server. E.g., the "restconf" container is 2506 not intended to be implemented as a top-level data node (under the 2507 "/restconf/data" entry point). 2509 RFC Ed.: update the date below with the date of RFC publication and 2510 remove this note. 2512 file "ietf-restconf@2015-06-04.yang" 2514 module ietf-restconf { 2515 namespace "urn:ietf:params:xml:ns:yang:ietf-restconf"; 2516 prefix "rc"; 2518 organization 2519 "IETF NETCONF (Network Configuration) Working Group"; 2521 contact 2522 "WG Web: 2523 WG List: 2524 WG Chair: Mehmet Ersue 2525 2527 WG Chair: Mahesh Jethanandani 2528 2530 Editor: Andy Bierman 2531 2533 Editor: Martin Bjorklund 2534 2536 Editor: Kent Watsen 2537 "; 2539 description 2540 "This module contains conceptual YANG specifications 2541 for basic RESTCONF media type definitions used in 2542 RESTCONF protocol messages. 2544 Note that the YANG definitions within this module do not 2545 represent configuration data of any kind. 2546 The 'restconf-media-type' YANG extension statement 2547 provides a normative syntax for XML and JSON message 2548 encoding purposes. 2550 Copyright (c) 2015 IETF Trust and the persons identified as 2551 authors of the code. All rights reserved. 2553 Redistribution and use in source and binary forms, with or 2554 without modification, is permitted pursuant to, and subject 2555 to the license terms contained in, the Simplified BSD License 2556 set forth in Section 4.c of the IETF Trust's Legal Provisions 2557 Relating to IETF Documents 2558 (http://trustee.ietf.org/license-info). 2560 This version of this YANG module is part of RFC XXXX; see 2561 the RFC itself for full legal notices."; 2563 // RFC Ed.: replace XXXX with actual RFC number and remove this 2564 // note. 2566 // RFC Ed.: remove this note 2567 // Note: extracted from draft-ietf-netconf-restconf-06.txt 2569 // RFC Ed.: update the date below with the date of RFC publication 2570 // and remove this note. 2571 revision 2015-06-04 { 2572 description 2573 "Initial revision."; 2574 reference 2575 "RFC XXXX: RESTCONF Protocol."; 2576 } 2578 extension restconf-media-type { 2579 argument media-type-id { 2580 yin-element true; 2581 } 2582 // RFC Ed.: replace draft-ietf-netmod-yang-json with RFC number 2583 // in the description below, and remove this note. 2584 description 2585 "This extension is used to specify a YANG data structure which 2586 represents a conceptual RESTCONF media type. 2587 Data definition statements within this extension specify 2588 the generic syntax for the specific media type. 2590 YANG is mapped to specific encoding formats outside the 2591 scope of this extension statement. RFC 6020 defines XML 2592 encoding rules for all RESTCONF media types that use 2593 the '+xml' suffix. draft-ietf-netmod-yang-json defines 2594 JSON encoding rules for all RESTCONF media types that 2595 use the '+json' suffix. 2597 The 'media-type-id' parameter value identifies the media type 2598 that is being defined. It contains the string associated 2599 with the generic media type, i.e., no suffix is specified. 2601 This extension is ignored unless it appears as a top-level 2602 statement. It SHOULD contain data definition statements 2603 that result in exactly one container data node definition. 2604 This allows compliant translation to an XML instance 2605 document for each media type. 2607 The module name and namespace value for the YANG module using 2608 the extension statement is assigned to instance document data 2609 conforming to the data definition statements within 2610 this extension. 2612 The sub-statements of this extension MUST follow the 2613 'data-def-stmt' rule in the YANG ABNF. 2615 The XPath document root is the extension statement itself, 2616 such that the child nodes of the document root are 2617 represented by the data-def-stmt sub-statements within 2618 this extension. This conceptual document is the context 2619 for the following YANG statements: 2621 - must-stmt 2622 - when-stmt 2623 - path-stmt 2624 - min-elements-stmt 2625 - max-elements-stmt 2626 - mandatory-stmt 2627 - unique-stmt 2628 - ordered-by 2629 - instance-identifier data type 2631 The following data-def-stmt sub-statements have special 2632 meaning when used within a restconf-resource extension 2633 statement. 2635 - The list-stmt is not required to have a key-stmt defined. 2636 - The if-feature-stmt is ignored if present. 2637 - The config-stmt is ignored if present. 2638 - The available identity values for any 'identityref' 2639 leaf or leaf-list nodes is limited to the module 2640 containing this extension statement, and the modules 2641 imported into that module. 2642 "; 2643 } 2645 rc:restconf-media-type "application/yang.errors" { 2646 uses errors; 2647 } 2649 rc:restconf-media-type "application/yang.api" { 2650 uses restconf; 2651 } 2653 grouping errors { 2654 description 2655 "A grouping that contains a YANG container 2656 representing the syntax and semantics of a 2657 YANG Patch errors report within a response message."; 2659 container errors { 2660 description 2661 "Represents an error report returned by the server if 2662 a request results in an error."; 2664 list error { 2665 description 2666 "An entry containing information about one 2667 specific error that occurred while processing 2668 a RESTCONF request."; 2670 reference "RFC 6241, Section 4.3"; 2672 leaf error-type { 2673 type enumeration { 2674 enum transport { 2675 description "The transport layer"; 2676 } 2677 enum rpc { 2678 description "The rpc or notification layer"; 2679 } 2680 enum protocol { 2681 description "The protocol operation layer"; 2682 } 2683 enum application { 2684 description "The server application layer"; 2685 } 2686 } 2687 mandatory true; 2688 description 2689 "The protocol layer where the error occurred."; 2690 } 2692 leaf error-tag { 2693 type string; 2694 mandatory true; 2695 description 2696 "The enumerated error tag."; 2697 } 2699 leaf error-app-tag { 2700 type string; 2701 description 2702 "The application-specific error tag."; 2703 } 2705 leaf error-path { 2706 type instance-identifier; 2707 description 2708 "The YANG instance identifier associated 2709 with the error node."; 2710 } 2712 leaf error-message { 2713 type string; 2714 description 2715 "A message describing the error."; 2716 } 2717 anyxml error-info { 2718 description 2719 "Arbitrary XML that represents a container 2720 of additional information for the error report."; 2721 } 2722 } 2723 } 2724 } 2726 grouping restconf { 2727 description 2728 "Conceptual container representing the 2729 application/yang.api resource type."; 2731 container restconf { 2732 description 2733 "Conceptual container representing the 2734 application/yang.api resource type."; 2736 container data { 2737 description 2738 "Container representing the application/yang.datastore 2739 resource type. Represents the conceptual root of all 2740 operational data and configuration data supported by 2741 the server. The child nodes of this container can be 2742 any data resource (application/yang.data), which are 2743 defined as top-level data nodes from the YANG modules 2744 advertised by the server in the ietf-restconf-monitoring 2745 module."; 2746 } 2748 container operations { 2749 description 2750 "Container for all operation resources 2751 (application/yang.operation), 2753 Each resource is represented as an empty leaf with the 2754 name of the RPC operation from the YANG rpc statement. 2756 E.g.; 2758 POST /restconf/operations/show-log-errors 2760 leaf show-log-errors { 2761 type empty; 2762 } 2763 "; 2764 } 2766 } 2767 } 2769 } 2771 2773 9. RESTCONF Monitoring 2775 The "ietf-restconf-monitoring" module provides information about the 2776 RESTCONF protocol capabilities and event notification streams 2777 available from the server. Implementation is mandatory for RESTCONF 2778 servers, if any protocol capabilities or event notification streams 2779 are supported. 2781 YANG Tree Diagram for "ietf-restconf-monitoring" module: 2783 +--ro restconf-state 2784 +--ro capabilities 2785 | +--ro capability* inet:uri 2786 +--ro streams 2787 +--ro stream* [name] 2788 +--ro name string 2789 +--ro description? string 2790 +--ro replay-support? boolean 2791 +--ro replay-log-creation-time? yang:date-and-time 2792 +--ro access* [type] 2793 +--ro encoding string 2794 +--ro location inet:uri 2796 9.1. restconf-state/capabilities 2798 This mandatory container holds the RESTCONF protocol capability URIs 2799 supported by the server. 2801 The server MUST maintain a last-modified timestamp for this 2802 container, and return the "Last-Modified" header when this data node 2803 is retrieved with the GET or HEAD methods. 2805 The server SHOULD maintain an entity-tag for this container, and 2806 return the "ETag" header when this data node is retrieved with the 2807 GET or HEAD methods. 2809 The server MUST include a "capability" URI leaf-list entry for the 2810 "defaults" mode used by the server, defined in Section 9.1.2. 2812 The server MUST include a "capability" URI leaf-list entry 2813 identifying each supported optional protocol feature. This includes 2814 optional query parameters and MAY include other capability URIs 2815 defined outside this document. 2817 9.1.1. Query Parameter URIs 2819 A new set of RESTCONF Capability URIs are defined to identify the 2820 specific query parameters (defined in Section 4.8) supported by the 2821 server. 2823 The server MUST include a "capability" leaf-list entry for each 2824 optional query parameter that it supports. 2826 +------------+--------+---------------------------------------------+ 2827 | Name | Sectio | URI | 2828 | | n | | 2829 +------------+--------+---------------------------------------------+ 2830 | depth | 4.8.2 | urn:ietf:params:restconf:capability:depth:1 | 2831 | | | .0 | 2832 | fields | 4.8.3 | urn:ietf:params:restconf:capability:fields: | 2833 | | | 1.0 | 2834 | filter | 4.8.6 | urn:ietf:params:restconf:capability:filter: | 2835 | | | 1.0 | 2836 | replay | 4.8.7 | urn:ietf:params:restconf:capability:replay: | 2837 | | 4.8.8 | 1.0 | 2838 | with- | 4.8.9 | urn:ietf:params:restconf:capability:with- | 2839 | defaults | | defaults:1.0 | 2840 +------------+--------+---------------------------------------------+ 2842 RESTCONF Query Parameter URIs 2844 9.1.2. The "defaults" Protocol Capability URI 2846 This URI identifies the defaults handling mode that is used by the 2847 server for processing default leafs in requests for data resources. 2848 A parameter named "basic-mode" is required for this capability URI. 2849 The "basic-mode" definitions are specified in the "With-Defaults 2850 Capability for NETCONF" [RFC6243]. 2852 +----------+--------------------------------------------------+ 2853 | Name | URI | 2854 +----------+--------------------------------------------------+ 2855 | defaults | urn:ietf:params:restconf:capability:defaults:1.0 | 2856 +----------+--------------------------------------------------+ 2858 RESTCONF defaults capability URI 2860 This protocol capability URI MUST be supported by the server, and the 2861 MUST be listed in the "capability" leaf-list in Section 9.3. 2863 +------------+------------------------------------------------------+ 2864 | Value | Description | 2865 +------------+------------------------------------------------------+ 2866 | report-all | No data nodes are considered default | 2867 | trim | Values set to the YANG default-stmt value are | 2868 | | default | 2869 | explicit | Values set by the client are never considered | 2870 | | default | 2871 +------------+------------------------------------------------------+ 2873 If the "basic-mode" is set to "report-all" then the server MUST 2874 adhere to the defaults handling behavior defined in Section 2.1 of 2875 [RFC6243]. 2877 If the "basic-mode" is set to "trim" then the server MUST adhere to 2878 the defaults handling behavior defined in Section 2.2 of [RFC6243]. 2880 If the "basic-mode" is set to "explicit" then the server MUST adhere 2881 to the defaults handling behavior defined in Section 2.3 of 2882 [RFC6243]. 2884 Example: (split for display purposes only) 2886 urn:ietf:params:restconf:capability:defaults:1.0? 2887 basic-mode=explicit 2889 9.2. restconf-state/streams 2891 This optional container provides access to the event notification 2892 streams supported by the server. The server MAY omit this container 2893 if no event notification streams are supported. 2895 The server will populate this container with a stream list entry for 2896 each stream type it supports. Each stream contains a leaf called 2897 "events" which contains a URI that represents an event stream 2898 resource. 2900 Stream resources are defined in Section 3.8. Notifications are 2901 defined in Section 6. 2903 9.3. RESTCONF Monitoring Module 2905 The "ietf-restconf-monitoring" module defines monitoring information 2906 for the RESTCONF protocol. 2908 The "ietf-yang-types" and "ietf-inet-types" modules from [RFC6991] 2909 are used by this module for some type definitions. 2911 RFC Ed.: update the date below with the date of RFC publication and 2912 remove this note. 2914 file "ietf-restconf-monitoring@2015-06-19.yang" 2916 module ietf-restconf-monitoring { 2917 namespace "urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring"; 2918 prefix "rcmon"; 2920 import ietf-yang-types { prefix yang; } 2921 import ietf-inet-types { prefix inet; } 2923 organization 2924 "IETF NETCONF (Network Configuration) Working Group"; 2926 contact 2927 "WG Web: 2928 WG List: 2930 WG Chair: Mehmet Ersue 2931 2933 WG Chair: Mahesh Jethanandani 2934 2936 Editor: Andy Bierman 2937 2939 Editor: Martin Bjorklund 2940 2942 Editor: Kent Watsen 2943 "; 2945 description 2946 "This module contains monitoring information for the 2947 RESTCONF protocol. 2949 Copyright (c) 2015 IETF Trust and the persons identified as 2950 authors of the code. All rights reserved. 2952 Redistribution and use in source and binary forms, with or 2953 without modification, is permitted pursuant to, and subject 2954 to the license terms contained in, the Simplified BSD License 2955 set forth in Section 4.c of the IETF Trust's Legal Provisions 2956 Relating to IETF Documents 2957 (http://trustee.ietf.org/license-info). 2958 This version of this YANG module is part of RFC XXXX; see 2959 the RFC itself for full legal notices."; 2961 // RFC Ed.: replace XXXX with actual RFC number and remove this 2962 // note. 2964 // RFC Ed.: remove this note 2965 // Note: extracted from draft-ietf-netconf-restconf-06.txt 2967 // RFC Ed.: update the date below with the date of RFC publication 2968 // and remove this note. 2969 revision 2015-06-19 { 2970 description 2971 "Initial revision."; 2972 reference 2973 "RFC XXXX: RESTCONF Protocol."; 2974 } 2976 container restconf-state { 2977 config false; 2978 description 2979 "Contains RESTCONF protocol monitoring information."; 2981 container capabilities { 2982 description 2983 "Contains a list of protocol capability URIs"; 2985 leaf-list capability { 2986 type inet:uri; 2987 description "A RESTCONF protocol capability URI."; 2988 } 2989 } 2991 container streams { 2992 description 2993 "Container representing the notification event streams 2994 supported by the server."; 2995 reference 2996 "RFC 5277, Section 3.4, element."; 2998 list stream { 2999 key name; 3000 description 3001 "Each entry describes an event stream supported by 3002 the server."; 3004 leaf name { 3005 type string; 3006 description "The stream name"; 3007 reference "RFC 5277, Section 3.4, element."; 3008 } 3010 leaf description { 3011 type string; 3012 description "Description of stream content"; 3013 reference 3014 "RFC 5277, Section 3.4, element."; 3015 } 3017 leaf replay-support { 3018 type boolean; 3019 description 3020 "Indicates if replay buffer supported for this stream. 3021 If 'true', then the server MUST support the 'start-time' 3022 and 'stop-time' query parameters for this stream."; 3023 reference 3024 "RFC 5277, Section 3.4, element."; 3025 } 3027 leaf replay-log-creation-time { 3028 when "../replay-support" { 3029 description 3030 "Only present if notification replay is supported"; 3031 } 3032 type yang:date-and-time; 3033 description 3034 "Indicates the time the replay log for this stream 3035 was created."; 3036 reference 3037 "RFC 5277, Section 3.4, 3038 element."; 3039 } 3041 list access { 3042 key encoding; 3043 min-elements 1; 3044 description 3045 "The server will create an entry in this list for each 3046 encoding format that is supported for this stream. 3047 The media type 'application/yang.stream' is expected 3048 for all event streams. This list identifies the 3049 sub-types supported for this stream."; 3051 leaf encoding { 3052 type string; 3053 description 3054 "This is the secondary encoding format within the 3055 'text/event-stream' encoding used by all streams. 3056 The type 'xml' is supported for the media type 3057 'application/yang.stream+xml'. The type 'json' 3058 is supported for the media type 3059 'application/yang.stream+json'."; 3061 } 3063 leaf location { 3064 type inet:uri; 3065 mandatory true; 3066 description 3067 "Contains a URL that represents the entry point 3068 for establishing notification delivery via server 3069 sent events."; 3070 } 3071 } 3072 } 3073 } 3074 } 3076 } 3078 3080 10. YANG Module Library 3082 The "ietf-yang-library" module defined in 3083 [I-D.ietf-netconf-yang-library] provides information about the YANG 3084 modules and submodules used by the RESTCONF server. Implementation 3085 is mandatory for RESTCONF servers. All YANG modules and submodules 3086 used by the server MUST be identified in the YANG module library. 3088 10.1. modules 3090 This mandatory container holds the identifiers for the YANG data 3091 model modules supported by the server. 3093 The server MUST maintain a last-modified timestamp for this 3094 container, and return the "Last-Modified" header when this data node 3095 is retrieved with the GET or HEAD methods. 3097 The server SHOULD maintain an entity-tag for this container, and 3098 return the "ETag" header when this data node is retrieved with the 3099 GET or HEAD methods. 3101 10.1.1. modules/module 3103 This mandatory list contains one entry for each YANG data model 3104 module supported by the server. There MUST be an instance of this 3105 list for every YANG module that is used by the server. 3107 The contents of this list are defined in the "module" YANG list 3108 statement in [I-D.ietf-netconf-yang-library]. 3110 The server MAY maintain a last-modified timestamp for each instance 3111 of this list entry, and return the "Last-Modified" header when this 3112 data node is retrieved with the GET or HEAD methods. If not 3113 supported then the timestamp for the parent "modules" container MAY 3114 be used instead. 3116 The server MAY maintain an entity-tag for each instance of this list 3117 entry, and return the "ETag" header when this data node is retrieved 3118 with the GET or HEAD methods. If not supported then the timestamp 3119 for the parent "modules" container MAY be used instead. 3121 11. IANA Considerations 3123 11.1. The "restconf" Relation Type 3125 This specification registers the "restconf" relation type in the Link 3126 Relation Type Registry defined by [RFC5988]: 3128 Relation Name: restconf 3130 Description: Identifies the root of RESTCONF API as configured 3131 on this HTTP server. The "restconf" relation 3132 defines the root of the API defined in RFCXXXX. 3133 Subsequent revisions of RESTCONF will use alternate 3134 relation values to support protocol versioning. 3136 Reference: RFC XXXX 3138 ` 3140 11.2. YANG Module Registry 3142 This document registers two URIs in the IETF XML registry [RFC3688]. 3143 Following the format in RFC 3688, the following registration is 3144 requested to be made. 3146 URI: urn:ietf:params:xml:ns:yang:ietf-restconf 3147 Registrant Contact: The NETMOD WG of the IETF. 3148 XML: N/A, the requested URI is an XML namespace. 3150 URI: urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring 3151 Registrant Contact: The NETMOD WG of the IETF. 3152 XML: N/A, the requested URI is an XML namespace. 3154 This document registers two YANG modules in the YANG Module Names 3155 registry [RFC6020]. 3157 name: ietf-restconf 3158 namespace: urn:ietf:params:xml:ns:yang:ietf-restconf 3159 prefix: rc 3160 // RFC Ed.: replace XXXX with RFC number and remove this note 3161 reference: RFC XXXX 3163 name: ietf-restconf-monitoring 3164 namespace: urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring 3165 prefix: rcmon 3166 // RFC Ed.: replace XXXX with RFC number and remove this note 3167 reference: RFC XXXX 3169 11.3. application/yang Media Sub Types 3171 The parent MIME media type for RESTCONF resources is application/ 3172 yang, which is defined in [RFC6020]. This document defines the 3173 following sub-types for this media type. 3175 - api 3176 - data 3177 - datastore 3178 - errors 3179 - operation 3180 - stream 3182 Type name: application 3184 Subtype name: yang.xxx 3186 Required parameters: none 3188 Optional parameters: See section 4.8 in RFC XXXX 3190 Encoding considerations: 8-bit 3192 Security considerations: See Section 12 in RFC XXXX 3194 Interoperability considerations: none 3196 // RFC Ed.: replace XXXX with RFC number and remove this note 3197 Published specification: RFC XXXX 3199 11.4. RESTCONF Capability URNs 3201 [Note to RFC Editor: 3202 The RESTCONF Protocol Capability Registry does not yet exist; 3203 Need to ask IANA to create it; remove this note for publication 3204 ] 3206 This document defines a registry for RESTCONF capability identifiers. 3207 The name of the registry is "RESTCONF Capability URNs". The registry 3208 shall record for each entry: 3210 o the name of the RESTCONF capability. By convention, this name is 3211 prefixed with the colon ':' character. 3213 o the URN for the RESTCONF capability. 3215 This document registers several capability identifiers in "RESTCONF 3216 Capability URNs" registry: 3218 Index 3219 Capability Identifier 3220 ------------------------ 3222 :defaults 3223 urn:ietf:params:restconf:capability:defaults:1.0 3225 :depth 3226 urn:ietf:params:restconf:capability:depth:1.0 3228 :fields 3229 urn:ietf:params:restconf:capability:fields:1.0 3231 :filter 3232 urn:ietf:params:restconf:capability:filter:1.0 3234 :replay 3235 urn:ietf:params:restconf:capability:replay:1.0 3237 :with-defaults 3238 urn:ietf:params:restconf:capability:with-defaults:1.0 3240 12. Security Considerations 3242 This section provides security considerations for the resources 3243 defined by the RESTCONF protocol. Security considerations for HTTPS 3244 are defined in [RFC2818]. Security considerations for the content 3245 manipulated by RESTCONF can be found in the documents defining data 3246 models. 3248 This document does not specify an authentication scheme, but it does 3249 require that an authenticated NETCONF username be associated with 3250 each HTTP request. The authentication scheme MAY be implemented in 3251 the underlying transport layer (e.g., client certificates) or within 3252 the HTTP layer (e.g., Basic Auth, OAuth, etc.). RESTCONF does not 3253 itself define an authentication mechanism. Authentication MUST occur 3254 in a lower layer. Implementors SHOULD provide a comprehensive 3255 authorization scheme with RESTCONF and ensure that the resulting 3256 NETCONF username is made available to the RESTCONF server. 3258 Authorization of individual user access to operations and data MAY be 3259 configured via NETCONF Access Control Model (NACM) [RFC6536], as 3260 specified in Section 4. 3262 Configuration information is by its very nature sensitive. Its 3263 transmission in the clear and without integrity checking leaves 3264 devices open to classic eavesdropping and false data injection 3265 attacks. Configuration information often contains passwords, user 3266 names, service descriptions, and topological information, all of 3267 which are sensitive. Because of this, this protocol SHOULD be 3268 implemented carefully with adequate attention to all manner of attack 3269 one might expect to experience with other management interfaces. 3271 Different environments may well allow different rights prior to and 3272 then after authentication. When an operation is not properly 3273 authorized, the RESTCONF server MUST return HTTP error status code 3274 401 Unauthorized. Note that authorization information can be 3275 exchanged in the form of configuration information, which is all the 3276 more reason to ensure the security of the connection. 3278 13. Acknowledgements 3280 The authors would like to thank the following people for their 3281 contributions to this document: Ladislav Lhotka, Juergen 3282 Schoenwaelder, Rex Fernando, Robert Wilton, and Jonathan Hansford. 3284 14. References 3286 14.1. Normative References 3288 [I-D.ietf-netconf-yang-library] 3289 Bierman, A., Bjorklund, M., and K. Watsen, "YANG Module 3290 Library", draft-ietf-netconf-yang-library-00 (work in 3291 progress), January 2015. 3293 [I-D.ietf-netmod-yang-json] 3294 Lhotka, L., "JSON Encoding of Data Modeled with YANG", 3295 draft-ietf-netmod-yang-json-03 (work in progress), 3296 February 2015. 3298 [I-D.ietf-netmod-yang-metadata] 3299 Lhotka, L., "Defining and Using Metadata with YANG", 3300 draft-ietf-netmod-yang-metadata-00 (work in progress), 3301 April 2015. 3303 [RFC2046] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 3304 Extensions (MIME) Part Two: Media Types", RFC 2046, 3305 November 1996. 3307 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 3308 Requirement Levels", BCP 14, RFC 2119, March 1997. 3310 [RFC2396] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 3311 Resource Identifiers (URI): Generic Syntax", RFC 2396, 3312 August 1998. 3314 [RFC2818] Rescorla, E., "The IETF XML Registry", RFC 2818, May 2000. 3316 [RFC3688] Mealling, M., "The IETF XML Registry", BCP 81, RFC 3688, 3317 January 2004. 3319 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 3320 Resource Identifier (URI): Generic Syntax", STD 66, RFC 3321 3986, January 2005. 3323 [RFC4252] Ylonen, T. and C. Lonvick, "The Secure Shell (SSH) 3324 Authentication Protocol", RFC 4252, January 2006. 3326 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 3327 (TLS) Protocol Version 1.2", RFC 5246, August 2008. 3329 [RFC5277] Chisholm, S. and H. Trevino, "NETCONF Event 3330 Notifications", RFC 5277, July 2008. 3332 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 3333 Housley, R., and T. Polk, "Internet X.509 Public Key 3334 Infrastructure Certificate and Certificate Revocation List 3335 (CRL) Profile", RFC 5280, May 2008. 3337 [RFC5789] Dusseault, L. and J. Snell, "PATCH Method for HTTP", RFC 3338 5789, March 2010. 3340 [RFC5988] Nottingham, M., "Web Linking", RFC 5988, October 2010. 3342 [RFC6020] Bjorklund, M., "YANG - A Data Modeling Language for the 3343 Network Configuration Protocol (NETCONF)", RFC 6020, 3344 October 2010. 3346 [RFC6125] Saint-Andre, P. and J. Hodges, "Representation and 3347 Verification of Domain-Based Application Service Identity 3348 within Internet Public Key Infrastructure Using X.509 3349 (PKIX) Certificates in the Context of Transport Layer 3350 Security (TLS)", RFC 6125, March 2011. 3352 [RFC6241] Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed., 3353 and A. Bierman, Ed., "Network Configuration Protocol 3354 (NETCONF)", RFC 6241, June 2011. 3356 [RFC6243] Bierman, A. and B. Lengyel, "With-defaults Capability for 3357 NETCONF", RFC 6243, June 2011. 3359 [RFC6415] Hammer-Lahav, E. and B. Cook, "Web Host Metadata", RFC 3360 6415, October 2011. 3362 [RFC6536] Bierman, A. and M. Bjorklund, "Network Configuration 3363 Protocol (NETCONF) Access Control Model", RFC 6536, March 3364 2012. 3366 [RFC6570] Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., 3367 and D. Orchard, "URI Template", RFC 6570, March 2012. 3369 [RFC6991] Schoenwaelder, J., "Common YANG Data Types", RFC 6991, 3370 July 2013. 3372 [RFC7158] Bray, T., Ed., "The JSON Data Interchange Format", RFC 3373 7158, March 2013. 3375 [RFC7230] Fielding, R. and J. Reschke, "Hypertext Transfer Protocol 3376 (HTTP/1.1): Message Syntax and Routing", RFC 7230, June 3377 2014. 3379 [RFC7231] Fielding, R. and J. Reschke, "Hypertext Transfer Protocol 3380 (HTTP/1.1): Semantics and Content", RFC 7231, June 2014. 3382 [RFC7232] Fielding, R. and J. Reschke, "Hypertext Transfer Protocol 3383 (HTTP/1.1): Conditional Requests", RFC 7232, June 2014. 3385 [RFC7235] Fielding, R. and J. Reschke, "Hypertext Transfer Protocol 3386 (HTTP/1.1): Authentication", RFC 7235, June 2014. 3388 [RFC7320] Nottingham, M., "URI Design and Ownership", BCP 190, RFC 3389 7320, July 2014. 3391 [W3C.CR-eventsource-20121211] 3392 Hickson, I., "Server-Sent Events", World Wide Web 3393 Consortium CR CR-eventsource-20121211, December 2012, 3394 . 3396 [W3C.REC-xml-20081126] 3397 Yergeau, F., Maler, E., Paoli, J., Sperberg-McQueen, C., 3398 and T. Bray, "Extensible Markup Language (XML) 1.0 (Fifth 3399 Edition)", World Wide Web Consortium Recommendation REC- 3400 xml-20081126, November 2008, 3401 . 3403 [XPath] Clark, J. and S. DeRose, "XML Path Language (XPath) 3404 Version 1.0", World Wide Web Consortium Recommendation 3405 REC-xpath-19991116, November 1999, 3406 . 3408 [draft-ietf-httpauth-basicauth-update-03] 3409 Reschke, J., "The 'Basic' HTTP Authentication Scheme", 3410 draft-ietf-httpauth-basicauth-update-03 (work in 3411 progress), Dec 2014. 3413 [draft-ietf-httpauth-digest-09] 3414 Shekh-Yusef, R., Reschke, D., and S. Bremer, "HTTP Digest 3415 Access Authentication", draft-ietf-httpauth-digest-09 3416 (work in progress), Dec 2014. 3418 [draft-ietf-netconf-rfc5539bis-10] 3419 Badra, M., Luchuk, A., and J. Schoenwaelder, "Using the 3420 NETCONF Protocol over Transport Layer Security (TLS) with 3421 Mutual X.509 Authentication", draft-ietf-netconf- 3422 rfc5539bis-10 (work in progress), Dec 2014. 3424 [draft-thomson-httpbis-cant-01] 3425 Thomson, M., "Client Authentication over New TLS 3426 Connection", draft-thomson-httpbis-cant-01 (work in 3427 progress), Jul 2014. 3429 14.2. Informative References 3431 [I-D.ietf-netconf-yang-patch] 3432 Bierman, A., Bjorklund, M., and K. Watsen, "YANG Patch 3433 Media Type", draft-ietf-netconf-yang-patch-04 (work in 3434 progress), June 2015. 3436 [rest-dissertation] 3437 Fielding, R., "Architectural Styles and the Design of 3438 Network-based Software Architectures", 2000. 3440 Appendix A. Change Log 3442 -- RFC Ed.: remove this section before publication. 3444 The RESTCONF issue tracker can be found here: https://github.com/ 3445 netconf-wg/restconf/issues 3447 A.1. 05 - 06 3449 o fixed RESTCONF issue #23 (ietf-restconf-monitoring bug) 3451 A.2. 04 - 05 3453 o changed term 'notification event' to 'event notification' 3455 o removed intro text about framework and meta-model 3456 o removed early mention of API resources 3458 o removed term unified datastore and cleaned up text about NETCONF 3459 datastores 3461 o removed text about not immediate persistence of edits 3463 o removed RESTCONF-specific data-resource-identifier typedef and its 3464 usage 3466 o clarified encoding of key leafs 3468 o changed several examples from JSON to XML encoding 3470 o made 'insert' and 'point' query parameters mandatory to implement 3472 o removed ":insert" capability URI 3474 o renamed stream/encoding to stream/access 3476 o renamed stream/encoding/type to stream/access/encoding 3478 o renamed stream/encoding/events to stream/access/location 3480 o changed XPath from informative to normative reference 3482 o changed rest-dissertation from normative to informative reference 3484 o changed example-jukebox playlist 'id' from a data-resource- 3485 identifier to a leafref pointing at the song name 3487 A.3. 03 - 04 3489 o renamed 'select' to 'fields' (#1) 3491 o moved collection resource and page capability to draft-ietf- 3492 netconf-restconf-collection-00 (#3) 3494 o added mandatory "defaults" protocol capability URI (#4) 3496 o added optional "with-defaults" query parameter URI (#4) 3498 o clarified authentication procedure (#9) 3500 o moved ietf-yang-library module to draft-ietf-netconf-yang- 3501 library-00 (#13) 3503 o clarified that JSON encoding of module name in a URI MUST follow 3504 the netmod-yang-json encoding rules (#14) 3506 o added restconf-media-type extension (#15) 3508 o remove "content" query parameter URI and made this parameter 3509 mandatory (#16) 3511 o clarified datastore usage 3513 o changed lock-denied error example 3515 o added with-defaults query parameter example 3517 o added term "RESTCONF Capability" 3519 o changed NETCONF Capability URI registry usage to new RESTCONF 3520 Capability URI Registry usage 3522 A.4. 02 - 03 3524 o added collection resource 3526 o added "page" query parameter capability 3528 o added "limit" and "offset" query parameters, which are available 3529 if the "page" capability is supported 3531 o added "stream list" term 3533 o fixed bugs in some examples 3535 o added "encoding" list within the "stream" list to allow different 3536 URLs for XML and JSON encoding. 3538 o made XML MUST implement and JSON MAY implement for servers 3540 o re-add JSON notification examples (previously removed) 3542 o updated JSON references 3544 A.5. 01 - 02 3546 o moved query parameter definitions from the YANG module back to the 3547 plain text sections 3549 o made all query parameters optional to implement 3550 o defined query parameter capability URI 3552 o moved 'streams' to new YANG module (ietf-restconf-monitoring) 3554 o added 'capabilities' container to new YANG module (ietf-restconf- 3555 monitoring) 3557 o moved 'modules' container to new YANG module (ietf-yang-library) 3559 o added new leaf 'module-set-id' (ietf-yang-library) 3561 o added new leaf 'conformance' (ietf-yang-library) 3563 o changed 'schema' leaf to type inet:uri that returns the location 3564 of the YANG schema (instead of returning the schema directly) 3566 o changed 'events' leaf to type inet:uri that returns the location 3567 of the event stream resource (instead of returning events 3568 directly) 3570 o changed examples for yang.api resource since the monitoring 3571 information is no longer in this resource 3573 o closed issue #1 'select parameter' since no objections to the 3574 proposed syntax 3576 o closed "encoding of list keys" issue since no objection to new 3577 encoding of list keys in a target resource URI. 3579 o moved open issues list to the issue tracker on github 3581 A.6. 00 - 01 3583 o fixed content=nonconfig example (non-config was incorrect) 3585 o closed open issue 'message-id'. There is no need for a message-id 3586 field, and RFC 2392 does not apply. 3588 o closed open issue 'server support verification'. The headers used 3589 by RESTCONF are widely supported. 3591 o removed encoding rules from section on RESTCONF Meta-Data. This 3592 is now defined in "I-D.lhotka-netmod-yang-json". 3594 o added media type application/yang.errors to map to errors YANG 3595 grouping. Updated error examples to use new media type. 3597 o closed open issue 'additional datastores'. Support may be added 3598 in the future to identify new datastores. 3600 o closed open issue 'PATCH media type discovery'. The section on 3601 PATCH has an added sentence on the Accept-Patch header. 3603 o closed open issue 'YANG to resource mapping'. Current mapping of 3604 all data nodes to resources will be used in order to allow 3605 mandatory DELETE support. The PATCH operation is optional, as 3606 well as the YANG Patch media type. 3608 o closed open issue '_self links for HATEOAS support'. It was 3609 decided that they are redundant because they can be derived from 3610 the YANG module for the specific data. 3612 o added explanatory text for the 'select' parameter. 3614 o added RESTCONF Path Resolution section for discovering the root of 3615 the RESTCONF API using the /.well-known/host-meta. 3617 o added an "error" media type to for structured error messages 3619 o added Secure Transport section requiring TLS 3621 o added Security Considerations section 3623 o removed all references to "REST-like" 3625 A.7. bierman:restconf-04 to ietf:restconf-00 3627 o updated open issues section 3629 Appendix B. Open Issues 3631 -- RFC Ed.: remove this section before publication. 3633 The RESTCONF issues are tracked on github.com: 3635 https://github.com/netconf-wg/restconf/issues 3637 Appendix C. Example YANG Module 3639 The example YANG module used in this document represents a simple 3640 media jukebox interface. 3642 YANG Tree Diagram for "example-jukebox" Module 3643 +--rw jukebox! 3644 +--rw library 3645 | +--rw artist* [name] 3646 | | +--rw name string 3647 | | +--rw album* [name] 3648 | | +--rw name string 3649 | | +--rw genre? identityref 3650 | | +--rw year? uint16 3651 | | +--rw admin 3652 | | | +--rw label? string 3653 | | | +--rw catalogue-number? string 3654 | | +--rw song* [name] 3655 | | +--rw name string 3656 | | +--rw location string 3657 | | +--rw format? string 3658 | | +--rw length? uint32 3659 | +--ro artist-count? uint32 3660 | +--ro album-count? uint32 3661 | +--ro song-count? uint32 3662 +--rw playlist* [name] 3663 | +--rw name string 3664 | +--rw description? string 3665 | +--rw song* [index] 3666 | +--rw index uint32 3667 | +--rw id leafref 3668 +--rw player 3669 +--rw gap? decimal64 3671 rpcs: 3673 +---x play 3674 +--ro input 3675 +--ro playlist string 3676 +--ro song-number uint32 3678 C.1. example-jukebox YANG Module 3680 module example-jukebox { 3682 namespace "http://example.com/ns/example-jukebox"; 3683 prefix "jbox"; 3685 organization "Example, Inc."; 3686 contact "support at example.com"; 3687 description "Example Jukebox Data Model Module"; 3688 revision "2015-04-04" { 3689 description "Initial version."; 3690 reference "example.com document 1-4673"; 3692 } 3694 identity genre { 3695 description "Base for all genre types"; 3696 } 3698 // abbreviated list of genre classifications 3699 identity alternative { 3700 base genre; 3701 description "Alternative music"; 3702 } 3703 identity blues { 3704 base genre; 3705 description "Blues music"; 3706 } 3707 identity country { 3708 base genre; 3709 description "Country music"; 3710 } 3711 identity jazz { 3712 base genre; 3713 description "Jazz music"; 3714 } 3715 identity pop { 3716 base genre; 3717 description "Pop music"; 3718 } 3719 identity rock { 3720 base genre; 3721 description "Rock music"; 3722 } 3724 container jukebox { 3725 presence 3726 "An empty container indicates that the jukebox 3727 service is available"; 3729 description 3730 "Represents a jukebox resource, with a library, playlists, 3731 and a play operation."; 3733 container library { 3735 description "Represents the jukebox library resource."; 3737 list artist { 3738 key name; 3739 description 3740 "Represents one artist resource within the 3741 jukebox library resource."; 3743 leaf name { 3744 type string { 3745 length "1 .. max"; 3746 } 3747 description "The name of the artist."; 3748 } 3750 list album { 3751 key name; 3753 description 3754 "Represents one album resource within one 3755 artist resource, within the jukebox library."; 3757 leaf name { 3758 type string { 3759 length "1 .. max"; 3760 } 3761 description "The name of the album."; 3762 } 3764 leaf genre { 3765 type identityref { base genre; } 3766 description 3767 "The genre identifying the type of music on 3768 the album."; 3769 } 3771 leaf year { 3772 type uint16 { 3773 range "1900 .. max"; 3774 } 3775 description "The year the album was released"; 3776 } 3778 container admin { 3779 description 3780 "Administrative information for the album."; 3782 leaf label { 3783 type string; 3784 description "The label that released the album."; 3785 } 3786 leaf catalogue-number { 3787 type string; 3788 description "The album's catalogue number."; 3789 } 3790 } 3792 list song { 3793 key name; 3795 description 3796 "Represents one song resource within one 3797 album resource, within the jukebox library."; 3799 leaf name { 3800 type string { 3801 length "1 .. max"; 3802 } 3803 description "The name of the song"; 3804 } 3805 leaf location { 3806 type string; 3807 mandatory true; 3808 description 3809 "The file location string of the 3810 media file for the song"; 3811 } 3812 leaf format { 3813 type string; 3814 description 3815 "An identifier string for the media type 3816 for the file associated with the 3817 'location' leaf for this entry."; 3818 } 3819 leaf length { 3820 type uint32; 3821 units "seconds"; 3822 description 3823 "The duration of this song in seconds."; 3824 } 3825 } // end list 'song' 3826 } // end list 'album' 3827 } // end list 'artist' 3829 leaf artist-count { 3830 type uint32; 3831 units "songs"; 3832 config false; 3833 description "Number of artists in the library"; 3834 } 3835 leaf album-count { 3836 type uint32; 3837 units "albums"; 3838 config false; 3839 description "Number of albums in the library"; 3840 } 3841 leaf song-count { 3842 type uint32; 3843 units "songs"; 3844 config false; 3845 description "Number of songs in the library"; 3846 } 3847 } // end library 3849 list playlist { 3850 key name; 3852 description 3853 "Example configuration data resource"; 3855 leaf name { 3856 type string; 3857 description 3858 "The name of the playlist."; 3859 } 3860 leaf description { 3861 type string; 3862 description 3863 "A comment describing the playlist."; 3864 } 3865 list song { 3866 key index; 3867 ordered-by user; 3869 description 3870 "Example nested configuration data resource"; 3872 leaf index { // not really needed 3873 type uint32; 3874 description 3875 "An arbitrary integer index for this playlist song."; 3876 } 3877 leaf id { 3878 type leafref { 3879 path "/jbox:jukebox/jbox:library/jbox:artist/" + 3880 "jbox:album/jbox:song/jbox:name"; 3881 } 3882 mandatory true; 3883 description 3884 "Song identifier. Must identify an instance of 3885 /jukebox/library/artist/album/song/name."; 3886 } 3887 } 3888 } 3890 container player { 3891 description 3892 "Represents the jukebox player resource."; 3894 leaf gap { 3895 type decimal64 { 3896 fraction-digits 1; 3897 range "0.0 .. 2.0"; 3898 } 3899 units "tenths of seconds"; 3900 description "Time gap between each song"; 3901 } 3902 } 3903 } 3905 rpc play { 3906 description "Control function for the jukebox player"; 3907 input { 3908 leaf playlist { 3909 type string; 3910 mandatory true; 3911 description "playlist name"; 3912 } 3913 leaf song-number { 3914 type uint32; 3915 mandatory true; 3916 description "Song number in playlist to play"; 3917 } 3918 } 3919 } 3920 } 3922 Appendix D. RESTCONF Message Examples 3924 The examples within this document use the normative YANG module 3925 defined in Section 8 and the non-normative example YANG module 3926 defined in Appendix C.1. 3928 This section shows some typical RESTCONF message exchanges. 3930 D.1. Resource Retrieval Examples 3932 D.1.1. Retrieve the Top-level API Resource 3934 The client may start by retrieving the top-level API resource, using 3935 the entry point URI "{+restconf}". 3937 GET /restconf HTTP/1.1 3938 Host: example.com 3939 Accept: application/yang.api+json 3941 The server might respond as follows: 3943 HTTP/1.1 200 OK 3944 Date: Mon, 23 Apr 2012 17:01:00 GMT 3945 Server: example-server 3946 Content-Type: application/yang.api+json 3948 { 3949 "ietf-restconf:restconf": { 3950 "data" : [ null ], 3951 "operations" : { 3952 "play" : [ null ] 3953 } 3954 } 3955 } 3957 To request that the response content to be encoded in XML, the 3958 "Accept" header can be used, as in this example request: 3960 GET /restconf HTTP/1.1 3961 Host: example.com 3962 Accept: application/yang.api+xml 3964 The server will return the same response either way, which might be 3965 as follows : 3967 HTTP/1.1 200 OK 3968 Date: Mon, 23 Apr 2012 17:01:00 GMT 3969 Server: example-server 3970 Cache-Control: no-cache 3971 Pragma: no-cache 3972 Content-Type: application/yang.api+xml 3973 3974 3975 3976 3977 3978 3980 D.1.2. Retrieve The Server Module Information 3982 In this example the client is retrieving the modules information from 3983 the server in JSON format: 3985 GET /restconf/data/ietf-yang-library:modules HTTP/1.1 3986 Host: example.com 3987 Accept: application/yang.data+json 3989 The server might respond as follows. 3991 HTTP/1.1 200 OK 3992 Date: Mon, 23 Apr 2012 17:01:00 GMT 3993 Server: example-server 3994 Cache-Control: no-cache 3995 Pragma: no-cache 3996 Last-Modified: Sun, 22 Apr 2012 01:00:14 GMT 3997 Content-Type: application/yang.data+json 3999 { 4000 "ietf-yang-library:modules": { 4001 "module": [ 4002 { 4003 "name" : "foo", 4004 "revision" : "2012-01-02", 4005 "schema" : "https://example.com/mymodules/foo/2012-01-02", 4006 "namespace" : "http://example.com/ns/foo", 4007 "feature" : [ "feature1", "feature2" ], 4008 "conformance" : true 4009 }, 4010 { 4011 "name" : "foo-types", 4012 "revision" : "2012-01-05", 4013 "schema" : 4014 "https://example.com/mymodules/foo-types/2012-01-05", 4015 "schema" : [null], 4016 "namespace" : "http://example.com/ns/foo-types", 4017 "conformance" : false 4018 }, 4019 { 4020 "name" : "bar", 4021 "revision" : "2012-11-05", 4022 "schema" : "https://example.com/mymodules/bar/2012-11-05", 4023 "namespace" : "http://example.com/ns/bar", 4024 "feature" : [ "bar-ext" ], 4025 "conformance" : true, 4026 "submodule" : [ 4027 { 4028 "name" : "bar-submod1", 4029 "revision" : "2012-11-05", 4030 "schema" : 4031 "https://example.com/mymodules/bar-submod1/2012-11-05" 4032 }, 4033 { 4034 "name" : "bar-submod2", 4035 "revision" : "2012-11-05", 4036 "schema" : 4037 "https://example.com/mymodules/bar-submod2/2012-11-05" 4038 } 4039 ] 4040 } 4041 ] 4042 } 4043 } 4045 D.1.3. Retrieve The Server Capability Information 4047 In this example the client is retrieving the capability information 4048 from the server in JSON format, and the server supports all the 4049 RESTCONF query parameters, plus one vendor parameter: 4051 GET /restconf/data/ietf-restconf-monitoring:restconf-state/ 4052 capabilities HTTP/1.1 4053 Host: example.com 4054 Accept: application/yang.data+xml 4056 The server might respond as follows. The extra whitespace in 4057 'capability' elements for display purposes only. 4059 HTTP/1.1 200 OK 4060 Date: Mon, 23 Apr 2012 17:02:00 GMT 4061 Server: example-server 4062 Cache-Control: no-cache 4063 Pragma: no-cache 4064 Last-Modified: Sun, 22 Apr 2012 01:00:14 GMT 4065 Content-Type: application/yang.data+xml 4066 4067 4068 urn:ietf:params:restconf:capability:content:1.0 4069 4070 4071 urn:ietf:params:restconf:capability:depth:1.0 4072 4073 4074 urn:ietf:params:restconf:capability:fields:1.0 4075 4076 4077 urn:ietf:params:restconf:capability:filter:1.0 4078 4079 4080 urn:ietf:params:restconf:capability:point:1.0 4081 4082 4083 urn:ietf:params:restconf:capability:start-time:1.0 4084 4085 4086 urn:ietf:params:restconf:capability:stop-time:1.0 4087 4088 4089 http://example.com/capabilities/myparam 4090 4091 4093 D.2. Edit Resource Examples 4095 D.2.1. Create New Data Resources 4097 To create a new "artist" resource within the "library" resource, the 4098 client might send the following request. 4100 POST /restconf/data/example-jukebox:jukebox/library HTTP/1.1 4101 Host: example.com 4102 Content-Type: application/yang.data+json 4104 { 4105 "example-jukebox:artist" : { 4106 "name" : "Foo Fighters" 4107 } 4108 } 4110 If the resource is created, the server might respond as follows. 4111 Note that the "Location" header line is wrapped for display purposes 4112 only: 4114 HTTP/1.1 201 Created 4115 Date: Mon, 23 Apr 2012 17:02:00 GMT 4116 Server: example-server 4117 Location: https://example.com/restconf/data/ 4118 example-jukebox:jukebox/library/artist=Foo%20Fighters 4119 Last-Modified: Mon, 23 Apr 2012 17:02:00 GMT 4120 ETag: b3830f23a4c 4122 To create a new "album" resource for this artist within the "jukebox" 4123 resource, the client might send the following request. Note that the 4124 request URI header line is wrapped for display purposes only: 4126 POST /restconf/data/example-jukebox:jukebox/ 4127 library/artist=Foo%20Fighters HTTP/1.1 4128 Host: example.com 4129 Content-Type: application/yang.data+json 4131 { 4132 "example-jukebox:album" : { 4133 "name" : "Wasting Light", 4134 "genre" : "example-jukebox:alternative", 4135 "year" : 2012 # note this is the wrong date 4136 } 4137 } 4139 If the resource is created, the server might respond as follows. 4140 Note that the "Location" header line is wrapped for display purposes 4141 only: 4143 HTTP/1.1 201 Created 4144 Date: Mon, 23 Apr 2012 17:03:00 GMT 4145 Server: example-server 4146 Location: https://example.com/restconf/data/ 4147 example-jukebox:jukebox/library/artist=Foo%20Fighters/ 4148 album=Wasting%20Light 4149 Last-Modified: Mon, 23 Apr 2012 17:03:00 GMT 4150 ETag: b8389233a4c 4152 D.2.2. Detect Resource Entity Tag Change 4154 In this example, the server just supports the mandatory datastore 4155 last-changed timestamp. The client has previously retrieved the 4156 "Last-Modified" header and has some value cached to provide in the 4157 following request to patch an "album" list entry with key value 4158 "Wasting Light". Only the "year" field is being updated. 4160 PATCH /restconf/data/example-jukebox:jukebox/ 4161 library/artist=Foo%20Fighters/album=Wasting%20Light/year 4162 HTTP/1.1 4163 Host: example.com 4164 If-Unmodified-Since: Mon, 23 Apr 2012 17:01:00 GMT 4165 Content-Type: application/yang.data+json 4167 { "example-jukebox:year" : "2011" } 4169 In this example the datastore resource has changed since the time 4170 specified in the "If-Unmodified-Since" header. The server might 4171 respond: 4173 HTTP/1.1 412 Precondition Failed 4174 Date: Mon, 23 Apr 2012 19:01:00 GMT 4175 Server: example-server 4176 Last-Modified: Mon, 23 Apr 2012 17:45:00 GMT 4177 ETag: b34aed893a4c 4179 D.2.3. Edit a Datastore Resource 4181 In this example, the client modifies two different data nodes by 4182 sending a PATCH to the datastore resource: 4184 PATCH /restconf/data HTTP/1.1 4185 Host: example.com 4186 Content-Type: application/yang.datastore+xml 4188 4189 4190 4191 4192 Foo Fighters 4193 4194 Wasting Light 4195 2011 4196 4197 4198 4199 Nick Cave 4200 4201 Tender Prey 4202 1988 4203 4204 4205 4206 4207 4209 D.3. Query Parameter Examples 4211 D.3.1. "content" Parameter 4213 The "content" parameter is used to select the type of data child 4214 resources (configuration and/or not configuration) that are returned 4215 by the server for a GET method request. 4217 In this example, a simple YANG list that has configuration and non- 4218 configuration child resources. 4220 container events 4221 list event { 4222 key name; 4223 leaf name { type string; } 4224 leaf description { type string; } 4225 leaf event-count { 4226 type uint32; 4227 config false; 4228 } 4229 } 4230 } 4232 Example 1: content=all 4234 To retrieve all the child resources, the "content" parameter is set 4235 to "all". The client might send: 4237 GET /restconf/data/example-events:events?content=all 4238 HTTP/1.1 4239 Host: example.com 4240 Accept: application/yang.data+json 4242 The server might respond: 4244 HTTP/1.1 200 OK 4245 Date: Mon, 23 Apr 2012 17:11:30 GMT 4246 Server: example-server 4247 Cache-Control: no-cache 4248 Pragma: no-cache 4249 Content-Type: application/yang.data+json 4251 { 4252 "example-events:events" : { 4253 "event" : [ 4254 { 4255 "name" : "interface-up", 4256 "description" : "Interface up notification count", 4257 "event-count" : 42 4258 }, 4259 { 4260 "name" : "interface-down", 4261 "description" : "Interface down notification count", 4262 "event-count" : 4 4263 } 4264 ] 4265 } 4266 } 4268 Example 2: content=config 4270 To retrieve only the configuration child resources, the "content" 4271 parameter is set to "config" or omitted since this is the default 4272 value. Note that the "ETag" and "Last-Modified" headers are only 4273 returned if the content parameter value is "config". 4275 GET /restconf/data/example-events:events?content=config 4276 HTTP/1.1 4277 Host: example.com 4278 Accept: application/yang.data+json 4280 The server might respond: 4282 HTTP/1.1 200 OK 4283 Date: Mon, 23 Apr 2012 17:11:30 GMT 4284 Server: example-server 4285 Last-Modified: Mon, 23 Apr 2012 13:01:20 GMT 4286 ETag: eeeada438af 4287 Cache-Control: no-cache 4288 Pragma: no-cache 4289 Content-Type: application/yang.data+json 4291 { 4292 "example-events:events" : { 4293 "event" : [ 4294 { 4295 "name" : "interface-up", 4296 "description" : "Interface up notification count" 4297 }, 4298 { 4299 "name" : "interface-down", 4300 "description" : "Interface down notification count" 4301 } 4302 ] 4303 } 4304 } 4306 Example 3: content=nonconfig 4308 To retrieve only the non-configuration child resources, the "content" 4309 parameter is set to "nonconfig". Note that configuration ancestors 4310 (if any) and list key leafs (if any) are also returned. The client 4311 might send: 4313 GET /restconf/data/example-events:events?content=nonconfig 4314 HTTP/1.1 4315 Host: example.com 4316 Accept: application/yang.data+json 4318 The server might respond: 4320 HTTP/1.1 200 OK 4321 Date: Mon, 23 Apr 2012 17:11:30 GMT 4322 Server: example-server 4323 Cache-Control: no-cache 4324 Pragma: no-cache 4325 Content-Type: application/yang.data+json 4327 { 4328 "example-events:events" : { 4329 "event" : [ 4330 { 4331 "name" : "interface-up", 4332 "event-count" : 42 4333 }, 4334 { 4335 "name" : "interface-down", 4336 "event-count" : 4 4337 } 4338 ] 4339 } 4340 } 4342 D.3.2. "depth" Parameter 4344 The "depth" parameter is used to limit the number of levels of child 4345 resources that are returned by the server for a GET method request. 4347 The depth parameter starts counting levels at the level of the target 4348 resource that is specified, so that a depth level of "1" includes 4349 just the target resource level itself. A depth level of "2" includes 4350 the target resource level and its child nodes. 4352 This example shows how different values of the "depth" parameter 4353 would affect the reply content for retrieval of the top-level 4354 "jukebox" data resource. 4356 Example 1: depth=unbounded 4358 To retrieve all the child resources, the "depth" parameter is not 4359 present or set to the default value "unbounded". Note that some 4360 strings are wrapped for display purposes only. 4362 GET /restconf/data/example-jukebox:jukebox?depth=unbounded 4363 HTTP/1.1 4364 Host: example.com 4365 Accept: application/yang.data+json 4367 The server might respond: 4369 HTTP/1.1 200 OK 4370 Date: Mon, 23 Apr 2012 17:11:30 GMT 4371 Server: example-server 4372 Cache-Control: no-cache 4373 Pragma: no-cache 4374 Content-Type: application/yang.data+json 4376 { 4377 "example-jukebox:jukebox" : { 4378 "library" : { 4379 "artist" : [ 4380 { 4381 "name" : "Foo Fighters", 4382 "album" : [ 4383 { 4384 "name" : "Wasting Light", 4385 "genre" : "example-jukebox:alternative", 4386 "year" : 2011, 4387 "song" : [ 4388 { 4389 "name" : "Wasting Light", 4390 "location" : 4391 "/media/foo/a7/wasting-light.mp3", 4392 "format" : "MP3", 4393 "length" " 286 4394 }, 4395 { 4396 "name" : "Rope", 4397 "location" : "/media/foo/a7/rope.mp3", 4398 "format" : "MP3", 4399 "length" " 259 4400 } 4401 ] 4402 } 4403 ] 4404 } 4405 ] 4406 }, 4407 "playlist" : [ 4408 { 4409 "name" : "Foo-One", 4410 "description" : "example playlist 1", 4411 "song" : [ 4412 { 4413 "index" : 1, 4414 "id" : "https://example.com/restconf/data/ 4415 example-jukebox:jukebox/library/artist= 4416 Foo%20Fighters/album=Wasting%20Light/ 4417 song=Rope" 4418 }, 4419 { 4420 "index" : 2, 4421 "id" : "https://example.com/restconf/data/ 4422 example-jukebox:jukebox/library/artist= 4423 Foo%20Fighters/album=Wasting%20Light/song= 4424 Bridge%20Burning" 4425 } 4426 ] 4427 } 4428 ], 4429 "player" : { 4430 "gap" : 0.5 4431 } 4432 } 4433 } 4435 Example 2: depth=1 4437 To determine if 1 or more resource instances exist for a given target 4438 resource, the value "1" is used. 4440 GET /restconf/data/example-jukebox:jukebox?depth=1 HTTP/1.1 4441 Host: example.com 4442 Accept: application/yang.data+json 4444 The server might respond: 4446 HTTP/1.1 200 OK 4447 Date: Mon, 23 Apr 2012 17:11:30 GMT 4448 Server: example-server 4449 Cache-Control: no-cache 4450 Pragma: no-cache 4451 Content-Type: application/yang.data+json 4453 { 4454 "example-jukebox:jukebox" : [null] 4455 } 4457 Example 3: depth=3 4459 To limit the depth level to the target resource plus 2 child resource 4460 layers the value "3" is used. 4462 GET /restconf/data/example-jukebox:jukebox?depth=3 HTTP/1.1 4463 Host: example.com 4464 Accept: application/yang.data+json 4466 The server might respond: 4468 HTTP/1.1 200 OK 4469 Date: Mon, 23 Apr 2012 17:11:30 GMT 4470 Server: example-server 4471 Cache-Control: no-cache 4472 Pragma: no-cache 4473 Content-Type: application/yang.data+json 4475 { 4476 "example-jukebox:jukebox" : { 4477 "library" : { 4478 "artist" : [ null ] 4479 }, 4480 "playlist" : [ 4481 { 4482 "name" : "Foo-One", 4483 "description" : "example playlist 1", 4484 "song" : [ null ] 4485 } 4486 ], 4487 "player" : { 4488 "gap" : 0.5 4489 } 4490 } 4491 } 4493 D.3.3. "fields" Parameter 4495 In this example the client is retrieving the API resource, but 4496 retrieving only the "name" and "revision" nodes from each module, in 4497 JSON format: 4499 GET /restconf/data?fields=modules/module(name;revision) HTTP/1.1 4500 Host: example.com 4501 Accept: application/yang.data+json 4503 The server might respond as follows. 4505 HTTP/1.1 200 OK 4506 Date: Mon, 23 Apr 2012 17:01:00 GMT 4507 Server: example-server 4508 Content-Type: application/yang.data+json 4510 { 4511 "ietf-yang-library:modules": { 4512 "module": [ 4513 { 4514 "name" : "example-jukebox", 4515 "revision" : "2015-06-04" 4516 }, 4517 { 4518 "name" : "ietf-inet-types", 4519 "revision" : "2013-07-15" 4520 }, 4521 { 4522 "name" : "ietf-restconf-monitoring", 4523 "revision" : "2015-06-19" 4524 }, 4525 { 4526 "name" : "ietf-yang-library", 4527 "revision" : "2015-01-30" 4528 }, 4529 { 4530 "name" : "ietf-yang-types", 4531 "revision" : "2013-07-15" 4532 } 4534 ] 4535 } 4536 } 4538 D.3.4. "insert" Parameter 4540 In this example, a new first entry in the "Foo-One" playlist is being 4541 created. 4543 Request from client: 4545 POST /restconf/data/example-jukebox:jukebox/ 4546 playlist=Foo-One?insert=first HTTP/1.1 4547 Host: example.com 4548 Content-Type: application/yang.data+json 4550 { 4551 "example-jukebox:song" : { 4552 "index" : 1, 4553 "id" : "/example-jukebox:jukebox/library/ 4554 artist=Foo%20Fighters/album=Wasting%20Light/song=Rope" 4555 } 4556 } 4558 Response from server: 4560 HTTP/1.1 201 Created 4561 Date: Mon, 23 Apr 2012 13:01:20 GMT 4562 Server: example-server 4563 Last-Modified: Mon, 23 Apr 2012 13:01:20 GMT 4564 Location: https://example.com/restconf/data/ 4565 example-jukebox:jukebox/playlist=Foo-One/song=1 4566 ETag: eeeada438af 4568 D.3.5. "point" Parameter 4570 In this example, the client is inserting a new "song" resource within 4571 an "album" resource after another song. The request URI is split for 4572 display purposes only. 4574 Request from client: 4576 POST /restconf/data/example-jukebox:jukebox/ 4577 library/artist=Foo%20Fighters/album=Wasting%20Light? 4578 insert=after&point=%2Fexample-jukebox%3Ajukebox%2F 4579 library%2Fartist%2FFoo%20Fighters%2Falbum%2F 4580 Wasting%20Light%2Fsong%2FBridge%20Burning HTTP/1.1 4581 Host: example.com 4582 Content-Type: application/yang.data+json 4584 { 4585 "example-jukebox:song" : { 4586 "name" : "Rope", 4587 "location" : "/media/foo/a7/rope.mp3", 4588 "format" : "MP3", 4589 "length" : 259 4590 } 4591 } 4593 Response from server: 4595 HTTP/1.1 204 No Content 4597 1. Date: Mon, 23 Apr 2012 13:01:20 GMT Server: example-server Last- 4598 Modified: Mon, 23 Apr 2012 13:01:20 GMT ETag: abcada438af 4600 D.3.6. "filter" Parameter 4602 The following URIs show some examples of notification filter 4603 specifications (lines wrapped for display purposes only): 4605 // filter = /event/event-class='fault' 4606 GET /mystreams/NETCONF?filter=%2Fevent%2Fevent-class%3D'fault' 4608 // filter = /event/severity<=4 4609 GET /mystreams/NETCONF?filter=%2Fevent%2Fseverity%3C%3D4 4611 // filter = /linkUp|/linkDown 4612 GET /mystreams/SNMP?filter=%2FlinkUp%7C%2FlinkDown 4614 // filter = /*/reporting-entity/card!='Ethernet0' 4615 GET /mystreams/NETCONF? 4616 filter=%2F*%2Freporting-entity%2Fcard%21%3D'Ethernet0' 4618 // filter = /*/email-addr[contains(.,'company.com')] 4619 GET /mystreams/critical-syslog? 4620 filter=%2F*%2Femail-addr[contains(.%2C'company.com')] 4622 // Note: the module name is used as prefix. 4623 // filter = (/example-mod:event1/name='joe' and 4624 // /example-mod:event1/status='online') 4625 GET /mystreams/NETCONF? 4626 filter=(%2Fexample-mod%3Aevent1%2Fname%3D'joe'%20and 4627 %20%2Fexample-mod%3Aevent1%2Fstatus%3D'online') 4629 D.3.7. "start-time" Parameter 4631 // start-time = 2014-10-25T10:02:00Z 4632 GET /mystreams/NETCONF?start-time=2014-10-25T10%3A02%3A00Z 4634 D.3.8. "stop-time" Parameter 4636 // stop-time = 2014-10-25T12:31:00Z 4637 GET /mystreams/NETCONF?stop-time=2014-10-25T12%3A31%3A00Z 4639 D.3.9. "with-defaults" Parameter 4641 Assume the same data model as defined in Appendix A.1 of [RFC6243]. 4642 Assume the same data set as defined in Appendix A.2 of [RFC6243]. If 4643 the server defaults-uri basic-mode is "trim", the the following 4644 request for interface "eth1" might be as follows: 4646 Without query parameter: 4648 GET /restconf/data/interfaces/interface=eth1 HTTP/1.1 4649 Host: example.com 4650 Accept: application/yang.data+json 4652 The server might respond as follows. 4654 HTTP/1.1 200 OK 4655 Date: Mon, 23 Apr 2012 17:01:00 GMT 4656 Server: example-server 4657 Content-Type: application/yang.data+json 4659 { 4660 "example:interface": [ 4661 { 4662 "name" : "eth1", 4663 "status" : "up" 4664 } 4665 ] 4666 } 4668 Note that the "mtu" leaf is missing because it is set to the default 4669 "1500", and the server defaults handling basic-mode is "trim". 4671 With query parameter: 4673 GET /restconf/data/interfaces/interface=eth1 4674 ?with-defaults=report-all HTTP/1.1 4675 Host: example.com 4676 Accept: application/yang.data+json 4678 The server might respond as follows. 4680 HTTP/1.1 200 OK 4681 Date: Mon, 23 Apr 2012 17:01:00 GMT 4682 Server: example-server 4683 Content-Type: application/yang.data+json 4685 { 4686 "example:interface": [ 4687 { 4688 "name" : "eth1", 4689 "mtu" : 1500, 4690 "status" : "up" 4691 } 4692 ] 4693 } 4695 Note that the server returns the "mtu" leaf because the "report-all" 4696 mode was requested with the "with-defaults" query parameter. 4698 Authors' Addresses 4700 Andy Bierman 4701 YumaWorks 4703 Email: andy@yumaworks.com 4705 Martin Bjorklund 4706 Tail-f Systems 4708 Email: mbj@tail-f.com 4710 Kent Watsen 4711 Juniper Networks 4713 Email: kwatsen@juniper.net