Namespaces API for admin users

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2013-11-15 15:24:10 +02:00
parent 77e3fab89f
commit 0759dd4513
No known key found for this signature in database
GPG key ID: 2CEAFD2671262EC2
3 changed files with 28 additions and 0 deletions

View file

@ -40,5 +40,6 @@ module API
mount ProjectHooks mount ProjectHooks
mount Services mount Services
mount Files mount Files
mount Namespaces
end end
end end

View file

@ -136,5 +136,9 @@ module API
expose :target_id, :target_type, :author_id expose :target_id, :target_type, :author_id
expose :data, :target_title expose :data, :target_title
end end
class Namespace < Grape::Entity
expose :id, :path, :kind
end
end end
end end

23
lib/api/namespaces.rb Normal file
View file

@ -0,0 +1,23 @@
module API
# namespaces API
class Namespaces < Grape::API
before {
authenticate!
authenticated_as_admin!
}
resource :namespaces do
# Get a namespaces list
#
# Example Request:
# GET /namespaces
get do
@namespaces = Namespace.scoped
@namespaces = @namespaces.search(params[:search]) if params[:search].present?
@namespaces = paginate @namespaces
present @namespaces, with: Entities::Namespace
end
end
end
end