Subject: Re: [netconf] FW: [netmod] CRUD operations on Leaf-list in RFC8040

From: Qin Wu <[email-masked]>
Date: Thu, 26 Sep 2019 01:26:59 +0000

Andy:
It is not clear to me how YANG Patch operation on leaf-list is different from what RFC8040 is doing.
Similar to RFC8040, YANG example described in RFC8072 appendix is using "example-jukebox" YANG module
With "artist" list, "album" list, "song" list, "playlist" list instead of any leaf-list node

Can you provide an YANG patch example which allows CRUD operations on multiple leaf-list instances?

By reading Section 4.3 of RFC8040
“
More than one element MUST NOT be
   returned for XML encoding.  If multiple elements are sent in a JSON
   message-body, then they MUST be sent as a JSON array.
”
It looks to me XML encoding restricts only one element or leaf-list instance can be returned but JSON encoding has no such limitation.
I am wondering whether YANG patch in RFC8072 has similar issue when we select between XML encoding and JSON encoding.

-Qin
发件人: Andy Bierman [mailto:[email-masked]]
发送时间: 2019年9月25日 23:01
收件人: Qin Wu <[email-masked]>
抄送: netconf <[email-masked]>
主题: Re: [netconf] FW: [netmod] CRUD operations on Leaf-list in RFC8040

Hi,

The RESTCONF target resource has to be one resource.
The WG added YANG Patch (RFC 8072) to do more complex editing operations.

Andy

On Wed, Sep 25, 2019 at 7:57 AM Qin Wu <[email-masked]<mailto:[email-masked]>> wrote:

Send to netconf for discussion in the right place,thank Jurgen for kindly reminder.

发件人： Qin Wu<[email-masked]<mailto:[email-masked]>>
收件人： netmod<[email-masked]<mailto:[email-masked]>>
抄送： Zengjuan<[email-masked]<mailto:[email-masked]>>
主题： [netmod] CRUD operations on Leaf-list in RFC8040
时间： 2019-09-25 19:55:12

Hi, All:
During implementing RFC8040, we face a few problems related to leaf-list usage.
I am wondering how do we create multiple instance of leaf-list data resource?
Suppose we have example-foo.yang model as follows:
example-top.yang

   container top {
    list list1 {
        key "key1 key2 key3";
         ...
         list list2 {
             key "key4 key5";
             ...
             leaf X { type string; }
         }
     }
     leaf-list Y {
       type uint32;
     }
}
To create a new "Y" resource within the "top" resource, can we make
the client send the following request:
POST /restconf/data/example-top:top HTTP/1.1
Host: example.com<http://example.com>
Content-Type: application/yang-data+json

{
  "example-top:Y" : [value1,value2]
}

response：
HTTP/1.1 201 Created
Date: Thu, 26 Jan 2017 20:56:30 GMT
Server: example-server
Location: https://example.com/restconf/data/example-top:top/Y=value1&value2
Last-Modified: Thu, 26 Jan 2017 20:56:30 GMT
ETag: "b3830f23a4c"

Also I don’t understand why we add limitation to PUT method and plain patch method on leaf-list and don’t allow
The value of leaf-list instance to be changed by these two methods
see section 4.5 and section 4.6.1
“
4.5.  PUT
   If the target resource represents a YANG leaf-list, then the PUT
   method MUST NOT change the value of the leaf-list instance.
4.6.1..  Plain Patch
   If the target resource represents a YANG leaf-list, then the PATCH
   method MUST NOT change the value of the leaf-list instance.
“
Suppose I want to delete all leaf-list instance values associated with leaf-list "Y",
Can I send the following request:
DELETE /restconf/data/example-top:top/Y  HTTP/1.1
Host: example.com<http://example.com>

Quoted section 4.7:
“
4.7.  DELETE
   If the target resource represents a configuration leaf-list or list
   data node, then it MUST represent a single YANG leaf-list or list
   instance.  The server MUST NOT use the DELETE method to delete more
   than one such instance.
”
It seems obvious that DELETE method can not delete more than one instances. But I don’t know why?

Also I don’t know we add constraint on XML encoding in the Get request, only allow one single element be
returned for XML encoding, see section 4.3 of RFC8040 as follows:
“
4.3.  GET
   If a retrieval request for a data resource representing a YANG
   leaf-list or list object identifies more than one instance and XML
   encoding is used in the response, then an error response containing a
   "400 Bad Request" status-line MUST be returned by the server.
“
Suppose I want to retrieve/delete/modify multiple leaf-list instance data resource, can I wrap leaf-list "Y" within container "top",
create/delete/modify container "top" data resource?
“
Comments?

-Qin

_______________________________________________
netconf mailing list
[email-masked]<mailto:[email-masked]>
https://www.ietf.org/mailman/listinfo/netconf

---

From: Andy Bierman <[email-masked]>
Date: Wed, 25 Sep 2019 20:58:34 -0700

> multiple leaf-list instances?

no (I don't have time) but you would have an "edit" list entry for each
leaf-list instance

Andy

> It looks to me XML encoding restricts only one element or leaf-list
> instance can be returned but JSON encoding has no such limitation.
>
> I am wondering whether YANG patch in RFC8072 has similar issue when we
> select between XML encoding and JSON encoding.
>
>
>
> -Qin
>
> *发件人:* Andy Bierman [mailto:[email-masked]]
> *发送时间:* 2019年9月25日 23:01
> *收件人:* Qin Wu <[email-masked]>
> *抄送:* netconf <[email-masked]>
> *主题:* Re: [netconf] FW: [netmod] CRUD operations on Leaf-list in RFC8040
>
>
>
> Hi,
>
>
>
> On Wed, Sep 25, 2019 at 7:57 AM Qin Wu <[email-masked]> wrote:
>
>
> *发件人： *Qin Wu<[email-masked]>
>
> *收件人： *netmod<[email-masked]>
>
> *抄送： *Zengjuan<[email-masked]>
>
> *主题： *[netmod] CRUD operations on Leaf-list in RFC8040
>
> *时间： *2019-09-25 19:55:12
>
>
>
> Hi, All:
>
> Host: example.com
> Location:
> https://example.com/restconf/data/example-top:top/Y=value1&value2
>
> Also I don’t understand why we add limitation to PUT method and plain
> patch method on leaf-list and don’t allow
>
> Host: example.com
> Suppose I want to retrieve/delete/modify multiple leaf-list instance data
> resource, can I wrap leaf-list "Y" within container "top",
>
> [email-masked]