debian-mirror-gitlab/lib/api/namespaces.rb
2017-09-10 17:25:29 +05:30

24 lines
642 B
Ruby

module API
class Namespaces < Grape::API
include PaginationParams
before { authenticate! }
resource :namespaces do
desc 'Get a namespaces list' do
success Entities::Namespace
end
params do
optional :search, type: String, desc: "Search query for namespaces"
use :pagination
end
get do
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