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 Services
mount Files
mount Namespaces
end
end

View File

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