Module: Zenoss::RESTAPI
- Included in:
- Connection
- Defined in:
- lib/zenoss/restapi.rb
Instance Method Summary collapse
-
#custom_rest(dev_path, req_path, callback_func = nil, callback_attr = nil) ⇒ String
Call a custom Zope method to work around some issues of unsupported or bad behaving REST methods.
-
#rest(req_path) ⇒ String
Prepend the appropriate path and call the REST method on the URL set with Zenoss#uri.
Instance Method Details
#custom_rest(dev_path, req_path, callback_func = nil, callback_attr = nil) ⇒ String
Call a custom Zope method to work around some issues of unsupported or bad behaving REST methods.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/zenoss/restapi.rb', line 43 def custom_rest(dev_path, req_path, callback_func = nil, callback_attr=nil) puts "ORIGINAL: #{req_path}" if $DEBUG meth,args = req_path.split('?') meth = "callZenossMethod?methodName=#{meth}" unless args.nil? meth << '&args=[' # Remove the named parameters because we can't dynamically call named parameters in Python. # This method uses positional parameters via the passed Array (Python List). meth << args.split('&').inject('') do |parms,arg| arg.gsub!(/'/, "'''") # This may cause problems if the passed argument is already triple quoted. parms << '===' unless parms.empty? parms << arg.split('=').last end meth << ']' end meth << "&filterFunc=#{callback_func}" unless callback_func.nil? meth << "&filterAttr=#{callback_attr}" unless callback_attr.nil? meth = "#{URI.encode(dev_path)}/#{URI.encode(meth)}" puts "METHOD: #{meth}" if $DEBUG rest(meth) end |
#rest(req_path) ⇒ String
Prepend the appropriate path and call the REST method on the URL set with Zenoss#uri
28 29 30 31 |
# File 'lib/zenoss/restapi.rb', line 28 def rest(req_path) resp = @httpcli.get "#{@zenoss_uri}#{req_path}" parse_rest(resp) end |