Key names from an enum?

How do I define a key such that the key names are from an enum type (that is, the key names are pre-defined)? Please find some context below:

I am trying to come up with an oper model in YANG that supports the following command:

show application appA (Display appA statistics)
show application appB (Display appB statistics)
show application appC (Display appC statistics)

container application {
    tailf:cli-oper-info "Display application specific Statistics";

    list app-name {                    << How do I "mask" this?
        tailf:info "Application name";
        
        config false;

        key "app-name";

        leaf app-name {
            tailf:info "Application name";
            type enumeration {
                enum appA;
                enum appB;
                enum appC;
            }
        }
		leaf value1 {}
		..............
		leaf valuen {}
    }
}

I have two requirements in the YANG model.

  1. app-name should be masked. The command should just be

show application appA | apB | appC

I tried cli-drop-node-name under “list app-name” and it did not do it. Could you tell me how I can achieve this?

  1. The app name should be from a predefined list of apps. I have enum defined as above but the command line interface seems to accept only appA. "show application appB (or appC ) " throws syntax errors.

cli-drop-node-name should work.
You can try it with the example: intro/5-c_stats, under “list arpe”.

Did you implement get_next? Your get_next might not be returning the proper keys.
ConfD will call get_next() to key the keys, or get_next_object() if implemented.
If your callback invocations don’t return “appB” and/or “appC” then there is no way for ConfD to display data for those entries.

It looks like your get_next() callback only returns the “appA” equivalent value for the key “app-name”.

Thanks for your response. I have two queries here:

  1. If I use cli-drop-node-name, the app-name does stop appearing as a command option but even the key names don’t appear in the “Possible Completions” list.

I would like to be able to say
“show application ?”

and see

appA
appB
appC

in the list of possible options. How could I do this?

  1. Regarding the callbacks, I already have get_next_object() implemented. I am going to see if there is a bug in my implementation.

What happens if I implement both get_next() and get_next_object()? Which one gets called by ConfD to find out the available key names?

And finally, does ConfD even need to make the callbacks? Can it take the enum values as the key names so that I don’t have to implement get_next() and just implement get_object and get_next_object functions?

Could you help me with my first query above? How could I use cli-drop-node-name but still have the key names appear in the completions list?

When you don’t drop the list name, do you see the data?
Play with the example I mentioned earlier and see if you get the same behavior.

Your list is operational, which means your data provider will have to return the values for the key that should be displayed to the user. You do this in a get_next() callback.
If you are not seeing those values when you do a tab, then your data provider is not returning the values.

If you don’t want your data provider to have to return these values for the key, you can then change your list to a configuration list with the key values stored in CDB (you would have to create 3 instances in CDB for the 3 apps you mentioned). This way ConfD doesn’t contact your application for the keys. This would be useful if you always expect your data provider to have records for each one of the applications. The rest of the nodes under the list should be operational data still (config false). In this case you can rely on a get_object() implementation instead of get_next() and get_next_object().