reference icon indicating copy to clipboard operation
reference copied to clipboard

Datatype with gnmi get query

Open mahen-g opened this issue 5 years ago • 1 comments

Hi,

This is w.r.t to vlan-id under oc-network-instance. In the below scenario, data type for vlan-id is uint16 as per the Model. When we perform a gnmi get query , how should the key and the leaf to which it references be displayed ? Should key be displayed as a string, where as the leaf to which it references to be displayed as an integer. Or should both be integers or should both be strings?

As per the spec

PathElem message contains the name of the node within the data tree, along with any associated keys/attributes that may be required for it. Keys are contained within a map<string, string> where the key of the map is the name of the key element, and the value is the key's value encoded as a string.

Is the below output correct ?

[ { "vlan-id": "2", "config": { "name": "vlan-2", "vlan-id": 2 } } ]

Thanks,

mahen-g avatar Mar 11 '20 14:03 mahen-g

The string mapping is only used for representing the list key in the gNMI PathElem message -- in this case the Path message includes a PathElem:

elem: <
    name: "vlan"
    key: <
      key: "vlan-id"
      value: "2"
    >
  >

But the output of the Get (assuming JSON_IETF) should represent both instances of "vlan-id" as integers since the encoding rule for a leafref node (the first instance) is to follow the encoding of the element it is referencing (in this case the uint16 value).

aashaikh avatar Mar 31 '20 07:03 aashaikh