Class: Katello::Api::V2::RootController

Inherits:
ApiController
  • Object
show all
Defined in:
app/controllers/katello/api/v2/root_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiController

#check_katello_agent_not_disabled, #deprecate_katello_agent, #empty_search_query?, #full_result_response, #katello_agent_removal_release, #resource_class, #scoped_search, #skip_session

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

#api_version

Class Method Details

.generate_rhsm_resource_listObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/katello/api/v2/root_controller.rb', line 25

def self.generate_rhsm_resource_list
  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 } }
end

.rhsm_resource_listObject



21
22
23
# File 'app/controllers/katello/api/v2/root_controller.rb', line 21

def self.rhsm_resource_list
  @rhsm_resource_list ||= generate_rhsm_resource_list
end

Instance Method Details

#rhsm_resource_listObject



12
13
14
15
16
17
18
19
# File 'app/controllers/katello/api/v2/root_controller.rb', line 12

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)

  render json: self.class.rhsm_resource_list
end