Class: MMS::Resource::RestoreJob

Inherits:
MMS::Resource show all
Defined in:
lib/mms/resource/restore_job.rb

Instance Attribute Summary collapse

Attributes inherited from MMS::Resource

#client, #data, #id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from MMS::Resource

#_load, find, #from_hash, #invalidate_cache, #set_client, #set_data, #to_hash

Instance Attribute Details

#cluster_idObject

Returns the value of attribute cluster_id.



23
24
25
# File 'lib/mms/resource/restore_job.rb', line 23

def cluster_id
  @cluster_id
end

#createdObject

Returns the value of attribute created.



16
17
18
# File 'lib/mms/resource/restore_job.rb', line 16

def created
  @created
end

#delivery_method_nameObject

Returns the value of attribute delivery_method_name.



19
20
21
# File 'lib/mms/resource/restore_job.rb', line 19

def delivery_method_name
  @delivery_method_name
end

#delivery_status_nameObject

Returns the value of attribute delivery_status_name.



20
21
22
# File 'lib/mms/resource/restore_job.rb', line 20

def delivery_status_name
  @delivery_status_name
end

#delivery_urlObject

Returns the value of attribute delivery_url.



21
22
23
# File 'lib/mms/resource/restore_job.rb', line 21

def delivery_url
  @delivery_url
end

#group_idObject

Returns the value of attribute group_id.



24
25
26
# File 'lib/mms/resource/restore_job.rb', line 24

def group_id
  @group_id
end

#host_idObject

Returns the value of attribute host_id.



25
26
27
# File 'lib/mms/resource/restore_job.rb', line 25

def host_id
  @host_id
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/mms/resource/restore_job.rb', line 7

def name
  @name
end

#point_in_timeObject

Returns the value of attribute point_in_time.



18
19
20
# File 'lib/mms/resource/restore_job.rb', line 18

def point_in_time
  @point_in_time
end

#snapshotMMS::Resource::Snapshot, NilClass

Returns:



12
13
14
# File 'lib/mms/resource/restore_job.rb', line 12

def snapshot
  @snapshot
end

#snapshot_idObject

Returns the value of attribute snapshot_id.



14
15
16
# File 'lib/mms/resource/restore_job.rb', line 14

def snapshot_id
  @snapshot_id
end

#status_nameObject

Returns the value of attribute status_name.



17
18
19
# File 'lib/mms/resource/restore_job.rb', line 17

def status_name
  @status_name
end

#timestampObject

Returns the value of attribute timestamp.



15
16
17
# File 'lib/mms/resource/restore_job.rb', line 15

def timestamp
  @timestamp
end

Class Method Details

._find(client, group_id, cluster_id, host_id, id) ⇒ Object



65
66
67
# File 'lib/mms/resource/restore_job.rb', line 65

def self._find(client, group_id, cluster_id, host_id, id)
  host_id.nil? ? self._find_by_cluster(client, group_id, cluster_id, id) : self._find_by_host(client, group_id, host_id, id)
end

._find_by_cluster(client, group_id, cluster_id, id) ⇒ Object



73
74
75
# File 'lib/mms/resource/restore_job.rb', line 73

def self._find_by_cluster(client, group_id, cluster_id, id)
  client.get('/groups/' + group_id + '/clusters/' + cluster_id + '/restoreJobs/' + id)
end

._find_by_host(client, group_id, host_id, id) ⇒ Object



69
70
71
# File 'lib/mms/resource/restore_job.rb', line 69

def self._find_by_host(client, group_id, host_id, id)
  client.get('/groups/' + group_id + '/hosts/' + host_id + '/restoreJobs/' + id)
end

.table_headerObject



61
62
63
# File 'lib/mms/resource/restore_job.rb', line 61

def self.table_header
  ['Timestamp / RestoreId', 'SnapshotId / Cluster / Group', 'Name (created)', 'Status', 'Point in time', 'Delivery', 'Restore status']
end

Instance Method Details

#clusterMMS::Resource::Cluster



28
29
30
# File 'lib/mms/resource/restore_job.rb', line 28

def cluster
  MMS::Resource::Cluster.find(@client, @group_id, @cluster_id)
end

#has_host?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/mms/resource/restore_job.rb', line 36

def has_host?
  !@host_id.nil?
end

#hostObject



32
33
34
# File 'lib/mms/resource/restore_job.rb', line 32

def host
  MMS::Resource::Host.find(@client, @group_id, @host_id)
end

#table_rowObject



45
46
47
48
# File 'lib/mms/resource/restore_job.rb', line 45

def table_row
  time_str = DateTime.parse(@timestamp).strftime("%m/%d/%Y %H:%M")
  [time_str, @snapshot_id, @name, @status_name, @point_in_time, @delivery_method_name, @delivery_status_name]
end

#table_sectionObject



50
51
52
53
54
55
56
57
58
59
# File 'lib/mms/resource/restore_job.rb', line 50

def table_section
  [
    table_row,
    [@id, "#{cluster.name} (#{cluster.id})", {:value => '', :colspan => 5}],
    ['', cluster.group.name, {:value => '', :colspan => 5}],
    [{:value => 'download url:', :colspan => 7}],
    [{:value => @delivery_url || '(waiting for link)', :colspan => 7}],
    :separator
  ]
end