Sha256: fa5dd28cda85996d0fdbdd5e5ecfb146fc7aabc2a84e43f754902347757b9a2b

Contents?: true

Size: 1.25 KB

Versions: 16

Compression:

Stored size: 1.25 KB

Contents

module MnoEnterprise
  class Jpi::V1::AppInstancesSyncController < Jpi::V1::BaseResourceController
    CONNECTOR_STATUS_RUNNING = ['PENDING', 'RUNNING']

    # GET /mnoe/jpi/v1/organization/org-fbba/app_instances_sync
    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

    # POST /mnoe/jpi/v1/organizations/org-fbba/app_instances_sync
    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

    private
      def results(connectors)
        {
          connectors: connectors,
          is_syncing: connectors.any? { |c| CONNECTOR_STATUS_RUNNING.include?(c[:status]) }
        }
      end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
mno-enterprise-api-3.3.2 app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb
mno-enterprise-api-3.2.1 app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb
mno-enterprise-api-3.3.1 app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb
mno-enterprise-api-3.3.0 app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb
mno-enterprise-api-3.2.0 app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb
mno-enterprise-api-3.1.4 app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb
mno-enterprise-api-3.0.7 app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb
mno-enterprise-api-2.0.9 app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb
mno-enterprise-api-3.1.3 app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb
mno-enterprise-api-3.0.6 app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb
mno-enterprise-api-2.0.8 app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb
mno-enterprise-api-3.1.2 app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb
mno-enterprise-api-3.0.5 app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb
mno-enterprise-api-2.0.7 app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb
mno-enterprise-api-2.0.6 app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb
mno-enterprise-api-2.0.5 app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb