How to have a list with more than one key?

I would like to model a show command as follows:

show application app appA version
show application app appB version

I am using a list node named ‘application’ that takes in two keys ‘app’ and ‘version’, where appA and appB are the possible values for the ‘app’ key and version has a string value.

My model looks like this:

list application 
        key "app version";
        config false;

        leaf app {
                   type enumeration {
                       enum appA;
                       enum appB;
         leaf version {
                   type string {
                        length "1..32";

With this model, when I do a show application app appA, I get an error message that the command has a syntax error at “app”. Could you tell me where I am going wrong here?

Unless you declare in your data model otherwise, you do not provide key leaf names in the CLI line, so your command should be like show application appA 1.2.3.

Thanks! What if I want to make the “version” key optional? That is, I want to be able to say:

show application appA

to list information about all the versions of appA


show application appA 1.2.3

to list information about version 1.2.3 of appA?

How could I achieve that? What changes do I need in my model above?

You should be able to do that without any data model changes, I believe.