Class: Api::V2::RhCloud::InventoryController
  
  
  
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  
  #start_inventory_sync
  
  
  
  
  
  
  
  
  
  
  #report_file, #start_report_generation
  
  
  
  
    Instance Method Details
    
      
  
  
    #download_file  ⇒ Object 
  
  
  
  
    
      
11
12
13
14
15
16
17 
     | 
    
      # File 'app/controllers/api/v2/rh_cloud/inventory_controller.rb', line 11
def download_file
  filename, file = report_file(params[:organization_id])
  send_file file, disposition: 'attachment', filename: filename
rescue InventoryUpload::ReportActions::ReportMissingError => error
  render json: { message: error.message }, status: :not_found
end
     | 
  
 
    
      
  
  
    #enable_cloud_connector  ⇒ Object 
  
  
  
  
    
      
71
72
73
74 
     | 
    
      # File 'app/controllers/api/v2/rh_cloud/inventory_controller.rb', line 71
def enable_cloud_connector
  cloud_connector = ForemanRhCloud::CloudConnector.new
  render json: cloud_connector.install.to_json
end 
     | 
  
 
    
      
  
  
    #generate_report  ⇒ Object 
  
  
  
  
    
      
22
23
24
25
26
27
28
29
30
31 
     | 
    
      # File 'app/controllers/api/v2/rh_cloud/inventory_controller.rb', line 22
def generate_report
  organization_id = params[:organization_id]
  disconnected = params[:disconnected] || false
  start_report_generation(organization_id, disconnected)
  render json: {
    action_status: 'success',
  }, status: :ok
end
     | 
  
 
    
      
  
  
    #get_hosts  ⇒ Object 
  
  
  
  
    
      
35
36
37
38
39
40 
     | 
    
      # File 'app/controllers/api/v2/rh_cloud/inventory_controller.rb', line 35
def get_hosts
  organization_id = params[:organization_id]
  payload = InsightsMissingHosts.where(organization_id: organization_id)
  render :json => payload
end 
     | 
  
 
    
      
  
  
    #remove_hosts  ⇒ Object 
  
  
  
  
    
      
45
46
47
48
49
50
51
52
53
54 
     | 
    
      # File 'app/controllers/api/v2/rh_cloud/inventory_controller.rb', line 45
def remove_hosts
  organization_id = params[:organization_id]
  search_term = params[:search_term]
  task = ForemanTasks.async_task(ForemanInventoryUpload::Async::RemoveInsightsHostsJob, search_term, organization_id)
  render json: {
    task: task,
  }, status: :ok
end
     | 
  
 
    
      
  
  
    #sync_inventory_status  ⇒ Object 
  
  
  
  
    
      
58
59
60
61
62
63
64
65
66
67
68 
     | 
    
      # File 'app/controllers/api/v2/rh_cloud/inventory_controller.rb', line 58
def sync_inventory_status
  selected_org = Organization.find(params[:organization_id])
  task = start_inventory_sync(selected_org)
  render json: {
    task: task,
  }, status: :ok
rescue InventoryUpload::TaskActions::NothingToSyncError => error
  render json: { message: error.message }, status: :bad_request
end
     |