cloudsmith-api 2.0.23 → 2.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +17 -4
- data/build.json +1 -1
- data/docs/FormatSupport.md +1 -0
- data/docs/GenericPackageUpload.md +90 -0
- data/docs/GenericPackageUploadRequest.md +13 -0
- data/docs/GenericUpstream.md +33 -0
- data/docs/GenericUpstreamRequest.md +21 -0
- data/docs/GenericUpstreamRequestPatch.md +21 -0
- data/docs/MavenUpstream.md +1 -0
- data/docs/MavenUpstreamRequest.md +1 -0
- data/docs/MavenUpstreamRequestPatch.md +1 -0
- data/docs/OrganizationTeam.md +1 -1
- data/docs/OrganizationTeamRequest.md +1 -1
- data/docs/OrganizationTeamRequestPatch.md +1 -1
- data/docs/Package.md +1 -0
- data/docs/PackageCopy.md +1 -0
- data/docs/PackageCopyRequest.md +1 -1
- data/docs/PackageMove.md +1 -0
- data/docs/PackageMoveRequest.md +1 -1
- data/docs/PackageQuarantine.md +1 -0
- data/docs/PackageResync.md +1 -0
- data/docs/PackageTag.md +1 -0
- data/docs/PackagesApi.md +131 -0
- data/docs/ReposApi.md +401 -0
- data/lib/cloudsmith-api/api/packages_api.rb +123 -0
- data/lib/cloudsmith-api/api/repos_api.rb +395 -0
- data/lib/cloudsmith-api/models/format_support.rb +16 -1
- data/lib/cloudsmith-api/models/generic_package_upload.rb +992 -0
- data/lib/cloudsmith-api/models/generic_package_upload_request.rb +245 -0
- data/lib/cloudsmith-api/models/generic_upstream.rb +503 -0
- data/lib/cloudsmith-api/models/generic_upstream_request.rb +375 -0
- data/lib/cloudsmith-api/models/generic_upstream_request_patch.rb +365 -0
- data/lib/cloudsmith-api/models/maven_upstream.rb +25 -1
- data/lib/cloudsmith-api/models/maven_upstream_request.rb +25 -1
- data/lib/cloudsmith-api/models/maven_upstream_request_patch.rb +25 -1
- data/lib/cloudsmith-api/models/organization_team.rb +1 -0
- data/lib/cloudsmith-api/models/organization_team_request.rb +1 -0
- data/lib/cloudsmith-api/models/organization_team_request_patch.rb +1 -0
- data/lib/cloudsmith-api/models/package.rb +11 -1
- data/lib/cloudsmith-api/models/package_copy.rb +11 -1
- data/lib/cloudsmith-api/models/package_copy_request.rb +1 -0
- data/lib/cloudsmith-api/models/package_move.rb +11 -1
- data/lib/cloudsmith-api/models/package_move_request.rb +1 -0
- data/lib/cloudsmith-api/models/package_quarantine.rb +11 -1
- data/lib/cloudsmith-api/models/package_resync.rb +11 -1
- data/lib/cloudsmith-api/models/package_tag.rb +11 -1
- data/lib/cloudsmith-api/version.rb +1 -1
- data/lib/cloudsmith-api.rb +5 -0
- data/spec/api/packages_api_spec.rb +28 -0
- data/spec/api/repos_api_spec.rb +87 -0
- data/spec/models/format_support_spec.rb +6 -0
- data/spec/models/generic_package_upload_request_spec.rb +71 -0
- data/spec/models/generic_package_upload_spec.rb +537 -0
- data/spec/models/generic_upstream_request_patch_spec.rb +127 -0
- data/spec/models/generic_upstream_request_spec.rb +127 -0
- data/spec/models/generic_upstream_spec.rb +203 -0
- data/spec/models/maven_upstream_request_patch_spec.rb +10 -0
- data/spec/models/maven_upstream_request_spec.rb +10 -0
- data/spec/models/maven_upstream_spec.rb +10 -0
- data/spec/models/package_copy_spec.rb +6 -0
- data/spec/models/package_move_spec.rb +6 -0
- data/spec/models/package_quarantine_spec.rb +6 -0
- data/spec/models/package_resync_spec.rb +6 -0
- data/spec/models/package_spec.rb +6 -0
- data/spec/models/package_tag_spec.rb +6 -0
- data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/autotest-fsevent-0.3.1/gem_make.out +1 -1
- data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/bigdecimal-4.0.1/gem_make.out +2 -2
- data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/bigdecimal-4.0.1/mkmf.log +4 -4
- data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/ffi-1.17.3/gem_make.out +2 -2
- data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/ffi-1.17.3/mkmf.log +1 -1
- data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/json-2.7.6/gem_make.out +2 -2
- data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/json-2.7.6/mkmf.log +1 -1
- data/vendor/bundle/ruby/2.6.0/gems/bigdecimal-4.0.1/ext/bigdecimal/Makefile +2 -2
- data/vendor/bundle/ruby/2.6.0/gems/ffi-1.17.3/ext/ffi_c/Makefile +2 -2
- data/vendor/bundle/ruby/2.6.0/gems/json-2.7.6/ext/json/ext/generator/Makefile +2 -2
- data/vendor/bundle/ruby/2.6.0/gems/json-2.7.6/ext/json/ext/parser/Makefile +2 -2
- metadata +25 -5
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Cloudsmith API (v1)
|
|
3
|
+
|
|
4
|
+
#The API to the Cloudsmith Service
|
|
5
|
+
|
|
6
|
+
OpenAPI spec version: v1
|
|
7
|
+
Contact: support@cloudsmith.io
|
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
|
9
|
+
Swagger Codegen version: 2.4.50
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
|
|
15
|
+
module CloudsmithApi
|
|
16
|
+
class GenericUpstreamRequest
|
|
17
|
+
# The authentication mode to use when accessing this upstream.
|
|
18
|
+
attr_accessor :auth_mode
|
|
19
|
+
|
|
20
|
+
# Secret to provide with requests to upstream.
|
|
21
|
+
attr_accessor :auth_secret
|
|
22
|
+
|
|
23
|
+
# Username to provide with requests to upstream.
|
|
24
|
+
attr_accessor :auth_username
|
|
25
|
+
|
|
26
|
+
# The key for extra header #1 to send to upstream.
|
|
27
|
+
attr_accessor :extra_header_1
|
|
28
|
+
|
|
29
|
+
# The key for extra header #2 to send to upstream.
|
|
30
|
+
attr_accessor :extra_header_2
|
|
31
|
+
|
|
32
|
+
# The value for extra header #1 to send to upstream. This is stored as plaintext, and is NOT encrypted.
|
|
33
|
+
attr_accessor :extra_value_1
|
|
34
|
+
|
|
35
|
+
# The value for extra header #2 to send to upstream. This is stored as plaintext, and is NOT encrypted.
|
|
36
|
+
attr_accessor :extra_value_2
|
|
37
|
+
|
|
38
|
+
# Whether or not this upstream is active and ready for requests.
|
|
39
|
+
attr_accessor :is_active
|
|
40
|
+
|
|
41
|
+
# The mode that this upstream should operate in. Upstream sources can be used to proxy resolved packages, as well as operate in a proxy/cache or cache only mode.
|
|
42
|
+
attr_accessor :mode
|
|
43
|
+
|
|
44
|
+
# A descriptive name for this upstream source. A shortened version of this name will be used for tagging cached packages retrieved from this upstream.
|
|
45
|
+
attr_accessor :name
|
|
46
|
+
|
|
47
|
+
# Upstream sources are selected for resolving requests by sequential order (1..n), followed by creation date.
|
|
48
|
+
attr_accessor :priority
|
|
49
|
+
|
|
50
|
+
# A unique prefix used to distinguish this upstream source within the repository. Generic upstreams can represent entirely different file servers, and we do not attempt to blend them. The prefix ensures each source remains separate, and requests including this prefix are routed to the correct upstream.
|
|
51
|
+
attr_accessor :upstream_prefix
|
|
52
|
+
|
|
53
|
+
# The URL for this upstream source. This must be a fully qualified URL including any path elements required to reach the root of the repository.
|
|
54
|
+
attr_accessor :upstream_url
|
|
55
|
+
|
|
56
|
+
# If enabled, SSL certificates are verified when requests are made to this upstream. It's recommended to leave this enabled for all public sources to help mitigate Man-In-The-Middle (MITM) attacks. Please note this only applies to HTTPS upstreams.
|
|
57
|
+
attr_accessor :verify_ssl
|
|
58
|
+
|
|
59
|
+
class EnumAttributeValidator
|
|
60
|
+
attr_reader :datatype
|
|
61
|
+
attr_reader :allowable_values
|
|
62
|
+
|
|
63
|
+
def initialize(datatype, allowable_values)
|
|
64
|
+
@allowable_values = allowable_values.map do |value|
|
|
65
|
+
case datatype.to_s
|
|
66
|
+
when /Integer/i
|
|
67
|
+
value.to_i
|
|
68
|
+
when /Float/i
|
|
69
|
+
value.to_f
|
|
70
|
+
else
|
|
71
|
+
value
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def valid?(value)
|
|
77
|
+
!value || allowable_values.include?(value)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
82
|
+
def self.attribute_map
|
|
83
|
+
{
|
|
84
|
+
:'auth_mode' => :'auth_mode',
|
|
85
|
+
:'auth_secret' => :'auth_secret',
|
|
86
|
+
:'auth_username' => :'auth_username',
|
|
87
|
+
:'extra_header_1' => :'extra_header_1',
|
|
88
|
+
:'extra_header_2' => :'extra_header_2',
|
|
89
|
+
:'extra_value_1' => :'extra_value_1',
|
|
90
|
+
:'extra_value_2' => :'extra_value_2',
|
|
91
|
+
:'is_active' => :'is_active',
|
|
92
|
+
:'mode' => :'mode',
|
|
93
|
+
:'name' => :'name',
|
|
94
|
+
:'priority' => :'priority',
|
|
95
|
+
:'upstream_prefix' => :'upstream_prefix',
|
|
96
|
+
:'upstream_url' => :'upstream_url',
|
|
97
|
+
:'verify_ssl' => :'verify_ssl'
|
|
98
|
+
}
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Attribute type mapping.
|
|
102
|
+
def self.swagger_types
|
|
103
|
+
{
|
|
104
|
+
:'auth_mode' => :'String',
|
|
105
|
+
:'auth_secret' => :'String',
|
|
106
|
+
:'auth_username' => :'String',
|
|
107
|
+
:'extra_header_1' => :'String',
|
|
108
|
+
:'extra_header_2' => :'String',
|
|
109
|
+
:'extra_value_1' => :'String',
|
|
110
|
+
:'extra_value_2' => :'String',
|
|
111
|
+
:'is_active' => :'BOOLEAN',
|
|
112
|
+
:'mode' => :'String',
|
|
113
|
+
:'name' => :'String',
|
|
114
|
+
:'priority' => :'Integer',
|
|
115
|
+
:'upstream_prefix' => :'String',
|
|
116
|
+
:'upstream_url' => :'String',
|
|
117
|
+
:'verify_ssl' => :'BOOLEAN'
|
|
118
|
+
}
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Initializes the object
|
|
122
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
123
|
+
def initialize(attributes = {})
|
|
124
|
+
return unless attributes.is_a?(Hash)
|
|
125
|
+
|
|
126
|
+
# convert string to symbol for hash key
|
|
127
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
|
128
|
+
|
|
129
|
+
if attributes.has_key?(:'auth_mode')
|
|
130
|
+
self.auth_mode = attributes[:'auth_mode']
|
|
131
|
+
else
|
|
132
|
+
self.auth_mode = 'None'
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
if attributes.has_key?(:'auth_secret')
|
|
136
|
+
self.auth_secret = attributes[:'auth_secret']
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
if attributes.has_key?(:'auth_username')
|
|
140
|
+
self.auth_username = attributes[:'auth_username']
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
if attributes.has_key?(:'extra_header_1')
|
|
144
|
+
self.extra_header_1 = attributes[:'extra_header_1']
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
if attributes.has_key?(:'extra_header_2')
|
|
148
|
+
self.extra_header_2 = attributes[:'extra_header_2']
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
if attributes.has_key?(:'extra_value_1')
|
|
152
|
+
self.extra_value_1 = attributes[:'extra_value_1']
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
if attributes.has_key?(:'extra_value_2')
|
|
156
|
+
self.extra_value_2 = attributes[:'extra_value_2']
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
if attributes.has_key?(:'is_active')
|
|
160
|
+
self.is_active = attributes[:'is_active']
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
if attributes.has_key?(:'mode')
|
|
164
|
+
self.mode = attributes[:'mode']
|
|
165
|
+
else
|
|
166
|
+
self.mode = 'Proxy Only'
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
if attributes.has_key?(:'name')
|
|
170
|
+
self.name = attributes[:'name']
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
if attributes.has_key?(:'priority')
|
|
174
|
+
self.priority = attributes[:'priority']
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
if attributes.has_key?(:'upstream_prefix')
|
|
178
|
+
self.upstream_prefix = attributes[:'upstream_prefix']
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
if attributes.has_key?(:'upstream_url')
|
|
182
|
+
self.upstream_url = attributes[:'upstream_url']
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
if attributes.has_key?(:'verify_ssl')
|
|
186
|
+
self.verify_ssl = attributes[:'verify_ssl']
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
191
|
+
# @return Array for valid properties with the reasons
|
|
192
|
+
def list_invalid_properties
|
|
193
|
+
invalid_properties = Array.new
|
|
194
|
+
if @name.nil?
|
|
195
|
+
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
if @upstream_url.nil?
|
|
199
|
+
invalid_properties.push('invalid value for "upstream_url", upstream_url cannot be nil.')
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
invalid_properties
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# Check to see if the all the properties in the model are valid
|
|
206
|
+
# @return true if the model is valid
|
|
207
|
+
def valid?
|
|
208
|
+
auth_mode_validator = EnumAttributeValidator.new('String', ['None', 'Username and Password', 'Token'])
|
|
209
|
+
return false unless auth_mode_validator.valid?(@auth_mode)
|
|
210
|
+
mode_validator = EnumAttributeValidator.new('String', ['Proxy Only', 'Cache and Proxy'])
|
|
211
|
+
return false unless mode_validator.valid?(@mode)
|
|
212
|
+
return false if @name.nil?
|
|
213
|
+
return false if @upstream_url.nil?
|
|
214
|
+
true
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
218
|
+
# @param [Object] auth_mode Object to be assigned
|
|
219
|
+
def auth_mode=(auth_mode)
|
|
220
|
+
validator = EnumAttributeValidator.new('String', ['None', 'Username and Password', 'Token'])
|
|
221
|
+
unless validator.valid?(auth_mode)
|
|
222
|
+
fail ArgumentError, 'invalid value for "auth_mode", must be one of #{validator.allowable_values}.'
|
|
223
|
+
end
|
|
224
|
+
@auth_mode = auth_mode
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
228
|
+
# @param [Object] mode Object to be assigned
|
|
229
|
+
def mode=(mode)
|
|
230
|
+
validator = EnumAttributeValidator.new('String', ['Proxy Only', 'Cache and Proxy'])
|
|
231
|
+
unless validator.valid?(mode)
|
|
232
|
+
fail ArgumentError, 'invalid value for "mode", must be one of #{validator.allowable_values}.'
|
|
233
|
+
end
|
|
234
|
+
@mode = mode
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Checks equality by comparing each attribute.
|
|
238
|
+
# @param [Object] Object to be compared
|
|
239
|
+
def ==(o)
|
|
240
|
+
return true if self.equal?(o)
|
|
241
|
+
self.class == o.class &&
|
|
242
|
+
auth_mode == o.auth_mode &&
|
|
243
|
+
auth_secret == o.auth_secret &&
|
|
244
|
+
auth_username == o.auth_username &&
|
|
245
|
+
extra_header_1 == o.extra_header_1 &&
|
|
246
|
+
extra_header_2 == o.extra_header_2 &&
|
|
247
|
+
extra_value_1 == o.extra_value_1 &&
|
|
248
|
+
extra_value_2 == o.extra_value_2 &&
|
|
249
|
+
is_active == o.is_active &&
|
|
250
|
+
mode == o.mode &&
|
|
251
|
+
name == o.name &&
|
|
252
|
+
priority == o.priority &&
|
|
253
|
+
upstream_prefix == o.upstream_prefix &&
|
|
254
|
+
upstream_url == o.upstream_url &&
|
|
255
|
+
verify_ssl == o.verify_ssl
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
# @see the `==` method
|
|
259
|
+
# @param [Object] Object to be compared
|
|
260
|
+
def eql?(o)
|
|
261
|
+
self == o
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
# Calculates hash code according to all attributes.
|
|
265
|
+
# @return [Fixnum] Hash code
|
|
266
|
+
def hash
|
|
267
|
+
[auth_mode, auth_secret, auth_username, extra_header_1, extra_header_2, extra_value_1, extra_value_2, is_active, mode, name, priority, upstream_prefix, upstream_url, verify_ssl].hash
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
# Builds the object from hash
|
|
271
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
272
|
+
# @return [Object] Returns the model itself
|
|
273
|
+
def build_from_hash(attributes)
|
|
274
|
+
return nil unless attributes.is_a?(Hash)
|
|
275
|
+
self.class.swagger_types.each_pair do |key, type|
|
|
276
|
+
if type =~ /\AArray<(.*)>/i
|
|
277
|
+
# check to ensure the input is an array given that the attribute
|
|
278
|
+
# is documented as an array but the input is not
|
|
279
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
280
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
281
|
+
end
|
|
282
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
283
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
284
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
self
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
# Deserializes the data based on type
|
|
291
|
+
# @param string type Data type
|
|
292
|
+
# @param string value Value to be deserialized
|
|
293
|
+
# @return [Object] Deserialized data
|
|
294
|
+
def _deserialize(type, value)
|
|
295
|
+
case type.to_sym
|
|
296
|
+
when :DateTime
|
|
297
|
+
DateTime.parse(value)
|
|
298
|
+
when :Date
|
|
299
|
+
Date.parse(value)
|
|
300
|
+
when :String
|
|
301
|
+
value.to_s
|
|
302
|
+
when :Integer
|
|
303
|
+
value.to_i
|
|
304
|
+
when :Float
|
|
305
|
+
value.to_f
|
|
306
|
+
when :BOOLEAN
|
|
307
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
308
|
+
true
|
|
309
|
+
else
|
|
310
|
+
false
|
|
311
|
+
end
|
|
312
|
+
when :Object
|
|
313
|
+
# generic object (usually a Hash), return directly
|
|
314
|
+
value
|
|
315
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
316
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
317
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
318
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
319
|
+
k_type = Regexp.last_match[:k_type]
|
|
320
|
+
v_type = Regexp.last_match[:v_type]
|
|
321
|
+
{}.tap do |hash|
|
|
322
|
+
value.each do |k, v|
|
|
323
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
324
|
+
end
|
|
325
|
+
end
|
|
326
|
+
else # model
|
|
327
|
+
temp_model = CloudsmithApi.const_get(type).new
|
|
328
|
+
temp_model.build_from_hash(value)
|
|
329
|
+
end
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
# Returns the string representation of the object
|
|
333
|
+
# @return [String] String presentation of the object
|
|
334
|
+
def to_s
|
|
335
|
+
to_hash.to_s
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
339
|
+
# @return [Hash] Returns the object in the form of hash
|
|
340
|
+
def to_body
|
|
341
|
+
to_hash
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
# Returns the object in the form of hash
|
|
345
|
+
# @return [Hash] Returns the object in the form of hash
|
|
346
|
+
def to_hash
|
|
347
|
+
hash = {}
|
|
348
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
349
|
+
value = self.send(attr)
|
|
350
|
+
next if value.nil?
|
|
351
|
+
hash[param] = _to_hash(value)
|
|
352
|
+
end
|
|
353
|
+
hash
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
# Outputs non-array value in the form of hash
|
|
357
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
358
|
+
# @param [Object] value Any valid value
|
|
359
|
+
# @return [Hash] Returns the value in the form of hash
|
|
360
|
+
def _to_hash(value)
|
|
361
|
+
if value.is_a?(Array)
|
|
362
|
+
value.compact.map { |v| _to_hash(v) }
|
|
363
|
+
elsif value.is_a?(Hash)
|
|
364
|
+
{}.tap do |hash|
|
|
365
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
366
|
+
end
|
|
367
|
+
elsif value.respond_to? :to_hash
|
|
368
|
+
value.to_hash
|
|
369
|
+
else
|
|
370
|
+
value
|
|
371
|
+
end
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
end
|
|
375
|
+
end
|