Class: Nucleus::Adapters::V1::OpenshiftV2
- Inherits:
-
Stub
- Object
- BaseAdapter
- Stub
- Nucleus::Adapters::V1::OpenshiftV2
- Includes:
- AppStates, Application, Authentication, Data, Domains, Lifecycle, Logs, Regions, Scaling, SemanticErrors, Services, Vars, Logging
- Defined in:
- lib/nucleus/adapters/v1/openshift_v2/openshift_v2.rb,
lib/nucleus/adapters/v1/openshift_v2/data.rb,
lib/nucleus/adapters/v1/openshift_v2/logs.rb,
lib/nucleus/adapters/v1/openshift_v2/vars.rb,
lib/nucleus/adapters/v1/openshift_v2/domains.rb,
lib/nucleus/adapters/v1/openshift_v2/regions.rb,
lib/nucleus/adapters/v1/openshift_v2/scaling.rb,
lib/nucleus/adapters/v1/openshift_v2/services.rb,
lib/nucleus/adapters/v1/openshift_v2/lifecycle.rb,
lib/nucleus/adapters/v1/openshift_v2/app_states.rb,
lib/nucleus/adapters/v1/openshift_v2/application.rb,
lib/nucleus/adapters/v1/openshift_v2/authentication.rb,
lib/nucleus/adapters/v1/openshift_v2/semantic_errors.rb
Overview
Defined Under Namespace
Modules: AppStates, Application, Authentication, Data, Domains, Lifecycle, Logs, Regions, Scaling, SemanticErrors, Services, Vars
Constant Summary
Constants inherited from Stub
Instance Attribute Summary
Attributes inherited from BaseAdapter
Instance Method Summary collapse
- #handle_error(error_response) ⇒ Object
-
#initialize(endpoint_url, endpoint_app_domain = nil, check_certificates = true) ⇒ OpenshiftV2
constructor
A new instance of OpenshiftV2.
- #openshift_errors(error_response) ⇒ Object
Methods included from Vars
#create_env_var, #delete_env_var, #env_var, #env_vars, #update_env_var
Methods included from Services
#add_service, #installed_service, #installed_services, #remove_service, #service, #service_plan, #service_plans, #services
Methods included from SemanticErrors
Methods included from Scaling
Methods included from Regions
Methods included from Logs
#log?, #log_entries, #logs, #tail
Methods included from Lifecycle
Methods included from Domains
#create_domain, #delete_domain, #domain, #domains
Methods included from Data
Methods included from AppStates
Methods included from Application
#application, #applications, #create_application, #delete_application
Methods included from Authentication
Methods included from Logging
configure_logger_for, #log, logger_for
Methods inherited from Stub
#add_service, #application, #applications, #auth_client, #change_service, #create_application, #create_domain, #create_env_var, #delete_application, #delete_domain, #delete_env_var, #deploy, #domain, #domains, #download, #env_var, #env_vars, #installed_service, #installed_services, #log?, #log_entries, #logs, #rebuild, #region, #regions, #remove_service, #restart, #scale, #service, #service_plan, #service_plans, #services, #start, #stop, #tail, #update_application, #update_env_var
Methods inherited from BaseAdapter
#cache, #cache?, #cache_key, #cached, #endpoint_call, #fail_with
Methods included from HttpTailClient
Methods included from HttpClient
#delete, #get, #head, #patch, #post, #put
Constructor Details
#initialize(endpoint_url, endpoint_app_domain = nil, check_certificates = true) ⇒ OpenshiftV2
Returns a new instance of OpenshiftV2.
21 22 23 |
# File 'lib/nucleus/adapters/v1/openshift_v2/openshift_v2.rb', line 21 def initialize(endpoint_url, endpoint_app_domain = nil, check_certificates = true) super(endpoint_url, endpoint_app_domain, check_certificates) end |
Instance Method Details
#handle_error(error_response) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/nucleus/adapters/v1/openshift_v2/openshift_v2.rb', line 25 def handle_error(error_response) # some error messages do not have the proper error message format errors = openshift_errors(error_response) if error_response.status == 404 && errors.any? { |e| e[:text].include?('not found') } fail Errors::AdapterResourceNotFoundError, errors.collect { |e| e[:text] }.join(' ') elsif error_response.status == 422 fail Errors::SemanticAdapterRequestError, errors.collect { |e| e[:text] }.join(' ') elsif error_response.status == 503 fail Errors::PlatformUnavailableError, 'The Openshift API is currently not available' elsif error_response.status == 504 fail Errors::PlatformTimeoutError, 'The Openshift API did not receive information from it\'s slaves. '\ 'Most likely the request is still being executed. Please make sure to analyse whether the request '\ 'was successful before invoking further actions.' end # error still unhandled, will result in a 500, server error log.warn "Openshift error still unhandled: #{error_response}" end |
#openshift_errors(error_response) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/nucleus/adapters/v1/openshift_v2/openshift_v2.rb', line 43 def openshift_errors(error_response) if error_response.body.is_a?(Hash) && error_response.body.key?(:messages) error_response.body[:messages].collect { |error| { field: error[:field], text: error[:text] } } else [] end end |