|
| 1 | +# Feature Name |
| 2 | +YANG Patch Media Type |
| 3 | +# High Level Requirements Document |
| 4 | +#### Rev 0.1 |
| 5 | + |
| 6 | +# Table of Contents |
| 7 | + * [List of Tables](#list-of-tables) |
| 8 | + * [Revision](#revision) |
| 9 | + * [About This Manual](#about-this-manual) |
| 10 | + * [Scope](#scope) |
| 11 | + * [Feature Overview](#feature-overview) |
| 12 | + * [Requirements](#requirements) |
| 13 | + * [Limitations](#limitations) |
| 14 | + * [Example](#example) |
| 15 | + |
| 16 | +# Revision |
| 17 | +| Rev | Date | Author | Change Description | |
| 18 | +|:---:|:-----------:|:------------------:|-----------------------------------| |
| 19 | +| 0.1 | 04/23/2021 | Mohammed Faraaz | Initial version | |
| 20 | + |
| 21 | +# About this Manual |
| 22 | +This document provides general information about the YANG Patch Media Type feature implementation in SONiC mgmt-framework's RESTCONF server. |
| 23 | +# Scope |
| 24 | +This document describes the high level design of YANG Patch Media Type feature. Describing RESTCONF and other related information are beyond the scope of this document. |
| 25 | + |
| 26 | +# Feature Overview |
| 27 | +A "YANG Patch" is an ordered list of edits that are applied to the target configuration datastore by the RESTCONF server. |
| 28 | +The YANG Patch operation is invoked by the RESTCONF client by sending a PATCH method request with a representation using |
| 29 | +"application/yang-patch+json". The message-body representing the YANG Patch input parameters MUST be present. |
| 30 | + |
| 31 | +## Requirements |
| 32 | + |
| 33 | +### Functional Requirements |
| 34 | + |
| 35 | +1. The RESTCONF server should implement the "YANG PATCH" feature as described in the [RFC8072](https://tools.ietf.org/html/rfc8072) |
| 36 | +2. The RESTCONF server should allow multiple sub-resources to be edited within the same PATCH method. |
| 37 | +3. The RESTCONF server should allow a more precise edit operation than the "plain patch" mechanism found in [RFC8040](https://tools.ietf.org/html/rfc8040). i.e. edits operations can be heterogenuous. |
| 38 | +4. The RESTCONF server should support "create", "delete", "merge", "replace", and "remove" operations. |
| 39 | +5. The RESTCONF server should process "edits" in the explicit order. i.e. The edits are processed in client-specified order. |
| 40 | +6. The RESTCONF server should process errors precisely even when multiple errors occur in the same YANG Patch request. |
| 41 | +7. The YANG Patch request should be an atomic operation. i.e. All the edits must be succeded, otherwise an error will be thrown. |
| 42 | +8. The RESTCONF server should log the YANG Patch's "patch-id" in the audit-log, this is useful for debugging. |
| 43 | +9. The RESTCONF server MUST return the "Accept-Patch" header field in an OPTIONS response, as specified in [RFC5789], which includes the media type for YANG Patch. This is needed by a client to determine the message-encoding formats supported by the server (e.g., XML, JSON, or both). |
| 44 | + The following is an example of an "Accept-Patch" header: |
| 45 | + Accept-Patch: application/yang-patch+json |
| 46 | + |
| 47 | +# Limitations |
| 48 | + |
| 49 | +1. Does not support “insert” and “move” operations because SONiC does not support order by user. |
| 50 | +2. Does not support YANG patch for data store resource i.e. The target resource cannot be '/' (top-level). |
| 51 | + |
| 52 | +# Example |
| 53 | + |
| 54 | +``` |
| 55 | + The following example shows several songs being added to an existing |
| 56 | + album. |
| 57 | +
|
| 58 | + o Each of two edits contains one song. |
| 59 | +
|
| 60 | + o Both edits succeed, and new sub-resources are created. |
| 61 | +
|
| 62 | + Request from the RESTCONF client: |
| 63 | +
|
| 64 | + PATCH /restconf/data/example-jukebox:jukebox/\ |
| 65 | + library/artist=Foo%20Fighters/album=Wasting%20Light \ |
| 66 | + HTTP/1.1 |
| 67 | + Host: example.com |
| 68 | + Accept: application/yang-data+json |
| 69 | + Content-Type: application/yang-patch+json |
| 70 | +
|
| 71 | + { |
| 72 | + "ietf-yang-patch:yang-patch" : { |
| 73 | + "patch-id" : "add-songs-patch-2", |
| 74 | + "edit" : [ |
| 75 | + { |
| 76 | + "edit-id" : "edit1", |
| 77 | + "operation" : "create", |
| 78 | + "target" : "/song=Rope", |
| 79 | + "value" : { |
| 80 | + "song" : [ |
| 81 | + { |
| 82 | + "name" : "Rope", |
| 83 | + "location" : "/media/rope.mp3", |
| 84 | + "format" : "MP3", |
| 85 | + "length" : 259 |
| 86 | + } |
| 87 | + ] |
| 88 | + } |
| 89 | + }, |
| 90 | + { |
| 91 | + "edit-id" : "edit2", |
| 92 | + "operation" : "create", |
| 93 | + "target" : "/song=Dear%20Rosemary", |
| 94 | + "value" : { |
| 95 | + "song" : [ |
| 96 | + { |
| 97 | + "name" : "Dear Rosemary", |
| 98 | + "location" : "/media/dear_rosemary.mp3", |
| 99 | + "format" : "MP3", |
| 100 | + "length" : 269 |
| 101 | + } |
| 102 | + ] |
| 103 | + } |
| 104 | + } |
| 105 | + ] |
| 106 | + } |
| 107 | + } |
| 108 | +
|
| 109 | + Response from the RESTCONF server: |
| 110 | +
|
| 111 | + HTTP/1.1 200 OK |
| 112 | + Date: Thu, 26 Jan 2017 20:56:30 GMT |
| 113 | + Server: example-server |
| 114 | + Last-Modified: Thu, 26 Jan 2017 20:56:30 GMT |
| 115 | + Content-Type: application/yang-data+json |
| 116 | +
|
| 117 | + { |
| 118 | + "ietf-yang-patch:yang-patch-status" : { |
| 119 | + "patch-id" : "add-songs-patch-2", |
| 120 | + "ok" : [null] |
| 121 | + } |
| 122 | + } |
| 123 | +``` |
| 124 | + |
0 commit comments