2013-11-15 08:24:10 -05:00
|
|
|
module API
|
|
|
|
# namespaces API
|
|
|
|
class Namespaces < Grape::API
|
2015-05-25 16:51:37 -04:00
|
|
|
before { authenticate! }
|
2013-11-15 08:24:10 -05:00
|
|
|
|
|
|
|
resource :namespaces do
|
|
|
|
# Get a namespaces list
|
|
|
|
#
|
|
|
|
# Example Request:
|
|
|
|
# GET /namespaces
|
|
|
|
get do
|
2015-05-25 16:51:37 -04:00
|
|
|
@namespaces = if current_user.admin
|
|
|
|
Namespace.all
|
|
|
|
else
|
|
|
|
current_user.namespaces
|
|
|
|
end
|
2013-11-15 08:24:10 -05:00
|
|
|
@namespaces = @namespaces.search(params[:search]) if params[:search].present?
|
|
|
|
@namespaces = paginate @namespaces
|
|
|
|
|
|
|
|
present @namespaces, with: Entities::Namespace
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|