ConfD User Community

How to show different set of containers based on the availability of the entry in the list?


#1
  list entry {
    key "number";
      leaf number {
        type uint32;
      }

  choice param {
    case first-case {
      container first_item {
      ....
      }
    }
    case second-case {
      container second_item {
      ....
      }
    }
  }

  container param_1 {
    ...
  }
  container param_2 {
    ...
  }
}

This is skeleton of my yang model (It is imperfect for my requirement. I need to fine tune this, so need help!)

The list had the key as a number.
So my requirement is if there is no list entry with the number that you want to configure, then it should list -
first_item
second_item
Otherwise (if there is a list entry with the number that you keyed in), then it should provide the options-
param_1
param_2

i.e., let us say there was no entry in the list with the ID 1, then the behavior should be like below-
(config)# entry 1
(config)# ?
Possible completions:
first_item
second_item

Now, let us say an entry in the list with the ID 1 is present, then the behavior should be like below-
(config)# entry 1
(config)# ?
Possible completions:
param_1
param_2

How can i achieve this?
I am guessing using of must or _when_statement should work. But what exact xpath should i be using is what I am unsure of.

Any help on this would be appreciated! Thanks in advance.