Class: Conversant::V3::Services::Portal
- Includes:
- Authorization
- Defined in:
- lib/conversant/v3/services/portal.rb,
lib/conversant/v3/services/portal/dashboard.rb
Overview
Portal service for Conversant/SwiftFederation administration
Provides access to portal functionality including appliance management and infrastructure monitoring.
Defined Under Namespace
Classes: Dashboard
Constant Summary collapse
- MASTER_APPLIANCE_REDIS_KEY =
Redis key prefix for caching appliance data
'CONVERSANT.V3.PORTAL.APPLIANCE.ITEMS'
Constants included from HttpClient
HttpClient::LOGIN_URL, HttpClient::PORTAL_SESSION_REDIS_KEY, HttpClient::SSO_GW_SESSION2_REDIS_KEY
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#appliances(gte = nil, lte = nil) ⇒ Array<Hash>
Retrieves appliance data for a specified date range.
-
#dashboard ⇒ Dashboard
Get dashboard service instance.
Methods inherited from Base
Methods included from HttpClient
#authenticate, #cookie_jar, #cookie_jar=, #debug_log, #request, #sso_login
Constructor Details
This class inherits a constructor from Conversant::V3::Base
Instance Method Details
#appliances(gte = nil, lte = nil) ⇒ Array<Hash>
Retrieves appliance data for a specified date range
Returns information about appliances (CDN nodes) including their IP addresses, hostnames, locations (POP), traffic volume, and federation volume. Results are cached in Redis for 10 minutes to improve performance.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/conversant/v3/services/portal.rb', line 60 def appliances(gte = nil, lte = nil) today = Date.today.to_datetime gte ||= today.beginning_of_month.strftime('%Y-%m-%dT00:00:00Z') lte ||= today.end_of_month.strftime('%Y-%m-%dT23:59:59Z') key = "#{MASTER_APPLIANCE_REDIS_KEY}.#{gte.to_datetime&.strftime('%Y%m')}" items = redis.get(key) if items.nil? logger.debug "#{identifier}.METHOD:appliances.FETCHING_DATA" payload = { startTime: gte, endTime: lte } response = JSON.parse(call('POST', '/load_appliance_data', payload)) items = response&.[]('applianceList')&.map do |item| { ip: item['ip'], hostname: item['hostname'], deleted: item['deleted'], pop: item['pop'], volume: item['volume'], federation: item['federationVolume'], } end.to_json redis.set(key, items, ex: 600) end JSON.parse(items) rescue StandardError => e logger.error "#{identifier}.METHOD:appliances.ERROR:#{e.}" [] end |