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, cache_key, find, #from_hash, #invalidate_cache, #to_hash

Instance Attribute Details

#cluster_idObject

Returns the value of attribute cluster_id.



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

def cluster_id
  @cluster_id
end

#createdObject

Returns the value of attribute created.



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

def created
  @created
end

#delivery_method_nameObject

Returns the value of attribute delivery_method_name.



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

def delivery_method_name
  @delivery_method_name
end

#delivery_status_nameObject

Returns the value of attribute delivery_status_name.



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

def delivery_status_name
  @delivery_status_name
end

#delivery_urlObject

Returns the value of attribute delivery_url.



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

def delivery_url
  @delivery_url
end

#group_idObject

Returns the value of attribute group_id.



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

def group_id
  @group_id
end

#hashesObject

Returns the value of attribute hashes.



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

def hashes
  @hashes
end

#host_idObject

Returns the value of attribute host_id.



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

def host_id
  @host_id
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/mms/resource/restore_job.rb', line 5

def name
  @name
end

#point_in_timeObject

Returns the value of attribute point_in_time.



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

def point_in_time
  @point_in_time
end

#snapshotMMS::Resource::Snapshot, NilClass

Returns:



10
11
12
# File 'lib/mms/resource/restore_job.rb', line 10

def snapshot
  @snapshot
end

#snapshot_idObject

Returns the value of attribute snapshot_id.



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

def snapshot_id
  @snapshot_id
end

#status_nameObject

Returns the value of attribute status_name.



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

def status_name
  @status_name
end

#timestampObject

Returns the value of attribute timestamp.



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

def timestamp
  @timestamp
end

Class Method Details

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



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

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

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



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

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



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

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

.table_headerObject



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

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



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

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

#has_host?Boolean

Returns:

  • (Boolean)


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

def has_host?
  !@host_id.nil?
end

#hostObject



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

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

#table_rowObject



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

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



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

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