简体   繁体   English

使用 yang restconf 访问特定的叶列表条目

[英]accessing a specific leaf-list entry using yang restconf

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 .我很清楚如何引用list项(restconf 草案),但不清楚如何引用特定的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 ?如何在第三个位置插入一个c

Restconf has the 'insert' and 'point' that takes the resource uri. Restconf 具有获取资源 uri 的“插入”和“点”。 But, what is the resource uri to identify a leaf-list item ?但是,识别叶列表项的资源 uri 是什么? If I want to refer to the second entry, is the following valid ?如果我想参考第二个条目,以下是否有效?

/y/z=b

Each leaf-list entry is a separate data resource in restconf-draft-10.每个叶列表条目都是 restconf-draft-10 中的一个单独的数据资源。

Containers, leafs, leaf-list entries, list entries, anydata and anyxml nodes are data resources.容器、叶子、叶子列表条目、列表条目、anydata 和 anyxml 节点都是数据资源。

This is what Section 3.5 says about leaf-list entries.这就是第 3.5节关于leaf-list条目的内容。 Further it defines encoding of leaf-list Data Resource Identifiers in 5.3.1:此外,它在 5.3.1 中定义了leaf-list数据资源标识符的编码:

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:如果路径表达式中的数据节点是 YANG 叶列表节点,则必须根据以下规则对叶列表值进行编码:

o The instance-identifier for the leaf-list MUST be encoded using one path segment [RFC3986]. o 叶列表的实例标识符必须使用一个路径段 [RFC3986] 进行编码。

o The path segment is constructed by having the leaf-list name, followed by an "=" character, followed by the leaf-list value. o 路径段由叶列表名称、“=”字符和叶列表值构成。 (eg, /restconf/data/top-leaflist=fred). (例如,/restconf/data/top-leaflist=fred)。

So, your example for second entry it would be: /restconf/data/x:y/z=b .所以,你的第二个条目的例子是: /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 中有关于pointinsert示例,但使用list而不是leaf-list (请注意,两者都必须ordered-by user ,以便两个参数在请求中有效)。

D.3.5. 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
    }
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM