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,300 @@
|
|
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
|
+
# UserProfileConfig is a typed class wrapper around the underlying Comet Server API data structure.
|
15
|
+
class UserProfileConfig
|
16
|
+
|
17
|
+
# @type [String] username
|
18
|
+
attr_accessor :username
|
19
|
+
|
20
|
+
# @type [String] account_name
|
21
|
+
attr_accessor :account_name
|
22
|
+
|
23
|
+
# @type [String] local_timezone
|
24
|
+
attr_accessor :local_timezone
|
25
|
+
|
26
|
+
# @type [String] language_code
|
27
|
+
attr_accessor :language_code
|
28
|
+
|
29
|
+
# @type [Array<String>] emails
|
30
|
+
attr_accessor :emails
|
31
|
+
|
32
|
+
# @type [Hash{String => Comet::UserCustomEmailSettings}] override_email_settings
|
33
|
+
attr_accessor :override_email_settings
|
34
|
+
|
35
|
+
# @type [Boolean] send_email_reports
|
36
|
+
attr_accessor :send_email_reports
|
37
|
+
|
38
|
+
# @type [Hash{String => Comet::DestinationConfig}] destinations
|
39
|
+
attr_accessor :destinations
|
40
|
+
|
41
|
+
# @type [Hash{String => Comet::SourceConfig}] sources
|
42
|
+
attr_accessor :sources
|
43
|
+
|
44
|
+
# @type [Hash{String => Comet::BackupRuleConfig}] backup_rules
|
45
|
+
attr_accessor :backup_rules
|
46
|
+
|
47
|
+
# @type [Hash{String => Comet::DeviceConfig}] devices
|
48
|
+
attr_accessor :devices
|
49
|
+
|
50
|
+
# @type [Boolean] is_suspended
|
51
|
+
attr_accessor :is_suspended
|
52
|
+
|
53
|
+
# @type [Boolean] all_protected_items_quota_enabled
|
54
|
+
attr_accessor :all_protected_items_quota_enabled
|
55
|
+
|
56
|
+
# @type [Number] all_protected_items_quota_bytes
|
57
|
+
attr_accessor :all_protected_items_quota_bytes
|
58
|
+
|
59
|
+
# @type [Number] maximum_devices
|
60
|
+
attr_accessor :maximum_devices
|
61
|
+
|
62
|
+
# @type [String] policy_id
|
63
|
+
attr_accessor :policy_id
|
64
|
+
|
65
|
+
# @type [Comet::UserPolicy] policy
|
66
|
+
attr_accessor :policy
|
67
|
+
|
68
|
+
# @type [Number] password_format
|
69
|
+
attr_accessor :password_format
|
70
|
+
|
71
|
+
# @type [String] password_hash
|
72
|
+
attr_accessor :password_hash
|
73
|
+
|
74
|
+
# @type [String] password_recovery
|
75
|
+
attr_accessor :password_recovery
|
76
|
+
|
77
|
+
# @type [Boolean] allow_password_login
|
78
|
+
attr_accessor :allow_password_login
|
79
|
+
|
80
|
+
# @type [Boolean] allow_password_and_totplogin
|
81
|
+
attr_accessor :allow_password_and_totplogin
|
82
|
+
|
83
|
+
# @type [Number] totpkey_encryption_format
|
84
|
+
attr_accessor :totpkey_encryption_format
|
85
|
+
|
86
|
+
# @type [String] totpkey
|
87
|
+
attr_accessor :totpkey
|
88
|
+
|
89
|
+
# @type [Boolean] require_password_change
|
90
|
+
attr_accessor :require_password_change
|
91
|
+
|
92
|
+
# @type [Number] create_time
|
93
|
+
attr_accessor :create_time
|
94
|
+
|
95
|
+
# @type [String] creation_guid
|
96
|
+
attr_accessor :creation_guid
|
97
|
+
|
98
|
+
# @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
|
99
|
+
attr_accessor :unknown_json_fields
|
100
|
+
|
101
|
+
def initialize
|
102
|
+
@emails = []
|
103
|
+
@override_email_settings = {}
|
104
|
+
@destinations = {}
|
105
|
+
@sources = {}
|
106
|
+
@backup_rules = {}
|
107
|
+
@devices = {}
|
108
|
+
@unknown_json_fields = {}
|
109
|
+
end
|
110
|
+
|
111
|
+
# @param [String] json_string The complete object in JSON format
|
112
|
+
def from_json(json_string)
|
113
|
+
raise TypeError 'expected string' unless json_string.is_a? String
|
114
|
+
|
115
|
+
from_hash(JSON.parse(json_string))
|
116
|
+
end
|
117
|
+
|
118
|
+
# @param [Hash] obj The complete object as a Ruby hash
|
119
|
+
def from_hash(obj)
|
120
|
+
raise TypeError 'expected hash' unless obj.is_a? Hash
|
121
|
+
|
122
|
+
obj.each do |k, v|
|
123
|
+
case k
|
124
|
+
when 'Username'
|
125
|
+
raise TypeError 'expected string' unless v.is_a? String
|
126
|
+
|
127
|
+
@username = v
|
128
|
+
when 'AccountName'
|
129
|
+
raise TypeError 'expected string' unless v.is_a? String
|
130
|
+
|
131
|
+
@account_name = v
|
132
|
+
when 'LocalTimezone'
|
133
|
+
raise TypeError 'expected string' unless v.is_a? String
|
134
|
+
|
135
|
+
@local_timezone = v
|
136
|
+
when 'LanguageCode'
|
137
|
+
raise TypeError 'expected string' unless v.is_a? String
|
138
|
+
|
139
|
+
@language_code = v
|
140
|
+
when 'Emails'
|
141
|
+
if v.nil?
|
142
|
+
@emails = []
|
143
|
+
else
|
144
|
+
@emails = Array.new(v.length)
|
145
|
+
v.each_with_index do |v1, i1|
|
146
|
+
raise TypeError 'expected string' unless v1.is_a? String
|
147
|
+
|
148
|
+
@emails[i1] = v1
|
149
|
+
end
|
150
|
+
end
|
151
|
+
when 'OverrideEmailSettings'
|
152
|
+
@override_email_settings = {}
|
153
|
+
if v.nil?
|
154
|
+
@override_email_settings = {}
|
155
|
+
else
|
156
|
+
v.each do |k1, v1|
|
157
|
+
@override_email_settings[k1] = Comet::UserCustomEmailSettings.new
|
158
|
+
@override_email_settings[k1].from_hash(v1)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
when 'SendEmailReports'
|
162
|
+
@send_email_reports = v
|
163
|
+
when 'Destinations'
|
164
|
+
@destinations = {}
|
165
|
+
if v.nil?
|
166
|
+
@destinations = {}
|
167
|
+
else
|
168
|
+
v.each do |k1, v1|
|
169
|
+
@destinations[k1] = Comet::DestinationConfig.new
|
170
|
+
@destinations[k1].from_hash(v1)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
when 'Sources'
|
174
|
+
@sources = {}
|
175
|
+
if v.nil?
|
176
|
+
@sources = {}
|
177
|
+
else
|
178
|
+
v.each do |k1, v1|
|
179
|
+
@sources[k1] = Comet::SourceConfig.new
|
180
|
+
@sources[k1].from_hash(v1)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
when 'BackupRules'
|
184
|
+
@backup_rules = {}
|
185
|
+
if v.nil?
|
186
|
+
@backup_rules = {}
|
187
|
+
else
|
188
|
+
v.each do |k1, v1|
|
189
|
+
@backup_rules[k1] = Comet::BackupRuleConfig.new
|
190
|
+
@backup_rules[k1].from_hash(v1)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
when 'Devices'
|
194
|
+
@devices = {}
|
195
|
+
if v.nil?
|
196
|
+
@devices = {}
|
197
|
+
else
|
198
|
+
v.each do |k1, v1|
|
199
|
+
@devices[k1] = Comet::DeviceConfig.new
|
200
|
+
@devices[k1].from_hash(v1)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
when 'IsSuspended'
|
204
|
+
@is_suspended = v
|
205
|
+
when 'AllProtectedItemsQuotaEnabled'
|
206
|
+
@all_protected_items_quota_enabled = v
|
207
|
+
when 'AllProtectedItemsQuotaBytes'
|
208
|
+
@all_protected_items_quota_bytes = v
|
209
|
+
when 'MaximumDevices'
|
210
|
+
@maximum_devices = v
|
211
|
+
when 'PolicyID'
|
212
|
+
raise TypeError 'expected string' unless v.is_a? String
|
213
|
+
|
214
|
+
@policy_id = v
|
215
|
+
when 'Policy'
|
216
|
+
@policy = Comet::UserPolicy.new
|
217
|
+
@policy.from_hash(v)
|
218
|
+
when 'PasswordFormat'
|
219
|
+
@password_format = v
|
220
|
+
when 'PasswordHash'
|
221
|
+
raise TypeError 'expected string' unless v.is_a? String
|
222
|
+
|
223
|
+
@password_hash = v
|
224
|
+
when 'PasswordRecovery'
|
225
|
+
raise TypeError 'expected string' unless v.is_a? String
|
226
|
+
|
227
|
+
@password_recovery = v
|
228
|
+
when 'AllowPasswordLogin'
|
229
|
+
@allow_password_login = v
|
230
|
+
when 'AllowPasswordAndTOTPLogin'
|
231
|
+
@allow_password_and_totplogin = v
|
232
|
+
when 'TOTPKeyEncryptionFormat'
|
233
|
+
@totpkey_encryption_format = v
|
234
|
+
when 'TOTPKey'
|
235
|
+
raise TypeError 'expected string' unless v.is_a? String
|
236
|
+
|
237
|
+
@totpkey = v
|
238
|
+
when 'RequirePasswordChange'
|
239
|
+
@require_password_change = v
|
240
|
+
when 'CreateTime'
|
241
|
+
@create_time = v
|
242
|
+
when 'CreationGUID'
|
243
|
+
raise TypeError 'expected string' unless v.is_a? String
|
244
|
+
|
245
|
+
@creation_guid = v
|
246
|
+
else
|
247
|
+
@unknown_json_fields[k] = v
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
# @return [Hash] The complete object as a Ruby hash
|
253
|
+
def to_hash
|
254
|
+
ret = {}
|
255
|
+
ret['Username'] = @username
|
256
|
+
ret['AccountName'] = @account_name
|
257
|
+
ret['LocalTimezone'] = @local_timezone
|
258
|
+
ret['LanguageCode'] = @language_code
|
259
|
+
ret['Emails'] = @emails
|
260
|
+
ret['OverrideEmailSettings'] = @override_email_settings
|
261
|
+
ret['SendEmailReports'] = @send_email_reports
|
262
|
+
ret['Destinations'] = @destinations
|
263
|
+
ret['Sources'] = @sources
|
264
|
+
ret['BackupRules'] = @backup_rules
|
265
|
+
ret['Devices'] = @devices
|
266
|
+
ret['IsSuspended'] = @is_suspended
|
267
|
+
ret['AllProtectedItemsQuotaEnabled'] = @all_protected_items_quota_enabled
|
268
|
+
ret['AllProtectedItemsQuotaBytes'] = @all_protected_items_quota_bytes
|
269
|
+
ret['MaximumDevices'] = @maximum_devices
|
270
|
+
ret['PolicyID'] = @policy_id
|
271
|
+
ret['Policy'] = @policy
|
272
|
+
ret['PasswordFormat'] = @password_format
|
273
|
+
ret['PasswordHash'] = @password_hash
|
274
|
+
unless @password_recovery.nil?
|
275
|
+
ret['PasswordRecovery'] = @password_recovery
|
276
|
+
end
|
277
|
+
ret['AllowPasswordLogin'] = @allow_password_login
|
278
|
+
ret['AllowPasswordAndTOTPLogin'] = @allow_password_and_totplogin
|
279
|
+
ret['TOTPKeyEncryptionFormat'] = @totpkey_encryption_format
|
280
|
+
ret['TOTPKey'] = @totpkey
|
281
|
+
ret['RequirePasswordChange'] = @require_password_change
|
282
|
+
ret['CreateTime'] = @create_time
|
283
|
+
ret['CreationGUID'] = @creation_guid
|
284
|
+
@unknown_json_fields.each do |k, v|
|
285
|
+
ret[k] = v
|
286
|
+
end
|
287
|
+
ret
|
288
|
+
end
|
289
|
+
|
290
|
+
# @return [Hash] The complete object as a Ruby hash
|
291
|
+
def to_h
|
292
|
+
to_hash
|
293
|
+
end
|
294
|
+
|
295
|
+
# @return [String] The complete object as a JSON string
|
296
|
+
def to_json(options = {})
|
297
|
+
to_hash.to_json(options)
|
298
|
+
end
|
299
|
+
end
|
300
|
+
end
|
@@ -0,0 +1,70 @@
|
|
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
|
+
# UserProfileFragment is a typed class wrapper around the underlying Comet Server API data structure.
|
15
|
+
class UserProfileFragment
|
16
|
+
|
17
|
+
# @type [String] username
|
18
|
+
attr_accessor :username
|
19
|
+
|
20
|
+
# @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
|
21
|
+
attr_accessor :unknown_json_fields
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
@unknown_json_fields = {}
|
25
|
+
end
|
26
|
+
|
27
|
+
# @param [String] json_string The complete object in JSON format
|
28
|
+
def from_json(json_string)
|
29
|
+
raise TypeError 'expected string' unless json_string.is_a? String
|
30
|
+
|
31
|
+
from_hash(JSON.parse(json_string))
|
32
|
+
end
|
33
|
+
|
34
|
+
# @param [Hash] obj The complete object as a Ruby hash
|
35
|
+
def from_hash(obj)
|
36
|
+
raise TypeError 'expected hash' unless obj.is_a? Hash
|
37
|
+
|
38
|
+
obj.each do |k, v|
|
39
|
+
case k
|
40
|
+
when 'Username'
|
41
|
+
raise TypeError 'expected string' unless v.is_a? String
|
42
|
+
|
43
|
+
@username = v
|
44
|
+
else
|
45
|
+
@unknown_json_fields[k] = v
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [Hash] The complete object as a Ruby hash
|
51
|
+
def to_hash
|
52
|
+
ret = {}
|
53
|
+
ret['Username'] = @username
|
54
|
+
@unknown_json_fields.each do |k, v|
|
55
|
+
ret[k] = v
|
56
|
+
end
|
57
|
+
ret
|
58
|
+
end
|
59
|
+
|
60
|
+
# @return [Hash] The complete object as a Ruby hash
|
61
|
+
def to_h
|
62
|
+
to_hash
|
63
|
+
end
|
64
|
+
|
65
|
+
# @return [String] The complete object as a JSON string
|
66
|
+
def to_json(options = {})
|
67
|
+
to_hash.to_json(options)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,84 @@
|
|
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
|
+
# VaultSnapshot is a typed class wrapper around the underlying Comet Server API data structure.
|
15
|
+
class VaultSnapshot
|
16
|
+
|
17
|
+
# @type [String] snapshot
|
18
|
+
attr_accessor :snapshot
|
19
|
+
|
20
|
+
# @type [String] source
|
21
|
+
attr_accessor :source
|
22
|
+
|
23
|
+
# @type [Number] create_time
|
24
|
+
attr_accessor :create_time
|
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 'Snapshot'
|
47
|
+
raise TypeError 'expected string' unless v.is_a? String
|
48
|
+
|
49
|
+
@snapshot = v
|
50
|
+
when 'Source'
|
51
|
+
raise TypeError 'expected string' unless v.is_a? String
|
52
|
+
|
53
|
+
@source = v
|
54
|
+
when 'CreateTime'
|
55
|
+
@create_time = v
|
56
|
+
else
|
57
|
+
@unknown_json_fields[k] = v
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# @return [Hash] The complete object as a Ruby hash
|
63
|
+
def to_hash
|
64
|
+
ret = {}
|
65
|
+
ret['Snapshot'] = @snapshot
|
66
|
+
ret['Source'] = @source
|
67
|
+
ret['CreateTime'] = @create_time
|
68
|
+
@unknown_json_fields.each do |k, v|
|
69
|
+
ret[k] = v
|
70
|
+
end
|
71
|
+
ret
|
72
|
+
end
|
73
|
+
|
74
|
+
# @return [Hash] The complete object as a Ruby hash
|
75
|
+
def to_h
|
76
|
+
to_hash
|
77
|
+
end
|
78
|
+
|
79
|
+
# @return [String] The complete object as a JSON string
|
80
|
+
def to_json(options = {})
|
81
|
+
to_hash.to_json(options)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|