debian-mirror-gitlab/lib/api/namespaces.rb

37 lines
966 B
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2014-09-02 18:07:02 +05:30
module API
class Namespaces < Grape::API
2017-08-17 22:00:37 +05:30
include PaginationParams
2015-09-11 14:41:01 +05:30
before { authenticate! }
2014-09-02 18:07:02 +05:30
resource :namespaces do
2016-11-03 12:29:30 +05:30
desc 'Get a namespaces list' do
success Entities::Namespace
end
params do
optional :search, type: String, desc: "Search query for namespaces"
2017-08-17 22:00:37 +05:30
use :pagination
2016-11-03 12:29:30 +05:30
end
2014-09-02 18:07:02 +05:30
get do
2016-11-03 12:29:30 +05:30
namespaces = current_user.admin ? Namespace.all : current_user.namespaces
namespaces = namespaces.search(params[:search]) if params[:search].present?
2014-09-02 18:07:02 +05:30
2017-09-10 17:25:29 +05:30
present paginate(namespaces), with: Entities::Namespace, current_user: current_user
2014-09-02 18:07:02 +05:30
end
2018-03-17 18:26:18 +05:30
desc 'Get a namespace by ID' do
success Entities::Namespace
end
params do
requires :id, type: String, desc: "Namespace's ID or path"
end
get ':id' do
present user_namespace, with: Entities::Namespace, current_user: current_user
end
2014-09-02 18:07:02 +05:30
end
end
end