Declare a 2 leaves with the same name but different types

I want to declare 2 leaves with the same name but different types:

    container cont-a {
            leaf leaf-a {
                    type uint32;
            }
            leaf leaf-a {
                    type uint16;
            }
    }

I want to use the one with type uint32 sometimes, and sometimes the one with type uint16, according to my decision (that can be based on another leaf).

Is this possible?
I tried with when but it didn’t work.
choice won’t work also, because I must use a differdnt leaf name.

See RFC 6020 Section 9.12. “The union Built-In Type”
https://tools.ietf.org/html/rfc6020#section-9.12

Example:

container cont-a {
        leaf leaf-a {
                type union {
                        type uint32;
                        type uint16;
                }
        }
}
1 Like

Thanks,

Do you think it’s possible to choose which one of the union types to use? / to show to the user?

I couldn’t find it…

What is returned to the user with the <get-config> request is determined by what value has previously been set with the <edit-config> request. The data type is determined at the configuration time.