SematextCloud 0.1.4 → 0.1.5

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 (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +87 -65
  3. data/docs/AlertNotificationRequest.md +6 -6
  4. data/docs/AlertNotificationsApi.md +11 -11
  5. data/docs/AlertRule.md +50 -50
  6. data/docs/AlertRuleScheduleTimeRangeDto.md +4 -4
  7. data/docs/AlertRuleScheduleWeekdayDto.md +7 -7
  8. data/docs/AlertsApi.md +22 -22
  9. data/docs/App.md +33 -29
  10. data/docs/AppDescription.md +3 -3
  11. data/docs/AppMetadata.md +7 -7
  12. data/docs/AppsApi.md +23 -23
  13. data/docs/AwsSettingsControllerApi.md +7 -7
  14. data/docs/BasicAuthMethodDto.md +4 -4
  15. data/docs/BasicOrganizationDto.md +6 -6
  16. data/docs/BillingApi.md +18 -18
  17. data/docs/BillingInfo.md +5 -5
  18. data/docs/CloudWatchSettings.md +6 -6
  19. data/docs/CreateAppInfo.md +7 -7
  20. data/docs/CreateTokenDto.md +7 -0
  21. data/docs/DataSeriesFilter.md +5 -5
  22. data/docs/DataSeriesRequest.md +9 -9
  23. data/docs/Error.md +4 -4
  24. data/docs/FilterValue.md +8 -8
  25. data/docs/GenericApiResponse.md +6 -6
  26. data/docs/Invitation.md +12 -12
  27. data/docs/LogsAppApi.md +6 -6
  28. data/docs/MetricsApi.md +20 -20
  29. data/docs/MonitoringAppApi.md +6 -6
  30. data/docs/NotificationIntegration.md +12 -12
  31. data/docs/Plan.md +15 -15
  32. data/docs/ReportInfo.md +10 -10
  33. data/docs/ResetPasswordApi.md +6 -6
  34. data/docs/SavedQueriesApi.md +19 -19
  35. data/docs/SavedQuery.md +15 -15
  36. data/docs/ServiceIntegration.md +14 -14
  37. data/docs/SubscriptionDashboardDto.md +16 -0
  38. data/docs/SubscriptionDto.md +17 -0
  39. data/docs/SubscriptionsApi.md +468 -32
  40. data/docs/TagApiControllerApi.md +34 -34
  41. data/docs/TokensApiControllerApi.md +285 -0
  42. data/docs/UpdateAppInfo.md +11 -11
  43. data/docs/UpdateSubscriptionDto.md +6 -0
  44. data/docs/UpdateTokenDto.md +6 -0
  45. data/docs/UserInfo.md +3 -3
  46. data/docs/UserPermissions.md +5 -5
  47. data/docs/UserRole.md +5 -5
  48. data/lib/SematextCloud/api/subscriptions_api.rb +463 -17
  49. data/lib/SematextCloud/api/tokens_api_controller_api.rb +313 -0
  50. data/lib/SematextCloud/models/create_token_dto.rb +192 -0
  51. data/lib/SematextCloud/models/subscription_dashboard_dto.rb +319 -0
  52. data/lib/SematextCloud/models/subscription_dto.rb +328 -0
  53. data/lib/SematextCloud/models/update_subscription_dto.rb +183 -0
  54. data/lib/SematextCloud/models/update_token_dto.rb +183 -0
  55. data/lib/SematextCloud/version.rb +1 -1
  56. data/spec/api/tokens_api_controller_api_spec.rb +95 -0
  57. data/spec/models/create_token_dto_spec.rb +47 -0
  58. data/spec/models/subscription_dashboard_dto_spec.rb +109 -0
  59. data/spec/models/subscription_dto_spec.rb +115 -0
  60. data/spec/models/update_subscription_dto_spec.rb +41 -0
  61. data/spec/models/update_token_dto_spec.rb +41 -0
  62. metadata +53 -29
@@ -0,0 +1,319 @@
1
+ =begin
2
+ #Sematext Cloud API
3
+
4
+ #API Explorer provides access and documentation for Sematext REST API. The REST API requires the API Key to be sent as part of `Authorization` header. E.g.: `Authorization : apiKey e5f18450-205a-48eb-8589-7d49edaea813`.
5
+
6
+ OpenAPI spec version: v3
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.12
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module stcloud
16
+ class SubscriptionDashboardDto
17
+ attr_accessor :addresses
18
+
19
+ attr_accessor :dashboard_id
20
+
21
+ attr_accessor :enable
22
+
23
+ attr_accessor :filters
24
+
25
+ attr_accessor :frequency
26
+
27
+ attr_accessor :id
28
+
29
+ attr_accessor :report_name
30
+
31
+ attr_accessor :send_time
32
+
33
+ attr_accessor :subject
34
+
35
+ attr_accessor :text
36
+
37
+ attr_accessor :time_range
38
+
39
+ class EnumAttributeValidator
40
+ attr_reader :datatype
41
+ attr_reader :allowable_values
42
+
43
+ def initialize(datatype, allowable_values)
44
+ @allowable_values = allowable_values.map do |value|
45
+ case datatype.to_s
46
+ when /Integer/i
47
+ value.to_i
48
+ when /Float/i
49
+ value.to_f
50
+ else
51
+ value
52
+ end
53
+ end
54
+ end
55
+
56
+ def valid?(value)
57
+ !value || allowable_values.include?(value)
58
+ end
59
+ end
60
+
61
+ # Attribute mapping from ruby-style variable name to JSON key.
62
+ def self.attribute_map
63
+ {
64
+ :'addresses' => :'addresses',
65
+ :'dashboard_id' => :'dashboardId',
66
+ :'enable' => :'enable',
67
+ :'filters' => :'filters',
68
+ :'frequency' => :'frequency',
69
+ :'id' => :'id',
70
+ :'report_name' => :'reportName',
71
+ :'send_time' => :'sendTime',
72
+ :'subject' => :'subject',
73
+ :'text' => :'text',
74
+ :'time_range' => :'timeRange'
75
+ }
76
+ end
77
+
78
+ # Attribute type mapping.
79
+ def self.swagger_types
80
+ {
81
+ :'addresses' => :'String',
82
+ :'dashboard_id' => :'Integer',
83
+ :'enable' => :'BOOLEAN',
84
+ :'filters' => :'String',
85
+ :'frequency' => :'String',
86
+ :'id' => :'Integer',
87
+ :'report_name' => :'String',
88
+ :'send_time' => :'DateTime',
89
+ :'subject' => :'String',
90
+ :'text' => :'String',
91
+ :'time_range' => :'String'
92
+ }
93
+ end
94
+
95
+ # Initializes the object
96
+ # @param [Hash] attributes Model attributes in the form of hash
97
+ def initialize(attributes = {})
98
+ return unless attributes.is_a?(Hash)
99
+
100
+ # convert string to symbol for hash key
101
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
102
+
103
+ if attributes.has_key?(:'addresses')
104
+ self.addresses = attributes[:'addresses']
105
+ end
106
+
107
+ if attributes.has_key?(:'dashboardId')
108
+ self.dashboard_id = attributes[:'dashboardId']
109
+ end
110
+
111
+ if attributes.has_key?(:'enable')
112
+ self.enable = attributes[:'enable']
113
+ end
114
+
115
+ if attributes.has_key?(:'filters')
116
+ self.filters = attributes[:'filters']
117
+ end
118
+
119
+ if attributes.has_key?(:'frequency')
120
+ self.frequency = attributes[:'frequency']
121
+ end
122
+
123
+ if attributes.has_key?(:'id')
124
+ self.id = attributes[:'id']
125
+ end
126
+
127
+ if attributes.has_key?(:'reportName')
128
+ self.report_name = attributes[:'reportName']
129
+ end
130
+
131
+ if attributes.has_key?(:'sendTime')
132
+ self.send_time = attributes[:'sendTime']
133
+ end
134
+
135
+ if attributes.has_key?(:'subject')
136
+ self.subject = attributes[:'subject']
137
+ end
138
+
139
+ if attributes.has_key?(:'text')
140
+ self.text = attributes[:'text']
141
+ end
142
+
143
+ if attributes.has_key?(:'timeRange')
144
+ self.time_range = attributes[:'timeRange']
145
+ end
146
+ end
147
+
148
+ # Show invalid properties with the reasons. Usually used together with valid?
149
+ # @return Array for valid properties with the reasons
150
+ def list_invalid_properties
151
+ invalid_properties = Array.new
152
+ invalid_properties
153
+ end
154
+
155
+ # Check to see if the all the properties in the model are valid
156
+ # @return true if the model is valid
157
+ def valid?
158
+ frequency_validator = EnumAttributeValidator.new('String', ['EVERY_FIVE_MINUTES', 'DAILY', 'WEEKLY', 'MONTHLY', 'QUARTERLY'])
159
+ return false unless frequency_validator.valid?(@frequency)
160
+ time_range_validator = EnumAttributeValidator.new('String', ['ONE_DAY', 'ONE_WEEK', 'ONE_MONTH', 'TWO_MONTH', 'SIX_MONTH', 'ONE_YEAR'])
161
+ return false unless time_range_validator.valid?(@time_range)
162
+ true
163
+ end
164
+
165
+ # Custom attribute writer method checking allowed values (enum).
166
+ # @param [Object] frequency Object to be assigned
167
+ def frequency=(frequency)
168
+ validator = EnumAttributeValidator.new('String', ['EVERY_FIVE_MINUTES', 'DAILY', 'WEEKLY', 'MONTHLY', 'QUARTERLY'])
169
+ unless validator.valid?(frequency)
170
+ fail ArgumentError, 'invalid value for "frequency", must be one of #{validator.allowable_values}.'
171
+ end
172
+ @frequency = frequency
173
+ end
174
+
175
+ # Custom attribute writer method checking allowed values (enum).
176
+ # @param [Object] time_range Object to be assigned
177
+ def time_range=(time_range)
178
+ validator = EnumAttributeValidator.new('String', ['ONE_DAY', 'ONE_WEEK', 'ONE_MONTH', 'TWO_MONTH', 'SIX_MONTH', 'ONE_YEAR'])
179
+ unless validator.valid?(time_range)
180
+ fail ArgumentError, 'invalid value for "time_range", must be one of #{validator.allowable_values}.'
181
+ end
182
+ @time_range = time_range
183
+ end
184
+
185
+ # Checks equality by comparing each attribute.
186
+ # @param [Object] Object to be compared
187
+ def ==(o)
188
+ return true if self.equal?(o)
189
+ self.class == o.class &&
190
+ addresses == o.addresses &&
191
+ dashboard_id == o.dashboard_id &&
192
+ enable == o.enable &&
193
+ filters == o.filters &&
194
+ frequency == o.frequency &&
195
+ id == o.id &&
196
+ report_name == o.report_name &&
197
+ send_time == o.send_time &&
198
+ subject == o.subject &&
199
+ text == o.text &&
200
+ time_range == o.time_range
201
+ end
202
+
203
+ # @see the `==` method
204
+ # @param [Object] Object to be compared
205
+ def eql?(o)
206
+ self == o
207
+ end
208
+
209
+ # Calculates hash code according to all attributes.
210
+ # @return [Fixnum] Hash code
211
+ def hash
212
+ [addresses, dashboard_id, enable, filters, frequency, id, report_name, send_time, subject, text, time_range].hash
213
+ end
214
+
215
+ # Builds the object from hash
216
+ # @param [Hash] attributes Model attributes in the form of hash
217
+ # @return [Object] Returns the model itself
218
+ def build_from_hash(attributes)
219
+ return nil unless attributes.is_a?(Hash)
220
+ self.class.swagger_types.each_pair do |key, type|
221
+ if type =~ /\AArray<(.*)>/i
222
+ # check to ensure the input is an array given that the the attribute
223
+ # is documented as an array but the input is not
224
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
225
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
226
+ end
227
+ elsif !attributes[self.class.attribute_map[key]].nil?
228
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
229
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
230
+ end
231
+
232
+ self
233
+ end
234
+
235
+ # Deserializes the data based on type
236
+ # @param string type Data type
237
+ # @param string value Value to be deserialized
238
+ # @return [Object] Deserialized data
239
+ def _deserialize(type, value)
240
+ case type.to_sym
241
+ when :DateTime
242
+ DateTime.parse(value)
243
+ when :Date
244
+ Date.parse(value)
245
+ when :String
246
+ value.to_s
247
+ when :Integer
248
+ value.to_i
249
+ when :Float
250
+ value.to_f
251
+ when :BOOLEAN
252
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
253
+ true
254
+ else
255
+ false
256
+ end
257
+ when :Object
258
+ # generic object (usually a Hash), return directly
259
+ value
260
+ when /\AArray<(?<inner_type>.+)>\z/
261
+ inner_type = Regexp.last_match[:inner_type]
262
+ value.map { |v| _deserialize(inner_type, v) }
263
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
264
+ k_type = Regexp.last_match[:k_type]
265
+ v_type = Regexp.last_match[:v_type]
266
+ {}.tap do |hash|
267
+ value.each do |k, v|
268
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
269
+ end
270
+ end
271
+ else # model
272
+ temp_model = stcloud.const_get(type).new
273
+ temp_model.build_from_hash(value)
274
+ end
275
+ end
276
+
277
+ # Returns the string representation of the object
278
+ # @return [String] String presentation of the object
279
+ def to_s
280
+ to_hash.to_s
281
+ end
282
+
283
+ # to_body is an alias to to_hash (backward compatibility)
284
+ # @return [Hash] Returns the object in the form of hash
285
+ def to_body
286
+ to_hash
287
+ end
288
+
289
+ # Returns the object in the form of hash
290
+ # @return [Hash] Returns the object in the form of hash
291
+ def to_hash
292
+ hash = {}
293
+ self.class.attribute_map.each_pair do |attr, param|
294
+ value = self.send(attr)
295
+ next if value.nil?
296
+ hash[param] = _to_hash(value)
297
+ end
298
+ hash
299
+ end
300
+
301
+ # Outputs non-array value in the form of hash
302
+ # For object, use to_hash. Otherwise, just return the value
303
+ # @param [Object] value Any valid value
304
+ # @return [Hash] Returns the value in the form of hash
305
+ def _to_hash(value)
306
+ if value.is_a?(Array)
307
+ value.compact.map { |v| _to_hash(v) }
308
+ elsif value.is_a?(Hash)
309
+ {}.tap do |hash|
310
+ value.each { |k, v| hash[k] = _to_hash(v) }
311
+ end
312
+ elsif value.respond_to? :to_hash
313
+ value.to_hash
314
+ else
315
+ value
316
+ end
317
+ end
318
+ end
319
+ end
@@ -0,0 +1,328 @@
1
+ =begin
2
+ #Sematext Cloud API
3
+
4
+ #API Explorer provides access and documentation for Sematext REST API. The REST API requires the API Key to be sent as part of `Authorization` header. E.g.: `Authorization : apiKey e5f18450-205a-48eb-8589-7d49edaea813`.
5
+
6
+ OpenAPI spec version: v3
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.12
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module stcloud
16
+ class SubscriptionDto
17
+ attr_accessor :addresses
18
+
19
+ attr_accessor :enable
20
+
21
+ attr_accessor :filters
22
+
23
+ attr_accessor :frequency
24
+
25
+ attr_accessor :id
26
+
27
+ attr_accessor :report_name
28
+
29
+ attr_accessor :send_time
30
+
31
+ attr_accessor :subject
32
+
33
+ attr_accessor :system_id
34
+
35
+ attr_accessor :text
36
+
37
+ attr_accessor :time_range
38
+
39
+ attr_accessor :user_permissions
40
+
41
+ class EnumAttributeValidator
42
+ attr_reader :datatype
43
+ attr_reader :allowable_values
44
+
45
+ def initialize(datatype, allowable_values)
46
+ @allowable_values = allowable_values.map do |value|
47
+ case datatype.to_s
48
+ when /Integer/i
49
+ value.to_i
50
+ when /Float/i
51
+ value.to_f
52
+ else
53
+ value
54
+ end
55
+ end
56
+ end
57
+
58
+ def valid?(value)
59
+ !value || allowable_values.include?(value)
60
+ end
61
+ end
62
+
63
+ # Attribute mapping from ruby-style variable name to JSON key.
64
+ def self.attribute_map
65
+ {
66
+ :'addresses' => :'addresses',
67
+ :'enable' => :'enable',
68
+ :'filters' => :'filters',
69
+ :'frequency' => :'frequency',
70
+ :'id' => :'id',
71
+ :'report_name' => :'reportName',
72
+ :'send_time' => :'sendTime',
73
+ :'subject' => :'subject',
74
+ :'system_id' => :'systemId',
75
+ :'text' => :'text',
76
+ :'time_range' => :'timeRange',
77
+ :'user_permissions' => :'userPermissions'
78
+ }
79
+ end
80
+
81
+ # Attribute type mapping.
82
+ def self.swagger_types
83
+ {
84
+ :'addresses' => :'String',
85
+ :'enable' => :'BOOLEAN',
86
+ :'filters' => :'String',
87
+ :'frequency' => :'String',
88
+ :'id' => :'Integer',
89
+ :'report_name' => :'String',
90
+ :'send_time' => :'DateTime',
91
+ :'subject' => :'String',
92
+ :'system_id' => :'Integer',
93
+ :'text' => :'String',
94
+ :'time_range' => :'String',
95
+ :'user_permissions' => :'UserPermissions'
96
+ }
97
+ end
98
+
99
+ # Initializes the object
100
+ # @param [Hash] attributes Model attributes in the form of hash
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
+ if attributes.has_key?(:'addresses')
108
+ self.addresses = attributes[:'addresses']
109
+ end
110
+
111
+ if attributes.has_key?(:'enable')
112
+ self.enable = attributes[:'enable']
113
+ end
114
+
115
+ if attributes.has_key?(:'filters')
116
+ self.filters = attributes[:'filters']
117
+ end
118
+
119
+ if attributes.has_key?(:'frequency')
120
+ self.frequency = attributes[:'frequency']
121
+ end
122
+
123
+ if attributes.has_key?(:'id')
124
+ self.id = attributes[:'id']
125
+ end
126
+
127
+ if attributes.has_key?(:'reportName')
128
+ self.report_name = attributes[:'reportName']
129
+ end
130
+
131
+ if attributes.has_key?(:'sendTime')
132
+ self.send_time = attributes[:'sendTime']
133
+ end
134
+
135
+ if attributes.has_key?(:'subject')
136
+ self.subject = attributes[:'subject']
137
+ end
138
+
139
+ if attributes.has_key?(:'systemId')
140
+ self.system_id = attributes[:'systemId']
141
+ end
142
+
143
+ if attributes.has_key?(:'text')
144
+ self.text = attributes[:'text']
145
+ end
146
+
147
+ if attributes.has_key?(:'timeRange')
148
+ self.time_range = attributes[:'timeRange']
149
+ end
150
+
151
+ if attributes.has_key?(:'userPermissions')
152
+ self.user_permissions = attributes[:'userPermissions']
153
+ end
154
+ end
155
+
156
+ # Show invalid properties with the reasons. Usually used together with valid?
157
+ # @return Array for valid properties with the reasons
158
+ def list_invalid_properties
159
+ invalid_properties = Array.new
160
+ invalid_properties
161
+ end
162
+
163
+ # Check to see if the all the properties in the model are valid
164
+ # @return true if the model is valid
165
+ def valid?
166
+ frequency_validator = EnumAttributeValidator.new('String', ['EVERY_FIVE_MINUTES', 'DAILY', 'WEEKLY', 'MONTHLY', 'QUARTERLY'])
167
+ return false unless frequency_validator.valid?(@frequency)
168
+ time_range_validator = EnumAttributeValidator.new('String', ['ONE_DAY', 'ONE_WEEK', 'ONE_MONTH', 'TWO_MONTH', 'SIX_MONTH', 'ONE_YEAR'])
169
+ return false unless time_range_validator.valid?(@time_range)
170
+ true
171
+ end
172
+
173
+ # Custom attribute writer method checking allowed values (enum).
174
+ # @param [Object] frequency Object to be assigned
175
+ def frequency=(frequency)
176
+ validator = EnumAttributeValidator.new('String', ['EVERY_FIVE_MINUTES', 'DAILY', 'WEEKLY', 'MONTHLY', 'QUARTERLY'])
177
+ unless validator.valid?(frequency)
178
+ fail ArgumentError, 'invalid value for "frequency", must be one of #{validator.allowable_values}.'
179
+ end
180
+ @frequency = frequency
181
+ end
182
+
183
+ # Custom attribute writer method checking allowed values (enum).
184
+ # @param [Object] time_range Object to be assigned
185
+ def time_range=(time_range)
186
+ validator = EnumAttributeValidator.new('String', ['ONE_DAY', 'ONE_WEEK', 'ONE_MONTH', 'TWO_MONTH', 'SIX_MONTH', 'ONE_YEAR'])
187
+ unless validator.valid?(time_range)
188
+ fail ArgumentError, 'invalid value for "time_range", must be one of #{validator.allowable_values}.'
189
+ end
190
+ @time_range = time_range
191
+ end
192
+
193
+ # Checks equality by comparing each attribute.
194
+ # @param [Object] Object to be compared
195
+ def ==(o)
196
+ return true if self.equal?(o)
197
+ self.class == o.class &&
198
+ addresses == o.addresses &&
199
+ enable == o.enable &&
200
+ filters == o.filters &&
201
+ frequency == o.frequency &&
202
+ id == o.id &&
203
+ report_name == o.report_name &&
204
+ send_time == o.send_time &&
205
+ subject == o.subject &&
206
+ system_id == o.system_id &&
207
+ text == o.text &&
208
+ time_range == o.time_range &&
209
+ user_permissions == o.user_permissions
210
+ end
211
+
212
+ # @see the `==` method
213
+ # @param [Object] Object to be compared
214
+ def eql?(o)
215
+ self == o
216
+ end
217
+
218
+ # Calculates hash code according to all attributes.
219
+ # @return [Fixnum] Hash code
220
+ def hash
221
+ [addresses, enable, filters, frequency, id, report_name, send_time, subject, system_id, text, time_range, user_permissions].hash
222
+ end
223
+
224
+ # Builds the object from hash
225
+ # @param [Hash] attributes Model attributes in the form of hash
226
+ # @return [Object] Returns the model itself
227
+ def build_from_hash(attributes)
228
+ return nil unless attributes.is_a?(Hash)
229
+ self.class.swagger_types.each_pair do |key, type|
230
+ if type =~ /\AArray<(.*)>/i
231
+ # check to ensure the input is an array given that the the attribute
232
+ # is documented as an array but the input is not
233
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
234
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
235
+ end
236
+ elsif !attributes[self.class.attribute_map[key]].nil?
237
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
238
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
239
+ end
240
+
241
+ self
242
+ end
243
+
244
+ # Deserializes the data based on type
245
+ # @param string type Data type
246
+ # @param string value Value to be deserialized
247
+ # @return [Object] Deserialized data
248
+ def _deserialize(type, value)
249
+ case type.to_sym
250
+ when :DateTime
251
+ DateTime.parse(value)
252
+ when :Date
253
+ Date.parse(value)
254
+ when :String
255
+ value.to_s
256
+ when :Integer
257
+ value.to_i
258
+ when :Float
259
+ value.to_f
260
+ when :BOOLEAN
261
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
262
+ true
263
+ else
264
+ false
265
+ end
266
+ when :Object
267
+ # generic object (usually a Hash), return directly
268
+ value
269
+ when /\AArray<(?<inner_type>.+)>\z/
270
+ inner_type = Regexp.last_match[:inner_type]
271
+ value.map { |v| _deserialize(inner_type, v) }
272
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
273
+ k_type = Regexp.last_match[:k_type]
274
+ v_type = Regexp.last_match[:v_type]
275
+ {}.tap do |hash|
276
+ value.each do |k, v|
277
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
278
+ end
279
+ end
280
+ else # model
281
+ temp_model = stcloud.const_get(type).new
282
+ temp_model.build_from_hash(value)
283
+ end
284
+ end
285
+
286
+ # Returns the string representation of the object
287
+ # @return [String] String presentation of the object
288
+ def to_s
289
+ to_hash.to_s
290
+ end
291
+
292
+ # to_body is an alias to to_hash (backward compatibility)
293
+ # @return [Hash] Returns the object in the form of hash
294
+ def to_body
295
+ to_hash
296
+ end
297
+
298
+ # Returns the object in the form of hash
299
+ # @return [Hash] Returns the object in the form of hash
300
+ def to_hash
301
+ hash = {}
302
+ self.class.attribute_map.each_pair do |attr, param|
303
+ value = self.send(attr)
304
+ next if value.nil?
305
+ hash[param] = _to_hash(value)
306
+ end
307
+ hash
308
+ end
309
+
310
+ # Outputs non-array value in the form of hash
311
+ # For object, use to_hash. Otherwise, just return the value
312
+ # @param [Object] value Any valid value
313
+ # @return [Hash] Returns the value in the form of hash
314
+ def _to_hash(value)
315
+ if value.is_a?(Array)
316
+ value.compact.map { |v| _to_hash(v) }
317
+ elsif value.is_a?(Hash)
318
+ {}.tap do |hash|
319
+ value.each { |k, v| hash[k] = _to_hash(v) }
320
+ end
321
+ elsif value.respond_to? :to_hash
322
+ value.to_hash
323
+ else
324
+ value
325
+ end
326
+ end
327
+ end
328
+ end