Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes #15159 - Api request fails for environments -> repositories (#6061
)
  • Loading branch information
ranjan authored and jlsherrill committed May 26, 2016
1 parent 5de5cf3 commit 195b9a6
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
16 changes: 0 additions & 16 deletions app/controllers/katello/api/v2/environments_controller.rb
Expand Up @@ -136,22 +136,6 @@ def paths
respond_for_index(:collection => collection, :template => :paths)
end

api :GET, "/organizations/:organization_id/environments/:id/repositories", "List repositories available in the environment"
param :id, :identifier, :desc => "environment identifier"
param :organization_id, String, :desc => "organization identifier"
param :content_view_id, :identifier, :desc => "content view identifier", :required => false
def repositories
if !@environment.library? && @content_view.nil?
fail HttpErrors::BadRequest,
_("Cannot retrieve repos from non-library environment '%s' without a content view.") % @environment.name
end

@repositories = @environment.products.readable(@organization).flat_map do |p|
p.repos(@environment, @content_view)
end
respond_for_index :collection => @repositories
end

protected

def find_environment
Expand Down
1 change: 1 addition & 0 deletions app/controllers/katello/api/v2/repositories_controller.rb
Expand Up @@ -36,6 +36,7 @@ class Api::V2::RepositoriesController < Api::V2::ApiController

api :GET, "/repositories", N_("List of enabled repositories")
api :GET, "/content_views/:id/repositories", N_("List of repositories for a content view")
api :GET, "/organizations/:organization_id/environments/:environment_id/repositories", _("List repositories in the environment")
param :organization_id, :number, :desc => N_("ID of an organization to show repositories in")
param :product_id, :number, :desc => N_("ID of a product to show repositories of")
param :environment_id, :number, :desc => N_("ID of an environment to show repositories in")
Expand Down
1 change: 1 addition & 0 deletions config/routes/api/v2.rb
Expand Up @@ -155,6 +155,7 @@ class ActionDispatch::Routing::Mapper
api_resources :activation_keys, :only => [:index]
api_resources :content_views, :only => [:index, :create]
api_resources :environments, :only => [:index, :show, :create, :update, :destroy] do
api_resources :repositories, :only => [:index]
collection do
get :paths
get :auto_complete_search
Expand Down

0 comments on commit 195b9a6

Please sign in to comment.