I did manage to find some older posts about empty types in keys. It seems that 
perhaps YANG 1.1 allows them but they are not actually useful.  I believe 
perhaps my example below does *not* work as I show and instead every apartment 
would be required to be a "bis" apartment.  Keys must be present which means 
the "bis" leaf would always have to be present.

Any confirmation of this would be appreciated.

Regards,
Jason

From: netmod [mailto:[email protected]] On Behalf Of Sterne, Jason (Nokia 
- CA)
Sent: Tuesday, August 30, 2016 18:17
To: [email protected]
Subject: [netmod] Using an empty type in a list key

Hi all,

I saw the addition of empty types in list keys in YANG 1.1 but had troubles 
finding more details in the NETMOD list.  Is it discussed in the YANG 1.1 
issues page (and if so, where is that now ?  I tried an old link and it didn't 
work) ?

If I take this example where I have a set of a apartments 1,2,3 but there may 
also be occasional 'bis' apartments (e.g. 7bis).

list apartment {
    key "number bis";
    leaf number {
        type int16;
    }
    leaf bis {
        type empty;
    }
    leaf description {
         type string;
    }
}

Can I create list entries like this ?

<apartment>
    <number>5</number>
    <description>apartment 5</description>
<apartment>
<apartment>
    <number>8</number>
    <bis/>
    <description>apartment 8bis</description>
<apartment>
<apartment>
    <number>8</number>
    <description>apartment 8</description>
<apartment>

Doesn't the empty type have two states and the absence/presence of the leaf/tag 
indicates those states ?

I realize that a Boolean type could be used for bis but the use case (a 
question of preference/style) is that 'bis' is unusual and so it becomes noisy 
to have to set <bis>false</bis> all the time when creating apartment entries.  
It may be useful to only have to specify <bis/> in the rare cases that it is 
needed.

Regards,
Jason

_______________________________________________
netmod mailing list
[email protected]
https://www.ietf.org/mailman/listinfo/netmod

Reply via email to