2014-09-02 18:07:02 +05:30
|
|
|
module API
|
|
|
|
# namespaces API
|
|
|
|
class Namespaces < Grape::API
|
2015-09-11 14:41:01 +05:30
|
|
|
before { authenticate! }
|
2014-09-02 18:07:02 +05:30
|
|
|
|
|
|
|
resource :namespaces do
|
|
|
|
# Get a namespaces list
|
|
|
|
#
|
|
|
|
# Example Request:
|
|
|
|
# GET /namespaces
|
|
|
|
get do
|
2015-09-11 14:41:01 +05:30
|
|
|
@namespaces = if current_user.admin
|
|
|
|
Namespace.all
|
|
|
|
else
|
|
|
|
current_user.namespaces
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
@namespaces = @namespaces.search(params[:search]) if params[:search].present?
|
|
|
|
@namespaces = paginate @namespaces
|
|
|
|
|
|
|
|
present @namespaces, with: Entities::Namespace
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|