Class: MMS::Resource::RestoreJob
- Inherits:
-
MMS::Resource
- Object
- MMS::Resource
- MMS::Resource::RestoreJob
- Defined in:
- lib/mms/resource/restore_job.rb
Instance Attribute Summary collapse
-
#created ⇒ Object
Returns the value of attribute created.
-
#delivery_method_name ⇒ Object
Returns the value of attribute delivery_method_name.
-
#delivery_status_name ⇒ Object
Returns the value of attribute delivery_status_name.
-
#delivery_url ⇒ Object
Returns the value of attribute delivery_url.
-
#name ⇒ Object
Returns the value of attribute name.
-
#point_in_time ⇒ Object
Returns the value of attribute point_in_time.
- #snapshot ⇒ MMS::Resource::Snapshot
-
#snapshot_id ⇒ Object
Returns the value of attribute snapshot_id.
-
#status_name ⇒ Object
Returns the value of attribute status_name.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Attributes inherited from MMS::Resource
Class Method Summary collapse
- ._find(client, group_id, cluster_id, id) ⇒ Object
- .find_recursively(client, group_id, cluster_id, id) ⇒ Hash, NilClass
- .table_header ⇒ Object
Instance Method Summary collapse
- #cluster ⇒ MMS::Resource::Cluster
- #has_cluster ⇒ TrueClass, FalseClass
- #table_row ⇒ Object
- #table_section ⇒ Object
Methods inherited from MMS::Resource
#_load, find, #from_hash, #set_client, #set_data, #to_hash
Instance Attribute Details
#created ⇒ Object
Returns the value of attribute created.
16 17 18 |
# File 'lib/mms/resource/restore_job.rb', line 16 def created @created end |
#delivery_method_name ⇒ Object
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_name ⇒ Object
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_url ⇒ Object
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 |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/mms/resource/restore_job.rb', line 7 def name @name end |
#point_in_time ⇒ Object
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 |
#snapshot ⇒ MMS::Resource::Snapshot
12 13 14 |
# File 'lib/mms/resource/restore_job.rb', line 12 def snapshot @snapshot end |
#snapshot_id ⇒ Object
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_name ⇒ Object
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 |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
15 16 17 |
# File 'lib/mms/resource/restore_job.rb', line 15 def @timestamp end |
Class Method Details
._find(client, group_id, cluster_id, id) ⇒ Object
86 87 88 |
# File 'lib/mms/resource/restore_job.rb', line 86 def self._find(client, group_id, cluster_id, id) client.get('/groups/' + group_id + '/clusters/' + cluster_id + '/restoreJobs/' + id) end |
.find_recursively(client, group_id, cluster_id, id) ⇒ Hash, NilClass
78 79 80 81 82 83 84 |
# File 'lib/mms/resource/restore_job.rb', line 78 def self.find_recursively(client, group_id, cluster_id, id) cluster = MMS::Resource::Cluster.find(client, group_id, cluster_id) # config server has no cluster but owns RestoreJob and Snapshot restore_jobs = cluster.restorejobs job = restore_jobs.select { |restorejob| restorejob.id == id } job.first.data unless job.nil? and job.empty? end |
.table_header ⇒ Object
73 74 75 |
# File 'lib/mms/resource/restore_job.rb', line 73 def self.table_header ['Timestamp / RestoreId', 'SnapshotId / Cluster / Group', 'Name (created)', 'Status', 'Point in time', 'Delivery', 'Restore status'] end |
Instance Method Details
#cluster ⇒ MMS::Resource::Cluster
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mms/resource/restore_job.rb', line 24 def cluster begin cluster = MMS::Resource::Cluster.find(@client, @data['groupId'], @data['clusterId']) rescue # Workaround # time to time the mms-api return data without "clusterId" defined # creation of empty clluster instance is a good solution here. cluster = MMS::Resource::Cluster.new cluster.set_client(@client) cluster.set_data({'groupId' => @data['groupId']}) end cluster end |
#has_cluster ⇒ TrueClass, FalseClass
39 40 41 42 43 44 45 |
# File 'lib/mms/resource/restore_job.rb', line 39 def has_cluster # cluster definition for config-server cannot be loaded # as there is no clusterId for this type of group. # there is snapshotId for RestoreJob but seems to be stored # internally in MMS API. Not accessible by public API. snapshot != nil end |
#table_row ⇒ Object
57 58 59 60 |
# File 'lib/mms/resource/restore_job.rb', line 57 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_section ⇒ Object
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/mms/resource/restore_job.rb', line 62 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 |