Sha256: fe1cdfd2ccfe82928f1bbf44e24be20b00934626d435378ab942d3dcdb20d458

Contents?: true

Size: 1.36 KB

Versions: 20

Compression:

Stored size: 1.36 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],
        allowAutoInsightsMismatchDelete: Setting[:allow_auto_insights_mismatch_delete],
        CloudConnectorStatus: ForemanInventoryUpload::UploadsSettingsController.cloud_connector_status,
        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

20 entries across 20 versions & 1 rubygems

Version Path
foreman_rh_cloud-9.0.59 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-11.0.2 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-11.0.1 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-11.0.0 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-9.0.58 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-10.0.2 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-9.0.57 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-10.0.1 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-9.0.56 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-9.0.55 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-9.0.54 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-9.0.53 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-9.0.52 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-8.0.52 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-9.0.51 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-8.0.51 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-8.0.50 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-8.0.49 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-8.0.48 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb
foreman_rh_cloud-8.0.47 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb