module MiqAeMethodService
  class MiqAeServiceServiceTemplate < MiqAeServiceModelBase
    expose :service_templates, :association => true
    expose :services,          :association => true
    expose :service_resources, :association => true
    expose :tenant,            :association => true
    expose :provision_request

    def owner=(owner)
      if owner.nil? || owner.kind_of?(MiqAeMethodService::MiqAeServiceUser)
        if owner.nil?
          @object.evm_owner = nil
        else
          @object.evm_owner = User.find_by_id(owner.id)
        end
        @object.save
      end
    end

    def group=(group)
      if group.nil? || group.kind_of?(MiqAeMethodService::MiqAeServiceMiqGroup)
        if group.nil?
          @object.miq_group = nil
        else
          @object.miq_group = MiqGroup.find_by_id(group.id)
        end
        @object.save
      end
    end
  end
end

module MiqAeMethodService
  class MiqAeServiceServiceTemplate < MiqAeServiceModelBase
    expose :service_templates, :association => true
    expose :services,          :association => true
    expose :service_resources, :association => true
    expose :tenant,            :association => true
    expose :provision_request

    def owner=(owner)
      if owner.nil? || owner.kind_of?(MiqAeMethodService::MiqAeServiceUser)
        if owner.nil?
          @object.evm_owner = nil
        else
          @object.evm_owner = User.find_by_id(owner.id)
        end
        @object.save
      end
    end

    def group=(group)
      if group.nil? || group.kind_of?(MiqAeMethodService::MiqAeServiceMiqGroup)
        if group.nil?
          @object.miq_group = nil
        else
          @object.miq_group = MiqGroup.find_by_id(group.id)
        end
        @object.save
      end
    end

    def provision_request(user, options)
      ar_method do
        wrap_results(@object.provision_request(user.instance_variable_get("@object"), options))
      end
    end
  end
end

Use user object instead of userid
Use user object instead of userid


(transferred from ManageIQ/manageiq@bc8f06be80d4efcaa5b29a1e54c279a9132b84da)
