Commit 0759dd4513c0190b80058d4851e2bde36cbaede6
1 parent
77e3fab8
Exists in
master
and in
4 other branches
Namespaces API for admin users
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
3 changed files
with
28 additions
and
0 deletions
Show diff stats
lib/api/api.rb
lib/api/entities.rb
@@ -136,5 +136,9 @@ module API | @@ -136,5 +136,9 @@ module API | ||
136 | expose :target_id, :target_type, :author_id | 136 | expose :target_id, :target_type, :author_id |
137 | expose :data, :target_title | 137 | expose :data, :target_title |
138 | end | 138 | end |
139 | + | ||
140 | + class Namespace < Grape::Entity | ||
141 | + expose :id, :path, :kind | ||
142 | + end | ||
139 | end | 143 | end |
140 | end | 144 | end |
@@ -0,0 +1,23 @@ | @@ -0,0 +1,23 @@ | ||
1 | +module API | ||
2 | + # namespaces API | ||
3 | + class Namespaces < Grape::API | ||
4 | + before { | ||
5 | + authenticate! | ||
6 | + authenticated_as_admin! | ||
7 | + } | ||
8 | + | ||
9 | + resource :namespaces do | ||
10 | + # Get a namespaces list | ||
11 | + # | ||
12 | + # Example Request: | ||
13 | + # GET /namespaces | ||
14 | + get do | ||
15 | + @namespaces = Namespace.scoped | ||
16 | + @namespaces = @namespaces.search(params[:search]) if params[:search].present? | ||
17 | + @namespaces = paginate @namespaces | ||
18 | + | ||
19 | + present @namespaces, with: Entities::Namespace | ||
20 | + end | ||
21 | + end | ||
22 | + end | ||
23 | +end |