Class: Dbwatcher::Api::V1::SystemInfoController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Dbwatcher::Api::V1::SystemInfoController
- Defined in:
- app/controllers/dbwatcher/api/v1/system_info_controller.rb
Overview
System information API controller
Provides RESTful API endpoints for system information access. Supports JSON responses for programmatic access to system data. rubocop:disable Metrics/ClassLength
Instance Method Summary collapse
-
#cache_status ⇒ void
Get cache status and metadata.
-
#clear_cache ⇒ void
Clear system information cache.
-
#database ⇒ void
Get database information only.
-
#index ⇒ void
Get complete system information.
-
#machine ⇒ void
Get machine information only.
-
#refresh ⇒ void
Refresh system information.
-
#runtime ⇒ void
Get runtime information only.
-
#summary ⇒ void
Get system information summary.
Instance Method Details
#cache_status ⇒ void
This method returns an undefined value.
Get cache status and metadata
rubocop:disable Metrics/MethodLength
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'app/controllers/dbwatcher/api/v1/system_info_controller.rb', line 135 def cache_status info_available = system_info_storage.info_available? cache_age = system_info_storage.info_age render json: { status: :ok, data: { cache_available: info_available, cache_age: cache_age&.round(2), cache_expired: cache_age && cache_age > Dbwatcher.configuration.system_info_cache_duration, max_cache_age: Dbwatcher.configuration.system_info_cache_duration, refresh_interval: Dbwatcher.configuration.system_info_refresh_interval }, timestamp: Time.current.iso8601 } rescue StandardError => e log_error "API: Failed to get cache status: #{e.}" render json: { error: e. }, status: :internal_server_error end |
#clear_cache ⇒ void
This method returns an undefined value.
Clear system information cache
118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'app/controllers/dbwatcher/api/v1/system_info_controller.rb', line 118 def clear_cache system_info_storage.clear_cache render json: { status: :ok, message: "System information cache cleared successfully", timestamp: Time.current.iso8601 } rescue StandardError => e log_error "API: Failed to clear cache: #{e.}" render json: { error: e. }, status: :internal_server_error end |
#database ⇒ void
This method returns an undefined value.
Get database information only
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/controllers/dbwatcher/api/v1/system_info_controller.rb', line 68 def database info = system_info_storage.cached_info render json: { status: :ok, data: info[:database] || {}, timestamp: Time.current.iso8601, cache_age: system_info_storage.info_age&.round(2) } rescue StandardError => e log_error "API: Failed to get database information: #{e.}" render json: { error: e. }, status: :internal_server_error end |
#index ⇒ void
This method returns an undefined value.
Get complete system information
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/dbwatcher/api/v1/system_info_controller.rb', line 17 def index info = system_info_storage.cached_info render json: { status: :ok, data: info, timestamp: Time.current.iso8601, cache_age: system_info_storage.info_age&.round(2) } rescue StandardError => e log_error "API: Failed to get system information: #{e.}" render json: { error: e. }, status: :internal_server_error end |
#machine ⇒ void
This method returns an undefined value.
Get machine information only
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/dbwatcher/api/v1/system_info_controller.rb', line 51 def machine info = system_info_storage.cached_info render json: { status: :ok, data: info[:machine] || {}, timestamp: Time.current.iso8601, cache_age: system_info_storage.info_age&.round(2) } rescue StandardError => e log_error "API: Failed to get machine information: #{e.}" render json: { error: e. }, status: :internal_server_error end |
#refresh ⇒ void
This method returns an undefined value.
Refresh system information
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/dbwatcher/api/v1/system_info_controller.rb', line 34 def refresh info = system_info_storage.refresh_info render json: { status: :ok, data: info, timestamp: Time.current.iso8601, message: "System information refreshed successfully" } rescue StandardError => e log_error "API: Failed to refresh system information: #{e.}" render json: { error: e. }, status: :internal_server_error end |
#runtime ⇒ void
This method returns an undefined value.
Get runtime information only
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/controllers/dbwatcher/api/v1/system_info_controller.rb', line 85 def runtime info = system_info_storage.cached_info render json: { status: :ok, data: info[:runtime] || {}, timestamp: Time.current.iso8601, cache_age: system_info_storage.info_age&.round(2) } rescue StandardError => e log_error "API: Failed to get runtime information: #{e.}" render json: { error: e. }, status: :internal_server_error end |
#summary ⇒ void
This method returns an undefined value.
Get system information summary
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'app/controllers/dbwatcher/api/v1/system_info_controller.rb', line 102 def summary summary_data = system_info_storage.summary render json: { status: :ok, data: summary_data, timestamp: Time.current.iso8601 } rescue StandardError => e log_error "API: Failed to get system info summary: #{e.}" render json: { error: e. }, status: :internal_server_error end |