Class: Comet::BackupJobDetail

Inherits:
Object
  • Object
show all
Defined in:
lib/comet/models/backup_job_detail.rb

Overview

BackupJobDetail is a typed class wrapper around the underlying Comet Server API data structure.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBackupJobDetail

Returns a new instance of BackupJobDetail.



86
87
88
# File 'lib/comet/models/backup_job_detail.rb', line 86

def initialize
  clear
end

Instance Attribute Details

#cancellation_idObject

Returns the value of attribute cancellation_id.



78
79
80
# File 'lib/comet/models/backup_job_detail.rb', line 78

def cancellation_id
  @cancellation_id
end

#classificationObject

Returns the value of attribute classification.



24
25
26
# File 'lib/comet/models/backup_job_detail.rb', line 24

def classification
  @classification
end

#client_versionObject

Returns the value of attribute client_version.



48
49
50
# File 'lib/comet/models/backup_job_detail.rb', line 48

def client_version
  @client_version
end

#destination_guidObject

Returns the value of attribute destination_guid.



39
40
41
# File 'lib/comet/models/backup_job_detail.rb', line 39

def destination_guid
  @destination_guid
end

#device_idObject

Returns the value of attribute device_id.



42
43
44
# File 'lib/comet/models/backup_job_detail.rb', line 42

def device_id
  @device_id
end

#download_sizeObject

Returns the value of attribute download_size.



66
67
68
# File 'lib/comet/models/backup_job_detail.rb', line 66

def download_size
  @download_size
end

#end_timeObject

Returns the value of attribute end_time.



33
34
35
# File 'lib/comet/models/backup_job_detail.rb', line 33

def end_time
  @end_time
end

#guidObject

Returns the value of attribute guid.



18
19
20
# File 'lib/comet/models/backup_job_detail.rb', line 18

def guid
  @guid
end

#progressObject

Returns the value of attribute progress.



81
82
83
# File 'lib/comet/models/backup_job_detail.rb', line 81

def progress
  @progress
end

#snapshot_idObject

Returns the value of attribute snapshot_id.



45
46
47
# File 'lib/comet/models/backup_job_detail.rb', line 45

def snapshot_id
  @snapshot_id
end

#source_guidObject

Returns the value of attribute source_guid.



36
37
38
# File 'lib/comet/models/backup_job_detail.rb', line 36

def source_guid
  @source_guid
end

#start_timeObject

Returns the value of attribute start_time.



30
31
32
# File 'lib/comet/models/backup_job_detail.rb', line 30

def start_time
  @start_time
end

#statusObject

Returns the value of attribute status.



27
28
29
# File 'lib/comet/models/backup_job_detail.rb', line 27

def status
  @status
end

#total_accounts_countObject

Returns the value of attribute total_accounts_count.



75
76
77
# File 'lib/comet/models/backup_job_detail.rb', line 75

def total_accounts_count
  @total_accounts_count
end

#total_chunksObject

Returns the value of attribute total_chunks.



60
61
62
# File 'lib/comet/models/backup_job_detail.rb', line 60

def total_chunks
  @total_chunks
end

#total_directoriesObject

Returns the value of attribute total_directories.



51
52
53
# File 'lib/comet/models/backup_job_detail.rb', line 51

def total_directories
  @total_directories
end

#total_filesObject

Returns the value of attribute total_files.



54
55
56
# File 'lib/comet/models/backup_job_detail.rb', line 54

def total_files
  @total_files
end

#total_mails_countObject

Returns the value of attribute total_mails_count.



69
70
71
# File 'lib/comet/models/backup_job_detail.rb', line 69

def total_mails_count
  @total_mails_count
end

#total_sites_countObject

Returns the value of attribute total_sites_count.



72
73
74
# File 'lib/comet/models/backup_job_detail.rb', line 72

def total_sites_count
  @total_sites_count
end

#total_sizeObject

Returns the value of attribute total_size.



57
58
59
# File 'lib/comet/models/backup_job_detail.rb', line 57

def total_size
  @total_size
end

#unknown_json_fieldsObject

Returns the value of attribute unknown_json_fields.



84
85
86
# File 'lib/comet/models/backup_job_detail.rb', line 84

def unknown_json_fields
  @unknown_json_fields
end

#upload_sizeObject

Returns the value of attribute upload_size.



63
64
65
# File 'lib/comet/models/backup_job_detail.rb', line 63

def upload_size
  @upload_size
end

#usernameObject

Returns the value of attribute username.



21
22
23
# File 'lib/comet/models/backup_job_detail.rb', line 21

def username
  @username
end

Instance Method Details

#clearObject



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/comet/models/backup_job_detail.rb', line 90

def clear
  @guid = ''
  @username = ''
  @classification = 0
  @status = 0
  @start_time = 0
  @end_time = 0
  @source_guid = ''
  @destination_guid = ''
  @device_id = ''
  @snapshot_id = ''
  @client_version = ''
  @total_directories = 0
  @total_files = 0
  @total_size = 0
  @total_chunks = 0
  @upload_size = 0
  @download_size = 0
  @total_mails_count = 0
  @total_sites_count = 0
  @total_accounts_count = 0
  @cancellation_id = ''
  @progress = Comet::BackupJobProgress.new
  @unknown_json_fields = {}
end

#from_hash(obj) ⇒ Object

Parameters:

  • obj (Hash)

    The complete object as a Ruby hash

Raises:

  • (TypeError)


124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/comet/models/backup_job_detail.rb', line 124

def from_hash(obj)
  raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash

  obj.each do |k, v|
    case k
    when 'GUID'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String

      @guid = v
    when 'Username'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String

      @username = v
    when 'Classification'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric

      @classification = v
    when 'Status'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric

      @status = v
    when 'StartTime'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric

      @start_time = v
    when 'EndTime'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric

      @end_time = v
    when 'SourceGUID'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String

      @source_guid = v
    when 'DestinationGUID'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String

      @destination_guid = v
    when 'DeviceID'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String

      @device_id = v
    when 'SnapshotID'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String

      @snapshot_id = v
    when 'ClientVersion'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String

      @client_version = v
    when 'TotalDirectories'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric

      @total_directories = v
    when 'TotalFiles'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric

      @total_files = v
    when 'TotalSize'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric

      @total_size = v
    when 'TotalChunks'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric

      @total_chunks = v
    when 'UploadSize'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric

      @upload_size = v
    when 'DownloadSize'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric

      @download_size = v
    when 'TotalMailsCount'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric

      @total_mails_count = v
    when 'TotalSitesCount'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric

      @total_sites_count = v
    when 'TotalAccountsCount'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric

      @total_accounts_count = v
    when 'CancellationID'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String

      @cancellation_id = v
    when 'Progress'
      @progress = Comet::BackupJobProgress.new
      @progress.from_hash(v)
    else
      @unknown_json_fields[k] = v
    end
  end
end

#from_json(json_string) ⇒ Object

Parameters:

  • json_string (String)

    The complete object in JSON format

Raises:

  • (TypeError)


117
118
119
120
121
# File 'lib/comet/models/backup_job_detail.rb', line 117

def from_json(json_string)
  raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String

  from_hash(JSON.parse(json_string))
end

#to_hHash

Returns The complete object as a Ruby hash.

Returns:

  • (Hash)

    The complete object as a Ruby hash



266
267
268
# File 'lib/comet/models/backup_job_detail.rb', line 266

def to_h
  to_hash
end

#to_hashHash

Returns The complete object as a Ruby hash.

Returns:

  • (Hash)

    The complete object as a Ruby hash



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/comet/models/backup_job_detail.rb', line 223

def to_hash
  ret = {}
  ret['GUID'] = @guid
  ret['Username'] = @username
  ret['Classification'] = @classification
  ret['Status'] = @status
  ret['StartTime'] = @start_time
  ret['EndTime'] = @end_time
  ret['SourceGUID'] = @source_guid
  ret['DestinationGUID'] = @destination_guid
  ret['DeviceID'] = @device_id
  unless @snapshot_id.nil?
    ret['SnapshotID'] = @snapshot_id
  end
  ret['ClientVersion'] = @client_version
  ret['TotalDirectories'] = @total_directories
  ret['TotalFiles'] = @total_files
  ret['TotalSize'] = @total_size
  ret['TotalChunks'] = @total_chunks
  ret['UploadSize'] = @upload_size
  ret['DownloadSize'] = @download_size
  unless @total_mails_count.nil?
    ret['TotalMailsCount'] = @total_mails_count
  end
  unless @total_sites_count.nil?
    ret['TotalSitesCount'] = @total_sites_count
  end
  unless @total_accounts_count.nil?
    ret['TotalAccountsCount'] = @total_accounts_count
  end
  unless @cancellation_id.nil?
    ret['CancellationID'] = @cancellation_id
  end
  unless @progress.nil?
    ret['Progress'] = @progress
  end
  @unknown_json_fields.each do |k, v|
    ret[k] = v
  end
  ret
end

#to_json(options = {}) ⇒ String

Returns The complete object as a JSON string.

Returns:

  • (String)

    The complete object as a JSON string



271
272
273
# File 'lib/comet/models/backup_job_detail.rb', line 271

def to_json(options = {})
  to_hash.to_json(options)
end