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,244 @@
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
+ class InlineObject2
17
+ # Grant type for this API call. You must set the grant type to `urn:ibm:params:oauth:grant-type:iam-authz`.
18
+ attr_accessor :grant_type
19
+
20
+ # The IAM access token of the identity that has the appropriate authorization to create an IAM access token for a given resource.
21
+ attr_accessor :access_token
22
+
23
+ # The IAM ID of the IAM access token identity that should be created. The desired_iam_id identifies a resource identity. The IAM ID consists of the prefix crn- and the CRN of the target identity, e.g. crn-crn:v1:bluemix:public:cloud-object-storage:global:a/59bcbfa6ea2f006b4ed7094c1a08dcdd:1a0ec336-f391-4091-a6fb-5e084a4c56f4::.
24
+ attr_accessor :desired_iam_id
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'grant_type' => :'grant_type',
30
+ :'access_token' => :'access_token',
31
+ :'desired_iam_id' => :'desired_iam_id'
32
+ }
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'grant_type' => :'String',
39
+ :'access_token' => :'String',
40
+ :'desired_iam_id' => :'String'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `IbmCloudIam::InlineObject2` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `IbmCloudIam::InlineObject2`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:'grant_type')
66
+ self.grant_type = attributes[:'grant_type']
67
+ end
68
+
69
+ if attributes.key?(:'access_token')
70
+ self.access_token = attributes[:'access_token']
71
+ end
72
+
73
+ if attributes.key?(:'desired_iam_id')
74
+ self.desired_iam_id = attributes[:'desired_iam_id']
75
+ end
76
+ end
77
+
78
+ # Show invalid properties with the reasons. Usually used together with valid?
79
+ # @return Array for valid properties with the reasons
80
+ def list_invalid_properties
81
+ invalid_properties = Array.new
82
+ if @grant_type.nil?
83
+ invalid_properties.push('invalid value for "grant_type", grant_type cannot be nil.')
84
+ end
85
+
86
+ if @access_token.nil?
87
+ invalid_properties.push('invalid value for "access_token", access_token cannot be nil.')
88
+ end
89
+
90
+ if @desired_iam_id.nil?
91
+ invalid_properties.push('invalid value for "desired_iam_id", desired_iam_id cannot be nil.')
92
+ end
93
+
94
+ invalid_properties
95
+ end
96
+
97
+ # Check to see if the all the properties in the model are valid
98
+ # @return true if the model is valid
99
+ def valid?
100
+ return false if @grant_type.nil?
101
+ return false if @access_token.nil?
102
+ return false if @desired_iam_id.nil?
103
+ true
104
+ end
105
+
106
+ # Checks equality by comparing each attribute.
107
+ # @param [Object] Object to be compared
108
+ def ==(o)
109
+ return true if self.equal?(o)
110
+ self.class == o.class &&
111
+ grant_type == o.grant_type &&
112
+ access_token == o.access_token &&
113
+ desired_iam_id == o.desired_iam_id
114
+ end
115
+
116
+ # @see the `==` method
117
+ # @param [Object] Object to be compared
118
+ def eql?(o)
119
+ self == o
120
+ end
121
+
122
+ # Calculates hash code according to all attributes.
123
+ # @return [Integer] Hash code
124
+ def hash
125
+ [grant_type, access_token, desired_iam_id].hash
126
+ end
127
+
128
+ # Builds the object from hash
129
+ # @param [Hash] attributes Model attributes in the form of hash
130
+ # @return [Object] Returns the model itself
131
+ def self.build_from_hash(attributes)
132
+ new.build_from_hash(attributes)
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 build_from_hash(attributes)
139
+ return nil unless attributes.is_a?(Hash)
140
+ self.class.openapi_types.each_pair do |key, type|
141
+ if type =~ /\AArray<(.*)>/i
142
+ # check to ensure the input is an array given that the attribute
143
+ # is documented as an array but the input is not
144
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
145
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
146
+ end
147
+ elsif !attributes[self.class.attribute_map[key]].nil?
148
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
149
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
150
+ self.send("#{key}=", nil)
151
+ end
152
+ end
153
+
154
+ self
155
+ end
156
+
157
+ # Deserializes the data based on type
158
+ # @param string type Data type
159
+ # @param string value Value to be deserialized
160
+ # @return [Object] Deserialized data
161
+ def _deserialize(type, value)
162
+ case type.to_sym
163
+ when :DateTime
164
+ DateTime.parse(value)
165
+ when :Date
166
+ Date.parse(value)
167
+ when :String
168
+ value.to_s
169
+ when :Integer
170
+ value.to_i
171
+ when :Float
172
+ value.to_f
173
+ when :Boolean
174
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
175
+ true
176
+ else
177
+ false
178
+ end
179
+ when :Object
180
+ # generic object (usually a Hash), return directly
181
+ value
182
+ when /\AArray<(?<inner_type>.+)>\z/
183
+ inner_type = Regexp.last_match[:inner_type]
184
+ value.map { |v| _deserialize(inner_type, v) }
185
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
186
+ k_type = Regexp.last_match[:k_type]
187
+ v_type = Regexp.last_match[:v_type]
188
+ {}.tap do |hash|
189
+ value.each do |k, v|
190
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
191
+ end
192
+ end
193
+ else # model
194
+ IbmCloudIam.const_get(type).build_from_hash(value)
195
+ end
196
+ end
197
+
198
+ # Returns the string representation of the object
199
+ # @return [String] String presentation of the object
200
+ def to_s
201
+ to_hash.to_s
202
+ end
203
+
204
+ # to_body is an alias to to_hash (backward compatibility)
205
+ # @return [Hash] Returns the object in the form of hash
206
+ def to_body
207
+ to_hash
208
+ end
209
+
210
+ # Returns the object in the form of hash
211
+ # @return [Hash] Returns the object in the form of hash
212
+ def to_hash
213
+ hash = {}
214
+ self.class.attribute_map.each_pair do |attr, param|
215
+ value = self.send(attr)
216
+ if value.nil?
217
+ is_nullable = self.class.openapi_nullable.include?(attr)
218
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
219
+ end
220
+
221
+ hash[param] = _to_hash(value)
222
+ end
223
+ hash
224
+ end
225
+
226
+ # Outputs non-array value in the form of hash
227
+ # For object, use to_hash. Otherwise, just return the value
228
+ # @param [Object] value Any valid value
229
+ # @return [Hash] Returns the value in the form of hash
230
+ def _to_hash(value)
231
+ if value.is_a?(Array)
232
+ value.compact.map { |v| _to_hash(v) }
233
+ elsif value.is_a?(Hash)
234
+ {}.tap do |hash|
235
+ value.each { |k, v| hash[k] = _to_hash(v) }
236
+ end
237
+ elsif value.respond_to? :to_hash
238
+ value.to_hash
239
+ else
240
+ value
241
+ end
242
+ end
243
+ end
244
+ end
@@ -0,0 +1,269 @@
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
+ class InlineObject3
17
+ # Grant type for this API call. You must set the grant type to `urn:ibm:params:oauth:grant-type:apikey`.
18
+ attr_accessor :grant_type
19
+
20
+ # The value of the API key.
21
+ attr_accessor :apikey
22
+
23
+ # Either 'delegated_refresh_token' to receive a delegated refresh token only, or 'cloud_iam delegated_refresh_token' to receive both an IAM access token and a delegated refresh token in one API call.
24
+ attr_accessor :response_type
25
+
26
+ # A comma separated list of one or more client IDs that will be able to consume the delegated refresh token. The service that accepts a delegated refresh token as API parameter must expose its client ID to allow this API call. The receiver of the delegated refresh token will be able to use the refresh token until it expires.
27
+ attr_accessor :receiver_client_ids
28
+
29
+ # Expiration in seconds until the delegated refresh token must be consumed by the receiver client IDs. After the expiration, no client ID can consume the delegated refresh token, even if the life time of the refresh token inside is still not expired. The default, if not specified, is 518,400 seconds which corresponds to 6 days.
30
+ attr_accessor :delegated_refresh_token_expiry
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'grant_type' => :'grant_type',
36
+ :'apikey' => :'apikey',
37
+ :'response_type' => :'response_type',
38
+ :'receiver_client_ids' => :'receiver_client_ids',
39
+ :'delegated_refresh_token_expiry' => :'delegated_refresh_token_expiry'
40
+ }
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.openapi_types
45
+ {
46
+ :'grant_type' => :'String',
47
+ :'apikey' => :'String',
48
+ :'response_type' => :'String',
49
+ :'receiver_client_ids' => :'String',
50
+ :'delegated_refresh_token_expiry' => :'Integer'
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::InlineObject3` 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::InlineObject3`. 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?(:'grant_type')
76
+ self.grant_type = attributes[:'grant_type']
77
+ end
78
+
79
+ if attributes.key?(:'apikey')
80
+ self.apikey = attributes[:'apikey']
81
+ end
82
+
83
+ if attributes.key?(:'response_type')
84
+ self.response_type = attributes[:'response_type']
85
+ end
86
+
87
+ if attributes.key?(:'receiver_client_ids')
88
+ self.receiver_client_ids = attributes[:'receiver_client_ids']
89
+ end
90
+
91
+ if attributes.key?(:'delegated_refresh_token_expiry')
92
+ self.delegated_refresh_token_expiry = attributes[:'delegated_refresh_token_expiry']
93
+ end
94
+ end
95
+
96
+ # Show invalid properties with the reasons. Usually used together with valid?
97
+ # @return Array for valid properties with the reasons
98
+ def list_invalid_properties
99
+ invalid_properties = Array.new
100
+ if @grant_type.nil?
101
+ invalid_properties.push('invalid value for "grant_type", grant_type cannot be nil.')
102
+ end
103
+
104
+ if @apikey.nil?
105
+ invalid_properties.push('invalid value for "apikey", apikey cannot be nil.')
106
+ end
107
+
108
+ if @response_type.nil?
109
+ invalid_properties.push('invalid value for "response_type", response_type cannot be nil.')
110
+ end
111
+
112
+ if @receiver_client_ids.nil?
113
+ invalid_properties.push('invalid value for "receiver_client_ids", receiver_client_ids cannot be nil.')
114
+ end
115
+
116
+ invalid_properties
117
+ end
118
+
119
+ # Check to see if the all the properties in the model are valid
120
+ # @return true if the model is valid
121
+ def valid?
122
+ return false if @grant_type.nil?
123
+ return false if @apikey.nil?
124
+ return false if @response_type.nil?
125
+ return false if @receiver_client_ids.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
+ grant_type == o.grant_type &&
135
+ apikey == o.apikey &&
136
+ response_type == o.response_type &&
137
+ receiver_client_ids == o.receiver_client_ids &&
138
+ delegated_refresh_token_expiry == o.delegated_refresh_token_expiry
139
+ end
140
+
141
+ # @see the `==` method
142
+ # @param [Object] Object to be compared
143
+ def eql?(o)
144
+ self == o
145
+ end
146
+
147
+ # Calculates hash code according to all attributes.
148
+ # @return [Integer] Hash code
149
+ def hash
150
+ [grant_type, apikey, response_type, receiver_client_ids, delegated_refresh_token_expiry].hash
151
+ end
152
+
153
+ # Builds the object from hash
154
+ # @param [Hash] attributes Model attributes in the form of hash
155
+ # @return [Object] Returns the model itself
156
+ def self.build_from_hash(attributes)
157
+ new.build_from_hash(attributes)
158
+ end
159
+
160
+ # Builds the object from hash
161
+ # @param [Hash] attributes Model attributes in the form of hash
162
+ # @return [Object] Returns the model itself
163
+ def build_from_hash(attributes)
164
+ return nil unless attributes.is_a?(Hash)
165
+ self.class.openapi_types.each_pair do |key, type|
166
+ if type =~ /\AArray<(.*)>/i
167
+ # check to ensure the input is an array given that the attribute
168
+ # is documented as an array but the input is not
169
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
170
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
171
+ end
172
+ elsif !attributes[self.class.attribute_map[key]].nil?
173
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
174
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
175
+ self.send("#{key}=", nil)
176
+ end
177
+ end
178
+
179
+ self
180
+ end
181
+
182
+ # Deserializes the data based on type
183
+ # @param string type Data type
184
+ # @param string value Value to be deserialized
185
+ # @return [Object] Deserialized data
186
+ def _deserialize(type, value)
187
+ case type.to_sym
188
+ when :DateTime
189
+ DateTime.parse(value)
190
+ when :Date
191
+ Date.parse(value)
192
+ when :String
193
+ value.to_s
194
+ when :Integer
195
+ value.to_i
196
+ when :Float
197
+ value.to_f
198
+ when :Boolean
199
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
200
+ true
201
+ else
202
+ false
203
+ end
204
+ when :Object
205
+ # generic object (usually a Hash), return directly
206
+ value
207
+ when /\AArray<(?<inner_type>.+)>\z/
208
+ inner_type = Regexp.last_match[:inner_type]
209
+ value.map { |v| _deserialize(inner_type, v) }
210
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
211
+ k_type = Regexp.last_match[:k_type]
212
+ v_type = Regexp.last_match[:v_type]
213
+ {}.tap do |hash|
214
+ value.each do |k, v|
215
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
216
+ end
217
+ end
218
+ else # model
219
+ IbmCloudIam.const_get(type).build_from_hash(value)
220
+ end
221
+ end
222
+
223
+ # Returns the string representation of the object
224
+ # @return [String] String presentation of the object
225
+ def to_s
226
+ to_hash.to_s
227
+ end
228
+
229
+ # to_body is an alias to to_hash (backward compatibility)
230
+ # @return [Hash] Returns the object in the form of hash
231
+ def to_body
232
+ to_hash
233
+ end
234
+
235
+ # Returns the object in the form of hash
236
+ # @return [Hash] Returns the object in the form of hash
237
+ def to_hash
238
+ hash = {}
239
+ self.class.attribute_map.each_pair do |attr, param|
240
+ value = self.send(attr)
241
+ if value.nil?
242
+ is_nullable = self.class.openapi_nullable.include?(attr)
243
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
244
+ end
245
+
246
+ hash[param] = _to_hash(value)
247
+ end
248
+ hash
249
+ end
250
+
251
+ # Outputs non-array value in the form of hash
252
+ # For object, use to_hash. Otherwise, just return the value
253
+ # @param [Object] value Any valid value
254
+ # @return [Hash] Returns the value in the form of hash
255
+ def _to_hash(value)
256
+ if value.is_a?(Array)
257
+ value.compact.map { |v| _to_hash(v) }
258
+ elsif value.is_a?(Hash)
259
+ {}.tap do |hash|
260
+ value.each { |k, v| hash[k] = _to_hash(v) }
261
+ end
262
+ elsif value.respond_to? :to_hash
263
+ value.to_hash
264
+ else
265
+ value
266
+ end
267
+ end
268
+ end
269
+ end