summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/api/api.rb1
-rw-r--r--lib/api/entities.rb4
-rw-r--r--lib/api/namespaces.rb23
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