module MnoEnterprise::Concerns::Controllers::Jpi::V1::AppInstancesController

Public Instance Methods

create() click to toggle source

POST /mnoe/jpi/v1/organization/1/app_instances

# File lib/mno_enterprise/concerns/controllers/jpi/v1/app_instances_controller.rb, line 26
def create
  authorize! :manage_app_instances, parent_organization
  app_instance = parent_organization.app_instances.create(product: params[:nid])
  MnoEnterprise::EventLogger.info('app_add', current_user.id, 'App added', app_instance)
  head :created
end
destroy() click to toggle source

DELETE /mnoe/jpi/v1/app_instances/1

# File lib/mno_enterprise/concerns/controllers/jpi/v1/app_instances_controller.rb, line 34
def destroy
  app_instance = MnoEnterprise::AppInstance.find(params[:id])

  if app_instance
    authorize! :manage_app_instances, app_instance.owner
    MnoEnterprise::EventLogger.info('app_destroy', current_user.id, 'App destroyed', app_instance)
    app_instance.terminate
  end

  head :accepted
end
index() click to toggle source
Instance methods
GET /mnoe/jpi/v1/organization/1/apps.json?timestamp=151452452345
# File lib/mno_enterprise/concerns/controllers/jpi/v1/app_instances_controller.rb, line 17
def index
  @app_instances = parent_organization.app_instances.active.where("updated_at.gt" => Time.at(timestamp)).select do |i|
    # force owner assignment to avoid a refetch in ability can?(:access,i)
    i.owner = parent_organization
    can?(:access,i)
  end
end