Re: [netmod] attributes in draft-lhotka-netmod-yang-json

Andy Bierman <andy@yumaworks.com> Sun, 23 March 2014 16:41 UTC

Return-Path: <andy@yumaworks.com>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 938761A6FDC for <netmod@ietfa.amsl.com>; Sun, 23 Mar 2014 09:41:48 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.278
X-Spam-Level:
X-Spam-Status: No, score=-1.278 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001] autolearn=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 OXc5DN5hs_sj for <netmod@ietfa.amsl.com>; Sun, 23 Mar 2014 09:41:47 -0700 (PDT)
Received: from mail-qg0-f41.google.com (mail-qg0-f41.google.com [209.85.192.41]) by ietfa.amsl.com (Postfix) with ESMTP id C619C1A6FDB for <netmod@ietf.org>; Sun, 23 Mar 2014 09:41:46 -0700 (PDT)
Received: by mail-qg0-f41.google.com with SMTP id i50so13640066qgf.0 for <netmod@ietf.org>; Sun, 23 Mar 2014 09:41:46 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=bulCuKZiNzw3UAN9YgQRVjM4npVBlI1cCVglN09mkkU=; b=MIlIwb0L+i7hoMdBuSyZ/1BvQ99zDZd1iRy3n72qXkR9yg640NhlGSJX2kP/DwBFdJ VYCu3dEPTYI5SRJzOwLhM13OrV9tlNXBy85XgdWz5UePLQV2a1o1gI9fcIl2SnXtATYN QbFkFLyqYW8uSN/tBZgeQxZNoCnHoTemuaFi2qoL93eMZEK1tt+5ZUWAXtUcZNkLcnQ7 c+MYR/9CGTAsUN04fVH7F15J2vkolk5UULpZQkA23ZTXwfW5uDM5FDvoz1+1X5HZJ0Yr Nm1TFQJWww55P55BHztL+zBntNCO18ps6wEakw7ZFt+6G2nMCq/eItJDSfOznimu7OYI oOZw==
X-Gm-Message-State: ALoCoQmGSl6ZvHVvz5kig8bd9UlRe7FCSGAKmOVKhqtlIUo+4H7w7LqiUCW5mi2V+gmLJkwUUZ46
MIME-Version: 1.0
X-Received: by 10.224.130.8 with SMTP id q8mr1222480qas.99.1395592906129; Sun, 23 Mar 2014 09:41:46 -0700 (PDT)
Received: by 10.140.104.194 with HTTP; Sun, 23 Mar 2014 09:41:46 -0700 (PDT)
In-Reply-To: <m2lhw0hoxy.fsf@nic.cz>
References: <3FADE5E8-88AC-4FD0-A2F6-72F408FAFFC4@juniper.net> <20140320.150426.496532825.mbj@tail-f.com> <CABCOCHT3AJR0u=-GV1eM8geL-F2j7HSBsw0uBb1DYDvZio6eCA@mail.gmail.com> <CABCOCHSM7CwAPFOZ4qzzTtTRRX0LWE2Gb+ZWzmDpwBGSKRGhOg@mail.gmail.com> <m2bnwy7j0c.fsf@nic.cz> <CABCOCHRFjzj40nWtckJRPCbxCMSwojadRh0rBb27qMRyHx8MHA@mail.gmail.com> <m2ob0xb697.fsf@nic.cz> <CABCOCHS0=fODFFaf_2kDZVcbGAd=BuvJXCpR5-K3uQFXy+PAsw@mail.gmail.com> <m2k3blar7e.fsf@nic.cz> <CABCOCHRZLp52pgMhi0tKs3=vLZLkAQcw=iK4TG77BArSCK8-_g@mail.gmail.com> <m2lhw0hoxy.fsf@nic.cz>
Date: Sun, 23 Mar 2014 09:41:46 -0700
Message-ID: <CABCOCHQdE5JwJBrQpGx_eFxr8ijGvKr0-_OuTUiPZH_bX+a1FQ@mail.gmail.com>
From: Andy Bierman <andy@yumaworks.com>
To: Ladislav Lhotka <lhotka@nic.cz>
Content-Type: multipart/alternative; boundary="001a11c2b34e6beed604f548cb1e"
Archived-At: http://mailarchive.ietf.org/arch/msg/netmod/EE5Kei0wqj_N5meHe1zNSFJmPfw
Cc: "netmod@ietf.org" <netmod@ietf.org>
Subject: Re: [netmod] attributes in draft-lhotka-netmod-yang-json
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sun, 23 Mar 2014 16:41:48 -0000

On Sun, Mar 23, 2014 at 9:14 AM, Ladislav Lhotka <lhotka@nic.cz> wrote:

> Andy Bierman <andy@yumaworks.com> writes:
> >
> > Try the example I did where entry1 is owned by owner admin1 and entry2
> > is owned by admin2.  I don't think this works.
>
> { "top": {
>   "A": [
>     { "@tagged-value": {
>         "@owner": "admin1",
>         "@value": {
>           "id": "entry-1",
>           "aa": [42, 19]
>         }
>       }
>     },
>     { "@tagged-value": {
>         "@owner": "admin2",
>         "@value": {
>           "id": "entry-2",
>           "aa": [99, 11]
>         }
>       }
>     }
>   ],
>   "host-name": "router"
> }
>
> >
> > This approach is way too complicated. The encoding scheme in the RESTCONF
> > draft
> > is easier to implement and it works for list and leaf-list siblings.
> >
>
> I think it is more difficult to parse. If you have a container "foo" in
> the data model, you cannot tell whether
>
> "foo": { ... }
>
> is the "native" container or the encoding of attributes, without first
> inspecting the contents of the object, i.e. looking whether any keys of its
> members start with "@".
>
> In my encoding, the two alternatives can be distinguished immediately:
>
> "foo": { ... }    (native container)
>
> versus
>
> "foo": {
>   @tagged-value { ... }
> }
>
>

To a plain JSON parser it doesn't matter (just valid JSON).
To a special parser that is looking for attributes, whatever ad-hoc
formula is used will be coded, so it doesn't matter.



> Note also that in your example
>
>    "host-name" : {
>        "@protect" : "protect",
>        "host-name" : "router"
>    }
>
> the value of the "@protect" attribute is irrelevant, and this is where my
> "property" encoding is IMO more elegant:
>
>   "host-name" : {
>     "@protect" : "router"
>   }
>
>
So if there are multiple boolean properties, the value is repeated?

  "host-name" : {
    "@protect" : "router",
    "@enabled": "router"
  }

This seems really hard to parse.

A variant that combines RESTCONF with yours:

  "host-name" : {
    "@protect" : true,
    "@enabled": true,
    "@owner": "admin1",
    "_@value":"router"
  }

A real YANG identifier could never start with "_@"
so it can be used to prevent "value" from being a reserved name.


 My impression from previous discussions was that the proposed uses of XML
> attributes ("protect", "disable" etc.) are often of this type.
>
>

There are plenty of examples like owner, etag, last-changed-time, and
with-defaults
that are not simple boolean properties.

We know the attributes can be encoded in a way that a plain JSON parser
will accept it.
The real issue is whether the client or server code that needs to interpret
the protocol
message is going to be too complicated to be workable.

HTTP header lines are for message-level meta-data.
We have data-level meta-data associated with datastore nodes.
I doubt it can be ignored. There are no issues with
adding attributes to containers or lists.  Only leaf and leaf-list
encoding needs to be impacted.




Lada
>
>
Andy