01-29-2020 06:47 AM
Hi, I have the following in yang:
choice autentication{ mandatory true; case pw { leaf password { type string; } } case sn { leaf serial-number { type string; } } }
I realize that you can check in python the value of the choice itself like this:
if autentication == "pw": ... else: ...
However I can't figure it out how to get the value of autentication from the REST NBI.
If I use the following curl comand i get and error:
curl -i -X GET http://127.0.0.1:1440/api/running/services/.../autentication
But i have no problems with:
curl -i -X GET http://127.0.0.1:1440/api/running/services/.../password
The same gows with checking the value of autentication in the CDB, I only got thea leaf password or serial-number depending of my choice.
Solved! Go to Solution.
01-29-2020 09:19 AM
A choice is only visible in the schema tree, not in the data-tree, see https://tools.ietf.org/html/rfc6020#section-4.2.7:
The choice and case nodes appear only in the schema tree, not in the data tree or NETCONF messages. The additional levels of hierarchy are not needed beyond the conceptual schema.
The python API has some convenience functions for it, but unfortunately you don't have an easy way to check this on most APIs - as you notice you'll have to check both and see which one exists.
01-29-2020 09:19 AM
A choice is only visible in the schema tree, not in the data-tree, see https://tools.ietf.org/html/rfc6020#section-4.2.7:
The choice and case nodes appear only in the schema tree, not in the data tree or NETCONF messages. The additional levels of hierarchy are not needed beyond the conceptual schema.
The python API has some convenience functions for it, but unfortunately you don't have an easy way to check this on most APIs - as you notice you'll have to check both and see which one exists.
01-30-2020 03:31 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide