Class: Jpi::V1::AppInstancesSyncController

Inherits:
BaseResourceController
  • Object
show all
Defined in:
app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb

Constant Summary collapse

CONNECTOR_STATUS_RUNNING =
['PENDING', 'RUNNING']

Instance Method Summary collapse

Instance Method Details

#createObject

POST /mnoe/jpi/v1/organizations/org-fbba/app_instances_sync



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb', line 14

def create
  authorize! :sync_apps, @parent_organization

  # Some weird behaviour with Her and has_one. If app_instances_sync.find is called somewhere before the create,
  # Her won't detect the organization_id as dirty and won't submit it.
  sync = @parent_organization.app_instances_sync.build(mode: params[:mode])
  sync.organization_id_will_change!
  sync.save

  connectors = sync.connectors

  render json: results(connectors)
end

#indexObject

GET /mnoe/jpi/v1/organization/org-fbba/app_instances_sync



6
7
8
9
10
11
# File 'app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb', line 6

def index
  authorize! :check_apps_sync, @parent_organization
  # find method is overriden in the mnoe interface to call organization.check_sync_apps_progress
  connectors = @parent_organization.app_instances_sync.find('anything').connectors
  render json: results(connectors)
end