Can/should a leaf-list entry be "merged"?

Hi,

The question is as title – Can/should a leaf-list entry be “merged”?

My understanding of leaf-list entries is that they kind of serve as "key"s (like a key to a list), and thus “modifying” existing entry isn’t valid. (the old should be deleted first and a new one created?)

Does anyone have an idea?

Thanks!

Yes, this is true. A leaf-list can be seen as a set of values, and its printed representation should contain each value just once; and yes, the value serves as a key, so you cannot set it. But you can use the maapi_move function to pretty much the same effect.

Thanks for the reply. :slight_smile:

But maapi_move only moves existing entries around (not setting new values), right? What are the use cases of maapi_move? And there’s a maapi_move_ordered which is specifically for user-ordered lists, so does that mean maapi_move is designed for system-ordered lists?

The function maapi_move is for both kinds of lists, it changes the key value of a list or leaf-list entry. In case of a leaf-list the effect is not so obvious, but for a list it really moves the whole list entry, including its sublists or containers.

So can we say the functionality thatmaapi_move_ordered provides is a subset of what maapi_move does?

Another question – I’m on ConfD 7.4.1. Using the CLI, I tried move/insert on a system-ordered list. Although that’s not what an NBI user is supposed to do, the command did seemingly go through, but the change was actually made on another sibling user-ordered list, which is not expected. I wonder if that happens to you as well? Or you prefer I create another topic for this?

Thanks!

Not at all, the fact that their names are similar is somewhat unfortunate. maapi_move_ordered does not do anything with key values (or any values at all), it changes position of an entry - again, this is a bit more obvious if you try that with a list, not a leaf-list. maapi_move is not concerned with entry position (and it would not change the position in an ordered-by-user list), its sole purpose is to changes key values. I hope it is clear now that maapi_move can be used both on system-ordered as well as user-ordered lists, whereas maapi_move_ordered only on user-ordered lists and would return an error if used on a system-ordered list.

Yes please, open another topic.