ubicloud/routes/project/vm.rb
Jeremy Evans aeacc6f0bb Allow authorization methods to accept objects in addition to ids
Previously, project_id and subject_id needed to be a uuid, and
object_id could be a uuid or ubid. This allows accepting an
object for all three. This simplifies almost all callers of
these methods. It also doesn't require either parsing a ubid
or generating a ubid. Previously, even if a uuid was given, it
would turn it into a ubid in order to extract the class, and
guess ApiKey if it was an et ubid.
2025-09-18 02:56:28 +09:00

32 lines
694 B
Ruby

# frozen_string_literal: true
class Clover
hash_branch(:project_prefix, "vm") do |r|
r.get true do
dataset = vm_list_dataset
if api?
vm_list_api_response(dataset)
else
@vms = dataset
.eager(:semaphores, :assigned_vm_address, :vm_storage_volumes, :location)
.reverse(:created_at)
.all
view "vm/index"
end
end
r.web do
r.post true do
handle_validation_failure("vm/create")
check_visible_location
vm_post(typecast_params.nonempty_str("name"))
end
r.get "create" do
authorize("Vm:create", @project)
view "vm/create"
end
end
end
end