cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
872
Views
5
Helpful
2
Replies

Choice statement in NBI

Gastonper
Level 1
Level 1

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.

1 Accepted Solution

Accepted Solutions

vleijon
Cisco Employee
Cisco Employee

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.

View solution in original post

2 Replies 2

vleijon
Cisco Employee
Cisco Employee

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.

Noted.

Thank you.