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

Martin Bjorklund <mbj@tail-f.com> Tue, 03 December 2019 15:46 UTC

Return-Path: <mbj@tail-f.com>
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 9A8251200DF for <yang-doctors@ietfa.amsl.com>; Tue, 3 Dec 2019 07:46:07 -0800 (PST)
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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] 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 FSEYpeU-l0sp for <yang-doctors@ietfa.amsl.com>; Tue, 3 Dec 2019 07:46:05 -0800 (PST)
Received: from mail.tail-f.com (mail.tail-f.com [46.21.102.45]) by ietfa.amsl.com (Postfix) with ESMTP id 35C341200CC for <yang-doctors@ietf.org>; Tue, 3 Dec 2019 07:46:05 -0800 (PST)
Received: from localhost (unknown [173.38.220.41]) by mail.tail-f.com (Postfix) with ESMTPSA id 76AB01AE0290; Tue, 3 Dec 2019 16:46:03 +0100 (CET)
Date: Tue, 03 Dec 2019 16:45:29 +0100
Message-Id: <20191203.164529.67194688085153171.mbj@tail-f.com>
To: kent@watsen.net
Cc: rwilton@cisco.com, yang-doctors@ietf.org
From: Martin Bjorklund <mbj@tail-f.com>
In-Reply-To: <0100016ecc5663e2-05f736ca-1b12-4692-a1f4-5b53d66079cc-000000@email.amazonses.com>
References: <9e54af2d14f72cfc498fee23987e588e84e59bc5.camel@nic.cz> <MN2PR11MB43663CA34FE4E3B9EDB59578B5420@MN2PR11MB4366.namprd11.prod.outlook.com> <0100016ecc5663e2-05f736ca-1b12-4692-a1f4-5b53d66079cc-000000@email.amazonses.com>
X-Mailer: Mew version 6.8 on Emacs 25.2
Mime-Version: 1.0
Content-Type: Text/Plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/Zm7Ons7iVOXMkov8m5cbKG64uH4>
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:46:07 -0000

Hi,

Kent Watsen <kent@watsen.net> wrote:
> 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 think that NP-containers should be used when they make sense from a
modelling pow, i.e., to provide structure to the nodes.  In most cases
such containers are not needed.  I do not agree that it is a good idea
to put a surrounding container on *all* lists just for the sake of it
(and eventually I am going to send comments re this and other things
like naming in your drafts, but not until we have agreement on the
basics).

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

I know it is common that REST apis are structured like this.  But a
YANG model is not a defintion for a REST interface; rather, RESTCONF
is one of many ways to access data modelled in YANG.

A good structure, just like good names, matter, even though we discuss
programmatic interfaces.



/martin



> 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