BigW Consortium Gitlab

namespaces.rb 617 Bytes
Newer Older
1 2 3
module API
  # namespaces API
  class Namespaces < Grape::API
4
    before { authenticate! }
5 6 7 8 9 10 11

    resource :namespaces do
      # Get a namespaces list
      #
      # Example Request:
      #  GET /namespaces
      get do
12 13 14 15 16
        @namespaces = if current_user.admin
                        Namespace.all
                      else
                        current_user.namespaces
                      end
17 18 19 20 21 22 23 24
        @namespaces = @namespaces.search(params[:search]) if params[:search].present?
        @namespaces = paginate @namespaces

        present @namespaces, with: Entities::Namespace
      end
    end
  end
end