Re: [yang-doctors] Consistency for naming lists and leaf-lists

Kent Watsen <kent@watsen.net> Tue, 03 December 2019 15:17 UTC

Return-Path: <0100016ecc5663e2-05f736ca-1b12-4692-a1f4-5b53d66079cc-000000@amazonses.watsen.net>
X-Original-To: yang-doctors@ietfa.amsl.com
Delivered-To: yang-doctors@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 8D07012006B for <yang-doctors@ietfa.amsl.com>; Tue, 3 Dec 2019 07:17:27 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.897
X-Spam-Level:
X-Spam-Status: No, score=-1.897 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=amazonses.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 KgOEjghXzazQ for <yang-doctors@ietfa.amsl.com>; Tue, 3 Dec 2019 07:17:26 -0800 (PST)
Received: from a48-93.smtp-out.amazonses.com (a48-93.smtp-out.amazonses.com [54.240.48.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id BAFF21200A1 for <yang-doctors@ietf.org>; Tue, 3 Dec 2019 07:17:25 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=6gbrjpgwjskckoa6a5zn6fwqkn67xbtw; d=amazonses.com; t=1575386244; h=From:Message-Id:Content-Type:Mime-Version:Subject:Date:In-Reply-To:Cc:To:References:Feedback-ID; bh=j6d6pGU/pKaaSbnKYpV0sxWqaciGAQ+20fJkxmyDlQI=; b=TwJgQ8FmoPLdv/nX8NcN3xyMlFitzxwBfHPIBR50n34MkmoQsR7WhSOLkDjVyllw 1cPwU+0gf4IHhkgPZFFvntlMKit7n3hMwBAWLDbwc0PJxsMbvv48rEXYVuUT1uvqcrJ lTeuuFkv9g5AZ9z08TXRxEahUTCxDSwx/SWya+s4=
From: Kent Watsen <kent@watsen.net>
Message-ID: <0100016ecc5663e2-05f736ca-1b12-4692-a1f4-5b53d66079cc-000000@email.amazonses.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_86FDF2CE-A1A0-4ACD-91CC-FFE9EB410123"
Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\))
Date: Tue, 03 Dec 2019 15:17:24 +0000
In-Reply-To: <MN2PR11MB43663CA34FE4E3B9EDB59578B5420@MN2PR11MB4366.namprd11.prod.outlook.com>
Cc: Ladislav Lhotka <lhotka@nic.cz>, "yang-doctors@ietf.org" <yang-doctors@ietf.org>
To: "Rob Wilton (rwilton)" <rwilton@cisco.com>
References: <MN2PR11MB4366355E6E59D9AFE3F27615B5460@MN2PR11MB4366.namprd11.prod.outlook.com> <20191202.093931.847844329284889456.mbj@tail-f.com> <9e54af2d14f72cfc498fee23987e588e84e59bc5.camel@nic.cz> <MN2PR11MB43663CA34FE4E3B9EDB59578B5420@MN2PR11MB4366.namprd11.prod.outlook.com>
X-Mailer: Apple Mail (2.3445.104.11)
X-SES-Outgoing: 2019.12.03-54.240.48.93
Feedback-ID: 1.us-east-1.DKmIRZFhhsBhtmFMNikgwZUWVrODEw9qVcPhqJEI2DA=:AmazonSES
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/kx6FwSkJgpvDAGNkK3oImrE-Cpk>
Subject: Re: [yang-doctors] Consistency for naming lists and leaf-lists
X-BeenThere: yang-doctors@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Email list of the yang-doctors directorate <yang-doctors.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/yang-doctors>, <mailto:yang-doctors-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/yang-doctors/>
List-Post: <mailto:yang-doctors@ietf.org>
List-Help: <mailto:yang-doctors-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/yang-doctors>, <mailto:yang-doctors-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 03 Dec 2019 15:17:27 -0000

Hi Rob,

> Can't we just say that lists SHOULD NOT be put in their own containers to wrap the list?

If we were to pick a default stance, though I'm hesitant to think we should, I'd recommend the opposite, that containers SHOULD be used to wrap lists (and this strategy is used in all the models in the drafts I'm authoring).

I feel that this is conceptually more accurate.  That is, what we call a "list" is really a list-element, hence why it should have  singular name.  A wrapping-container, having a plural name, gives it the appearance of it being a collection at first glance (e.g., "/widget" vs. "/widgets/widget").

In REST APIs, clients create new list-elements by POST-ing to the parent resource, which acts as the list, supporting query options for sorting, filtering, searching, and pagination.  While it is possible to have heterogeneous contents (i.e., using media-types), it's most common for the contents to be homogeneous.  Any search for "REST API collection best practice" shows this.

The issue we're having is what might be called an "impedance mismatch".  In YANG, the list-element is the "list", but the parent node is rightfully the "collection". 

Notably, https://tools.ietf.org/html/draft-ietf-netconf-restconf-collection <https://tools.ietf.org/html/draft-ietf-netconf-restconf-collection-00> effectively bucks REST API best practice, targeting the collection-oriented operations to the "list element" resource.  Accordingly, this resulting RESTCONF API is both asymmetric and different than most other REST APIs.  For example (simplified for brevity):

	To insert a new widget into the collection:

		POST /widgets

	To get widgets in the collection:

	 	GET /widgets/widget?limit=2&offset=3?sort=name?where='foo==bar'

	(both are "collection" operations, but act on different resources)
	
It is understandable why the "restconf-collection" draft takes the approach it does, it being the logical result of YANG allowing a container to having more than one 'list' descendant.  But, if we were ever to pick that draft up again, or perhaps as part of YANG-next, we could define a "collection" annotation for containers (or a "collection" statement) that would: 1) signal that the container contains exactly one list and 2) allow the list-operations to be targeted to the container resource.

In the meanwhile, while waiting for the "collections" work to be picked up again, I feel that the YANG best practice, if anything, should be to mimic this structure (a container wrapping each list).

Kent