oci 2.3.2 → 2.3.3

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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -5
  3. data/lib/oci.rb +1 -0
  4. data/lib/oci/api_client.rb +2 -2
  5. data/lib/oci/auth/federation_client.rb +1 -0
  6. data/lib/oci/auth/signers/instance_principals_security_token_signer.rb +1 -1
  7. data/lib/oci/auth/signers/x509_federation_client_based_security_token_signer.rb +2 -1
  8. data/lib/oci/core/compute_client.rb +7 -5
  9. data/lib/oci/core/models/create_boot_volume_details.rb +17 -1
  10. data/lib/oci/core/models/egress_security_rule.rb +19 -5
  11. data/lib/oci/core/models/fast_connect_provider_service.rb +2 -2
  12. data/lib/oci/core/models/ingress_security_rule.rb +16 -7
  13. data/lib/oci/core/models/instance.rb +0 -2
  14. data/lib/oci/core/models/launch_instance_details.rb +0 -2
  15. data/lib/oci/core/models/route_rule.rb +19 -8
  16. data/lib/oci/core/models/virtual_circuit.rb +6 -1
  17. data/lib/oci/regions.rb +2 -1
  18. data/lib/oci/resource_search/models/free_text_search_details.rb +158 -0
  19. data/lib/oci/resource_search/models/queryable_field_description.rb +225 -0
  20. data/lib/oci/resource_search/models/resource_summary.rb +272 -0
  21. data/lib/oci/resource_search/models/resource_summary_collection.rb +146 -0
  22. data/lib/oci/resource_search/models/resource_type.rb +158 -0
  23. data/lib/oci/resource_search/models/search_context.rb +149 -0
  24. data/lib/oci/resource_search/models/search_details.rb +192 -0
  25. data/lib/oci/resource_search/models/structured_search_details.rb +158 -0
  26. data/lib/oci/resource_search/resource_search.rb +26 -0
  27. data/lib/oci/resource_search/resource_search_client.rb +279 -0
  28. data/lib/oci/resource_search/resource_search_client_composite_operations.rb +24 -0
  29. data/lib/oci/resource_search/util.rb +2 -0
  30. data/lib/oci/version.rb +1 -1
  31. metadata +14 -2
@@ -0,0 +1,225 @@
1
+ # Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2
+
3
+ require 'date'
4
+ require 'logger'
5
+
6
+ # rubocop:disable Lint/UnneededCopDisableDirective
7
+ module OCI
8
+ # An individual field that can be used as part of a query filter.
9
+ class ResourceSearch::Models::QueryableFieldDescription # rubocop:disable Metrics/LineLength
10
+ FIELD_TYPE_ENUM = [
11
+ FIELD_TYPE_IDENTIFIER = 'IDENTIFIER'.freeze,
12
+ FIELD_TYPE_STRING = 'STRING'.freeze,
13
+ FIELD_TYPE_INTEGER = 'INTEGER'.freeze,
14
+ FIELD_TYPE_RATIONAL = 'RATIONAL'.freeze,
15
+ FIELD_TYPE_BOOLEAN = 'BOOLEAN'.freeze,
16
+ FIELD_TYPE_DATETIME = 'DATETIME'.freeze,
17
+ FIELD_TYPE_IP = 'IP'.freeze,
18
+ FIELD_TYPE_OBJECT = 'OBJECT'.freeze,
19
+ FIELD_TYPE_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
20
+ ].freeze
21
+
22
+ # **[Required]** The type of the field, which dictates what semantics and query constraints you can use when searching or querying.
23
+ #
24
+ # @return [String]
25
+ attr_reader :field_type
26
+
27
+ # **[Required]** The name of the field to use when constructing the query. Field names are present for all types except `OBJECT`.
28
+ #
29
+ # @return [String]
30
+ attr_accessor :field_name
31
+
32
+ # Indicates this field is actually an array of the specified field type.
33
+ #
34
+ # @return [BOOLEAN]
35
+ attr_accessor :is_array
36
+
37
+ # If the field type is `OBJECT`, then this property will provide all the individual properties on the object that can
38
+ # be queried.
39
+ #
40
+ # @return [Array<OCI::ResourceSearch::Models::QueryableFieldDescription>]
41
+ attr_accessor :object_properties
42
+
43
+ # Attribute mapping from ruby-style variable name to JSON key.
44
+ def self.attribute_map
45
+ {
46
+ # rubocop:disable Style/SymbolLiteral
47
+ 'field_type': :'fieldType',
48
+ 'field_name': :'fieldName',
49
+ 'is_array': :'isArray',
50
+ 'object_properties': :'objectProperties'
51
+ # rubocop:enable Style/SymbolLiteral
52
+ }
53
+ end
54
+
55
+ # Attribute type mapping.
56
+ def self.swagger_types
57
+ {
58
+ # rubocop:disable Style/SymbolLiteral
59
+ 'field_type': :'String',
60
+ 'field_name': :'String',
61
+ 'is_array': :'BOOLEAN',
62
+ 'object_properties': :'Array<OCI::ResourceSearch::Models::QueryableFieldDescription>'
63
+ # rubocop:enable Style/SymbolLiteral
64
+ }
65
+ end
66
+
67
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
68
+ # rubocop:disable Metrics/LineLength, Metrics/MethodLength, Layout/EmptyLines, Style/SymbolLiteral
69
+
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ # @option attributes [String] :field_type The value to assign to the {#field_type} property
74
+ # @option attributes [String] :field_name The value to assign to the {#field_name} property
75
+ # @option attributes [BOOLEAN] :is_array The value to assign to the {#is_array} property
76
+ # @option attributes [Array<OCI::ResourceSearch::Models::QueryableFieldDescription>] :object_properties The value to assign to the {#object_properties} property
77
+ def initialize(attributes = {})
78
+ return unless attributes.is_a?(Hash)
79
+
80
+ # convert string to symbol for hash key
81
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
82
+
83
+ self.field_type = attributes[:'fieldType'] if attributes[:'fieldType']
84
+
85
+ raise 'You cannot provide both :fieldType and :field_type' if attributes.key?(:'fieldType') && attributes.key?(:'field_type')
86
+
87
+ self.field_type = attributes[:'field_type'] if attributes[:'field_type']
88
+
89
+ self.field_name = attributes[:'fieldName'] if attributes[:'fieldName']
90
+
91
+ raise 'You cannot provide both :fieldName and :field_name' if attributes.key?(:'fieldName') && attributes.key?(:'field_name')
92
+
93
+ self.field_name = attributes[:'field_name'] if attributes[:'field_name']
94
+
95
+ self.is_array = attributes[:'isArray'] unless attributes[:'isArray'].nil?
96
+
97
+ raise 'You cannot provide both :isArray and :is_array' if attributes.key?(:'isArray') && attributes.key?(:'is_array')
98
+
99
+ self.is_array = attributes[:'is_array'] unless attributes[:'is_array'].nil?
100
+
101
+ self.object_properties = attributes[:'objectProperties'] if attributes[:'objectProperties']
102
+
103
+ raise 'You cannot provide both :objectProperties and :object_properties' if attributes.key?(:'objectProperties') && attributes.key?(:'object_properties')
104
+
105
+ self.object_properties = attributes[:'object_properties'] if attributes[:'object_properties']
106
+ end
107
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
108
+ # rubocop:enable Metrics/LineLength, Metrics/MethodLength, Layout/EmptyLines, Style/SymbolLiteral
109
+
110
+ # Custom attribute writer method checking allowed values (enum).
111
+ # @param [Object] field_type Object to be assigned
112
+ def field_type=(field_type)
113
+ # rubocop:disable Style/ConditionalAssignment
114
+ if field_type && !FIELD_TYPE_ENUM.include?(field_type)
115
+ # rubocop: disable Metrics/LineLength
116
+ OCI.logger.debug("Unknown value for 'field_type' [" + field_type + "]. Mapping to 'FIELD_TYPE_UNKNOWN_ENUM_VALUE'") if OCI.logger
117
+ # rubocop: enable Metrics/LineLength
118
+ @field_type = FIELD_TYPE_UNKNOWN_ENUM_VALUE
119
+ else
120
+ @field_type = field_type
121
+ end
122
+ # rubocop:enable Style/ConditionalAssignment
123
+ end
124
+
125
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity, Layout/EmptyLines
126
+
127
+
128
+ # Checks equality by comparing each attribute.
129
+ # @param [Object] other the other object to be compared
130
+ def ==(other)
131
+ return true if equal?(other)
132
+ self.class == other.class &&
133
+ field_type == other.field_type &&
134
+ field_name == other.field_name &&
135
+ is_array == other.is_array &&
136
+ object_properties == other.object_properties
137
+ end
138
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity, Layout/EmptyLines
139
+
140
+ # @see the `==` method
141
+ # @param [Object] other the other object to be compared
142
+ def eql?(other)
143
+ self == other
144
+ end
145
+
146
+ # rubocop:disable Metrics/AbcSize, Metrics/LineLength, Layout/EmptyLines
147
+
148
+
149
+ # Calculates hash code according to all attributes.
150
+ # @return [Fixnum] Hash code
151
+ def hash
152
+ [field_type, field_name, is_array, object_properties].hash
153
+ end
154
+ # rubocop:enable Metrics/AbcSize, Metrics/LineLength, Layout/EmptyLines
155
+
156
+ # rubocop:disable Metrics/AbcSize, Layout/EmptyLines
157
+
158
+
159
+ # Builds the object from hash
160
+ # @param [Hash] attributes Model attributes in the form of hash
161
+ # @return [Object] Returns the model itself
162
+ def build_from_hash(attributes)
163
+ return nil unless attributes.is_a?(Hash)
164
+ self.class.swagger_types.each_pair do |key, type|
165
+ if type =~ /^Array<(.*)>/i
166
+ # check to ensure the input is an array given that the the attribute
167
+ # is documented as an array but the input is not
168
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
169
+ public_method("#{key}=").call(
170
+ attributes[self.class.attribute_map[key]]
171
+ .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
172
+ )
173
+ end
174
+ elsif !attributes[self.class.attribute_map[key]].nil?
175
+ public_method("#{key}=").call(
176
+ OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
177
+ )
178
+ end
179
+ # or else data not found in attributes(hash), not an issue as the data can be optional
180
+ end
181
+
182
+ self
183
+ end
184
+ # rubocop:enable Metrics/AbcSize, Layout/EmptyLines
185
+
186
+ # Returns the string representation of the object
187
+ # @return [String] String presentation of the object
188
+ def to_s
189
+ to_hash.to_s
190
+ end
191
+
192
+ # Returns the object in the form of hash
193
+ # @return [Hash] Returns the object in the form of hash
194
+ def to_hash
195
+ hash = {}
196
+ self.class.attribute_map.each_pair do |attr, param|
197
+ value = public_method(attr).call
198
+ next if value.nil? && !instance_variable_defined?("@#{attr}")
199
+ hash[param] = _to_hash(value)
200
+ end
201
+ hash
202
+ end
203
+
204
+ private
205
+
206
+ # Outputs non-array value in the form of hash
207
+ # For object, use to_hash. Otherwise, just return the value
208
+ # @param [Object] value Any valid value
209
+ # @return [Hash] Returns the value in the form of hash
210
+ def _to_hash(value)
211
+ if value.is_a?(Array)
212
+ value.compact.map { |v| _to_hash(v) }
213
+ elsif value.is_a?(Hash)
214
+ {}.tap do |hash|
215
+ value.each { |k, v| hash[k] = _to_hash(v) }
216
+ end
217
+ elsif value.respond_to? :to_hash
218
+ value.to_hash
219
+ else
220
+ value
221
+ end
222
+ end
223
+ end
224
+ end
225
+ # rubocop:enable Lint/UnneededCopDisableDirective
@@ -0,0 +1,272 @@
1
+ # Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2
+
3
+ require 'date'
4
+
5
+ # rubocop:disable Lint/UnneededCopDisableDirective
6
+ module OCI
7
+ # A resource that exists in the user's cloud network.
8
+ class ResourceSearch::Models::ResourceSummary # rubocop:disable Metrics/LineLength
9
+ # **[Required]** The resource type name.
10
+ # @return [String]
11
+ attr_accessor :resource_type
12
+
13
+ # **[Required]** The unique identifier for this particular resource, usually an OCID.
14
+ # @return [String]
15
+ attr_accessor :identifier
16
+
17
+ # **[Required]** The OCID of the compartment that contains this resource.
18
+ # @return [String]
19
+ attr_accessor :compartment_id
20
+
21
+ # The time this resource was created.
22
+ # @return [DateTime]
23
+ attr_accessor :time_created
24
+
25
+ # The display name (or name) of this resource, if one exists.
26
+ # @return [String]
27
+ attr_accessor :display_name
28
+
29
+ # The availability domain this resource is located in, if applicable.
30
+ # @return [String]
31
+ attr_accessor :availability_domain
32
+
33
+ # The lifecycle state of this resource, if applicable.
34
+ # @return [String]
35
+ attr_accessor :lifecycle_state
36
+
37
+ # The freeform tags associated with this resource, if any.
38
+ # @return [Hash<String, String>]
39
+ attr_accessor :freeform_tags
40
+
41
+ # The defined tags associated with this resource, if any.
42
+ # @return [Hash<String, Hash<String, Object>>]
43
+ attr_accessor :defined_tags
44
+
45
+ # Contains search context, such as highlighting, for found resources.
46
+ # @return [OCI::ResourceSearch::Models::SearchContext]
47
+ attr_accessor :search_context
48
+
49
+ # Attribute mapping from ruby-style variable name to JSON key.
50
+ def self.attribute_map
51
+ {
52
+ # rubocop:disable Style/SymbolLiteral
53
+ 'resource_type': :'resourceType',
54
+ 'identifier': :'identifier',
55
+ 'compartment_id': :'compartmentId',
56
+ 'time_created': :'timeCreated',
57
+ 'display_name': :'displayName',
58
+ 'availability_domain': :'availabilityDomain',
59
+ 'lifecycle_state': :'lifecycleState',
60
+ 'freeform_tags': :'freeformTags',
61
+ 'defined_tags': :'definedTags',
62
+ 'search_context': :'searchContext'
63
+ # rubocop:enable Style/SymbolLiteral
64
+ }
65
+ end
66
+
67
+ # Attribute type mapping.
68
+ def self.swagger_types
69
+ {
70
+ # rubocop:disable Style/SymbolLiteral
71
+ 'resource_type': :'String',
72
+ 'identifier': :'String',
73
+ 'compartment_id': :'String',
74
+ 'time_created': :'DateTime',
75
+ 'display_name': :'String',
76
+ 'availability_domain': :'String',
77
+ 'lifecycle_state': :'String',
78
+ 'freeform_tags': :'Hash<String, String>',
79
+ 'defined_tags': :'Hash<String, Hash<String, Object>>',
80
+ 'search_context': :'OCI::ResourceSearch::Models::SearchContext'
81
+ # rubocop:enable Style/SymbolLiteral
82
+ }
83
+ end
84
+
85
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
86
+ # rubocop:disable Metrics/LineLength, Metrics/MethodLength, Layout/EmptyLines, Style/SymbolLiteral
87
+
88
+
89
+ # Initializes the object
90
+ # @param [Hash] attributes Model attributes in the form of hash
91
+ # @option attributes [String] :resource_type The value to assign to the {#resource_type} property
92
+ # @option attributes [String] :identifier The value to assign to the {#identifier} property
93
+ # @option attributes [String] :compartment_id The value to assign to the {#compartment_id} property
94
+ # @option attributes [DateTime] :time_created The value to assign to the {#time_created} property
95
+ # @option attributes [String] :display_name The value to assign to the {#display_name} property
96
+ # @option attributes [String] :availability_domain The value to assign to the {#availability_domain} property
97
+ # @option attributes [String] :lifecycle_state The value to assign to the {#lifecycle_state} property
98
+ # @option attributes [Hash<String, String>] :freeform_tags The value to assign to the {#freeform_tags} property
99
+ # @option attributes [Hash<String, Hash<String, Object>>] :defined_tags The value to assign to the {#defined_tags} property
100
+ # @option attributes [OCI::ResourceSearch::Models::SearchContext] :search_context The value to assign to the {#search_context} property
101
+ def initialize(attributes = {})
102
+ return unless attributes.is_a?(Hash)
103
+
104
+ # convert string to symbol for hash key
105
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
106
+
107
+ self.resource_type = attributes[:'resourceType'] if attributes[:'resourceType']
108
+
109
+ raise 'You cannot provide both :resourceType and :resource_type' if attributes.key?(:'resourceType') && attributes.key?(:'resource_type')
110
+
111
+ self.resource_type = attributes[:'resource_type'] if attributes[:'resource_type']
112
+
113
+ self.identifier = attributes[:'identifier'] if attributes[:'identifier']
114
+
115
+ self.compartment_id = attributes[:'compartmentId'] if attributes[:'compartmentId']
116
+
117
+ raise 'You cannot provide both :compartmentId and :compartment_id' if attributes.key?(:'compartmentId') && attributes.key?(:'compartment_id')
118
+
119
+ self.compartment_id = attributes[:'compartment_id'] if attributes[:'compartment_id']
120
+
121
+ self.time_created = attributes[:'timeCreated'] if attributes[:'timeCreated']
122
+
123
+ raise 'You cannot provide both :timeCreated and :time_created' if attributes.key?(:'timeCreated') && attributes.key?(:'time_created')
124
+
125
+ self.time_created = attributes[:'time_created'] if attributes[:'time_created']
126
+
127
+ self.display_name = attributes[:'displayName'] if attributes[:'displayName']
128
+
129
+ raise 'You cannot provide both :displayName and :display_name' if attributes.key?(:'displayName') && attributes.key?(:'display_name')
130
+
131
+ self.display_name = attributes[:'display_name'] if attributes[:'display_name']
132
+
133
+ self.availability_domain = attributes[:'availabilityDomain'] if attributes[:'availabilityDomain']
134
+
135
+ raise 'You cannot provide both :availabilityDomain and :availability_domain' if attributes.key?(:'availabilityDomain') && attributes.key?(:'availability_domain')
136
+
137
+ self.availability_domain = attributes[:'availability_domain'] if attributes[:'availability_domain']
138
+
139
+ self.lifecycle_state = attributes[:'lifecycleState'] if attributes[:'lifecycleState']
140
+
141
+ raise 'You cannot provide both :lifecycleState and :lifecycle_state' if attributes.key?(:'lifecycleState') && attributes.key?(:'lifecycle_state')
142
+
143
+ self.lifecycle_state = attributes[:'lifecycle_state'] if attributes[:'lifecycle_state']
144
+
145
+ self.freeform_tags = attributes[:'freeformTags'] if attributes[:'freeformTags']
146
+
147
+ raise 'You cannot provide both :freeformTags and :freeform_tags' if attributes.key?(:'freeformTags') && attributes.key?(:'freeform_tags')
148
+
149
+ self.freeform_tags = attributes[:'freeform_tags'] if attributes[:'freeform_tags']
150
+
151
+ self.defined_tags = attributes[:'definedTags'] if attributes[:'definedTags']
152
+
153
+ raise 'You cannot provide both :definedTags and :defined_tags' if attributes.key?(:'definedTags') && attributes.key?(:'defined_tags')
154
+
155
+ self.defined_tags = attributes[:'defined_tags'] if attributes[:'defined_tags']
156
+
157
+ self.search_context = attributes[:'searchContext'] if attributes[:'searchContext']
158
+
159
+ raise 'You cannot provide both :searchContext and :search_context' if attributes.key?(:'searchContext') && attributes.key?(:'search_context')
160
+
161
+ self.search_context = attributes[:'search_context'] if attributes[:'search_context']
162
+ end
163
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
164
+ # rubocop:enable Metrics/LineLength, Metrics/MethodLength, Layout/EmptyLines, Style/SymbolLiteral
165
+
166
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity, Layout/EmptyLines
167
+
168
+
169
+ # Checks equality by comparing each attribute.
170
+ # @param [Object] other the other object to be compared
171
+ def ==(other)
172
+ return true if equal?(other)
173
+ self.class == other.class &&
174
+ resource_type == other.resource_type &&
175
+ identifier == other.identifier &&
176
+ compartment_id == other.compartment_id &&
177
+ time_created == other.time_created &&
178
+ display_name == other.display_name &&
179
+ availability_domain == other.availability_domain &&
180
+ lifecycle_state == other.lifecycle_state &&
181
+ freeform_tags == other.freeform_tags &&
182
+ defined_tags == other.defined_tags &&
183
+ search_context == other.search_context
184
+ end
185
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity, Layout/EmptyLines
186
+
187
+ # @see the `==` method
188
+ # @param [Object] other the other object to be compared
189
+ def eql?(other)
190
+ self == other
191
+ end
192
+
193
+ # rubocop:disable Metrics/AbcSize, Metrics/LineLength, Layout/EmptyLines
194
+
195
+
196
+ # Calculates hash code according to all attributes.
197
+ # @return [Fixnum] Hash code
198
+ def hash
199
+ [resource_type, identifier, compartment_id, time_created, display_name, availability_domain, lifecycle_state, freeform_tags, defined_tags, search_context].hash
200
+ end
201
+ # rubocop:enable Metrics/AbcSize, Metrics/LineLength, Layout/EmptyLines
202
+
203
+ # rubocop:disable Metrics/AbcSize, Layout/EmptyLines
204
+
205
+
206
+ # Builds the object from hash
207
+ # @param [Hash] attributes Model attributes in the form of hash
208
+ # @return [Object] Returns the model itself
209
+ def build_from_hash(attributes)
210
+ return nil unless attributes.is_a?(Hash)
211
+ self.class.swagger_types.each_pair do |key, type|
212
+ if type =~ /^Array<(.*)>/i
213
+ # check to ensure the input is an array given that the the attribute
214
+ # is documented as an array but the input is not
215
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
216
+ public_method("#{key}=").call(
217
+ attributes[self.class.attribute_map[key]]
218
+ .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
219
+ )
220
+ end
221
+ elsif !attributes[self.class.attribute_map[key]].nil?
222
+ public_method("#{key}=").call(
223
+ OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
224
+ )
225
+ end
226
+ # or else data not found in attributes(hash), not an issue as the data can be optional
227
+ end
228
+
229
+ self
230
+ end
231
+ # rubocop:enable Metrics/AbcSize, Layout/EmptyLines
232
+
233
+ # Returns the string representation of the object
234
+ # @return [String] String presentation of the object
235
+ def to_s
236
+ to_hash.to_s
237
+ end
238
+
239
+ # Returns the object in the form of hash
240
+ # @return [Hash] Returns the object in the form of hash
241
+ def to_hash
242
+ hash = {}
243
+ self.class.attribute_map.each_pair do |attr, param|
244
+ value = public_method(attr).call
245
+ next if value.nil? && !instance_variable_defined?("@#{attr}")
246
+ hash[param] = _to_hash(value)
247
+ end
248
+ hash
249
+ end
250
+
251
+ private
252
+
253
+ # Outputs non-array value in the form of hash
254
+ # For object, use to_hash. Otherwise, just return the value
255
+ # @param [Object] value Any valid value
256
+ # @return [Hash] Returns the value in the form of hash
257
+ def _to_hash(value)
258
+ if value.is_a?(Array)
259
+ value.compact.map { |v| _to_hash(v) }
260
+ elsif value.is_a?(Hash)
261
+ {}.tap do |hash|
262
+ value.each { |k, v| hash[k] = _to_hash(v) }
263
+ end
264
+ elsif value.respond_to? :to_hash
265
+ value.to_hash
266
+ else
267
+ value
268
+ end
269
+ end
270
+ end
271
+ end
272
+ # rubocop:enable Lint/UnneededCopDisableDirective