The RESTCONF uses the HTTP PATCH method defined in to provide an extensible framework for resource patching mechanisms. Each patch mechanism needs a unique media type.


If the target resource instance does not exist, the server MUST NOT create it.

If the PATCH request succeeds, a "200 OK" status-line is returned if there is a message-body, and "204 No Content" is returned if no response message-body is sent.

If the user is not authorized to alter the target resource, an error response containing a "403 Forbidden" status-line will be returned. A server MAY return a "404 Not Found" status-line. The error-tag value "invalid-value" is used in this case.


Plain Patch


The plain patch mechanism merges the contents of the message-body with the target resource. The message-body for a plain patch MUST be present and MUST be represented by the media type "application/yang-data+xml" or "application/yang-data+json".

Plain patch can be used to create or update, but not delete, a child resource within the target resource. If the target resource represents a YANG leaf-list, then the PATCH method MUST NOT change the value of the leaf-list instance.


If the target resource represents a YANG list instance, then the key leaf values, in message-body representation, MUST be the same as the key leaf values in the request URI. The PATCH method MUST NOT be used to change the key leaf values for a data resource instance.

After the plain patch is processed by the server, a response will be returned to the client.

Example:

To replace just the "year" field in the "album" resource (instead of replacing the entire resource with the PUT method), the client might send a plain patch as follows:


      PATCH /restconf/data/example-jukebox:jukebox/\
          library/artist=Foo%20Fighters/album=Wasting%20Light HTTP/1.1
      Host: example.com
      If-Match: "b8389233a4c"
      Content-Type: application/yang-data+xml

      <album xmlns="http://example.com/ns/example-jukebox">
       <year>2011</year>
      </album>


If the field is updated, the server might respond as follows:

      HTTP/1.1 204 No Content
      Date: Thu, 26 Jan 2017 20:56:30 GMT
      Server: example-server
      Last-Modified: Thu, 26 Jan 2017 20:56:30 GMT
      ETag: "b2788923da4c"


Please see [YANG-Patch] for an alternate media type supporting the ability to delete child resources. The YANG Patch media type allows multiple sub-operations (e.g., "merge", "delete") within a single PATCH method.


For more details refer to RESTCONF [RFC8040]