[Opensrf-commits] r2099 - trunk/src/python (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Sat Nov 20 10:50:32 EST 2010


Author: erickson
Date: 2010-11-20 10:50:30 -0500 (Sat, 20 Nov 2010)
New Revision: 2099

Modified:
   trunk/src/python/srfsh.py
Log:
added support for introspect operation

Modified: trunk/src/python/srfsh.py
===================================================================
--- trunk/src/python/srfsh.py	2010-11-20 15:29:13 UTC (rev 2098)
+++ trunk/src/python/srfsh.py	2010-11-20 15:50:30 UTC (rev 2099)
@@ -11,10 +11,15 @@
 
   request <service> <method> [<param1>, <param2>, ...]
     - performs an opensrf request
+    - parameters are JSON strings
 
   router <query>
     - Queries the router.  Query options: services service-stats service-nodes
 
+  introspect <service> [<api_name_prefix>]
+    - List API calls for a service.  
+    - api_name_prefix is a bare string or JSON string.
+
   set VAR=<value>
     - sets an environment variable
 
@@ -52,6 +57,7 @@
     'help', 
     'exit', 
     'quit', 
+    'introspect',
     'opensrf.settings', 
     'opensrf.math'
 ]
@@ -69,6 +75,7 @@
         'request' : handle_request,
         'router' : handle_router,
         'math_bench' : handle_math_bench,
+        'introspect' : handle_introspect,
         'help' : handle_help,
         'set' : handle_set,
         'get' : handle_get,
@@ -106,6 +113,26 @@
 
     cleanup()
 
+def handle_introspect(parts):
+
+    if len(parts) == 0:
+        report("usage: introspect <service> [api_prefix]\n")
+        return
+
+    service = parts.pop(0)
+    args = [service, 'opensrf.system.method']
+
+    if len(parts) > 0:
+        api_pfx = parts[0]
+        if api_pfx[0] != '"': # json-encode if necessary
+            api_pfx = '"%s"' % api_pfx
+        args.append(api_pfx)
+    else:
+        args[1] += '.all'
+
+    return handle_request(args)
+
+
 def handle_router(parts):
 
     if len(parts) == 0:



More information about the opensrf-commits mailing list