Class: RedhatAccess::Api::MachineTelemetryApiController
Instance Method Summary
collapse
#action_permission, #check_telemetry_enabled, #connection_status, #get_creds, #get_current_organization, #get_machines, #index, #proxy, #render_telemetry_off
#can_mask_rules, #can_unregister_system, #current_organization_object, #disconnected_org?, #get_basic_auth_options, #get_branch_id_for_org, #get_branch_id_for_uuid, #get_content_host, #get_content_hosts, #get_default_ssl_ca_file, #get_http_options, #get_leaf_id, #get_mutual_tls_auth_options, #get_organization, #get_plugin_parent_name, #get_plugin_parent_version, #get_portal_http_proxy, #get_rha_plugin_name, #get_rha_plugin_rpm_name, #get_rha_plugin_version, #get_ssl_options_for_org, #get_ssl_options_for_uuid, #get_tapi_timeout, #get_telemetry_config, #get_upload_timeout, #insights_api_host, #is_org_selected?, #is_susbcribed_to_redhat?, #telemetry_enabled?, #telemetry_enabled_for_uuid?, #upstream_owner, #use_basic_auth?, #use_subsets?, #user_login_to_hash
#authenticate_client, #cert_from_request, #cert_present?, #deny_access, #set_client_user
#api_request?, #http_error_response
Instance Method Details
#api_connection_test ⇒ Object
37
38
39
40
41
42
|
# File 'app/controllers/redhat_access/api/machine_telemetry_api_controller.rb', line 37
def api_connection_test
client = get_api_client
res = client.call_tapi('GET', '/', nil, nil, {timeout: get_tapi_timeout})
Rails.logger.debug(res[:data])
render status: res[:code], json: {}
end
|
#ensure_telemetry_enabled ⇒ Object
25
26
27
|
# File 'app/controllers/redhat_access/api/machine_telemetry_api_controller.rb', line 25
def ensure_telemetry_enabled
render_telemetry_off unless telemetry_enabled_for_uuid?(User.current.login)
end
|
#get_auth_opts(creds) ⇒ Object
29
30
31
32
33
34
35
|
# File 'app/controllers/redhat_access/api/machine_telemetry_api_controller.rb', line 29
def get_auth_opts(creds)
if valid_machine_user?
get_ssl_options_for_uuid(User.current.login, nil)
else
raise(RedhatAccess::Telemetry::LookUps::RecordNotFound,'Invalid User')
end
end
|
#proxy_upload ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'app/controllers/redhat_access/api/machine_telemetry_api_controller.rb', line 44
def proxy_upload
original_method = request.method
original_params = add_branch_to_params(request.query_parameters)
original_payload = request.request_parameters[controller_name]
if not params[:id] and params[:test]
resource = "uploads/"
original_payload = {:test => params[:test]}
else
resource = "uploads/#{params[:id]}"
end
if request.format.json?
original_payload = original_payload.to_json
end
if params[:file]
original_payload = get_file_data(params)
end
client = get_api_client
Rails.logger.debug("Proxy upload original_payload : #{original_payload}")
res = client.call_tapi(original_method, URI.escape(resource), original_params, original_payload, {timeout: get_upload_timeout}, use_subsets)
render status: res[:code], json: res[:data]
end
|
#telemetry_auth ⇒ Object
18
19
20
21
22
23
|
# File 'app/controllers/redhat_access/api/machine_telemetry_api_controller.rb', line 18
def telemetry_auth
authenticate_client
unless valid_machine_user?
deny_access
end
end
|