ibm_cloud_iam 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +131 -0
  4. data/Rakefile +10 -0
  5. data/docs/ApiKey.md +43 -0
  6. data/docs/ApiKeyInsideCreateServiceIdRequest.md +23 -0
  7. data/docs/ApiKeyList.md +29 -0
  8. data/docs/CreateApiKeyRequest.md +27 -0
  9. data/docs/CreateServiceIdRequest.md +25 -0
  10. data/docs/EnityHistoryRecord.md +27 -0
  11. data/docs/Error.md +23 -0
  12. data/docs/ExceptionResponse.md +23 -0
  13. data/docs/ExceptionResponseContext.md +39 -0
  14. data/docs/IdentityOperationsApi.md +828 -0
  15. data/docs/InlineObject.md +19 -0
  16. data/docs/InlineObject1.md +23 -0
  17. data/docs/InlineObject2.md +21 -0
  18. data/docs/InlineObject3.md +25 -0
  19. data/docs/MFARequirementsResponse.md +21 -0
  20. data/docs/OidcExceptionResponse.md +25 -0
  21. data/docs/ResponseContext.md +37 -0
  22. data/docs/ServiceId.md +43 -0
  23. data/docs/ServiceIdList.md +29 -0
  24. data/docs/TokenOperationsApi.md +226 -0
  25. data/docs/TokenResponse.md +27 -0
  26. data/docs/UpdateApiKeyRequest.md +19 -0
  27. data/docs/UpdateServiceIdRequest.md +21 -0
  28. data/git_push.sh +58 -0
  29. data/ibm_cloud_iam-1.0.0.gem +0 -0
  30. data/ibm_cloud_iam.gemspec +38 -0
  31. data/lib/ibm_cloud_iam.rb +62 -0
  32. data/lib/ibm_cloud_iam/api/identity_operations_api.rb +1083 -0
  33. data/lib/ibm_cloud_iam/api/token_operations_api.rb +351 -0
  34. data/lib/ibm_cloud_iam/api_client.rb +387 -0
  35. data/lib/ibm_cloud_iam/api_error.rb +57 -0
  36. data/lib/ibm_cloud_iam/configuration.rb +241 -0
  37. data/lib/ibm_cloud_iam/models/api_key.rb +381 -0
  38. data/lib/ibm_cloud_iam/models/api_key_inside_create_service_id_request.rb +245 -0
  39. data/lib/ibm_cloud_iam/models/api_key_list.rb +276 -0
  40. data/lib/ibm_cloud_iam/models/create_api_key_request.rb +270 -0
  41. data/lib/ibm_cloud_iam/models/create_service_id_request.rb +261 -0
  42. data/lib/ibm_cloud_iam/models/enity_history_record.rb +292 -0
  43. data/lib/ibm_cloud_iam/models/error.rb +255 -0
  44. data/lib/ibm_cloud_iam/models/exception_response.rb +251 -0
  45. data/lib/ibm_cloud_iam/models/exception_response_context.rb +320 -0
  46. data/lib/ibm_cloud_iam/models/inline_object.rb +229 -0
  47. data/lib/ibm_cloud_iam/models/inline_object1.rb +254 -0
  48. data/lib/ibm_cloud_iam/models/inline_object2.rb +244 -0
  49. data/lib/ibm_cloud_iam/models/inline_object3.rb +269 -0
  50. data/lib/ibm_cloud_iam/models/mfa_requirements_response.rb +245 -0
  51. data/lib/ibm_cloud_iam/models/oidc_exception_response.rb +258 -0
  52. data/lib/ibm_cloud_iam/models/response_context.rb +310 -0
  53. data/lib/ibm_cloud_iam/models/service_id.rb +377 -0
  54. data/lib/ibm_cloud_iam/models/service_id_list.rb +276 -0
  55. data/lib/ibm_cloud_iam/models/token_response.rb +260 -0
  56. data/lib/ibm_cloud_iam/models/update_api_key_request.rb +220 -0
  57. data/lib/ibm_cloud_iam/models/update_service_id_request.rb +232 -0
  58. data/lib/ibm_cloud_iam/version.rb +15 -0
  59. data/spec/api/identity_operations_api_spec.rb +253 -0
  60. data/spec/api/token_operations_api_spec.rb +94 -0
  61. data/spec/api_client_spec.rb +226 -0
  62. data/spec/configuration_spec.rb +42 -0
  63. data/spec/models/api_key_inside_create_service_id_request_spec.rb +59 -0
  64. data/spec/models/api_key_list_spec.rb +77 -0
  65. data/spec/models/api_key_spec.rb +119 -0
  66. data/spec/models/create_api_key_request_spec.rb +71 -0
  67. data/spec/models/create_service_id_request_spec.rb +65 -0
  68. data/spec/models/enity_history_record_spec.rb +71 -0
  69. data/spec/models/error_spec.rb +59 -0
  70. data/spec/models/exception_response_context_spec.rb +107 -0
  71. data/spec/models/exception_response_spec.rb +59 -0
  72. data/spec/models/inline_object1_spec.rb +59 -0
  73. data/spec/models/inline_object2_spec.rb +53 -0
  74. data/spec/models/inline_object3_spec.rb +65 -0
  75. data/spec/models/inline_object_spec.rb +47 -0
  76. data/spec/models/mfa_requirements_response_spec.rb +53 -0
  77. data/spec/models/oidc_exception_response_spec.rb +65 -0
  78. data/spec/models/response_context_spec.rb +101 -0
  79. data/spec/models/service_id_list_spec.rb +77 -0
  80. data/spec/models/service_id_spec.rb +119 -0
  81. data/spec/models/token_response_spec.rb +71 -0
  82. data/spec/models/update_api_key_request_spec.rb +47 -0
  83. data/spec/models/update_service_id_request_spec.rb +53 -0
  84. data/spec/spec_helper.rb +111 -0
  85. metadata +192 -0
@@ -0,0 +1,270 @@
1
+ =begin
2
+ #IAM Identity Services API
3
+
4
+ #The IAM Identity Service API allows for the management of Identities (Service IDs, ApiKeys).
5
+
6
+ The version of the OpenAPI document: 1.0.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 IbmCloudIam
16
+ # Input body parameters for the Create API key V1 REST request.
17
+ class CreateApiKeyRequest
18
+ # Name of the API key. The name is not checked for uniqueness. Therefore multiple names with the same value can exist. Access is done via the UUID of the API key.
19
+ attr_accessor :name
20
+
21
+ # The optional description of the API key. The 'description' property is only available if a description was provided during a create of an API key.
22
+ attr_accessor :description
23
+
24
+ # The iam_id that this API key authenticates.
25
+ attr_accessor :iam_id
26
+
27
+ # The account ID of the API key.
28
+ attr_accessor :account_id
29
+
30
+ # You can optionally passthrough the API key value for this API key. If passed, NO validation of that apiKey value is done, i.e. the value can be non-URL safe. If omitted, the API key management will create an URL safe opaque API key value. The value of the API key is checked for uniqueness. Please ensure enough variations when passing in this value.
31
+ attr_accessor :apikey
32
+
33
+ # Send true or false to set whether the API key value is retrievable in the future by using the Get details of an API key request. If you create an API key for a user, you must specify `false` or omit the value. We don't allow storing of API keys for users.
34
+ attr_accessor :store_value
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :'name' => :'name',
40
+ :'description' => :'description',
41
+ :'iam_id' => :'iam_id',
42
+ :'account_id' => :'account_id',
43
+ :'apikey' => :'apikey',
44
+ :'store_value' => :'store_value'
45
+ }
46
+ end
47
+
48
+ # Attribute type mapping.
49
+ def self.openapi_types
50
+ {
51
+ :'name' => :'String',
52
+ :'description' => :'String',
53
+ :'iam_id' => :'String',
54
+ :'account_id' => :'String',
55
+ :'apikey' => :'String',
56
+ :'store_value' => :'Boolean'
57
+ }
58
+ end
59
+
60
+ # List of attributes with nullable: true
61
+ def self.openapi_nullable
62
+ Set.new([
63
+ ])
64
+ end
65
+
66
+ # Initializes the object
67
+ # @param [Hash] attributes Model attributes in the form of hash
68
+ def initialize(attributes = {})
69
+ if (!attributes.is_a?(Hash))
70
+ fail ArgumentError, "The input argument (attributes) must be a hash in `IbmCloudIam::CreateApiKeyRequest` initialize method"
71
+ end
72
+
73
+ # check to see if the attribute exists and convert string to symbol for hash key
74
+ attributes = attributes.each_with_object({}) { |(k, v), h|
75
+ if (!self.class.attribute_map.key?(k.to_sym))
76
+ fail ArgumentError, "`#{k}` is not a valid attribute in `IbmCloudIam::CreateApiKeyRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
77
+ end
78
+ h[k.to_sym] = v
79
+ }
80
+
81
+ if attributes.key?(:'name')
82
+ self.name = attributes[:'name']
83
+ end
84
+
85
+ if attributes.key?(:'description')
86
+ self.description = attributes[:'description']
87
+ end
88
+
89
+ if attributes.key?(:'iam_id')
90
+ self.iam_id = attributes[:'iam_id']
91
+ end
92
+
93
+ if attributes.key?(:'account_id')
94
+ self.account_id = attributes[:'account_id']
95
+ end
96
+
97
+ if attributes.key?(:'apikey')
98
+ self.apikey = attributes[:'apikey']
99
+ end
100
+
101
+ if attributes.key?(:'store_value')
102
+ self.store_value = attributes[:'store_value']
103
+ end
104
+ end
105
+
106
+ # Show invalid properties with the reasons. Usually used together with valid?
107
+ # @return Array for valid properties with the reasons
108
+ def list_invalid_properties
109
+ invalid_properties = Array.new
110
+ if @name.nil?
111
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
112
+ end
113
+
114
+ if @iam_id.nil?
115
+ invalid_properties.push('invalid value for "iam_id", iam_id cannot be nil.')
116
+ end
117
+
118
+ invalid_properties
119
+ end
120
+
121
+ # Check to see if the all the properties in the model are valid
122
+ # @return true if the model is valid
123
+ def valid?
124
+ return false if @name.nil?
125
+ return false if @iam_id.nil?
126
+ true
127
+ end
128
+
129
+ # Checks equality by comparing each attribute.
130
+ # @param [Object] Object to be compared
131
+ def ==(o)
132
+ return true if self.equal?(o)
133
+ self.class == o.class &&
134
+ name == o.name &&
135
+ description == o.description &&
136
+ iam_id == o.iam_id &&
137
+ account_id == o.account_id &&
138
+ apikey == o.apikey &&
139
+ store_value == o.store_value
140
+ end
141
+
142
+ # @see the `==` method
143
+ # @param [Object] Object to be compared
144
+ def eql?(o)
145
+ self == o
146
+ end
147
+
148
+ # Calculates hash code according to all attributes.
149
+ # @return [Integer] Hash code
150
+ def hash
151
+ [name, description, iam_id, account_id, apikey, store_value].hash
152
+ end
153
+
154
+ # Builds the object from hash
155
+ # @param [Hash] attributes Model attributes in the form of hash
156
+ # @return [Object] Returns the model itself
157
+ def self.build_from_hash(attributes)
158
+ new.build_from_hash(attributes)
159
+ end
160
+
161
+ # Builds the object from hash
162
+ # @param [Hash] attributes Model attributes in the form of hash
163
+ # @return [Object] Returns the model itself
164
+ def build_from_hash(attributes)
165
+ return nil unless attributes.is_a?(Hash)
166
+ self.class.openapi_types.each_pair do |key, type|
167
+ if type =~ /\AArray<(.*)>/i
168
+ # check to ensure the input is an array given that the attribute
169
+ # is documented as an array but the input is not
170
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
171
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
172
+ end
173
+ elsif !attributes[self.class.attribute_map[key]].nil?
174
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
175
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
176
+ self.send("#{key}=", nil)
177
+ end
178
+ end
179
+
180
+ self
181
+ end
182
+
183
+ # Deserializes the data based on type
184
+ # @param string type Data type
185
+ # @param string value Value to be deserialized
186
+ # @return [Object] Deserialized data
187
+ def _deserialize(type, value)
188
+ case type.to_sym
189
+ when :DateTime
190
+ DateTime.parse(value)
191
+ when :Date
192
+ Date.parse(value)
193
+ when :String
194
+ value.to_s
195
+ when :Integer
196
+ value.to_i
197
+ when :Float
198
+ value.to_f
199
+ when :Boolean
200
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
201
+ true
202
+ else
203
+ false
204
+ end
205
+ when :Object
206
+ # generic object (usually a Hash), return directly
207
+ value
208
+ when /\AArray<(?<inner_type>.+)>\z/
209
+ inner_type = Regexp.last_match[:inner_type]
210
+ value.map { |v| _deserialize(inner_type, v) }
211
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
212
+ k_type = Regexp.last_match[:k_type]
213
+ v_type = Regexp.last_match[:v_type]
214
+ {}.tap do |hash|
215
+ value.each do |k, v|
216
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
217
+ end
218
+ end
219
+ else # model
220
+ IbmCloudIam.const_get(type).build_from_hash(value)
221
+ end
222
+ end
223
+
224
+ # Returns the string representation of the object
225
+ # @return [String] String presentation of the object
226
+ def to_s
227
+ to_hash.to_s
228
+ end
229
+
230
+ # to_body is an alias to to_hash (backward compatibility)
231
+ # @return [Hash] Returns the object in the form of hash
232
+ def to_body
233
+ to_hash
234
+ end
235
+
236
+ # Returns the object in the form of hash
237
+ # @return [Hash] Returns the object in the form of hash
238
+ def to_hash
239
+ hash = {}
240
+ self.class.attribute_map.each_pair do |attr, param|
241
+ value = self.send(attr)
242
+ if value.nil?
243
+ is_nullable = self.class.openapi_nullable.include?(attr)
244
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
245
+ end
246
+
247
+ hash[param] = _to_hash(value)
248
+ end
249
+ hash
250
+ end
251
+
252
+ # Outputs non-array value in the form of hash
253
+ # For object, use to_hash. Otherwise, just return the value
254
+ # @param [Object] value Any valid value
255
+ # @return [Hash] Returns the value in the form of hash
256
+ def _to_hash(value)
257
+ if value.is_a?(Array)
258
+ value.compact.map { |v| _to_hash(v) }
259
+ elsif value.is_a?(Hash)
260
+ {}.tap do |hash|
261
+ value.each { |k, v| hash[k] = _to_hash(v) }
262
+ end
263
+ elsif value.respond_to? :to_hash
264
+ value.to_hash
265
+ else
266
+ value
267
+ end
268
+ end
269
+ end
270
+ end
@@ -0,0 +1,261 @@
1
+ =begin
2
+ #IAM Identity Services API
3
+
4
+ #The IAM Identity Service API allows for the management of Identities (Service IDs, ApiKeys).
5
+
6
+ The version of the OpenAPI document: 1.0.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 IbmCloudIam
16
+ # Input body parameters for the Create service ID V1 REST request.
17
+ class CreateServiceIdRequest
18
+ # ID of the account the service ID belongs to.
19
+ attr_accessor :account_id
20
+
21
+ # Name of the Service Id. The name is not checked for uniqueness. Therefore multiple names with the same value can exist. Access is done via the UUID of the Service Id.
22
+ attr_accessor :name
23
+
24
+ # The optional description of the Service Id. The 'description' property is only available if a description was provided during a create of a Service Id.
25
+ attr_accessor :description
26
+
27
+ # Optional list of CRNs (string array) which point to the services connected to the service ID.
28
+ attr_accessor :unique_instance_crns
29
+
30
+ attr_accessor :apikey
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'account_id' => :'account_id',
36
+ :'name' => :'name',
37
+ :'description' => :'description',
38
+ :'unique_instance_crns' => :'unique_instance_crns',
39
+ :'apikey' => :'apikey'
40
+ }
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.openapi_types
45
+ {
46
+ :'account_id' => :'String',
47
+ :'name' => :'String',
48
+ :'description' => :'String',
49
+ :'unique_instance_crns' => :'Array<String>',
50
+ :'apikey' => :'ApiKeyInsideCreateServiceIdRequest'
51
+ }
52
+ end
53
+
54
+ # List of attributes with nullable: true
55
+ def self.openapi_nullable
56
+ Set.new([
57
+ ])
58
+ end
59
+
60
+ # Initializes the object
61
+ # @param [Hash] attributes Model attributes in the form of hash
62
+ def initialize(attributes = {})
63
+ if (!attributes.is_a?(Hash))
64
+ fail ArgumentError, "The input argument (attributes) must be a hash in `IbmCloudIam::CreateServiceIdRequest` initialize method"
65
+ end
66
+
67
+ # check to see if the attribute exists and convert string to symbol for hash key
68
+ attributes = attributes.each_with_object({}) { |(k, v), h|
69
+ if (!self.class.attribute_map.key?(k.to_sym))
70
+ fail ArgumentError, "`#{k}` is not a valid attribute in `IbmCloudIam::CreateServiceIdRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
71
+ end
72
+ h[k.to_sym] = v
73
+ }
74
+
75
+ if attributes.key?(:'account_id')
76
+ self.account_id = attributes[:'account_id']
77
+ end
78
+
79
+ if attributes.key?(:'name')
80
+ self.name = attributes[:'name']
81
+ end
82
+
83
+ if attributes.key?(:'description')
84
+ self.description = attributes[:'description']
85
+ end
86
+
87
+ if attributes.key?(:'unique_instance_crns')
88
+ if (value = attributes[:'unique_instance_crns']).is_a?(Array)
89
+ self.unique_instance_crns = value
90
+ end
91
+ end
92
+
93
+ if attributes.key?(:'apikey')
94
+ self.apikey = attributes[:'apikey']
95
+ end
96
+ end
97
+
98
+ # Show invalid properties with the reasons. Usually used together with valid?
99
+ # @return Array for valid properties with the reasons
100
+ def list_invalid_properties
101
+ invalid_properties = Array.new
102
+ if @account_id.nil?
103
+ invalid_properties.push('invalid value for "account_id", account_id cannot be nil.')
104
+ end
105
+
106
+ if @name.nil?
107
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
108
+ end
109
+
110
+ invalid_properties
111
+ end
112
+
113
+ # Check to see if the all the properties in the model are valid
114
+ # @return true if the model is valid
115
+ def valid?
116
+ return false if @account_id.nil?
117
+ return false if @name.nil?
118
+ true
119
+ end
120
+
121
+ # Checks equality by comparing each attribute.
122
+ # @param [Object] Object to be compared
123
+ def ==(o)
124
+ return true if self.equal?(o)
125
+ self.class == o.class &&
126
+ account_id == o.account_id &&
127
+ name == o.name &&
128
+ description == o.description &&
129
+ unique_instance_crns == o.unique_instance_crns &&
130
+ apikey == o.apikey
131
+ end
132
+
133
+ # @see the `==` method
134
+ # @param [Object] Object to be compared
135
+ def eql?(o)
136
+ self == o
137
+ end
138
+
139
+ # Calculates hash code according to all attributes.
140
+ # @return [Integer] Hash code
141
+ def hash
142
+ [account_id, name, description, unique_instance_crns, apikey].hash
143
+ end
144
+
145
+ # Builds the object from hash
146
+ # @param [Hash] attributes Model attributes in the form of hash
147
+ # @return [Object] Returns the model itself
148
+ def self.build_from_hash(attributes)
149
+ new.build_from_hash(attributes)
150
+ end
151
+
152
+ # Builds the object from hash
153
+ # @param [Hash] attributes Model attributes in the form of hash
154
+ # @return [Object] Returns the model itself
155
+ def build_from_hash(attributes)
156
+ return nil unless attributes.is_a?(Hash)
157
+ self.class.openapi_types.each_pair do |key, type|
158
+ if type =~ /\AArray<(.*)>/i
159
+ # check to ensure the input is an array given that the attribute
160
+ # is documented as an array but the input is not
161
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
162
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
163
+ end
164
+ elsif !attributes[self.class.attribute_map[key]].nil?
165
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
166
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
167
+ self.send("#{key}=", nil)
168
+ end
169
+ end
170
+
171
+ self
172
+ end
173
+
174
+ # Deserializes the data based on type
175
+ # @param string type Data type
176
+ # @param string value Value to be deserialized
177
+ # @return [Object] Deserialized data
178
+ def _deserialize(type, value)
179
+ case type.to_sym
180
+ when :DateTime
181
+ DateTime.parse(value)
182
+ when :Date
183
+ Date.parse(value)
184
+ when :String
185
+ value.to_s
186
+ when :Integer
187
+ value.to_i
188
+ when :Float
189
+ value.to_f
190
+ when :Boolean
191
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
192
+ true
193
+ else
194
+ false
195
+ end
196
+ when :Object
197
+ # generic object (usually a Hash), return directly
198
+ value
199
+ when /\AArray<(?<inner_type>.+)>\z/
200
+ inner_type = Regexp.last_match[:inner_type]
201
+ value.map { |v| _deserialize(inner_type, v) }
202
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
203
+ k_type = Regexp.last_match[:k_type]
204
+ v_type = Regexp.last_match[:v_type]
205
+ {}.tap do |hash|
206
+ value.each do |k, v|
207
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
208
+ end
209
+ end
210
+ else # model
211
+ IbmCloudIam.const_get(type).build_from_hash(value)
212
+ end
213
+ end
214
+
215
+ # Returns the string representation of the object
216
+ # @return [String] String presentation of the object
217
+ def to_s
218
+ to_hash.to_s
219
+ end
220
+
221
+ # to_body is an alias to to_hash (backward compatibility)
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_body
224
+ to_hash
225
+ end
226
+
227
+ # Returns the object in the form of hash
228
+ # @return [Hash] Returns the object in the form of hash
229
+ def to_hash
230
+ hash = {}
231
+ self.class.attribute_map.each_pair do |attr, param|
232
+ value = self.send(attr)
233
+ if value.nil?
234
+ is_nullable = self.class.openapi_nullable.include?(attr)
235
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
236
+ end
237
+
238
+ hash[param] = _to_hash(value)
239
+ end
240
+ hash
241
+ end
242
+
243
+ # Outputs non-array value in the form of hash
244
+ # For object, use to_hash. Otherwise, just return the value
245
+ # @param [Object] value Any valid value
246
+ # @return [Hash] Returns the value in the form of hash
247
+ def _to_hash(value)
248
+ if value.is_a?(Array)
249
+ value.compact.map { |v| _to_hash(v) }
250
+ elsif value.is_a?(Hash)
251
+ {}.tap do |hash|
252
+ value.each { |k, v| hash[k] = _to_hash(v) }
253
+ end
254
+ elsif value.respond_to? :to_hash
255
+ value.to_hash
256
+ else
257
+ value
258
+ end
259
+ end
260
+ end
261
+ end