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
... | ... | @@ -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 | ... | ... |