diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-11-15 15:24:10 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-11-15 15:24:10 +0200 |
commit | 0759dd4513c0190b80058d4851e2bde36cbaede6 (patch) | |
tree | 9f64dbbcd60e2da3c8d35ec038d71dcf2977a3d1 /lib | |
parent | 77e3fab89f633b70a0f805cce94d09304ad893e2 (diff) | |
download | gitlab-ce-0759dd4513c0190b80058d4851e2bde36cbaede6.tar.gz |
Namespaces API for admin users
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/api.rb | 1 | ||||
-rw-r--r-- | lib/api/entities.rb | 4 | ||||
-rw-r--r-- | lib/api/namespaces.rb | 23 |
3 files changed, 28 insertions, 0 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb index 45efcc8cd47..283f7642f67 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -40,5 +40,6 @@ module API mount ProjectHooks mount Services mount Files + mount Namespaces end end diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 429083d75be..2bdcbdc8c7f 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -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 diff --git a/lib/api/namespaces.rb b/lib/api/namespaces.rb new file mode 100644 index 00000000000..3a9ab66957e --- /dev/null +++ b/lib/api/namespaces.rb @@ -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 |