gitlab-org--gitlab-foss/lib/api/namespaces.rb
2016-10-04 07:47:29 +02:00

22 lines
579 B
Ruby

module API
# namespaces API
class Namespaces < Grape::API
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"
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
end
end
end
end