swagger_aem 2.5.0 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -1
  3. data/Gemfile.lock +47 -46
  4. data/README.md +20 -9
  5. data/Rakefile +2 -0
  6. data/docs/ConsoleApi.md +107 -58
  7. data/docs/CqApi.md +14 -13
  8. data/docs/CrxApi.md +60 -60
  9. data/docs/CustomApi.md +27 -24
  10. data/docs/GraniteApi.md +75 -0
  11. data/docs/InlineObject.md +17 -0
  12. data/docs/InlineObject1.md +17 -0
  13. data/docs/InlineObject2.md +17 -0
  14. data/docs/InlineObject3.md +17 -0
  15. data/docs/InlineObject4.md +21 -0
  16. data/docs/InlineObject5.md +19 -0
  17. data/docs/InstallStatus.md +9 -0
  18. data/docs/InstallStatusStatus.md +11 -1
  19. data/docs/KeystoreChainItems.md +13 -0
  20. data/docs/KeystoreInfo.md +11 -1
  21. data/docs/KeystoreItems.md +13 -0
  22. data/docs/SamlConfigurationInfo.md +15 -1
  23. data/docs/SamlConfigurationProperties.md +56 -24
  24. data/docs/SamlConfigurationPropertyItemsArray.md +16 -2
  25. data/docs/SamlConfigurationPropertyItemsBoolean.md +17 -3
  26. data/docs/SamlConfigurationPropertyItemsLong.md +17 -3
  27. data/docs/SamlConfigurationPropertyItemsString.md +17 -3
  28. data/docs/SlingApi.md +482 -445
  29. data/docs/TruststoreInfo.md +11 -1
  30. data/docs/TruststoreItems.md +15 -0
  31. data/git_push.sh +11 -8
  32. data/lib/swagger_aem.rb +10 -3
  33. data/lib/swagger_aem/api/console_api.rb +160 -91
  34. data/lib/swagger_aem/api/cq_api.rb +49 -41
  35. data/lib/swagger_aem/api/crx_api.rb +170 -135
  36. data/lib/swagger_aem/api/custom_api.rb +68 -56
  37. data/lib/swagger_aem/api/granite_api.rb +124 -0
  38. data/lib/swagger_aem/api/sling_api.rb +900 -720
  39. data/lib/swagger_aem/api_client.rb +53 -54
  40. data/lib/swagger_aem/api_error.rb +22 -3
  41. data/lib/swagger_aem/configuration.rb +49 -10
  42. data/lib/swagger_aem/models/inline_object.rb +206 -0
  43. data/lib/swagger_aem/models/inline_object1.rb +206 -0
  44. data/lib/swagger_aem/models/inline_object2.rb +206 -0
  45. data/lib/swagger_aem/models/inline_object3.rb +206 -0
  46. data/lib/swagger_aem/models/inline_object4.rb +224 -0
  47. data/lib/swagger_aem/models/inline_object5.rb +215 -0
  48. data/lib/swagger_aem/models/install_status.rb +43 -25
  49. data/lib/swagger_aem/models/install_status_status.rb +46 -28
  50. data/lib/swagger_aem/models/keystore_chain_items.rb +50 -32
  51. data/lib/swagger_aem/models/keystore_info.rb +45 -27
  52. data/lib/swagger_aem/models/keystore_items.rb +49 -31
  53. data/lib/swagger_aem/models/saml_configuration_info.rb +49 -31
  54. data/lib/swagger_aem/models/saml_configuration_properties.rb +114 -168
  55. data/lib/swagger_aem/models/saml_configuration_property_items_array.rb +50 -32
  56. data/lib/swagger_aem/models/saml_configuration_property_items_boolean.rb +56 -38
  57. data/lib/swagger_aem/models/saml_configuration_property_items_long.rb +56 -38
  58. data/lib/swagger_aem/models/saml_configuration_property_items_string.rb +56 -38
  59. data/lib/swagger_aem/models/truststore_info.rb +45 -27
  60. data/lib/swagger_aem/models/truststore_items.rb +54 -36
  61. data/lib/swagger_aem/version.rb +4 -4
  62. data/spec/api/console_api_spec.rb +17 -16
  63. data/spec/api/cq_api_spec.rb +6 -10
  64. data/spec/api/crx_api_spec.rb +11 -25
  65. data/spec/api/custom_api_spec.rb +7 -13
  66. data/spec/api/granite_api_spec.rb +52 -0
  67. data/spec/api/sling_api_spec.rb +32 -88
  68. data/spec/api_client_spec.rb +37 -37
  69. data/spec/configuration_spec.rb +11 -11
  70. data/spec/models/inline_object1_spec.rb +41 -0
  71. data/spec/models/inline_object2_spec.rb +41 -0
  72. data/spec/models/inline_object3_spec.rb +41 -0
  73. data/spec/models/inline_object4_spec.rb +53 -0
  74. data/spec/models/inline_object5_spec.rb +47 -0
  75. data/spec/models/inline_object_spec.rb +41 -0
  76. data/spec/models/install_status_spec.rb +5 -6
  77. data/spec/models/install_status_status_spec.rb +6 -7
  78. data/spec/models/keystore_chain_items_spec.rb +9 -10
  79. data/spec/models/keystore_info_spec.rb +6 -7
  80. data/spec/models/keystore_items_spec.rb +9 -10
  81. data/spec/models/saml_configuration_info_spec.rb +10 -11
  82. data/spec/models/saml_configuration_properties_spec.rb +28 -29
  83. data/spec/models/saml_configuration_property_items_array_spec.rb +10 -11
  84. data/spec/models/saml_configuration_property_items_boolean_spec.rb +11 -12
  85. data/spec/models/saml_configuration_property_items_long_spec.rb +11 -12
  86. data/spec/models/saml_configuration_property_items_string_spec.rb +11 -12
  87. data/spec/models/truststore_info_spec.rb +6 -7
  88. data/spec/models/truststore_items_spec.rb +11 -12
  89. data/spec/spec_helper.rb +3 -3
  90. data/swagger_aem.gemspec +8 -14
  91. metadata +36 -128
@@ -3,10 +3,10 @@
3
3
 
4
4
  #Swagger AEM is an OpenAPI specification for Adobe Experience Manager (AEM) API
5
5
 
6
- OpenAPI spec version: 2.4.0
6
+ The version of the OpenAPI document: 3.4.0
7
7
  Contact: opensource@shinesolutions.com
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.3.0-SNAPSHOT
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
10
 
11
11
  =end
12
12
 
@@ -15,7 +15,6 @@ require 'json'
15
15
  require 'logger'
16
16
  require 'tempfile'
17
17
  require 'typhoeus'
18
- require 'uri'
19
18
 
20
19
  module SwaggerAemClient
21
20
  class ApiClient
@@ -31,9 +30,9 @@ module SwaggerAemClient
31
30
  # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
32
31
  def initialize(config = Configuration.default)
33
32
  @config = config
34
- @user_agent = "Swagger-Codegen/#{VERSION}/ruby"
33
+ @user_agent = "OpenAPI-Generator/#{VERSION}/ruby"
35
34
  @default_headers = {
36
- 'Content-Type' => "application/json",
35
+ 'Content-Type' => 'application/json',
37
36
  'User-Agent' => @user_agent
38
37
  }
39
38
  end
@@ -44,7 +43,7 @@ module SwaggerAemClient
44
43
 
45
44
  # Call an API with given options.
46
45
  #
47
- # @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements:
46
+ # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
48
47
  # the data deserialized from response body (could be nil), response status code and response headers.
49
48
  def call_api(http_method, path, opts = {})
50
49
  request = build_request(http_method, path, opts)
@@ -128,6 +127,34 @@ module SwaggerAemClient
128
127
  request
129
128
  end
130
129
 
130
+ # Builds the HTTP request body
131
+ #
132
+ # @param [Hash] header_params Header parameters
133
+ # @param [Hash] form_params Query parameters
134
+ # @param [Object] body HTTP body (JSON/XML)
135
+ # @return [String] HTTP body data in the form of string
136
+ def build_request_body(header_params, form_params, body)
137
+ # http form
138
+ if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
139
+ header_params['Content-Type'] == 'multipart/form-data'
140
+ data = {}
141
+ form_params.each do |key, value|
142
+ case value
143
+ when ::File, ::Array, nil
144
+ # let typhoeus handle File, Array and nil parameters
145
+ data[key] = value
146
+ else
147
+ data[key] = value.to_s
148
+ end
149
+ end
150
+ elsif body
151
+ data = body.is_a?(String) ? body : body.to_json
152
+ else
153
+ data = nil
154
+ end
155
+ data
156
+ end
157
+
131
158
  # Check if the given MIME is a JSON MIME.
132
159
  # JSON MIME examples:
133
160
  # application/json
@@ -137,13 +164,13 @@ module SwaggerAemClient
137
164
  # @param [String] mime MIME
138
165
  # @return [Boolean] True if the MIME is application/json
139
166
  def json_mime?(mime)
140
- (mime == "*/*") || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
167
+ (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
141
168
  end
142
169
 
143
170
  # Deserialize the response to the given return type.
144
171
  #
145
172
  # @param [Response] response HTTP response
146
- # @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
173
+ # @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
147
174
  def deserialize(response, return_type)
148
175
  body = response.body
149
176
 
@@ -187,7 +214,7 @@ module SwaggerAemClient
187
214
  data.to_i
188
215
  when 'Float'
189
216
  data.to_f
190
- when 'BOOLEAN'
217
+ when 'Boolean'
191
218
  data == true
192
219
  when 'DateTime'
193
220
  # parse date time (expecting ISO 8601 format)
@@ -201,18 +228,16 @@ module SwaggerAemClient
201
228
  when /\AArray<(.+)>\z/
202
229
  # e.g. Array<Pet>
203
230
  sub_type = $1
204
- data.map {|item| convert_to_type(item, sub_type) }
231
+ data.map { |item| convert_to_type(item, sub_type) }
205
232
  when /\AHash\<String, (.+)\>\z/
206
233
  # e.g. Hash<String, Integer>
207
234
  sub_type = $1
208
235
  {}.tap do |hash|
209
- data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
236
+ data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
210
237
  end
211
238
  else
212
239
  # models, e.g. Pet
213
- SwaggerAemClient.const_get(return_type).new.tap do |model|
214
- model.build_from_hash data
215
- end
240
+ SwaggerAemClient.const_get(return_type).build_from_hash(data)
216
241
  end
217
242
  end
218
243
 
@@ -228,7 +253,7 @@ module SwaggerAemClient
228
253
  encoding = nil
229
254
  request.on_headers do |response|
230
255
  content_disposition = response.headers['Content-Disposition']
231
- if content_disposition and content_disposition =~ /filename=/i
256
+ if content_disposition && content_disposition =~ /filename=/i
232
257
  filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
233
258
  prefix = sanitize_filename(filename)
234
259
  else
@@ -244,11 +269,13 @@ module SwaggerAemClient
244
269
  tempfile.write(chunk)
245
270
  end
246
271
  request.on_complete do |response|
247
- tempfile.close
248
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
249
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
250
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
251
- "explicitly with `tempfile.delete`"
272
+ if tempfile
273
+ tempfile.close
274
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
275
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
276
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
277
+ "explicitly with `tempfile.delete`"
278
+ end
252
279
  end
253
280
  end
254
281
 
@@ -264,35 +291,7 @@ module SwaggerAemClient
264
291
  def build_request_url(path)
265
292
  # Add leading and trailing slashes to path
266
293
  path = "/#{path}".gsub(/\/+/, '/')
267
- URI.encode(@config.base_url + path)
268
- end
269
-
270
- # Builds the HTTP request body
271
- #
272
- # @param [Hash] header_params Header parameters
273
- # @param [Hash] form_params Query parameters
274
- # @param [Object] body HTTP body (JSON/XML)
275
- # @return [String] HTTP body data in the form of string
276
- def build_request_body(header_params, form_params, body)
277
- # http form
278
- if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
279
- header_params['Content-Type'] == 'multipart/form-data'
280
- data = {}
281
- form_params.each do |key, value|
282
- case value
283
- when ::File, ::Array, nil
284
- # let typhoeus handle File, Array and nil parameters
285
- data[key] = value
286
- else
287
- data[key] = value.to_s
288
- end
289
- end
290
- elsif body
291
- data = body.is_a?(String) ? body : body.to_json
292
- else
293
- data = nil
294
- end
295
- data
294
+ @config.base_url + path
296
295
  end
297
296
 
298
297
  # Update hearder and query params based on authentication settings.
@@ -314,7 +313,7 @@ module SwaggerAemClient
314
313
 
315
314
  # Sets user agent in HTTP header
316
315
  #
317
- # @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0)
316
+ # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
318
317
  def user_agent=(user_agent)
319
318
  @user_agent = user_agent
320
319
  @default_headers['User-Agent'] = @user_agent
@@ -327,7 +326,7 @@ module SwaggerAemClient
327
326
  return nil if accepts.nil? || accepts.empty?
328
327
  # use JSON when present, otherwise use all of the provided
329
328
  json_accept = accepts.find { |s| json_mime?(s) }
330
- return json_accept || accepts.join(',')
329
+ json_accept || accepts.join(',')
331
330
  end
332
331
 
333
332
  # Return Content-Type header based on an array of content types provided.
@@ -338,7 +337,7 @@ module SwaggerAemClient
338
337
  return 'application/json' if content_types.nil? || content_types.empty?
339
338
  # use JSON when present, otherwise use the first one
340
339
  json_content_type = content_types.find { |s| json_mime?(s) }
341
- return json_content_type || content_types.first
340
+ json_content_type || content_types.first
342
341
  end
343
342
 
344
343
  # Convert object (array, hash, object, etc) to JSON string.
@@ -348,7 +347,7 @@ module SwaggerAemClient
348
347
  return model if model.nil? || model.is_a?(String)
349
348
  local_body = nil
350
349
  if model.is_a?(Array)
351
- local_body = model.map{|m| object_to_hash(m) }
350
+ local_body = model.map { |m| object_to_hash(m) }
352
351
  else
353
352
  local_body = object_to_hash(model)
354
353
  end
@@ -3,10 +3,10 @@
3
3
 
4
4
  #Swagger AEM is an OpenAPI specification for Adobe Experience Manager (AEM) API
5
5
 
6
- OpenAPI spec version: 2.4.0
6
+ The version of the OpenAPI document: 3.4.0
7
7
  Contact: opensource@shinesolutions.com
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.3.0-SNAPSHOT
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
10
 
11
11
  =end
12
12
 
@@ -34,5 +34,24 @@ module SwaggerAemClient
34
34
  super arg
35
35
  end
36
36
  end
37
+
38
+ # Override to_s to display a friendly error message
39
+ def to_s
40
+ message
41
+ end
42
+
43
+ def message
44
+ if @message.nil?
45
+ msg = "Error message: the server returns an error"
46
+ else
47
+ msg = @message
48
+ end
49
+
50
+ msg += "\nHTTP status code: #{code}" if code
51
+ msg += "\nResponse headers: #{response_headers}" if response_headers
52
+ msg += "\nResponse body: #{response_body}" if response_body
53
+
54
+ msg
55
+ end
37
56
  end
38
57
  end
@@ -3,15 +3,13 @@
3
3
 
4
4
  #Swagger AEM is an OpenAPI specification for Adobe Experience Manager (AEM) API
5
5
 
6
- OpenAPI spec version: 2.4.0
6
+ The version of the OpenAPI document: 3.4.0
7
7
  Contact: opensource@shinesolutions.com
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.3.0-SNAPSHOT
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
10
 
11
11
  =end
12
12
 
13
- require 'uri'
14
-
15
13
  module SwaggerAemClient
16
14
  class Configuration
17
15
  # Defines url scheme
@@ -129,8 +127,8 @@ module SwaggerAemClient
129
127
 
130
128
  def initialize
131
129
  @scheme = 'http'
132
- @host = ''
133
- @base_path = '/'
130
+ @host = 'localhost'
131
+ @base_path = ''
134
132
  @api_key = {}
135
133
  @api_key_prefix = {}
136
134
  @timeout = 0
@@ -170,12 +168,11 @@ module SwaggerAemClient
170
168
  def base_path=(base_path)
171
169
  # Add leading and trailing slashes to base_path
172
170
  @base_path = "/#{base_path}".gsub(/\/+/, '/')
173
- @base_path = "" if @base_path == "/"
171
+ @base_path = '' if @base_path == '/'
174
172
  end
175
173
 
176
174
  def base_url
177
- url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
178
- URI.encode(url)
175
+ "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
179
176
  end
180
177
 
181
178
  # Gets API key (with prefix if set).
@@ -205,5 +202,47 @@ module SwaggerAemClient
205
202
  },
206
203
  }
207
204
  end
205
+
206
+ # Returns an array of Server setting
207
+ def server_settings
208
+ [
209
+ {
210
+ url: "/",
211
+ description: "No description provided",
212
+ }
213
+ ]
214
+ end
215
+
216
+ # Returns URL based on server settings
217
+ #
218
+ # @param index array index of the server settings
219
+ # @param variables hash of variable and the corresponding value
220
+ def server_url(index, variables = {})
221
+ servers = server_settings
222
+
223
+ # check array index out of bound
224
+ if (index < 0 || index >= servers.size)
225
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
226
+ end
227
+
228
+ server = servers[index]
229
+ url = server[:url]
230
+
231
+ # go through variable and assign a value
232
+ server[:variables].each do |name, variable|
233
+ if variables.key?(name)
234
+ if (server[:variables][name][:enum_values].include? variables[name])
235
+ url.gsub! "{" + name.to_s + "}", variables[name]
236
+ else
237
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
238
+ end
239
+ else
240
+ # use default value
241
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
242
+ end
243
+ end
244
+
245
+ url
246
+ end
208
247
  end
209
248
  end
@@ -0,0 +1,206 @@
1
+ =begin
2
+ #Adobe Experience Manager (AEM) API
3
+
4
+ #Swagger AEM is an OpenAPI specification for Adobe Experience Manager (AEM) API
5
+
6
+ The version of the OpenAPI document: 3.4.0
7
+ Contact: opensource@shinesolutions.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module SwaggerAemClient
16
+ class InlineObject
17
+ attr_accessor :file
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'file' => :'file'
23
+ }
24
+ end
25
+
26
+ # Attribute type mapping.
27
+ def self.openapi_types
28
+ {
29
+ :'file' => :'File'
30
+ }
31
+ end
32
+
33
+ # List of attributes with nullable: true
34
+ def self.openapi_nullable
35
+ Set.new([
36
+ ])
37
+ end
38
+
39
+ # Initializes the object
40
+ # @param [Hash] attributes Model attributes in the form of hash
41
+ def initialize(attributes = {})
42
+ if (!attributes.is_a?(Hash))
43
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SwaggerAemClient::InlineObject` initialize method"
44
+ end
45
+
46
+ # check to see if the attribute exists and convert string to symbol for hash key
47
+ attributes = attributes.each_with_object({}) { |(k, v), h|
48
+ if (!self.class.attribute_map.key?(k.to_sym))
49
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SwaggerAemClient::InlineObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
50
+ end
51
+ h[k.to_sym] = v
52
+ }
53
+
54
+ if attributes.key?(:'file')
55
+ self.file = attributes[:'file']
56
+ end
57
+ end
58
+
59
+ # Show invalid properties with the reasons. Usually used together with valid?
60
+ # @return Array for valid properties with the reasons
61
+ def list_invalid_properties
62
+ invalid_properties = Array.new
63
+ invalid_properties
64
+ end
65
+
66
+ # Check to see if the all the properties in the model are valid
67
+ # @return true if the model is valid
68
+ def valid?
69
+ true
70
+ end
71
+
72
+ # Checks equality by comparing each attribute.
73
+ # @param [Object] Object to be compared
74
+ def ==(o)
75
+ return true if self.equal?(o)
76
+ self.class == o.class &&
77
+ file == o.file
78
+ end
79
+
80
+ # @see the `==` method
81
+ # @param [Object] Object to be compared
82
+ def eql?(o)
83
+ self == o
84
+ end
85
+
86
+ # Calculates hash code according to all attributes.
87
+ # @return [Integer] Hash code
88
+ def hash
89
+ [file].hash
90
+ end
91
+
92
+ # Builds the object from hash
93
+ # @param [Hash] attributes Model attributes in the form of hash
94
+ # @return [Object] Returns the model itself
95
+ def self.build_from_hash(attributes)
96
+ new.build_from_hash(attributes)
97
+ end
98
+
99
+ # Builds the object from hash
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ # @return [Object] Returns the model itself
102
+ def build_from_hash(attributes)
103
+ return nil unless attributes.is_a?(Hash)
104
+ self.class.openapi_types.each_pair do |key, type|
105
+ if type =~ /\AArray<(.*)>/i
106
+ # check to ensure the input is an array given that the attribute
107
+ # is documented as an array but the input is not
108
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
109
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
110
+ end
111
+ elsif !attributes[self.class.attribute_map[key]].nil?
112
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
113
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
114
+ end
115
+
116
+ self
117
+ end
118
+
119
+ # Deserializes the data based on type
120
+ # @param string type Data type
121
+ # @param string value Value to be deserialized
122
+ # @return [Object] Deserialized data
123
+ def _deserialize(type, value)
124
+ case type.to_sym
125
+ when :DateTime
126
+ DateTime.parse(value)
127
+ when :Date
128
+ Date.parse(value)
129
+ when :String
130
+ value.to_s
131
+ when :Integer
132
+ value.to_i
133
+ when :Float
134
+ value.to_f
135
+ when :Boolean
136
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
137
+ true
138
+ else
139
+ false
140
+ end
141
+ when :Object
142
+ # generic object (usually a Hash), return directly
143
+ value
144
+ when /\AArray<(?<inner_type>.+)>\z/
145
+ inner_type = Regexp.last_match[:inner_type]
146
+ value.map { |v| _deserialize(inner_type, v) }
147
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
148
+ k_type = Regexp.last_match[:k_type]
149
+ v_type = Regexp.last_match[:v_type]
150
+ {}.tap do |hash|
151
+ value.each do |k, v|
152
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
153
+ end
154
+ end
155
+ else # model
156
+ SwaggerAemClient.const_get(type).build_from_hash(value)
157
+ end
158
+ end
159
+
160
+ # Returns the string representation of the object
161
+ # @return [String] String presentation of the object
162
+ def to_s
163
+ to_hash.to_s
164
+ end
165
+
166
+ # to_body is an alias to to_hash (backward compatibility)
167
+ # @return [Hash] Returns the object in the form of hash
168
+ def to_body
169
+ to_hash
170
+ end
171
+
172
+ # Returns the object in the form of hash
173
+ # @return [Hash] Returns the object in the form of hash
174
+ def to_hash
175
+ hash = {}
176
+ self.class.attribute_map.each_pair do |attr, param|
177
+ value = self.send(attr)
178
+ if value.nil?
179
+ is_nullable = self.class.openapi_nullable.include?(attr)
180
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
181
+ end
182
+
183
+ hash[param] = _to_hash(value)
184
+ end
185
+ hash
186
+ end
187
+
188
+ # Outputs non-array value in the form of hash
189
+ # For object, use to_hash. Otherwise, just return the value
190
+ # @param [Object] value Any valid value
191
+ # @return [Hash] Returns the value in the form of hash
192
+ def _to_hash(value)
193
+ if value.is_a?(Array)
194
+ value.compact.map { |v| _to_hash(v) }
195
+ elsif value.is_a?(Hash)
196
+ {}.tap do |hash|
197
+ value.each { |k, v| hash[k] = _to_hash(v) }
198
+ end
199
+ elsif value.respond_to? :to_hash
200
+ value.to_hash
201
+ else
202
+ value
203
+ end
204
+ end
205
+ end
206
+ end