Re: [Netconf] RESTCONF JSON list questions

Ladislav Lhotka <lhotka@nic.cz> Fri, 09 September 2016 12:16 UTC

Return-Path: <lhotka@nic.cz>
X-Original-To: netconf@ietfa.amsl.com
Delivered-To: netconf@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 8B9CE12B00A for <netconf@ietfa.amsl.com>; Fri, 9 Sep 2016 05:16:09 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.9
X-Spam-Level:
X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SCkOc7oBijfV for <netconf@ietfa.amsl.com>; Fri, 9 Sep 2016 05:16:08 -0700 (PDT)
Received: from trail.lhotka.name (trail.lhotka.name [77.48.224.143]) by ietfa.amsl.com (Postfix) with ESMTP id 97C4412B006 for <netconf@ietf.org>; Fri, 9 Sep 2016 05:16:07 -0700 (PDT)
Received: from localhost (unknown [195.113.220.110]) by trail.lhotka.name (Postfix) with ESMTPSA id 675A21CC021B; Fri, 9 Sep 2016 14:16:17 +0200 (CEST)
From: Ladislav Lhotka <lhotka@nic.cz>
To: Nick Weeds <nick.weeds@metaswitch.com>, Mahesh Jethanandani <mjethanandani@gmail.com>
In-Reply-To: <BY2PR02MB2007408A9A3592DD034ED1C5FBFB0@BY2PR02MB2007.namprd02.prod.outlook.com>
References: <BY2PR02MB2007333A5905BFE3D0D2DEF6FB320@BY2PR02MB2007.namprd02.prod.outlook.com> <5d21cb64-1160-5ab9-cd2f-39ac28b8d66d@cisco.com> <C98F8F34-077B-4E4C-B949-9D399B05B7E2@gmail.com> <BY2PR02MB2007408A9A3592DD034ED1C5FBFB0@BY2PR02MB2007.namprd02.prod.outlook.com>
User-Agent: Notmuch/0.22.1 (http://notmuchmail.org) Emacs/24.4.51.2 (x86_64-apple-darwin14.0.0)
Date: Fri, 09 Sep 2016 14:16:10 +0200
Message-ID: <m2eg4t9sl1.fsf@birdie.labs.nic.cz>
MIME-Version: 1.0
Content-Type: text/plain
Archived-At: <https://mailarchive.ietf.org/arch/msg/netconf/nyVlPEnFsSvOzEj8qcoGCri2Cf4>
Cc: "netconf@ietf.org" <netconf@ietf.org>
Subject: Re: [Netconf] RESTCONF JSON list questions
X-BeenThere: netconf@ietf.org
X-Mailman-Version: 2.1.17
Precedence: list
List-Id: Network Configuration WG mailing list <netconf.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netconf>, <mailto:netconf-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netconf/>
List-Post: <mailto:netconf@ietf.org>
List-Help: <mailto:netconf-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netconf>, <mailto:netconf-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 09 Sep 2016 12:16:09 -0000

Nick Weeds <nick.weeds@metaswitch.com> writes:

> Hi Mahesh,
>
> The answer to question (2) is that list entries should always be encoded as JSON lists even when there is only one entry.  This is fixed in the latest restconf draft.
>
> I didn't really get an answer to question (1) other than "check the WG
> mailing list". However, a subsequent discussion on the WG mailing list

Yes, and also, for example,

https://www.ietf.org/mail-archive/web/netconf/current/msg11049.html

> with subject "restconf confusing text" raised the same issue.  I think
> the official view is that restconf does not support querying a list
> because a list is not a single "data node", and that a future restconf

In YANG, a list *is* a single data node:

   o  data node: A node in the schema tree that can be instantiated in a
      data tree.  One of container, leaf, leaf-list, list, anydata, and
      anyxml.


> collections draft would provide this kind of function.  I don't think

I believe it has to do with limitations of XML that doesn't have (unlike
YANG and JSON) the concept of a list, just a sequence of elements with
the same tag.

Lada

> Dale Worley agrees with that position and/or my summary of it.  Also
> note that it is possible to query a list by using a parent container
> as the target together with a "fields" query parameter to select the
> list, so it is possible to query a list using restconf but in a more
> fiddly way.

>
>                Nick.
>
> From: Mahesh Jethanandani [mailto:mjethanandani@gmail.com]
> Sent: 08 September 2016 15:58
> To: Nick Weeds
> Subject: Re: [Netconf] RESTCONF JSON list questions
>
> Did you ever get a response to your questions below?
>
>
> Subject:
>
> [Netconf] RESTCONF JSON list questions
>
> Date:
>
> Thu, 14 Jul 2016 16:48:25 +0000
>
> From:
>
> Nick Weeds <nick.weeds@metaswitch.com><mailto:nick.weeds@metaswitch.com>
>
> To:
>
> netconf@ietf.org<mailto:netconf@ietf.org> <netconf@ietf.org><mailto:netconf@ietf.org>
>
>
> I have a couple of questions on RESTCONF handling of Yang lists when using JSON encoding.
> Please can anybody answer or clarify these points ?
> The current drafts don't seem to give definite answers (or might contain errors), and it's hard to find answers in the archives.
>
>
> (1)    Is it valid to perform a GET on an entire list rather than a single list entry ?
>
> For example, is it valid to send a GET request for the interface list:
>
>                GET /restconf/data/interfaces/interface
>
> rather than a GET request on for a particular interface list entry:
>
>                GET /restconf/data/interfaces/interface=eth1
>
> Observations:
> -        RFC 6020 seems to say that list entries are data nodes but lists are not (sections 3, 4.2.2.4, 7.8).
> -        draft-ietf-netconf-restconf-15 seems to say that list entries are data resources but lists are not (section 3.5).
> -        draft-ietf-netconf-restconf-15 section 3.5.3 says that the URI must include the key values (so that it identifies a list entry rather than a list), but it doesn't say what happens if the list doesn't have any keys (as is typical for a GET).
> -        draft-ietf-netconf-restconf-15 section 4.3 says that a GET cannot return more than one instance when using XML encoding, but it doesn't say what happens when using other encodings (such as JSON).  This seems to keep the possibility of JSON providing more function than XML, although some WG mailing list discussions seem to have argued for keeping strict equivalence.
>
>
> (2)    When a RESTCONF request contains a single list entry, when should it be encoded as a JSON list and when should it be encoded as a single JSON object (examples in draft-ietf-netconf-restconf-15 vary) ?
> For example, when should an album list entry be encoded like this:
>
>         "example-jukebox:album" : [
>           {
>             "name" : "Wasting Light",
>             ...
>           }
>         ]
>
> and when should it be encoded like this:
>
>         "example-jukebox:album" : {
>           "name" : "Wasting Light",
>           ...
>         }
>
> draft-ietf-netmod-yang-json-10 section 5.4 describes how to encode a list but not how to encode a single list entry in isolation.
>
> Examples in draft-ietf-netconf-restconf-15 seem to vary:
> - PUT examples seem to use a JSON list (section 4.5)
> - GET example seem to use JSON list (section 5.3.2, D.3.9)
> - POST examples seem to use a single JSON object without a JSON list (sections D.2.1, D.3.4, D.3.5).
>
> The earlier "data format for list entry" discussion on the WG mailing list seems to indicate that the PUT and GET examples are correct but the POST examples are wrong.  Is that true?
>
>                Nick.
> <Attached Message Part.txt>
>
> Mahesh Jethanandani
> mjethanandani@gmail.com<mailto:mjethanandani@gmail.com>
>
>
>
> _______________________________________________
> Netconf mailing list
> Netconf@ietf.org
> https://www.ietf.org/mailman/listinfo/netconf

-- 
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: E74E8C0C