Class: Bosh::Director::Api::Controllers::TasksController

Inherits:
BaseController show all
Defined in:
lib/bosh/director/api/controllers/tasks_controller.rb

Constant Summary

Constants inherited from BaseController

BaseController::ROUTES_WITH_EXTENDED_TIMEOUT

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

Attributes inherited from BaseController

#identity_provider

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseController

consumes, #requires_authentication?

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) ⇒ TasksController

Returns a new instance of TasksController.



7
8
9
10
# File 'lib/bosh/director/api/controllers/tasks_controller.rb', line 7

def initialize(config)
  super(config)
  @deployment_manager = Api::DeploymentManager.new
end

Class Method Details

.authorization(perm) ⇒ Object



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

def self.authorization(perm)
  return unless perm

  condition do
    type = params[:type]
    task = @task_manager.find_task(params[:id])
    if type == 'debug' || type == 'cpi' || !type
      @permission_authorizer.granted_or_raise(task, :admin, token_scopes)
    elsif type == 'event' || type == 'result' || type == 'none'
      @permission_authorizer.granted_or_raise(task, :read, token_scopes)
    else
      raise UnauthorizedToAccessDeployment, "Unknown type #{type}"
    end
  end
end

Instance Method Details

#filter_task_by_deployment_and_teams(dataset, deployment, token_scopes, limit) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/bosh/director/api/controllers/tasks_controller.rb', line 80

def filter_task_by_deployment_and_teams(dataset, deployment, token_scopes, limit)
    if deployment
      dataset = dataset.where(deployment_name: deployment)
    end
    if token_scopes
      teams = Models::Team.transform_admin_team_scope_to_teams(token_scopes)
      dataset = dataset.where(teams: teams)
    end
    if limit
      dataset = dataset.limit(limit)
    end
    dataset.order_by(Sequel.desc(:timestamp)).all
end