Class: MrMurano::Services

Inherits:
SolutionBase show all
Defined in:
lib/MrMurano/Solution-ServiceConfig.rb

Overview

This is only used for debugging and deciphering APIs.

There was once a plan for using this to automagically map commands into services by reading their schema. That plan had too much magic and was too fragile for real use.

A much better UI/UX happens with human intervention. :nocov:

Instance Method Summary collapse

Methods inherited from SolutionBase

#endPoint

Methods included from SyncUpDown

#docmp, #dodiff, #download, #ignoring, #localitems, #locallist, #remove, #removelocal, #searchFor, #status, #syncdown, #synckey, #syncup, #toRemoteItem, #tolocalname, #tolocalpath, #upload

Methods included from Verbose

#debug, #error, #outf, #tabularize, #verbose, #warning

Methods included from Http

#curldebug, #delete, #get, #http, #http_reset, #isJSON, #json_opts, #post, #postf, #put, #set_def_headers, #showHttpError, #token, #workit

Constructor Details

#initializeServices

Returns a new instance of Services.



70
71
72
73
# File 'lib/MrMurano/Solution-ServiceConfig.rb', line 70

def initialize
  super
  @uriparts << 'service'
end

Instance Method Details

#callable(id = sid) ⇒ Object

Get list of call operations from a schema



97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/MrMurano/Solution-ServiceConfig.rb', line 97

def callable(id=sid)
  scm = schema(id)
  calls = []
  scm[:paths].each do |path, methods|
    methods.each do |method, params|
      if params.kind_of?(Hash) and
          not params['x-internal-use'.to_sym] and
          params.has_key?(:operationId) then
        calls << [method, params[:operationId]]
      end
    end
  end
  calls
end

#listObject



86
87
88
89
# File 'lib/MrMurano/Solution-ServiceConfig.rb', line 86

def list
  ret = get()
  ret[:items]
end

#schema(id = sid) ⇒ Object



91
92
93
94
# File 'lib/MrMurano/Solution-ServiceConfig.rb', line 91

def schema(id=sid)
  # TODO: cache schema in user dir?
  get("/#{id}/schema")
end

#sidObject



81
82
83
84
# File 'lib/MrMurano/Solution-ServiceConfig.rb', line 81

def sid
  return @sid unless @sid.nil?
  @sid = sid_for_name(@serviceName)
end

#sid_for_name(name) ⇒ Object



75
76
77
78
79
# File 'lib/MrMurano/Solution-ServiceConfig.rb', line 75

def sid_for_name(name)
  name = name.to_s unless name.kind_of? String
  scr = list().select{|i| i[:alias] == name}.first
  scr[:id]
end