2010-10-04 17:02:08 -04:00
|
|
|
require 'fog/core/model'
|
2010-04-16 03:20:02 -04:00
|
|
|
|
|
|
|
module Fog
|
2010-05-17 23:57:13 -04:00
|
|
|
module Terremark
|
2010-04-16 03:20:02 -04:00
|
|
|
module Shared
|
|
|
|
|
|
|
|
class Task < Fog::Model
|
|
|
|
|
|
|
|
identity :id
|
|
|
|
|
2010-09-07 14:30:02 -04:00
|
|
|
attribute :end_time, :aliases => 'endTime'
|
|
|
|
attribute :owner, :aliases => 'Owner'
|
|
|
|
attribute :result, :aliases => 'Result'
|
|
|
|
attribute :start_time, :aliases => 'startTime'
|
2010-04-16 03:20:02 -04:00
|
|
|
attribute :status
|
2010-09-07 14:30:02 -04:00
|
|
|
attribute :link, :aliases => 'Link'
|
|
|
|
attribute :error, :aliases => 'Error'
|
2010-04-16 03:20:02 -04:00
|
|
|
|
|
|
|
def initialize(attributes = {})
|
|
|
|
new_owner = attributes.delete('Owner')
|
|
|
|
new_result = attributes.delete('Result')
|
2010-05-16 15:20:19 -04:00
|
|
|
new_error = attributes.delete('Error')
|
|
|
|
new_cancel_link = attributes.delete('Link')
|
|
|
|
|
2010-04-16 03:20:02 -04:00
|
|
|
super
|
2010-11-19 16:45:45 -05:00
|
|
|
self.owner = connection.parse(new_owner)
|
2010-04-25 14:42:35 -04:00
|
|
|
if new_result
|
2010-11-19 16:45:45 -05:00
|
|
|
self.result = connection.parse(new_result)
|
2010-04-25 14:42:35 -04:00
|
|
|
end
|
2010-11-19 16:45:45 -05:00
|
|
|
self.error = connection.parse(new_error) if new_error
|
2010-05-16 15:20:19 -04:00
|
|
|
@cancel_link = connection.parse(new_cancel_link) if new_cancel_link
|
2010-04-16 03:20:02 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def ready?
|
|
|
|
@status == 'success'
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def href=(new_href)
|
|
|
|
@id = new_href.split('/').last.to_i
|
|
|
|
end
|
|
|
|
|
|
|
|
def type=(new_type); end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|