1

It is clear to me how to refer to a list item (restconf draft) but it is not clear how to refer to a specific leaf-list entry. For example, given the following definition:

module x { 
   container y { 
     leaf-list z;
   }
}

and if I have the following data in the system

<y>
  <z>a</z>
  <z>b</z>
  <z>d</z>
</y>

how do I insert a c in the third position ?

Restconf has the 'insert' and 'point' that takes the resource uri. But, what is the resource uri to identify a leaf-list item ? If I want to refer to the second entry, is the following valid ?

/y/z=b
predi
  • 5,528
  • 32
  • 60
user19937
  • 587
  • 1
  • 7
  • 25

1 Answers1

1

Each leaf-list entry is a separate data resource in restconf-draft-10.

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

This is what Section 3.5 says about leaf-list entries. Further it defines encoding of leaf-list Data Resource Identifiers in 5.3.1:

If a data node in the path expression is a YANG leaf-list node, then the leaf-list value MUST be encoded according to the following rules:

o The instance-identifier for the leaf-list MUST be encoded using one path segment [RFC3986].

o The path segment is constructed by having the leaf-list name, followed by an "=" character, followed by the leaf-list value. (e.g., /restconf/data/top-leaflist=fred).

So, your example for second entry it would be: /restconf/data/x:y/z=b.

As for inserting, it seems to be unclear. There are examples in the appendix D of the draft for both point and insert, but use a list instead of a leaf-list (note that both MUST be ordered-by user in order for the two parameters to be valid in a request).

D.3.5. "point" Parameter

  POST /restconf/data/example-jukebox:jukebox/
      library/artist=Foo%20Fighters/album=Wasting%20Light?
      insert=after&point=%2Fexample-jukebox%3Ajukebox%2F
      library%2Fartist%3DFoo%20Fighters%2Falbum%3D
      Wasting%20Light%2Fsong%3DBridge%20Burning   HTTP/1.1
  Host: example.com
  Content-Type: application/yang.data+json

  {
    "example-jukebox:song" : {
      "name" : "Rope",
      "location" : "/media/foo/a7/rope.mp3",
      "format" : "MP3",
      "length" : 259
    }
  }
Community
  • 1
  • 1
predi
  • 5,528
  • 32
  • 60
  • How can i access both z.a and z.b, I tried using comma but it throws error as "unsupported uri format - number of values differs from number of keys" – user3516540 Oct 30 '20 at 09:39