comet_backup_ruby_sdk 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +25 -0
- data/Gemfile +15 -0
- data/LICENSE +7 -0
- data/README.md +81 -0
- data/Rakefile +22 -0
- data/comet_backup_ruby_sdk.gemspec +35 -0
- data/lib/comet/api_response_error.rb +27 -0
- data/lib/comet/comet_server.rb +2926 -0
- data/lib/comet/definitions.rb +550 -0
- data/lib/comet/models/add_bucket_response_message.rb +92 -0
- data/lib/comet/models/admin_account_properties_response.rb +76 -0
- data/lib/comet/models/admin_resource_response.rb +84 -0
- data/lib/comet/models/admin_security_options.rb +139 -0
- data/lib/comet/models/admin_u2fregistration.rb +84 -0
- data/lib/comet/models/admin_user_permissions.rb +102 -0
- data/lib/comet/models/available_download.rb +84 -0
- data/lib/comet/models/azure_destination_location.rb +102 -0
- data/lib/comet/models/b2destination_location.rb +110 -0
- data/lib/comet/models/b2storage_extra_info.rb +77 -0
- data/lib/comet/models/b2transaction_totals.rb +80 -0
- data/lib/comet/models/backup_job_advanced_options.rb +98 -0
- data/lib/comet/models/backup_job_detail.rb +199 -0
- data/lib/comet/models/backup_job_progress.rb +92 -0
- data/lib/comet/models/backup_rule_config.rb +188 -0
- data/lib/comet/models/backup_rule_event_triggers.rb +78 -0
- data/lib/comet/models/branding_options.rb +283 -0
- data/lib/comet/models/branding_properties.rb +245 -0
- data/lib/comet/models/browse_disk_drives_response.rb +91 -0
- data/lib/comet/models/browse_edbresponse.rb +91 -0
- data/lib/comet/models/browse_hvresponse.rb +91 -0
- data/lib/comet/models/browse_vssresponse.rb +91 -0
- data/lib/comet/models/bucket_properties.rb +89 -0
- data/lib/comet/models/bucket_usage_info.rb +91 -0
- data/lib/comet/models/comet_apiresponse_message.rb +76 -0
- data/lib/comet/models/comet_destination_location.rb +86 -0
- data/lib/comet/models/constellation_check_report.rb +89 -0
- data/lib/comet/models/constellation_stats.rb +86 -0
- data/lib/comet/models/constellation_status_apiresponse.rb +109 -0
- data/lib/comet/models/content_measurement.rb +89 -0
- data/lib/comet/models/content_measurement_component.rb +84 -0
- data/lib/comet/models/create_group_policy_response.rb +84 -0
- data/lib/comet/models/default_email_report_policy.rb +83 -0
- data/lib/comet/models/destination_config.rb +465 -0
- data/lib/comet/models/destination_location.rb +365 -0
- data/lib/comet/models/destination_statistics.rb +102 -0
- data/lib/comet/models/device_config.rb +96 -0
- data/lib/comet/models/disk_drive.rb +153 -0
- data/lib/comet/models/dispatcher_admin_sources_response.rb +92 -0
- data/lib/comet/models/dispatcher_stored_objects_response.rb +91 -0
- data/lib/comet/models/dispatcher_vault_snapshots_response.rb +91 -0
- data/lib/comet/models/edbfile_info.rb +92 -0
- data/lib/comet/models/email_options.rb +140 -0
- data/lib/comet/models/email_report_config.rb +90 -0
- data/lib/comet/models/email_report_generated_preview.rb +100 -0
- data/lib/comet/models/extra_file_exclusion.rb +82 -0
- data/lib/comet/models/ftpdestination_location.rb +124 -0
- data/lib/comet/models/get_group_policy_response.rb +91 -0
- data/lib/comet/models/get_profile_and_hash_response_message.rb +91 -0
- data/lib/comet/models/get_profile_hash_response_message.rb +84 -0
- data/lib/comet/models/group_policy.rb +83 -0
- data/lib/comet/models/hyper_vmachine_info.rb +78 -0
- data/lib/comet/models/live_user_connection.rb +125 -0
- data/lib/comet/models/local_destination_location.rb +92 -0
- data/lib/comet/models/mac_oscode_sign_properties.rb +113 -0
- data/lib/comet/models/mongo_dbconnection.rb +211 -0
- data/lib/comet/models/new_bucket_detail.rb +78 -0
- data/lib/comet/models/news_entry.rb +76 -0
- data/lib/comet/models/osinfo.rb +92 -0
- data/lib/comet/models/partition.rb +148 -0
- data/lib/comet/models/private_branding_properties.rb +185 -0
- data/lib/comet/models/protected_item_engine_type_policy.rb +84 -0
- data/lib/comet/models/public_branding_properties.rb +122 -0
- data/lib/comet/models/remote_server_address.rb +135 -0
- data/lib/comet/models/remote_storage_option.rb +147 -0
- data/lib/comet/models/replicator_state_apiresponse.rb +138 -0
- data/lib/comet/models/request_storage_vault_response_message.rb +84 -0
- data/lib/comet/models/restore_job_advanced_options.rb +104 -0
- data/lib/comet/models/retention_policy.rb +83 -0
- data/lib/comet/models/retention_range.rb +110 -0
- data/lib/comet/models/s3destination_location.rb +114 -0
- data/lib/comet/models/schedule_config.rb +82 -0
- data/lib/comet/models/search_clause.rb +111 -0
- data/lib/comet/models/server_config_options_branding_fragment.rb +69 -0
- data/lib/comet/models/server_config_options_software_build_role_fragment.rb +69 -0
- data/lib/comet/models/server_meta_version_info.rb +208 -0
- data/lib/comet/models/session_key_regenerated_response.rb +92 -0
- data/lib/comet/models/sftpdestination_location.rb +122 -0
- data/lib/comet/models/size_measurement.rb +80 -0
- data/lib/comet/models/software_build_role_options.rb +74 -0
- data/lib/comet/models/software_update_news_response.rb +102 -0
- data/lib/comet/models/source_basic_info.rb +93 -0
- data/lib/comet/models/source_config.rb +172 -0
- data/lib/comet/models/source_statistics.rb +69 -0
- data/lib/comet/models/spanned_destination_location.rb +77 -0
- data/lib/comet/models/spanned_storage_extra_info.rb +77 -0
- data/lib/comet/models/sshconnection.rb +114 -0
- data/lib/comet/models/stat_result.rb +86 -0
- data/lib/comet/models/storage_free_space_info.rb +98 -0
- data/lib/comet/models/storage_vault_provider_policy.rb +82 -0
- data/lib/comet/models/stored_object.rb +130 -0
- data/lib/comet/models/streamable_event.rb +74 -0
- data/lib/comet/models/swift_destination_location.rb +192 -0
- data/lib/comet/models/test_response.rb +82 -0
- data/lib/comet/models/totp_regenerated_response.rb +100 -0
- data/lib/comet/models/u2fregister_request.rb +78 -0
- data/lib/comet/models/u2fregistered_key.rb +86 -0
- data/lib/comet/models/u2fregistration_challenge_response.rb +122 -0
- data/lib/comet/models/u2fsign_request.rb +101 -0
- data/lib/comet/models/u2fsign_response.rb +94 -0
- data/lib/comet/models/uninstall_config.rb +74 -0
- data/lib/comet/models/update_campaign_device_status.rb +68 -0
- data/lib/comet/models/update_campaign_options.rb +86 -0
- data/lib/comet/models/update_campaign_properties.rb +100 -0
- data/lib/comet/models/update_campaign_status.rb +115 -0
- data/lib/comet/models/update_campaign_status_device_entry.rb +84 -0
- data/lib/comet/models/user_custom_email_settings.rb +77 -0
- data/lib/comet/models/user_on_server.rb +76 -0
- data/lib/comet/models/user_policy.rb +304 -0
- data/lib/comet/models/user_profile_config.rb +300 -0
- data/lib/comet/models/user_profile_fragment.rb +70 -0
- data/lib/comet/models/vault_snapshot.rb +84 -0
- data/lib/comet/models/vsscomponent.rb +92 -0
- data/lib/comet/models/vsswriter_info.rb +85 -0
- data/lib/comet/models/web_interface_branding_properties.rb +100 -0
- data/lib/comet/models/webhook_option.rb +84 -0
- data/lib/comet/models/win_smbauth.rb +92 -0
- data/lib/comet/models/windows_code_sign_properties.rb +130 -0
- data/lib/comet_backup_ruby_sdk.rb +130 -0
- metadata +227 -0
@@ -0,0 +1,80 @@
|
|
1
|
+
#!/usr/bin/env ruby --enable-frozen-string-literal
|
2
|
+
#
|
3
|
+
# Copyright (c) 2020-2020 Comet Licensing Ltd.
|
4
|
+
# Please see the LICENSE file for usage information.
|
5
|
+
#
|
6
|
+
# SPDX-License-Identifier: MIT
|
7
|
+
#
|
8
|
+
# frozen_string_literal: true
|
9
|
+
|
10
|
+
require 'json'
|
11
|
+
|
12
|
+
module Comet
|
13
|
+
|
14
|
+
# B2TransactionTotals is a typed class wrapper around the underlying Comet Server API data structure.
|
15
|
+
class B2TransactionTotals
|
16
|
+
|
17
|
+
# @type [Number] class_a
|
18
|
+
attr_accessor :class_a
|
19
|
+
|
20
|
+
# @type [Number] class_b
|
21
|
+
attr_accessor :class_b
|
22
|
+
|
23
|
+
# @type [Number] class_c
|
24
|
+
attr_accessor :class_c
|
25
|
+
|
26
|
+
# @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
|
27
|
+
attr_accessor :unknown_json_fields
|
28
|
+
|
29
|
+
def initialize
|
30
|
+
@unknown_json_fields = {}
|
31
|
+
end
|
32
|
+
|
33
|
+
# @param [String] json_string The complete object in JSON format
|
34
|
+
def from_json(json_string)
|
35
|
+
raise TypeError 'expected string' unless json_string.is_a? String
|
36
|
+
|
37
|
+
from_hash(JSON.parse(json_string))
|
38
|
+
end
|
39
|
+
|
40
|
+
# @param [Hash] obj The complete object as a Ruby hash
|
41
|
+
def from_hash(obj)
|
42
|
+
raise TypeError 'expected hash' unless obj.is_a? Hash
|
43
|
+
|
44
|
+
obj.each do |k, v|
|
45
|
+
case k
|
46
|
+
when 'ClassA'
|
47
|
+
@class_a = v
|
48
|
+
when 'ClassB'
|
49
|
+
@class_b = v
|
50
|
+
when 'ClassC'
|
51
|
+
@class_c = v
|
52
|
+
else
|
53
|
+
@unknown_json_fields[k] = v
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# @return [Hash] The complete object as a Ruby hash
|
59
|
+
def to_hash
|
60
|
+
ret = {}
|
61
|
+
ret['ClassA'] = @class_a
|
62
|
+
ret['ClassB'] = @class_b
|
63
|
+
ret['ClassC'] = @class_c
|
64
|
+
@unknown_json_fields.each do |k, v|
|
65
|
+
ret[k] = v
|
66
|
+
end
|
67
|
+
ret
|
68
|
+
end
|
69
|
+
|
70
|
+
# @return [Hash] The complete object as a Ruby hash
|
71
|
+
def to_h
|
72
|
+
to_hash
|
73
|
+
end
|
74
|
+
|
75
|
+
# @return [String] The complete object as a JSON string
|
76
|
+
def to_json(options = {})
|
77
|
+
to_hash.to_json(options)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
#!/usr/bin/env ruby --enable-frozen-string-literal
|
2
|
+
#
|
3
|
+
# Copyright (c) 2020-2020 Comet Licensing Ltd.
|
4
|
+
# Please see the LICENSE file for usage information.
|
5
|
+
#
|
6
|
+
# SPDX-License-Identifier: MIT
|
7
|
+
#
|
8
|
+
# frozen_string_literal: true
|
9
|
+
|
10
|
+
require 'json'
|
11
|
+
|
12
|
+
module Comet
|
13
|
+
|
14
|
+
# BackupJobAdvancedOptions is a typed class wrapper around the underlying Comet Server API data structure.
|
15
|
+
class BackupJobAdvancedOptions
|
16
|
+
|
17
|
+
# @type [Boolean] skip_already_running
|
18
|
+
attr_accessor :skip_already_running
|
19
|
+
|
20
|
+
# @type [Number] stop_after
|
21
|
+
attr_accessor :stop_after
|
22
|
+
|
23
|
+
# @type [Number] limit_vault_speed_bps
|
24
|
+
attr_accessor :limit_vault_speed_bps
|
25
|
+
|
26
|
+
# @type [Boolean] reduce_disk_concurrency
|
27
|
+
attr_accessor :reduce_disk_concurrency
|
28
|
+
|
29
|
+
# @type [Boolean] use_on_disk_indexes
|
30
|
+
attr_accessor :use_on_disk_indexes
|
31
|
+
|
32
|
+
# @type [Boolean] allow_zero_files_success
|
33
|
+
attr_accessor :allow_zero_files_success
|
34
|
+
|
35
|
+
# @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
|
36
|
+
attr_accessor :unknown_json_fields
|
37
|
+
|
38
|
+
def initialize
|
39
|
+
@unknown_json_fields = {}
|
40
|
+
end
|
41
|
+
|
42
|
+
# @param [String] json_string The complete object in JSON format
|
43
|
+
def from_json(json_string)
|
44
|
+
raise TypeError 'expected string' unless json_string.is_a? String
|
45
|
+
|
46
|
+
from_hash(JSON.parse(json_string))
|
47
|
+
end
|
48
|
+
|
49
|
+
# @param [Hash] obj The complete object as a Ruby hash
|
50
|
+
def from_hash(obj)
|
51
|
+
raise TypeError 'expected hash' unless obj.is_a? Hash
|
52
|
+
|
53
|
+
obj.each do |k, v|
|
54
|
+
case k
|
55
|
+
when 'SkipAlreadyRunning'
|
56
|
+
@skip_already_running = v
|
57
|
+
when 'StopAfter'
|
58
|
+
@stop_after = v
|
59
|
+
when 'LimitVaultSpeedBps'
|
60
|
+
@limit_vault_speed_bps = v
|
61
|
+
when 'ReduceDiskConcurrency'
|
62
|
+
@reduce_disk_concurrency = v
|
63
|
+
when 'UseOnDiskIndexes'
|
64
|
+
@use_on_disk_indexes = v
|
65
|
+
when 'AllowZeroFilesSuccess'
|
66
|
+
@allow_zero_files_success = v
|
67
|
+
else
|
68
|
+
@unknown_json_fields[k] = v
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# @return [Hash] The complete object as a Ruby hash
|
74
|
+
def to_hash
|
75
|
+
ret = {}
|
76
|
+
ret['SkipAlreadyRunning'] = @skip_already_running
|
77
|
+
ret['StopAfter'] = @stop_after
|
78
|
+
ret['LimitVaultSpeedBps'] = @limit_vault_speed_bps
|
79
|
+
ret['ReduceDiskConcurrency'] = @reduce_disk_concurrency
|
80
|
+
ret['UseOnDiskIndexes'] = @use_on_disk_indexes
|
81
|
+
ret['AllowZeroFilesSuccess'] = @allow_zero_files_success
|
82
|
+
@unknown_json_fields.each do |k, v|
|
83
|
+
ret[k] = v
|
84
|
+
end
|
85
|
+
ret
|
86
|
+
end
|
87
|
+
|
88
|
+
# @return [Hash] The complete object as a Ruby hash
|
89
|
+
def to_h
|
90
|
+
to_hash
|
91
|
+
end
|
92
|
+
|
93
|
+
# @return [String] The complete object as a JSON string
|
94
|
+
def to_json(options = {})
|
95
|
+
to_hash.to_json(options)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
#!/usr/bin/env ruby --enable-frozen-string-literal
|
2
|
+
#
|
3
|
+
# Copyright (c) 2020-2020 Comet Licensing Ltd.
|
4
|
+
# Please see the LICENSE file for usage information.
|
5
|
+
#
|
6
|
+
# SPDX-License-Identifier: MIT
|
7
|
+
#
|
8
|
+
# frozen_string_literal: true
|
9
|
+
|
10
|
+
require 'json'
|
11
|
+
|
12
|
+
module Comet
|
13
|
+
|
14
|
+
# BackupJobDetail is a typed class wrapper around the underlying Comet Server API data structure.
|
15
|
+
class BackupJobDetail
|
16
|
+
|
17
|
+
# @type [String] guid
|
18
|
+
attr_accessor :guid
|
19
|
+
|
20
|
+
# @type [String] username
|
21
|
+
attr_accessor :username
|
22
|
+
|
23
|
+
# @type [Number] classification
|
24
|
+
attr_accessor :classification
|
25
|
+
|
26
|
+
# @type [Number] status
|
27
|
+
attr_accessor :status
|
28
|
+
|
29
|
+
# @type [Number] start_time
|
30
|
+
attr_accessor :start_time
|
31
|
+
|
32
|
+
# @type [Number] end_time
|
33
|
+
attr_accessor :end_time
|
34
|
+
|
35
|
+
# @type [String] source_guid
|
36
|
+
attr_accessor :source_guid
|
37
|
+
|
38
|
+
# @type [String] destination_guid
|
39
|
+
attr_accessor :destination_guid
|
40
|
+
|
41
|
+
# @type [String] device_id
|
42
|
+
attr_accessor :device_id
|
43
|
+
|
44
|
+
# @type [String] snapshot_id
|
45
|
+
attr_accessor :snapshot_id
|
46
|
+
|
47
|
+
# @type [String] client_version
|
48
|
+
attr_accessor :client_version
|
49
|
+
|
50
|
+
# @type [Number] total_directories
|
51
|
+
attr_accessor :total_directories
|
52
|
+
|
53
|
+
# @type [Number] total_files
|
54
|
+
attr_accessor :total_files
|
55
|
+
|
56
|
+
# @type [Number] total_size
|
57
|
+
attr_accessor :total_size
|
58
|
+
|
59
|
+
# @type [Number] total_chunks
|
60
|
+
attr_accessor :total_chunks
|
61
|
+
|
62
|
+
# @type [Number] upload_size
|
63
|
+
attr_accessor :upload_size
|
64
|
+
|
65
|
+
# @type [Number] download_size
|
66
|
+
attr_accessor :download_size
|
67
|
+
|
68
|
+
# @type [String] cancellation_id
|
69
|
+
attr_accessor :cancellation_id
|
70
|
+
|
71
|
+
# @type [Comet::BackupJobProgress] progress
|
72
|
+
attr_accessor :progress
|
73
|
+
|
74
|
+
# @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
|
75
|
+
attr_accessor :unknown_json_fields
|
76
|
+
|
77
|
+
def initialize
|
78
|
+
@unknown_json_fields = {}
|
79
|
+
end
|
80
|
+
|
81
|
+
# @param [String] json_string The complete object in JSON format
|
82
|
+
def from_json(json_string)
|
83
|
+
raise TypeError 'expected string' unless json_string.is_a? String
|
84
|
+
|
85
|
+
from_hash(JSON.parse(json_string))
|
86
|
+
end
|
87
|
+
|
88
|
+
# @param [Hash] obj The complete object as a Ruby hash
|
89
|
+
def from_hash(obj)
|
90
|
+
raise TypeError 'expected hash' unless obj.is_a? Hash
|
91
|
+
|
92
|
+
obj.each do |k, v|
|
93
|
+
case k
|
94
|
+
when 'GUID'
|
95
|
+
raise TypeError 'expected string' unless v.is_a? String
|
96
|
+
|
97
|
+
@guid = v
|
98
|
+
when 'Username'
|
99
|
+
raise TypeError 'expected string' unless v.is_a? String
|
100
|
+
|
101
|
+
@username = v
|
102
|
+
when 'Classification'
|
103
|
+
@classification = v
|
104
|
+
when 'Status'
|
105
|
+
@status = v
|
106
|
+
when 'StartTime'
|
107
|
+
@start_time = v
|
108
|
+
when 'EndTime'
|
109
|
+
@end_time = v
|
110
|
+
when 'SourceGUID'
|
111
|
+
raise TypeError 'expected string' unless v.is_a? String
|
112
|
+
|
113
|
+
@source_guid = v
|
114
|
+
when 'DestinationGUID'
|
115
|
+
raise TypeError 'expected string' unless v.is_a? String
|
116
|
+
|
117
|
+
@destination_guid = v
|
118
|
+
when 'DeviceID'
|
119
|
+
raise TypeError 'expected string' unless v.is_a? String
|
120
|
+
|
121
|
+
@device_id = v
|
122
|
+
when 'SnapshotID'
|
123
|
+
raise TypeError 'expected string' unless v.is_a? String
|
124
|
+
|
125
|
+
@snapshot_id = v
|
126
|
+
when 'ClientVersion'
|
127
|
+
raise TypeError 'expected string' unless v.is_a? String
|
128
|
+
|
129
|
+
@client_version = v
|
130
|
+
when 'TotalDirectories'
|
131
|
+
@total_directories = v
|
132
|
+
when 'TotalFiles'
|
133
|
+
@total_files = v
|
134
|
+
when 'TotalSize'
|
135
|
+
@total_size = v
|
136
|
+
when 'TotalChunks'
|
137
|
+
@total_chunks = v
|
138
|
+
when 'UploadSize'
|
139
|
+
@upload_size = v
|
140
|
+
when 'DownloadSize'
|
141
|
+
@download_size = v
|
142
|
+
when 'CancellationID'
|
143
|
+
raise TypeError 'expected string' unless v.is_a? String
|
144
|
+
|
145
|
+
@cancellation_id = v
|
146
|
+
when 'Progress'
|
147
|
+
@progress = Comet::BackupJobProgress.new
|
148
|
+
@progress.from_hash(v)
|
149
|
+
else
|
150
|
+
@unknown_json_fields[k] = v
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
# @return [Hash] The complete object as a Ruby hash
|
156
|
+
def to_hash
|
157
|
+
ret = {}
|
158
|
+
ret['GUID'] = @guid
|
159
|
+
ret['Username'] = @username
|
160
|
+
ret['Classification'] = @classification
|
161
|
+
ret['Status'] = @status
|
162
|
+
ret['StartTime'] = @start_time
|
163
|
+
ret['EndTime'] = @end_time
|
164
|
+
ret['SourceGUID'] = @source_guid
|
165
|
+
ret['DestinationGUID'] = @destination_guid
|
166
|
+
ret['DeviceID'] = @device_id
|
167
|
+
unless @snapshot_id.nil?
|
168
|
+
ret['SnapshotID'] = @snapshot_id
|
169
|
+
end
|
170
|
+
ret['ClientVersion'] = @client_version
|
171
|
+
ret['TotalDirectories'] = @total_directories
|
172
|
+
ret['TotalFiles'] = @total_files
|
173
|
+
ret['TotalSize'] = @total_size
|
174
|
+
ret['TotalChunks'] = @total_chunks
|
175
|
+
ret['UploadSize'] = @upload_size
|
176
|
+
ret['DownloadSize'] = @download_size
|
177
|
+
unless @cancellation_id.nil?
|
178
|
+
ret['CancellationID'] = @cancellation_id
|
179
|
+
end
|
180
|
+
unless @progress.nil?
|
181
|
+
ret['Progress'] = @progress
|
182
|
+
end
|
183
|
+
@unknown_json_fields.each do |k, v|
|
184
|
+
ret[k] = v
|
185
|
+
end
|
186
|
+
ret
|
187
|
+
end
|
188
|
+
|
189
|
+
# @return [Hash] The complete object as a Ruby hash
|
190
|
+
def to_h
|
191
|
+
to_hash
|
192
|
+
end
|
193
|
+
|
194
|
+
# @return [String] The complete object as a JSON string
|
195
|
+
def to_json(options = {})
|
196
|
+
to_hash.to_json(options)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
#!/usr/bin/env ruby --enable-frozen-string-literal
|
2
|
+
#
|
3
|
+
# Copyright (c) 2020-2020 Comet Licensing Ltd.
|
4
|
+
# Please see the LICENSE file for usage information.
|
5
|
+
#
|
6
|
+
# SPDX-License-Identifier: MIT
|
7
|
+
#
|
8
|
+
# frozen_string_literal: true
|
9
|
+
|
10
|
+
require 'json'
|
11
|
+
|
12
|
+
module Comet
|
13
|
+
|
14
|
+
# BackupJobProgress is a typed class wrapper around the underlying Comet Server API data structure.
|
15
|
+
class BackupJobProgress
|
16
|
+
|
17
|
+
# @type [Number] counter
|
18
|
+
attr_accessor :counter
|
19
|
+
|
20
|
+
# @type [Number] sent_time
|
21
|
+
attr_accessor :sent_time
|
22
|
+
|
23
|
+
# @type [Number] recieved_time
|
24
|
+
attr_accessor :recieved_time
|
25
|
+
|
26
|
+
# @type [Number] bytes_done
|
27
|
+
attr_accessor :bytes_done
|
28
|
+
|
29
|
+
# @type [Number] items_done
|
30
|
+
attr_accessor :items_done
|
31
|
+
|
32
|
+
# @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
|
33
|
+
attr_accessor :unknown_json_fields
|
34
|
+
|
35
|
+
def initialize
|
36
|
+
@unknown_json_fields = {}
|
37
|
+
end
|
38
|
+
|
39
|
+
# @param [String] json_string The complete object in JSON format
|
40
|
+
def from_json(json_string)
|
41
|
+
raise TypeError 'expected string' unless json_string.is_a? String
|
42
|
+
|
43
|
+
from_hash(JSON.parse(json_string))
|
44
|
+
end
|
45
|
+
|
46
|
+
# @param [Hash] obj The complete object as a Ruby hash
|
47
|
+
def from_hash(obj)
|
48
|
+
raise TypeError 'expected hash' unless obj.is_a? Hash
|
49
|
+
|
50
|
+
obj.each do |k, v|
|
51
|
+
case k
|
52
|
+
when 'Counter'
|
53
|
+
@counter = v
|
54
|
+
when 'SentTime'
|
55
|
+
@sent_time = v
|
56
|
+
when 'RecievedTime'
|
57
|
+
@recieved_time = v
|
58
|
+
when 'BytesDone'
|
59
|
+
@bytes_done = v
|
60
|
+
when 'ItemsDone'
|
61
|
+
@items_done = v
|
62
|
+
else
|
63
|
+
@unknown_json_fields[k] = v
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# @return [Hash] The complete object as a Ruby hash
|
69
|
+
def to_hash
|
70
|
+
ret = {}
|
71
|
+
ret['Counter'] = @counter
|
72
|
+
ret['SentTime'] = @sent_time
|
73
|
+
ret['RecievedTime'] = @recieved_time
|
74
|
+
ret['BytesDone'] = @bytes_done
|
75
|
+
ret['ItemsDone'] = @items_done
|
76
|
+
@unknown_json_fields.each do |k, v|
|
77
|
+
ret[k] = v
|
78
|
+
end
|
79
|
+
ret
|
80
|
+
end
|
81
|
+
|
82
|
+
# @return [Hash] The complete object as a Ruby hash
|
83
|
+
def to_h
|
84
|
+
to_hash
|
85
|
+
end
|
86
|
+
|
87
|
+
# @return [String] The complete object as a JSON string
|
88
|
+
def to_json(options = {})
|
89
|
+
to_hash.to_json(options)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|