在RESTCONF中获取所有列表实例合法吗? [英] Is it legal to GET all list instances in RESTCONF?

查看:187
本文介绍了在RESTCONF中获取所有列表实例合法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在模块test中给出以下YANG定义:

Given the following YANG definitions, in module test:

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

并在数据树中:

"machine" : [
    { "name": "a" },
    { "name": "b" },
    { "name": "c" }
]

我想知道以下请求是否符合RESTCONF?

I want to know if the following request conforming to RESTCONF?

GET /restconf/data/test/machine

该请求应返回所有列表实例.

This request is expected to return all the list instances.

我有这个问题,因为我对RESTCONF中的词语不了解.在RESTCONF中 3.5.3

I have this question because I don't have a clear understanding of the words from RESTCONF. In RESTCONF 3.5.3,

如果路径表达式中的数据节点是YANG列表节点,则 列表的键值(如果有)必须根据 以下规则:

If a data node in the path expression is a YANG list node, then the key values for the list (if any) MUST be encoded according to the following rules:

o代表YANG列表的数据资源的关键叶子值 必须使用一个路径段[RFC3986]进行编码.

o The key leaf values for a data resource representing a YANG list MUST be encoded using one path segment [RFC3986].

o如果只有一个键叶值,则路径段为 通过具有列表名称,后跟一个"="字符来构造, 然后是单个键叶值.

o If there is only one key leaf value, the path segment is constructed by having the list name, followed by an "=" character, followed by the single key leaf value.

(if any)表示以下两个含义之一? (对于非配置listkey语句不是必须的.因此,有keyed listsnon-keyed lists.)

The (if any) mean which one of the following two meanings? (the key statement is not a must for a non-configuration list. So there are keyed lists and non-keyed lists.)

  1. 用户可以自由指定键列表的键值. (if any)表示如果指定了键值".如果指定,则键值必须遵循有关键值的规则.如果未指定,则不必遵循有关键值的规则.以我的YANG定义为例,这两个请求都是正确的:

  1. Users are free to specify key values for keyed lists. The (if any) is about "if the key values are specified." If they specify then the key values MUST follow the rules about the key values. If they don't specify then you don't have to follow the rules about key values. Take my YANG definitions for example, these two requests are both correct:

GET /restconf/data/test/machine    // get all list instances
GET /restconf/data/test/machine=a  // get the list instance keyed "a"

  • 用户必须为键列表指定键值. (if any)表示列表是否已键入".在这种理解下,将会有:

  • Users have to specify key values for keyed lists. The (if any) is about "if the list is keyed or not." In this understanding, there will be:

    GET /restconf/data/test/machine    // wrong request, can't get all list instanecs
    GET /restconf/data/test/machine=a  // ok, get the list instance keyed "a"
    

  • 第二个理解是来自同一部分中的叶子列表中的相似词:

    The second understanding is from the similar words in the same section for leaf-lists:

    如果路径表达式中的数据节点是YANG叶列表节点,则 叶列表值必须根据以下规则进行编码:

    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叶子列表的标识符必须使用一条路径进行编码 段[RFC3986].

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

    o路径段是通过具有叶列表名称来构造的, 后跟一个"="字符,后跟叶子列表值 (例如,/restconf/data/top-leaflist = fred).

    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).

    叶子列表的单词没有(if any),因此您不能使用像/restconf/data/top-leaflist这样的URL.您必须使用=fred指定叶子列表实例.因此,如果无法整体检索叶列表实例,为什么可以整体检索列表实例(理解1)?叶列表实例和列表实例都是数据资源,它们在概念上是等效的.

    The words for leaf-lists don't have (if any), so you cannot use a URL like /restconf/data/top-leaflist. You have to use =fred to specify a leaf-list instance. So If leaf-list instances cannot be retrieved as a whole, why list instances can be retrieved as a whole (in understanding 1)? A leaf-list instance and a list instance are both a data resource, they are equivalent in concept.

    谢谢

    推荐答案

    正确的解释是1.如果有"是指键值,而不是YANG键声明. RESTCONF GET可以获取列表的多个实例,但是只能使用JSON编码(格式正确的XML不允许多个根元素).这也是检索无键非配置(状态)列表实例的唯一方法.

    The correct interpretation is 1. The "if any" refers to key values, not YANG key statements. It is okay for a RESTCONF GET to fetch more than one instance of a list, but only in JSON encoding (well formed XML does not allow multiple root elements). This is also the only way to retrieve key-less non-configuration (state) list instances.

    如果仅允许通过GET获得单个列表条目,则其相应的RFC部分将使用MUST明确声明该内容-如果您查看

    If only a single list entry would be allowed to be obtained via GET, its corresponding RFC section would explicitly state this with a MUST - if you take a look at the wording for DELETE in section 4.7, p3, such text exists, but there is no equivalent for GET.

    也可以检索多个叶子列表实例.这可能是检索某些此类实例的唯一方法,因为(在YANG 1.1中)非配置叶列表允许重复值.缺少的如果有的话"很可能是社论上的遗漏.

    It is also okay to retrieve multiple leaf-list instances. This may be the only way to retrieve some such instances, since (in YANG 1.1) duplicate values are allowed for non-configuration leaf-lists. The missing "if any" is most likely an editorial omission.

    请注意,3.5.3中的文字仅说明URI的形成方式,而没有提及RESTCONF操作如何利用这些URI.

    Note that the text in 3.5.3 only explains how URIs are formed, it does not say anything about how RESTCONF operations utilize those URIs.

    这篇关于在RESTCONF中获取所有列表实例合法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆