ibm_cloud_resource_controller 1.0.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/Gemfile +9 -0
- data/README.md +148 -0
- data/Rakefile +10 -0
- data/docs/Credentials.md +25 -0
- data/docs/ErrorReport.md +23 -0
- data/docs/PlanHistoryItem.md +19 -0
- data/docs/Reclamation.md +45 -0
- data/docs/ReclamationActionsPost.md +19 -0
- data/docs/ReclamationsList.md +17 -0
- data/docs/ResourceAlias.md +57 -0
- data/docs/ResourceAliasPatch.md +17 -0
- data/docs/ResourceAliasPost.md +21 -0
- data/docs/ResourceAliasesApi.md +302 -0
- data/docs/ResourceAliasesList.md +21 -0
- data/docs/ResourceBinding.md +57 -0
- data/docs/ResourceBindingPatch.md +17 -0
- data/docs/ResourceBindingPost.md +25 -0
- data/docs/ResourceBindingPostParameters.md +17 -0
- data/docs/ResourceBindingsApi.md +300 -0
- data/docs/ResourceBindingsList.md +21 -0
- data/docs/ResourceInstance.md +81 -0
- data/docs/ResourceInstancePatch.md +23 -0
- data/docs/ResourceInstancePost.md +29 -0
- data/docs/ResourceInstancesApi.md +418 -0
- data/docs/ResourceInstancesList.md +21 -0
- data/docs/ResourceKey.md +53 -0
- data/docs/ResourceKeyPatch.md +17 -0
- data/docs/ResourceKeyPost.md +23 -0
- data/docs/ResourceKeysApi.md +298 -0
- data/docs/ResourceKeysList.md +21 -0
- data/docs/ResourceReclamationsApi.md +128 -0
- data/git_push.sh +58 -0
- data/ibm_cloud_resource_controller.gemspec +38 -0
- data/lib/ibm_cloud_resource_controller.rb +67 -0
- data/lib/ibm_cloud_resource_controller/api/resource_aliases_api.rb +363 -0
- data/lib/ibm_cloud_resource_controller/api/resource_bindings_api.rb +360 -0
- data/lib/ibm_cloud_resource_controller/api/resource_instances_api.rb +493 -0
- data/lib/ibm_cloud_resource_controller/api/resource_keys_api.rb +357 -0
- data/lib/ibm_cloud_resource_controller/api/resource_reclamations_api.rb +156 -0
- data/lib/ibm_cloud_resource_controller/api_client.rb +388 -0
- data/lib/ibm_cloud_resource_controller/api_error.rb +57 -0
- data/lib/ibm_cloud_resource_controller/configuration.rb +248 -0
- data/lib/ibm_cloud_resource_controller/models/credentials.rb +250 -0
- data/lib/ibm_cloud_resource_controller/models/error_report.rb +240 -0
- data/lib/ibm_cloud_resource_controller/models/plan_history_item.rb +230 -0
- data/lib/ibm_cloud_resource_controller/models/reclamation.rb +352 -0
- data/lib/ibm_cloud_resource_controller/models/reclamation_actions_post.rb +220 -0
- data/lib/ibm_cloud_resource_controller/models/reclamations_list.rb +212 -0
- data/lib/ibm_cloud_resource_controller/models/resource_alias.rb +410 -0
- data/lib/ibm_cloud_resource_controller/models/resource_alias_patch.rb +236 -0
- data/lib/ibm_cloud_resource_controller/models/resource_alias_post.rb +266 -0
- data/lib/ibm_cloud_resource_controller/models/resource_aliases_list.rb +247 -0
- data/lib/ibm_cloud_resource_controller/models/resource_binding.rb +410 -0
- data/lib/ibm_cloud_resource_controller/models/resource_binding_patch.rb +236 -0
- data/lib/ibm_cloud_resource_controller/models/resource_binding_post.rb +278 -0
- data/lib/ibm_cloud_resource_controller/models/resource_binding_post_parameters.rb +210 -0
- data/lib/ibm_cloud_resource_controller/models/resource_bindings_list.rb +247 -0
- data/lib/ibm_cloud_resource_controller/models/resource_instance.rb +536 -0
- data/lib/ibm_cloud_resource_controller/models/resource_instance_patch.rb +259 -0
- data/lib/ibm_cloud_resource_controller/models/resource_instance_post.rb +317 -0
- data/lib/ibm_cloud_resource_controller/models/resource_instances_list.rb +247 -0
- data/lib/ibm_cloud_resource_controller/models/resource_key.rb +390 -0
- data/lib/ibm_cloud_resource_controller/models/resource_key_patch.rb +236 -0
- data/lib/ibm_cloud_resource_controller/models/resource_key_post.rb +251 -0
- data/lib/ibm_cloud_resource_controller/models/resource_keys_list.rb +247 -0
- data/lib/ibm_cloud_resource_controller/version.rb +15 -0
- data/spec/api/resource_aliases_api_spec.rb +104 -0
- data/spec/api/resource_bindings_api_spec.rb +103 -0
- data/spec/api/resource_instances_api_spec.rb +130 -0
- data/spec/api/resource_keys_api_spec.rb +102 -0
- data/spec/api/resource_reclamations_api_spec.rb +62 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/credentials_spec.rb +65 -0
- data/spec/models/error_report_spec.rb +59 -0
- data/spec/models/plan_history_item_spec.rb +47 -0
- data/spec/models/reclamation_actions_post_spec.rb +47 -0
- data/spec/models/reclamation_spec.rb +125 -0
- data/spec/models/reclamations_list_spec.rb +41 -0
- data/spec/models/resource_alias_patch_spec.rb +41 -0
- data/spec/models/resource_alias_post_spec.rb +53 -0
- data/spec/models/resource_alias_spec.rb +143 -0
- data/spec/models/resource_aliases_list_spec.rb +53 -0
- data/spec/models/resource_binding_patch_spec.rb +41 -0
- data/spec/models/resource_binding_post_parameters_spec.rb +41 -0
- data/spec/models/resource_binding_post_spec.rb +65 -0
- data/spec/models/resource_binding_spec.rb +137 -0
- data/spec/models/resource_bindings_list_spec.rb +53 -0
- data/spec/models/resource_instance_patch_spec.rb +59 -0
- data/spec/models/resource_instance_post_spec.rb +77 -0
- data/spec/models/resource_instance_spec.rb +191 -0
- data/spec/models/resource_instances_list_spec.rb +53 -0
- data/spec/models/resource_key_patch_spec.rb +41 -0
- data/spec/models/resource_key_post_spec.rb +59 -0
- data/spec/models/resource_key_spec.rb +125 -0
- data/spec/models/resource_keys_list_spec.rb +53 -0
- data/spec/spec_helper.rb +111 -0
- metadata +211 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#IBM Cloud Resource Controller API
|
|
3
|
+
|
|
4
|
+
#Manage lifecycle of your Cloud resources using Resource Controller APIs. Resources are provisioned globally in an account scope. Supports asynchronous provisioning of resources. Enables consumption of a global resource through a Cloud Foundry space in any region.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 2.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
OpenAPI Generator version: 5.0.0-beta2
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
|
|
15
|
+
module IbmCloudResourceController
|
|
16
|
+
# Updated property values for the resource key.
|
|
17
|
+
class ResourceKeyPatch
|
|
18
|
+
# The new name of the key. Must be 180 characters or less and cannot include any special characters other than `(space) - . _ :`.
|
|
19
|
+
attr_accessor :name
|
|
20
|
+
|
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
22
|
+
def self.attribute_map
|
|
23
|
+
{
|
|
24
|
+
:'name' => :'name'
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Attribute type mapping.
|
|
29
|
+
def self.openapi_types
|
|
30
|
+
{
|
|
31
|
+
:'name' => :'String'
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# List of attributes with nullable: true
|
|
36
|
+
def self.openapi_nullable
|
|
37
|
+
Set.new([
|
|
38
|
+
])
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Initializes the object
|
|
42
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
43
|
+
def initialize(attributes = {})
|
|
44
|
+
if (!attributes.is_a?(Hash))
|
|
45
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `IbmCloudResourceController::ResourceKeyPatch` initialize method"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
49
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
50
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
51
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `IbmCloudResourceController::ResourceKeyPatch`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
52
|
+
end
|
|
53
|
+
h[k.to_sym] = v
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if attributes.key?(:'name')
|
|
57
|
+
self.name = attributes[:'name']
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
62
|
+
# @return Array for valid properties with the reasons
|
|
63
|
+
def list_invalid_properties
|
|
64
|
+
invalid_properties = Array.new
|
|
65
|
+
if @name.nil?
|
|
66
|
+
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
pattern = Regexp.new(/^([^[:ascii:]]|[a-zA-Z0-9\-._: ])+$/)
|
|
70
|
+
if @name !~ pattern
|
|
71
|
+
invalid_properties.push("invalid value for \"name\", must conform to the pattern #{pattern}.")
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
invalid_properties
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Check to see if the all the properties in the model are valid
|
|
78
|
+
# @return true if the model is valid
|
|
79
|
+
def valid?
|
|
80
|
+
return false if @name.nil?
|
|
81
|
+
return false if @name !~ Regexp.new(/^([^[:ascii:]]|[a-zA-Z0-9\-._: ])+$/)
|
|
82
|
+
true
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Custom attribute writer method with validation
|
|
86
|
+
# @param [Object] name Value to be assigned
|
|
87
|
+
def name=(name)
|
|
88
|
+
if name.nil?
|
|
89
|
+
fail ArgumentError, 'name cannot be nil'
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
pattern = Regexp.new(/^([^[:ascii:]]|[a-zA-Z0-9\-._: ])+$/)
|
|
93
|
+
if name !~ pattern
|
|
94
|
+
fail ArgumentError, "invalid value for \"name\", must conform to the pattern #{pattern}."
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
@name = name
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Checks equality by comparing each attribute.
|
|
101
|
+
# @param [Object] Object to be compared
|
|
102
|
+
def ==(o)
|
|
103
|
+
return true if self.equal?(o)
|
|
104
|
+
self.class == o.class &&
|
|
105
|
+
name == o.name
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# @see the `==` method
|
|
109
|
+
# @param [Object] Object to be compared
|
|
110
|
+
def eql?(o)
|
|
111
|
+
self == o
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Calculates hash code according to all attributes.
|
|
115
|
+
# @return [Integer] Hash code
|
|
116
|
+
def hash
|
|
117
|
+
[name].hash
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Builds the object from hash
|
|
121
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
122
|
+
# @return [Object] Returns the model itself
|
|
123
|
+
def self.build_from_hash(attributes)
|
|
124
|
+
new.build_from_hash(attributes)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Builds the object from hash
|
|
128
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
129
|
+
# @return [Object] Returns the model itself
|
|
130
|
+
def build_from_hash(attributes)
|
|
131
|
+
return nil unless attributes.is_a?(Hash)
|
|
132
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
133
|
+
if type =~ /\AArray<(.*)>/i
|
|
134
|
+
# check to ensure the input is an array given that the attribute
|
|
135
|
+
# is documented as an array but the input is not
|
|
136
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
137
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
138
|
+
end
|
|
139
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
140
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
141
|
+
elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
142
|
+
self.send("#{key}=", nil)
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
self
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Deserializes the data based on type
|
|
150
|
+
# @param string type Data type
|
|
151
|
+
# @param string value Value to be deserialized
|
|
152
|
+
# @return [Object] Deserialized data
|
|
153
|
+
def _deserialize(type, value)
|
|
154
|
+
case type.to_sym
|
|
155
|
+
when :DateTime
|
|
156
|
+
DateTime.parse(value)
|
|
157
|
+
when :Date
|
|
158
|
+
Date.parse(value)
|
|
159
|
+
when :String
|
|
160
|
+
value.to_s
|
|
161
|
+
when :Integer
|
|
162
|
+
value.to_i
|
|
163
|
+
when :Float
|
|
164
|
+
value.to_f
|
|
165
|
+
when :Boolean
|
|
166
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
167
|
+
true
|
|
168
|
+
else
|
|
169
|
+
false
|
|
170
|
+
end
|
|
171
|
+
when :Object
|
|
172
|
+
# generic object (usually a Hash), return directly
|
|
173
|
+
value
|
|
174
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
175
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
176
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
177
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
178
|
+
k_type = Regexp.last_match[:k_type]
|
|
179
|
+
v_type = Regexp.last_match[:v_type]
|
|
180
|
+
{}.tap do |hash|
|
|
181
|
+
value.each do |k, v|
|
|
182
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
else # model
|
|
186
|
+
IbmCloudResourceController.const_get(type).build_from_hash(value)
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Returns the string representation of the object
|
|
191
|
+
# @return [String] String presentation of the object
|
|
192
|
+
def to_s
|
|
193
|
+
to_hash.to_s
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
197
|
+
# @return [Hash] Returns the object in the form of hash
|
|
198
|
+
def to_body
|
|
199
|
+
to_hash
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# Returns the object in the form of hash
|
|
203
|
+
# @return [Hash] Returns the object in the form of hash
|
|
204
|
+
def to_hash
|
|
205
|
+
hash = {}
|
|
206
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
207
|
+
value = self.send(attr)
|
|
208
|
+
if value.nil?
|
|
209
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
210
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
hash[param] = _to_hash(value)
|
|
214
|
+
end
|
|
215
|
+
hash
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# Outputs non-array value in the form of hash
|
|
219
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
220
|
+
# @param [Object] value Any valid value
|
|
221
|
+
# @return [Hash] Returns the value in the form of hash
|
|
222
|
+
def _to_hash(value)
|
|
223
|
+
if value.is_a?(Array)
|
|
224
|
+
value.compact.map { |v| _to_hash(v) }
|
|
225
|
+
elsif value.is_a?(Hash)
|
|
226
|
+
{}.tap do |hash|
|
|
227
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
228
|
+
end
|
|
229
|
+
elsif value.respond_to? :to_hash
|
|
230
|
+
value.to_hash
|
|
231
|
+
else
|
|
232
|
+
value
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
end
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#IBM Cloud Resource Controller API
|
|
3
|
+
|
|
4
|
+
#Manage lifecycle of your Cloud resources using Resource Controller APIs. Resources are provisioned globally in an account scope. Supports asynchronous provisioning of resources. Enables consumption of a global resource through a Cloud Foundry space in any region.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 2.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
OpenAPI Generator version: 5.0.0-beta2
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
|
|
15
|
+
module IbmCloudResourceController
|
|
16
|
+
# Property values for the new resource key.
|
|
17
|
+
class ResourceKeyPost
|
|
18
|
+
# The name of the key.
|
|
19
|
+
attr_accessor :name
|
|
20
|
+
|
|
21
|
+
# The short or long ID of resource instance or alias.
|
|
22
|
+
attr_accessor :source
|
|
23
|
+
|
|
24
|
+
attr_accessor :parameters
|
|
25
|
+
|
|
26
|
+
# The role name or it's CRN.
|
|
27
|
+
attr_accessor :role
|
|
28
|
+
|
|
29
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
30
|
+
def self.attribute_map
|
|
31
|
+
{
|
|
32
|
+
:'name' => :'name',
|
|
33
|
+
:'source' => :'source',
|
|
34
|
+
:'parameters' => :'parameters',
|
|
35
|
+
:'role' => :'role'
|
|
36
|
+
}
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Attribute type mapping.
|
|
40
|
+
def self.openapi_types
|
|
41
|
+
{
|
|
42
|
+
:'name' => :'String',
|
|
43
|
+
:'source' => :'String',
|
|
44
|
+
:'parameters' => :'ResourceBindingPostParameters',
|
|
45
|
+
:'role' => :'String'
|
|
46
|
+
}
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# List of attributes with nullable: true
|
|
50
|
+
def self.openapi_nullable
|
|
51
|
+
Set.new([
|
|
52
|
+
])
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Initializes the object
|
|
56
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
57
|
+
def initialize(attributes = {})
|
|
58
|
+
if (!attributes.is_a?(Hash))
|
|
59
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `IbmCloudResourceController::ResourceKeyPost` initialize method"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
63
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
64
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
65
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `IbmCloudResourceController::ResourceKeyPost`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
66
|
+
end
|
|
67
|
+
h[k.to_sym] = v
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if attributes.key?(:'name')
|
|
71
|
+
self.name = attributes[:'name']
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
if attributes.key?(:'source')
|
|
75
|
+
self.source = attributes[:'source']
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
if attributes.key?(:'parameters')
|
|
79
|
+
self.parameters = attributes[:'parameters']
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
if attributes.key?(:'role')
|
|
83
|
+
self.role = attributes[:'role']
|
|
84
|
+
else
|
|
85
|
+
self.role = 'Writer'
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
90
|
+
# @return Array for valid properties with the reasons
|
|
91
|
+
def list_invalid_properties
|
|
92
|
+
invalid_properties = Array.new
|
|
93
|
+
if @name.nil?
|
|
94
|
+
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
if @source.nil?
|
|
98
|
+
invalid_properties.push('invalid value for "source", source cannot be nil.')
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
invalid_properties
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Check to see if the all the properties in the model are valid
|
|
105
|
+
# @return true if the model is valid
|
|
106
|
+
def valid?
|
|
107
|
+
return false if @name.nil?
|
|
108
|
+
return false if @source.nil?
|
|
109
|
+
true
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Checks equality by comparing each attribute.
|
|
113
|
+
# @param [Object] Object to be compared
|
|
114
|
+
def ==(o)
|
|
115
|
+
return true if self.equal?(o)
|
|
116
|
+
self.class == o.class &&
|
|
117
|
+
name == o.name &&
|
|
118
|
+
source == o.source &&
|
|
119
|
+
parameters == o.parameters &&
|
|
120
|
+
role == o.role
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# @see the `==` method
|
|
124
|
+
# @param [Object] Object to be compared
|
|
125
|
+
def eql?(o)
|
|
126
|
+
self == o
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Calculates hash code according to all attributes.
|
|
130
|
+
# @return [Integer] Hash code
|
|
131
|
+
def hash
|
|
132
|
+
[name, source, parameters, role].hash
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Builds the object from hash
|
|
136
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
137
|
+
# @return [Object] Returns the model itself
|
|
138
|
+
def self.build_from_hash(attributes)
|
|
139
|
+
new.build_from_hash(attributes)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Builds the object from hash
|
|
143
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
144
|
+
# @return [Object] Returns the model itself
|
|
145
|
+
def build_from_hash(attributes)
|
|
146
|
+
return nil unless attributes.is_a?(Hash)
|
|
147
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
148
|
+
if type =~ /\AArray<(.*)>/i
|
|
149
|
+
# check to ensure the input is an array given that the attribute
|
|
150
|
+
# is documented as an array but the input is not
|
|
151
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
152
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
153
|
+
end
|
|
154
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
155
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
156
|
+
elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
157
|
+
self.send("#{key}=", nil)
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
self
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Deserializes the data based on type
|
|
165
|
+
# @param string type Data type
|
|
166
|
+
# @param string value Value to be deserialized
|
|
167
|
+
# @return [Object] Deserialized data
|
|
168
|
+
def _deserialize(type, value)
|
|
169
|
+
case type.to_sym
|
|
170
|
+
when :DateTime
|
|
171
|
+
DateTime.parse(value)
|
|
172
|
+
when :Date
|
|
173
|
+
Date.parse(value)
|
|
174
|
+
when :String
|
|
175
|
+
value.to_s
|
|
176
|
+
when :Integer
|
|
177
|
+
value.to_i
|
|
178
|
+
when :Float
|
|
179
|
+
value.to_f
|
|
180
|
+
when :Boolean
|
|
181
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
182
|
+
true
|
|
183
|
+
else
|
|
184
|
+
false
|
|
185
|
+
end
|
|
186
|
+
when :Object
|
|
187
|
+
# generic object (usually a Hash), return directly
|
|
188
|
+
value
|
|
189
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
190
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
191
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
192
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
193
|
+
k_type = Regexp.last_match[:k_type]
|
|
194
|
+
v_type = Regexp.last_match[:v_type]
|
|
195
|
+
{}.tap do |hash|
|
|
196
|
+
value.each do |k, v|
|
|
197
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
else # model
|
|
201
|
+
IbmCloudResourceController.const_get(type).build_from_hash(value)
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# Returns the string representation of the object
|
|
206
|
+
# @return [String] String presentation of the object
|
|
207
|
+
def to_s
|
|
208
|
+
to_hash.to_s
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
212
|
+
# @return [Hash] Returns the object in the form of hash
|
|
213
|
+
def to_body
|
|
214
|
+
to_hash
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# Returns the object in the form of hash
|
|
218
|
+
# @return [Hash] Returns the object in the form of hash
|
|
219
|
+
def to_hash
|
|
220
|
+
hash = {}
|
|
221
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
222
|
+
value = self.send(attr)
|
|
223
|
+
if value.nil?
|
|
224
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
225
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
hash[param] = _to_hash(value)
|
|
229
|
+
end
|
|
230
|
+
hash
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Outputs non-array value in the form of hash
|
|
234
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
235
|
+
# @param [Object] value Any valid value
|
|
236
|
+
# @return [Hash] Returns the value in the form of hash
|
|
237
|
+
def _to_hash(value)
|
|
238
|
+
if value.is_a?(Array)
|
|
239
|
+
value.compact.map { |v| _to_hash(v) }
|
|
240
|
+
elsif value.is_a?(Hash)
|
|
241
|
+
{}.tap do |hash|
|
|
242
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
243
|
+
end
|
|
244
|
+
elsif value.respond_to? :to_hash
|
|
245
|
+
value.to_hash
|
|
246
|
+
else
|
|
247
|
+
value
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
end
|