ibm_cloud_resource_controller 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/.bumpversion.cfg +13 -0
  3. data/.gitignore +13 -0
  4. data/.openapi-generator-ignore +23 -0
  5. data/.openapi-generator/VERSION +1 -0
  6. data/.rspec +3 -0
  7. data/.travis.yml +49 -0
  8. data/CHANGELOG.md +2 -0
  9. data/CODE_OF_CONDUCT.md +76 -0
  10. data/CONTRIBUTING.md +13 -0
  11. data/Gemfile +4 -6
  12. data/LICENSE +201 -0
  13. data/README.md +56 -120
  14. data/Rakefile +3 -7
  15. data/bin/console +14 -0
  16. data/bin/setup +8 -0
  17. data/ibm_cloud_resource_controller.gemspec +34 -37
  18. data/lib/ibm_cloud_resource_controller.rb +9 -64
  19. data/lib/ibm_cloud_resource_controller/authenticators.rb +15 -0
  20. data/lib/ibm_cloud_resource_controller/common.rb +22 -0
  21. data/lib/ibm_cloud_resource_controller/resource_controller_v2.rb +982 -0
  22. data/lib/ibm_cloud_resource_controller/resource_manager_v2.rb +303 -0
  23. data/lib/ibm_cloud_resource_controller/version.rb +1 -13
  24. metadata +59 -145
  25. data/docs/Credentials.md +0 -25
  26. data/docs/ErrorReport.md +0 -23
  27. data/docs/PlanHistoryItem.md +0 -19
  28. data/docs/Reclamation.md +0 -45
  29. data/docs/ReclamationActionsPost.md +0 -19
  30. data/docs/ReclamationsList.md +0 -17
  31. data/docs/ResourceAlias.md +0 -57
  32. data/docs/ResourceAliasPatch.md +0 -17
  33. data/docs/ResourceAliasPost.md +0 -21
  34. data/docs/ResourceAliasesApi.md +0 -302
  35. data/docs/ResourceAliasesList.md +0 -21
  36. data/docs/ResourceBinding.md +0 -57
  37. data/docs/ResourceBindingPatch.md +0 -17
  38. data/docs/ResourceBindingPost.md +0 -25
  39. data/docs/ResourceBindingPostParameters.md +0 -17
  40. data/docs/ResourceBindingsApi.md +0 -300
  41. data/docs/ResourceBindingsList.md +0 -21
  42. data/docs/ResourceInstance.md +0 -81
  43. data/docs/ResourceInstancePatch.md +0 -23
  44. data/docs/ResourceInstancePost.md +0 -29
  45. data/docs/ResourceInstancesApi.md +0 -418
  46. data/docs/ResourceInstancesList.md +0 -21
  47. data/docs/ResourceKey.md +0 -53
  48. data/docs/ResourceKeyPatch.md +0 -17
  49. data/docs/ResourceKeyPost.md +0 -23
  50. data/docs/ResourceKeysApi.md +0 -298
  51. data/docs/ResourceKeysList.md +0 -21
  52. data/docs/ResourceReclamationsApi.md +0 -128
  53. data/git_push.sh +0 -58
  54. data/lib/ibm_cloud_resource_controller/api/resource_aliases_api.rb +0 -363
  55. data/lib/ibm_cloud_resource_controller/api/resource_bindings_api.rb +0 -360
  56. data/lib/ibm_cloud_resource_controller/api/resource_instances_api.rb +0 -493
  57. data/lib/ibm_cloud_resource_controller/api/resource_keys_api.rb +0 -357
  58. data/lib/ibm_cloud_resource_controller/api/resource_reclamations_api.rb +0 -156
  59. data/lib/ibm_cloud_resource_controller/api_client.rb +0 -388
  60. data/lib/ibm_cloud_resource_controller/api_error.rb +0 -57
  61. data/lib/ibm_cloud_resource_controller/configuration.rb +0 -248
  62. data/lib/ibm_cloud_resource_controller/models/credentials.rb +0 -250
  63. data/lib/ibm_cloud_resource_controller/models/error_report.rb +0 -240
  64. data/lib/ibm_cloud_resource_controller/models/plan_history_item.rb +0 -230
  65. data/lib/ibm_cloud_resource_controller/models/reclamation.rb +0 -352
  66. data/lib/ibm_cloud_resource_controller/models/reclamation_actions_post.rb +0 -220
  67. data/lib/ibm_cloud_resource_controller/models/reclamations_list.rb +0 -212
  68. data/lib/ibm_cloud_resource_controller/models/resource_alias.rb +0 -410
  69. data/lib/ibm_cloud_resource_controller/models/resource_alias_patch.rb +0 -236
  70. data/lib/ibm_cloud_resource_controller/models/resource_alias_post.rb +0 -266
  71. data/lib/ibm_cloud_resource_controller/models/resource_aliases_list.rb +0 -247
  72. data/lib/ibm_cloud_resource_controller/models/resource_binding.rb +0 -410
  73. data/lib/ibm_cloud_resource_controller/models/resource_binding_patch.rb +0 -236
  74. data/lib/ibm_cloud_resource_controller/models/resource_binding_post.rb +0 -278
  75. data/lib/ibm_cloud_resource_controller/models/resource_binding_post_parameters.rb +0 -210
  76. data/lib/ibm_cloud_resource_controller/models/resource_bindings_list.rb +0 -247
  77. data/lib/ibm_cloud_resource_controller/models/resource_instance.rb +0 -536
  78. data/lib/ibm_cloud_resource_controller/models/resource_instance_patch.rb +0 -259
  79. data/lib/ibm_cloud_resource_controller/models/resource_instance_post.rb +0 -317
  80. data/lib/ibm_cloud_resource_controller/models/resource_instances_list.rb +0 -247
  81. data/lib/ibm_cloud_resource_controller/models/resource_key.rb +0 -390
  82. data/lib/ibm_cloud_resource_controller/models/resource_key_patch.rb +0 -236
  83. data/lib/ibm_cloud_resource_controller/models/resource_key_post.rb +0 -251
  84. data/lib/ibm_cloud_resource_controller/models/resource_keys_list.rb +0 -247
  85. data/spec/api/resource_aliases_api_spec.rb +0 -104
  86. data/spec/api/resource_bindings_api_spec.rb +0 -103
  87. data/spec/api/resource_instances_api_spec.rb +0 -130
  88. data/spec/api/resource_keys_api_spec.rb +0 -102
  89. data/spec/api/resource_reclamations_api_spec.rb +0 -62
  90. data/spec/api_client_spec.rb +0 -226
  91. data/spec/configuration_spec.rb +0 -42
  92. data/spec/models/credentials_spec.rb +0 -65
  93. data/spec/models/error_report_spec.rb +0 -59
  94. data/spec/models/plan_history_item_spec.rb +0 -47
  95. data/spec/models/reclamation_actions_post_spec.rb +0 -47
  96. data/spec/models/reclamation_spec.rb +0 -125
  97. data/spec/models/reclamations_list_spec.rb +0 -41
  98. data/spec/models/resource_alias_patch_spec.rb +0 -41
  99. data/spec/models/resource_alias_post_spec.rb +0 -53
  100. data/spec/models/resource_alias_spec.rb +0 -143
  101. data/spec/models/resource_aliases_list_spec.rb +0 -53
  102. data/spec/models/resource_binding_patch_spec.rb +0 -41
  103. data/spec/models/resource_binding_post_parameters_spec.rb +0 -41
  104. data/spec/models/resource_binding_post_spec.rb +0 -65
  105. data/spec/models/resource_binding_spec.rb +0 -137
  106. data/spec/models/resource_bindings_list_spec.rb +0 -53
  107. data/spec/models/resource_instance_patch_spec.rb +0 -59
  108. data/spec/models/resource_instance_post_spec.rb +0 -77
  109. data/spec/models/resource_instance_spec.rb +0 -191
  110. data/spec/models/resource_instances_list_spec.rb +0 -53
  111. data/spec/models/resource_key_patch_spec.rb +0 -41
  112. data/spec/models/resource_key_post_spec.rb +0 -59
  113. data/spec/models/resource_key_spec.rb +0 -125
  114. data/spec/models/resource_keys_list_spec.rb +0 -53
  115. data/spec/spec_helper.rb +0 -111
@@ -1,259 +0,0 @@
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 a resource instance.
17
- class ResourceInstancePatch
18
- # The new name of the instance. Must be 180 characters or less and cannot include any special characters other than `(space) - . _ :`.
19
- attr_accessor :name
20
-
21
- # The new configuration options for the instance.
22
- attr_accessor :parameters
23
-
24
- # The unique ID of the plan associated with the offering. This value is provided by and stored in the global catalog.
25
- attr_accessor :resource_plan_id
26
-
27
- # A boolean that dictates if the resource instance should be deleted (cleaned up) during the processing of a region instance delete call.
28
- attr_accessor :allow_cleanup
29
-
30
- # Attribute mapping from ruby-style variable name to JSON key.
31
- def self.attribute_map
32
- {
33
- :'name' => :'name',
34
- :'parameters' => :'parameters',
35
- :'resource_plan_id' => :'resource_plan_id',
36
- :'allow_cleanup' => :'allow_cleanup'
37
- }
38
- end
39
-
40
- # Attribute type mapping.
41
- def self.openapi_types
42
- {
43
- :'name' => :'String',
44
- :'parameters' => :'Hash<String, Object>',
45
- :'resource_plan_id' => :'String',
46
- :'allow_cleanup' => :'Boolean'
47
- }
48
- end
49
-
50
- # List of attributes with nullable: true
51
- def self.openapi_nullable
52
- Set.new([
53
- ])
54
- end
55
-
56
- # Initializes the object
57
- # @param [Hash] attributes Model attributes in the form of hash
58
- def initialize(attributes = {})
59
- if (!attributes.is_a?(Hash))
60
- fail ArgumentError, "The input argument (attributes) must be a hash in `IbmCloudResourceController::ResourceInstancePatch` initialize method"
61
- end
62
-
63
- # check to see if the attribute exists and convert string to symbol for hash key
64
- attributes = attributes.each_with_object({}) { |(k, v), h|
65
- if (!self.class.attribute_map.key?(k.to_sym))
66
- fail ArgumentError, "`#{k}` is not a valid attribute in `IbmCloudResourceController::ResourceInstancePatch`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
- end
68
- h[k.to_sym] = v
69
- }
70
-
71
- if attributes.key?(:'name')
72
- self.name = attributes[:'name']
73
- end
74
-
75
- if attributes.key?(:'parameters')
76
- if (value = attributes[:'parameters']).is_a?(Hash)
77
- self.parameters = value
78
- end
79
- end
80
-
81
- if attributes.key?(:'resource_plan_id')
82
- self.resource_plan_id = attributes[:'resource_plan_id']
83
- end
84
-
85
- if attributes.key?(:'allow_cleanup')
86
- self.allow_cleanup = attributes[:'allow_cleanup']
87
- end
88
- end
89
-
90
- # Show invalid properties with the reasons. Usually used together with valid?
91
- # @return Array for valid properties with the reasons
92
- def list_invalid_properties
93
- invalid_properties = Array.new
94
- pattern = Regexp.new(/^([^[:ascii:]]|[a-zA-Z0-9\-._: ])+$/)
95
- if !@name.nil? && @name !~ pattern
96
- invalid_properties.push("invalid value for \"name\", must conform to the pattern #{pattern}.")
97
- end
98
-
99
- invalid_properties
100
- end
101
-
102
- # Check to see if the all the properties in the model are valid
103
- # @return true if the model is valid
104
- def valid?
105
- return false if !@name.nil? && @name !~ Regexp.new(/^([^[:ascii:]]|[a-zA-Z0-9\-._: ])+$/)
106
- true
107
- end
108
-
109
- # Custom attribute writer method with validation
110
- # @param [Object] name Value to be assigned
111
- def name=(name)
112
- pattern = Regexp.new(/^([^[:ascii:]]|[a-zA-Z0-9\-._: ])+$/)
113
- if !name.nil? && name !~ pattern
114
- fail ArgumentError, "invalid value for \"name\", must conform to the pattern #{pattern}."
115
- end
116
-
117
- @name = name
118
- end
119
-
120
- # Checks equality by comparing each attribute.
121
- # @param [Object] Object to be compared
122
- def ==(o)
123
- return true if self.equal?(o)
124
- self.class == o.class &&
125
- name == o.name &&
126
- parameters == o.parameters &&
127
- resource_plan_id == o.resource_plan_id &&
128
- allow_cleanup == o.allow_cleanup
129
- end
130
-
131
- # @see the `==` method
132
- # @param [Object] Object to be compared
133
- def eql?(o)
134
- self == o
135
- end
136
-
137
- # Calculates hash code according to all attributes.
138
- # @return [Integer] Hash code
139
- def hash
140
- [name, parameters, resource_plan_id, allow_cleanup].hash
141
- end
142
-
143
- # Builds the object from hash
144
- # @param [Hash] attributes Model attributes in the form of hash
145
- # @return [Object] Returns the model itself
146
- def self.build_from_hash(attributes)
147
- new.build_from_hash(attributes)
148
- end
149
-
150
- # Builds the object from hash
151
- # @param [Hash] attributes Model attributes in the form of hash
152
- # @return [Object] Returns the model itself
153
- def build_from_hash(attributes)
154
- return nil unless attributes.is_a?(Hash)
155
- self.class.openapi_types.each_pair do |key, type|
156
- if type =~ /\AArray<(.*)>/i
157
- # check to ensure the input is an array given that the attribute
158
- # is documented as an array but the input is not
159
- if attributes[self.class.attribute_map[key]].is_a?(Array)
160
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
161
- end
162
- elsif !attributes[self.class.attribute_map[key]].nil?
163
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
164
- elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
165
- self.send("#{key}=", nil)
166
- end
167
- end
168
-
169
- self
170
- end
171
-
172
- # Deserializes the data based on type
173
- # @param string type Data type
174
- # @param string value Value to be deserialized
175
- # @return [Object] Deserialized data
176
- def _deserialize(type, value)
177
- case type.to_sym
178
- when :DateTime
179
- DateTime.parse(value)
180
- when :Date
181
- Date.parse(value)
182
- when :String
183
- value.to_s
184
- when :Integer
185
- value.to_i
186
- when :Float
187
- value.to_f
188
- when :Boolean
189
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
190
- true
191
- else
192
- false
193
- end
194
- when :Object
195
- # generic object (usually a Hash), return directly
196
- value
197
- when /\AArray<(?<inner_type>.+)>\z/
198
- inner_type = Regexp.last_match[:inner_type]
199
- value.map { |v| _deserialize(inner_type, v) }
200
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
201
- k_type = Regexp.last_match[:k_type]
202
- v_type = Regexp.last_match[:v_type]
203
- {}.tap do |hash|
204
- value.each do |k, v|
205
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
206
- end
207
- end
208
- else # model
209
- IbmCloudResourceController.const_get(type).build_from_hash(value)
210
- end
211
- end
212
-
213
- # Returns the string representation of the object
214
- # @return [String] String presentation of the object
215
- def to_s
216
- to_hash.to_s
217
- end
218
-
219
- # to_body is an alias to to_hash (backward compatibility)
220
- # @return [Hash] Returns the object in the form of hash
221
- def to_body
222
- to_hash
223
- end
224
-
225
- # Returns the object in the form of hash
226
- # @return [Hash] Returns the object in the form of hash
227
- def to_hash
228
- hash = {}
229
- self.class.attribute_map.each_pair do |attr, param|
230
- value = self.send(attr)
231
- if value.nil?
232
- is_nullable = self.class.openapi_nullable.include?(attr)
233
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
234
- end
235
-
236
- hash[param] = _to_hash(value)
237
- end
238
- hash
239
- end
240
-
241
- # Outputs non-array value in the form of hash
242
- # For object, use to_hash. Otherwise, just return the value
243
- # @param [Object] value Any valid value
244
- # @return [Hash] Returns the value in the form of hash
245
- def _to_hash(value)
246
- if value.is_a?(Array)
247
- value.compact.map { |v| _to_hash(v) }
248
- elsif value.is_a?(Hash)
249
- {}.tap do |hash|
250
- value.each { |k, v| hash[k] = _to_hash(v) }
251
- end
252
- elsif value.respond_to? :to_hash
253
- value.to_hash
254
- else
255
- value
256
- end
257
- end
258
- end
259
- end
@@ -1,317 +0,0 @@
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 instance.
17
- class ResourceInstancePost
18
- # The name of the instance. Must be 180 characters or less and cannot include any special characters other than `(space) - . _ :`.
19
- attr_accessor :name
20
-
21
- # The deployment location where the instance should be hosted.
22
- attr_accessor :target
23
-
24
- # Short or long ID of resource group
25
- attr_accessor :resource_group
26
-
27
- # The unique ID of the plan associated with the offering. This value is provided by and stored in the global catalog.
28
- attr_accessor :resource_plan_id
29
-
30
- # Tags that are attached to the instance after provisioning. These tags can be searched and managed through the Tagging API in IBM Cloud.
31
- attr_accessor :tags
32
-
33
- # A boolean that dictates if the resource instance should be deleted (cleaned up) during the processing of a region instance delete call.
34
- attr_accessor :allow_cleanup
35
-
36
- # Configuration options represented as key-value pairs that are passed through to the target resource brokers.
37
- attr_accessor :parameters
38
-
39
- # Attribute mapping from ruby-style variable name to JSON key.
40
- def self.attribute_map
41
- {
42
- :'name' => :'name',
43
- :'target' => :'target',
44
- :'resource_group' => :'resource_group',
45
- :'resource_plan_id' => :'resource_plan_id',
46
- :'tags' => :'tags',
47
- :'allow_cleanup' => :'allow_cleanup',
48
- :'parameters' => :'parameters'
49
- }
50
- end
51
-
52
- # Attribute type mapping.
53
- def self.openapi_types
54
- {
55
- :'name' => :'String',
56
- :'target' => :'String',
57
- :'resource_group' => :'String',
58
- :'resource_plan_id' => :'String',
59
- :'tags' => :'Array<String>',
60
- :'allow_cleanup' => :'Boolean',
61
- :'parameters' => :'Hash<String, Object>'
62
- }
63
- end
64
-
65
- # List of attributes with nullable: true
66
- def self.openapi_nullable
67
- Set.new([
68
- ])
69
- end
70
-
71
- # Initializes the object
72
- # @param [Hash] attributes Model attributes in the form of hash
73
- def initialize(attributes = {})
74
- if (!attributes.is_a?(Hash))
75
- fail ArgumentError, "The input argument (attributes) must be a hash in `IbmCloudResourceController::ResourceInstancePost` initialize method"
76
- end
77
-
78
- # check to see if the attribute exists and convert string to symbol for hash key
79
- attributes = attributes.each_with_object({}) { |(k, v), h|
80
- if (!self.class.attribute_map.key?(k.to_sym))
81
- fail ArgumentError, "`#{k}` is not a valid attribute in `IbmCloudResourceController::ResourceInstancePost`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
82
- end
83
- h[k.to_sym] = v
84
- }
85
-
86
- if attributes.key?(:'name')
87
- self.name = attributes[:'name']
88
- end
89
-
90
- if attributes.key?(:'target')
91
- self.target = attributes[:'target']
92
- end
93
-
94
- if attributes.key?(:'resource_group')
95
- self.resource_group = attributes[:'resource_group']
96
- end
97
-
98
- if attributes.key?(:'resource_plan_id')
99
- self.resource_plan_id = attributes[:'resource_plan_id']
100
- end
101
-
102
- if attributes.key?(:'tags')
103
- if (value = attributes[:'tags']).is_a?(Array)
104
- self.tags = value
105
- end
106
- end
107
-
108
- if attributes.key?(:'allow_cleanup')
109
- self.allow_cleanup = attributes[:'allow_cleanup']
110
- else
111
- self.allow_cleanup = false
112
- end
113
-
114
- if attributes.key?(:'parameters')
115
- if (value = attributes[:'parameters']).is_a?(Hash)
116
- self.parameters = value
117
- end
118
- end
119
- end
120
-
121
- # Show invalid properties with the reasons. Usually used together with valid?
122
- # @return Array for valid properties with the reasons
123
- def list_invalid_properties
124
- invalid_properties = Array.new
125
- if @name.nil?
126
- invalid_properties.push('invalid value for "name", name cannot be nil.')
127
- end
128
-
129
- pattern = Regexp.new(/^([^[:ascii:]]|[a-zA-Z0-9\-._: ])+$/)
130
- if @name !~ pattern
131
- invalid_properties.push("invalid value for \"name\", must conform to the pattern #{pattern}.")
132
- end
133
-
134
- if @target.nil?
135
- invalid_properties.push('invalid value for "target", target cannot be nil.')
136
- end
137
-
138
- if @resource_group.nil?
139
- invalid_properties.push('invalid value for "resource_group", resource_group cannot be nil.')
140
- end
141
-
142
- if @resource_plan_id.nil?
143
- invalid_properties.push('invalid value for "resource_plan_id", resource_plan_id cannot be nil.')
144
- end
145
-
146
- invalid_properties
147
- end
148
-
149
- # Check to see if the all the properties in the model are valid
150
- # @return true if the model is valid
151
- def valid?
152
- return false if @name.nil?
153
- return false if @name !~ Regexp.new(/^([^[:ascii:]]|[a-zA-Z0-9\-._: ])+$/)
154
- return false if @target.nil?
155
- return false if @resource_group.nil?
156
- return false if @resource_plan_id.nil?
157
- true
158
- end
159
-
160
- # Custom attribute writer method with validation
161
- # @param [Object] name Value to be assigned
162
- def name=(name)
163
- if name.nil?
164
- fail ArgumentError, 'name cannot be nil'
165
- end
166
-
167
- pattern = Regexp.new(/^([^[:ascii:]]|[a-zA-Z0-9\-._: ])+$/)
168
- if name !~ pattern
169
- fail ArgumentError, "invalid value for \"name\", must conform to the pattern #{pattern}."
170
- end
171
-
172
- @name = name
173
- end
174
-
175
- # Checks equality by comparing each attribute.
176
- # @param [Object] Object to be compared
177
- def ==(o)
178
- return true if self.equal?(o)
179
- self.class == o.class &&
180
- name == o.name &&
181
- target == o.target &&
182
- resource_group == o.resource_group &&
183
- resource_plan_id == o.resource_plan_id &&
184
- tags == o.tags &&
185
- allow_cleanup == o.allow_cleanup &&
186
- parameters == o.parameters
187
- end
188
-
189
- # @see the `==` method
190
- # @param [Object] Object to be compared
191
- def eql?(o)
192
- self == o
193
- end
194
-
195
- # Calculates hash code according to all attributes.
196
- # @return [Integer] Hash code
197
- def hash
198
- [name, target, resource_group, resource_plan_id, tags, allow_cleanup, parameters].hash
199
- end
200
-
201
- # Builds the object from hash
202
- # @param [Hash] attributes Model attributes in the form of hash
203
- # @return [Object] Returns the model itself
204
- def self.build_from_hash(attributes)
205
- new.build_from_hash(attributes)
206
- end
207
-
208
- # Builds the object from hash
209
- # @param [Hash] attributes Model attributes in the form of hash
210
- # @return [Object] Returns the model itself
211
- def build_from_hash(attributes)
212
- return nil unless attributes.is_a?(Hash)
213
- self.class.openapi_types.each_pair do |key, type|
214
- if type =~ /\AArray<(.*)>/i
215
- # check to ensure the input is an array given that the attribute
216
- # is documented as an array but the input is not
217
- if attributes[self.class.attribute_map[key]].is_a?(Array)
218
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
219
- end
220
- elsif !attributes[self.class.attribute_map[key]].nil?
221
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
222
- elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
223
- self.send("#{key}=", nil)
224
- end
225
- end
226
-
227
- self
228
- end
229
-
230
- # Deserializes the data based on type
231
- # @param string type Data type
232
- # @param string value Value to be deserialized
233
- # @return [Object] Deserialized data
234
- def _deserialize(type, value)
235
- case type.to_sym
236
- when :DateTime
237
- DateTime.parse(value)
238
- when :Date
239
- Date.parse(value)
240
- when :String
241
- value.to_s
242
- when :Integer
243
- value.to_i
244
- when :Float
245
- value.to_f
246
- when :Boolean
247
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
248
- true
249
- else
250
- false
251
- end
252
- when :Object
253
- # generic object (usually a Hash), return directly
254
- value
255
- when /\AArray<(?<inner_type>.+)>\z/
256
- inner_type = Regexp.last_match[:inner_type]
257
- value.map { |v| _deserialize(inner_type, v) }
258
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
259
- k_type = Regexp.last_match[:k_type]
260
- v_type = Regexp.last_match[:v_type]
261
- {}.tap do |hash|
262
- value.each do |k, v|
263
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
264
- end
265
- end
266
- else # model
267
- IbmCloudResourceController.const_get(type).build_from_hash(value)
268
- end
269
- end
270
-
271
- # Returns the string representation of the object
272
- # @return [String] String presentation of the object
273
- def to_s
274
- to_hash.to_s
275
- end
276
-
277
- # to_body is an alias to to_hash (backward compatibility)
278
- # @return [Hash] Returns the object in the form of hash
279
- def to_body
280
- to_hash
281
- end
282
-
283
- # Returns the object in the form of hash
284
- # @return [Hash] Returns the object in the form of hash
285
- def to_hash
286
- hash = {}
287
- self.class.attribute_map.each_pair do |attr, param|
288
- value = self.send(attr)
289
- if value.nil?
290
- is_nullable = self.class.openapi_nullable.include?(attr)
291
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
292
- end
293
-
294
- hash[param] = _to_hash(value)
295
- end
296
- hash
297
- end
298
-
299
- # Outputs non-array value in the form of hash
300
- # For object, use to_hash. Otherwise, just return the value
301
- # @param [Object] value Any valid value
302
- # @return [Hash] Returns the value in the form of hash
303
- def _to_hash(value)
304
- if value.is_a?(Array)
305
- value.compact.map { |v| _to_hash(v) }
306
- elsif value.is_a?(Hash)
307
- {}.tap do |hash|
308
- value.each { |k, v| hash[k] = _to_hash(v) }
309
- end
310
- elsif value.respond_to? :to_hash
311
- value.to_hash
312
- else
313
- value
314
- end
315
- end
316
- end
317
- end