Class: Bosh::Director::Api::Controllers::BaseController

Inherits:
Sinatra::Base
  • Object
show all
Includes:
ApiHelper, Http, DnsHelper
Defined in:
lib/bosh/director/api/controllers/base_controller.rb

Constant Summary collapse

PUBLIC_URLS =
%w(/info)

Constants included from DnsHelper

DnsHelper::SOA, DnsHelper::TTL_4H, DnsHelper::TTL_5M

Constants included from Http

Http::BAD_REQUEST, Http::CREATED, Http::FORBIDDEN, Http::INTERNAL_SERVER_ERROR, Http::NOT_FOUND, Http::NO_CONTENT, Http::OK, Http::UNAUTHORIZED

Constants included from ApiHelper

ApiHelper::READ_CHUNK_SIZE

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DnsHelper

#add_default_dns_server, #canonical, #default_dns_server, #delete_dns_records, #delete_empty_domain, #dns_domain_name, #dns_ns_record, #dns_servers, #invalid_dns, #reverse_domain, #reverse_host, #update_dns_a_record, #update_dns_ptr_record

Methods included from ApiHelper

#check_available_disk_space, #json_decode, #json_encode, #send_disposable_file, #start_task, #write_file

Constructor Details

#initialize(*_) ⇒ BaseController

Returns a new instance of BaseController.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bosh/director/api/controllers/base_controller.rb', line 11

def initialize(*_)
  super
  @deployment_manager = DeploymentManager.new
  @backup_manager = BackupManager.new
  @instance_manager = InstanceManager.new
  @resurrector_manager = ResurrectorManager.new
  @problem_manager = ProblemManager.new
  @property_manager = PropertyManager.new
  @resource_manager = ResourceManager.new
  @release_manager = ReleaseManager.new
  @snapshot_manager = SnapshotManager.new
  @stemcell_manager = StemcellManager.new
  @task_manager = TaskManager.new
  @user_manager = UserManager.new
  @vm_state_manager = VmStateManager.new
  @logger = Config.logger
end

Class Method Details

.consumes(*types) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/bosh/director/api/controllers/base_controller.rb', line 31

def self.consumes(*types)
  types = Set.new(types)
  types.map! { |t| mime_type(t) }

  condition do
    types.include?(request.content_type)
  end
end

Instance Method Details

#authenticate(user, password) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/bosh/director/api/controllers/base_controller.rb', line 40

def authenticate(user, password)
  if @user_manager.authenticate(user, password)
    @user = user
    true
  else
    false
  end
end