【问题标题】:How to get the specific child element from the parent in restconf如何在restconf中从父级获取特定的子元素
【发布时间】:2020-03-29 06:52:06
【问题描述】:

如何在restconf中从父元素中获取特定的子元素,同时在restconf中获取父元素的所有子元素? 例如: 我的模块

module system{
   leaf name{
      type string;
   }
   leaf version{
      type string;
   }
   container processors{
     list processor{
       key "id";
       leaf id{
         type string;
       }
       leaf name{
         type string;
       }
     }
   }
}

我想要系统的所有子代(名称、版本、处理器),但只想要处理器的 ID:

<system>
  <name>system_1</name>
  <version>1</version>
  <processors>
   <processor>
     <id>1</id>
   </processor>
   <processor>
     <id>2</id>
   </processor>
  </processors>
</system>

将在 restconf 中调用该答案的查询是什么?

【问题讨论】:

    标签: ietf-netmod-yang ietf-restconf


    【解决方案1】:

    您应该能够通过使用 GET 方法的字段查询参数来获得它。 参考可在 RFC8040 (https://www.rfc-editor.org/rfc/rfc8040#section-4.8.3) 中找到。

    请求应该是这样的:

    GET /restconf/data?fields=(system:name;system:version;system:processors/processor/id)

    请注意,您需要多次重复模块名称“system”,因为您尚未在示例模型中定义公共顶部节点。

    请记住,这仅在 RESTCONF 服务器支持 'fields' 查询参数时才有效,需要先确认。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-12-14
      • 2021-03-25
      • 2019-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多