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

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

Constant Summary collapse

ROUTES_WITH_EXTENDED_TIMEOUT =
['/stemcells', '/releases', '/restore']

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ApiHelper

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

Constructor Details

#initialize(config) ⇒ BaseController

Returns a new instance of BaseController.



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

def initialize(config)
  super()
  @config = config
  @logger = Config.logger
  @identity_provider = config.identity_provider
  @permission_authorizer = PermissionAuthorizer.new(config.get_uuid_provider)
  @backup_manager = BackupManager.new
  @restore_manager = RestoreManager.new
  @resurrector_manager = ResurrectorManager.new
  @release_manager = ReleaseManager.new
  @snapshot_manager = SnapshotManager.new
  @stemcell_manager = StemcellManager.new
  @task_manager = TaskManager.new
  @dns_manager = DnsManagerProvider.create
  @disk_manager = DiskManager.new(nil, @logger)
  @event_manager = EventManager.new(config.record_events)
end

Instance Attribute Details

#identity_providerObject (readonly)

Returns the value of attribute identity_provider.



36
37
38
# File 'lib/bosh/director/api/controllers/base_controller.rb', line 36

def identity_provider
  @identity_provider
end

Class Method Details

.consumes(*types) ⇒ Object



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

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

  condition do
    # Content-Type header may include charset or boundry info
    content_type = request.content_type || ''
    mime_type = content_type.split(';')[0]
    types.include?(mime_type)
  end
end

Instance Method Details

#requires_authentication?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/bosh/director/api/controllers/base_controller.rb', line 75

def requires_authentication?
  true
end