Class: Nucleus::Adapters::V1::Heroku

Inherits:
Stub show all
Includes:
AppStates, Application, Authentication, Buildpacks, Data, Domains, Lifecycle, Logs, Regions, Scaling, SemanticErrors, Services, Vars, Logging
Defined in:
lib/nucleus/adapters/v1/heroku/heroku.rb,
lib/nucleus/adapters/v1/heroku/data.rb,
lib/nucleus/adapters/v1/heroku/logs.rb,
lib/nucleus/adapters/v1/heroku/vars.rb,
lib/nucleus/adapters/v1/heroku/domains.rb,
lib/nucleus/adapters/v1/heroku/regions.rb,
lib/nucleus/adapters/v1/heroku/scaling.rb,
lib/nucleus/adapters/v1/heroku/services.rb,
lib/nucleus/adapters/v1/heroku/lifecycle.rb,
lib/nucleus/adapters/v1/heroku/app_states.rb,
lib/nucleus/adapters/v1/heroku/buildpacks.rb,
lib/nucleus/adapters/v1/heroku/application.rb,
lib/nucleus/adapters/v1/heroku/authentication.rb,
lib/nucleus/adapters/v1/heroku/semantic_errors.rb

Overview

The Heroku adapter is designed to support the Heroku platform API.

The Nucleus API is fully supported, there are no known issues.

Defined Under Namespace

Modules: AppStates, Application, Authentication, Buildpacks, Data, Domains, Lifecycle, Logs, Regions, Scaling, SemanticErrors, Services, Vars

Constant Summary

Constants included from Logs

Logs::CRLF

Constants included from BuildpackTranslator

BuildpackTranslator::PUBLIC_BUILDPACKS

Constants inherited from Stub

Stub::NOT_IMPLEMENTED_ERROR

Instance Attribute Summary

Attributes inherited from BaseAdapter

#endpoint_url

Instance Method Summary collapse

Methods included from Vars

#create_env_var, #delete_env_var, #env_var, #env_vars, #update_env_var

Methods included from SemanticErrors

#semantic_error_messages

Methods included from Services

#add_service, #change_service, #installed_service, #installed_services, #remove_service, #service, #service_plan, #service_plans, #services

Methods included from Scaling

#scale

Methods included from Regions

#region, #regions

Methods included from Lifecycle

#restart, #start, #stop

Methods included from Logs

#log?, #log_entries, #logs, #tail

Methods included from Domains

#create_domain, #delete_domain, #domain, #domains

Methods included from Data

#deploy, #download, #rebuild

Methods included from Buildpacks

#vendor_specific_runtimes

Methods included from BuildpackTranslator

#find_runtime, #native_runtime?

Methods included from Application

#application, #applications, #create_application, #delete_application, #update_application

Methods included from Authentication

#auth_client

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

#tail_http_response

Methods included from HttpClient

#delete, #get, #head, #patch, #post, #put

Constructor Details

#initialize(endpoint_url, endpoint_app_domain = nil, check_certificates = true) ⇒ Heroku

Returns a new instance of Heroku.



24
25
26
# File 'lib/nucleus/adapters/v1/heroku/heroku.rb', line 24

def initialize(endpoint_url, endpoint_app_domain = nil, check_certificates = true)
  super(endpoint_url, endpoint_app_domain, check_certificates)
end

Instance Method Details

#handle_422(error_response) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/nucleus/adapters/v1/heroku/heroku.rb', line 39

def handle_422(error_response)
  return unless error_response.status == 422
  if error_response.body[:id] == 'invalid_params'
    fail Errors::SemanticAdapterRequestError, error_response.body[:message]
  elsif error_response.body[:id] == 'verification_required'
    fail_with(:need_verification, [error_response.body[:message]])
  end
end

#handle_error(error_response) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/nucleus/adapters/v1/heroku/heroku.rb', line 28

def handle_error(error_response)
  handle_422(error_response)
  if error_response.status == 404 && error_response.body[:id] == 'not_found'
    fail Errors::AdapterResourceNotFoundError, error_response.body[:message]
  elsif error_response.status == 503
    fail Errors::PlatformUnavailableError, 'The Heroku API is currently not responding'
  end
  # error still unhandled, will result in a 500, server error
  log.warn "Heroku error still unhandled: #{error_response}"
end