Merge branch 'master' into 9623-reuse-containers
[arvados.git] / services / api / app / controllers / arvados / v1 / containers_controller.rb
1 class Arvados::V1::ContainersController < ApplicationController
2   accept_attribute_as_json :environment, Hash
3   accept_attribute_as_json :mounts, Hash
4   accept_attribute_as_json :runtime_constraints, Hash
5   accept_attribute_as_json :command, Array
6
7   def auth
8     if @object.locked_by_uuid != Thread.current[:api_client_authorization].uuid
9       raise ArvadosModel::PermissionDeniedError.new("Not locked by your token")
10     end
11     @object = @object.auth
12     show
13   end
14
15   # Updates use row locking to resolve races between multiple
16   # dispatchers trying to lock the same container.
17   def update
18     @object.with_lock do
19       super
20     end
21   end
22
23   def lock
24     @object.lock
25     show
26   end
27
28   def unlock
29     @object.unlock
30     show
31   end
32 end