How to have selective type in leaf

Hi all,

Request for yang syntax help

Have the child (ace list) as part of parent (acl list)

now want to enforce child to use ietf-type ipv4 or ipv6 based on the selection done in acl(parent).

Could you please help with the syntax, also came with choice(switch) but could not undestand if it fits here.

Preformatted text

grouping acl-attributes {
container access-control-list {
list acl {
leaf type {
type enumeration {
enum ipv4 { value 1; }
enum ipv6 { value 2; }
}
}
list ace {
leaf source-ip-address {
if …/type == ipv4
type acl-ipv4-prefix;
default “0.0.0.0”; //sip
else if …/type == ipv6
type acl-ipv6-prefix;
default “::/0”
} //sip
}
indent preformatted text by 4 spaces

Hi

I would suggest you reuse the IETF solution for that and base your setup on that standard YANG model if possible.
https://tools.ietf.org/html/rfc8519