Re: [Netconf] RESTCONF JSON list questions

Nick Weeds <nick.weeds@metaswitch.com> Thu, 08 September 2016 15:09 UTC

Return-Path: <nick.weeds@metaswitch.com>
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 071DD12B041 for <netconf@ietfa.amsl.com>; Thu, 8 Sep 2016 08:09:01 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.021
X-Spam-Level:
X-Spam-Status: No, score=-2.021 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=metaswitch.com
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 Jw-00MCQuhvH for <netconf@ietfa.amsl.com>; Thu, 8 Sep 2016 08:08:56 -0700 (PDT)
Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0131.outbound.protection.outlook.com [104.47.36.131]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 8D1DE12B019 for <netconf@ietf.org>; Thu, 8 Sep 2016 08:08:56 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=metaswitch.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=3b9N0YdMw1pkeEHasav52NcfKthgbBYz0KhMPlELSGI=; b=VwrvZJY4zNFENBi+yCbO2qbRDuR5UXa4fhQnGw+K61LduSBgDmirRV8VYDXaqNNQOfh3LphMFF7coQ5N58poxls8WwoPYldTOYFcE5F4AYPjTSbMxTQdJyZ3M8Q1Q6SPU+yqmxsL6aXJ/y2A+Co2e7Rxb4GMupZggahCjnFBt1g=
Received: from BY2PR02MB2007.namprd02.prod.outlook.com (10.166.110.7) by BY2PR02MB2006.namprd02.prod.outlook.com (10.166.109.156) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.609.9; Thu, 8 Sep 2016 15:08:54 +0000
Received: from BY2PR02MB2007.namprd02.prod.outlook.com ([10.166.110.7]) by BY2PR02MB2007.namprd02.prod.outlook.com ([10.166.110.7]) with mapi id 15.01.0609.012; Thu, 8 Sep 2016 15:08:54 +0000
From: Nick Weeds <nick.weeds@metaswitch.com>
To: Mahesh Jethanandani <mjethanandani@gmail.com>
Thread-Topic: [Netconf] RESTCONF JSON list questions
Thread-Index: AdHd36/dNWIKaogdRmSfDrmBOFq2yQADPVxwAACxs5AK/H0GVQAAEugw
Date: Thu, 08 Sep 2016 15:08:53 +0000
Message-ID: <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>
In-Reply-To: <C98F8F34-077B-4E4C-B949-9D399B05B7E2@gmail.com>
Accept-Language: en-GB, en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: spf=none (sender IP is ) smtp.mailfrom=nick.weeds@metaswitch.com;
x-originating-ip: [2620:104:4000:3064:f4d0:1aef:5f0e:4eb4]
x-ms-office365-filtering-correlation-id: a39231cd-91ae-4487-7a49-08d3d7fa0c98
x-microsoft-exchange-diagnostics: 1; BY2PR02MB2006; 6:h7g8OjKuWOvxnGfYhymxf1NjI/VStSOLfaHce994T9ME5hCZXynbHZD5P3hpAJlItJhDv4KeJxbqe0ioiTJmVr5QP8D82SPi2XFNHoqgoKExRH3RGB1SUYVvEgakdV/rUF29Gbeqjua1+Lv2ohBDPn0Iah4qU86P7VOyNYu71odOk7cpjr5a7F2iAB480waJh8MmdKNmGb42So3MH/mTKCgqrVt0scIF5qlFTx4o58pMmcgEvMsJj5plPl1+wrcx+rSR/7BFECWamkp47TfzpRlsXAEfMlUsqM8PmlsDJ4Y=; 5:eWjbvBwDEDmx4pEJH3JL8i556+L5bRNqWV5zZyHBqFwkcmfnbFlfh7kK5iV9LV6zwkNwjRpIdPRhXKJNwQ2hUGXsHsV7lJORhDX5mBJ9O/0NCV9sEu7SSfrIOW2DKYauBvR4vPQ2dddteZs08rF9nQ==; 24:HeZzxBM/cejevNJl/YmOfbgmhhGaXXKOkcWC1wTPFxqMz60s0Ca1c4SLEKT5j0vr+FoCGDvOQY4bfiKzdA4RA+lJhrwlx80UBjtE9vzys4o=; 7:l5XTuUy4zl4/SnWQ+Ji9NcgkpG5bZWFKO1QvgC4F8AJ1rxuqHkj0i9vYkvCgry0caY7ywkkKmzBflddDpdErvZ2KowKotVcPjWvZ3KVDPdQoQuqD6PEANQpSCQhhI6EkhaAP73ZSr4eD2LsqxmQJWluYo0d0vcwDgXCcK32xfMBmKJJx0rF6vXJTXLW7QS++WqjCYrp6/RA8hzQBabGVSTIlG/FDzrmln10ZA3wR5Hvifpdf50l3KC0atU0rd9WU
x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR02MB2006;
x-microsoft-antispam-prvs: <BY2PR02MB2006BD8F11FF05FB1A1BB3ADFBFB0@BY2PR02MB2006.namprd02.prod.outlook.com>
x-exchange-antispam-report-test: UriScan:(21748063052155);
x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:BY2PR02MB2006; BCL:0; PCL:0; RULEID:; SRVR:BY2PR02MB2006;
x-forefront-prvs: 00594E8DBA
x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(7916002)(199003)(189002)(4326007)(19580395003)(74316002)(68736007)(86362001)(19625215002)(3280700002)(10400500002)(5890100001)(105586002)(3660700001)(87936001)(102836003)(189998001)(92566002)(1411001)(19580405001)(122556002)(16236675004)(81156014)(2950100001)(2900100001)(50986999)(2906002)(99286002)(6116002)(11100500001)(77096005)(8936002)(81166006)(97736004)(19300405004)(9686002)(5660300001)(54356999)(106356001)(8676002)(101416001)(5002640100001)(76176999)(7736002)(33656002)(790700001)(76576001)(7846002)(110136002)(586003)(15975445007)(9326002)(7696003)(3826002)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR02MB2006; H:BY2PR02MB2007.namprd02.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en;
received-spf: None (protection.outlook.com: metaswitch.com does not designate permitted sender hosts)
spamdiagnosticoutput: 1:99
spamdiagnosticmetadata: NSPM
Content-Type: multipart/alternative; boundary="_000_BY2PR02MB2007408A9A3592DD034ED1C5FBFB0BY2PR02MB2007namp_"
MIME-Version: 1.0
X-OriginatorOrg: metaswitch.com
X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Sep 2016 15:08:53.8253 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 9d9e56eb-f613-4ddb-b27b-bfcdf14b2cdb
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR02MB2006
Archived-At: <https://mailarchive.ietf.org/arch/msg/netconf/X8mrvpbAvFTv5j5cwZorEHsFIpU>
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: Thu, 08 Sep 2016 15:09:01 -0000

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 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 collections draft would provide this kind of function.  I don't think 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>