summaryrefslogtreecommitdiff
path: root/lib/api/namespaces.rb
diff options
context:
space:
mode:
authorRubén Dávila <ruben@gitlab.com>2018-12-07 08:29:53 -0500
committerRubén Dávila <ruben@gitlab.com>2018-12-07 08:29:53 -0500
commitb2cf4b9525f41b2de7c96c493d0fe296760a736b (patch)
tree5424623f4e6092ed8a610adef45a59a4003271b6 /lib/api/namespaces.rb
parenta2e06ad3034cd1e007b78514a5c1f47feef7b648 (diff)
downloadgitlab-ce-b2cf4b9525f41b2de7c96c493d0fe296760a736b.tar.gz
Backports some changes from gitlab-ee!7885
Diffstat (limited to 'lib/api/namespaces.rb')
-rw-r--r--lib/api/namespaces.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/api/namespaces.rb b/lib/api/namespaces.rb
index 06a57e3cd6f..3cc09f6ac3f 100644
--- a/lib/api/namespaces.rb
+++ b/lib/api/namespaces.rb
@@ -6,20 +6,35 @@ module API
before { authenticate! }
+ helpers do
+ params :optional_list_params_ee do
+ # EE::API::Namespaces would override this helper
+ end
+
+ # EE::API::Namespaces would override this method
+ def custom_namespace_present_options
+ {}
+ end
+ end
+
resource :namespaces do
desc 'Get a namespaces list' do
success Entities::Namespace
end
params do
optional :search, type: String, desc: "Search query for namespaces"
+
use :pagination
+ use :optional_list_params_ee
end
get do
namespaces = current_user.admin ? Namespace.all : current_user.namespaces
namespaces = namespaces.search(params[:search]) if params[:search].present?
- present paginate(namespaces), with: Entities::Namespace, current_user: current_user
+ options = { with: Entities::Namespace, current_user: current_user }
+
+ present paginate(namespaces), options.reverse_merge(custom_namespace_present_options)
end
desc 'Get a namespace by ID' do