gitlab-org--gitlab-foss/lib/api/namespaces.rb

24 lines
617 B
Ruby

module API
# namespaces API
class Namespaces < Grape::API
before { authenticate! }
resource :namespaces do
# Get a namespaces list
#
# Example Request:
# GET /namespaces
get do
@namespaces = if current_user.admin
Namespace.all
else
current_user.namespaces
end
@namespaces = @namespaces.search(params[:search]) if params[:search].present?
@namespaces = paginate @namespaces
present @namespaces, with: Entities::Namespace
end
end
end
end