Class: Api::V2::RhCloud::InventoryController
Instance Method Summary
collapse
#start_inventory_sync
#report_file, #start_report_generation
Instance Method Details
#download_file ⇒ Object
14
15
16
17
18
19
20
|
# File 'app/controllers/api/v2/rh_cloud/inventory_controller.rb', line 14
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
74
75
76
77
|
# File 'app/controllers/api/v2/rh_cloud/inventory_controller.rb', line 74
def enable_cloud_connector
cloud_connector = ForemanRhCloud::CloudConnector.new
render json: cloud_connector.install.to_json
end
|
#generate_report ⇒ Object
25
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/api/v2/rh_cloud/inventory_controller.rb', line 25
def generate_report
organization_id = params[:organization_id]
disconnected = params[:no_upload] || false
start_report_generation(organization_id, disconnected)
render json: {
action_status: 'success',
}, status: :ok
end
|
#get_hosts ⇒ Object
38
39
40
41
42
43
|
# File 'app/controllers/api/v2/rh_cloud/inventory_controller.rb', line 38
def get_hosts
organization_id = params[:organization_id]
payload = InsightsMissingHosts.where(organization_id: organization_id)
render :json => payload
end
|
#remove_hosts ⇒ Object
48
49
50
51
52
53
54
55
56
57
|
# File 'app/controllers/api/v2/rh_cloud/inventory_controller.rb', line 48
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
61
62
63
64
65
66
67
68
69
70
71
|
# File 'app/controllers/api/v2/rh_cloud/inventory_controller.rb', line 61
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
|