oraclebmc 1.1.1
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 +7 -0
- data/LICENSE.txt +82 -0
- data/README.md +220 -0
- data/lib/oraclebmc/api_client.rb +349 -0
- data/lib/oraclebmc/config.rb +80 -0
- data/lib/oraclebmc/config_file_loader.rb +85 -0
- data/lib/oraclebmc/core/blockstorage_client.rb +459 -0
- data/lib/oraclebmc/core/compute_client.rb +1053 -0
- data/lib/oraclebmc/core/core.rb +82 -0
- data/lib/oraclebmc/core/models/attach_i_scsi_volume_details.rb +179 -0
- data/lib/oraclebmc/core/models/attach_volume_details.rb +206 -0
- data/lib/oraclebmc/core/models/capture_console_history_details.rb +162 -0
- data/lib/oraclebmc/core/models/console_history.rb +252 -0
- data/lib/oraclebmc/core/models/cpe.rb +209 -0
- data/lib/oraclebmc/core/models/create_cpe_details.rb +187 -0
- data/lib/oraclebmc/core/models/create_dhcp_details.rb +195 -0
- data/lib/oraclebmc/core/models/create_drg_attachment_details.rb +184 -0
- data/lib/oraclebmc/core/models/create_drg_details.rb +173 -0
- data/lib/oraclebmc/core/models/create_image_details.rb +188 -0
- data/lib/oraclebmc/core/models/create_internet_gateway_details.rb +195 -0
- data/lib/oraclebmc/core/models/create_ip_sec_connection_details.rb +210 -0
- data/lib/oraclebmc/core/models/create_route_table_details.rb +195 -0
- data/lib/oraclebmc/core/models/create_security_list_details.rb +206 -0
- data/lib/oraclebmc/core/models/create_subnet_details.rb +253 -0
- data/lib/oraclebmc/core/models/create_vcn_details.rb +187 -0
- data/lib/oraclebmc/core/models/create_volume_backup_details.rb +173 -0
- data/lib/oraclebmc/core/models/create_volume_details.rb +211 -0
- data/lib/oraclebmc/core/models/dhcp_dns_option.rb +203 -0
- data/lib/oraclebmc/core/models/dhcp_option.rb +171 -0
- data/lib/oraclebmc/core/models/dhcp_options.rb +246 -0
- data/lib/oraclebmc/core/models/drg.rb +224 -0
- data/lib/oraclebmc/core/models/drg_attachment.rb +246 -0
- data/lib/oraclebmc/core/models/egress_security_rule.rb +240 -0
- data/lib/oraclebmc/core/models/i_scsi_volume_attachment.rb +254 -0
- data/lib/oraclebmc/core/models/icmp_options.rb +173 -0
- data/lib/oraclebmc/core/models/image.rb +282 -0
- data/lib/oraclebmc/core/models/ingress_security_rule.rb +240 -0
- data/lib/oraclebmc/core/models/instance.rb +326 -0
- data/lib/oraclebmc/core/models/internet_gateway.rb +248 -0
- data/lib/oraclebmc/core/models/ip_sec_connection.rb +261 -0
- data/lib/oraclebmc/core/models/ip_sec_connection_device_config.rb +195 -0
- data/lib/oraclebmc/core/models/ip_sec_connection_device_status.rb +198 -0
- data/lib/oraclebmc/core/models/launch_instance_details.rb +327 -0
- data/lib/oraclebmc/core/models/port_range.rb +175 -0
- data/lib/oraclebmc/core/models/route_rule.rb +177 -0
- data/lib/oraclebmc/core/models/route_table.rb +246 -0
- data/lib/oraclebmc/core/models/security_list.rb +257 -0
- data/lib/oraclebmc/core/models/shape.rb +164 -0
- data/lib/oraclebmc/core/models/subnet.rb +325 -0
- data/lib/oraclebmc/core/models/tcp_options.rb +177 -0
- data/lib/oraclebmc/core/models/tunnel_config.rb +193 -0
- data/lib/oraclebmc/core/models/tunnel_status.rb +218 -0
- data/lib/oraclebmc/core/models/udp_options.rb +177 -0
- data/lib/oraclebmc/core/models/update_cpe_details.rb +162 -0
- data/lib/oraclebmc/core/models/update_dhcp_details.rb +172 -0
- data/lib/oraclebmc/core/models/update_drg_attachment_details.rb +162 -0
- data/lib/oraclebmc/core/models/update_drg_details.rb +162 -0
- data/lib/oraclebmc/core/models/update_image_details.rb +165 -0
- data/lib/oraclebmc/core/models/update_instance_details.rb +165 -0
- data/lib/oraclebmc/core/models/update_internet_gateway_details.rb +173 -0
- data/lib/oraclebmc/core/models/update_ip_sec_connection_details.rb +162 -0
- data/lib/oraclebmc/core/models/update_route_table_details.rb +173 -0
- data/lib/oraclebmc/core/models/update_security_list_details.rb +184 -0
- data/lib/oraclebmc/core/models/update_subnet_details.rb +162 -0
- data/lib/oraclebmc/core/models/update_vcn_details.rb +162 -0
- data/lib/oraclebmc/core/models/update_volume_backup_details.rb +162 -0
- data/lib/oraclebmc/core/models/update_volume_details.rb +163 -0
- data/lib/oraclebmc/core/models/vcn.rb +272 -0
- data/lib/oraclebmc/core/models/vnic.rb +274 -0
- data/lib/oraclebmc/core/models/vnic_attachment.rb +271 -0
- data/lib/oraclebmc/core/models/volume.rb +249 -0
- data/lib/oraclebmc/core/models/volume_attachment.rb +284 -0
- data/lib/oraclebmc/core/models/volume_backup.rb +273 -0
- data/lib/oraclebmc/core/util.rb +1 -0
- data/lib/oraclebmc/core/virtual_network_client.rb +2263 -0
- data/lib/oraclebmc/errors.rb +62 -0
- data/lib/oraclebmc/global_context.rb +21 -0
- data/lib/oraclebmc/identity/identity.rb +38 -0
- data/lib/oraclebmc/identity/identity_client.rb +1462 -0
- data/lib/oraclebmc/identity/models/add_user_to_group_details.rb +173 -0
- data/lib/oraclebmc/identity/models/api_key.rb +251 -0
- data/lib/oraclebmc/identity/models/availability_domain.rb +173 -0
- data/lib/oraclebmc/identity/models/compartment.rb +251 -0
- data/lib/oraclebmc/identity/models/create_api_key_details.rb +162 -0
- data/lib/oraclebmc/identity/models/create_compartment_details.rb +187 -0
- data/lib/oraclebmc/identity/models/create_group_details.rb +186 -0
- data/lib/oraclebmc/identity/models/create_policy_details.rb +215 -0
- data/lib/oraclebmc/identity/models/create_swift_password_details.rb +163 -0
- data/lib/oraclebmc/identity/models/create_user_details.rb +186 -0
- data/lib/oraclebmc/identity/models/group.rb +251 -0
- data/lib/oraclebmc/identity/models/policy.rb +277 -0
- data/lib/oraclebmc/identity/models/swift_password.rb +266 -0
- data/lib/oraclebmc/identity/models/ui_password.rb +227 -0
- data/lib/oraclebmc/identity/models/update_compartment_details.rb +162 -0
- data/lib/oraclebmc/identity/models/update_group_details.rb +162 -0
- data/lib/oraclebmc/identity/models/update_policy_details.rb +190 -0
- data/lib/oraclebmc/identity/models/update_state_details.rb +163 -0
- data/lib/oraclebmc/identity/models/update_swift_password_details.rb +162 -0
- data/lib/oraclebmc/identity/models/update_user_details.rb +162 -0
- data/lib/oraclebmc/identity/models/user.rb +257 -0
- data/lib/oraclebmc/identity/models/user_group_membership.rb +249 -0
- data/lib/oraclebmc/identity/util.rb +1 -0
- data/lib/oraclebmc/load_balancer/load_balancer.rb +45 -0
- data/lib/oraclebmc/load_balancer/load_balancer_client.rb +1218 -0
- data/lib/oraclebmc/load_balancer/models/backend.rb +262 -0
- data/lib/oraclebmc/load_balancer/models/backend_details.rb +248 -0
- data/lib/oraclebmc/load_balancer/models/backend_set.rb +211 -0
- data/lib/oraclebmc/load_balancer/models/backend_set_details.rb +197 -0
- data/lib/oraclebmc/load_balancer/models/certificate.rb +209 -0
- data/lib/oraclebmc/load_balancer/models/certificate_details.rb +245 -0
- data/lib/oraclebmc/load_balancer/models/create_backend_details.rb +248 -0
- data/lib/oraclebmc/load_balancer/models/create_backend_set_details.rb +210 -0
- data/lib/oraclebmc/load_balancer/models/create_certificate_details.rb +245 -0
- data/lib/oraclebmc/load_balancer/models/create_listener_details.rb +216 -0
- data/lib/oraclebmc/load_balancer/models/create_load_balancer_details.rb +233 -0
- data/lib/oraclebmc/load_balancer/models/health_checker.rb +265 -0
- data/lib/oraclebmc/load_balancer/models/health_checker_details.rb +264 -0
- data/lib/oraclebmc/load_balancer/models/ip_address.rb +165 -0
- data/lib/oraclebmc/load_balancer/models/listener.rb +216 -0
- data/lib/oraclebmc/load_balancer/models/listener_details.rb +202 -0
- data/lib/oraclebmc/load_balancer/models/load_balancer.rb +296 -0
- data/lib/oraclebmc/load_balancer/models/load_balancer_policy.rb +162 -0
- data/lib/oraclebmc/load_balancer/models/load_balancer_protocol.rb +162 -0
- data/lib/oraclebmc/load_balancer/models/load_balancer_shape.rb +162 -0
- data/lib/oraclebmc/load_balancer/models/ssl_configuration.rb +195 -0
- data/lib/oraclebmc/load_balancer/models/ssl_configuration_details.rb +195 -0
- data/lib/oraclebmc/load_balancer/models/update_backend_details.rb +220 -0
- data/lib/oraclebmc/load_balancer/models/update_backend_set_details.rb +197 -0
- data/lib/oraclebmc/load_balancer/models/update_health_checker_details.rb +263 -0
- data/lib/oraclebmc/load_balancer/models/update_listener_details.rb +202 -0
- data/lib/oraclebmc/load_balancer/models/update_load_balancer_details.rb +165 -0
- data/lib/oraclebmc/load_balancer/models/work_request.rb +269 -0
- data/lib/oraclebmc/load_balancer/models/work_request_error.rb +185 -0
- data/lib/oraclebmc/load_balancer/util.rb +55 -0
- data/lib/oraclebmc/regions.rb +41 -0
- data/lib/oraclebmc/response.rb +86 -0
- data/lib/oraclebmc/signer.rb +119 -0
- data/lib/oraclebmc/version.rb +5 -0
- data/lib/oraclebmc/waiter.rb +111 -0
- data/lib/oraclebmc.rb +20 -0
- metadata +265 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
|
|
2
|
+
|
|
3
|
+
require 'date'
|
|
4
|
+
|
|
5
|
+
module OracleBMC
|
|
6
|
+
class LoadBalancer::Models::WorkRequest
|
|
7
|
+
|
|
8
|
+
LIFECYCLE_STATE_ENUM = [LIFECYCLE_STATE_ACCEPTED = 'ACCEPTED',
|
|
9
|
+
LIFECYCLE_STATE_IN_PROGRESS = 'IN_PROGRESS',
|
|
10
|
+
LIFECYCLE_STATE_FAILED = 'FAILED',
|
|
11
|
+
LIFECYCLE_STATE_SUCCEEDED = 'SUCCEEDED']
|
|
12
|
+
|
|
13
|
+
# The [OCID](https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/identifiers.htm) of the work request.
|
|
14
|
+
# @return [String]
|
|
15
|
+
attr_accessor :id
|
|
16
|
+
|
|
17
|
+
# The [OCID](https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/identifiers.htm) of the load balancer with which the work request
|
|
18
|
+
# is associated.
|
|
19
|
+
#
|
|
20
|
+
# @return [String]
|
|
21
|
+
attr_accessor :load_balancer_id
|
|
22
|
+
|
|
23
|
+
# The type of action the work request represents.
|
|
24
|
+
#
|
|
25
|
+
# @return [String]
|
|
26
|
+
attr_accessor :type
|
|
27
|
+
|
|
28
|
+
# @return [String]
|
|
29
|
+
attr_accessor :lifecycle_state
|
|
30
|
+
|
|
31
|
+
# A collection of data, related to the load balancer provisioning process, that helps with debugging in the event of failure.
|
|
32
|
+
# Possible data elements include:
|
|
33
|
+
#
|
|
34
|
+
# - workflow name
|
|
35
|
+
# - event ID
|
|
36
|
+
# - work request ID
|
|
37
|
+
# - load balancer ID
|
|
38
|
+
# - workflow completion message
|
|
39
|
+
#
|
|
40
|
+
# @return [String]
|
|
41
|
+
attr_accessor :message
|
|
42
|
+
|
|
43
|
+
# The date and time the work request was created, in the format defined by RFC3339.
|
|
44
|
+
#
|
|
45
|
+
# Example: `2016-08-25T21:10:29.600Z`
|
|
46
|
+
#
|
|
47
|
+
# @return [DateTime]
|
|
48
|
+
attr_accessor :time_accepted
|
|
49
|
+
|
|
50
|
+
# The date and time the work request was completed, in the format defined by RFC3339.
|
|
51
|
+
#
|
|
52
|
+
# Example: `2016-08-25T21:10:29.600Z`
|
|
53
|
+
#
|
|
54
|
+
# @return [DateTime]
|
|
55
|
+
attr_accessor :time_finished
|
|
56
|
+
|
|
57
|
+
# @return [Array<OracleBMC::LoadBalancer::Models::WorkRequestError>]
|
|
58
|
+
attr_accessor :error_details
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# Initializes the object
|
|
62
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
63
|
+
def initialize(attributes = {})
|
|
64
|
+
return unless attributes.is_a?(Hash)
|
|
65
|
+
|
|
66
|
+
# convert string to symbol for hash key
|
|
67
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
if attributes[:'id']
|
|
71
|
+
self.id = attributes[:'id']
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
if attributes[:'loadBalancerId']
|
|
75
|
+
self.load_balancer_id = attributes[:'loadBalancerId']
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
if attributes[:'type']
|
|
79
|
+
self.type = attributes[:'type']
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
if attributes[:'lifecycleState']
|
|
83
|
+
self.lifecycle_state = attributes[:'lifecycleState']
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
if attributes[:'message']
|
|
87
|
+
self.message = attributes[:'message']
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
if attributes[:'timeAccepted']
|
|
91
|
+
self.time_accepted = attributes[:'timeAccepted']
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
if attributes[:'timeFinished']
|
|
95
|
+
self.time_finished = attributes[:'timeFinished']
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
if attributes[:'errorDetails']
|
|
99
|
+
self.error_details = attributes[:'errorDetails']
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
105
|
+
# @param [Object] lifecycle_state Object to be assigned
|
|
106
|
+
def lifecycle_state=(lifecycle_state)
|
|
107
|
+
if lifecycle_state && !LIFECYCLE_STATE_ENUM.include?(lifecycle_state)
|
|
108
|
+
fail "Invalid value for 'lifecycle_state': this must be one of the values in LIFECYCLE_STATE_ENUM."
|
|
109
|
+
end
|
|
110
|
+
@lifecycle_state = lifecycle_state
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Checks equality by comparing each attribute.
|
|
114
|
+
# @param [Object] other_object to be compared
|
|
115
|
+
def ==(other_object)
|
|
116
|
+
return true if self.equal?(other_object)
|
|
117
|
+
self.class == other_object.class &&
|
|
118
|
+
id == other_object.id &&
|
|
119
|
+
load_balancer_id == other_object.load_balancer_id &&
|
|
120
|
+
type == other_object.type &&
|
|
121
|
+
lifecycle_state == other_object.lifecycle_state &&
|
|
122
|
+
message == other_object.message &&
|
|
123
|
+
time_accepted == other_object.time_accepted &&
|
|
124
|
+
time_finished == other_object.time_finished &&
|
|
125
|
+
error_details == other_object.error_details
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# @see the `==` method
|
|
129
|
+
# @param [Object] other_object to be compared
|
|
130
|
+
def eql?(other_object)
|
|
131
|
+
self == other_object
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Calculates hash code according to all attributes.
|
|
135
|
+
# @return [Fixnum] Hash code
|
|
136
|
+
def hash
|
|
137
|
+
[id, load_balancer_id, type, lifecycle_state, message, time_accepted, time_finished, error_details].hash
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Builds the object from hash
|
|
141
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
142
|
+
# @return [Object] Returns the model itself
|
|
143
|
+
def build_from_hash(attributes)
|
|
144
|
+
return nil unless attributes.is_a?(Hash)
|
|
145
|
+
self.class.swagger_types.each_pair do |key, type|
|
|
146
|
+
if type =~ /^Array<(.*)>/i
|
|
147
|
+
# check to ensure the input is an array given that the the attribute
|
|
148
|
+
# is documented as an array but the input is not
|
|
149
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
150
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
|
151
|
+
end
|
|
152
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
153
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
154
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
self
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Returns the string representation of the object
|
|
161
|
+
# @return [String] String presentation of the object
|
|
162
|
+
def to_s
|
|
163
|
+
to_hash.to_s
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Returns the object in the form of hash
|
|
167
|
+
# @return [Hash] Returns the object in the form of hash
|
|
168
|
+
def to_hash
|
|
169
|
+
hash = {}
|
|
170
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
171
|
+
value = self.send(attr)
|
|
172
|
+
next if value.nil?
|
|
173
|
+
hash[param] = _to_hash(value)
|
|
174
|
+
end
|
|
175
|
+
hash
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
private
|
|
179
|
+
|
|
180
|
+
# Outputs non-array value in the form of hash
|
|
181
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
182
|
+
# @param [Object] value Any valid value
|
|
183
|
+
# @return [Hash] Returns the value in the form of hash
|
|
184
|
+
def _to_hash(value)
|
|
185
|
+
if value.is_a?(Array)
|
|
186
|
+
value.compact.map{ |v| _to_hash(v) }
|
|
187
|
+
elsif value.is_a?(Hash)
|
|
188
|
+
{}.tap do |hash|
|
|
189
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
190
|
+
end
|
|
191
|
+
elsif value.respond_to? :to_hash
|
|
192
|
+
value.to_hash
|
|
193
|
+
else
|
|
194
|
+
value
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# Deserializes the data based on type
|
|
199
|
+
# @param [String] type Data type
|
|
200
|
+
# @param [String] value Value to be deserialized
|
|
201
|
+
# @return [Object] Deserialized data
|
|
202
|
+
def _deserialize(type, value)
|
|
203
|
+
case type.to_sym
|
|
204
|
+
when :DateTime
|
|
205
|
+
DateTime.parse(value)
|
|
206
|
+
when :Date
|
|
207
|
+
Date.parse(value)
|
|
208
|
+
when :String
|
|
209
|
+
value.to_s
|
|
210
|
+
when :Integer
|
|
211
|
+
value.to_i
|
|
212
|
+
when :Float
|
|
213
|
+
value.to_f
|
|
214
|
+
when :BOOLEAN
|
|
215
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
|
216
|
+
true
|
|
217
|
+
else
|
|
218
|
+
false
|
|
219
|
+
end
|
|
220
|
+
when :Object
|
|
221
|
+
# generic object (usually a Hash), return directly
|
|
222
|
+
value
|
|
223
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
224
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
225
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
226
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
|
227
|
+
k_type = Regexp.last_match[:k_type]
|
|
228
|
+
v_type = Regexp.last_match[:v_type]
|
|
229
|
+
{}.tap do |hash|
|
|
230
|
+
value.each do |k, v|
|
|
231
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
else # model
|
|
235
|
+
temp_model = OracleBMC.const_get(type.to_s).new
|
|
236
|
+
temp_model.build_from_hash(value)
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
242
|
+
def self.attribute_map
|
|
243
|
+
{
|
|
244
|
+
:'id' => :'id',
|
|
245
|
+
:'load_balancer_id' => :'loadBalancerId',
|
|
246
|
+
:'type' => :'type',
|
|
247
|
+
:'lifecycle_state' => :'lifecycleState',
|
|
248
|
+
:'message' => :'message',
|
|
249
|
+
:'time_accepted' => :'timeAccepted',
|
|
250
|
+
:'time_finished' => :'timeFinished',
|
|
251
|
+
:'error_details' => :'errorDetails'
|
|
252
|
+
}
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
# Attribute type mapping.
|
|
256
|
+
def self.swagger_types
|
|
257
|
+
{
|
|
258
|
+
:'id' => :'String',
|
|
259
|
+
:'load_balancer_id' => :'String',
|
|
260
|
+
:'type' => :'String',
|
|
261
|
+
:'lifecycle_state' => :'String',
|
|
262
|
+
:'message' => :'String',
|
|
263
|
+
:'time_accepted' => :'DateTime',
|
|
264
|
+
:'time_finished' => :'DateTime',
|
|
265
|
+
:'error_details' => :'Array<OracleBMC::LoadBalancer::Models::WorkRequestError>'
|
|
266
|
+
}
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
end
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
|
|
2
|
+
|
|
3
|
+
require 'date'
|
|
4
|
+
|
|
5
|
+
module OracleBMC
|
|
6
|
+
class LoadBalancer::Models::WorkRequestError
|
|
7
|
+
|
|
8
|
+
ERROR_CODE_ENUM = [ERROR_CODE_BAD_INPUT = 'BAD_INPUT',
|
|
9
|
+
ERROR_CODE_INTERNAL_ERROR = 'INTERNAL_ERROR']
|
|
10
|
+
|
|
11
|
+
# @return [String]
|
|
12
|
+
attr_accessor :error_code
|
|
13
|
+
|
|
14
|
+
# A human-readable error string.
|
|
15
|
+
# @return [String]
|
|
16
|
+
attr_accessor :message
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# Initializes the object
|
|
20
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
21
|
+
def initialize(attributes = {})
|
|
22
|
+
return unless attributes.is_a?(Hash)
|
|
23
|
+
|
|
24
|
+
# convert string to symbol for hash key
|
|
25
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
if attributes[:'errorCode']
|
|
29
|
+
self.error_code = attributes[:'errorCode']
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
if attributes[:'message']
|
|
33
|
+
self.message = attributes[:'message']
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
39
|
+
# @param [Object] error_code Object to be assigned
|
|
40
|
+
def error_code=(error_code)
|
|
41
|
+
if error_code && !ERROR_CODE_ENUM.include?(error_code)
|
|
42
|
+
fail "Invalid value for 'error_code': this must be one of the values in ERROR_CODE_ENUM."
|
|
43
|
+
end
|
|
44
|
+
@error_code = error_code
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Checks equality by comparing each attribute.
|
|
48
|
+
# @param [Object] other_object to be compared
|
|
49
|
+
def ==(other_object)
|
|
50
|
+
return true if self.equal?(other_object)
|
|
51
|
+
self.class == other_object.class &&
|
|
52
|
+
error_code == other_object.error_code &&
|
|
53
|
+
message == other_object.message
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# @see the `==` method
|
|
57
|
+
# @param [Object] other_object to be compared
|
|
58
|
+
def eql?(other_object)
|
|
59
|
+
self == other_object
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Calculates hash code according to all attributes.
|
|
63
|
+
# @return [Fixnum] Hash code
|
|
64
|
+
def hash
|
|
65
|
+
[error_code, message].hash
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Builds the object from hash
|
|
69
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
70
|
+
# @return [Object] Returns the model itself
|
|
71
|
+
def build_from_hash(attributes)
|
|
72
|
+
return nil unless attributes.is_a?(Hash)
|
|
73
|
+
self.class.swagger_types.each_pair do |key, type|
|
|
74
|
+
if type =~ /^Array<(.*)>/i
|
|
75
|
+
# check to ensure the input is an array given that the the attribute
|
|
76
|
+
# is documented as an array but the input is not
|
|
77
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
78
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
|
79
|
+
end
|
|
80
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
81
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
82
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
self
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Returns the string representation of the object
|
|
89
|
+
# @return [String] String presentation of the object
|
|
90
|
+
def to_s
|
|
91
|
+
to_hash.to_s
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Returns the object in the form of hash
|
|
95
|
+
# @return [Hash] Returns the object in the form of hash
|
|
96
|
+
def to_hash
|
|
97
|
+
hash = {}
|
|
98
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
99
|
+
value = self.send(attr)
|
|
100
|
+
next if value.nil?
|
|
101
|
+
hash[param] = _to_hash(value)
|
|
102
|
+
end
|
|
103
|
+
hash
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
private
|
|
107
|
+
|
|
108
|
+
# Outputs non-array value in the form of hash
|
|
109
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
110
|
+
# @param [Object] value Any valid value
|
|
111
|
+
# @return [Hash] Returns the value in the form of hash
|
|
112
|
+
def _to_hash(value)
|
|
113
|
+
if value.is_a?(Array)
|
|
114
|
+
value.compact.map{ |v| _to_hash(v) }
|
|
115
|
+
elsif value.is_a?(Hash)
|
|
116
|
+
{}.tap do |hash|
|
|
117
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
118
|
+
end
|
|
119
|
+
elsif value.respond_to? :to_hash
|
|
120
|
+
value.to_hash
|
|
121
|
+
else
|
|
122
|
+
value
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Deserializes the data based on type
|
|
127
|
+
# @param [String] type Data type
|
|
128
|
+
# @param [String] value Value to be deserialized
|
|
129
|
+
# @return [Object] Deserialized data
|
|
130
|
+
def _deserialize(type, value)
|
|
131
|
+
case type.to_sym
|
|
132
|
+
when :DateTime
|
|
133
|
+
DateTime.parse(value)
|
|
134
|
+
when :Date
|
|
135
|
+
Date.parse(value)
|
|
136
|
+
when :String
|
|
137
|
+
value.to_s
|
|
138
|
+
when :Integer
|
|
139
|
+
value.to_i
|
|
140
|
+
when :Float
|
|
141
|
+
value.to_f
|
|
142
|
+
when :BOOLEAN
|
|
143
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
|
144
|
+
true
|
|
145
|
+
else
|
|
146
|
+
false
|
|
147
|
+
end
|
|
148
|
+
when :Object
|
|
149
|
+
# generic object (usually a Hash), return directly
|
|
150
|
+
value
|
|
151
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
152
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
153
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
154
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
|
155
|
+
k_type = Regexp.last_match[:k_type]
|
|
156
|
+
v_type = Regexp.last_match[:v_type]
|
|
157
|
+
{}.tap do |hash|
|
|
158
|
+
value.each do |k, v|
|
|
159
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
else # model
|
|
163
|
+
temp_model = OracleBMC.const_get(type.to_s).new
|
|
164
|
+
temp_model.build_from_hash(value)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
170
|
+
def self.attribute_map
|
|
171
|
+
{
|
|
172
|
+
:'error_code' => :'errorCode',
|
|
173
|
+
:'message' => :'message'
|
|
174
|
+
}
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# Attribute type mapping.
|
|
178
|
+
def self.swagger_types
|
|
179
|
+
{
|
|
180
|
+
:'error_code' => :'String',
|
|
181
|
+
:'message' => :'String'
|
|
182
|
+
}
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
|
|
2
|
+
|
|
3
|
+
module OracleBMC::LoadBalancer
|
|
4
|
+
|
|
5
|
+
# Load balancer utility methods
|
|
6
|
+
module Util
|
|
7
|
+
|
|
8
|
+
# Wait until the work request succeeds or fails, or max_wait_seconds is reached.
|
|
9
|
+
# The work request will be polled at an increasing rate, with a maximum of
|
|
10
|
+
# max_interval_seconds between requests.
|
|
11
|
+
#
|
|
12
|
+
# @param [LoadBalancerClient] client A load balancer client
|
|
13
|
+
# @param [Integer] max_interval_seconds The maximum interval between queries, in seconds.
|
|
14
|
+
# @param [Integer] max_wait_seconds The maximum total time to wait, in seconds.
|
|
15
|
+
# @param [Boolean] raise_error_on_failure If true, then a WorkRequestFailedError will be raised if the work request is in a failed state.
|
|
16
|
+
# @return [WorkRequest] The final work request
|
|
17
|
+
def self.wait_on_work_request(client, work_request_id, max_interval_seconds: 30, max_wait_seconds: 1200, raise_error_on_failure:true)
|
|
18
|
+
fail "Work request ID not specified." unless work_request_id
|
|
19
|
+
|
|
20
|
+
interval_seconds = 1
|
|
21
|
+
start_time = Time.now
|
|
22
|
+
|
|
23
|
+
while true
|
|
24
|
+
response = client.get_work_request(work_request_id)
|
|
25
|
+
if response.data.lifecycle_state == OracleBMC::LoadBalancer::Models::WorkRequest::LIFECYCLE_STATE_SUCCEEDED
|
|
26
|
+
return response.data
|
|
27
|
+
elsif response.data.lifecycle_state == OracleBMC::LoadBalancer::Models::WorkRequest::LIFECYCLE_STATE_FAILED
|
|
28
|
+
if raise_error_on_failure
|
|
29
|
+
raise OracleBMC::Errors::WorkRequestFailedError.new(response.data)
|
|
30
|
+
else
|
|
31
|
+
return response.data
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
elapsed_seconds = (Time.now - start_time).to_i
|
|
36
|
+
|
|
37
|
+
if elapsed_seconds + interval_seconds > max_wait_seconds
|
|
38
|
+
if max_wait_seconds > elapsed_seconds
|
|
39
|
+
# Make one last request right at the maximum wait time.
|
|
40
|
+
interval_seconds = max_wait_seconds - elapsed_seconds
|
|
41
|
+
else
|
|
42
|
+
raise OracleBMC::Errors::MaximumWaitTimeExceededError.new('Maximum wait time has been exceeded.')
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
sleep(interval_seconds)
|
|
47
|
+
|
|
48
|
+
interval_seconds *= 2
|
|
49
|
+
if interval_seconds > max_interval_seconds
|
|
50
|
+
interval_seconds = max_interval_seconds
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
|
|
2
|
+
|
|
3
|
+
module OracleBMC
|
|
4
|
+
module Regions
|
|
5
|
+
|
|
6
|
+
REGION_ENUM = [REGION_US_PHOENIX_1 = 'us-phoenix-1']
|
|
7
|
+
|
|
8
|
+
# Returns an endpoint for the given region and service.
|
|
9
|
+
#
|
|
10
|
+
# @param [String] region A region used to determine the service endpoint. This will usually
|
|
11
|
+
# correspond to a value in {OracleBMC::Regions::REGION_ENUM}, but may be an arbitrary string.
|
|
12
|
+
# @param [Symbol] service A symbol representing a service client class (e.g. :IdentityClient)
|
|
13
|
+
#
|
|
14
|
+
# @return [String] A fully qualified endpoint
|
|
15
|
+
def self.get_service_endpoint(region, service)
|
|
16
|
+
prefix = SERVICE_ENDPOINT_PREFIX_MAPPING[service]
|
|
17
|
+
fail "Service '#{service}' is not supported." unless prefix
|
|
18
|
+
format_endpoint(prefix, region)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# @return [Boolean] Returns true if the given string corresponds to a known region, as defined in {OracleBMC::Regions::REGION_ENUM}.
|
|
22
|
+
def self.valid_region? region
|
|
23
|
+
return REGION_ENUM.include? region
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
SERVICE_ENDPOINT_PREFIX_MAPPING = {
|
|
29
|
+
:BlockstorageClient => 'iaas',
|
|
30
|
+
:ComputeClient => 'iaas',
|
|
31
|
+
:VirtualNetworkClient => 'iaas',
|
|
32
|
+
:IdentityClient => 'identity',
|
|
33
|
+
:LoadBalancerClient => 'iaas',
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
def self.format_endpoint(prefix, region)
|
|
37
|
+
"https://#{prefix}.#{region}.oraclecloud.com"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
|
|
2
|
+
|
|
3
|
+
module OracleBMC
|
|
4
|
+
|
|
5
|
+
# A response, which represents all successful API calls.
|
|
6
|
+
class Response
|
|
7
|
+
# The HTTP status, such as 200, 401, etc
|
|
8
|
+
#
|
|
9
|
+
# @return [Integer]
|
|
10
|
+
attr_reader :status
|
|
11
|
+
|
|
12
|
+
# A hash containing all response headers
|
|
13
|
+
#
|
|
14
|
+
# @return [Hash]
|
|
15
|
+
attr_reader :headers
|
|
16
|
+
|
|
17
|
+
# The body of the response. For example, this
|
|
18
|
+
# may contain a User object, or a list of Users.
|
|
19
|
+
attr_reader :data
|
|
20
|
+
|
|
21
|
+
# The value of the next page token, if available,
|
|
22
|
+
# taken from the opc-next-page header.
|
|
23
|
+
#
|
|
24
|
+
# @return [String]
|
|
25
|
+
attr_reader :next_page
|
|
26
|
+
|
|
27
|
+
# The request ID, taken from the opc-request-id header.
|
|
28
|
+
#
|
|
29
|
+
# @return [String]
|
|
30
|
+
attr_reader :request_id
|
|
31
|
+
|
|
32
|
+
def initialize(status, headers, data)
|
|
33
|
+
@status = status
|
|
34
|
+
@headers = headers
|
|
35
|
+
@data = data
|
|
36
|
+
|
|
37
|
+
if headers
|
|
38
|
+
@next_page = headers["opc-next-page"]
|
|
39
|
+
@request_id = headers["opc-request-id"]
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Returns true if there is another page available.
|
|
44
|
+
def has_next_page?
|
|
45
|
+
return !next_page.nil?
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
include Enumerable
|
|
49
|
+
|
|
50
|
+
# For paged responses, yields each page until the last page is reached.
|
|
51
|
+
# For example:
|
|
52
|
+
#
|
|
53
|
+
# OracleBMC::Identity::IdentityClient.new.list_users(compartment, limit:'3').each { |r| r.data.each { |user| puts user.name }}
|
|
54
|
+
#
|
|
55
|
+
# The first response yielded is always the response that 'each' is being
|
|
56
|
+
# called on.
|
|
57
|
+
#
|
|
58
|
+
# If any of the requests result in an error, that error will be thrown
|
|
59
|
+
# as normal, which will abort the enumeration.
|
|
60
|
+
#
|
|
61
|
+
# While this can be called on non-paged responses, it will simply result
|
|
62
|
+
# in the response itself being yielded.
|
|
63
|
+
#
|
|
64
|
+
# @yieldparam [Response] response A response object for each page, starting with the response used to call 'each'.
|
|
65
|
+
def each
|
|
66
|
+
yield self
|
|
67
|
+
page = @next_page
|
|
68
|
+
|
|
69
|
+
while @api_call && page
|
|
70
|
+
next_response = @api_call.call(page)
|
|
71
|
+
|
|
72
|
+
if page == next_response.next_page
|
|
73
|
+
fail "Paging failure: Two consecutive responses had the same next page token."
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
page = next_response.next_page
|
|
77
|
+
yield next_response
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def api_call=(c)
|
|
82
|
+
@api_call = c
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
end
|
|
86
|
+
end
|