Is it legal to POST/PUT/PATCH list and leaf-list in RESTCONF?

♀尐吖头ヾ 提交于 2019-12-11 05:24:26

问题


This is a follow-up question of this post. From @predi's answer I know that it is legal to GET a URL whose target resource is a list or leaf-list and DELETE can't use such URL. That is to say, given the following YANG definitions:

list machine {
    key "name";
        leaf "name" {
        type string;
    }
} 

The request GET /restconf/data/test/machine is legal. The request DELETE /restconf/data/test/machine is illegal.

I want to confirm if other methods like POST, PUT or PATCH can use list or leaf-list as URL target resource in requests. For example, are below requests legal in RESTCONF?

POST   /restconf/data/test/machine
PUT    /restconf/data/test/machine
PATCH  /restconf/data/test/machine

Currently I think the POST and PUT requests are illegal and not sure about the PATCH request.

Here are my reasons:

From 3.5:

Containers, leafs, leaf-list entries, list entries, anydata nodes, and anyxml nodes are data resources.

So a leaf-list or list is not a data resource. Only a leaf-list entry or list entry is a data resource.

From 4.4:

The POST method is sent by the client to create a data resource or invoke an operation resource. The server uses the target resource type to determine how to process the request.

  +-----------+------------------------------------------------+
  | Type      | Description                                    |
  +-----------+------------------------------------------------+
  | Datastore | Create a top-level configuration data resource |
  | Data      | Create a configuration data child resource     |
  | Operation | Invoke an RPC operation                        |
  +-----------+------------------------------------------------+

                 Resource Types That Support POST

So the listed target resource type is DATA, a data resource.

From 4.5:

The PUT method is sent by the client to create or replace the target data resource.

I haven't found similar descriptions in the PATCH section. The PATCH section just talks about target resource, not target data resource or data resource.

But ther are also ambiguous words in PUT and PATCH sections:

If the target resource represents a YANG leaf-list, then the PUT method MUST NOT change the value of the leaf-list instance.

If the target resource represents a YANG leaf-list, then the PATCH method MUST NOT change the value of the leaf-list instance.

It seems that the target resource can represent a leaf-list, but later it says "MUST NOT change the value of the leaf-list instance". If using a leaf-list as the target resouce, a PUT or PATCH must not change which leaf-list instance?

Given this:

leaf-list names {
    type string;
}

and the JSON encoded instances:

names: ["a", "b", "c"]

There are three leaf-list instances: a, b and c. If using:

PUT .../names

then you can only create or replace the whole leaf-list, how can you MUST NOT change the value of the leaf-list instance?

Thanks,

来源:https://stackoverflow.com/questions/56174498/is-it-legal-to-post-put-patch-list-and-leaf-list-in-restconf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!