comet_backup_ruby_sdk 2.41.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/comet_backup_ruby_sdk.gemspec +1 -1
- data/lib/comet/comet_server.rb +95 -4
- data/lib/comet/definitions.rb +41 -7
- data/lib/comet/models/backup_job_detail.rb +12 -0
- data/lib/comet/models/block_info.rb +82 -0
- data/lib/comet/models/browse_proxmox_nodes_response.rb +99 -0
- data/lib/comet/models/browse_proxmox_response.rb +98 -0
- data/lib/comet/models/browse_proxmox_storage_response.rb +98 -0
- data/lib/comet/models/external_authentication_source.rb +3 -3
- data/lib/comet/models/office_365custom_setting_v2.rb +16 -5
- data/lib/comet/models/partition.rb +20 -0
- data/lib/comet/models/proxmox_connection.rb +72 -0
- data/lib/comet/models/proxmox_restore_target_options.rb +92 -0
- data/lib/comet/models/pvebackup_disk.rb +86 -0
- data/lib/comet/models/pvebackup_node.rb +100 -0
- data/lib/comet/models/pvebackup_vm.rb +122 -0
- data/lib/comet/models/pvedisk.rb +137 -0
- data/lib/comet/models/pveparams.rb +138 -0
- data/lib/comet/models/pverestore_selection.rb +94 -0
- data/lib/comet/models/pvestorage_name.rb +83 -0
- data/lib/comet/models/pvevm.rb +148 -0
- data/lib/comet/models/registration_lobby_connection.rb +11 -0
- data/lib/comet/models/remote_server_address.rb +3 -3
- data/lib/comet/models/remote_storage_option.rb +3 -3
- data/lib/comet/models/replica_server.rb +3 -3
- data/lib/comet/models/request_storage_vault_response_message.rb +17 -0
- data/lib/comet/models/restore_job_advanced_options.rb +11 -0
- data/lib/comet/models/retention_range.rb +18 -0
- data/lib/comet/models/schedule_config.rb +18 -0
- data/lib/comet/models/self_backup_export_options.rb +2 -2
- data/lib/comet/models/self_backup_target.rb +2 -2
- data/lib/comet/models/user_policy.rb +11 -0
- data/lib/comet_backup_ruby_sdk.rb +16 -0
- metadata +16 -2
@@ -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
|
@@ -18,15 +18,15 @@ module Comet
|
|
18
18
|
# @type [String] description
|
19
19
|
attr_accessor :description
|
20
20
|
|
21
|
-
# For use with Comet Server (Storage
|
21
|
+
# For use with Comet Server (Storage Gateway / Management Console)
|
22
22
|
# @type [String] remote_address
|
23
23
|
attr_accessor :remote_address
|
24
24
|
|
25
|
-
# For use with Comet Server (Storage
|
25
|
+
# For use with Comet Server (Storage Gateway / Management Console)
|
26
26
|
# @type [String] username
|
27
27
|
attr_accessor :username
|
28
28
|
|
29
|
-
# For use with Comet Server (Storage
|
29
|
+
# For use with Comet Server (Storage Gateway / Management Console)
|
30
30
|
# @type [String] password
|
31
31
|
attr_accessor :password
|
32
32
|
|
@@ -24,23 +24,27 @@ module Comet
|
|
24
24
|
# @type [Boolean] filter_mode
|
25
25
|
attr_accessor :filter_mode
|
26
26
|
|
27
|
+
# If true, backup everything, ignoring selection and filter options
|
28
|
+
# @type [Boolean] whole_org
|
29
|
+
attr_accessor :whole_org
|
30
|
+
|
27
31
|
# Key is the ID of User, Group, or Site
|
28
|
-
# Value is a bitset of the SERVICE_ constants, to select which services to
|
32
|
+
# Value is a bitset of the SERVICE_ constants, to select which services to backup for accounts
|
29
33
|
# @type [Hash{String => Number}] backup_options
|
30
34
|
attr_accessor :backup_options
|
31
35
|
|
32
36
|
# Key is the ID of a Group or Team Site
|
33
|
-
# Value is a bitset of the SERVICE_ constants, to select which services to
|
37
|
+
# Value is a bitset of the SERVICE_ constants, to select which services to backup for members
|
34
38
|
# @type [Hash{String => Number}] member_backup_options
|
35
39
|
attr_accessor :member_backup_options
|
36
40
|
|
37
41
|
# Key is the ID of a User, Group, or Site
|
38
|
-
# Value is a bitset of the SERVICE_ constants, to select which services to
|
42
|
+
# Value is a bitset of the SERVICE_ constants, to select which services to not backup for accounts
|
39
43
|
# @type [Hash{String => Number}] filter_options
|
40
44
|
attr_accessor :filter_options
|
41
45
|
|
42
46
|
# Key is the ID of a Group or Team Site
|
43
|
-
# Value is a bitset of the SERVICE_ constants, to select which services to
|
47
|
+
# Value is a bitset of the SERVICE_ constants, to select which services to not backup for members
|
44
48
|
# @type [Hash{String => Number}] filter_member_options
|
45
49
|
attr_accessor :filter_member_options
|
46
50
|
|
@@ -76,6 +80,8 @@ module Comet
|
|
76
80
|
@organization = v
|
77
81
|
when 'FilterMode'
|
78
82
|
@filter_mode = v
|
83
|
+
when 'WholeOrg'
|
84
|
+
@whole_org = v
|
79
85
|
when 'BackupOptions'
|
80
86
|
@backup_options = {}
|
81
87
|
if v.nil?
|
@@ -130,7 +136,12 @@ module Comet
|
|
130
136
|
def to_hash
|
131
137
|
ret = {}
|
132
138
|
ret['Organization'] = @organization
|
133
|
-
|
139
|
+
unless @filter_mode.nil?
|
140
|
+
ret['FilterMode'] = @filter_mode
|
141
|
+
end
|
142
|
+
unless @whole_org.nil?
|
143
|
+
ret['WholeOrg'] = @whole_org
|
144
|
+
end
|
134
145
|
unless @backup_options.nil?
|
135
146
|
ret['BackupOptions'] = @backup_options
|
136
147
|
end
|
@@ -15,6 +15,14 @@ module Comet
|
|
15
15
|
# @type [String] device_name
|
16
16
|
attr_accessor :device_name
|
17
17
|
|
18
|
+
# The partition's MBR or GPT id, if any
|
19
|
+
# @type [String] partition_guid
|
20
|
+
attr_accessor :partition_guid
|
21
|
+
|
22
|
+
# The partition's offset within the physical disk
|
23
|
+
# @type [Number] partition_offset
|
24
|
+
attr_accessor :partition_offset
|
25
|
+
|
18
26
|
# The name of the filesystem used on this partition (e.g. "NTFS")
|
19
27
|
# @type [String] filesystem
|
20
28
|
attr_accessor :filesystem
|
@@ -59,6 +67,8 @@ module Comet
|
|
59
67
|
|
60
68
|
def clear
|
61
69
|
@device_name = ''
|
70
|
+
@partition_guid = ''
|
71
|
+
@partition_offset = 0
|
62
72
|
@filesystem = ''
|
63
73
|
@volume_name = ''
|
64
74
|
@volume_guid = ''
|
@@ -89,6 +99,14 @@ module Comet
|
|
89
99
|
raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
|
90
100
|
|
91
101
|
@device_name = v
|
102
|
+
when 'PartitionGuid'
|
103
|
+
raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
|
104
|
+
|
105
|
+
@partition_guid = v
|
106
|
+
when 'PartitionOffset'
|
107
|
+
raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
|
108
|
+
|
109
|
+
@partition_offset = v
|
92
110
|
when 'Filesystem'
|
93
111
|
raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
|
94
112
|
|
@@ -146,6 +164,8 @@ module Comet
|
|
146
164
|
def to_hash
|
147
165
|
ret = {}
|
148
166
|
ret['DeviceName'] = @device_name
|
167
|
+
ret['PartitionGuid'] = @partition_guid
|
168
|
+
ret['PartitionOffset'] = @partition_offset
|
149
169
|
ret['Filesystem'] = @filesystem
|
150
170
|
ret['VolumeName'] = @volume_name
|
151
171
|
ret['VolumeGuid'] = @volume_guid
|
@@ -0,0 +1,72 @@
|
|
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
|
+
# ProxmoxConnection is a typed class wrapper around the underlying Comet Server API data structure.
|
13
|
+
class ProxmoxConnection
|
14
|
+
|
15
|
+
# @type [Comet::SSHConnection] ssh
|
16
|
+
attr_accessor :ssh
|
17
|
+
|
18
|
+
# @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
|
19
|
+
attr_accessor :unknown_json_fields
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
clear
|
23
|
+
end
|
24
|
+
|
25
|
+
def clear
|
26
|
+
@ssh = Comet::SSHConnection.new
|
27
|
+
@unknown_json_fields = {}
|
28
|
+
end
|
29
|
+
|
30
|
+
# @param [String] json_string The complete object in JSON format
|
31
|
+
def from_json(json_string)
|
32
|
+
raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String
|
33
|
+
|
34
|
+
from_hash(JSON.parse(json_string))
|
35
|
+
end
|
36
|
+
|
37
|
+
# @param [Hash] obj The complete object as a Ruby hash
|
38
|
+
def from_hash(obj)
|
39
|
+
raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash
|
40
|
+
|
41
|
+
obj.each do |k, v|
|
42
|
+
case k
|
43
|
+
when 'SSH'
|
44
|
+
@ssh = Comet::SSHConnection.new
|
45
|
+
@ssh.from_hash(v)
|
46
|
+
else
|
47
|
+
@unknown_json_fields[k] = v
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# @return [Hash] The complete object as a Ruby hash
|
53
|
+
def to_hash
|
54
|
+
ret = {}
|
55
|
+
ret['SSH'] = @ssh
|
56
|
+
@unknown_json_fields.each do |k, v|
|
57
|
+
ret[k] = v
|
58
|
+
end
|
59
|
+
ret
|
60
|
+
end
|
61
|
+
|
62
|
+
# @return [Hash] The complete object as a Ruby hash
|
63
|
+
def to_h
|
64
|
+
to_hash
|
65
|
+
end
|
66
|
+
|
67
|
+
# @return [String] The complete object as a JSON string
|
68
|
+
def to_json(options = {})
|
69
|
+
to_hash.to_json(options)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,92 @@
|
|
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
|
+
# ProxmoxRestoreTargetOptions is a typed class wrapper around the underlying Comet Server API data structure.
|
13
|
+
class ProxmoxRestoreTargetOptions
|
14
|
+
|
15
|
+
# The name of the node to restore to in the Proxmox Cluster
|
16
|
+
# @type [String] node
|
17
|
+
attr_accessor :node
|
18
|
+
|
19
|
+
# @type [Comet::SSHConnection] ssh
|
20
|
+
attr_accessor :ssh
|
21
|
+
|
22
|
+
# the name of the storage location to restore to
|
23
|
+
# @type [String] storage
|
24
|
+
attr_accessor :storage
|
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
|
+
@node = ''
|
35
|
+
@ssh = Comet::SSHConnection.new
|
36
|
+
@storage = ''
|
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 'Node'
|
54
|
+
raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
|
55
|
+
|
56
|
+
@node = v
|
57
|
+
when 'SSH'
|
58
|
+
@ssh = Comet::SSHConnection.new
|
59
|
+
@ssh.from_hash(v)
|
60
|
+
when 'Storage'
|
61
|
+
raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
|
62
|
+
|
63
|
+
@storage = v
|
64
|
+
else
|
65
|
+
@unknown_json_fields[k] = v
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# @return [Hash] The complete object as a Ruby hash
|
71
|
+
def to_hash
|
72
|
+
ret = {}
|
73
|
+
ret['Node'] = @node
|
74
|
+
ret['SSH'] = @ssh
|
75
|
+
ret['Storage'] = @storage
|
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
|
@@ -0,0 +1,86 @@
|
|
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
|
+
# PVEBackupDisk is a typed class wrapper around the underlying Comet Server API data structure.
|
13
|
+
class PVEBackupDisk
|
14
|
+
|
15
|
+
# @type [String] device
|
16
|
+
attr_accessor :device
|
17
|
+
|
18
|
+
# @type [Number] device_num
|
19
|
+
attr_accessor :device_num
|
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 = ''
|
30
|
+
@device_num = 0
|
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 'Device'
|
48
|
+
raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
|
49
|
+
|
50
|
+
@device = v
|
51
|
+
when 'DeviceNum'
|
52
|
+
raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
|
53
|
+
|
54
|
+
@device_num = 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
|
+
unless @device.nil?
|
65
|
+
ret['Device'] = @device
|
66
|
+
end
|
67
|
+
unless @device_num.nil?
|
68
|
+
ret['DeviceNum'] = @device_num
|
69
|
+
end
|
70
|
+
@unknown_json_fields.each do |k, v|
|
71
|
+
ret[k] = v
|
72
|
+
end
|
73
|
+
ret
|
74
|
+
end
|
75
|
+
|
76
|
+
# @return [Hash] The complete object as a Ruby hash
|
77
|
+
def to_h
|
78
|
+
to_hash
|
79
|
+
end
|
80
|
+
|
81
|
+
# @return [String] The complete object as a JSON string
|
82
|
+
def to_json(options = {})
|
83
|
+
to_hash.to_json(options)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
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
|
+
# PVEBackupNode is a typed class wrapper around the underlying Comet Server API data structure.
|
13
|
+
class PVEBackupNode
|
14
|
+
|
15
|
+
# @type [Array<Comet::PVEBackupVM>] included_vms
|
16
|
+
attr_accessor :included_vms
|
17
|
+
|
18
|
+
# @type [String] name
|
19
|
+
attr_accessor :name
|
20
|
+
|
21
|
+
# @type [Boolean] selected
|
22
|
+
attr_accessor :selected
|
23
|
+
|
24
|
+
# @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
|
25
|
+
attr_accessor :unknown_json_fields
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
clear
|
29
|
+
end
|
30
|
+
|
31
|
+
def clear
|
32
|
+
@included_vms = []
|
33
|
+
@name = ''
|
34
|
+
@unknown_json_fields = {}
|
35
|
+
end
|
36
|
+
|
37
|
+
# @param [String] json_string The complete object in JSON format
|
38
|
+
def from_json(json_string)
|
39
|
+
raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String
|
40
|
+
|
41
|
+
from_hash(JSON.parse(json_string))
|
42
|
+
end
|
43
|
+
|
44
|
+
# @param [Hash] obj The complete object as a Ruby hash
|
45
|
+
def from_hash(obj)
|
46
|
+
raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash
|
47
|
+
|
48
|
+
obj.each do |k, v|
|
49
|
+
case k
|
50
|
+
when 'IncludedVMs'
|
51
|
+
if v.nil?
|
52
|
+
@included_vms = []
|
53
|
+
else
|
54
|
+
@included_vms = Array.new(v.length)
|
55
|
+
v.each_with_index do |v1, i1|
|
56
|
+
@included_vms[i1] = Comet::PVEBackupVM.new
|
57
|
+
@included_vms[i1].from_hash(v1)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
when 'Name'
|
61
|
+
raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
|
62
|
+
|
63
|
+
@name = v
|
64
|
+
when 'Selected'
|
65
|
+
@selected = v
|
66
|
+
else
|
67
|
+
@unknown_json_fields[k] = v
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# @return [Hash] The complete object as a Ruby hash
|
73
|
+
def to_hash
|
74
|
+
ret = {}
|
75
|
+
unless @included_vms.nil?
|
76
|
+
ret['IncludedVMs'] = @included_vms
|
77
|
+
end
|
78
|
+
unless @name.nil?
|
79
|
+
ret['Name'] = @name
|
80
|
+
end
|
81
|
+
unless @selected.nil?
|
82
|
+
ret['Selected'] = @selected
|
83
|
+
end
|
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,122 @@
|
|
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
|
+
# PVEBackupVM is a typed class wrapper around the underlying Comet Server API data structure.
|
13
|
+
class PVEBackupVM
|
14
|
+
|
15
|
+
# @type [Array<Comet::PVEBackupDisk>] included_disks
|
16
|
+
attr_accessor :included_disks
|
17
|
+
|
18
|
+
# @type [String] name
|
19
|
+
attr_accessor :name
|
20
|
+
|
21
|
+
# @type [Boolean] selected
|
22
|
+
attr_accessor :selected
|
23
|
+
|
24
|
+
# @type [String] type
|
25
|
+
attr_accessor :type
|
26
|
+
|
27
|
+
# @type [String] vmid
|
28
|
+
attr_accessor :vmid
|
29
|
+
|
30
|
+
# @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
|
31
|
+
attr_accessor :unknown_json_fields
|
32
|
+
|
33
|
+
def initialize
|
34
|
+
clear
|
35
|
+
end
|
36
|
+
|
37
|
+
def clear
|
38
|
+
@included_disks = []
|
39
|
+
@name = ''
|
40
|
+
@type = ''
|
41
|
+
@vmid = ''
|
42
|
+
@unknown_json_fields = {}
|
43
|
+
end
|
44
|
+
|
45
|
+
# @param [String] json_string The complete object in JSON format
|
46
|
+
def from_json(json_string)
|
47
|
+
raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String
|
48
|
+
|
49
|
+
from_hash(JSON.parse(json_string))
|
50
|
+
end
|
51
|
+
|
52
|
+
# @param [Hash] obj The complete object as a Ruby hash
|
53
|
+
def from_hash(obj)
|
54
|
+
raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash
|
55
|
+
|
56
|
+
obj.each do |k, v|
|
57
|
+
case k
|
58
|
+
when 'IncludedDisks'
|
59
|
+
if v.nil?
|
60
|
+
@included_disks = []
|
61
|
+
else
|
62
|
+
@included_disks = Array.new(v.length)
|
63
|
+
v.each_with_index do |v1, i1|
|
64
|
+
@included_disks[i1] = Comet::PVEBackupDisk.new
|
65
|
+
@included_disks[i1].from_hash(v1)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
when 'Name'
|
69
|
+
raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
|
70
|
+
|
71
|
+
@name = v
|
72
|
+
when 'Selected'
|
73
|
+
@selected = v
|
74
|
+
when 'Type'
|
75
|
+
raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
|
76
|
+
|
77
|
+
@type = v
|
78
|
+
when 'VMID'
|
79
|
+
raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
|
80
|
+
|
81
|
+
@vmid = v
|
82
|
+
else
|
83
|
+
@unknown_json_fields[k] = v
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# @return [Hash] The complete object as a Ruby hash
|
89
|
+
def to_hash
|
90
|
+
ret = {}
|
91
|
+
unless @included_disks.nil?
|
92
|
+
ret['IncludedDisks'] = @included_disks
|
93
|
+
end
|
94
|
+
unless @name.nil?
|
95
|
+
ret['Name'] = @name
|
96
|
+
end
|
97
|
+
unless @selected.nil?
|
98
|
+
ret['Selected'] = @selected
|
99
|
+
end
|
100
|
+
unless @type.nil?
|
101
|
+
ret['Type'] = @type
|
102
|
+
end
|
103
|
+
unless @vmid.nil?
|
104
|
+
ret['VMID'] = @vmid
|
105
|
+
end
|
106
|
+
@unknown_json_fields.each do |k, v|
|
107
|
+
ret[k] = v
|
108
|
+
end
|
109
|
+
ret
|
110
|
+
end
|
111
|
+
|
112
|
+
# @return [Hash] The complete object as a Ruby hash
|
113
|
+
def to_h
|
114
|
+
to_hash
|
115
|
+
end
|
116
|
+
|
117
|
+
# @return [String] The complete object as a JSON string
|
118
|
+
def to_json(options = {})
|
119
|
+
to_hash.to_json(options)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|