idnits 2.17.1 draft-ietf-netconf-restconf-05.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 1919 has weird spacing: '... method entry...' == Line 2792 has weird spacing: '...ncoding strin...' == Line 2793 has weird spacing: '...ocation inet:...' == Line 3651 has weird spacing: '...ocation str...' == Line 3661 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 4, 2015) is 3248 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-02 ** 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-03 Summary: 12 errors (**), 0 flaws (~~), 11 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 6, 2015 Tail-f Systems 6 K. Watsen 7 Juniper Networks 8 June 4, 2015 10 RESTCONF Protocol 11 draft-ietf-netconf-restconf-05 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 6, 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. 04 - 05 . . . . . . . . . . . . . . . . . . . . . . . . . 75 147 A.2. 03 - 04 . . . . . . . . . . . . . . . . . . . . . . . . . 76 148 A.3. 02 - 03 . . . . . . . . . . . . . . . . . . . . . . . . . 77 149 A.4. 01 - 02 . . . . . . . . . . . . . . . . . . . . . . . . . 77 150 A.5. 00 - 01 . . . . . . . . . . . . . . . . . . . . . . . . . 78 151 A.6. bierman:restconf-04 to ietf:restconf-00 . . . . . . . . . 79 152 Appendix B. Open Issues . . . . . . . . . . . . . . . . . . . . 79 153 Appendix C. Example YANG Module . . . . . . . . . . . . . . . . 79 154 C.1. example-jukebox YANG Module . . . . . . . . . . . . . . . 80 155 Appendix D. RESTCONF Message Examples . . . . . . . . . . . . . 85 156 D.1. Resource Retrieval Examples . . . . . . . . . . . . . . . 86 157 D.1.1. Retrieve the Top-level API Resource . . . . . . . . . 86 158 D.1.2. Retrieve The Server Module Information . . . . . . . 87 159 D.1.3. Retrieve The Server Capability Information . . . . . 88 160 D.2. Edit Resource Examples . . . . . . . . . . . . . . . . . 89 161 D.2.1. Create New Data Resources . . . . . . . . . . . . . . 89 162 D.2.2. Detect Resource Entity Tag Change . . . . . . . . . . 90 163 D.2.3. Edit a Datastore Resource . . . . . . . . . . . . . . 91 164 D.3. Query Parameter Examples . . . . . . . . . . . . . . . . 92 165 D.3.1. "content" Parameter . . . . . . . . . . . . . . . . . 92 166 D.3.2. "depth" Parameter . . . . . . . . . . . . . . . . . . 95 167 D.3.3. "fields" Parameter . . . . . . . . . . . . . . . . . 98 168 D.3.4. "insert" Parameter . . . . . . . . . . . . . . . . . 99 169 D.3.5. "point" Parameter . . . . . . . . . . . . . . . . . . 100 170 D.3.6. "filter" Parameter . . . . . . . . . . . . . . . . . 101 171 D.3.7. "start-time" Parameter . . . . . . . . . . . . . . . 101 172 D.3.8. "stop-time" Parameter . . . . . . . . . . . . . . . . 101 173 D.3.9. "with-defaults" Parameter . . . . . . . . . . . . . . 102 174 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 103 176 1. Introduction 178 There is a need for standard mechanisms to allow Web applications to 179 access the configuration data, operational data, data-model specific 180 protocol operations, and event notifications within a networking 181 device, in a modular and extensible manner. 183 This document describes an HTTP [RFC7230] based protocol called 184 RESTCONF, for accessing data defined in YANG [RFC6020], using 185 datastores defined in NETCONF [RFC6241]. 187 The NETCONF protocol defines configuration datastores and a set of 188 Create, Retrieve, Update, Delete (CRUD) operations that can be used 189 to access these datastores. The YANG language defines the syntax and 190 semantics of datastore content, operational data, protocol 191 operations, and event notifications. RESTCONF uses HTTP operations 192 to provide CRUD operations on a NETCONF datastore containing YANG- 193 defined data. Since NETCONF protocol operations are not relevant, 194 the user should not need any prior knowledge of NETCONF in order to 195 use RESTCONF. 197 Configuration data and state data are exposed as resources that can 198 be retrieved with the GET method. Resources representing 199 configuration data can be modified with the DELETE, PATCH, POST, and 200 PUT methods. Data is encoded with either XML [W3C.REC-xml-20081126] 201 or JSON [RFC7158]. 203 Data-model specific protocol operations defined with the YANG "rpc" 204 statement can be invoked with the POST method. Data-model specific 205 event notifications defined with the YANG "notification" statement 206 can be accessed. 208 1.1. Simple Subset of NETCONF Functionality 210 An HTTP-based management protocol does not need to mirror the 211 functionality of the NETCONF protocol, but it needs to be compatible 212 with NETCONF. A simplified transaction model is needed that allows 213 basic CRUD operations on a hierarchy of conceptual resources. This 214 represents a limited subset of the transaction capabilities of the 215 NETCONF protocol. 217 The HTTP POST, PUT, PATCH, and DELETE methods are used to edit data 218 resources represented by YANG data models. These basic edit 219 operations allow the running configuration to be altered in an all- 220 or-none fashion. This is similar to the "rollback-on-error" 221 capability in NETCONF. Edits are usually applied to one data 222 resource instance at a time. 224 The base RESTCONF protocol is intentionally simple to allow 225 deployment for as many use cases as possible. Additional 226 functionality can be defined in external documents, outside the scope 227 of this document. 229 RESTCONF is not intended to replace NETCONF, but rather provide an 230 additional simplified interface that follows REST principles and is 231 compatible with a resource-oriented device abstraction. 233 The following figure shows the system components: 235 +-----------+ +-----------------+ 236 | Web app | <-------> | | 237 +-----------+ HTTP | network device | 238 | | 239 +-----------+ | +-----------+ | 240 | NMS app | <-------> | | datastore | | 241 +-----------+ NETCONF | +-----------+ | 242 +-----------------+ 244 1.2. Data Model Driven API 246 RESTCONF combines the simplicity of the HTTP protocol with the 247 predictability and automation potential of a schema-driven API. 248 Using YANG, a client can predict all resource endpoints, much like 249 using URI Templates [RFC6570], but in a more holistic manner. This 250 strategy obviates the need for responses provided by the server to 251 contain HATEOAS links, originally described in Roy Fielding's 252 doctoral dissertation [rest-dissertation]. 254 In contrast, a REST client using HATEOAS principles would not use any 255 data modeling language to define the application-specific content of 256 the API. The client would need to discover each new child resource 257 as it traverses the URIs to discover the server capabilities. This 258 approach has the following significant weaknesses with regards to 259 control of complex networking devices: 261 o inefficient performance: configuration APIs will be quite complex 262 and may require thousands of protocol messages to discover all the 263 schema information. Typically the data type information has to be 264 passed in the protocol messages, which is also wasteful overhead. 266 o no data model richness: without a data model, the schema-level 267 semantics and validation constraints are not available to the 268 application. 270 o no tool automation: API automation tools need some sort of content 271 schema to function. Such tools can automate various programming 272 and documentation tasks related to specific data models. 274 Data models such as YANG modules serve as an "API contract" that will 275 be honored by the server. An application designer can code to the 276 data model, knowing in advance important details about the exact 277 protocol operations and datastore content a conforming server 278 implementation will support. 280 RESTCONF provides the YANG module capability information supported by 281 the server, in case the client wants to use it. The URIs for custom 282 protocol operations and datastore content are predictable, based on 283 the YANG module definitions. 285 Operational experience with CLI and SNMP indicates that operators 286 learn the 'location' of specific service or device related data and 287 do not expect such information to be arbitrary and discovered each 288 time the client opens a management session to a server. 290 The RESTCONF protocol operates on a conceptual datastore defined with 291 the YANG data modeling language. The server lists each YANG module 292 it supports using the "ietf-yang-library" YANG module, defined in 293 [I-D.ietf-netconf-yang-library]. The server MUST implement the 294 "ietf-yang-library" module, which SHOULD identify all the YANG 295 modules used by the server. 297 The conceptual datastore contents, data-model-specific operations and 298 event notifications are identified by this set of YANG modules. All 299 RESTCONF content identified as either a data resource, operation 300 resource, or event stream resource is defined with the YANG language. 302 The classification of data as configuration or non-configuration is 303 derived from the YANG "config" statement. Data ordering behavior is 304 derived from the YANG "ordered-by" statement. 306 The RESTCONF datastore editing model is simple and direct, similar to 307 the behavior of the :writable-running capability in NETCONF. Each 308 RESTCONF edit of a datastore resource is activated upon successful 309 completion of the transaction. 311 1.3. Coexistence with NETCONF 313 RESTCONF can be implemented on a device that supports NETCONF. 315 If the device supports :writable-running, all edits to configuration 316 nodes in {+restconf}/data are performed in the running configuration 317 datastore. 319 Otherwise, if the device supports :candidate, all edits to 320 configuration nodes in {+restconf}/data are performed in the 321 candidate configuration datastore. The candidate is automatically 322 committed to running after a successful edit. 324 If the device supports :startup, the device automatically copies the 325 content of running to startup after running has been updated as a 326 consequence of a RESTCONF edit operation. 328 If a datastore that would be modified by a RESTCONF operation has an 329 active lock, the RESTCONF edit operation MUST fail with a 409 330 (Conflict) error code. 332 1.4. Terminology 334 The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 335 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 336 "OPTIONAL" in this document are to be interpreted as described in BCP 337 14, [RFC2119]. 339 1.4.1. NETCONF 341 The following terms are defined in [RFC6241]: 343 o candidate configuration datastore 345 o client 347 o configuration data 349 o datastore 351 o configuration datastore 353 o protocol operation 355 o running configuration datastore 357 o server 359 o startup configuration datastore 361 o state data 363 o user 365 1.4.2. HTTP 367 The following terms are defined in [RFC3986]: 369 o fragment 371 o path 373 o query 375 The following terms are defined in [RFC7230]: 377 o header 379 o message-body 381 o request-line 383 o request URI 385 o status-line 387 The following terms are defined in [RFC7231]: 389 o method 391 o request 393 o resource 395 The following terms are defined in [RFC7232]: 397 o entity tag 399 1.4.3. YANG 401 The following terms are defined in [RFC6020]: 403 o container 405 o data node 407 o key leaf 409 o leaf 411 o leaf-list 413 o list 415 o presence container (or P-container) 417 o RPC operation (now called protocol operation) 419 o non-presence container (or NP-container) 421 o ordered-by system 423 o ordered-by user 425 1.4.4. Terms 427 The following terms are used within this document: 429 o API resource: a resource with the media type "application/ 430 yang.api+xml" or "application/yang.api+json". 432 o data resource: a resource with the media type "application/ 433 yang.data+xml" or "application/yang.data+json". Containers, 434 leafs, list entries and anyxml nodes can be data resources. 436 o datastore resource: a resource with the media type "application/ 437 yang.datastore+xml" or "application/yang.datastore+json". 438 Represents a datastore. 440 o edit operation: a RESTCONF operation on a data resource using 441 either a POST, PUT, PATCH, or DELETE method. 443 o event stream resource: This resource represents an SSE (Server- 444 Sent Events) event stream. The content consists of text using the 445 media type "text/event-stream", as defined by the HTML5 446 specification. Each event represents one message 447 generated by the server. It contains a conceptual system or data- 448 model specific event that is delivered within an event 449 notification stream. Also called a "stream resource". 451 o media-type: HTTP uses Internet media types [RFC2046] in the 452 Content-Type and Accept header fields in order to provide open and 453 extensible data typing and type negotiation. 455 o operation: the conceptual RESTCONF operation for a message, 456 derived from the HTTP method, request URI, headers, and message- 457 body. 459 o operation resource: a resource with the media type "application/ 460 yang.operation+xml" or "application/yang.operation+json". 462 o patch: a generic PATCH request on the target datastore or data 463 resource. The media type of the message-body content will 464 identify the patch type in use. 466 o plain patch: a specific PATCH request type that can be used for 467 simple merge operations. 469 o query parameter: a parameter (and its value if any), encoded 470 within the query component of the request URI. 472 o RESTCONF capability: An optional RESTCONF protocol feature 473 supported by the server, which is identified by an IANA registered 474 NETCONF Capability URI, and advertised with an entry in the 475 "capability" leaf-list in Section 9.3. 477 o retrieval request: a request using the GET or HEAD methods. 479 o target resource: the resource that is associated with a particular 480 message, identified by the "path" component of the request URI. 482 o schema resource: a resource with the media type "application/ 483 yang". The YANG representation of the schema can be retrieved by 484 the client with the GET method. 486 o stream list: the set of data resource instances that describe the 487 event stream resources available from the server. This 488 information is defined in the "ietf-restconf-monitoring" module as 489 the "stream" list. It can be retrieved using the target resource 490 "{+restconf}/data/ietf-restconf-monitoring:restconf-state/streams/ 491 stream". The stream list contains information about each stream, 492 such as the URL to retrieve the event stream data. 494 1.4.5. URI Template 496 Throughout this document, the URI template [RFC6570] syntax 497 "{+restconf}" is used to refer to the RESTCONF API entry point 498 outside of an example. See Section 3.1 for details. 500 For simplicity, all of the examples in this document assume 501 "/restconf" as the discovered RESTCONF API root path. 503 1.4.6. Tree Diagrams 505 A simplified graphical representation of the data model is used in 506 this document. The meaning of the symbols in these diagrams is as 507 follows: 509 o Brackets "[" and "]" enclose list keys. 511 o Abbreviations before data node names: "rw" means configuration 512 data (read-write) and "ro" state data (read-only). 514 o Symbols after data node names: "?" means an optional node, "!" 515 means a presence container, and "*" denotes a list and leaf-list. 517 o Parentheses enclose choice and case nodes, and case nodes are also 518 marked with a colon (":"). 520 o Ellipsis ("...") stands for contents of subtrees that are not 521 shown. 523 2. Transport Protocol Requirements 525 2.1. Integrity and Confidentiality 527 HTTP [RFC7230] is an application layer protocol that may be layered 528 on any reliable transport-layer protocol. RESTCONF is defined on top 529 of HTTP, but due to the sensitive nature of the information conveyed, 530 RESTCONF requires that the transport-layer protocol provides both 531 data integrity and confidentiality, such as are provided by the TLS 532 protocol [RFC5246]. 534 2.2. HTTPS with X.509v3 Certificates 536 Given the nearly ubiquitous support for HTTP over TLS [RFC7230], 537 RESTCONF implementations MUST support the "https" URI scheme, which 538 has the IANA assigned default port 443. Consistent with the 539 exclusive use of X.509v3 certificates for NETCONF over TLS 540 [draft-ietf-netconf-rfc5539bis-10], use of certificates in RESTCONF 541 is also limited to X.509v3 certificates. 543 2.3. Certificate Validation 545 When presented an X.509 certificate, the RESTCONF peer MUST use X.509 546 certificate path validation [RFC5280] to verify the integrity of the 547 certificate. The presented X.509 certificate MAY also be considered 548 valid if it matches a locally configured certificate fingerprint. If 549 X.509 certificate path validation fails and the presented X.509 550 certificate does not match a locally configured certificate 551 fingerprint, the connection MUST be terminated as defined in 552 [RFC5246]. 554 2.4. Authenticated Server Identity 556 The RESTCONF client MUST carefully examine the certificate presented 557 by the RESTCONF server to determine if it meets the client's 558 expectations. The RESTCONF client MUST check the identity of the 559 server according to Section 6 of [RFC6125], including processing the 560 outcome as described in Section 6.6 of [RFC6125]. 562 2.5. Authenticated Client Identity 564 The RESTCONF server MUST authenticate client access to any protected 565 resource using HTTP Authentication [RFC7235]. If the RESTCONF client 566 is not authenticated to access a resource, the server MUST send a 567 response with status code 401 (Unauthorized) and a WWW-Authenticate 568 header field containing at least one challenge applicable to the 569 target resource. The RESTCONF server MAY advertise support for any 570 number of authentication schemes but, in order to ensure 571 interoperability, the RESTCONF server MUST advertise at least one of 572 the following authentication schemes: 574 o Basic [draft-ietf-httpauth-basicauth-update-03] 576 o Digest [draft-ietf-httpauth-digest-09] 578 o ClientCertificate [draft-thomson-httpbis-cant-01] 580 These authentication schemes are selected for to their similarity to 581 the authentication schemes supported by NETCONF. In particular, the 582 Basic and Digest authentication schemes both directly provide an 583 identity and verification of a shared secret, much like NETCONF over 584 SSH, when using the SSH "password" authentication method [RFC4252]. 585 Similarly, the ClientCertificate authentication scheme is much like 586 NETCONF over TLS's use of X.509 client-certificates. When using the 587 ClientCertificate authentication scheme, the RESTCONF server MUST 588 derive the identity of the RESTCONF client using the algorithm 589 defined in Section 7 of [draft-ietf-netconf-rfc5539bis-10]. 591 The RESTCONF client identity determined from any HTTP authentication 592 scheme is hereafter known as the "RESTCONF username" and subject to 593 the NETCONF Access Control Module (NACM) [RFC6536]. 595 3. Resources 597 The RESTCONF protocol operates on a hierarchy of resources, starting 598 with the top-level API resource itself (Section 3.1). Each resource 599 represents a manageable component within the device. 601 A resource can be considered a collection of conceptual data and the 602 set of allowed methods on that data. It can contain nested child 603 resources. The child resource types and methods allowed on them are 604 data-model specific. 606 A resource has its own media type identifier, represented by the 607 "Content-Type" header in the HTTP response message. A resource can 608 contain zero or more nested resources. A resource can be created and 609 deleted independently of its parent resource, as long as the parent 610 resource exists. 612 All RESTCONF resources are defined in this document except specific 613 datastore contents, protocol operations, and event notifications. 614 The syntax and semantics for these resource types are defined in YANG 615 modules. 617 The RESTCONF resources are accessed via a set of URIs defined in this 618 document. The set of YANG modules supported by the server will 619 determine the data model specific operations, top-level data node 620 resources, and event notification messages supported by the server. 622 The RESTCONF protocol does not include a resource discovery 623 mechanism. Instead, the definitions within the YANG modules 624 advertised by the server are used to construct a predictable 625 operation or data resource identifier. 627 3.1. Root Resource Discovery 629 In line with the best practices defined by [RFC7320], RESTCONF 630 enables deployments to specify where the RESTCONF API is located. 631 When first connecting to a RESTCONF server, a RESTCONF client MUST 632 determine the root of the RESTCONF API. The client discovers this by 633 getting the "/.well-known/host-meta" resource ([RFC6415]) and using 634 the element containing the "restconf" attribute : 636 Request 637 ------- 638 GET /.well-known/host-meta users HTTP/1.1 639 Host: example.com 640 Accept: application/xrd+xml 642 Response 643 -------- 644 HTTP/1.1 200 OK 645 Content-Type: application/xrd+xml 646 Content-Length: nnn 648 649 650 652 Once discovering the RESTCONF API root, the client MUST prepend it to 653 any subsequent request to a RESTCONF resource. For instance, using 654 the "/restconf" path discovered above, the client can now determine 655 the operations supported by the the server. In this example a custom 656 "play" operation is supported: 658 Request 659 ------- 660 GET /restconf/operations HTTP/1.1 661 Host: example.com 662 Accept: application/yang.api+json 664 Response 665 -------- 666 HTTP/1.1 200 OK 667 Date: Mon, 23 Apr 2012 17:01:00 GMT 668 Server: example-server 669 Cache-Control: no-cache 670 Pragma: no-cache 671 Last-Modified: Sun, 22 Apr 2012 01:00:14 GMT 672 Content-Type: application/yang.api+json 674 { "operations" : { "play" : [ null ] } } 676 3.2. RESTCONF Resource Types 678 The RESTCONF protocol defines a set of application specific media 679 types to identify each of the available resource types. The 680 following resource types are defined in RESTCONF: 682 +-----------+---------------------------------+ 683 | Resource | Media Type | 684 +-----------+---------------------------------+ 685 | API | application/yang.api+xml | 686 | | application/yang.api+json | 687 | Datastore | application/yang.datastore+xml | 688 | | application/yang.datastore+json | 689 | Data | application/yang.data+xml | 690 | | application/yang.data+json | 691 | Errors | application/yang.errors+xml | 692 | | application/yang.errors+json | 693 | Operation | application/yang.operation+xml | 694 | | application/yang.operation+json | 695 | Schema | application/yang | 696 +-----------+---------------------------------+ 698 RESTCONF Media Types 700 3.3. API Resource 702 The API resource contains the entry points for the RESTCONF datastore 703 and operation resources. It is the top-level resource located at 704 {+restconf} and has the media type "application/yang.api+xml" or 705 "application/yang.api+json". 707 YANG Tree Diagram for an API Resource: 709 +--rw restconf 710 +--rw data 711 +--rw operations 713 The "application/yang.api" restconf-media-type extension in the 714 "ietf-restconf" module defined in Section 8 is used to specify the 715 structure and syntax of the conceptual child resources within the API 716 resource. 718 The API resource can be retrieved with the GET method. 720 This resource has the following child resources: 722 +----------------+--------------------------------+ 723 | Child Resource | Description | 724 +----------------+--------------------------------+ 725 | data | Contains all data resources | 726 | operations | Data-model specific operations | 727 +----------------+--------------------------------+ 729 RESTCONF API Resource 731 3.3.1. {+restconf}/data 733 This mandatory resource represents the combined configuration and 734 operational data resources that can be accessed by a client. It 735 cannot be created or deleted by the client. The datastore resource 736 type is defined in Section 3.4. 738 Example: 740 This example request by the client would retrieve only the non- 741 configuration data nodes that exist within the "library" resource, 742 using the "content" query parameter (see Section 4.8.1). 744 GET /restconf/data/example-jukebox:jukebox/library 745 ?content=nonconfig HTTP/1.1 746 Host: example.com 747 Accept: application/yang.data+xml 749 The server might respond: 751 HTTP/1.1 200 OK 752 Date: Mon, 23 Apr 2012 17:01:30 GMT 753 Server: example-server 754 Cache-Control: no-cache 755 Pragma: no-cache 756 Content-Type: application/yang.data+xml 758 759 42 760 59 761 374 762 764 3.3.2. {+restconf}/operations 766 This optional resource is a container that provides access to the 767 data-model specific protocol operations supported by the server. The 768 server MAY omit this resource if no data-model specific operations 769 are advertised. 771 Any data-model specific operations defined in the YANG modules 772 advertised by the server MAY be available as child nodes of this 773 resource. 775 Operation resources are defined in Section 3.6. 777 3.4. Datastore Resource 779 The "{+restconf}/data" subtree represents the datastore resource 780 type, which is a collection of configuration and operational data 781 nodes. 783 This resource type is an abstraction of the system's underlying 784 datastore implementation. It is used to simplify resource editing 785 for the client. The RESTCONF datastore resource is a conceptual 786 collection of all configuration and operational data that is present 787 on the device. 789 Configuration edit transaction management and configuration 790 persistence are handled by the server and not controlled by the 791 client. A datastore resource can only be written directly with the 792 PATCH method. Each RESTCONF edit of a datastore resource is saved to 793 non-volatile storage in an implementation-specific matter by the 794 server. 796 3.4.1. Edit Collision Detection 798 Two "edit collision detection" mechanisms are provided in RESTCONF, 799 for datastore and data resources. 801 3.4.1.1. Timestamp 803 The last change time is maintained and the "Last-Modified" 804 ([RFC7232], Section 2.2) header is returned in the response for a 805 retrieval request. The "If-Unmodified-Since" header can be used in 806 edit operation requests to cause the server to reject the request if 807 the resource has been modified since the specified timestamp. 809 The server MUST maintain a last-modified timestamp for the top-level 810 {+restconf}/data resource and SHOULD maintain last-modified 811 timestamps for descendant resources. For all resources, the server 812 MUST return the "Last-Modified" header when the resource is retrieved 813 with the GET or HEAD methods. If the server does not maintain a 814 timestamp for a resource, it MUST return the timestamp of the 815 resource's ancestor, a process that may recurse up to the top-level 816 {+restconf}/data resource. Only changes to configuration data 817 resources within the datastore affect the timestamp. 819 3.4.1.2. Entity tag 821 A unique opaque string is maintained and the "ETag" ([RFC7232], 822 Section 2.3) header is returned in the response for a retrieval 823 request. The "If-Match" header can be used in edit operation 824 requests to cause the server to reject the request if the resource 825 entity tag does not match the specified value. 827 The server MUST maintain an entity tag for the top-level 828 {+restconf}/data resource and SHOULD maintain entity tags for 829 descendant resources. For all resources, the server MUST return the 830 "ETag" header when the resource is retrieved with the GET or HEAD 831 methods. If the server does not maintain an entity tag for a 832 resource, it MUST return the entity tag of the resource's ancestor, a 833 process that may recurse up to the top-level {+restconf}/data 834 resource. Only changes to configuration data resources within the 835 datastore affect the entity tag. 837 3.5. Data Resource 839 A data resource represents a YANG data node that is a descendant node 840 of a datastore resource. Each YANG-defined data node can be uniquely 841 targeted by the request-line of an HTTP operation. Containers, 842 leafs, list entries and anyxml nodes are data resources. 844 The representation maintained for each data resource is the YANG 845 defined subtree for that node. HTTP operations on a data resource 846 affect both the targeted data node and all its descendants, if any. 848 For configuration data resources, the server MAY maintain a last- 849 modified timestamp for the resource, and return the "Last-Modified" 850 header when it is retrieved with the GET or HEAD methods. If 851 maintained, the resource timestamp MUST be set to the current time 852 whenever the resource or any configuration resource within the 853 resource is altered. 855 For configuration data resources, the server MAY maintain a resource 856 entity tag for the resource, and return the "ETag" header when it is 857 retrieved as the target resource with the GET or HEAD methods. If 858 maintained, the resource entity tag MUST be updated whenever the 859 resource or any configuration resource within the resource is 860 altered. 862 A data resource can be retrieved with the GET method. Data resources 863 are accessed via the "{+restconf}/data" entry point. This sub-tree 864 is used to retrieve and edit data resources. 866 A configuration data resource can be altered by the client with some 867 or all of the edit operations, depending on the target resource and 868 the specific operation. Refer to Section 4 for more details on edit 869 operations. 871 The resource definition version for a data resource is identified by 872 the revision date of the YANG module containing the YANG definition 873 for the data resource. 875 3.5.1. Encoding Data Resource Identifiers in the Request URI 877 In YANG, data nodes are named with an absolute XPath expression, 878 defined in [XPath], starting from the document root to the target 879 resource. In RESTCONF, URL encoded path expressions are used 880 instead. 882 A predictable location for a data resource is important, since 883 applications will code to the YANG data model module, which uses 884 static naming and defines an absolute path location for all data 885 nodes. 887 A RESTCONF data resource identifier is not an XPath expression. It 888 is encoded from left to right, starting with the top-level data node, 889 according to the "api-path" rule in Section 3.5.1.1. The node name 890 of each ancestor of the target resource node is encoded in order, 891 ending with the node name for the target resource. 893 If a data node in the path expression is a YANG list node, then the 894 key values for the list (if any) MUST be encoded according to the 895 following rules: 897 o The key leaf values for a data resource representing a YANG list 898 MUST be encoded using one path segment [RFC3986]. 900 o If there is only one key leaf value, the path segment is 901 constructed by having the list name followed by an "=" followed by 902 the single key leaf value. 904 o If there are multiple key leaf values, the value of each leaf 905 identified in the "key" statement is encoded in the order 906 specified in the YANG "key" statement, with a comma separating 907 them. 909 o The key value is specified as a string, using the canonical 910 representation for the YANG data type. Any reserved characters 911 MUST be encoded with escape sequences, according to [RFC2396], 912 Section 2.4. 914 o All the components in the "key" statement MUST be encoded. 915 Partial instance identifiers are not supported. 917 o Quoted strings are supported in the key leaf values. Quoted 918 strings MUST be used to express empty strings. (example: 919 list=foo,'',baz). 921 o The "list-instance" ABNF rule defined in Section 3.5.1.1 922 represents the syntax of a list instance identifier. 924 o Resource URI values returned in Location headers for data 925 resources MUST identify the module name, even if there are no 926 conflicting local names when the resource is created. This 927 ensures the correct resource will be identified even if the server 928 loads a new module that the old client does not know about. 930 Examples: 932 container top { 933 list list1 { 934 key "key1 key2 key3"; 935 ... 936 list list2 { 937 key "key4 key5"; 938 ... 939 leaf X { type string; } 940 } 941 } 942 } 944 For the above YANG definition, URI with key leaf values will be 945 encoded as follows (line wrapped for display purposes only): 947 /restconf/data/example-top:top/list1=key1val,key2val,key3val3/ 948 list2=key4val,key5val/X 950 3.5.1.1. ABNF For Data Resource Identifiers 952 The "api-path" ABNF syntax is used to construct RESTCONF path 953 identifiers: 955 api-path = "/" | 956 ("/" api-identifier 957 0*("/" (api-identifier | list-instance ))) 959 api-identifier = [module-name ":"] identifier ;; note 1 961 module-name = identifier 963 list-instance = api-identifier "=" key-value ["," key-value]* 965 key-value = string ;; note 1 967 string = 969 ;; An identifier MUST NOT start with 970 ;; (('X'|'x') ('M'|'m') ('L'|'l')) 971 identifier = (ALPHA / "_") 972 *(ALPHA / DIGIT / "_" / "-" / ".") 974 Note 1: The syntax for "api-identifier" and "key-value" MUST conform 975 to the JSON identifier encoding rules in Section 4 of 976 [I-D.ietf-netmod-yang-json]. 978 3.5.2. Defaults Handling 980 RESTCONF requires that a server report its default handling mode (see 981 Section 9.1.2 for details). If the optional "with-defaults" query 982 parameter is supported by the server, a client may use it to control 983 retrieval of default values (see Section 4.8.9 for details). 985 If the target of a GET method is a data node that represents a leaf 986 that has a default value, and the leaf has not been given a value 987 yet, the server MUST return the default value that is in use by the 988 server. 990 If the target of a GET method is a data node that represents a 991 container or list that has any child resources with default values, 992 for the child resources that have not been given value yet, the 993 server MAY return the default values that are in use by the server, 994 in accordance with its reported default handing mode and query 995 parameters passed by the client. 997 3.6. Operation Resource 999 An operation resource represents a protocol operation defined with 1000 the YANG "rpc" statement. It is invoked using a POST method on the 1001 operation resource. 1003 POST {+restconf}/operations/ 1005 The field identifies the module name and rpc identifier 1006 string for the desired operation. 1008 For example, if "module-A" defined a "reset" operation, then invoking 1009 the operation from "module-A" would be requested as follows: 1011 POST /restconf/operations/module-A:reset HTTP/1.1 1012 Server example.com 1014 If the "rpc" statement has an "input" section, then a message-body 1015 MAY be sent by the client in the request, otherwise the request 1016 message MUST NOT include a message-body. 1018 If the operation is successfully invoked, and if the "rpc" statement 1019 has an "output" section, then a message-body MAY be sent by the 1020 server in the response, otherwise the response message MUST NOT 1021 include a message-body in the response message, and MUST send a "204 1022 No Content" status-line instead. 1024 If the operation is not successfully invoked, then a message-body 1025 SHOULD be sent by the server, containing an "errors" resource, as 1026 defined in Section 3.9. 1028 3.6.1. Encoding Operation Input Parameters 1030 If the "rpc" statement has an "input" section, then the "input" node 1031 is provided in the message-body, corresponding to the YANG data 1032 definition statements within the "input" section. 1034 Example: 1036 The following YANG definition is used for the examples in this 1037 section. 1039 module example-ops { 1040 namespace "https://example.com/ns/example-ops"; 1041 prefix "ops"; 1043 rpc reboot { 1044 input { 1045 leaf delay { 1046 units seconds; 1047 type uint32; 1048 default 0; 1049 } 1050 leaf message { type string; } 1051 leaf language { type string; } 1052 } 1053 } 1055 rpc get-reboot-info { 1056 output { 1057 leaf reboot-time { 1058 units seconds; 1059 type uint32; 1060 } 1061 leaf message { type string; } 1062 leaf language { type string; } 1063 } 1064 } 1065 } 1067 The client might send the following POST request message: 1069 POST /restconf/operations/example-ops:reboot HTTP/1.1 1070 Host: example.com 1071 Content-Type: application/yang.operation+xml 1072 1073 600 1074 Going down for system maintenance 1075 en-US 1076 1078 The server might respond: 1080 HTTP/1.1 204 No Content 1081 Date: Mon, 25 Apr 2012 11:01:00 GMT 1082 Server: example-server 1084 3.6.2. Encoding Operation Output Parameters 1086 If the "rpc" statement has an "output" section, then the "output" 1087 node is provided in the message-body, corresponding to the YANG data 1088 definition statements within the "output" section. 1090 Example: 1092 The "example-ops" YANG module defined in Section 3.6.1 is used for 1093 the examples in this section. 1095 The client might send the following POST request message: 1097 POST /restconf/operations/example-ops:get-reboot-info HTTP/1.1 1098 Host: example.com 1099 Accept: application/yang.operation+json 1101 The server might respond: 1103 HTTP/1.1 200 OK 1104 Date: Mon, 25 Apr 2012 11:10:30 GMT 1105 Server: example-server 1106 Content-Type: application/yang.operation+json 1108 { 1109 "example-ops:output" : { 1110 "reboot-time" : 30, 1111 "message" : "Going down for system maintenance", 1112 "language" : "en-US" 1113 } 1114 } 1116 3.6.3. Encoding Operation Errors 1118 If any errors occur while attempting to invoke the operation, then an 1119 "errors" data structure is returned with the appropriate error 1120 status. 1122 Using the "reset" operation example above, the client might send the 1123 following POST request message: 1125 POST /restconf/operations/example-ops:reboot HTTP/1.1 1126 Host: example.com 1127 Content-Type: application/yang.operation+xml 1129 1130 -33 1131 Going down for system maintenance 1132 en-US 1133 1135 The server might respond with an "invalid-value" error: 1137 HTTP/1.1 400 Bad Request 1138 Date: Mon, 25 Apr 2012 11:10:30 GMT 1139 Server: example-server 1140 Content-Type: application/yang.errors+xml 1142 1143 1144 protocol 1145 invalid-value 1146 1147 err:input/err:delay 1148 1149 Invalid input parameter 1150 1151 1153 3.7. Schema Resource 1155 The server can optionally support retrieval of the YANG modules it 1156 supports, using the "ietf-yang-library" module, defined in 1157 [I-D.ietf-netconf-yang-library]. 1159 To retrieve a YANG module, a client first needs to get the URL for 1160 retrieving the schema. 1162 The client might send the following GET request message: 1164 GET /restconf/data/ietf-yang-library:modules/module= 1165 example-jukebox,2014-07-03/schema HTTP/1.1 1166 Host: example.com 1167 Accept: application/yang.data+json 1169 The server might respond: 1171 HTTP/1.1 200 OK 1172 Date: Mon, 25 Apr 2012 11:10:30 GMT 1173 Server: example-server 1174 Content-Type: application/yang.data+json 1176 { 1177 "ietf-yang-library:schema": 1178 "https://example.com/mymodules/example-jukebox/2015-06-04" 1179 } 1181 Next the client needs to retrieve the actual YANG schema. 1183 The client might send the following GET request message: 1185 GET https://example.com/mymodules/example-jukebox/2015-06-04 1186 HTTP/1.1 1187 Host: example.com 1188 Accept: application/yang 1190 The server might respond: 1192 module example-jukebox { 1194 // contents of YANG module deleted for this example... 1196 } 1198 3.8. Event Stream Resource 1200 An "event stream" resource represents a source for system generated 1201 event notifications. Each stream is created and modified by the 1202 server only. A client can retrieve a stream resource or initiate a 1203 long-poll server sent event stream, using the procedure specified in 1204 Section 6.3. 1206 A notification stream functions according to the NETCONF 1207 Notifications specification [RFC5277]. The available streams can be 1208 retrieved from the stream list, which specifies the syntax and 1209 semantics of a stream resource. 1211 3.9. Errors Media Type 1213 An "errors" media type is a collection of error information that is 1214 sent as the message-body in a server response message, if an error 1215 occurs while processing a request message. It is not considered a 1216 resource type because no instances can be retrieved with a GET 1217 request. 1219 The "ietf-restconf" YANG module contains the "application/ 1220 yang.errors" restconf-media-type extension which specifies the syntax 1221 and semantics of an "errors" media type. RESTCONF error handling 1222 behavior is defined in Section 7. 1224 4. Operations 1226 The RESTCONF protocol uses HTTP methods to identify the CRUD 1227 operation requested for a particular resource. 1229 The following table shows how the RESTCONF operations relate to 1230 NETCONF protocol operations: 1232 +----------+--------------------------------------------+ 1233 | RESTCONF | NETCONF | 1234 +----------+--------------------------------------------+ 1235 | OPTIONS | none | 1236 | HEAD | none | 1237 | GET | , | 1238 | POST | (operation="create") | 1239 | PUT | (operation="create/replace") | 1240 | PATCH | (operation="merge") | 1241 | DELETE | (operation="delete") | 1242 +----------+--------------------------------------------+ 1244 Table 1: CRUD Methods in RESTCONF 1246 The NETCONF "remove" operation attribute is not supported by the HTTP 1247 DELETE method. The resource must exist or the DELETE method will 1248 fail. The PATCH method is equivalent to a "merge" operation when 1249 using a plain patch (see Section 4.6.1), other media-types may 1250 provide more granular control. 1252 Access control mechanisms may be used to limit what operations can be 1253 used. In particular, RESTCONF is compatible with the NETCONF Access 1254 Control Model (NACM) [RFC6536], as there is a specific mapping 1255 between RESTCONF and NETCONF operations, defined in Table 1. The 1256 resource path needs to be converted internally by the server to the 1257 corresponding YANG instance-identifier. Using this information, the 1258 server can apply the NACM access control rules to RESTCONF messages. 1260 The server MUST NOT allow any operation to any resources that the 1261 client is not authorized to access. 1263 Implementation of all methods (except PATCH) are defined in 1264 [RFC7231]. This section defines the RESTCONF protocol usage for each 1265 HTTP method. 1267 4.1. OPTIONS 1269 The OPTIONS method is sent by the client to discover which methods 1270 are supported by the server for a specific resource (e.g., GET, POST, 1271 DELETE, etc.). 1273 The server SHOULD implement this method, however the same information 1274 could be extracted from the YANG modules and the RESTCONF protocol 1275 specification. 1277 If the PATCH method is supported, then the "Accept-Patch" header MUST 1278 be supported and returned in the response to the OPTIONS request, as 1279 defined in [RFC5789]. 1281 4.2. HEAD 1283 The HEAD method is sent by the client to retrieve just the headers 1284 that would be returned for the comparable GET method, without the 1285 response message-body. It is supported for all resource types, 1286 except operation resources. 1288 The request MUST contain a request URI that contains at least the 1289 entry point. The same query parameters supported by the GET method 1290 are supported by the HEAD method. 1292 The access control behavior is enforced as if the method was GET 1293 instead of HEAD. The server MUST respond the same as if the method 1294 was GET instead of HEAD, except that no response message-body is 1295 included. 1297 4.3. GET 1299 The GET method is sent by the client to retrieve data and meta-data 1300 for a resource. It is supported for all resource types, except 1301 operation resources. The request MUST contain a request URI that 1302 contains at least the entry point. 1304 The server MUST NOT return any data resources for which the user does 1305 not have read privileges. If the user is not authorized to read the 1306 target resource, an error response containing a "403 Forbidden" or 1307 "404 Not Found" status-line is returned to the client. 1309 If the user is authorized to read some but not all of the target 1310 resource, the unauthorized content is omitted from the response 1311 message-body, and the authorized content is returned to the client. 1313 Example: 1315 The client might request the response headers for a JSON 1316 representation of the "library" resource: 1318 GET /restconf/data/example-jukebox:jukebox/ 1319 library/artist=Foo%20Fighters/album HTTP/1.1 1320 Host: example.com 1321 Accept: application/yang.data+xml 1323 The server might respond: 1325 HTTP/1.1 200 OK 1326 Date: Mon, 23 Apr 2012 17:02:40 GMT 1327 Server: example-server 1328 Content-Type: application/yang.data+xml 1329 Cache-Control: no-cache 1330 Pragma: no-cache 1331 ETag: a74eefc993a2b 1332 Last-Modified: Mon, 23 Apr 2012 11:02:14 GMT 1334 1335 Wasting Light 1336 1337 g:alternative 1338 1339 2011 1340 1342 4.4. POST 1344 The POST method is sent by the client to create a data resource or 1345 invoke an operation resource. The server uses the target resource 1346 media type to determine how to process the request. 1348 +-----------+------------------------------------------------+ 1349 | Type | Description | 1350 +-----------+------------------------------------------------+ 1351 | Datastore | Create a top-level configuration data resource | 1352 | Data | Create a configuration data child resource | 1353 | Operation | Invoke a protocol operation | 1354 +-----------+------------------------------------------------+ 1356 Resource Types that Support POST 1358 4.4.1. Create Resource Mode 1360 If the target resource type is a datastore or data resource, then the 1361 POST is treated as a request to create a top-level resource or child 1362 resource, respectively. The message-body is expected to contain the 1363 content of a child resource to create within the parent (target 1364 resource). The data-model for the child tree is the subtree is 1365 defined by YANG for the child resource. 1367 The "insert" and "point" query parameters are supported by the POST 1368 method for datastore and data resource types, as specified in the 1369 YANG definition in Section 8. 1371 If the POST method succeeds, a "201 Created" status-line is returned 1372 and there is no response message-body. A "Location" header 1373 identifying the child resource that was created MUST be present in 1374 the response in this case. 1376 If the user is not authorized to create the target resource, an error 1377 response containing a "403 Forbidden" or "404 Not Found" status-line 1378 is returned to the client. All other error responses are handled 1379 according to the procedures defined in Section 7. 1381 Example: 1383 To create a new "jukebox" resource, the client might send: 1385 POST /restconf/data HTTP/1.1 1386 Host: example.com 1387 Content-Type: application/yang.data+json 1389 { "example-jukebox:jukebox" : [null] } 1391 If the resource is created, the server might respond as follows. 1392 Note that the "Location" header line is wrapped for display purposes 1393 only: 1395 HTTP/1.1 201 Created 1396 Date: Mon, 23 Apr 2012 17:01:00 GMT 1397 Server: example-server 1398 Location: https://example.com/restconf/data/ 1399 example-jukebox:jukebox 1400 Last-Modified: Mon, 23 Apr 2012 17:01:00 GMT 1401 ETag: b3a3e673be2 1403 Refer to Appendix D.2.1 for more resource creation examples. 1405 4.4.2. Invoke Operation Mode 1407 If the target resource type is an operation resource, then the POST 1408 method is treated as a request to invoke that operation. The 1409 message-body (if any) is processed as the operation input parameters. 1410 Refer to Section 3.6 for details on operation resources. 1412 If the POST request succeeds, a "200 OK" status-line is returned if 1413 there is a response message-body, and a "204 No Content" status-line 1414 is returned if there is no response message-body. 1416 If the user is not authorized to invoke the target operation, an 1417 error response containing a "403 Forbidden" or "404 Not Found" 1418 status-line is returned to the client. All other error responses are 1419 handled according to the procedures defined in Section 7. 1421 Example: 1423 In this example, the client is invoking the "play" operation defined 1424 in the "example-jukebox" YANG module. 1426 A client might send a "play" request as follows: 1428 POST /restconf/operations/example-jukebox:play HTTP/1.1 1429 Host: example.com 1430 Content-Type: application/yang.operation+json 1432 { 1433 "example-jukebox:input" : { 1434 "playlist" : "Foo-One", 1435 "song-number" : 2 1436 } 1437 } 1439 The server might respond: 1441 HTTP/1.1 204 No Content 1442 Date: Mon, 23 Apr 2012 17:50:00 GMT 1443 Server: example-server 1445 4.5. PUT 1447 The PUT method is sent by the client to create or replace the target 1448 resource. 1450 The only target resource media type that supports PUT is the data 1451 resource. The message-body is expected to contain the content used 1452 to create or replace the target resource. 1454 The "insert" (Section 4.8.4) and "point" (Section 4.8.5) query 1455 parameters are supported by the PUT method for data resources. 1457 Consistent with [RFC7231], if the PUT request creates a new resource, 1458 a "201 Created" status-line is returned. If an existing resource is 1459 modified, either "200 OK" or "204 No Content" are returned. 1461 If the user is not authorized to create or replace the target 1462 resource an error response containing a "403 Forbidden" or "404 Not 1463 Found" status-line is returned to the client. All other error 1464 responses are handled according to the procedures defined in 1465 Section 7. 1467 Example: 1469 An "album" child resource defined in the "example-jukebox" YANG 1470 module is replaced or created if it does not already exist. 1472 To replace the "album" resource contents, the client might send as 1473 follows. Note that the request-line is wrapped for display purposes 1474 only: 1476 PUT /restconf/data/example-jukebox:jukebox/ 1477 library/artist=Foo%20Fighters/album=Wasting%20Light HTTP/1.1 1478 Host: example.com 1479 Content-Type: application/yang.data+json 1481 { 1482 "example-jukebox:album" : { 1483 "name" : "Wasting Light", 1484 "genre" : "example-jukebox:alternative", 1485 "year" : 2011 1486 } 1487 } 1489 If the resource is updated, the server might respond: 1491 HTTP/1.1 204 No Content 1492 Date: Mon, 23 Apr 2012 17:04:00 GMT 1493 Server: example-server 1494 Last-Modified: Mon, 23 Apr 2012 17:04:00 GMT 1495 ETag: b27480aeda4c 1497 4.6. PATCH 1499 RESTCONF uses the HTTP PATCH method defined in [RFC5789] to provide 1500 an extensible framework for resource patching mechanisms. It is 1501 optional to implement by the server. Each patch type needs a unique 1502 media type. Zero or more PATCH media types MAY be supported by the 1503 server. The media types supported by a server can be discovered by 1504 the client by sending an OPTIONS request (see Section 4.1). 1506 If the target resource instance does not exist, the server MUST NOT 1507 create it. 1509 If the PATCH request succeeds, a "200 OK" status-line is returned if 1510 there is a message-body, and "204 No Content" is returned if no 1511 response message-body is sent. 1513 If the user is not authorized to alter the target resource an error 1514 response containing a "403 Forbidden" or "404 Not Found" status-line 1515 is returned to the client. All other error responses are handled 1516 according to the procedures defined in Section 7. 1518 4.6.1. Plain Patch 1520 The plain patch mechanism merges the contents of the message body 1521 with the target resource. If the target resource is a datastore 1522 resource (see Section 3.4), the message body MUST be either 1523 application/yang.datastore+xml or application/yang.datastore+json. 1524 If then the target resource is a data resource (see Section 3.5), 1525 then the message body MUST be either application/yang.data+xml or 1526 application/yang.data+json. 1528 Plain patch can used to create or update, but not delete, a child 1529 resource within the target resource. Please see 1530 [I-D.ietf-netconf-yang-patch] for an alternate media-type supporting 1531 more granular control. 1533 Example: 1535 To replace just the "year" field in the "album" resource (instead of 1536 replacing the entire resource with the PUT method), the client might 1537 send a plain patch as follows. Note that the request-line is wrapped 1538 for display purposes only: 1540 PATCH /restconf/data/example-jukebox:jukebox/ 1541 library/artist=Foo%20Fighters/album=Wasting%20Light HTTP/1.1 1542 Host: example.com 1543 If-Match: b8389233a4c 1544 Content-Type: application/yang.data+xml 1546 1547 2011 1548 1550 If the field is updated, the server might respond: 1552 HTTP/1.1 204 No Content 1553 Date: Mon, 23 Apr 2012 17:49:30 GMT 1554 Server: example-server 1555 Last-Modified: Mon, 23 Apr 2012 17:49:30 GMT 1556 ETag: b2788923da4c 1558 4.7. DELETE 1560 The DELETE method is used to delete the target resource. If the 1561 DELETE request succeeds, a "204 No Content" status-line is returned, 1562 and there is no response message-body. 1564 If the user is not authorized to delete the target resource then an 1565 error response containing a "403 Forbidden" or "404 Not Found" 1566 status-line is returned to the client. All other error responses are 1567 handled according to the procedures defined in Section 7. 1569 Example: 1571 To delete a resource such as the "album" resource, the client might 1572 send: 1574 DELETE /restconf/data/example-jukebox:jukebox/ 1575 library/artist=Foo%20Fighters/album=Wasting%20Light HTTP/1.1 1576 Host: example.com 1578 If the resource is deleted, the server might respond: 1580 HTTP/1.1 204 No Content 1581 Date: Mon, 23 Apr 2012 17:49:40 GMT 1582 Server: example-server 1584 4.8. Query Parameters 1586 Each RESTCONF operation allows zero or more query parameters to be 1587 present in the request URI. The specific parameters that are allowed 1588 depends on the resource type, and sometimes the specific target 1589 resource used, in the request. 1591 +---------------+---------+-----------------------------------------+ 1592 | Name | Methods | Description | 1593 +---------------+---------+-----------------------------------------+ 1594 | content | GET | Select config and/or non-config data | 1595 | | | resources | 1596 | depth | GET | Request limited sub-tree depth in the | 1597 | | | reply content | 1598 | fields | GET | Request a subset of the target resource | 1599 | | | contents | 1600 | filter | GET | Boolean notification filter for event | 1601 | | | stream resources | 1602 | insert | POST, | Insertion mode for user-ordered data | 1603 | | PUT | resources | 1604 | point | POST, | Insertion point for user-ordered data | 1605 | | PUT | resources | 1606 | start-time | GET | Replay buffer start time for event | 1607 | | | stream resources | 1608 | stop-time | GET | Replay buffer stop time for event | 1609 | | | stream resources | 1610 | with-defaults | GET | Control retrieval of default values | 1611 +---------------+---------+-----------------------------------------+ 1613 RESTCONF Query Parameters 1615 Query parameters can be given in any order. Each parameter can 1616 appear at most once in a request URI. A default value may apply if 1617 the parameter is missing. 1619 Refer to Appendix D.3 for examples of query parameter usage. 1621 If vendors define additional query parameters, they SHOULD use a 1622 prefix (such as the enterprise or organization name) for query 1623 parameter names in order to avoid collisions with other parameters. 1625 4.8.1. The "content" Query Parameter 1627 The "content" parameter controls how descendant nodes of the 1628 requested data nodes will be processed in the reply. 1630 The allowed values are: 1632 +-----------+-----------------------------------------------------+ 1633 | Value | Description | 1634 +-----------+-----------------------------------------------------+ 1635 | config | Return only configuration descendant data nodes | 1636 | nonconfig | Return only non-configuration descendant data nodes | 1637 | all | Return all descendant data nodes | 1638 +-----------+-----------------------------------------------------+ 1640 This parameter is only allowed for GET methods on datastore and data 1641 resources. A 400 Bad Request error is returned if used for other 1642 methods or resource types. 1644 The default value is determined by the "config" statement value of 1645 the requested data nodes. If the "config" value is "false", then the 1646 default for the "content" parameter is "nonconfig". If "config" is 1647 "true" then the default for the "content" parameter is "config". 1649 This query parameter MUST be supported by the server. 1651 4.8.2. The "depth" Query Parameter 1653 The "depth" parameter is used to specify the number of nest levels 1654 returned in a response for a GET method. The first nest-level 1655 consists of the requested data node itself. Any child nodes which 1656 are contained within a parent node have a depth value that is 1 1657 greater than its parent. 1659 The value of the "depth" parameter is either an integer between 1 and 1660 65535, or the string "unbounded". "unbounded" is the default. 1662 This parameter is only allowed for GET methods on API, datastore, and 1663 data resources. A 400 Bad Request error is returned if it used for 1664 other methods or resource types. 1666 By default, the server will include all sub-resources within a 1667 retrieved resource, which have the same resource type as the 1668 requested resource. Only one level of sub-resources with a different 1669 media type than the target resource will be returned. 1671 If the "depth" query parameter URI is listed in the "capability" 1672 leaf-list in Section 9.3, then the server supports the "depth" query 1673 parameter. 1675 4.8.3. The "fields" Query Parameter 1677 The "fields" query parameter is used to optionally identify data 1678 nodes within the target resource to be retrieved in a GET method. 1679 The client can use this parameter to retrieve a subset of all nodes 1680 in a resource. 1682 A value of the "fields" query parameter matches the following rule: 1684 fields-expr = path '(' fields-expr / '*' ')' / 1685 path ';' fields-expr / 1686 path 1687 path = api-identifier [ '/' path ] 1689 "api-identifier" is defined in Section 3.5.1.1. 1691 ";" is used to select multiple nodes. For example, to retrieve only 1692 the "genre" and "year" of an album, use: "fields=genre;year". 1694 Parentheses are used to specify sub-selectors of a node. For 1695 example, to retrieve only the "label" and "catalogue-number" of an 1696 album, use: "fields=admin(label;catalogue-number)". 1698 "/" is used in a path to retrieve a child node of a node. For 1699 example, to retrieve only the "label" of an album, use: 1700 "fields=admin/label". 1702 This parameter is only allowed for GET methods on api, datastore, and 1703 data resources. A 400 Bad Request error is returned if used for 1704 other methods or resource types. 1706 If the "fields" query parameter URI is listed in the "capability" 1707 leaf-list in Section 9.3, then the server supports the "fields" 1708 parameter. 1710 4.8.4. The "insert" Query Parameter 1712 The "insert" parameter is used to specify how a resource should be 1713 inserted within a user-ordered list. 1715 The allowed values are: 1717 +--------+----------------------------------------------------------+ 1718 | Value | Description | 1719 +--------+----------------------------------------------------------+ 1720 | first | Insert the new data as the new first entry. | 1721 | last | Insert the new data as the new last entry. | 1722 | before | Insert the new data before the insertion point, as | 1723 | | specified by the value of the "point" parameter. | 1724 | after | Insert the new data after the insertion point, as | 1725 | | specified by the value of the "point" parameter. | 1726 +--------+----------------------------------------------------------+ 1728 The default value is "last". 1730 This parameter is only supported for the POST and PUT methods. It is 1731 also only supported if the target resource is a data resource, and 1732 that data represents a YANG list or leaf-list that is ordered by the 1733 user. 1735 If the values "before" or "after" are used, then a "point" query 1736 parameter for the insertion parameter MUST also be present, or a 400 1737 Bad Request error is returned. 1739 The "insert" query parameter MUST be supported by the server. 1741 4.8.5. The "point" Query Parameter 1743 The "point" parameter is used to specify the insertion point for a 1744 data resource that is being created or moved within a user ordered 1745 list or leaf-list. 1747 The value of the "point" parameter is a string that identifies the 1748 path to the insertion point object. The format is the same as a 1749 target resource URI string. 1751 This parameter is only supported for the POST and PUT methods. It is 1752 also only supported if the target resource is a data resource, and 1753 that data represents a YANG list or leaf-list that is ordered by the 1754 user. 1756 If the "insert" query parameter is not present, or has a value other 1757 than "before" or "after", then a 400 Bad Request error is returned. 1759 This parameter contains the instance identifier of the resource to be 1760 used as the insertion point for a POST or PUT method. 1762 The "point" query parameter MUST be supported by the server. 1764 4.8.6. The "filter" Query Parameter 1766 The "filter" parameter is used to indicate which subset of all 1767 possible events are of interest. If not present, all events not 1768 precluded by other parameters will be sent. 1770 This parameter is only allowed for GET methods on a text/event-stream 1771 data resource. A 400 Bad Request error is returned if used for other 1772 methods or resource types. 1774 The format of this parameter is an XPath 1.0 expression, and is 1775 evaluated in the following context: 1777 o The set of namespace declarations is the set of prefix and 1778 namespace pairs for all supported YANG modules, where the prefix 1779 is the YANG module name, and the namespace is as defined by the 1780 "namespace" statement in the YANG module. 1782 o The function library is the core function library defined in XPath 1783 1.0. 1785 o The set of variable bindings is empty. 1787 o The context node is the root node. 1789 The filter is used as defined in [RFC5277], Section 3.6. If the 1790 boolean result of the expression is true when applied to the 1791 conceptual "notification" document root, then the event notification 1792 is delivered to the client. 1794 If the "filter" query parameter URI is listed in the "capability" 1795 leaf-list in Section 9.3, then the server supports the "filter" query 1796 parameter. 1798 4.8.7. The "start-time" Query Parameter 1800 The "start-time" parameter is used to trigger the notification replay 1801 feature and indicate that the replay should start at the time 1802 specified. If the stream does not support replay, per the 1803 "replay-support" attribute returned by stream list entry for the 1804 stream resource, then the server MUST return the HTTP error code 400 1805 Bad Request. 1807 The value of the "start-time" parameter is of type "date-and-time", 1808 defined in the "ietf-yang" YANG module [RFC6991]. 1810 This parameter is only allowed for GET methods on a text/event-stream 1811 data resource. A 400 Bad Request error is returned if used for other 1812 methods or resource types. 1814 If this parameter is not present, then a replay subscription is not 1815 being requested. It is not valid to specify start times that are 1816 later than the current time. If the value specified is earlier than 1817 the log can support, the replay will begin with the earliest 1818 available notification. 1820 If this query parameter is supported by the server, then the "replay" 1821 query parameter URI MUST be listed in the "capability" leaf-list in 1822 Section 9.3. The "stop-time" query parameter MUST also be supported 1823 by the server. 1825 If the "replay-support" leaf is present in the "stream" entry 1826 (defined in Section 9.3) then the server MUST support the 1827 "start-time" and "stop-time" query parameters for that stream. 1829 4.8.8. The "stop-time" Query Parameter 1831 The "stop-time" parameter is used with the replay feature to indicate 1832 the newest notifications of interest. This parameter MUST be used 1833 with and have a value later than the "start-time" parameter. 1835 The value of the "stop-time" parameter is of type "date-and-time", 1836 defined in the "ietf-yang" YANG module [RFC6991]. 1838 This parameter is only allowed for GET methods on a text/event-stream 1839 data resource. A 400 Bad Request error is returned if used for other 1840 methods or resource types. 1842 If this parameter is not present, the notifications will continue 1843 until the subscription is terminated. Values in the future are 1844 valid. 1846 If this query parameter is supported by the server, then the "replay" 1847 query parameter URI MUST be listed in the "capability" leaf-list in 1848 Section 9.3. The "start-time" query parameter MUST also be supported 1849 by the server. 1851 If the "replay-support" leaf is present in the "stream" entry 1852 (defined in Section 9.3) then the server MUST support the 1853 "start-time" and "stop-time" query parameters for that stream. 1855 4.8.9. The "with-defaults" Query Parameter 1857 The "with-defaults" parameter is used to specify how information 1858 about default data nodes should be returned in response to GET 1859 requests on data resources. 1861 If the server supports this capability, then it MUST implement the 1862 behavior in Section 4.5.1 of [RFC6243], except applied to the 1863 RESTCONF GET operation, instead of the NETCONF operations. 1865 +-------------------+-----------------------------------------------+ 1866 | Value | Description | 1867 +-------------------+-----------------------------------------------+ 1868 | report-all | All data nodes are reported | 1869 | trim | Data nodes set to the YANG default are not | 1870 | | reported | 1871 | explicit | Data nodes set by the client are not reported | 1872 | report-all-tagged | All data nodes are reported and defaults are | 1873 | | tagged | 1874 +-------------------+-----------------------------------------------+ 1875 If the "with-defaults" parameter is set to "report-all" then the 1876 server MUST adhere to the defaults reporting behavior defined in 1877 Section 3.1 of [RFC6243]. 1879 If the "with-defaults" parameter is set to "trim" then the server 1880 MUST adhere to the defaults reporting behavior defined in Section 3.2 1881 of [RFC6243]. 1883 If the "with-defaults" parameter is set to "explicit" then the server 1884 MUST adhere to the defaults reporting behavior defined in Section 3.3 1885 of [RFC6243]. 1887 If the "with-defaults" parameter is set to "report-all-tagged" then 1888 the server MUST adhere to the defaults reporting behavior defined in 1889 Section 3.4 of [RFC6243]. 1891 If the "with-defaults" parameter is not present then the server MUST 1892 adhere to the defaults reporting behavior defined in its "basic-mode" 1893 parameter for the "defaults" protocol capability URI, defined in 1894 Section 9.1.2. 1896 If the server includes the "with-defaults" query parameter URI in the 1897 "capability" leaf-list in Section 9.3, then the "with-defaults" query 1898 parameter MUST be supported. 1900 5. Messages 1902 The RESTCONF protocol uses HTTP entities for messages. A single HTTP 1903 message corresponds to a single protocol method. Most messages can 1904 perform a single task on a single resource, such as retrieving a 1905 resource or editing a resource. The exception is the PATCH method, 1906 which allows multiple datastore edits within a single message. 1908 5.1. Request URI Structure 1910 Resources are represented with URIs following the structure for 1911 generic URIs in [RFC3986]. 1913 A RESTCONF operation is derived from the HTTP method and the request 1914 URI, using the following conceptual fields: 1916 //?# 1917 ^ ^ ^ ^ ^ 1918 | | | | | 1919 method entry resource query fragment 1921 M M O O I 1923 M=mandatory, O=optional, I=ignored 1925 replaced by client with real values 1927 o method: the HTTP method identifying the RESTCONF operation 1928 requested by the client, to act upon the target resource specified 1929 in the request URI. RESTCONF operation details are described in 1930 Section 4. 1932 o entry: the root of the RESTCONF API configured on this HTTP 1933 server, discovered by getting the ".well-known/host-meta" 1934 resource, as described in Section 3.1. 1936 o resource: the path expression identifying the resource that is 1937 being accessed by the operation. If this field is not present, 1938 then the target resource is the API itself, represented by the 1939 media type "application/yang.api". 1941 o query: the set of parameters associated with the RESTCONF message. 1942 These have the familiar form of "name=value" pairs. All query 1943 parameters are optional to implement by the server and optional to 1944 use by the client. Each query parameter is identified by a URI. 1945 The server MUST list the query parameter URIs it supports in the 1946 "capabilities" list defined in Section 9.3. 1948 There is a specific set of parameters defined, although the server 1949 MAY choose to support query parameters not defined in this document. 1950 The contents of the any query parameter value MUST be encoded 1951 according to [RFC2396], Section 3.4. Any reserved characters MUST be 1952 encoded with escape sequences, according to [RFC2396], Section 2.4. 1954 o fragment: This field is not used by the RESTCONF protocol. 1956 When new resources are created by the client, a "Location" header is 1957 returned, which identifies the path of the newly created resource. 1958 The client MUST use this exact path identifier to access the resource 1959 once it has been created. 1961 The "target" of an operation is a resource. The "path" field in the 1962 request URI represents the target resource for the operation. 1964 5.2. Message Headers 1966 There are several HTTP header lines utilized in RESTCONF messages. 1967 Messages are not limited to the HTTP headers listed in this section. 1969 HTTP defines which header lines are required for particular 1970 circumstances. Refer to each operation definition section in 1971 Section 4 for examples on how particular headers are used. 1973 There are some request headers that are used within RESTCONF, usually 1974 applied to data resources. The following tables summarize the 1975 headers most relevant in RESTCONF message requests: 1977 +---------------------+---------------------------------------------+ 1978 | Name | Description | 1979 +---------------------+---------------------------------------------+ 1980 | Accept | Response Content-Types that are acceptable | 1981 | Content-Type | The media type of the request body | 1982 | Host | The host address of the server | 1983 | If-Match | Only perform the action if the entity | 1984 | | matches ETag | 1985 | If-Modified-Since | Only perform the action if modified since | 1986 | | time | 1987 | If-Unmodified-Since | Only perform the action if un-modified | 1988 | | since time | 1989 +---------------------+---------------------------------------------+ 1991 RESTCONF Request Headers 1993 The following tables summarize the headers most relevant in RESTCONF 1994 message responses: 1996 +---------------+---------------------------------------------------+ 1997 | Name | Description | 1998 +---------------+---------------------------------------------------+ 1999 | Allow | Valid actions when 405 error returned | 2000 | Cache-Control | The cache control parameters for the response | 2001 | Content-Type | The media type of the response message-body | 2002 | Date | The date and time the message was sent | 2003 | ETag | An identifier for a specific version of a | 2004 | | resource | 2005 | Last-Modified | The last modified date and time of a resource | 2006 | Location | The resource identifier for a newly created | 2007 | | resource | 2008 +---------------+---------------------------------------------------+ 2010 RESTCONF Response Headers 2012 5.3. Message Encoding 2014 RESTCONF messages are encoded in HTTP according to [RFC7230]. The 2015 "utf-8" character set is used for all messages. RESTCONF message 2016 content is sent in the HTTP message-body. 2018 Content is encoded in either JSON or XML format. A server MUST 2019 support XML encoding and MAY support JSON encoding. XML encoding 2020 rules for data nodes are defined in [RFC6020]. The same encoding 2021 rules are used for all XML content. JSON encoding rules are defined 2022 in [I-D.ietf-netmod-yang-json]. This encoding is valid JSON, but 2023 also has special encoding rules to identify module namespaces and 2024 provide consistent type processing of YANG data. 2026 Request input content encoding format is identified with the Content- 2027 Type header. This field MUST be present if a message-body is sent by 2028 the client. 2030 Response output content encoding format is identified with the Accept 2031 header in the request, or if is not specified, the request input 2032 encoding format is used. If there was no request input, then the 2033 default output encoding is XML. File extensions encoded in the 2034 request are not used to identify format encoding. 2036 5.4. RESTCONF Meta-Data 2038 The RESTCONF protocol needs to retrieve the same meta-data that is 2039 used in the NETCONF protocol. Information about default leafs, last- 2040 modified timestamps, etc. are commonly used to annotate 2041 representations of the datastore contents. This meta-data is not 2042 defined in the YANG schema because it applies to the datastore, and 2043 is common across all data nodes. 2045 This information is encoded as attributes in XML. JSON encoding of 2046 meta-data is defined in [I-D.lhotka-netmod-yang-metadata]. 2048 5.5. Return Status 2050 Each message represents some sort of resource access. An HTTP 2051 "status-line" header line is returned for each request. If a 4xx or 2052 5xx range status code is returned in the status-line, then the error 2053 information will be returned in the response, according to the format 2054 defined in Section 7.1. 2056 5.6. Message Caching 2058 Since the datastore contents change at unpredictable times, responses 2059 from a RESTCONF server generally SHOULD NOT be cached. 2061 The server SHOULD include a "Cache-Control" header in every response 2062 that specifies whether the response should be cached. A "Pragma" 2063 header specifying "no-cache" MAY also be sent in case the 2064 "Cache-Control" header is not supported. 2066 Instead of using HTTP caching, the client SHOULD track the "ETag" 2067 and/or "Last-Modified" headers returned by the server for the 2068 datastore resource (or data resource if the server supports it). A 2069 retrieval request for a resource can include the "If-None-Match" and/ 2070 or "If-Modified-Since" headers, which will cause the server to return 2071 a "304 Not Modified" status-line if the resource has not changed. 2072 The client MAY use the HEAD method to retrieve just the message 2073 headers, which SHOULD include the "ETag" and "Last-Modified" headers, 2074 if this meta-data is maintained for the target resource. 2076 6. Notifications 2078 The RESTCONF protocol supports YANG-defined event notifications. The 2079 solution preserves aspects of NETCONF Event Notifications [RFC5277] 2080 while utilizing the Server-Sent Events [W3C.CR-eventsource-20121211] 2081 transport strategy. 2083 6.1. Server Support 2085 A RESTCONF server is not required to support RESTCONF notifications. 2086 Clients may determine if a server supports RESTCONF notifications by 2087 using the HTTP operation OPTIONS, HEAD, or GET on the stream list. 2088 The server does not support RESTCONF notifications if an HTTP error 2089 code is returned (e.g., 404 Not Found). 2091 6.2. Event Streams 2093 A RESTCONF server that supports notifications will populate a stream 2094 resource for each notification delivery service access point. A 2095 RESTCONF client can retrieve the list of supported event streams from 2096 a RESTCONF server using the GET operation on the stream list. 2098 The "restconf-state/streams" container definition in the 2099 "ietf-restconf-monitoring" module (defined in Section 9.3) is used to 2100 specify the structure and syntax of the conceptual child resources 2101 within the "streams" resource. 2103 For example: 2105 The client might send the following request: 2107 GET /restconf/data/ietf-restconf-monitoring:restconf-state/ 2108 streams HTTP/1.1 2109 Host: example.com 2110 Accept: application/yang.data+xml 2112 The server might send the following response: 2114 HTTP/1.1 200 OK 2115 Content-Type: application/yang.api+xml 2116 2118 2119 NETCONF 2120 default NETCONF event stream 2121 2122 true 2123 2124 2007-07-08T00:00:00Z 2125 2126 2127 xml 2128 https://example.com/streams/NETCONF 2129 2130 2131 2132 json 2133 https://example.com/streams/NETCONF-JSON 2134 2135 2136 2137 2138 SNMP 2139 SNMP notifications 2140 false 2141 2142 xml 2143 https://example.com/streams/SNMP 2144 2145 2146 2147 syslog-critical 2148 Critical and higher severity 2149 2150 true 2151 2152 2007-07-01T00:00:00Z 2153 2154 2155 xml 2156 2157 https://example.com/streams/syslog-critical 2158 2159 2160 2161 2163 6.3. Subscribing to Receive Notifications 2165 RESTCONF clients can determine the URL for the subscription resource 2166 (to receive notifications) by sending an HTTP GET request for the 2167 "location" leaf with the stream list entry. The value returned by 2168 the server can be used for the actual notification subscription. 2170 The client will send an HTTP GET request for the URL returned by the 2171 server with the "Accept" type "text/event-stream". 2173 The server will treat the connection as an event stream, using the 2174 Server Sent Events [W3C.CR-eventsource-20121211] transport strategy. 2176 The server MAY support query parameters for a GET method on this 2177 resource. These parameters are specific to each notification stream. 2179 For example: 2181 The client might send the following request: 2183 GET /restconf/data/ietf-restconf-monitoring:restconf-state/ 2184 streams/stream=NETCONF/encoding=xml/location HTTP/1.1 2185 Host: example.com 2186 Accept: application/yang.data+xml 2188 The server might send the following response: 2190 HTTP/1.1 200 OK 2191 Content-Type: application/yang.api+xml 2193 2195 https://example.com/streams/NETCONF 2196 2198 The RESTCONF client can then use this URL value to start monitoring 2199 the event stream: 2201 GET /streams/NETCONF HTTP/1.1 2202 Host: example.com 2203 Accept: text/event-stream 2204 Cache-Control: no-cache 2205 Connection: keep-alive 2207 A RESTCONF client MAY request the server compress the events using 2208 the HTTP header field "Accept-Encoding". For instance: 2210 GET /streams/NETCONF HTTP/1.1 2211 Host: example.com 2212 Accept: text/event-stream 2213 Cache-Control: no-cache 2214 Connection: keep-alive 2215 Accept-Encoding: gzip, deflate 2217 6.3.1. NETCONF Event Stream 2219 The server SHOULD support the "NETCONF" notification stream defined 2220 in [RFC5277]. For this stream, RESTCONF notification subscription 2221 requests MAY specify parameters indicating the events it wishes to 2222 receive. These query parameters are optional to implement, and only 2223 available if the server supports them. 2225 +------------+---------+-------------------------+ 2226 | Name | Section | Description | 2227 +------------+---------+-------------------------+ 2228 | start-time | 4.8.7 | replay event start time | 2229 | stop-time | 4.8.8 | replay event stop time | 2230 | filter | 4.8.6 | boolean content filter | 2231 +------------+---------+-------------------------+ 2233 NETCONF Stream Query Parameters 2235 The semantics and syntax for these query parameters are defined in 2236 the sections listed above. The YANG encoding MUST be converted to 2237 URL-encoded string for use in the request URI. 2239 Refer to Appendix D.3.6 for filter parameter examples. 2241 6.4. Receiving Event Notifications 2243 RESTCONF notifications are encoded according to the definition of the 2244 event stream. The NETCONF stream defined in [RFC5277] is encoded in 2245 XML format. 2247 The structure of the event data is based on the "notification" 2248 element definition in Section 4 of [RFC5277]. It MUST conform to the 2249 schema for the "notification" element in Section 4 of [RFC5277], 2250 except the XML namespace for this element is defined as: 2252 urn:ietf:params:xml:ns:yang:ietf-restconf 2254 For JSON encoding purposes, the module name for the "notification" 2255 element is "ietf-restconf". 2257 Two child nodes within the "notification" container are expected, 2258 representing the event time and the event payload. The "event-time" 2259 node is defined within the "ietf-restconf" module namespace. The 2260 name and namespace of the payload element are determined by the YANG 2261 module containing the notification-stmt. 2263 In the following example, the YANG module "example-mod" is used: 2265 module example-mod { 2266 namespace "http://example.com/event/1.0"; 2268 notification event { 2269 leaf event-class { type string; } 2270 container reporting-entity { 2271 leaf card { type string; } 2272 } 2273 leaf severity { type string; } 2274 } 2275 } 2277 An example SSE event notification encoded using XML: 2279 data: 2281 data: 2013-12-21T00:01:00Z 2282 data: 2283 data: fault 2284 data: 2285 data: Ethernet0 2286 data: 2287 data: major 2288 data: 2289 data: 2291 An example SSE event notification encoded using JSON: 2293 data: { 2294 data: "ietf-restconf:notification": { 2295 data: "event-time": "2013-12-21T00:01:00Z", 2296 data: "example-mod:event": { 2297 data: "event-class": "fault", 2298 data: "reporting-entity": { "card": "Ethernet0" }, 2299 data: "severity": "major" 2300 data: } 2301 data: } 2302 data: } 2304 Alternatively, since neither XML nor JSON are whitespace sensitive, 2305 the above messages can be encoded onto a single line. For example: 2307 For example: ('\' line wrapping added for formatting only) 2309 XML: 2311 data: 2013-12-21T00:01:00ZfaultEthernet0\ 2315 major 2317 JSON: 2319 data: {"ietf-restconf:notification":{"event-time":"2013-12-21\ 2320 T00:01:00Z","example-mod:event":{"event-class": "fault","repor\ 2321 tingEntity":{"card":"Ethernet0"},"severity":"major"}}} 2323 The SSE specifications supports the following additional fields: 2324 event, id and retry. A RESTCONF server MAY send the "retry" field 2325 and, if it does, RESTCONF clients SHOULD use it. A RESTCONF server 2326 SHOULD NOT send the "event" or "id" fields, as there are no 2327 meaningful values that could be used for them that would not be 2328 redundant to the contents of the notification itself. RESTCONF 2329 servers that do not send the "id" field also do not need to support 2330 the HTTP header "Last-Event-Id". RESTCONF servers that do send the 2331 "id" field MUST still support the "startTime" query parameter as the 2332 preferred means for a client to specify where to restart the event 2333 stream. 2335 7. Error Reporting 2337 HTTP status-lines are used to report success or failure for RESTCONF 2338 operations. The element returned in NETCONF error 2339 responses contains some useful information. This error information 2340 is adapted for use in RESTCONF, and error information is returned for 2341 "4xx" class of status codes. 2343 The following table summarizes the return status codes used 2344 specifically by RESTCONF operations: 2346 +---------------------------+---------------------------------------+ 2347 | Status-Line | Description | 2348 +---------------------------+---------------------------------------+ 2349 | 100 Continue | POST accepted, 201 should follow | 2350 | 200 OK | Success with response message-body | 2351 | 201 Created | POST to create a resource success | 2352 | 202 Accepted | POST to create a resource accepted | 2353 | 204 No Content | Success without response message-body | 2354 | 304 Not Modified | Conditional operation not done | 2355 | 400 Bad Request | Invalid request message | 2356 | 403 Forbidden | Access to resource denied | 2357 | 404 Not Found | Resource target or resource node not | 2358 | | found | 2359 | 405 Method Not Allowed | Method not allowed for target | 2360 | | resource | 2361 | 409 Conflict | Resource or lock in use | 2362 | 412 Precondition Failed | Conditional method is false | 2363 | 413 Request Entity Too | too-big error | 2364 | Large | | 2365 | 414 Request-URI Too Large | too-big error | 2366 | 415 Unsupported Media | non RESTCONF media type | 2367 | Type | | 2368 | 500 Internal Server Error | operation-failed | 2369 | 501 Not Implemented | unknown-operation | 2370 | 503 Service Unavailable | Recoverable server error | 2371 +---------------------------+---------------------------------------+ 2373 HTTP Status Codes used in RESTCONF 2375 Since an operation resource is defined with a YANG "rpc" statement, a 2376 mapping between the NETCONF value and the HTTP status 2377 code is needed. The specific error condition and response code to 2378 use are data-model specific and might be contained in the YANG 2379 "description" statement for the "rpc" statement. 2381 +-------------------------+-------------+ 2382 | | status code | 2383 +-------------------------+-------------+ 2384 | in-use | 409 | 2385 | invalid-value | 400 | 2386 | too-big | 413 | 2387 | missing-attribute | 400 | 2388 | bad-attribute | 400 | 2389 | unknown-attribute | 400 | 2390 | bad-element | 400 | 2391 | unknown-element | 400 | 2392 | unknown-namespace | 400 | 2393 | access-denied | 403 | 2394 | lock-denied | 409 | 2395 | resource-denied | 409 | 2396 | rollback-failed | 500 | 2397 | data-exists | 409 | 2398 | data-missing | 409 | 2399 | operation-not-supported | 501 | 2400 | operation-failed | 500 | 2401 | partial-operation | 500 | 2402 | malformed-message | 400 | 2403 +-------------------------+-------------+ 2405 Mapping from error-tag to status code 2407 7.1. Error Response Message 2409 When an error occurs for a request message on a data resource or an 2410 operation resource, and a "4xx" class of status codes (except for 2411 status code "403 Forbidden"), then the server SHOULD send a response 2412 message-body containing the information described by the "errors" 2413 container definition within the YANG module Section 8. The Content- 2414 Type of this response message MUST be application/yang.errors (see 2415 example below). 2417 The client MAY specify the desired encoding for error messages by 2418 specifying the appropriate media-type in the Accept header. If no 2419 error media is specified, the server MUST assume that "application/ 2420 yang.errors+xml" was specified. All of the examples in this 2421 document, except for the one below, assume the default XML encoding 2422 will be returned if there is an error. 2424 YANG Tree Diagram for Data: 2426 +--ro errors 2427 +--ro error 2428 +--ro error-type enumeration 2429 +--ro error-tag string 2430 +--ro error-app-tag? string 2431 +--ro error-path? instance-identifier 2432 +--ro error-message? string 2433 +--ro error-info 2435 The semantics and syntax for RESTCONF error messages are defined in 2436 the "application/yang.errors" restconf-media-type extension in 2437 Section 8. 2439 Examples: 2441 The following example shows an error returned for an "lock-denied" 2442 error that can occur if a NETCONF client has locked a datastore. The 2443 RESTCONF client is attempting to delete a data resource. Note that 2444 an Accept header is used to specify the desired encoding for the 2445 error message. This example's use of the Accept header is especially 2446 notable since the DELETE method typically doesn't return a message- 2447 body and hence Accept headers are typically not passed. 2449 DELETE /restconf/data/example-jukebox:jukebox/ 2450 library/artist=Foo%20Fighters/album=Wasting%20Light HTTP/1.1 2451 Host: example.com 2452 Accept: application/yang.errors+json 2454 The server might respond: 2456 HTTP/1.1 409 Conflict 2457 Date: Mon, 23 Apr 2012 17:11:00 GMT 2458 Server: example-server 2459 Content-Type: application/yang.errors+json 2461 { 2462 "ietf-restconf:errors": { 2463 "error": { 2464 "error-type": "protocol", 2465 "error-tag": "lock-denied", 2466 "error-message": "Lock failed, lock already held" 2467 } 2468 } 2469 } 2471 The following example shows an error returned for a "data-exists" 2472 error on a data resource. The "jukebox" resource already exists so 2473 it cannot be created. 2475 The client might send: 2477 POST /restconf/data/example-jukebox:jukebox HTTP/1.1 2478 Host: example.com 2480 The server might respond: 2482 HTTP/1.1 409 Conflict 2483 Date: Mon, 23 Apr 2012 17:11:00 GMT 2484 Server: example-server 2485 Content-Type: application/yang.errors+json 2487 { 2488 "ietf-restconf:errors": { 2489 "error": { 2490 "error-type": "protocol", 2491 "error-tag": "data-exists", 2492 "error-urlpath": "https://example.com/restconf/data/ 2493 example-jukebox:jukebox", 2494 "error-message": 2495 "Data already exists, cannot create new resource" 2496 } 2497 } 2498 } 2500 8. RESTCONF module 2502 The "ietf-restconf" module defines conceptual definitions within an 2503 extension and two groupings, which are not meant to be implemented as 2504 datastore contents by a server. E.g., the "restconf" container is 2505 not intended to be implemented as a top-level data node (under the 2506 "/restconf/data" entry point). 2508 RFC Ed.: update the date below with the date of RFC publication and 2509 remove this note. 2511 file "ietf-restconf@2015-06-04.yang" 2513 module ietf-restconf { 2514 namespace "urn:ietf:params:xml:ns:yang:ietf-restconf"; 2515 prefix "rc"; 2517 organization 2518 "IETF NETCONF (Network Configuration) Working Group"; 2520 contact 2521 "WG Web: 2522 WG List: 2523 WG Chair: Mehmet Ersue 2524 2526 WG Chair: Mahesh Jethanandani 2527 2529 Editor: Andy Bierman 2530 2532 Editor: Martin Bjorklund 2533 2535 Editor: Kent Watsen 2536 "; 2538 description 2539 "This module contains conceptual YANG specifications 2540 for basic RESTCONF media type definitions used in 2541 RESTCONF protocol messages. 2543 Note that the YANG definitions within this module do not 2544 represent configuration data of any kind. 2545 The 'restconf-media-type' YANG extension statement 2546 provides a normative syntax for XML and JSON message 2547 encoding purposes. 2549 Copyright (c) 2015 IETF Trust and the persons identified as 2550 authors of the code. All rights reserved. 2552 Redistribution and use in source and binary forms, with or 2553 without modification, is permitted pursuant to, and subject 2554 to the license terms contained in, the Simplified BSD License 2555 set forth in Section 4.c of the IETF Trust's Legal Provisions 2556 Relating to IETF Documents 2557 (http://trustee.ietf.org/license-info). 2559 This version of this YANG module is part of RFC XXXX; see 2560 the RFC itself for full legal notices."; 2562 // RFC Ed.: replace XXXX with actual RFC number and remove this 2563 // note. 2565 // RFC Ed.: remove this note 2566 // Note: extracted from draft-ietf-netconf-restconf-05.txt 2568 // RFC Ed.: update the date below with the date of RFC publication 2569 // and remove this note. 2570 revision 2015-06-04 { 2571 description 2572 "Initial revision."; 2573 reference 2574 "RFC XXXX: RESTCONF Protocol."; 2575 } 2577 extension restconf-media-type { 2578 argument media-type-id { 2579 yin-element true; 2580 } 2581 // RFC Ed.: replace draft-ietf-netmod-yang-json with RFC number 2582 // in the description below, and remove this note. 2583 description 2584 "This extension is used to specify a YANG data structure which 2585 represents a conceptual RESTCONF media type. 2586 Data definition statements within this extension specify 2587 the generic syntax for the specific media type. 2589 YANG is mapped to specific encoding formats outside the 2590 scope of this extension statement. RFC 6020 defines XML 2591 encoding rules for all RESTCONF media types that use 2592 the '+xml' suffix. draft-ietf-netmod-yang-json defines 2593 JSON encoding rules for all RESTCONF media types that 2594 use the '+json' suffix. 2596 The 'media-type-id' parameter value identifies the media type 2597 that is being defined. It contains the string associated 2598 with the generic media type, i.e., no suffix is specified. 2600 This extension is ignored unless it appears as a top-level 2601 statement. It SHOULD contain data definition statements 2602 that result in exactly one container data node definition. 2603 This allows compliant translation to an XML instance 2604 document for each media type. 2606 The module name and namespace value for the YANG module using 2607 the extension statement is assigned to instance document data 2608 conforming to the data definition statements within 2609 this extension. 2611 The sub-statements of this extension MUST follow the 2612 'data-def-stmt' rule in the YANG ABNF. 2614 The XPath document root is the extension statement itself, 2615 such that the child nodes of the document root are 2616 represented by the data-def-stmt sub-statements within 2617 this extension. This conceptual document is the context 2618 for the following YANG statements: 2620 - must-stmt 2621 - when-stmt 2622 - path-stmt 2623 - min-elements-stmt 2624 - max-elements-stmt 2625 - mandatory-stmt 2626 - unique-stmt 2627 - ordered-by 2628 - instance-identifier data type 2630 The following data-def-stmt sub-statements have special 2631 meaning when used within a restconf-resource extension 2632 statement. 2634 - The list-stmt is not required to have a key-stmt defined. 2635 - The if-feature-stmt is ignored if present. 2636 - The config-stmt is ignored if present. 2637 - The available identity values for any 'identityref' 2638 leaf or leaf-list nodes is limited to the module 2639 containing this extension statement, and the modules 2640 imported into that module. 2641 "; 2642 } 2644 rc:restconf-media-type "application/yang.errors" { 2645 uses errors; 2646 } 2648 rc:restconf-media-type "application/yang.api" { 2649 uses restconf; 2650 } 2652 grouping errors { 2653 description 2654 "A grouping that contains a YANG container 2655 representing the syntax and semantics of a 2656 YANG Patch errors report within a response message."; 2658 container errors { 2659 description 2660 "Represents an error report returned by the server if 2661 a request results in an error."; 2663 list error { 2664 description 2665 "An entry containing information about one 2666 specific error that occurred while processing 2667 a RESTCONF request."; 2669 reference "RFC 6241, Section 4.3"; 2671 leaf error-type { 2672 type enumeration { 2673 enum transport { 2674 description "The transport layer"; 2675 } 2676 enum rpc { 2677 description "The rpc or notification layer"; 2678 } 2679 enum protocol { 2680 description "The protocol operation layer"; 2681 } 2682 enum application { 2683 description "The server application layer"; 2684 } 2685 } 2686 mandatory true; 2687 description 2688 "The protocol layer where the error occurred."; 2689 } 2691 leaf error-tag { 2692 type string; 2693 mandatory true; 2694 description 2695 "The enumerated error tag."; 2696 } 2698 leaf error-app-tag { 2699 type string; 2700 description 2701 "The application-specific error tag."; 2702 } 2704 leaf error-path { 2705 type instance-identifier; 2706 description 2707 "The YANG instance identifier associated 2708 with the error node."; 2709 } 2711 leaf error-message { 2712 type string; 2713 description 2714 "A message describing the error."; 2715 } 2716 anyxml error-info { 2717 description 2718 "Arbitrary XML that represents a container 2719 of additional information for the error report."; 2720 } 2721 } 2722 } 2723 } 2725 grouping restconf { 2726 description 2727 "Conceptual container representing the 2728 application/yang.api resource type."; 2730 container restconf { 2731 description 2732 "Conceptual container representing the 2733 application/yang.api resource type."; 2735 container data { 2736 description 2737 "Container representing the application/yang.datastore 2738 resource type. Represents the conceptual root of all 2739 operational data and configuration data supported by 2740 the server. The child nodes of this container can be 2741 any data resource (application/yang.data), which are 2742 defined as top-level data nodes from the YANG modules 2743 advertised by the server in the ietf-restconf-monitoring 2744 module."; 2745 } 2747 container operations { 2748 description 2749 "Container for all operation resources 2750 (application/yang.operation), 2752 Each resource is represented as an empty leaf with the 2753 name of the RPC operation from the YANG rpc statement. 2755 E.g.; 2757 POST /restconf/operations/show-log-errors 2759 leaf show-log-errors { 2760 type empty; 2761 } 2762 "; 2763 } 2765 } 2766 } 2768 } 2770 2772 9. RESTCONF Monitoring 2774 The "ietf-restconf-monitoring" module provides information about the 2775 RESTCONF protocol capabilities and event notification streams 2776 available from the server. Implementation is mandatory for RESTCONF 2777 servers, if any protocol capabilities or event notification streams 2778 are supported. 2780 YANG Tree Diagram for "ietf-restconf-monitoring" module: 2782 +--ro restconf-state 2783 +--ro capabilities 2784 | +--ro capability* inet:uri 2785 +--ro streams 2786 +--ro stream* [name] 2787 +--ro name string 2788 +--ro description? string 2789 +--ro replay-support? boolean 2790 +--ro replay-log-creation-time? yang:date-and-time 2791 +--ro access* [type] 2792 +--ro encoding string 2793 +--ro location inet:uri 2795 9.1. restconf-state/capabilities 2797 This mandatory container holds the RESTCONF protocol capability URIs 2798 supported by the server. 2800 The server MUST maintain a last-modified timestamp for this 2801 container, and return the "Last-Modified" header when this data node 2802 is retrieved with the GET or HEAD methods. 2804 The server SHOULD maintain an entity-tag for this container, and 2805 return the "ETag" header when this data node is retrieved with the 2806 GET or HEAD methods. 2808 The server MUST include a "capability" URI leaf-list entry for the 2809 "defaults" mode used by the server, defined in Section 9.1.2. 2811 The server MUST include a "capability" URI leaf-list entry 2812 identifying each supported optional protocol feature. This includes 2813 optional query parameters and MAY include other capability URIs 2814 defined outside this document. 2816 9.1.1. Query Parameter URIs 2818 A new set of RESTCONF Capability URIs are defined to identify the 2819 specific query parameters (defined in Section 4.8) supported by the 2820 server. 2822 The server MUST include a "capability" leaf-list entry for each 2823 optional query parameter that it supports. 2825 +------------+--------+---------------------------------------------+ 2826 | Name | Sectio | URI | 2827 | | n | | 2828 +------------+--------+---------------------------------------------+ 2829 | depth | 4.8.2 | urn:ietf:params:restconf:capability:depth:1 | 2830 | | | .0 | 2831 | fields | 4.8.3 | urn:ietf:params:restconf:capability:fields: | 2832 | | | 1.0 | 2833 | filter | 4.8.6 | urn:ietf:params:restconf:capability:filter: | 2834 | | | 1.0 | 2835 | replay | 4.8.7 | urn:ietf:params:restconf:capability:replay: | 2836 | | 4.8.8 | 1.0 | 2837 | with- | 4.8.9 | urn:ietf:params:restconf:capability:with- | 2838 | defaults | | defaults:1.0 | 2839 +------------+--------+---------------------------------------------+ 2841 RESTCONF Query Parameter URIs 2843 9.1.2. The "defaults" Protocol Capability URI 2845 This URI identifies the defaults handling mode that is used by the 2846 server for processing default leafs in requests for data resources. 2847 A parameter named "basic-mode" is required for this capability URI. 2848 The "basic-mode" definitions are specified in the "With-Defaults 2849 Capability for NETCONF" [RFC6243]. 2851 +----------+--------------------------------------------------+ 2852 | Name | URI | 2853 +----------+--------------------------------------------------+ 2854 | defaults | urn:ietf:params:restconf:capability:defaults:1.0 | 2855 +----------+--------------------------------------------------+ 2857 RESTCONF defaults capability URI 2859 This protocol capability URI MUST be supported by the server, and the 2860 MUST be listed in the "capability" leaf-list in Section 9.3. 2862 +------------+------------------------------------------------------+ 2863 | Value | Description | 2864 +------------+------------------------------------------------------+ 2865 | report-all | No data nodes are considered default | 2866 | trim | Values set to the YANG default-stmt value are | 2867 | | default | 2868 | explicit | Values set by the client are never considered | 2869 | | default | 2870 +------------+------------------------------------------------------+ 2872 If the "basic-mode" is set to "report-all" then the server MUST 2873 adhere to the defaults handling behavior defined in Section 2.1 of 2874 [RFC6243]. 2876 If the "basic-mode" is set to "trim" then the server MUST adhere to 2877 the defaults handling behavior defined in Section 2.2 of [RFC6243]. 2879 If the "basic-mode" is set to "explicit" then the server MUST adhere 2880 to the defaults handling behavior defined in Section 2.3 of 2881 [RFC6243]. 2883 Example: (split for display purposes only) 2885 urn:ietf:params:restconf:capability:defaults:1.0? 2886 basic-mode=explicit 2888 9.2. restconf-state/streams 2890 This optional container provides access to the event notification 2891 streams supported by the server. The server MAY omit this container 2892 if no event notification streams are supported. 2894 The server will populate this container with a stream list entry for 2895 each stream type it supports. Each stream contains a leaf called 2896 "events" which contains a URI that represents an event stream 2897 resource. 2899 Stream resources are defined in Section 3.8. Notifications are 2900 defined in Section 6. 2902 9.3. RESTCONF Monitoring Module 2904 The "ietf-restconf-monitoring" module defines monitoring information 2905 for the RESTCONF protocol. 2907 The "ietf-yang-types" and "ietf-inet-types" modules from [RFC6991] 2908 are used by this module for some type definitions. 2910 RFC Ed.: update the date below with the date of RFC publication and 2911 remove this note. 2913 file "ietf-restconf-monitoring@2015-06-04.yang" 2915 module ietf-restconf-monitoring { 2916 namespace "urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring"; 2917 prefix "rcmon"; 2919 import ietf-yang-types { prefix yang; } 2920 import ietf-inet-types { prefix inet; } 2922 organization 2923 "IETF NETCONF (Network Configuration) Working Group"; 2925 contact 2926 "WG Web: 2927 WG List: 2929 WG Chair: Mehmet Ersue 2930 2932 WG Chair: Mahesh Jethanandani 2933 2935 Editor: Andy Bierman 2936 2938 Editor: Martin Bjorklund 2939 2941 Editor: Kent Watsen 2942 "; 2944 description 2945 "This module contains monitoring information for the 2946 RESTCONF protocol. 2948 Copyright (c) 2015 IETF Trust and the persons identified as 2949 authors of the code. All rights reserved. 2951 Redistribution and use in source and binary forms, with or 2952 without modification, is permitted pursuant to, and subject 2953 to the license terms contained in, the Simplified BSD License 2954 set forth in Section 4.c of the IETF Trust's Legal Provisions 2955 Relating to IETF Documents 2956 (http://trustee.ietf.org/license-info). 2957 This version of this YANG module is part of RFC XXXX; see 2958 the RFC itself for full legal notices."; 2960 // RFC Ed.: replace XXXX with actual RFC number and remove this 2961 // note. 2963 // RFC Ed.: remove this note 2964 // Note: extracted from draft-ietf-netconf-restconf-05.txt 2966 // RFC Ed.: update the date below with the date of RFC publication 2967 // and remove this note. 2968 revision 2015-06-04 { 2969 description 2970 "Initial revision."; 2971 reference 2972 "RFC XXXX: RESTCONF Protocol."; 2973 } 2975 container restconf-state { 2976 config false; 2977 description 2978 "Contains RESTCONF protocol monitoring information."; 2980 container capabilities { 2981 description 2982 "Contains a list of protocol capability URIs"; 2984 leaf-list capability { 2985 type inet:uri; 2986 description "A RESTCONF protocol capability URI."; 2987 } 2988 } 2990 container streams { 2991 description 2992 "Container representing the notification event streams 2993 supported by the server."; 2994 reference 2995 "RFC 5277, Section 3.4, element."; 2997 list stream { 2998 key name; 2999 description 3000 "Each entry describes an event stream supported by 3001 the server."; 3003 leaf name { 3004 type string; 3005 description "The stream name"; 3006 reference "RFC 5277, Section 3.4, element."; 3007 } 3009 leaf description { 3010 type string; 3011 description "Description of stream content"; 3012 reference 3013 "RFC 5277, Section 3.4, element."; 3014 } 3016 leaf replay-support { 3017 type boolean; 3018 description 3019 "Indicates if replay buffer supported for this stream. 3020 If 'true', then the server MUST support the 'start-time' 3021 and 'stop-time' query parameters for this stream."; 3022 reference 3023 "RFC 5277, Section 3.4, element."; 3024 } 3026 leaf replay-log-creation-time { 3027 when "../replay-support" { 3028 description 3029 "Only present if notification replay is supported"; 3030 } 3031 type yang:date-and-time; 3032 description 3033 "Indicates the time the replay log for this stream 3034 was created."; 3035 reference 3036 "RFC 5277, Section 3.4, 3037 element."; 3038 } 3040 list access { 3041 key type; 3042 min-elements 1; 3043 description 3044 "The server will create an entry in this list for each 3045 encoding format that is supported for this stream. 3046 The media type 'application/yang.stream' is expected 3047 for all event streams. This list identifies the 3048 sub-types supported for this stream."; 3050 leaf encoding { 3051 type string; 3052 description 3053 "This is the secondary encoding format within the 3054 'text/event-stream' encoding used by all streams. 3055 The type 'xml' is supported for the media type 3056 'application/yang.stream+xml'. The type 'json' 3057 is supported for the media type 3058 'application/yang.stream+json'."; 3060 } 3062 leaf location { 3063 type inet:uri; 3064 mandatory true; 3065 description 3066 "Contains a URL that represents the entry point 3067 for establishing notification delivery via server 3068 sent events."; 3069 } 3070 } 3071 } 3072 } 3073 } 3075 } 3077 3079 10. YANG Module Library 3081 The "ietf-yang-library" module defined in 3082 [I-D.ietf-netconf-yang-library] provides information about the YANG 3083 modules and submodules used by the RESTCONF server. Implementation 3084 is mandatory for RESTCONF servers. All YANG modules and submodules 3085 used by the server MUST be identified in the YANG module library. 3087 10.1. modules 3089 This mandatory container holds the identifiers for the YANG data 3090 model modules supported by the server. 3092 The server MUST maintain a last-modified timestamp for this 3093 container, and return the "Last-Modified" header when this data node 3094 is retrieved with the GET or HEAD methods. 3096 The server SHOULD maintain an entity-tag for this container, and 3097 return the "ETag" header when this data node is retrieved with the 3098 GET or HEAD methods. 3100 10.1.1. modules/module 3102 This mandatory list contains one entry for each YANG data model 3103 module supported by the server. There MUST be an instance of this 3104 list for every YANG module that is used by the server. 3106 The contents of this list are defined in the "module" YANG list 3107 statement in [I-D.ietf-netconf-yang-library]. 3109 The server MAY maintain a last-modified timestamp for each instance 3110 of this list entry, and return the "Last-Modified" header when this 3111 data node is retrieved with the GET or HEAD methods. If not 3112 supported then the timestamp for the parent "modules" container MAY 3113 be used instead. 3115 The server MAY maintain an entity-tag for each instance of this list 3116 entry, and return the "ETag" header when this data node is retrieved 3117 with the GET or HEAD methods. If not supported then the timestamp 3118 for the parent "modules" container MAY be used instead. 3120 11. IANA Considerations 3122 11.1. The "restconf" Relation Type 3124 This specification registers the "restconf" relation type in the Link 3125 Relation Type Registry defined by [RFC5988]: 3127 Relation Name: restconf 3129 Description: Identifies the root of RESTCONF API as configured 3130 on this HTTP server. The "restconf" relation 3131 defines the root of the API defined in RFCXXXX. 3132 Subsequent revisions of RESTCONF will use alternate 3133 relation values to support protocol versioning. 3135 Reference: RFC XXXX 3137 ` 3139 11.2. YANG Module Registry 3141 This document registers two URIs in the IETF XML registry [RFC3688]. 3142 Following the format in RFC 3688, the following registration is 3143 requested to be made. 3145 URI: urn:ietf:params:xml:ns:yang:ietf-restconf 3146 Registrant Contact: The NETMOD WG of the IETF. 3147 XML: N/A, the requested URI is an XML namespace. 3149 URI: urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring 3150 Registrant Contact: The NETMOD WG of the IETF. 3151 XML: N/A, the requested URI is an XML namespace. 3153 This document registers two YANG modules in the YANG Module Names 3154 registry [RFC6020]. 3156 name: ietf-restconf 3157 namespace: urn:ietf:params:xml:ns:yang:ietf-restconf 3158 prefix: rc 3159 // RFC Ed.: replace XXXX with RFC number and remove this note 3160 reference: RFC XXXX 3162 name: ietf-restconf-monitoring 3163 namespace: urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring 3164 prefix: rcmon 3165 // RFC Ed.: replace XXXX with RFC number and remove this note 3166 reference: RFC XXXX 3168 11.3. application/yang Media Sub Types 3170 The parent MIME media type for RESTCONF resources is application/ 3171 yang, which is defined in [RFC6020]. This document defines the 3172 following sub-types for this media type. 3174 - api 3175 - data 3176 - datastore 3177 - errors 3178 - operation 3179 - stream 3181 Type name: application 3183 Subtype name: yang.xxx 3185 Required parameters: none 3187 Optional parameters: See section 4.8 in RFC XXXX 3189 Encoding considerations: 8-bit 3191 Security considerations: See Section 12 in RFC XXXX 3193 Interoperability considerations: none 3195 // RFC Ed.: replace XXXX with RFC number and remove this note 3196 Published specification: RFC XXXX 3198 11.4. RESTCONF Capability URNs 3200 [Note to RFC Editor: 3201 The RESTCONF Protocol Capability Registry does not yet exist; 3202 Need to ask IANA to create it; remove this note for publication 3203 ] 3205 This document defines a registry for RESTCONF capability identifiers. 3206 The name of the registry is "RESTCONF Capability URNs". The registry 3207 shall record for each entry: 3209 o the name of the RESTCONF capability. By convention, this name is 3210 prefixed with the colon ':' character. 3212 o the URN for the RESTCONF capability. 3214 This document registers several capability identifiers in "RESTCONF 3215 Capability URNs" registry: 3217 Index 3218 Capability Identifier 3219 ------------------------ 3221 :defaults 3222 urn:ietf:params:restconf:capability:defaults:1.0 3224 :depth 3225 urn:ietf:params:restconf:capability:depth:1.0 3227 :fields 3228 urn:ietf:params:restconf:capability:fields:1.0 3230 :filter 3231 urn:ietf:params:restconf:capability:filter:1.0 3233 :replay 3234 urn:ietf:params:restconf:capability:replay:1.0 3236 :with-defaults 3237 urn:ietf:params:restconf:capability:with-defaults:1.0 3239 12. Security Considerations 3241 This section provides security considerations for the resources 3242 defined by the RESTCONF protocol. Security considerations for HTTPS 3243 are defined in [RFC2818]. Security considerations for the content 3244 manipulated by RESTCONF can be found in the documents defining data 3245 models. 3247 This document does not specify an authentication scheme, but it does 3248 require that an authenticated NETCONF username be associated with 3249 each HTTP request. The authentication scheme MAY be implemented in 3250 the underlying transport layer (e.g., client certificates) or within 3251 the HTTP layer (e.g., Basic Auth, OAuth, etc.). RESTCONF does not 3252 itself define an authentication mechanism. Authentication MUST occur 3253 in a lower layer. Implementors SHOULD provide a comprehensive 3254 authorization scheme with RESTCONF and ensure that the resulting 3255 NETCONF username is made available to the RESTCONF server. 3257 Authorization of individual user access to operations and data MAY be 3258 configured via NETCONF Access Control Model (NACM) [RFC6536], as 3259 specified in Section 4. 3261 Configuration information is by its very nature sensitive. Its 3262 transmission in the clear and without integrity checking leaves 3263 devices open to classic eavesdropping and false data injection 3264 attacks. Configuration information often contains passwords, user 3265 names, service descriptions, and topological information, all of 3266 which are sensitive. Because of this, this protocol SHOULD be 3267 implemented carefully with adequate attention to all manner of attack 3268 one might expect to experience with other management interfaces. 3270 Different environments may well allow different rights prior to and 3271 then after authentication. When an operation is not properly 3272 authorized, the RESTCONF server MUST return HTTP error status code 3273 401 Unauthorized. Note that authorization information can be 3274 exchanged in the form of configuration information, which is all the 3275 more reason to ensure the security of the connection. 3277 13. Acknowledgements 3279 The authors would like to thank the following people for their 3280 contributions to this document: Ladislav Lhotka, Juergen 3281 Schoenwaelder, Rex Fernando, Robert Wilton, and Jonathan Hansford. 3283 14. References 3285 14.1. Normative References 3287 [I-D.ietf-netconf-yang-library] 3288 Bierman, A., Bjorklund, M., and K. Watsen, "YANG Module 3289 Library", draft-ietf-netconf-yang-library-00 (work in 3290 progress), January 2015. 3292 [I-D.ietf-netmod-yang-json] 3293 Lhotka, L., "JSON Encoding of Data Modeled with YANG", 3294 draft-ietf-netmod-yang-json-02 (work in progress), 3295 November 2014. 3297 [I-D.lhotka-netmod-yang-metadata] 3298 Lhotka, L., "Defining and Using Metadata with YANG", 3299 draft-lhotka-netmod-yang-metadata-01 (work in progress), 3300 February 2015. 3302 [RFC2046] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 3303 Extensions (MIME) Part Two: Media Types", RFC 2046, 3304 November 1996. 3306 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 3307 Requirement Levels", BCP 14, RFC 2119, March 1997. 3309 [RFC2396] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 3310 Resource Identifiers (URI): Generic Syntax", RFC 2396, 3311 August 1998. 3313 [RFC2818] Rescorla, E., "The IETF XML Registry", RFC 2818, May 2000. 3315 [RFC3688] Mealling, M., "The IETF XML Registry", BCP 81, RFC 3688, 3316 January 2004. 3318 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 3319 Resource Identifier (URI): Generic Syntax", STD 66, RFC 3320 3986, January 2005. 3322 [RFC4252] Ylonen, T. and C. Lonvick, "The Secure Shell (SSH) 3323 Authentication Protocol", RFC 4252, January 2006. 3325 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 3326 (TLS) Protocol Version 1.2", RFC 5246, August 2008. 3328 [RFC5277] Chisholm, S. and H. Trevino, "NETCONF Event 3329 Notifications", RFC 5277, July 2008. 3331 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 3332 Housley, R., and T. Polk, "Internet X.509 Public Key 3333 Infrastructure Certificate and Certificate Revocation List 3334 (CRL) Profile", RFC 5280, May 2008. 3336 [RFC5789] Dusseault, L. and J. Snell, "PATCH Method for HTTP", RFC 3337 5789, March 2010. 3339 [RFC5988] Nottingham, M., "Web Linking", RFC 5988, October 2010. 3341 [RFC6020] Bjorklund, M., "YANG - A Data Modeling Language for the 3342 Network Configuration Protocol (NETCONF)", RFC 6020, 3343 October 2010. 3345 [RFC6125] Saint-Andre, P. and J. Hodges, "Representation and 3346 Verification of Domain-Based Application Service Identity 3347 within Internet Public Key Infrastructure Using X.509 3348 (PKIX) Certificates in the Context of Transport Layer 3349 Security (TLS)", RFC 6125, March 2011. 3351 [RFC6241] Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed., 3352 and A. Bierman, Ed., "Network Configuration Protocol 3353 (NETCONF)", RFC 6241, June 2011. 3355 [RFC6243] Bierman, A. and B. Lengyel, "With-defaults Capability for 3356 NETCONF", RFC 6243, June 2011. 3358 [RFC6415] Hammer-Lahav, E. and B. Cook, "Web Host Metadata", RFC 3359 6415, October 2011. 3361 [RFC6536] Bierman, A. and M. Bjorklund, "Network Configuration 3362 Protocol (NETCONF) Access Control Model", RFC 6536, March 3363 2012. 3365 [RFC6570] Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., 3366 and D. Orchard, "URI Template", RFC 6570, March 2012. 3368 [RFC6991] Schoenwaelder, J., "Common YANG Data Types", RFC 6991, 3369 July 2013. 3371 [RFC7158] Bray, T., Ed., "The JSON Data Interchange Format", RFC 3372 7158, March 2013. 3374 [RFC7230] Fielding, R. and J. Reschke, "Hypertext Transfer Protocol 3375 (HTTP/1.1): Message Syntax and Routing", RFC 7230, June 3376 2014. 3378 [RFC7231] Fielding, R. and J. Reschke, "Hypertext Transfer Protocol 3379 (HTTP/1.1): Semantics and Content", RFC 7231, June 2014. 3381 [RFC7232] Fielding, R. and J. Reschke, "Hypertext Transfer Protocol 3382 (HTTP/1.1): Conditional Requests", RFC 7232, June 2014. 3384 [RFC7235] Fielding, R. and J. Reschke, "Hypertext Transfer Protocol 3385 (HTTP/1.1): Authentication", RFC 7235, June 2014. 3387 [RFC7320] Nottingham, M., "URI Design and Ownership", BCP 190, RFC 3388 7320, July 2014. 3390 [W3C.CR-eventsource-20121211] 3391 Hickson, I., "Server-Sent Events", World Wide Web 3392 Consortium CR CR-eventsource-20121211, December 2012, 3393 . 3395 [W3C.REC-xml-20081126] 3396 Yergeau, F., Maler, E., Paoli, J., Sperberg-McQueen, C., 3397 and T. Bray, "Extensible Markup Language (XML) 1.0 (Fifth 3398 Edition)", World Wide Web Consortium Recommendation REC- 3399 xml-20081126, November 2008, 3400 . 3402 [XPath] Clark, J. and S. DeRose, "XML Path Language (XPath) 3403 Version 1.0", World Wide Web Consortium Recommendation 3404 REC-xpath-19991116, November 1999, 3405 . 3407 [draft-ietf-httpauth-basicauth-update-03] 3408 Reschke, J., "The 'Basic' HTTP Authentication Scheme", 3409 draft-ietf-httpauth-basicauth-update-03 (work in 3410 progress), Dec 2014. 3412 [draft-ietf-httpauth-digest-09] 3413 Shekh-Yusef, R., Reschke, D., and S. Bremer, "HTTP Digest 3414 Access Authentication", draft-ietf-httpauth-digest-09 3415 (work in progress), Dec 2014. 3417 [draft-ietf-netconf-rfc5539bis-10] 3418 Badra, M., Luchuk, A., and J. Schoenwaelder, "Using the 3419 NETCONF Protocol over Transport Layer Security (TLS) with 3420 Mutual X.509 Authentication", draft-ietf-netconf- 3421 rfc5539bis-10 (work in progress), Dec 2014. 3423 [draft-thomson-httpbis-cant-01] 3424 Thomson, M., "Client Authentication over New TLS 3425 Connection", draft-thomson-httpbis-cant-01 (work in 3426 progress), Jul 2014. 3428 14.2. Informative References 3430 [I-D.ietf-netconf-yang-patch] 3431 Bierman, A., Bjorklund, M., and K. Watsen, "YANG Patch 3432 Media Type", draft-ietf-netconf-yang-patch-03 (work in 3433 progress), January 2015. 3435 [rest-dissertation] 3436 Fielding, R., "Architectural Styles and the Design of 3437 Network-based Software Architectures", 2000. 3439 Appendix A. Change Log 3441 -- RFC Ed.: remove this section before publication. 3443 The RESTCONF issue tracker can be found here: https://github.com/ 3444 netconf-wg/restconf/issues 3446 A.1. 04 - 05 3448 o changed term 'notification event' to 'event notification' 3450 o removed intro text about framework and meta-model 3452 o removed early mention of API resources 3453 o removed term unified datastore and cleaned up text about NETCONF 3454 datastores 3456 o removed text about not immediate persistence of edits 3458 o removed RESTCONF-specific data-resource-identifier typedef and its 3459 usage 3461 o clarified encoding of key leafs 3463 o changed several examples from JSON to XML encoding 3465 o made 'insert' and 'point' query parameters mandatory to implement 3467 o removed ":insert" capability URI 3469 o renamed stream/encoding to stream/access 3471 o renamed stream/encoding/type to stream/access/encoding 3473 o renamed stream/encoding/events to stream/access/location 3475 o changed XPath from informative to normative reference 3477 o changed rest-dissertation from normative to informative reference 3479 o changed example-jukebox playlist 'id' from a data-resource- 3480 identifier to a leafref pointing at the song name 3482 A.2. 03 - 04 3484 o renamed 'select' to 'fields' (#1) 3486 o moved collection resource and page capability to draft-ietf- 3487 netconf-restconf-collection-00 (#3) 3489 o added mandatory "defaults" protocol capability URI (#4) 3491 o added optional "with-defaults" query parameter URI (#4) 3493 o clarified authentication procedure (#9) 3495 o moved ietf-yang-library module to draft-ietf-netconf-yang- 3496 library-00 (#13) 3498 o clarified that JSON encoding of module name in a URI MUST follow 3499 the netmod-yang-json encoding rules (#14) 3501 o added restconf-media-type extension (#15) 3503 o remove "content" query parameter URI and made this parameter 3504 mandatory (#16) 3506 o clarified datastore usage 3508 o changed lock-denied error example 3510 o added with-defaults query parameter example 3512 o added term "RESTCONF Capability" 3514 o changed NETCONF Capability URI registry usage to new RESTCONF 3515 Capability URI Registry usage 3517 A.3. 02 - 03 3519 o added collection resource 3521 o added "page" query parameter capability 3523 o added "limit" and "offset" query parameters, which are available 3524 if the "page" capability is supported 3526 o added "stream list" term 3528 o fixed bugs in some examples 3530 o added "encoding" list within the "stream" list to allow different 3531 URLs for XML and JSON encoding. 3533 o made XML MUST implement and JSON MAY implement for servers 3535 o re-add JSON notification examples (previously removed) 3537 o updated JSON references 3539 A.4. 01 - 02 3541 o moved query parameter definitions from the YANG module back to the 3542 plain text sections 3544 o made all query parameters optional to implement 3546 o defined query parameter capability URI 3548 o moved 'streams' to new YANG module (ietf-restconf-monitoring) 3549 o added 'capabilities' container to new YANG module (ietf-restconf- 3550 monitoring) 3552 o moved 'modules' container to new YANG module (ietf-yang-library) 3554 o added new leaf 'module-set-id' (ietf-yang-library) 3556 o added new leaf 'conformance' (ietf-yang-library) 3558 o changed 'schema' leaf to type inet:uri that returns the location 3559 of the YANG schema (instead of returning the schema directly) 3561 o changed 'events' leaf to type inet:uri that returns the location 3562 of the event stream resource (instead of returning events 3563 directly) 3565 o changed examples for yang.api resource since the monitoring 3566 information is no longer in this resource 3568 o closed issue #1 'select parameter' since no objections to the 3569 proposed syntax 3571 o closed "encoding of list keys" issue since no objection to new 3572 encoding of list keys in a target resource URI. 3574 o moved open issues list to the issue tracker on github 3576 A.5. 00 - 01 3578 o fixed content=nonconfig example (non-config was incorrect) 3580 o closed open issue 'message-id'. There is no need for a message-id 3581 field, and RFC 2392 does not apply. 3583 o closed open issue 'server support verification'. The headers used 3584 by RESTCONF are widely supported. 3586 o removed encoding rules from section on RESTCONF Meta-Data. This 3587 is now defined in "I-D.lhotka-netmod-yang-json". 3589 o added media type application/yang.errors to map to errors YANG 3590 grouping. Updated error examples to use new media type. 3592 o closed open issue 'additional datastores'. Support may be added 3593 in the future to identify new datastores. 3595 o closed open issue 'PATCH media type discovery'. The section on 3596 PATCH has an added sentence on the Accept-Patch header. 3598 o closed open issue 'YANG to resource mapping'. Current mapping of 3599 all data nodes to resources will be used in order to allow 3600 mandatory DELETE support. The PATCH operation is optional, as 3601 well as the YANG Patch media type. 3603 o closed open issue '_self links for HATEOAS support'. It was 3604 decided that they are redundant because they can be derived from 3605 the YANG module for the specific data. 3607 o added explanatory text for the 'select' parameter. 3609 o added RESTCONF Path Resolution section for discovering the root of 3610 the RESTCONF API using the /.well-known/host-meta. 3612 o added an "error" media type to for structured error messages 3614 o added Secure Transport section requiring TLS 3616 o added Security Considerations section 3618 o removed all references to "REST-like" 3620 A.6. bierman:restconf-04 to ietf:restconf-00 3622 o updated open issues section 3624 Appendix B. Open Issues 3626 -- RFC Ed.: remove this section before publication. 3628 The RESTCONF issues are tracked on github.com: 3630 https://github.com/netconf-wg/restconf/issues 3632 Appendix C. Example YANG Module 3634 The example YANG module used in this document represents a simple 3635 media jukebox interface. 3637 YANG Tree Diagram for "example-jukebox" Module 3638 +--rw jukebox! 3639 +--rw library 3640 | +--rw artist* [name] 3641 | | +--rw name string 3642 | | +--rw album* [name] 3643 | | +--rw name string 3644 | | +--rw genre? identityref 3645 | | +--rw year? uint16 3646 | | +--rw admin 3647 | | | +--rw label? string 3648 | | | +--rw catalogue-number? string 3649 | | +--rw song* [name] 3650 | | +--rw name string 3651 | | +--rw location string 3652 | | +--rw format? string 3653 | | +--rw length? uint32 3654 | +--ro artist-count? uint32 3655 | +--ro album-count? uint32 3656 | +--ro song-count? uint32 3657 +--rw playlist* [name] 3658 | +--rw name string 3659 | +--rw description? string 3660 | +--rw song* [index] 3661 | +--rw index uint32 3662 | +--rw id leafref 3663 +--rw player 3664 +--rw gap? decimal64 3666 rpcs: 3668 +---x play 3669 +--ro input 3670 +--ro playlist string 3671 +--ro song-number uint32 3673 C.1. example-jukebox YANG Module 3675 module example-jukebox { 3677 namespace "http://example.com/ns/example-jukebox"; 3678 prefix "jbox"; 3680 organization "Example, Inc."; 3681 contact "support at example.com"; 3682 description "Example Jukebox Data Model Module"; 3683 revision "2015-04-04" { 3684 description "Initial version."; 3685 reference "example.com document 1-4673"; 3687 } 3689 identity genre { 3690 description "Base for all genre types"; 3691 } 3693 // abbreviated list of genre classifications 3694 identity alternative { 3695 base genre; 3696 description "Alternative music"; 3697 } 3698 identity blues { 3699 base genre; 3700 description "Blues music"; 3701 } 3702 identity country { 3703 base genre; 3704 description "Country music"; 3705 } 3706 identity jazz { 3707 base genre; 3708 description "Jazz music"; 3709 } 3710 identity pop { 3711 base genre; 3712 description "Pop music"; 3713 } 3714 identity rock { 3715 base genre; 3716 description "Rock music"; 3717 } 3719 container jukebox { 3720 presence 3721 "An empty container indicates that the jukebox 3722 service is available"; 3724 description 3725 "Represents a jukebox resource, with a library, playlists, 3726 and a play operation."; 3728 container library { 3730 description "Represents the jukebox library resource."; 3732 list artist { 3733 key name; 3734 description 3735 "Represents one artist resource within the 3736 jukebox library resource."; 3738 leaf name { 3739 type string { 3740 length "1 .. max"; 3741 } 3742 description "The name of the artist."; 3743 } 3745 list album { 3746 key name; 3748 description 3749 "Represents one album resource within one 3750 artist resource, within the jukebox library."; 3752 leaf name { 3753 type string { 3754 length "1 .. max"; 3755 } 3756 description "The name of the album."; 3757 } 3759 leaf genre { 3760 type identityref { base genre; } 3761 description 3762 "The genre identifying the type of music on 3763 the album."; 3764 } 3766 leaf year { 3767 type uint16 { 3768 range "1900 .. max"; 3769 } 3770 description "The year the album was released"; 3771 } 3773 container admin { 3774 description 3775 "Administrative information for the album."; 3777 leaf label { 3778 type string; 3779 description "The label that released the album."; 3780 } 3781 leaf catalogue-number { 3782 type string; 3783 description "The album's catalogue number."; 3784 } 3785 } 3787 list song { 3788 key name; 3790 description 3791 "Represents one song resource within one 3792 album resource, within the jukebox library."; 3794 leaf name { 3795 type string { 3796 length "1 .. max"; 3797 } 3798 description "The name of the song"; 3799 } 3800 leaf location { 3801 type string; 3802 mandatory true; 3803 description 3804 "The file location string of the 3805 media file for the song"; 3806 } 3807 leaf format { 3808 type string; 3809 description 3810 "An identifier string for the media type 3811 for the file associated with the 3812 'location' leaf for this entry."; 3813 } 3814 leaf length { 3815 type uint32; 3816 units "seconds"; 3817 description 3818 "The duration of this song in seconds."; 3819 } 3820 } // end list 'song' 3821 } // end list 'album' 3822 } // end list 'artist' 3824 leaf artist-count { 3825 type uint32; 3826 units "songs"; 3827 config false; 3828 description "Number of artists in the library"; 3829 } 3830 leaf album-count { 3831 type uint32; 3832 units "albums"; 3833 config false; 3834 description "Number of albums in the library"; 3835 } 3836 leaf song-count { 3837 type uint32; 3838 units "songs"; 3839 config false; 3840 description "Number of songs in the library"; 3841 } 3842 } // end library 3844 list playlist { 3845 key name; 3847 description 3848 "Example configuration data resource"; 3850 leaf name { 3851 type string; 3852 description 3853 "The name of the playlist."; 3854 } 3855 leaf description { 3856 type string; 3857 description 3858 "A comment describing the playlist."; 3859 } 3860 list song { 3861 key index; 3862 ordered-by user; 3864 description 3865 "Example nested configuration data resource"; 3867 leaf index { // not really needed 3868 type uint32; 3869 description 3870 "An arbitrary integer index for this playlist song."; 3871 } 3872 leaf id { 3873 type leafref { 3874 path "/jbox:jukebox/jbox:library/jbox:artist/" + 3875 "jbox:album/jbox:song/jbox:name"; 3876 } 3877 mandatory true; 3878 description 3879 "Song identifier. Must identify an instance of 3880 /jukebox/library/artist/album/song/name."; 3881 } 3882 } 3883 } 3885 container player { 3886 description 3887 "Represents the jukebox player resource."; 3889 leaf gap { 3890 type decimal64 { 3891 fraction-digits 1; 3892 range "0.0 .. 2.0"; 3893 } 3894 units "tenths of seconds"; 3895 description "Time gap between each song"; 3896 } 3897 } 3898 } 3900 rpc play { 3901 description "Control function for the jukebox player"; 3902 input { 3903 leaf playlist { 3904 type string; 3905 mandatory true; 3906 description "playlist name"; 3907 } 3908 leaf song-number { 3909 type uint32; 3910 mandatory true; 3911 description "Song number in playlist to play"; 3912 } 3913 } 3914 } 3915 } 3917 Appendix D. RESTCONF Message Examples 3919 The examples within this document use the normative YANG module 3920 defined in Section 8 and the non-normative example YANG module 3921 defined in Appendix C.1. 3923 This section shows some typical RESTCONF message exchanges. 3925 D.1. Resource Retrieval Examples 3927 D.1.1. Retrieve the Top-level API Resource 3929 The client may start by retrieving the top-level API resource, using 3930 the entry point URI "{+restconf}". 3932 GET /restconf HTTP/1.1 3933 Host: example.com 3934 Accept: application/yang.api+json 3936 The server might respond as follows: 3938 HTTP/1.1 200 OK 3939 Date: Mon, 23 Apr 2012 17:01:00 GMT 3940 Server: example-server 3941 Content-Type: application/yang.api+json 3943 { 3944 "ietf-restconf:restconf": { 3945 "data" : [ null ], 3946 "operations" : { 3947 "play" : [ null ] 3948 } 3949 } 3950 } 3952 To request that the response content to be encoded in XML, the 3953 "Accept" header can be used, as in this example request: 3955 GET /restconf HTTP/1.1 3956 Host: example.com 3957 Accept: application/yang.api+xml 3959 The server will return the same response either way, which might be 3960 as follows : 3962 HTTP/1.1 200 OK 3963 Date: Mon, 23 Apr 2012 17:01:00 GMT 3964 Server: example-server 3965 Cache-Control: no-cache 3966 Pragma: no-cache 3967 Content-Type: application/yang.api+xml 3968 3969 3970 3971 3972 3973 3975 D.1.2. Retrieve The Server Module Information 3977 In this example the client is retrieving the modules information from 3978 the server in JSON format: 3980 GET /restconf/data/ietf-yang-library:modules HTTP/1.1 3981 Host: example.com 3982 Accept: application/yang.data+json 3984 The server might respond as follows. 3986 HTTP/1.1 200 OK 3987 Date: Mon, 23 Apr 2012 17:01:00 GMT 3988 Server: example-server 3989 Cache-Control: no-cache 3990 Pragma: no-cache 3991 Last-Modified: Sun, 22 Apr 2012 01:00:14 GMT 3992 Content-Type: application/yang.data+json 3994 { 3995 "ietf-yang-library:modules": { 3996 "module": [ 3997 { 3998 "name" : "foo", 3999 "revision" : "2012-01-02", 4000 "schema" : "https://example.com/mymodules/foo/2012-01-02", 4001 "namespace" : "http://example.com/ns/foo", 4002 "feature" : [ "feature1", "feature2" ], 4003 "conformance" : true 4004 }, 4005 { 4006 "name" : "foo-types", 4007 "revision" : "2012-01-05", 4008 "schema" : 4009 "https://example.com/mymodules/foo-types/2012-01-05", 4010 "schema" : [null], 4011 "namespace" : "http://example.com/ns/foo-types", 4012 "conformance" : false 4013 }, 4014 { 4015 "name" : "bar", 4016 "revision" : "2012-11-05", 4017 "schema" : "https://example.com/mymodules/bar/2012-11-05", 4018 "namespace" : "http://example.com/ns/bar", 4019 "feature" : [ "bar-ext" ], 4020 "conformance" : true, 4021 "submodule" : [ 4022 { 4023 "name" : "bar-submod1", 4024 "revision" : "2012-11-05", 4025 "schema" : 4026 "https://example.com/mymodules/bar-submod1/2012-11-05" 4027 }, 4028 { 4029 "name" : "bar-submod2", 4030 "revision" : "2012-11-05", 4031 "schema" : 4032 "https://example.com/mymodules/bar-submod2/2012-11-05" 4033 } 4034 ] 4035 } 4036 ] 4037 } 4038 } 4040 D.1.3. Retrieve The Server Capability Information 4042 In this example the client is retrieving the capability information 4043 from the server in JSON format, and the server supports all the 4044 RESTCONF query parameters, plus one vendor parameter: 4046 GET /restconf/data/ietf-restconf-monitoring:restconf-state/ 4047 capabilities HTTP/1.1 4048 Host: example.com 4049 Accept: application/yang.data+xml 4051 The server might respond as follows. The extra whitespace in 4052 'capability' elements for display purposes only. 4054 HTTP/1.1 200 OK 4055 Date: Mon, 23 Apr 2012 17:02:00 GMT 4056 Server: example-server 4057 Cache-Control: no-cache 4058 Pragma: no-cache 4059 Last-Modified: Sun, 22 Apr 2012 01:00:14 GMT 4060 Content-Type: application/yang.data+xml 4061 4062 4063 urn:ietf:params:restconf:capability:content:1.0 4064 4065 4066 urn:ietf:params:restconf:capability:depth:1.0 4067 4068 4069 urn:ietf:params:restconf:capability:fields:1.0 4070 4071 4072 urn:ietf:params:restconf:capability:filter:1.0 4073 4074 4075 urn:ietf:params:restconf:capability:point:1.0 4076 4077 4078 urn:ietf:params:restconf:capability:start-time:1.0 4079 4080 4081 urn:ietf:params:restconf:capability:stop-time:1.0 4082 4083 4084 http://example.com/capabilities/myparam 4085 4086 4088 D.2. Edit Resource Examples 4090 D.2.1. Create New Data Resources 4092 To create a new "artist" resource within the "library" resource, the 4093 client might send the following request. 4095 POST /restconf/data/example-jukebox:jukebox/library HTTP/1.1 4096 Host: example.com 4097 Content-Type: application/yang.data+json 4099 { 4100 "example-jukebox:artist" : { 4101 "name" : "Foo Fighters" 4102 } 4103 } 4105 If the resource is created, the server might respond as follows. 4106 Note that the "Location" header line is wrapped for display purposes 4107 only: 4109 HTTP/1.1 201 Created 4110 Date: Mon, 23 Apr 2012 17:02:00 GMT 4111 Server: example-server 4112 Location: https://example.com/restconf/data/ 4113 example-jukebox:jukebox/library/artist=Foo%20Fighters 4114 Last-Modified: Mon, 23 Apr 2012 17:02:00 GMT 4115 ETag: b3830f23a4c 4117 To create a new "album" resource for this artist within the "jukebox" 4118 resource, the client might send the following request. Note that the 4119 request URI header line is wrapped for display purposes only: 4121 POST /restconf/data/example-jukebox:jukebox/ 4122 library/artist=Foo%20Fighters HTTP/1.1 4123 Host: example.com 4124 Content-Type: application/yang.data+json 4126 { 4127 "example-jukebox:album" : { 4128 "name" : "Wasting Light", 4129 "genre" : "example-jukebox:alternative", 4130 "year" : 2012 # note this is the wrong date 4131 } 4132 } 4134 If the resource is created, the server might respond as follows. 4135 Note that the "Location" header line is wrapped for display purposes 4136 only: 4138 HTTP/1.1 201 Created 4139 Date: Mon, 23 Apr 2012 17:03:00 GMT 4140 Server: example-server 4141 Location: https://example.com/restconf/data/ 4142 example-jukebox:jukebox/library/artist=Foo%20Fighters/ 4143 album=Wasting%20Light 4144 Last-Modified: Mon, 23 Apr 2012 17:03:00 GMT 4145 ETag: b8389233a4c 4147 D.2.2. Detect Resource Entity Tag Change 4149 In this example, the server just supports the mandatory datastore 4150 last-changed timestamp. The client has previously retrieved the 4151 "Last-Modified" header and has some value cached to provide in the 4152 following request to patch an "album" list entry with key value 4153 "Wasting Light". Only the "year" field is being updated. 4155 PATCH /restconf/data/example-jukebox:jukebox/ 4156 library/artist=Foo%20Fighters/album=Wasting%20Light/year 4157 HTTP/1.1 4158 Host: example.com 4159 If-Unmodified-Since: Mon, 23 Apr 2012 17:01:00 GMT 4160 Content-Type: application/yang.data+json 4162 { "example-jukebox:year" : "2011" } 4164 In this example the datastore resource has changed since the time 4165 specified in the "If-Unmodified-Since" header. The server might 4166 respond: 4168 HTTP/1.1 412 Precondition Failed 4169 Date: Mon, 23 Apr 2012 19:01:00 GMT 4170 Server: example-server 4171 Last-Modified: Mon, 23 Apr 2012 17:45:00 GMT 4172 ETag: b34aed893a4c 4174 D.2.3. Edit a Datastore Resource 4176 In this example, the client modifies two different data nodes by 4177 sending a PATCH to the datastore resource: 4179 PATCH /restconf/data HTTP/1.1 4180 Host: example.com 4181 Content-Type: application/yang.datastore+xml 4183 4184 4185 4186 4187 Foo Fighters 4188 4189 Wasting Light 4190 2011 4191 4192 4193 4194 Nick Cave 4195 4196 Tender Prey 4197 1988 4198 4199 4200 4201 4202 4204 D.3. Query Parameter Examples 4206 D.3.1. "content" Parameter 4208 The "content" parameter is used to select the type of data child 4209 resources (configuration and/or not configuration) that are returned 4210 by the server for a GET method request. 4212 In this example, a simple YANG list that has configuration and non- 4213 configuration child resources. 4215 container events 4216 list event { 4217 key name; 4218 leaf name { type string; } 4219 leaf description { type string; } 4220 leaf event-count { 4221 type uint32; 4222 config false; 4223 } 4224 } 4225 } 4227 Example 1: content=all 4229 To retrieve all the child resources, the "content" parameter is set 4230 to "all". The client might send: 4232 GET /restconf/data/example-events:events?content=all 4233 HTTP/1.1 4234 Host: example.com 4235 Accept: application/yang.data+json 4237 The server might respond: 4239 HTTP/1.1 200 OK 4240 Date: Mon, 23 Apr 2012 17:11:30 GMT 4241 Server: example-server 4242 Cache-Control: no-cache 4243 Pragma: no-cache 4244 Content-Type: application/yang.data+json 4246 { 4247 "example-events:events" : { 4248 "event" : [ 4249 { 4250 "name" : "interface-up", 4251 "description" : "Interface up notification count", 4252 "event-count" : 42 4253 }, 4254 { 4255 "name" : "interface-down", 4256 "description" : "Interface down notification count", 4257 "event-count" : 4 4258 } 4259 ] 4260 } 4261 } 4263 Example 2: content=config 4265 To retrieve only the configuration child resources, the "content" 4266 parameter is set to "config" or omitted since this is the default 4267 value. Note that the "ETag" and "Last-Modified" headers are only 4268 returned if the content parameter value is "config". 4270 GET /restconf/data/example-events:events?content=config 4271 HTTP/1.1 4272 Host: example.com 4273 Accept: application/yang.data+json 4275 The server might respond: 4277 HTTP/1.1 200 OK 4278 Date: Mon, 23 Apr 2012 17:11:30 GMT 4279 Server: example-server 4280 Last-Modified: Mon, 23 Apr 2012 13:01:20 GMT 4281 ETag: eeeada438af 4282 Cache-Control: no-cache 4283 Pragma: no-cache 4284 Content-Type: application/yang.data+json 4286 { 4287 "example-events:events" : { 4288 "event" : [ 4289 { 4290 "name" : "interface-up", 4291 "description" : "Interface up notification count" 4292 }, 4293 { 4294 "name" : "interface-down", 4295 "description" : "Interface down notification count" 4296 } 4297 ] 4298 } 4299 } 4301 Example 3: content=nonconfig 4303 To retrieve only the non-configuration child resources, the "content" 4304 parameter is set to "nonconfig". Note that configuration ancestors 4305 (if any) and list key leafs (if any) are also returned. The client 4306 might send: 4308 GET /restconf/data/example-events:events?content=nonconfig 4309 HTTP/1.1 4310 Host: example.com 4311 Accept: application/yang.data+json 4313 The server might respond: 4315 HTTP/1.1 200 OK 4316 Date: Mon, 23 Apr 2012 17:11:30 GMT 4317 Server: example-server 4318 Cache-Control: no-cache 4319 Pragma: no-cache 4320 Content-Type: application/yang.data+json 4322 { 4323 "example-events:events" : { 4324 "event" : [ 4325 { 4326 "name" : "interface-up", 4327 "event-count" : 42 4328 }, 4329 { 4330 "name" : "interface-down", 4331 "event-count" : 4 4332 } 4333 ] 4334 } 4335 } 4337 D.3.2. "depth" Parameter 4339 The "depth" parameter is used to limit the number of levels of child 4340 resources that are returned by the server for a GET method request. 4342 The depth parameter starts counting levels at the level of the target 4343 resource that is specified, so that a depth level of "1" includes 4344 just the target resource level itself. A depth level of "2" includes 4345 the target resource level and its child nodes. 4347 This example shows how different values of the "depth" parameter 4348 would affect the reply content for retrieval of the top-level 4349 "jukebox" data resource. 4351 Example 1: depth=unbounded 4353 To retrieve all the child resources, the "depth" parameter is not 4354 present or set to the default value "unbounded". Note that some 4355 strings are wrapped for display purposes only. 4357 GET /restconf/data/example-jukebox:jukebox?depth=unbounded 4358 HTTP/1.1 4359 Host: example.com 4360 Accept: application/yang.data+json 4362 The server might respond: 4364 HTTP/1.1 200 OK 4365 Date: Mon, 23 Apr 2012 17:11:30 GMT 4366 Server: example-server 4367 Cache-Control: no-cache 4368 Pragma: no-cache 4369 Content-Type: application/yang.data+json 4371 { 4372 "example-jukebox:jukebox" : { 4373 "library" : { 4374 "artist" : [ 4375 { 4376 "name" : "Foo Fighters", 4377 "album" : [ 4378 { 4379 "name" : "Wasting Light", 4380 "genre" : "example-jukebox:alternative", 4381 "year" : 2011, 4382 "song" : [ 4383 { 4384 "name" : "Wasting Light", 4385 "location" : 4386 "/media/foo/a7/wasting-light.mp3", 4387 "format" : "MP3", 4388 "length" " 286 4389 }, 4390 { 4391 "name" : "Rope", 4392 "location" : "/media/foo/a7/rope.mp3", 4393 "format" : "MP3", 4394 "length" " 259 4395 } 4396 ] 4397 } 4398 ] 4399 } 4400 ] 4401 }, 4402 "playlist" : [ 4403 { 4404 "name" : "Foo-One", 4405 "description" : "example playlist 1", 4406 "song" : [ 4407 { 4408 "index" : 1, 4409 "id" : "https://example.com/restconf/data/ 4410 example-jukebox:jukebox/library/artist= 4411 Foo%20Fighters/album/Wasting%20Light/ 4412 song/Rope" 4413 }, 4414 { 4415 "index" : 2, 4416 "id" : "https://example.com/restconf/data/ 4417 example-jukebox:jukebox/library/artist= 4418 Foo%20Fighters/album/Wasting%20Light/song/ 4419 Bridge%20Burning" 4420 } 4421 ] 4422 } 4423 ], 4424 "player" : { 4425 "gap" : 0.5 4426 } 4427 } 4428 } 4430 Example 2: depth=1 4432 To determine if 1 or more resource instances exist for a given target 4433 resource, the value "1" is used. 4435 GET /restconf/data/example-jukebox:jukebox?depth=1 HTTP/1.1 4436 Host: example.com 4437 Accept: application/yang.data+json 4439 The server might respond: 4441 HTTP/1.1 200 OK 4442 Date: Mon, 23 Apr 2012 17:11:30 GMT 4443 Server: example-server 4444 Cache-Control: no-cache 4445 Pragma: no-cache 4446 Content-Type: application/yang.data+json 4448 { 4449 "example-jukebox:jukebox" : [null] 4450 } 4452 Example 3: depth=3 4454 To limit the depth level to the target resource plus 2 child resource 4455 layers the value "3" is used. 4457 GET /restconf/data/example-jukebox:jukebox?depth=3 HTTP/1.1 4458 Host: example.com 4459 Accept: application/yang.data+json 4461 The server might respond: 4463 HTTP/1.1 200 OK 4464 Date: Mon, 23 Apr 2012 17:11:30 GMT 4465 Server: example-server 4466 Cache-Control: no-cache 4467 Pragma: no-cache 4468 Content-Type: application/yang.data+json 4470 { 4471 "example-jukebox:jukebox" : { 4472 "library" : { 4473 "artist" : [ null ] 4474 }, 4475 "playlist" : [ 4476 { 4477 "name" : "Foo-One", 4478 "description" : "example playlist 1", 4479 "song" : [ null ] 4480 } 4481 ], 4482 "player" : { 4483 "gap" : 0.5 4484 } 4485 } 4486 } 4488 D.3.3. "fields" Parameter 4490 In this example the client is retrieving the API resource, but 4491 retrieving only the "name" and "revision" nodes from each module, in 4492 JSON format: 4494 GET /restconf/data?fields=modules/module(name;revision) HTTP/1.1 4495 Host: example.com 4496 Accept: application/yang.data+json 4498 The server might respond as follows. 4500 HTTP/1.1 200 OK 4501 Date: Mon, 23 Apr 2012 17:01:00 GMT 4502 Server: example-server 4503 Content-Type: application/yang.data+json 4505 { 4506 "ietf-yang-library:modules": { 4507 "module": [ 4508 { 4509 "name" : "example-jukebox", 4510 "revision" : "2015-06-04" 4511 }, 4512 { 4513 "name" : "ietf-inet-types", 4514 "revision" : "2013-07-15" 4515 }, 4516 { 4517 "name" : "ietf-restconf-monitoring", 4518 "revision" : "2015-06-04" 4519 }, 4520 { 4521 "name" : "ietf-yang-library", 4522 "revision" : "2015-01-30" 4523 }, 4524 { 4525 "name" : "ietf-yang-types", 4526 "revision" : "2013-07-15" 4527 } 4529 ] 4530 } 4531 } 4533 D.3.4. "insert" Parameter 4535 In this example, a new first entry in the "Foo-One" playlist is being 4536 created. 4538 Request from client: 4540 POST /restconf/data/example-jukebox:jukebox/ 4541 playlist=Foo-One?insert=first HTTP/1.1 4542 Host: example.com 4543 Content-Type: application/yang.data+json 4545 { 4546 "example-jukebox:song" : { 4547 "index" : 1, 4548 "id" : "/example-jukebox:jukebox/library/ 4549 artist=Foo%20Fighters/album/Wasting%20Light/song/Rope" 4550 } 4551 } 4553 Response from server: 4555 HTTP/1.1 201 Created 4556 Date: Mon, 23 Apr 2012 13:01:20 GMT 4557 Server: example-server 4558 Last-Modified: Mon, 23 Apr 2012 13:01:20 GMT 4559 Location: https://example.com/restconf/data/ 4560 example-jukebox:jukebox/playlist=Foo-One/song=1 4561 ETag: eeeada438af 4563 D.3.5. "point" Parameter 4565 In this example, the client is inserting a new "song" resource within 4566 an "album" resource after another song. The request URI is split for 4567 display purposes only. 4569 Request from client: 4571 POST /restconf/data/example-jukebox:jukebox/ 4572 library/artist=Foo%20Fighters/album/Wasting%20Light? 4573 insert=after&point=%2Fexample-jukebox%3Ajukebox%2F 4574 library%2Fartist%2FFoo%20Fighters%2Falbum%2F 4575 Wasting%20Light%2Fsong%2FBridge%20Burning HTTP/1.1 4576 Host: example.com 4577 Content-Type: application/yang.data+json 4579 { 4580 "example-jukebox:song" : { 4581 "name" : "Rope", 4582 "location" : "/media/foo/a7/rope.mp3", 4583 "format" : "MP3", 4584 "length" : 259 4585 } 4586 } 4588 Response from server: 4590 HTTP/1.1 204 No Content 4592 1. Date: Mon, 23 Apr 2012 13:01:20 GMT Server: example-server Last- 4593 Modified: Mon, 23 Apr 2012 13:01:20 GMT ETag: abcada438af 4595 D.3.6. "filter" Parameter 4597 The following URIs show some examples of notification filter 4598 specifications (lines wrapped for display purposes only): 4600 // filter = /event/event-class='fault' 4601 GET /mystreams/NETCONF?filter=%2Fevent%2Fevent-class%3D'fault' 4603 // filter = /event/severity<=4 4604 GET /mystreams/NETCONF?filter=%2Fevent%2Fseverity%3C%3D4 4606 // filter = /linkUp|/linkDown 4607 GET /mystreams/SNMP?filter=%2FlinkUp%7C%2FlinkDown 4609 // filter = /*/reporting-entity/card!='Ethernet0' 4610 GET /mystreams/NETCONF? 4611 filter=%2F*%2Freporting-entity%2Fcard%21%3D'Ethernet0' 4613 // filter = /*/email-addr[contains(.,'company.com')] 4614 GET /mystreams/critical-syslog? 4615 filter=%2F*%2Femail-addr[contains(.%2C'company.com')] 4617 // Note: the module name is used as prefix. 4618 // filter = (/example-mod:event1/name='joe' and 4619 // /example-mod:event1/status='online') 4620 GET /mystreams/NETCONF? 4621 filter=(%2Fexample-mod%3Aevent1%2Fname%3D'joe'%20and 4622 %20%2Fexample-mod%3Aevent1%2Fstatus%3D'online') 4624 D.3.7. "start-time" Parameter 4626 // start-time = 2014-10-25T10:02:00Z 4627 GET /mystreams/NETCONF?start-time=2014-10-25T10%3A02%3A00Z 4629 D.3.8. "stop-time" Parameter 4631 // stop-time = 2014-10-25T12:31:00Z 4632 GET /mystreams/NETCONF?stop-time=2014-10-25T12%3A31%3A00Z 4634 D.3.9. "with-defaults" Parameter 4636 Assume the same data model as defined in Appendix A.1 of [RFC6243]. 4637 Assume the same data set as defined in Appendix A.2 of [RFC6243]. If 4638 the server defaults-uri basic-mode is "trim", the the following 4639 request for interface "eth1" might be as follows: 4641 Without query parameter: 4643 GET /restconf/data/interfaces/interface=eth1 HTTP/1.1 4644 Host: example.com 4645 Accept: application/yang.data+json 4647 The server might respond as follows. 4649 HTTP/1.1 200 OK 4650 Date: Mon, 23 Apr 2012 17:01:00 GMT 4651 Server: example-server 4652 Content-Type: application/yang.data+json 4654 { 4655 "example:interface": [ 4656 { 4657 "name" : "eth1", 4658 "status" : "up" 4659 } 4660 ] 4661 } 4663 Note that the "mtu" leaf is missing because it is set to the default 4664 "1500", and the server defaults handling basic-mode is "trim". 4666 With query parameter: 4668 GET /restconf/data/interfaces/interface=eth1 4669 ?with-defaults=report-all HTTP/1.1 4670 Host: example.com 4671 Accept: application/yang.data+json 4673 The server might respond as follows. 4675 HTTP/1.1 200 OK 4676 Date: Mon, 23 Apr 2012 17:01:00 GMT 4677 Server: example-server 4678 Content-Type: application/yang.data+json 4680 { 4681 "example:interface": [ 4682 { 4683 "name" : "eth1", 4684 "mtu" : 1500, 4685 "status" : "up" 4686 } 4687 ] 4688 } 4690 Note that the server returns the "mtu" leaf because the "report-all" 4691 mode was requested with the "with-defaults" query parameter. 4693 Authors' Addresses 4695 Andy Bierman 4696 YumaWorks 4698 Email: andy@yumaworks.com 4700 Martin Bjorklund 4701 Tail-f Systems 4703 Email: mbj@tail-f.com 4705 Kent Watsen 4706 Juniper Networks 4708 Email: kwatsen@juniper.net