# Key names from an enum?

**URL:** <https://dmap-community.ductus.global/t/key-names-from-an-enum/2398>\
**Category:** YANG\
**Created:** [April 8, 2019, 8:01pm UTC](https://dmap-community.ductus.global/t/key-names-from-an-enum/2398 "2019-04-08T20:01:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![arun88](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@arun88](https://dmap-community.ductus.global/u/arun88)\
**Post date:** [April 8, 2019, 8:01pm UTC](https://dmap-community.ductus.global/t/key-names-from-an-enum/2398/1 "2019-04-08T20:01:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nabil](https://avatars.discourse-cdn.com/v4/letter/n/e79b87/32.png) [@nabil](https://dmap-community.ductus.global/u/nabil)\
**Post date:** [April 8, 2019, 9:43pm UTC](https://dmap-community.ductus.global/t/key-names-from-an-enum/2398/2 "2019-04-08T21:43:47Z")

</div>

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”.

---

<div class="post-metadata">

**Author:** ![arun88](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@arun88](https://dmap-community.ductus.global/u/arun88)\
**Post date:** [April 8, 2019, 10:44pm UTC](https://dmap-community.ductus.global/t/key-names-from-an-enum/2398/3 "2019-04-08T22:44:06Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![arun88](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@arun88](https://dmap-community.ductus.global/u/arun88)\
**Post date:** [April 9, 2019, 10:57pm UTC](https://dmap-community.ductus.global/t/key-names-from-an-enum/2398/4 "2019-04-09T22:57:18Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![nabil](https://avatars.discourse-cdn.com/v4/letter/n/e79b87/32.png) [@nabil](https://dmap-community.ductus.global/u/nabil)\
**Post date:** [April 9, 2019, 11:35pm UTC](https://dmap-community.ductus.global/t/key-names-from-an-enum/2398/5 "2019-04-09T23:35:27Z")

</div>

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().
