From 1f2f1b117bc5935a710ba32ef82b967b3c4fa73c Mon Sep 17 00:00:00 2001 From: erickson Date: Sat, 20 Nov 2010 15:50:30 +0000 Subject: [PATCH] added support for introspect operation git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@2099 9efc2488-bf62-4759-914b-345cdb29e865 --- src/python/srfsh.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/python/srfsh.py b/src/python/srfsh.py index a8aec1f..d1c3c04 100755 --- a/src/python/srfsh.py +++ b/src/python/srfsh.py @@ -11,10 +11,15 @@ srfsh.py - provides a basic shell for issuing OpenSRF requests request [, , ...] - performs an opensrf request + - parameters are JSON strings router - Queries the router. Query options: services service-stats service-nodes + introspect [] + - List API calls for a service. + - api_name_prefix is a bare string or JSON string. + set VAR= - sets an environment variable @@ -52,6 +57,7 @@ tab_complete_words = [ 'help', 'exit', 'quit', + 'introspect', 'opensrf.settings', 'opensrf.math' ] @@ -69,6 +75,7 @@ def do_loop(): '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 @@ def do_loop(): cleanup() +def handle_introspect(parts): + + if len(parts) == 0: + report("usage: introspect [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: -- 2.43.2