papi: add method to retrieve field options
[vpp.git] / src / vpp-api / python / vpp_papi / vpp_papi.py
index b5310a1..86bf7cb 100644 (file)
@@ -686,6 +686,15 @@ class VPPApiClient:
                                                            n[1]['avg'], n[1]['max'])
         return s
 
+    def get_field_options(self, msg, fld_name):
+        # when there is an option, the msgdef has 3 elements.
+        # ['u32', 'ring_size', {'default': 1024}]
+        for _def in self.messages[msg].msgdef:
+            if isinstance(_def, list) and \
+                    len(_def) == 3 and \
+                    _def[1] == fld_name:
+                return _def[2]
+
     def _call_vpp(self, i, msgdef, service, **kwargs):
         """Given a message, send the message and await a reply.