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

25 lines
642 B
Ruby
Raw Normal View History

module API
class Namespaces < Grape::API
2016-12-04 12:11:19 -05:00
include PaginationParams
before { authenticate! }
resource :namespaces do
2016-09-13 14:55:26 -04:00
desc 'Get a namespaces list' do
success Entities::Namespace
end
params do
optional :search, type: String, desc: "Search query for namespaces"
2016-12-04 12:11:19 -05:00
use :pagination
2016-09-13 14:55:26 -04:00
end
get do
2016-09-13 14:55:26 -04:00
namespaces = current_user.admin ? Namespace.all : current_user.namespaces
namespaces = namespaces.search(params[:search]) if params[:search].present?
present paginate(namespaces), with: Entities::Namespace, current_user: current_user
end
end
end
end