protected
+ ActionNameMap = {
+ 'destroy' => 'delete',
+ 'index' => 'list',
+ 'show' => 'get',
+ }
+
def discovery_doc
Rails.application.eager_load!
remoteHosts = {}
"https://api.arvados.org/auth/arvados.readonly"
]
},
- index: {
- id: "arvados.#{k.to_s.underscore.pluralize}.index",
+ list: {
+ id: "arvados.#{k.to_s.underscore.pluralize}.list",
path: k.to_s.underscore.pluralize,
httpMethod: "GET",
description:
- %|Index #{k.to_s.pluralize}.
+ %|List #{k.to_s.pluralize}.
- The <code>index</code> method returns a
+ The <code>list</code> method returns a
<a href="/api/resources.html">resource list</a> of
matching #{k.to_s.pluralize}. For example:
httpMethod = ['GET', 'POST', 'PUT', 'DELETE'].map { |method|
method if route.verb.match(method)
}.compact.first
- if httpMethod and
- route.defaults[:controller] == 'arvados/v1/' + k.to_s.underscore.pluralize and
- ctl_class.action_methods.include? action
- if !d_methods[action.to_sym]
+ if httpMethod &&
+ route.defaults[:controller] == 'arvados/v1/' + k.to_s.underscore.pluralize &&
+ ctl_class.action_methods.include?(action)
+ method_name = ActionNameMap[action] || action
+ method_key = method_name.to_sym
+ if !d_methods[method_key]
method = {
- id: "arvados.#{k.to_s.underscore.pluralize}.#{action}",
+ id: "arvados.#{k.to_s.underscore.pluralize}.#{method_name}",
path: route.path.spec.to_s.sub('/arvados/v1/','').sub('(.:format)','').sub(/:(uu)?id/,'{uuid}'),
httpMethod: httpMethod,
- description: "#{action} #{k.to_s.underscore.pluralize}",
+ description: "#{method_name} #{k.to_s.underscore.pluralize}",
parameters: {},
response: {
- "$ref" => (action == 'index' ? "#{k.to_s}List" : k.to_s)
+ "$ref" => (method_name == 'list' ? "#{k.to_s}List" : k.to_s)
},
scopes: [
"https://api.arvados.org/auth/arvados"
# We already built a generic method description, but we
# might find some more required parameters through
# introspection.
- method = d_methods[action.to_sym]
+ method = d_methods[method_key]
end
if ctl_class.respond_to? "_#{action}_requires_parameters".to_sym
ctl_class.send("_#{action}_requires_parameters".to_sym).each do |l, v|
end
end
end
- d_methods[action.to_sym] = method
-
- if action == 'index'
- list_method = method.dup
- list_method[:id].sub!('index', 'list')
- list_method[:description].sub!('Index', 'List')
- list_method[:description].sub!('index', 'list')
- d_methods[:list] = list_method
- end
+ d_methods[method_key] = method
end
end
end