Class: Katello::Api::V2::RootController
- Inherits:
-
ApiController
- Object
- Api::V2::BaseController
- ApiController
- Katello::Api::V2::RootController
- Defined in:
- app/controllers/katello/api/v2/root_controller.rb
Instance Method Summary collapse
Methods inherited from ApiController
#full_result_response, #resource_class, #scoped_search
Methods included from Rendering
#respond_for_async, #respond_for_bulk_async, #respond_for_create, #respond_for_destroy, #respond_for_index, #respond_for_show, #respond_for_status, #respond_for_update, #respond_with_template, #respond_with_template_collection, #respond_with_template_resource, #try_specific_collection_template, #try_specific_resource_template
Methods included from Katello::Api::Version2
Instance Method Details
#resource_list ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/katello/api/v2/root_controller.rb', line 11 def resource_list all_routes = Engine.routes.routes all_routes = all_routes.collect { |r| r.path.spec.to_s } api_root_routes = all_routes.select do |path| path =~ %r{^/katello/api(\(/:api_version\))?/[^/]+/:id\(\.:format\)$} end api_root_routes = api_root_routes.collect do |path| path = path.sub("(/:api_version)", "") path[0..-(":id(.:format)".length + 1)] end api_root_routes.collect! { |r| { :rel => r["/katello/api/".size..-2], :href => r } } respond_for_index :collection => api_root_routes end |
#rhsm_resource_list ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/katello/api/v2/root_controller.rb', line 28 def rhsm_resource_list # The RHSM resource list is required to interact with RHSM on the client. # When requested, it will return a list of the resources (href & rel) defined by katello # for the /rhsm namespace. The rel values are used by RHSM to determine if the server # supports a particular resource (e.g. environments, guestids, organizations..etc) all_routes = Engine.routes.routes.collect { |r| r.path.spec.to_s } api_routes = all_routes.select do |path| # obtain only the rhsm routes path =~ %r{^/rhsm/.+$} end api_routes = api_routes.collect do |path| # drop the trailing :format path = path.sub("(.:format)", "") # drop the trailing ids path_elements = path.split("/") if path_elements.last.start_with?(':') && path_elements.last.end_with?('id') path_elements.delete_at(-1) path_elements.join('/') else path end end api_routes.uniq! api_routes.collect! { |r| { :rel => r.split('/').last, :href => r } } respond_for_index :collection => api_routes, :template => 'resource_list' end |