def index
      if params[:terms]
        # Search mode
        @users = []
        JSON.parse(params[:terms]).map { |t| @users = @users | MnoEnterprise::User.where(Hash[*t]).fetch }
        response.headers['X-Total-Count'] = @users.count
      else
        # Index mode
        query = MnoEnterprise::User
        query = query.limit(params[:limit]) if params[:limit]
        query = query.skip(params[:offset]) if params[:offset]
        query = query.order_by(params[:order_by]) if params[:order_by]
        query = query.where(params[:where]) if params[:where]
        all = query.all
        all.params[:sub_tenant_id] = params[:sub_tenant_id]
        all.params[:account_manager_id] = params[:account_manager_id]

        @users = all.fetch

        response.headers['X-Total-Count'] = @users.metadata[:pagination][:count]
      end
    end
def index
      if params[:terms]
        # Search mode
        @users = []
        JSON.parse(params[:terms]).map { |t| @users = @users | MnoEnterprise::User.where(Hash[*t]).fetch }
        response.headers['X-Total-Count'] = @users.count
      else
        # Index mode
        query = MnoEnterprise::User
        query = query.limit(params[:limit]) if params[:limit]
        query = query.skip(params[:offset]) if params[:offset]
        query = query.order_by(params[:order_by]) if params[:order_by]
        query = query.where(params[:where]) if params[:where]
        all = query.all
        all.params[:sub_tenant_id] = params[:sub_tenant_id]
        all.params[:account_manager_id] = params[:account_manager_id]

        @users = all.fetch

        response.headers['X-Total-Count'] = @users.metadata[:pagination][:count]
      end
    end
GET /mnoe/jpi/v1/admin/users