Namespaces API for admin users
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
77e3fab89f
commit
0759dd4513
3 changed files with 28 additions and 0 deletions
|
@ -40,5 +40,6 @@ module API
|
||||||
mount ProjectHooks
|
mount ProjectHooks
|
||||||
mount Services
|
mount Services
|
||||||
mount Files
|
mount Files
|
||||||
|
mount Namespaces
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
23
lib/api/namespaces.rb
Normal 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
|
Loading…
Reference in a new issue