2013-06-20 13:36:34 -04:00
|
|
|
require 'fog/core/collection'
|
2013-08-27 05:19:54 -04:00
|
|
|
require 'fog/vcloud_director/models/compute/task'
|
2013-06-20 13:36:34 -04:00
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
2013-08-27 05:19:54 -04:00
|
|
|
class VcloudDirector
|
|
|
|
class Tasks < Collection
|
2014-06-19 03:27:33 -04:00
|
|
|
|
|
|
|
include Fog::VcloudDirector::Query
|
|
|
|
|
2013-08-27 05:19:54 -04:00
|
|
|
model Fog::Compute::VcloudDirector::Task
|
2013-06-20 13:36:34 -04:00
|
|
|
|
2013-09-10 13:01:42 -04:00
|
|
|
attribute :organization
|
|
|
|
|
2014-06-19 03:27:33 -04:00
|
|
|
def query_type
|
|
|
|
"task"
|
|
|
|
end
|
|
|
|
|
2013-07-04 07:24:25 -04:00
|
|
|
def get(id)
|
|
|
|
data = service.get_task(id).body
|
|
|
|
return nil unless data
|
|
|
|
data[:id] = data[:href].split('/').last
|
2014-04-09 10:44:13 -04:00
|
|
|
data[:progress] ||= 0
|
2013-07-04 07:24:25 -04:00
|
|
|
new(data)
|
|
|
|
end
|
2013-09-10 13:01:42 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def item_list
|
2013-10-01 03:43:28 -04:00
|
|
|
data = service.get_task_list(organization.id).body
|
2013-10-15 07:41:15 -04:00
|
|
|
data[:Task].each {|task| service.add_id_from_href!(task)}
|
2013-09-10 13:01:42 -04:00
|
|
|
end
|
2013-06-20 13:36:34 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-09-10 13:01:42 -04:00
|
|
|
end
|