oraclebmc 1.1.2 → 1.2.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/LICENSE.txt +2 -2
- data/README.md +2 -2
- data/lib/oraclebmc/api_client.rb +1 -50
- data/lib/oraclebmc/core/compute_client.rb +33 -0
- data/lib/oraclebmc/core/core.rb +2 -0
- data/lib/oraclebmc/core/models/attach_i_scsi_volume_details.rb +2 -43
- data/lib/oraclebmc/core/models/attach_volume_details.rb +2 -43
- data/lib/oraclebmc/core/models/capture_console_history_details.rb +2 -43
- data/lib/oraclebmc/core/models/console_history.rb +2 -43
- data/lib/oraclebmc/core/models/cpe.rb +2 -43
- data/lib/oraclebmc/core/models/create_cpe_details.rb +2 -43
- data/lib/oraclebmc/core/models/create_dhcp_details.rb +2 -43
- data/lib/oraclebmc/core/models/create_drg_attachment_details.rb +2 -43
- data/lib/oraclebmc/core/models/create_drg_details.rb +2 -43
- data/lib/oraclebmc/core/models/create_image_details.rb +2 -43
- data/lib/oraclebmc/core/models/create_internet_gateway_details.rb +2 -43
- data/lib/oraclebmc/core/models/create_ip_sec_connection_details.rb +2 -43
- data/lib/oraclebmc/core/models/create_route_table_details.rb +2 -43
- data/lib/oraclebmc/core/models/create_security_list_details.rb +2 -43
- data/lib/oraclebmc/core/models/create_subnet_details.rb +28 -44
- data/lib/oraclebmc/core/models/create_vcn_details.rb +33 -47
- data/lib/oraclebmc/core/models/create_volume_backup_details.rb +2 -43
- data/lib/oraclebmc/core/models/create_volume_details.rb +2 -43
- data/lib/oraclebmc/core/models/dhcp_dns_option.rb +16 -49
- data/lib/oraclebmc/core/models/dhcp_option.rb +7 -43
- data/lib/oraclebmc/core/models/dhcp_options.rb +2 -43
- data/lib/oraclebmc/core/models/dhcp_search_domain_option.rb +143 -0
- data/lib/oraclebmc/core/models/drg.rb +2 -43
- data/lib/oraclebmc/core/models/drg_attachment.rb +2 -43
- data/lib/oraclebmc/core/models/egress_security_rule.rb +2 -43
- data/lib/oraclebmc/core/models/i_scsi_volume_attachment.rb +2 -43
- data/lib/oraclebmc/core/models/icmp_options.rb +2 -43
- data/lib/oraclebmc/core/models/image.rb +2 -43
- data/lib/oraclebmc/core/models/ingress_security_rule.rb +2 -43
- data/lib/oraclebmc/core/models/instance.rb +7 -43
- data/lib/oraclebmc/core/models/instance_credentials.rb +132 -0
- data/lib/oraclebmc/core/models/internet_gateway.rb +2 -43
- data/lib/oraclebmc/core/models/ip_sec_connection.rb +2 -43
- data/lib/oraclebmc/core/models/ip_sec_connection_device_config.rb +2 -43
- data/lib/oraclebmc/core/models/ip_sec_connection_device_status.rb +2 -43
- data/lib/oraclebmc/core/models/launch_instance_details.rb +32 -44
- data/lib/oraclebmc/core/models/port_range.rb +2 -43
- data/lib/oraclebmc/core/models/route_rule.rb +2 -43
- data/lib/oraclebmc/core/models/route_table.rb +2 -43
- data/lib/oraclebmc/core/models/security_list.rb +2 -43
- data/lib/oraclebmc/core/models/shape.rb +2 -43
- data/lib/oraclebmc/core/models/subnet.rb +45 -44
- data/lib/oraclebmc/core/models/tcp_options.rb +2 -43
- data/lib/oraclebmc/core/models/tunnel_config.rb +2 -43
- data/lib/oraclebmc/core/models/tunnel_status.rb +2 -43
- data/lib/oraclebmc/core/models/udp_options.rb +2 -43
- data/lib/oraclebmc/core/models/update_cpe_details.rb +2 -43
- data/lib/oraclebmc/core/models/update_dhcp_details.rb +2 -43
- data/lib/oraclebmc/core/models/update_drg_attachment_details.rb +2 -43
- data/lib/oraclebmc/core/models/update_drg_details.rb +2 -43
- data/lib/oraclebmc/core/models/update_image_details.rb +2 -43
- data/lib/oraclebmc/core/models/update_instance_details.rb +2 -43
- data/lib/oraclebmc/core/models/update_internet_gateway_details.rb +2 -43
- data/lib/oraclebmc/core/models/update_ip_sec_connection_details.rb +2 -43
- data/lib/oraclebmc/core/models/update_route_table_details.rb +2 -43
- data/lib/oraclebmc/core/models/update_security_list_details.rb +2 -43
- data/lib/oraclebmc/core/models/update_subnet_details.rb +2 -43
- data/lib/oraclebmc/core/models/update_vcn_details.rb +2 -43
- data/lib/oraclebmc/core/models/update_volume_backup_details.rb +2 -43
- data/lib/oraclebmc/core/models/update_volume_details.rb +2 -43
- data/lib/oraclebmc/core/models/vcn.rb +48 -47
- data/lib/oraclebmc/core/models/vnic.rb +30 -47
- data/lib/oraclebmc/core/models/vnic_attachment.rb +2 -43
- data/lib/oraclebmc/core/models/volume.rb +2 -43
- data/lib/oraclebmc/core/models/volume_attachment.rb +2 -43
- data/lib/oraclebmc/core/models/volume_backup.rb +2 -43
- data/lib/oraclebmc/core/virtual_network_client.rb +10 -4
- data/lib/oraclebmc/identity/models/add_user_to_group_details.rb +2 -43
- data/lib/oraclebmc/identity/models/api_key.rb +2 -43
- data/lib/oraclebmc/identity/models/availability_domain.rb +2 -43
- data/lib/oraclebmc/identity/models/compartment.rb +2 -43
- data/lib/oraclebmc/identity/models/create_api_key_details.rb +2 -43
- data/lib/oraclebmc/identity/models/create_compartment_details.rb +2 -43
- data/lib/oraclebmc/identity/models/create_group_details.rb +2 -43
- data/lib/oraclebmc/identity/models/create_policy_details.rb +2 -43
- data/lib/oraclebmc/identity/models/create_swift_password_details.rb +2 -43
- data/lib/oraclebmc/identity/models/create_user_details.rb +2 -43
- data/lib/oraclebmc/identity/models/group.rb +2 -43
- data/lib/oraclebmc/identity/models/policy.rb +2 -43
- data/lib/oraclebmc/identity/models/swift_password.rb +2 -43
- data/lib/oraclebmc/identity/models/ui_password.rb +2 -43
- data/lib/oraclebmc/identity/models/update_compartment_details.rb +2 -43
- data/lib/oraclebmc/identity/models/update_group_details.rb +2 -43
- data/lib/oraclebmc/identity/models/update_policy_details.rb +2 -43
- data/lib/oraclebmc/identity/models/update_state_details.rb +2 -43
- data/lib/oraclebmc/identity/models/update_swift_password_details.rb +2 -43
- data/lib/oraclebmc/identity/models/update_user_details.rb +2 -43
- data/lib/oraclebmc/identity/models/user.rb +2 -43
- data/lib/oraclebmc/identity/models/user_group_membership.rb +2 -43
- data/lib/oraclebmc/internal/internal.rb +11 -0
- data/lib/oraclebmc/internal/util.rb +69 -0
- data/lib/oraclebmc/load_balancer/models/backend.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/backend_details.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/backend_set.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/backend_set_details.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/certificate.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/certificate_details.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/create_backend_details.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/create_backend_set_details.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/create_certificate_details.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/create_listener_details.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/create_load_balancer_details.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/health_checker.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/health_checker_details.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/ip_address.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/listener.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/listener_details.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/load_balancer.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/load_balancer_policy.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/load_balancer_protocol.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/load_balancer_shape.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/ssl_configuration.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/ssl_configuration_details.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/update_backend_details.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/update_backend_set_details.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/update_health_checker_details.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/update_listener_details.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/update_load_balancer_details.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/work_request.rb +2 -43
- data/lib/oraclebmc/load_balancer/models/work_request_error.rb +2 -43
- data/lib/oraclebmc/version.rb +1 -1
- data/lib/oraclebmc.rb +1 -0
- metadata +6 -2
|
@@ -55,10 +55,10 @@ module OracleBMC
|
|
|
55
55
|
# check to ensure the input is an array given that the the attribute
|
|
56
56
|
# is documented as an array but the input is not
|
|
57
57
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
58
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v|
|
|
58
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| OracleBMC::Internal::Util.convert_to_type($1, v) } )
|
|
59
59
|
end
|
|
60
60
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
61
|
-
self.send("#{key}=",
|
|
61
|
+
self.send("#{key}=", OracleBMC::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]]))
|
|
62
62
|
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
63
63
|
end
|
|
64
64
|
|
|
@@ -103,47 +103,6 @@ module OracleBMC
|
|
|
103
103
|
end
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
-
# Deserializes the data based on type
|
|
107
|
-
# @param [String] type Data type
|
|
108
|
-
# @param [String] value Value to be deserialized
|
|
109
|
-
# @return [Object] Deserialized data
|
|
110
|
-
def _deserialize(type, value)
|
|
111
|
-
case type.to_sym
|
|
112
|
-
when :DateTime
|
|
113
|
-
DateTime.parse(value)
|
|
114
|
-
when :Date
|
|
115
|
-
Date.parse(value)
|
|
116
|
-
when :String
|
|
117
|
-
value.to_s
|
|
118
|
-
when :Integer
|
|
119
|
-
value.to_i
|
|
120
|
-
when :Float
|
|
121
|
-
value.to_f
|
|
122
|
-
when :BOOLEAN
|
|
123
|
-
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
|
124
|
-
true
|
|
125
|
-
else
|
|
126
|
-
false
|
|
127
|
-
end
|
|
128
|
-
when :Object
|
|
129
|
-
# generic object (usually a Hash), return directly
|
|
130
|
-
value
|
|
131
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
|
132
|
-
inner_type = Regexp.last_match[:inner_type]
|
|
133
|
-
value.map { |v| _deserialize(inner_type, v) }
|
|
134
|
-
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
|
135
|
-
k_type = Regexp.last_match[:k_type]
|
|
136
|
-
v_type = Regexp.last_match[:v_type]
|
|
137
|
-
{}.tap do |hash|
|
|
138
|
-
value.each do |k, v|
|
|
139
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
else # model
|
|
143
|
-
temp_model = OracleBMC.const_get(type.to_s).new
|
|
144
|
-
temp_model.build_from_hash(value)
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
106
|
|
|
148
107
|
|
|
149
108
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
@@ -54,10 +54,10 @@ module OracleBMC
|
|
|
54
54
|
# check to ensure the input is an array given that the the attribute
|
|
55
55
|
# is documented as an array but the input is not
|
|
56
56
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
57
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v|
|
|
57
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| OracleBMC::Internal::Util.convert_to_type($1, v) } )
|
|
58
58
|
end
|
|
59
59
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
60
|
-
self.send("#{key}=",
|
|
60
|
+
self.send("#{key}=", OracleBMC::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]]))
|
|
61
61
|
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
62
62
|
end
|
|
63
63
|
|
|
@@ -102,47 +102,6 @@ module OracleBMC
|
|
|
102
102
|
end
|
|
103
103
|
end
|
|
104
104
|
|
|
105
|
-
# Deserializes the data based on type
|
|
106
|
-
# @param [String] type Data type
|
|
107
|
-
# @param [String] value Value to be deserialized
|
|
108
|
-
# @return [Object] Deserialized data
|
|
109
|
-
def _deserialize(type, value)
|
|
110
|
-
case type.to_sym
|
|
111
|
-
when :DateTime
|
|
112
|
-
DateTime.parse(value)
|
|
113
|
-
when :Date
|
|
114
|
-
Date.parse(value)
|
|
115
|
-
when :String
|
|
116
|
-
value.to_s
|
|
117
|
-
when :Integer
|
|
118
|
-
value.to_i
|
|
119
|
-
when :Float
|
|
120
|
-
value.to_f
|
|
121
|
-
when :BOOLEAN
|
|
122
|
-
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
|
123
|
-
true
|
|
124
|
-
else
|
|
125
|
-
false
|
|
126
|
-
end
|
|
127
|
-
when :Object
|
|
128
|
-
# generic object (usually a Hash), return directly
|
|
129
|
-
value
|
|
130
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
|
131
|
-
inner_type = Regexp.last_match[:inner_type]
|
|
132
|
-
value.map { |v| _deserialize(inner_type, v) }
|
|
133
|
-
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
|
134
|
-
k_type = Regexp.last_match[:k_type]
|
|
135
|
-
v_type = Regexp.last_match[:v_type]
|
|
136
|
-
{}.tap do |hash|
|
|
137
|
-
value.each do |k, v|
|
|
138
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
else # model
|
|
142
|
-
temp_model = OracleBMC.const_get(type.to_s).new
|
|
143
|
-
temp_model.build_from_hash(value)
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
105
|
|
|
147
106
|
|
|
148
107
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
@@ -54,10 +54,10 @@ module OracleBMC
|
|
|
54
54
|
# check to ensure the input is an array given that the the attribute
|
|
55
55
|
# is documented as an array but the input is not
|
|
56
56
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
57
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v|
|
|
57
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| OracleBMC::Internal::Util.convert_to_type($1, v) } )
|
|
58
58
|
end
|
|
59
59
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
60
|
-
self.send("#{key}=",
|
|
60
|
+
self.send("#{key}=", OracleBMC::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]]))
|
|
61
61
|
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
62
62
|
end
|
|
63
63
|
|
|
@@ -102,47 +102,6 @@ module OracleBMC
|
|
|
102
102
|
end
|
|
103
103
|
end
|
|
104
104
|
|
|
105
|
-
# Deserializes the data based on type
|
|
106
|
-
# @param [String] type Data type
|
|
107
|
-
# @param [String] value Value to be deserialized
|
|
108
|
-
# @return [Object] Deserialized data
|
|
109
|
-
def _deserialize(type, value)
|
|
110
|
-
case type.to_sym
|
|
111
|
-
when :DateTime
|
|
112
|
-
DateTime.parse(value)
|
|
113
|
-
when :Date
|
|
114
|
-
Date.parse(value)
|
|
115
|
-
when :String
|
|
116
|
-
value.to_s
|
|
117
|
-
when :Integer
|
|
118
|
-
value.to_i
|
|
119
|
-
when :Float
|
|
120
|
-
value.to_f
|
|
121
|
-
when :BOOLEAN
|
|
122
|
-
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
|
123
|
-
true
|
|
124
|
-
else
|
|
125
|
-
false
|
|
126
|
-
end
|
|
127
|
-
when :Object
|
|
128
|
-
# generic object (usually a Hash), return directly
|
|
129
|
-
value
|
|
130
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
|
131
|
-
inner_type = Regexp.last_match[:inner_type]
|
|
132
|
-
value.map { |v| _deserialize(inner_type, v) }
|
|
133
|
-
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
|
134
|
-
k_type = Regexp.last_match[:k_type]
|
|
135
|
-
v_type = Regexp.last_match[:v_type]
|
|
136
|
-
{}.tap do |hash|
|
|
137
|
-
value.each do |k, v|
|
|
138
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
else # model
|
|
142
|
-
temp_model = OracleBMC.const_get(type.to_s).new
|
|
143
|
-
temp_model.build_from_hash(value)
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
105
|
|
|
147
106
|
|
|
148
107
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
@@ -137,10 +137,10 @@ module OracleBMC
|
|
|
137
137
|
# check to ensure the input is an array given that the the attribute
|
|
138
138
|
# is documented as an array but the input is not
|
|
139
139
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
140
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v|
|
|
140
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| OracleBMC::Internal::Util.convert_to_type($1, v) } )
|
|
141
141
|
end
|
|
142
142
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
143
|
-
self.send("#{key}=",
|
|
143
|
+
self.send("#{key}=", OracleBMC::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]]))
|
|
144
144
|
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
145
145
|
end
|
|
146
146
|
|
|
@@ -185,47 +185,6 @@ module OracleBMC
|
|
|
185
185
|
end
|
|
186
186
|
end
|
|
187
187
|
|
|
188
|
-
# Deserializes the data based on type
|
|
189
|
-
# @param [String] type Data type
|
|
190
|
-
# @param [String] value Value to be deserialized
|
|
191
|
-
# @return [Object] Deserialized data
|
|
192
|
-
def _deserialize(type, value)
|
|
193
|
-
case type.to_sym
|
|
194
|
-
when :DateTime
|
|
195
|
-
DateTime.parse(value)
|
|
196
|
-
when :Date
|
|
197
|
-
Date.parse(value)
|
|
198
|
-
when :String
|
|
199
|
-
value.to_s
|
|
200
|
-
when :Integer
|
|
201
|
-
value.to_i
|
|
202
|
-
when :Float
|
|
203
|
-
value.to_f
|
|
204
|
-
when :BOOLEAN
|
|
205
|
-
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
|
206
|
-
true
|
|
207
|
-
else
|
|
208
|
-
false
|
|
209
|
-
end
|
|
210
|
-
when :Object
|
|
211
|
-
# generic object (usually a Hash), return directly
|
|
212
|
-
value
|
|
213
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
|
214
|
-
inner_type = Regexp.last_match[:inner_type]
|
|
215
|
-
value.map { |v| _deserialize(inner_type, v) }
|
|
216
|
-
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
|
217
|
-
k_type = Regexp.last_match[:k_type]
|
|
218
|
-
v_type = Regexp.last_match[:v_type]
|
|
219
|
-
{}.tap do |hash|
|
|
220
|
-
value.each do |k, v|
|
|
221
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
222
|
-
end
|
|
223
|
-
end
|
|
224
|
-
else # model
|
|
225
|
-
temp_model = OracleBMC.const_get(type.to_s).new
|
|
226
|
-
temp_model.build_from_hash(value)
|
|
227
|
-
end
|
|
228
|
-
end
|
|
229
188
|
|
|
230
189
|
|
|
231
190
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
@@ -129,10 +129,10 @@ module OracleBMC
|
|
|
129
129
|
# check to ensure the input is an array given that the the attribute
|
|
130
130
|
# is documented as an array but the input is not
|
|
131
131
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
132
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v|
|
|
132
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| OracleBMC::Internal::Util.convert_to_type($1, v) } )
|
|
133
133
|
end
|
|
134
134
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
135
|
-
self.send("#{key}=",
|
|
135
|
+
self.send("#{key}=", OracleBMC::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]]))
|
|
136
136
|
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
137
137
|
end
|
|
138
138
|
|
|
@@ -177,47 +177,6 @@ module OracleBMC
|
|
|
177
177
|
end
|
|
178
178
|
end
|
|
179
179
|
|
|
180
|
-
# Deserializes the data based on type
|
|
181
|
-
# @param [String] type Data type
|
|
182
|
-
# @param [String] value Value to be deserialized
|
|
183
|
-
# @return [Object] Deserialized data
|
|
184
|
-
def _deserialize(type, value)
|
|
185
|
-
case type.to_sym
|
|
186
|
-
when :DateTime
|
|
187
|
-
DateTime.parse(value)
|
|
188
|
-
when :Date
|
|
189
|
-
Date.parse(value)
|
|
190
|
-
when :String
|
|
191
|
-
value.to_s
|
|
192
|
-
when :Integer
|
|
193
|
-
value.to_i
|
|
194
|
-
when :Float
|
|
195
|
-
value.to_f
|
|
196
|
-
when :BOOLEAN
|
|
197
|
-
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
|
198
|
-
true
|
|
199
|
-
else
|
|
200
|
-
false
|
|
201
|
-
end
|
|
202
|
-
when :Object
|
|
203
|
-
# generic object (usually a Hash), return directly
|
|
204
|
-
value
|
|
205
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
|
206
|
-
inner_type = Regexp.last_match[:inner_type]
|
|
207
|
-
value.map { |v| _deserialize(inner_type, v) }
|
|
208
|
-
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
|
209
|
-
k_type = Regexp.last_match[:k_type]
|
|
210
|
-
v_type = Regexp.last_match[:v_type]
|
|
211
|
-
{}.tap do |hash|
|
|
212
|
-
value.each do |k, v|
|
|
213
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
214
|
-
end
|
|
215
|
-
end
|
|
216
|
-
else # model
|
|
217
|
-
temp_model = OracleBMC.const_get(type.to_s).new
|
|
218
|
-
temp_model.build_from_hash(value)
|
|
219
|
-
end
|
|
220
|
-
end
|
|
221
180
|
|
|
222
181
|
|
|
223
182
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
|
2
|
+
|
|
3
|
+
module OracleBMC
|
|
4
|
+
|
|
5
|
+
# Contains internal modules and class that are not meant for public use.
|
|
6
|
+
module Internal
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Require models
|
|
11
|
+
require 'oraclebmc/internal/util'
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
|
2
|
+
|
|
3
|
+
module OracleBMC::Internal
|
|
4
|
+
|
|
5
|
+
# Utility methods for internal use only.
|
|
6
|
+
module Util
|
|
7
|
+
|
|
8
|
+
# Convert data to the given type. This is part of the conversion from strings representing
|
|
9
|
+
# json, where the data that is passed in should already have been converted using JSON.parse.
|
|
10
|
+
# That will give us arrays and hashes, but will not set the correct data types.
|
|
11
|
+
#
|
|
12
|
+
# @param [String] type Type that the data should be converted to
|
|
13
|
+
# @param [String] data Data in string, array or hash of strings, or raw object format.
|
|
14
|
+
# @return [Mixed] Data in the specified type
|
|
15
|
+
def self.convert_to_type(type, data)
|
|
16
|
+
return nil if data.nil?
|
|
17
|
+
|
|
18
|
+
case type.downcase.to_sym
|
|
19
|
+
when :datetime
|
|
20
|
+
DateTime.parse(data)
|
|
21
|
+
when :date
|
|
22
|
+
Date.parse(data)
|
|
23
|
+
when :string
|
|
24
|
+
data.to_s
|
|
25
|
+
when :integer
|
|
26
|
+
data.to_i
|
|
27
|
+
when :float
|
|
28
|
+
data.to_f
|
|
29
|
+
when :boolean
|
|
30
|
+
if data.to_s =~ /^(true|yes|1)$/i
|
|
31
|
+
true
|
|
32
|
+
else
|
|
33
|
+
false
|
|
34
|
+
end
|
|
35
|
+
when :object
|
|
36
|
+
# generic object, return directly
|
|
37
|
+
data
|
|
38
|
+
else
|
|
39
|
+
# The remaining cases might need to match a specific model class, so don't ignore case.
|
|
40
|
+
case type.to_sym
|
|
41
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
42
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
43
|
+
data.map { |v| convert_to_type(inner_type, v) }
|
|
44
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
|
45
|
+
k_type = Regexp.last_match[:k_type]
|
|
46
|
+
v_type = Regexp.last_match[:v_type]
|
|
47
|
+
{}.tap do |hash|
|
|
48
|
+
data.each do |k, v|
|
|
49
|
+
hash[convert_to_type(k_type, k)] = convert_to_type(v_type, v)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
else
|
|
53
|
+
# Type must be a model.
|
|
54
|
+
type = OracleBMC.const_get(type.to_s)
|
|
55
|
+
|
|
56
|
+
if defined? type.get_subtype
|
|
57
|
+
# The return type may be an abstract type, in which case
|
|
58
|
+
# we need to use the discriminator value to get the correct subtype.
|
|
59
|
+
type = OracleBMC.const_get(type.get_subtype(data))
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
type.new.tap do |model|
|
|
63
|
+
model.build_from_hash data
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -142,10 +142,10 @@ module OracleBMC
|
|
|
142
142
|
# check to ensure the input is an array given that the the attribute
|
|
143
143
|
# is documented as an array but the input is not
|
|
144
144
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
145
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v|
|
|
145
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| OracleBMC::Internal::Util.convert_to_type($1, v) } )
|
|
146
146
|
end
|
|
147
147
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
148
|
-
self.send("#{key}=",
|
|
148
|
+
self.send("#{key}=", OracleBMC::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]]))
|
|
149
149
|
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
150
150
|
end
|
|
151
151
|
|
|
@@ -190,47 +190,6 @@ module OracleBMC
|
|
|
190
190
|
end
|
|
191
191
|
end
|
|
192
192
|
|
|
193
|
-
# Deserializes the data based on type
|
|
194
|
-
# @param [String] type Data type
|
|
195
|
-
# @param [String] value Value to be deserialized
|
|
196
|
-
# @return [Object] Deserialized data
|
|
197
|
-
def _deserialize(type, value)
|
|
198
|
-
case type.to_sym
|
|
199
|
-
when :DateTime
|
|
200
|
-
DateTime.parse(value)
|
|
201
|
-
when :Date
|
|
202
|
-
Date.parse(value)
|
|
203
|
-
when :String
|
|
204
|
-
value.to_s
|
|
205
|
-
when :Integer
|
|
206
|
-
value.to_i
|
|
207
|
-
when :Float
|
|
208
|
-
value.to_f
|
|
209
|
-
when :BOOLEAN
|
|
210
|
-
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
|
211
|
-
true
|
|
212
|
-
else
|
|
213
|
-
false
|
|
214
|
-
end
|
|
215
|
-
when :Object
|
|
216
|
-
# generic object (usually a Hash), return directly
|
|
217
|
-
value
|
|
218
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
|
219
|
-
inner_type = Regexp.last_match[:inner_type]
|
|
220
|
-
value.map { |v| _deserialize(inner_type, v) }
|
|
221
|
-
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
|
222
|
-
k_type = Regexp.last_match[:k_type]
|
|
223
|
-
v_type = Regexp.last_match[:v_type]
|
|
224
|
-
{}.tap do |hash|
|
|
225
|
-
value.each do |k, v|
|
|
226
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
227
|
-
end
|
|
228
|
-
end
|
|
229
|
-
else # model
|
|
230
|
-
temp_model = OracleBMC.const_get(type.to_s).new
|
|
231
|
-
temp_model.build_from_hash(value)
|
|
232
|
-
end
|
|
233
|
-
end
|
|
234
193
|
|
|
235
194
|
|
|
236
195
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
@@ -130,10 +130,10 @@ module OracleBMC
|
|
|
130
130
|
# check to ensure the input is an array given that the the attribute
|
|
131
131
|
# is documented as an array but the input is not
|
|
132
132
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
133
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v|
|
|
133
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| OracleBMC::Internal::Util.convert_to_type($1, v) } )
|
|
134
134
|
end
|
|
135
135
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
136
|
-
self.send("#{key}=",
|
|
136
|
+
self.send("#{key}=", OracleBMC::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]]))
|
|
137
137
|
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
138
138
|
end
|
|
139
139
|
|
|
@@ -178,47 +178,6 @@ module OracleBMC
|
|
|
178
178
|
end
|
|
179
179
|
end
|
|
180
180
|
|
|
181
|
-
# Deserializes the data based on type
|
|
182
|
-
# @param [String] type Data type
|
|
183
|
-
# @param [String] value Value to be deserialized
|
|
184
|
-
# @return [Object] Deserialized data
|
|
185
|
-
def _deserialize(type, value)
|
|
186
|
-
case type.to_sym
|
|
187
|
-
when :DateTime
|
|
188
|
-
DateTime.parse(value)
|
|
189
|
-
when :Date
|
|
190
|
-
Date.parse(value)
|
|
191
|
-
when :String
|
|
192
|
-
value.to_s
|
|
193
|
-
when :Integer
|
|
194
|
-
value.to_i
|
|
195
|
-
when :Float
|
|
196
|
-
value.to_f
|
|
197
|
-
when :BOOLEAN
|
|
198
|
-
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
|
199
|
-
true
|
|
200
|
-
else
|
|
201
|
-
false
|
|
202
|
-
end
|
|
203
|
-
when :Object
|
|
204
|
-
# generic object (usually a Hash), return directly
|
|
205
|
-
value
|
|
206
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
|
207
|
-
inner_type = Regexp.last_match[:inner_type]
|
|
208
|
-
value.map { |v| _deserialize(inner_type, v) }
|
|
209
|
-
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
|
210
|
-
k_type = Regexp.last_match[:k_type]
|
|
211
|
-
v_type = Regexp.last_match[:v_type]
|
|
212
|
-
{}.tap do |hash|
|
|
213
|
-
value.each do |k, v|
|
|
214
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
215
|
-
end
|
|
216
|
-
end
|
|
217
|
-
else # model
|
|
218
|
-
temp_model = OracleBMC.const_get(type.to_s).new
|
|
219
|
-
temp_model.build_from_hash(value)
|
|
220
|
-
end
|
|
221
|
-
end
|
|
222
181
|
|
|
223
182
|
|
|
224
183
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
@@ -95,10 +95,10 @@ module OracleBMC
|
|
|
95
95
|
# check to ensure the input is an array given that the the attribute
|
|
96
96
|
# is documented as an array but the input is not
|
|
97
97
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
98
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v|
|
|
98
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| OracleBMC::Internal::Util.convert_to_type($1, v) } )
|
|
99
99
|
end
|
|
100
100
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
101
|
-
self.send("#{key}=",
|
|
101
|
+
self.send("#{key}=", OracleBMC::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]]))
|
|
102
102
|
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
103
103
|
end
|
|
104
104
|
|
|
@@ -143,47 +143,6 @@ module OracleBMC
|
|
|
143
143
|
end
|
|
144
144
|
end
|
|
145
145
|
|
|
146
|
-
# Deserializes the data based on type
|
|
147
|
-
# @param [String] type Data type
|
|
148
|
-
# @param [String] value Value to be deserialized
|
|
149
|
-
# @return [Object] Deserialized data
|
|
150
|
-
def _deserialize(type, value)
|
|
151
|
-
case type.to_sym
|
|
152
|
-
when :DateTime
|
|
153
|
-
DateTime.parse(value)
|
|
154
|
-
when :Date
|
|
155
|
-
Date.parse(value)
|
|
156
|
-
when :String
|
|
157
|
-
value.to_s
|
|
158
|
-
when :Integer
|
|
159
|
-
value.to_i
|
|
160
|
-
when :Float
|
|
161
|
-
value.to_f
|
|
162
|
-
when :BOOLEAN
|
|
163
|
-
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
|
164
|
-
true
|
|
165
|
-
else
|
|
166
|
-
false
|
|
167
|
-
end
|
|
168
|
-
when :Object
|
|
169
|
-
# generic object (usually a Hash), return directly
|
|
170
|
-
value
|
|
171
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
|
172
|
-
inner_type = Regexp.last_match[:inner_type]
|
|
173
|
-
value.map { |v| _deserialize(inner_type, v) }
|
|
174
|
-
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
|
175
|
-
k_type = Regexp.last_match[:k_type]
|
|
176
|
-
v_type = Regexp.last_match[:v_type]
|
|
177
|
-
{}.tap do |hash|
|
|
178
|
-
value.each do |k, v|
|
|
179
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
180
|
-
end
|
|
181
|
-
end
|
|
182
|
-
else # model
|
|
183
|
-
temp_model = OracleBMC.const_get(type.to_s).new
|
|
184
|
-
temp_model.build_from_hash(value)
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
146
|
|
|
188
147
|
|
|
189
148
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
@@ -83,10 +83,10 @@ module OracleBMC
|
|
|
83
83
|
# check to ensure the input is an array given that the the attribute
|
|
84
84
|
# is documented as an array but the input is not
|
|
85
85
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
86
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v|
|
|
86
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| OracleBMC::Internal::Util.convert_to_type($1, v) } )
|
|
87
87
|
end
|
|
88
88
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
89
|
-
self.send("#{key}=",
|
|
89
|
+
self.send("#{key}=", OracleBMC::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]]))
|
|
90
90
|
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
91
91
|
end
|
|
92
92
|
|
|
@@ -131,47 +131,6 @@ module OracleBMC
|
|
|
131
131
|
end
|
|
132
132
|
end
|
|
133
133
|
|
|
134
|
-
# Deserializes the data based on type
|
|
135
|
-
# @param [String] type Data type
|
|
136
|
-
# @param [String] value Value to be deserialized
|
|
137
|
-
# @return [Object] Deserialized data
|
|
138
|
-
def _deserialize(type, value)
|
|
139
|
-
case type.to_sym
|
|
140
|
-
when :DateTime
|
|
141
|
-
DateTime.parse(value)
|
|
142
|
-
when :Date
|
|
143
|
-
Date.parse(value)
|
|
144
|
-
when :String
|
|
145
|
-
value.to_s
|
|
146
|
-
when :Integer
|
|
147
|
-
value.to_i
|
|
148
|
-
when :Float
|
|
149
|
-
value.to_f
|
|
150
|
-
when :BOOLEAN
|
|
151
|
-
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
|
152
|
-
true
|
|
153
|
-
else
|
|
154
|
-
false
|
|
155
|
-
end
|
|
156
|
-
when :Object
|
|
157
|
-
# generic object (usually a Hash), return directly
|
|
158
|
-
value
|
|
159
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
|
160
|
-
inner_type = Regexp.last_match[:inner_type]
|
|
161
|
-
value.map { |v| _deserialize(inner_type, v) }
|
|
162
|
-
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
|
163
|
-
k_type = Regexp.last_match[:k_type]
|
|
164
|
-
v_type = Regexp.last_match[:v_type]
|
|
165
|
-
{}.tap do |hash|
|
|
166
|
-
value.each do |k, v|
|
|
167
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
168
|
-
end
|
|
169
|
-
end
|
|
170
|
-
else # model
|
|
171
|
-
temp_model = OracleBMC.const_get(type.to_s).new
|
|
172
|
-
temp_model.build_from_hash(value)
|
|
173
|
-
end
|
|
174
|
-
end
|
|
175
134
|
|
|
176
135
|
|
|
177
136
|
# Attribute mapping from ruby-style variable name to JSON key.
|