Sha256: a7c18e15aaec1536c1456e79db931cb466c2cec642c16e51ecf648d81ed42d34

Contents?: true

Size: 1.33 KB

Versions: 37

Compression:

Stored size: 1.33 KB

Contents

module ForemanInventoryUpload
  class UploadsSettingsController < ::ApplicationController
    def index
      render json: {
        autoUploadEnabled: Setting[:allow_auto_inventory_upload],
        hostObfuscationEnabled: Setting[:obfuscate_inventory_hostnames],
        ipsObfuscationEnabled: Setting[:obfuscate_inventory_ips],
        excludePackagesEnabled: Setting[:exclude_installed_packages],
        CloudConnectorStatus: ForemanInventoryUpload::UploadsSettingsController.cloud_connector_status,
        cloudToken: !Setting[:rh_cloud_token].empty?,
        lastSyncTask: last_successful_inventory_sync_task,
      }, status: :ok
    end

    def set_advanced_setting
      Setting[params.require(:setting)] = ActiveModel::Type::Boolean.new.cast(params.require(:value))
      index
    end

    def self.cloud_connector_status
      cloud_connector = ForemanRhCloud::CloudConnector.new
      job = cloud_connector&.latest_job
      return nil unless job
      { id: job.id, task: ForemanTasks::Task.where(:id => job.task_id).first }
    end

    def last_successful_inventory_sync_task
      task = ForemanTasks::Task.where(label: 'InventorySync::Async::InventoryFullSync', result: 'success')
                        .reorder('ended_at desc').first
      return nil unless task
      { output: task.output, endedAt: task.ended_at }
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
foreman_rh_cloud-4.0.36 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-3.0.33 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-4.0.35 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-5.0.35 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-5.0.34 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-5.0.33 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-3.0.32 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-4.0.32 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-5.0.32 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-4.0.31 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-5.0.31 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-5.0.30 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-4.0.30 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-3.0.29 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-4.0.29 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-5.0.29 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-3.0.28 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-5.0.28 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-4.0.27 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-3.0.26 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb