comet_backup_ruby_sdk 2.40.0 → 2.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/Gemfile.lock +1 -1
  4. data/comet_backup_ruby_sdk.gemspec +1 -1
  5. data/lib/comet/comet_server.rb +264 -6
  6. data/lib/comet/definitions.rb +45 -7
  7. data/lib/comet/models/admin_options.rb +72 -0
  8. data/lib/comet/models/backup_job_detail.rb +12 -0
  9. data/lib/comet/models/block_info.rb +82 -0
  10. data/lib/comet/models/browse_proxmox_nodes_response.rb +99 -0
  11. data/lib/comet/models/browse_proxmox_response.rb +98 -0
  12. data/lib/comet/models/browse_proxmox_storage_response.rb +98 -0
  13. data/lib/comet/models/browse_vmware_datacenters_response.rb +100 -0
  14. data/lib/comet/models/browse_vmware_datastores_response.rb +100 -0
  15. data/lib/comet/models/browse_vmware_hosts_response.rb +100 -0
  16. data/lib/comet/models/browse_vmware_networks_response.rb +100 -0
  17. data/lib/comet/models/browse_vmware_response.rb +2 -0
  18. data/lib/comet/models/disk_drive.rb +16 -0
  19. data/lib/comet/models/dispatcher_list_snapshot_virtual_machines_response.rb +99 -0
  20. data/lib/comet/models/external_authentication_source.rb +3 -3
  21. data/lib/comet/models/hyper_vmachine_info.rb +57 -0
  22. data/lib/comet/models/hyper_vrestore_target_options.rb +73 -0
  23. data/lib/comet/models/office_365custom_setting_v2.rb +64 -6
  24. data/lib/comet/models/office_365mixed_virtual_account.rb +8 -8
  25. data/lib/comet/models/partition.rb +20 -0
  26. data/lib/comet/models/partition_conflict.rb +91 -0
  27. data/lib/comet/models/policy_options.rb +80 -0
  28. data/lib/comet/models/proxmox_connection.rb +72 -0
  29. data/lib/comet/models/proxmox_restore_target_options.rb +92 -0
  30. data/lib/comet/models/pvebackup_disk.rb +86 -0
  31. data/lib/comet/models/pvebackup_node.rb +100 -0
  32. data/lib/comet/models/pvebackup_vm.rb +122 -0
  33. data/lib/comet/models/pvedisk.rb +137 -0
  34. data/lib/comet/models/pveparams.rb +138 -0
  35. data/lib/comet/models/pverestore_selection.rb +94 -0
  36. data/lib/comet/models/pvestorage_name.rb +83 -0
  37. data/lib/comet/models/pvevm.rb +148 -0
  38. data/lib/comet/models/registration_lobby_connection.rb +11 -0
  39. data/lib/comet/models/remote_server_address.rb +3 -3
  40. data/lib/comet/models/remote_storage_option.rb +3 -3
  41. data/lib/comet/models/replica_server.rb +3 -3
  42. data/lib/comet/models/request_storage_vault_response_message.rb +17 -0
  43. data/lib/comet/models/restore_job_advanced_options.rb +35 -0
  44. data/lib/comet/models/retention_range.rb +18 -0
  45. data/lib/comet/models/schedule_config.rb +18 -0
  46. data/lib/comet/models/self_backup_export_options.rb +2 -2
  47. data/lib/comet/models/self_backup_target.rb +2 -2
  48. data/lib/comet/models/user_policy.rb +11 -0
  49. data/lib/comet/models/vmdisk_info.rb +105 -0
  50. data/lib/comet/models/vminfo.rb +137 -0
  51. data/lib/comet/models/vminfo_list.rb +80 -0
  52. data/lib/comet/models/vmware_datacenter_info.rb +74 -0
  53. data/lib/comet/models/vmware_datastore_info.rb +74 -0
  54. data/lib/comet/models/vmware_host_info.rb +74 -0
  55. data/lib/comet/models/vmware_machine_info.rb +1 -0
  56. data/lib/comet/models/vmware_network_info.rb +74 -0
  57. data/lib/comet/models/vmware_restore_target_options.rb +119 -0
  58. data/lib/comet_backup_ruby_sdk.rb +33 -0
  59. metadata +33 -2
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2020-2025 Comet Licensing Ltd.
4
+ # Please see the LICENSE file for usage information.
5
+ #
6
+ # SPDX-License-Identifier: MIT
7
+
8
+ require 'json'
9
+
10
+ module Comet
11
+
12
+ # BlockInfo is a typed class wrapper around the underlying Comet Server API data structure.
13
+ class BlockInfo
14
+
15
+ # @type [String] device_id
16
+ attr_accessor :device_id
17
+
18
+ # @type [String] disk_node_name
19
+ attr_accessor :disk_node_name
20
+
21
+ # @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
22
+ attr_accessor :unknown_json_fields
23
+
24
+ def initialize
25
+ clear
26
+ end
27
+
28
+ def clear
29
+ @device_id = ''
30
+ @disk_node_name = ''
31
+ @unknown_json_fields = {}
32
+ end
33
+
34
+ # @param [String] json_string The complete object in JSON format
35
+ def from_json(json_string)
36
+ raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String
37
+
38
+ from_hash(JSON.parse(json_string))
39
+ end
40
+
41
+ # @param [Hash] obj The complete object as a Ruby hash
42
+ def from_hash(obj)
43
+ raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash
44
+
45
+ obj.each do |k, v|
46
+ case k
47
+ when 'DeviceID'
48
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
49
+
50
+ @device_id = v
51
+ when 'DiskNodeName'
52
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
53
+
54
+ @disk_node_name = v
55
+ else
56
+ @unknown_json_fields[k] = v
57
+ end
58
+ end
59
+ end
60
+
61
+ # @return [Hash] The complete object as a Ruby hash
62
+ def to_hash
63
+ ret = {}
64
+ ret['DeviceID'] = @device_id
65
+ ret['DiskNodeName'] = @disk_node_name
66
+ @unknown_json_fields.each do |k, v|
67
+ ret[k] = v
68
+ end
69
+ ret
70
+ end
71
+
72
+ # @return [Hash] The complete object as a Ruby hash
73
+ def to_h
74
+ to_hash
75
+ end
76
+
77
+ # @return [String] The complete object as a JSON string
78
+ def to_json(options = {})
79
+ to_hash.to_json(options)
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,99 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2020-2025 Comet Licensing Ltd.
4
+ # Please see the LICENSE file for usage information.
5
+ #
6
+ # SPDX-License-Identifier: MIT
7
+
8
+ require 'json'
9
+
10
+ module Comet
11
+
12
+ # BrowseProxmoxNodesResponse is a typed class wrapper around the underlying Comet Server API data structure.
13
+ class BrowseProxmoxNodesResponse
14
+
15
+ # If the operation was successful, the status will be in the 200-299 range.
16
+ # @type [Number] status
17
+ attr_accessor :status
18
+
19
+ # @type [String] message
20
+ attr_accessor :message
21
+
22
+ # @type [Array<String>] nodes
23
+ attr_accessor :nodes
24
+
25
+ # @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
26
+ attr_accessor :unknown_json_fields
27
+
28
+ def initialize
29
+ clear
30
+ end
31
+
32
+ def clear
33
+ @status = 0
34
+ @message = ''
35
+ @nodes = []
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, "'json_string' expected String, got #{json_string.class}" 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, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash
49
+
50
+ obj.each do |k, v|
51
+ case k
52
+ when 'Status'
53
+ raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
54
+
55
+ @status = v
56
+ when 'Message'
57
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
58
+
59
+ @message = v
60
+ when 'Nodes'
61
+ if v.nil?
62
+ @nodes = []
63
+ else
64
+ @nodes = Array.new(v.length)
65
+ v.each_with_index do |v1, i1|
66
+ raise TypeError, "'v1' expected String, got #{v1.class}" unless v1.is_a? String
67
+
68
+ @nodes[i1] = 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['Nodes'] = @nodes
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
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2020-2025 Comet Licensing Ltd.
4
+ # Please see the LICENSE file for usage information.
5
+ #
6
+ # SPDX-License-Identifier: MIT
7
+
8
+ require 'json'
9
+
10
+ module Comet
11
+
12
+ # BrowseProxmoxResponse is a typed class wrapper around the underlying Comet Server API data structure.
13
+ class BrowseProxmoxResponse
14
+
15
+ # If the operation was successful, the status will be in the 200-299 range.
16
+ # @type [Number] status
17
+ attr_accessor :status
18
+
19
+ # @type [String] message
20
+ attr_accessor :message
21
+
22
+ # @type [Array<Comet::PVEVM>] vms
23
+ attr_accessor :vms
24
+
25
+ # @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
26
+ attr_accessor :unknown_json_fields
27
+
28
+ def initialize
29
+ clear
30
+ end
31
+
32
+ def clear
33
+ @status = 0
34
+ @message = ''
35
+ @vms = []
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, "'json_string' expected String, got #{json_string.class}" 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, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash
49
+
50
+ obj.each do |k, v|
51
+ case k
52
+ when 'Status'
53
+ raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
54
+
55
+ @status = v
56
+ when 'Message'
57
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
58
+
59
+ @message = v
60
+ when 'VMs'
61
+ if v.nil?
62
+ @vms = []
63
+ else
64
+ @vms = Array.new(v.length)
65
+ v.each_with_index do |v1, i1|
66
+ @vms[i1] = Comet::PVEVM.new
67
+ @vms[i1].from_hash(v1)
68
+ end
69
+ end
70
+ else
71
+ @unknown_json_fields[k] = v
72
+ end
73
+ end
74
+ end
75
+
76
+ # @return [Hash] The complete object as a Ruby hash
77
+ def to_hash
78
+ ret = {}
79
+ ret['Status'] = @status
80
+ ret['Message'] = @message
81
+ ret['VMs'] = @vms
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,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2020-2025 Comet Licensing Ltd.
4
+ # Please see the LICENSE file for usage information.
5
+ #
6
+ # SPDX-License-Identifier: MIT
7
+
8
+ require 'json'
9
+
10
+ module Comet
11
+
12
+ # BrowseProxmoxStorageResponse is a typed class wrapper around the underlying Comet Server API data structure.
13
+ class BrowseProxmoxStorageResponse
14
+
15
+ # If the operation was successful, the status will be in the 200-299 range.
16
+ # @type [Number] status
17
+ attr_accessor :status
18
+
19
+ # @type [String] message
20
+ attr_accessor :message
21
+
22
+ # @type [Array<Comet::PVEStorageName>] storage
23
+ attr_accessor :storage
24
+
25
+ # @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
26
+ attr_accessor :unknown_json_fields
27
+
28
+ def initialize
29
+ clear
30
+ end
31
+
32
+ def clear
33
+ @status = 0
34
+ @message = ''
35
+ @storage = []
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, "'json_string' expected String, got #{json_string.class}" 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, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash
49
+
50
+ obj.each do |k, v|
51
+ case k
52
+ when 'Status'
53
+ raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
54
+
55
+ @status = v
56
+ when 'Message'
57
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
58
+
59
+ @message = v
60
+ when 'Storage'
61
+ if v.nil?
62
+ @storage = []
63
+ else
64
+ @storage = Array.new(v.length)
65
+ v.each_with_index do |v1, i1|
66
+ @storage[i1] = Comet::PVEStorageName.new
67
+ @storage[i1].from_hash(v1)
68
+ end
69
+ end
70
+ else
71
+ @unknown_json_fields[k] = v
72
+ end
73
+ end
74
+ end
75
+
76
+ # @return [Hash] The complete object as a Ruby hash
77
+ def to_hash
78
+ ret = {}
79
+ ret['Status'] = @status
80
+ ret['Message'] = @message
81
+ ret['Storage'] = @storage
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,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2020-2025 Comet Licensing Ltd.
4
+ # Please see the LICENSE file for usage information.
5
+ #
6
+ # SPDX-License-Identifier: MIT
7
+
8
+ require 'json'
9
+
10
+ module Comet
11
+
12
+ # BrowseVMwareDatacentersResponse is a typed class wrapper around the underlying Comet Server API data structure.
13
+ # BrowseVMwareDatacentersResponse contains a list of VMware Datacenters when remotely browsing a
14
+ # VMware vSphere connection.
15
+ class BrowseVMwareDatacentersResponse
16
+
17
+ # If the operation was successful, the status will be in the 200-299 range.
18
+ # @type [Number] status
19
+ attr_accessor :status
20
+
21
+ # @type [String] message
22
+ attr_accessor :message
23
+
24
+ # @type [Array<Comet::VMwareDatacenterInfo>] datacenters
25
+ attr_accessor :datacenters
26
+
27
+ # @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
28
+ attr_accessor :unknown_json_fields
29
+
30
+ def initialize
31
+ clear
32
+ end
33
+
34
+ def clear
35
+ @status = 0
36
+ @message = ''
37
+ @datacenters = []
38
+ @unknown_json_fields = {}
39
+ end
40
+
41
+ # @param [String] json_string The complete object in JSON format
42
+ def from_json(json_string)
43
+ raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String
44
+
45
+ from_hash(JSON.parse(json_string))
46
+ end
47
+
48
+ # @param [Hash] obj The complete object as a Ruby hash
49
+ def from_hash(obj)
50
+ raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash
51
+
52
+ obj.each do |k, v|
53
+ case k
54
+ when 'Status'
55
+ raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
56
+
57
+ @status = v
58
+ when 'Message'
59
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
60
+
61
+ @message = v
62
+ when 'Datacenters'
63
+ if v.nil?
64
+ @datacenters = []
65
+ else
66
+ @datacenters = Array.new(v.length)
67
+ v.each_with_index do |v1, i1|
68
+ @datacenters[i1] = Comet::VMwareDatacenterInfo.new
69
+ @datacenters[i1].from_hash(v1)
70
+ end
71
+ end
72
+ else
73
+ @unknown_json_fields[k] = v
74
+ end
75
+ end
76
+ end
77
+
78
+ # @return [Hash] The complete object as a Ruby hash
79
+ def to_hash
80
+ ret = {}
81
+ ret['Status'] = @status
82
+ ret['Message'] = @message
83
+ ret['Datacenters'] = @datacenters
84
+ @unknown_json_fields.each do |k, v|
85
+ ret[k] = v
86
+ end
87
+ ret
88
+ end
89
+
90
+ # @return [Hash] The complete object as a Ruby hash
91
+ def to_h
92
+ to_hash
93
+ end
94
+
95
+ # @return [String] The complete object as a JSON string
96
+ def to_json(options = {})
97
+ to_hash.to_json(options)
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2020-2025 Comet Licensing Ltd.
4
+ # Please see the LICENSE file for usage information.
5
+ #
6
+ # SPDX-License-Identifier: MIT
7
+
8
+ require 'json'
9
+
10
+ module Comet
11
+
12
+ # BrowseVMwareDatastoresResponse is a typed class wrapper around the underlying Comet Server API data structure.
13
+ # BrowseVMwareHostsResponse contains a list of VMware Datastores for a specific VMware Datacenter,
14
+ # when remotely browsing a VMware vSphere connection.
15
+ class BrowseVMwareDatastoresResponse
16
+
17
+ # If the operation was successful, the status will be in the 200-299 range.
18
+ # @type [Number] status
19
+ attr_accessor :status
20
+
21
+ # @type [String] message
22
+ attr_accessor :message
23
+
24
+ # @type [Array<Comet::VMwareDatastoreInfo>] datastores
25
+ attr_accessor :datastores
26
+
27
+ # @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
28
+ attr_accessor :unknown_json_fields
29
+
30
+ def initialize
31
+ clear
32
+ end
33
+
34
+ def clear
35
+ @status = 0
36
+ @message = ''
37
+ @datastores = []
38
+ @unknown_json_fields = {}
39
+ end
40
+
41
+ # @param [String] json_string The complete object in JSON format
42
+ def from_json(json_string)
43
+ raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String
44
+
45
+ from_hash(JSON.parse(json_string))
46
+ end
47
+
48
+ # @param [Hash] obj The complete object as a Ruby hash
49
+ def from_hash(obj)
50
+ raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash
51
+
52
+ obj.each do |k, v|
53
+ case k
54
+ when 'Status'
55
+ raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
56
+
57
+ @status = v
58
+ when 'Message'
59
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
60
+
61
+ @message = v
62
+ when 'Datastores'
63
+ if v.nil?
64
+ @datastores = []
65
+ else
66
+ @datastores = Array.new(v.length)
67
+ v.each_with_index do |v1, i1|
68
+ @datastores[i1] = Comet::VMwareDatastoreInfo.new
69
+ @datastores[i1].from_hash(v1)
70
+ end
71
+ end
72
+ else
73
+ @unknown_json_fields[k] = v
74
+ end
75
+ end
76
+ end
77
+
78
+ # @return [Hash] The complete object as a Ruby hash
79
+ def to_hash
80
+ ret = {}
81
+ ret['Status'] = @status
82
+ ret['Message'] = @message
83
+ ret['Datastores'] = @datastores
84
+ @unknown_json_fields.each do |k, v|
85
+ ret[k] = v
86
+ end
87
+ ret
88
+ end
89
+
90
+ # @return [Hash] The complete object as a Ruby hash
91
+ def to_h
92
+ to_hash
93
+ end
94
+
95
+ # @return [String] The complete object as a JSON string
96
+ def to_json(options = {})
97
+ to_hash.to_json(options)
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2020-2025 Comet Licensing Ltd.
4
+ # Please see the LICENSE file for usage information.
5
+ #
6
+ # SPDX-License-Identifier: MIT
7
+
8
+ require 'json'
9
+
10
+ module Comet
11
+
12
+ # BrowseVMwareHostsResponse is a typed class wrapper around the underlying Comet Server API data structure.
13
+ # BrowseVMwareHostsResponse contains a list of VMware Hosts for a specific VMware Datacenter, when
14
+ # remotely browsing a VMware vSphere connection.
15
+ class BrowseVMwareHostsResponse
16
+
17
+ # If the operation was successful, the status will be in the 200-299 range.
18
+ # @type [Number] status
19
+ attr_accessor :status
20
+
21
+ # @type [String] message
22
+ attr_accessor :message
23
+
24
+ # @type [Array<Comet::VMwareHostInfo>] hosts
25
+ attr_accessor :hosts
26
+
27
+ # @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
28
+ attr_accessor :unknown_json_fields
29
+
30
+ def initialize
31
+ clear
32
+ end
33
+
34
+ def clear
35
+ @status = 0
36
+ @message = ''
37
+ @hosts = []
38
+ @unknown_json_fields = {}
39
+ end
40
+
41
+ # @param [String] json_string The complete object in JSON format
42
+ def from_json(json_string)
43
+ raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String
44
+
45
+ from_hash(JSON.parse(json_string))
46
+ end
47
+
48
+ # @param [Hash] obj The complete object as a Ruby hash
49
+ def from_hash(obj)
50
+ raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash
51
+
52
+ obj.each do |k, v|
53
+ case k
54
+ when 'Status'
55
+ raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
56
+
57
+ @status = v
58
+ when 'Message'
59
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
60
+
61
+ @message = v
62
+ when 'Hosts'
63
+ if v.nil?
64
+ @hosts = []
65
+ else
66
+ @hosts = Array.new(v.length)
67
+ v.each_with_index do |v1, i1|
68
+ @hosts[i1] = Comet::VMwareHostInfo.new
69
+ @hosts[i1].from_hash(v1)
70
+ end
71
+ end
72
+ else
73
+ @unknown_json_fields[k] = v
74
+ end
75
+ end
76
+ end
77
+
78
+ # @return [Hash] The complete object as a Ruby hash
79
+ def to_hash
80
+ ret = {}
81
+ ret['Status'] = @status
82
+ ret['Message'] = @message
83
+ ret['Hosts'] = @hosts
84
+ @unknown_json_fields.each do |k, v|
85
+ ret[k] = v
86
+ end
87
+ ret
88
+ end
89
+
90
+ # @return [Hash] The complete object as a Ruby hash
91
+ def to_h
92
+ to_hash
93
+ end
94
+
95
+ # @return [String] The complete object as a JSON string
96
+ def to_json(options = {})
97
+ to_hash.to_json(options)
98
+ end
99
+ end
100
+ end