summaryrefslogtreecommitdiff
path: root/lib/api/namespaces.rb
diff options
context:
space:
mode:
authorZ.J. van de Weg <zegerjan@gitlab.com>2016-09-13 20:55:26 +0200
committerZ.J. van de Weg <zegerjan@gitlab.com>2016-10-04 07:47:29 +0200
commitd6e42e0ca1ab9962b7d43517c6f6beab5f1ade1c (patch)
tree8e6536627970639b683ddb8c71a4123ab35ce684 /lib/api/namespaces.rb
parent4be63f5b5bd9c0859f5ba2b91ecdbdcc57b69b98 (diff)
downloadgitlab-ce-d6e42e0ca1ab9962b7d43517c6f6beab5f1ade1c.tar.gz
GrapeDSL for Namespace endpointzj-grape-sessions
Diffstat (limited to 'lib/api/namespaces.rb')
-rw-r--r--lib/api/namespaces.rb22
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/api/namespaces.rb b/lib/api/namespaces.rb
index 50d3729449e..fe981d7b9fa 100644
--- a/lib/api/namespaces.rb
+++ b/lib/api/namespaces.rb
@@ -4,20 +4,18 @@ module API
before { authenticate! }
resource :namespaces do
- # Get a namespaces list
- #
- # Example Request:
- # GET /namespaces
+ desc 'Get a namespaces list' do
+ success Entities::Namespace
+ end
+ params do
+ optional :search, type: String, desc: "Search query for namespaces"
+ end
get do
- @namespaces = if current_user.admin
- Namespace.all
- else
- current_user.namespaces
- end
- @namespaces = @namespaces.search(params[:search]) if params[:search].present?
- @namespaces = paginate @namespaces
+ namespaces = current_user.admin ? Namespace.all : current_user.namespaces
+
+ namespaces = namespaces.search(params[:search]) if params[:search].present?
- present @namespaces, with: Entities::Namespace
+ present paginate(namespaces), with: Entities::Namespace
end
end
end