[英]Accessing Individual leaf in leaf in list of yang
I want to access value of leaf of list in yang module? 我想在yang模块中访问列表叶的值? Ex
防爆
module abc
{
list xyz{
key a;
leaf a{
type int
},
leaf b{
type string
},
leaf c{
type string
},
leaf d{
type string
}
}
}
REST should be like "abc/xyz/(which is key)" ie (abc/xyz/1) REST应该像“ abc / xyz /(这是关键)”,即(abc / xyz / 1)
it will give all values of a,b,c,d. 它将给出a,b,c,d的所有值。
But if I want to access of individual element b,c,d individual which is non key. 但是,如果我想访问单个元素b,c,d,这不是关键。 How can we write REST API?
我们如何编写REST API?
This is explained in RFC8040, Section 3.5.3 . RFC8040第3.5.3节对此进行了说明。 Here's the example from this section:
这是本节中的示例:
Examples:
例子:
container top { list list1 { key "key1 key2 key3"; ... list list2 { key "key4 key5"; ... leaf X { type string; } } } leaf-list Y { type uint32; } }
For the above YANG definition, the container "top" is defined in the "example-top" YANG module, and a target resource URI for leaf "X" would be encoded as follows:
对于上述YANG定义,在“ example-top” YANG模块中定义了容器“ top”,并且叶“ X”的目标资源URI编码如下:
/restconf/data/example-top:top/list1=key1,key2,key3/\\ list2=key4,key5/X
For the above YANG definition, a target resource URI for leaf-list "Y" would be encoded as follows:
对于上述YANG定义,叶列表“ Y”的目标资源URI的编码如下:
/restconf/data/example-top:top/Y=instance-value
The following example shows how reserved characters are percent-encoded within a key value.
下面的示例显示如何在键值内对保留字符进行百分比编码。 The value of "key1" contains a comma, single-quote, double-quote, colon, double-quote, space, and forward slash (,'":" /).
“ key1”的值包含逗号,单引号,双引号,冒号,双引号,空格和正斜杠(,'“:” /)。 Note that double-quote is not a reserved character and does not need to be percent-encoded.
请注意,双引号不是保留字符,不需要百分号编码。 The value of "key2" is the empty string, and the value of "key3" is the string "foo".
“ key2”的值是空字符串,而“ key3”的值是字符串“ foo”。
Example URL:
范例网址:
/restconf/data/example-top:top/list1=%2C%27"%3A"%20%2F,,foo
So in the context of your example, you would do /restconf/data/abc:xyz=my-key/b
, /restconf/data/abc:xyz=my-key/c
or /restconf/data/abc:xyz=my-key/d
, where my-key is the key of the list instance's entry you wish to query. 因此,在您的示例上下文中,您将
/restconf/data/abc:xyz=my-key/b
, /restconf/data/abc:xyz=my-key/c
或/restconf/data/abc:xyz=my-key/d
,其中my-key是您要查询的列表实例条目的键。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.