comet_backup_ruby_sdk 1.10.0 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -1
  3. data/comet_backup_ruby_sdk.gemspec +1 -1
  4. data/lib/comet/comet_server.rb +61 -3
  5. data/lib/comet/definitions.rb +3 -3
  6. data/lib/comet/models/admin_security_options.rb +23 -0
  7. data/lib/comet/models/admin_web_authn_registration.rb +112 -0
  8. data/lib/comet/models/allowed_admin_user.rb +212 -0
  9. data/lib/comet/models/browse_office_365list_virtual_accounts_response.rb +99 -0
  10. data/lib/comet/models/office_365custom_setting_v2.rb +108 -0
  11. data/lib/comet/models/office_365mixed_virtual_account.rb +203 -0
  12. data/lib/comet/models/stat_result.rb +9 -0
  13. data/lib/comet/models/web_authn_authenticator_selection.rb +96 -0
  14. data/lib/comet/models/web_authn_credential.rb +105 -0
  15. data/lib/comet/models/web_authn_credential_assertion.rb +74 -0
  16. data/lib/comet/models/web_authn_credential_descriptor.rb +101 -0
  17. data/lib/comet/models/web_authn_credential_entity.rb +86 -0
  18. data/lib/comet/models/web_authn_credential_parameter.rb +84 -0
  19. data/lib/comet/models/web_authn_public_key_credential_creation_options.rb +173 -0
  20. data/lib/comet/models/web_authn_public_key_credential_request_options.rb +141 -0
  21. data/lib/comet/models/web_authn_registration_challenge_response.rb +101 -0
  22. data/lib/comet/models/web_authn_relying_party_entity.rb +95 -0
  23. data/lib/comet/models/web_authn_sign_request.rb +83 -0
  24. data/lib/comet/models/web_authn_sign_response.rb +84 -0
  25. data/lib/comet/models/web_authn_user_entity.rb +105 -0
  26. data/lib/comet_backup_ruby_sdk.rb +15 -0
  27. metadata +20 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1351a43776da0134fbbc0f29301c07bf21684f24fad024a2b24311c6c5f1993b
4
- data.tar.gz: a21014914d06619f590dce35f990036d4369a76287a6d654a5565fb373ebf003
3
+ metadata.gz: 6d320abff24079c6c63042f2319ab6bf85895df807ae4e3c64e28f124931439d
4
+ data.tar.gz: 54992cd97acfdea46b281ec833bd6b42a5ee56968ca0f6a9a59a2dfaee4ee97b
5
5
  SHA512:
6
- metadata.gz: 6c1267509de43041f58a02f46edd7aeb2d57eb7a464b5ba018d86398132bff04f94a5cc75bd6f04942a04fdd08a3a7e558c31cea467aae5090f192a75cb11a07
7
- data.tar.gz: 8f5b8df8f2d55019e6ca2efd9ad5025d5d31e9bb00babd2fc82c3aeb3a434f4e6f790385cd8643170b4eb69ba2f30cb6d6fc4f59460f5177865f01678ec0ac08
6
+ metadata.gz: 3554197606a2d10499e981d642f7b2ad5645b2a424f13be88cf0be3d118da6c6df0caf9a784cc1d0c2536f9b591ef8320b1a04e46fffe0e42c4372c677dafa87
7
+ data.tar.gz: '0921fc302340b38c77bb6f7733c447d274347dc7379a8916b7f5a4fea0b97c666cdc126d793075be180ea40d431db1449659f279779bf965513c7e5af1235cb2'
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
- ## 2021-11-24 v3.18.0
3
+ ## 2021-12-22 v1.11.0
4
+ - Based on 21.12.1
5
+ - Add `AdminAccountWebauthnRegistration` endpoint for new webauthn support.
6
+ - Deprecate `AdminACcountU2fSubmitChallenge` as U2F is ending browser support in February 2022.
7
+
8
+ ## 2021-11-24 v1.10.0
4
9
  - Based on 21.9.12
5
10
  - Add support for Thai and Danish localizations
6
11
  - Add From and To fields to the EmailReportGenerated API
@@ -12,7 +12,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
12
12
 
13
13
  Gem::Specification.new do |spec|
14
14
  spec.name = 'comet_backup_ruby_sdk'
15
- spec.version = '1.10.0'
15
+ spec.version = '1.11.0'
16
16
  spec.authors = ['Comet Licensing Ltd.']
17
17
  spec.email = ['hello@cometbackup.com']
18
18
 
@@ -96,7 +96,7 @@ module Comet
96
96
  #
97
97
  # You must supply administrator authentication credentials to use this API.
98
98
  #
99
- # @param [String] self_address (Optional) External URL of this server (used for U2F AppID)
99
+ # @param [String] self_address (Optional) External URL of this server
100
100
  # @return [Comet::SessionKeyRegeneratedResponse]
101
101
  def admin_account_session_start(self_address = nil)
102
102
  submit_params = {}
@@ -166,6 +166,9 @@ module Comet
166
166
  # AdminAccountU2fRequestRegistrationChallenge
167
167
  #
168
168
  # Register a new FIDO U2F token.
169
+ # Browser support for U2F is ending in February 2022. WebAuthn is backwards
170
+ # compatible with U2F keys, and Comet will automatically migrate existing U2F keys
171
+ # to allow their use with the WebAuthn endpoints.
169
172
  #
170
173
  # You must supply administrator authentication credentials to use this API.
171
174
  #
@@ -188,6 +191,9 @@ module Comet
188
191
  # AdminAccountU2fSubmitChallengeResponse
189
192
  #
190
193
  # Register a new FIDO U2F token.
194
+ # Browser support for U2F is ending in February 2022. WebAuthn is backwards
195
+ # compatible with U2F keys, and Comet will automatically migrate existing U2F keys
196
+ # to allow their use with the WebAuthn endpoints.
191
197
  #
192
198
  # You must supply administrator authentication credentials to use this API.
193
199
  #
@@ -245,6 +251,58 @@ module Comet
245
251
  ret
246
252
  end
247
253
 
254
+ # AdminAccountWebauthnRequestRegistrationChallenge
255
+ #
256
+ # Register a new FIDO2 WebAuthn token.
257
+ #
258
+ # You must supply administrator authentication credentials to use this API.
259
+ #
260
+ # @param [String] self_address External URL of this server, used as WebAuthn ID
261
+ # @return [Comet::WebAuthnRegistrationChallengeResponse]
262
+ def admin_account_webauthn_request_registration_challenge(self_address)
263
+ submit_params = {}
264
+ raise TypeError, "'self_address' expected String, got #{self_address.class}" unless self_address.is_a? String
265
+
266
+ submit_params['SelfAddress'] = self_address
267
+
268
+ body = perform_request('api/v1/admin/account/webauthn/request-registration-challenge', submit_params)
269
+ json_body = JSON.parse body
270
+ check_status json_body
271
+ ret = Comet::WebAuthnRegistrationChallengeResponse.new
272
+ ret.from_hash(json_body)
273
+ ret
274
+ end
275
+
276
+ # AdminAccountWebauthnSubmitChallengeResponse
277
+ #
278
+ # Register a new FIDO2 WebAuthn token.
279
+ #
280
+ # You must supply administrator authentication credentials to use this API.
281
+ #
282
+ # @param [String] self_address External URL of this server, used as WebAuthn ID
283
+ # @param [String] challenge_id Associated value from AdminAccountWebAuthnRequestRegistrationChallenge API
284
+ # @param [String] credential JSON-encoded credential
285
+ # @return [Comet::CometAPIResponseMessage]
286
+ def admin_account_webauthn_submit_challenge_response(self_address, challenge_id, credential)
287
+ submit_params = {}
288
+ raise TypeError, "'self_address' expected String, got #{self_address.class}" unless self_address.is_a? String
289
+
290
+ submit_params['SelfAddress'] = self_address
291
+ raise TypeError, "'challenge_id' expected String, got #{challenge_id.class}" unless challenge_id.is_a? String
292
+
293
+ submit_params['ChallengeID'] = challenge_id
294
+ raise TypeError, "'credential' expected String, got #{credential.class}" unless credential.is_a? String
295
+
296
+ submit_params['Credential'] = credential
297
+
298
+ body = perform_request('api/v1/admin/account/webauthn/submit-challenge-response', submit_params)
299
+ json_body = JSON.parse body
300
+ check_status json_body
301
+ ret = Comet::CometAPIResponseMessage.new
302
+ ret.from_hash(json_body)
303
+ ret
304
+ end
305
+
248
306
  # AdminAddUser
249
307
  #
250
308
  # Add a new user account.
@@ -3593,7 +3651,7 @@ module Comet
3593
3651
 
3594
3652
  ret_error = Comet::CometAPIResponseMessage.new
3595
3653
  ret_error.from_hash(obj)
3596
- raise Comet::APIResponseError.new(ret_error), 'Comet API response status was not OK'
3654
+ raise Comet::APIResponseError.new(ret_error)
3597
3655
  end
3598
3656
 
3599
3657
  # Perform a synchronous HTTP request.
@@ -3630,7 +3688,7 @@ module Comet
3630
3688
 
3631
3689
  form_params = []
3632
3690
  params.each do |k, v|
3633
- form_params.append [k, v, { :filename => k }]
3691
+ form_params.append [k, v, {:filename => k}]
3634
3692
  end
3635
3693
  req.set_form(form_params, 'multipart/form-data')
3636
3694
 
@@ -430,13 +430,13 @@ module Comet
430
430
 
431
431
  DEFAULT_TIMEZONE = 'UTC'
432
432
 
433
- APPLICATION_VERSION = '21.9.12'
433
+ APPLICATION_VERSION = '21.12.1'
434
434
 
435
435
  APPLICATION_VERSION_MAJOR = 21
436
436
 
437
- APPLICATION_VERSION_MINOR = 9
437
+ APPLICATION_VERSION_MINOR = 12
438
438
 
439
- APPLICATION_VERSION_REVISION = 12
439
+ APPLICATION_VERSION_REVISION = 1
440
440
 
441
441
  RELEASE_CODENAME = 'Voyager'
442
442
 
@@ -29,9 +29,15 @@ module Comet
29
29
  # @type [Boolean] allow_password_and_u2flogin
30
30
  attr_accessor :allow_password_and_u2flogin
31
31
 
32
+ # @type [Boolean] allow_password_and_web_authn_login
33
+ attr_accessor :allow_password_and_web_authn_login
34
+
32
35
  # @type [Array<Comet::AdminU2FRegistration>] u2fregistrations
33
36
  attr_accessor :u2fregistrations
34
37
 
38
+ # @type [Array<Comet::AdminWebAuthnRegistration>] web_authn_registrations
39
+ attr_accessor :web_authn_registrations
40
+
35
41
  # @type [Number] totpkey_encryption_format
36
42
  attr_accessor :totpkey_encryption_format
37
43
 
@@ -52,6 +58,7 @@ module Comet
52
58
  @password_format = 0
53
59
  @password = ''
54
60
  @u2fregistrations = []
61
+ @web_authn_registrations = []
55
62
  @totpkey_encryption_format = 0
56
63
  @totpkey = ''
57
64
  @ipwhitelist = ''
@@ -85,6 +92,8 @@ module Comet
85
92
  @allow_password_and_totplogin = v
86
93
  when 'AllowPasswordAndU2FLogin'
87
94
  @allow_password_and_u2flogin = v
95
+ when 'AllowPasswordAndWebAuthnLogin'
96
+ @allow_password_and_web_authn_login = v
88
97
  when 'U2FRegistrations'
89
98
  if v.nil?
90
99
  @u2fregistrations = []
@@ -95,6 +104,16 @@ module Comet
95
104
  @u2fregistrations[i1].from_hash(v1)
96
105
  end
97
106
  end
107
+ when 'WebAuthnRegistrations'
108
+ if v.nil?
109
+ @web_authn_registrations = []
110
+ else
111
+ @web_authn_registrations = Array.new(v.length)
112
+ v.each_with_index do |v1, i1|
113
+ @web_authn_registrations[i1] = Comet::AdminWebAuthnRegistration.new
114
+ @web_authn_registrations[i1].from_hash(v1)
115
+ end
116
+ end
98
117
  when 'TOTPKeyEncryptionFormat'
99
118
  raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
100
119
 
@@ -121,9 +140,13 @@ module Comet
121
140
  ret['AllowPasswordLogin'] = @allow_password_login
122
141
  ret['AllowPasswordAndTOTPLogin'] = @allow_password_and_totplogin
123
142
  ret['AllowPasswordAndU2FLogin'] = @allow_password_and_u2flogin
143
+ ret['AllowPasswordAndWebAuthnLogin'] = @allow_password_and_web_authn_login
124
144
  unless @u2fregistrations.nil?
125
145
  ret['U2FRegistrations'] = @u2fregistrations
126
146
  end
147
+ unless @web_authn_registrations.nil?
148
+ ret['WebAuthnRegistrations'] = @web_authn_registrations
149
+ end
127
150
  unless @totpkey_encryption_format.nil?
128
151
  ret['TOTPKeyEncryptionFormat'] = @totpkey_encryption_format
129
152
  end
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env ruby --enable-frozen-string-literal
2
+ #
3
+ # Copyright (c) 2020-2021 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 'base64'
11
+ require 'json'
12
+
13
+ module Comet
14
+
15
+ # AdminWebAuthnRegistration is a typed class wrapper around the underlying Comet Server API data structure.
16
+ class AdminWebAuthnRegistration
17
+
18
+ # @type [String] description
19
+ attr_accessor :description
20
+
21
+ # @type [Number] register_time
22
+ attr_accessor :register_time
23
+
24
+ # @type [Boolean] is_legacy_u2f
25
+ attr_accessor :is_legacy_u2f
26
+
27
+ # @type [Array<Object>] id
28
+ attr_accessor :id
29
+
30
+ # @type [Comet::WebAuthnCredential] credential
31
+ attr_accessor :credential
32
+
33
+ # @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
34
+ attr_accessor :unknown_json_fields
35
+
36
+ def initialize
37
+ clear
38
+ end
39
+
40
+ def clear
41
+ @description = ''
42
+ @register_time = 0
43
+ @id = []
44
+ @credential = Comet::WebAuthnCredential.new
45
+ @unknown_json_fields = {}
46
+ end
47
+
48
+ # @param [String] json_string The complete object in JSON format
49
+ def from_json(json_string)
50
+ raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String
51
+
52
+ from_hash(JSON.parse(json_string))
53
+ end
54
+
55
+ # @param [Hash] obj The complete object as a Ruby hash
56
+ def from_hash(obj)
57
+ raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash
58
+
59
+ obj.each do |k, v|
60
+ case k
61
+ when 'Description'
62
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
63
+
64
+ @description = v
65
+ when 'RegisterTime'
66
+ raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
67
+
68
+ @register_time = v
69
+ when 'IsLegacyU2F'
70
+ @is_legacy_u2f = v
71
+ when 'ID'
72
+ @id = Base64.decode64(v)
73
+ when 'Credential'
74
+ @credential = Comet::WebAuthnCredential.new
75
+ @credential.from_hash(v)
76
+ else
77
+ @unknown_json_fields[k] = v
78
+ end
79
+ end
80
+ end
81
+
82
+ # @return [Hash] The complete object as a Ruby hash
83
+ def to_hash
84
+ ret = {}
85
+ ret['Description'] = @description
86
+ ret['RegisterTime'] = @register_time
87
+ unless @is_legacy_u2f.nil?
88
+ ret['IsLegacyU2F'] = @is_legacy_u2f
89
+ end
90
+ unless @id.nil?
91
+ ret['ID'] = @id
92
+ end
93
+ unless @credential.nil?
94
+ ret['Credential'] = @credential
95
+ end
96
+ @unknown_json_fields.each do |k, v|
97
+ ret[k] = v
98
+ end
99
+ ret
100
+ end
101
+
102
+ # @return [Hash] The complete object as a Ruby hash
103
+ def to_h
104
+ to_hash
105
+ end
106
+
107
+ # @return [String] The complete object as a JSON string
108
+ def to_json(options = {})
109
+ to_hash.to_json(options)
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,212 @@
1
+ #!/usr/bin/env ruby --enable-frozen-string-literal
2
+ #
3
+ # Copyright (c) 2020-2021 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
+ # AllowedAdminUser is a typed class wrapper around the underlying Comet Server API data structure.
15
+ class AllowedAdminUser
16
+
17
+ # @type [String] username
18
+ attr_accessor :username
19
+
20
+ # @type [String] organization_id
21
+ attr_accessor :organization_id
22
+
23
+ # @type [String] external_authentication_source
24
+ attr_accessor :external_authentication_source
25
+
26
+ # @type [Number] password_format
27
+ attr_accessor :password_format
28
+
29
+ # @type [String] password
30
+ attr_accessor :password
31
+
32
+ # @type [Boolean] allow_password_login
33
+ attr_accessor :allow_password_login
34
+
35
+ # @type [Boolean] allow_password_and_totplogin
36
+ attr_accessor :allow_password_and_totplogin
37
+
38
+ # @type [Boolean] allow_password_and_u2flogin
39
+ attr_accessor :allow_password_and_u2flogin
40
+
41
+ # @type [Boolean] allow_password_and_web_authn_login
42
+ attr_accessor :allow_password_and_web_authn_login
43
+
44
+ # @type [Array<Comet::AdminU2FRegistration>] u2fregistrations
45
+ attr_accessor :u2fregistrations
46
+
47
+ # @type [Array<Comet::AdminWebAuthnRegistration>] web_authn_registrations
48
+ attr_accessor :web_authn_registrations
49
+
50
+ # @type [Number] totpkey_encryption_format
51
+ attr_accessor :totpkey_encryption_format
52
+
53
+ # @type [String] totpkey
54
+ attr_accessor :totpkey
55
+
56
+ # @type [String] ipwhitelist
57
+ attr_accessor :ipwhitelist
58
+
59
+ # @type [Comet::AdminUserPermissions] permissions
60
+ attr_accessor :permissions
61
+
62
+ # @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
63
+ attr_accessor :unknown_json_fields
64
+
65
+ def initialize
66
+ clear
67
+ end
68
+
69
+ def clear
70
+ @username = ''
71
+ @organization_id = ''
72
+ @external_authentication_source = ''
73
+ @password_format = 0
74
+ @password = ''
75
+ @u2fregistrations = []
76
+ @web_authn_registrations = []
77
+ @totpkey_encryption_format = 0
78
+ @totpkey = ''
79
+ @ipwhitelist = ''
80
+ @permissions = Comet::AdminUserPermissions.new
81
+ @unknown_json_fields = {}
82
+ end
83
+
84
+ # @param [String] json_string The complete object in JSON format
85
+ def from_json(json_string)
86
+ raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String
87
+
88
+ from_hash(JSON.parse(json_string))
89
+ end
90
+
91
+ # @param [Hash] obj The complete object as a Ruby hash
92
+ def from_hash(obj)
93
+ raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash
94
+
95
+ obj.each do |k, v|
96
+ case k
97
+ when 'Username'
98
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
99
+
100
+ @username = v
101
+ when 'OrganizationID'
102
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
103
+
104
+ @organization_id = v
105
+ when 'ExternalAuthenticationSource'
106
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
107
+
108
+ @external_authentication_source = v
109
+ when 'PasswordFormat'
110
+ raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
111
+
112
+ @password_format = v
113
+ when 'Password'
114
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
115
+
116
+ @password = v
117
+ when 'AllowPasswordLogin'
118
+ @allow_password_login = v
119
+ when 'AllowPasswordAndTOTPLogin'
120
+ @allow_password_and_totplogin = v
121
+ when 'AllowPasswordAndU2FLogin'
122
+ @allow_password_and_u2flogin = v
123
+ when 'AllowPasswordAndWebAuthnLogin'
124
+ @allow_password_and_web_authn_login = v
125
+ when 'U2FRegistrations'
126
+ if v.nil?
127
+ @u2fregistrations = []
128
+ else
129
+ @u2fregistrations = Array.new(v.length)
130
+ v.each_with_index do |v1, i1|
131
+ @u2fregistrations[i1] = Comet::AdminU2FRegistration.new
132
+ @u2fregistrations[i1].from_hash(v1)
133
+ end
134
+ end
135
+ when 'WebAuthnRegistrations'
136
+ if v.nil?
137
+ @web_authn_registrations = []
138
+ else
139
+ @web_authn_registrations = Array.new(v.length)
140
+ v.each_with_index do |v1, i1|
141
+ @web_authn_registrations[i1] = Comet::AdminWebAuthnRegistration.new
142
+ @web_authn_registrations[i1].from_hash(v1)
143
+ end
144
+ end
145
+ when 'TOTPKeyEncryptionFormat'
146
+ raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
147
+
148
+ @totpkey_encryption_format = v
149
+ when 'TOTPKey'
150
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
151
+
152
+ @totpkey = v
153
+ when 'IPWhitelist'
154
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
155
+
156
+ @ipwhitelist = v
157
+ when 'Permissions'
158
+ @permissions = Comet::AdminUserPermissions.new
159
+ @permissions.from_hash(v)
160
+ else
161
+ @unknown_json_fields[k] = v
162
+ end
163
+ end
164
+ end
165
+
166
+ # @return [Hash] The complete object as a Ruby hash
167
+ def to_hash
168
+ ret = {}
169
+ ret['Username'] = @username
170
+ ret['OrganizationID'] = @organization_id
171
+ unless @external_authentication_source.nil?
172
+ ret['ExternalAuthenticationSource'] = @external_authentication_source
173
+ end
174
+ ret['PasswordFormat'] = @password_format
175
+ ret['Password'] = @password
176
+ ret['AllowPasswordLogin'] = @allow_password_login
177
+ ret['AllowPasswordAndTOTPLogin'] = @allow_password_and_totplogin
178
+ ret['AllowPasswordAndU2FLogin'] = @allow_password_and_u2flogin
179
+ ret['AllowPasswordAndWebAuthnLogin'] = @allow_password_and_web_authn_login
180
+ unless @u2fregistrations.nil?
181
+ ret['U2FRegistrations'] = @u2fregistrations
182
+ end
183
+ unless @web_authn_registrations.nil?
184
+ ret['WebAuthnRegistrations'] = @web_authn_registrations
185
+ end
186
+ unless @totpkey_encryption_format.nil?
187
+ ret['TOTPKeyEncryptionFormat'] = @totpkey_encryption_format
188
+ end
189
+ unless @totpkey.nil?
190
+ ret['TOTPKey'] = @totpkey
191
+ end
192
+ unless @ipwhitelist.nil?
193
+ ret['IPWhitelist'] = @ipwhitelist
194
+ end
195
+ ret['Permissions'] = @permissions
196
+ @unknown_json_fields.each do |k, v|
197
+ ret[k] = v
198
+ end
199
+ ret
200
+ end
201
+
202
+ # @return [Hash] The complete object as a Ruby hash
203
+ def to_h
204
+ to_hash
205
+ end
206
+
207
+ # @return [String] The complete object as a JSON string
208
+ def to_json(options = {})
209
+ to_hash.to_json(options)
210
+ end
211
+ end
212
+ end
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env ruby --enable-frozen-string-literal
2
+ #
3
+ # Copyright (c) 2020-2021 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
+ # BrowseOffice365ListVirtualAccountsResponse is a typed class wrapper around the underlying Comet Server API data structure.
15
+ class BrowseOffice365ListVirtualAccountsResponse
16
+
17
+ # @type [Number] status
18
+ attr_accessor :status
19
+
20
+ # @type [String] message
21
+ attr_accessor :message
22
+
23
+ # @type [Array<Comet::Office365MixedVirtualAccount>] objects
24
+ attr_accessor :objects
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
+ clear
31
+ end
32
+
33
+ def clear
34
+ @status = 0
35
+ @message = ''
36
+ @objects = []
37
+ @unknown_json_fields = {}
38
+ end
39
+
40
+ # @param [String] json_string The complete object in JSON format
41
+ def from_json(json_string)
42
+ raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String
43
+
44
+ from_hash(JSON.parse(json_string))
45
+ end
46
+
47
+ # @param [Hash] obj The complete object as a Ruby hash
48
+ def from_hash(obj)
49
+ raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash
50
+
51
+ obj.each do |k, v|
52
+ case k
53
+ when 'Status'
54
+ raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
55
+
56
+ @status = v
57
+ when 'Message'
58
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
59
+
60
+ @message = v
61
+ when 'Objects'
62
+ if v.nil?
63
+ @objects = []
64
+ else
65
+ @objects = Array.new(v.length)
66
+ v.each_with_index do |v1, i1|
67
+ @objects[i1] = Comet::Office365MixedVirtualAccount.new
68
+ @objects[i1].from_hash(v1)
69
+ end
70
+ end
71
+ else
72
+ @unknown_json_fields[k] = v
73
+ end
74
+ end
75
+ end
76
+
77
+ # @return [Hash] The complete object as a Ruby hash
78
+ def to_hash
79
+ ret = {}
80
+ ret['Status'] = @status
81
+ ret['Message'] = @message
82
+ ret['Objects'] = @objects
83
+ @unknown_json_fields.each do |k, v|
84
+ ret[k] = v
85
+ end
86
+ ret
87
+ end
88
+
89
+ # @return [Hash] The complete object as a Ruby hash
90
+ def to_h
91
+ to_hash
92
+ end
93
+
94
+ # @return [String] The complete object as a JSON string
95
+ def to_json(options = {})
96
+ to_hash.to_json(options)
97
+ end
98
+ end
99
+ end