Skip to content
This repository was archived by the owner on Aug 28, 2023. It is now read-only.

Commit d6d5a52

Browse files
committed
Add payload download action.
1 parent bfc2122 commit d6d5a52

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

app/controllers/api/red_hat_migration_analytics_controller.rb

+18
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,24 @@ def reset_manifest_collection(type, data)
5050
end
5151
end
5252

53+
def payload_collection(type, data)
54+
check_feature_enabled
55+
task_id = data['task_id']
56+
raise "Must specify a task id via \"task_id\"" if task_id.blank?
57+
58+
begin
59+
task = MiqTask.find(task_id)
60+
path = task&.context_data&.payload_path
61+
if path && File.exist?(path)
62+
send_file(path, :type => 'application/binary', :filename => 'analytics_payload.bin')
63+
else
64+
raise "Payload not found."
65+
end
66+
rescue ActiveRecord::RecordNotFound => e
67+
action_result(false, e.to_s)
68+
end
69+
end
70+
5371
private
5472

5573
def check_feature_enabled

config/api.yml

+3
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@
1919
:identifier: red_hat_migration_analytics
2020
- :name: reset_manifest
2121
:identifier: red_hat_migration_analytics
22+
- :name: payload
23+
:identifier: red_hat_migration_analytics
24+
2225

0 commit comments

Comments
 (0)