Subject: [Netconf] data format for list entry

From: "Yi Yang (yiya)" <[email-masked]>
Date: Wed, 1 Jun 2016 18:26:53 +0000

I am trying to understand how the data should be formatted when updating a list entry. Using the list model presented in https://tools.ietf.org/html/draft-ietf-netconf-restconf-13#section-3.5.1, if I want to create an entry in the list2 with key (key4v, key5v), I undertand the creation request should be encoded as:

GET /restconf/data/example-top:top/list1=key1v,key2v,key3v/list2=key4v,key5v
Accept: application/yang.data+json

Inside the rest request, how the data will be encapsulated in json? Based on the example given at https://tools.ietf.org/html/draft-ietf-netconf-restconf-13#appendix-D.3.9, it seems the entry needs to encoded as a list, even though it's a single list entry:

{
    "list2": [
        {
            "key4": "key4v",
            "key5": "key5v",
            "X": "x_value"
        }
    ]
}

Is this correct?

Yi

---

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 02 Jun 2016 12:36:58 +0200

> Accept: application/yang.data+json

To create a new entry of list2, you have to POST to the list resource, so
the Request-URI should be

POST /restconf/data/example-top:top/list1=key1v,key2v,key3v/list2

> Inside the rest request, how the data will be encapsulated in json? Based on the example given at https://tools.ietf.org/html/draft-ietf-netconf-restconf-13#appendix-D.3.9, it seems the entry needs…

I think this is correct.

Lada

>
> Is this correct?
>
> Yi
> _______________________________________________
> Netconf mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netconf

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

---

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 02 Jun 2016 12:49:50 +0200

"Yi Yang (yiya)" <[email-masked]> writes:

> Inside the rest request, how the data will be encapsulated in json?
> Based on the example given at
> https://tools.ietf.org/html/draft-ietf-netconf-restconf-13#appendix-D.3.9,
> it seems the entry needs to encoded as a list, even though it's a
> single list entry:

Oh, I missed this point. Yes, it would indeed be more logical to send just the
entry, i.e.

{
    "key4": "key4v",
    "key5": "key5v",
    "X": "x_value"
}

However, this won't work in the XML encoding where each list entry is
wrapped in an element with the list name:

<list2>
  <key4>key4v</key4>
  <key5>key5v</key5>
  <X>x_value</X>
</list2>

Lada

---

From: "Yi Yang (yiya)" <[email-masked]>
Date: Thu, 2 Jun 2016 14:15:46 +0000

Hi Lada,

To have a consisten structure between JSON and XML, does this indicate the
JSON format MSUT also be wrapped in an element with the list name, as
noted in my previous email?

{
    ³list2²: [
        {
            ³key4²: ³key4v²,
            ³key5²: ³key5v²,
            ³X²: ³x_value"
        }
    ]
}

Regardless, it would be great to have some clarifications on this in the
draft.

Yi

On 6/2/16, 6:49 AM, "Ladislav Lhotka" <[email-masked]> wrote:

>> I am trying to understand how the data should be formatted when
>>updating a list entry. Using the list model presented in
>>https://tools.ietf.org/html/draft-ietf-netconf-restconf-13#section-3.5.1,
>> if I want to create an entry in the list2 with key (key4v, key5v), I
>>undertand the creation request should be encoded as:
>>
>> GET 
>>/restconf/data/example-top:top/list1=key1v,key2v,key3v/list2=key4v,key5v

---

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 2 Jun 2016 16:46:48 +0200

> On 02 Jun 2016, at 16:15, Yi Yang (yiya) <[email-masked]> wrote:
> 
> Hi Lada,
> 

Yes, RESTCONF designers preferred to have a consistent structure. This was already discussed:

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

Lada

---

From: "Yi Yang (yiya)" <[email-masked]>
Date: Thu, 2 Jun 2016 14:53:28 +0000

Hi Lada,

While my original question was about ³GET², your response actually brings
a second question to me. Yes, as you suggested, creating a list entry can
be done by POST to the list URI
POST /restconf/data/example-top:top/list1=key1v,key2v,key3v/list2

Or, it can be created by PUT to the list-entry specific URI:
PUT 
/restconf/data/example-top:top/list1=key1v,key2v,key3v/list2=key4v,key5v

I assume, for consistency, both should be wrapped in an element with the
list name?

Yi

On 6/2/16, 6:36 AM, "Ladislav Lhotka" <[email-masked]> wrote:

>>https://tools.ietf.org/html/draft-ietf-netconf-restconf-13#appendix-D.3.9
>>, it seems the entry needs to encoded as a list, even though it's a
>>single list entry:
>>
>> {
>>     "list2": [
>>         {
>>             "key4": "key4v",
>>             "key5": "key5v",
>>             "X": "x_value"
>>         }
>>     ]
>> }
>
>I think this is correct.
>
>Lada
>
>>
>> Is this correct?
>>
>> Yi

---

From: Qin Wu <[email-masked]>
Date: Tue, 7 Jun 2016 07:09:35 +0000

Agree to have consistent structure between JSON and XML, otherwise it looks JSON and XML is not exchangeable.

-Qin
-----邮件原件-----
发件人: Netconf [mailto:[email-masked]] 代表 Ladislav Lhotka
发送时间: 2016年6月2日 22:47
收件人: Yi Yang (yiya)
抄送: Netconf
主题: Re: [Netconf] data format for list entry

> To have a consisten structure between JSON and XML, does this indicate 
> the JSON format MSUT also be wrapped in an element with the list name, 
> as noted in my previous email?

Lada

> 
> {
>    ³list2²: [
>        {
>            ³key4²: ³key4v²,
>            ³key5²: ³key5v²,
>            ³X²: ³x_value"
>        }
>    ]
> }
> 
> Regardless, it would be great to have some clarifications on this in 
> the draft.
> 
> Yi
> 
> 
> 
> 
> 
>>> https://tools.ietf.org/html/draft-ietf-netconf-restconf-13#section-3
>>> .5.1, if I want to create an entry in the list2 with key (key4v, 
>>> key5v), I undertand the creation request should be encoded as:
>>> 
>>> GET
>>> ,
>> Oh, I missed this point. Yes, it would indeed be more logical to send 
>> just the entry, i.e.
>> 
>> {
>>   "key4": "key4v",
>>   "key5": "key5v",
>>   "X": "x_value"
>> }
>>

---

From: Juergen Schoenwaelder <[email-masked]>
Date: Tue, 7 Jun 2016 09:26:52 +0200

On Tue, Jun 07, 2016 at 07:09:35AM +0000, Qin Wu wrote:

> Agree to have consistent structure between JSON and XML, otherwise
> it looks JSON and XML is not exchangeable.

The truth is that JSON and XML is 'exchangable' only if you have
access to the data models. You can't transform XML encoding to JSON
encoding or vice versa without having access to the model definition.

/js

-- 
Juergen Schoenwaelder           Jacobs University Bremen gGmbH
Phone: +49 421 200 3587         Campus Ring 1 | 28759 Bremen | Germany
Fax:   +49 421 200 3103         <http://www.jacobs-university.de/>

---

From: Qin Wu <[email-masked]>
Date: Tue, 7 Jun 2016 08:40:07 +0000

Exactly. Thanks for clarification.

-Qin
-----邮件原件-----
发件人: Juergen Schoenwaelder [mailto:[email-masked]] 
发送时间: 2016年6月7日 15:27
收件人: Qin Wu
抄送: Ladislav Lhotka; Yi Yang (yiya); Netconf
主题: Re: [Netconf] data format for list entry

> looks JSON and XML is not exchangeable.

The truth is that JSON and XML is 'exchangable' only if you have access to the data models. You can't transform XML encoding to JSON encoding or vice versa without having access to the model definition.

/js