SematextCloud 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/LICENSE +13 -0
- data/README.md +149 -0
- data/Rakefile +8 -0
- data/SematextCloud.gemspec +45 -0
- data/docs/AlertNotificationRequest.md +9 -0
- data/docs/AlertNotificationsApi.md +118 -0
- data/docs/AlertRule.md +53 -0
- data/docs/AlertRuleScheduleTimeRangeDto.md +7 -0
- data/docs/AlertRuleScheduleWeekdayDto.md +10 -0
- data/docs/AlertsApi.md +270 -0
- data/docs/App.md +32 -0
- data/docs/AppDescription.md +6 -0
- data/docs/AppMetadata.md +10 -0
- data/docs/AppsApi.md +369 -0
- data/docs/AwsSettingsControllerApi.md +63 -0
- data/docs/BasicAuthMethodDto.md +7 -0
- data/docs/BasicOrganizationDto.md +9 -0
- data/docs/BillingApi.md +176 -0
- data/docs/BillingInfo.md +8 -0
- data/docs/CloudWatchSettings.md +9 -0
- data/docs/CreateAppInfo.md +10 -0
- data/docs/DataSeriesFilter.md +8 -0
- data/docs/DataSeriesRequest.md +12 -0
- data/docs/Error.md +7 -0
- data/docs/FilterValue.md +11 -0
- data/docs/GenericApiResponse.md +9 -0
- data/docs/Invitation.md +15 -0
- data/docs/LogsAppApi.md +58 -0
- data/docs/MetricsApi.md +227 -0
- data/docs/MonitoringAppApi.md +58 -0
- data/docs/NotificationIntegration.md +15 -0
- data/docs/Plan.md +18 -0
- data/docs/ReportInfo.md +13 -0
- data/docs/ResetPasswordApi.md +58 -0
- data/docs/SavedQueriesApi.md +220 -0
- data/docs/SavedQuery.md +18 -0
- data/docs/ServiceIntegration.md +17 -0
- data/docs/SubscriptionsApi.md +114 -0
- data/docs/TagApiControllerApi.md +212 -0
- data/docs/UpdateAppInfo.md +14 -0
- data/docs/UserInfo.md +6 -0
- data/docs/UserPermissions.md +8 -0
- data/docs/UserRole.md +8 -0
- data/lib/SematextCloud.rb +78 -0
- data/lib/SematextCloud/api/alert_notifications_api.rb +137 -0
- data/lib/SematextCloud/api/alerts_api.rb +283 -0
- data/lib/SematextCloud/api/apps_api.rb +381 -0
- data/lib/SematextCloud/api/aws_settings_controller_api.rb +83 -0
- data/lib/SematextCloud/api/billing_api.rb +197 -0
- data/lib/SematextCloud/api/logs_app_api.rb +75 -0
- data/lib/SematextCloud/api/metrics_api.rb +247 -0
- data/lib/SematextCloud/api/monitoring_app_api.rb +75 -0
- data/lib/SematextCloud/api/reset_password_api.rb +75 -0
- data/lib/SematextCloud/api/saved_queries_api.rb +237 -0
- data/lib/SematextCloud/api/subscriptions_api.rb +133 -0
- data/lib/SematextCloud/api/tag_api_controller_api.rb +247 -0
- data/lib/SematextCloud/api_client.rb +389 -0
- data/lib/SematextCloud/api_error.rb +38 -0
- data/lib/SematextCloud/configuration.rb +209 -0
- data/lib/SematextCloud/models/alert_notification_request.rb +212 -0
- data/lib/SematextCloud/models/alert_rule.rb +652 -0
- data/lib/SematextCloud/models/alert_rule_schedule_time_range_dto.rb +192 -0
- data/lib/SematextCloud/models/alert_rule_schedule_weekday_dto.rb +221 -0
- data/lib/SematextCloud/models/app.rb +419 -0
- data/lib/SematextCloud/models/app_description.rb +183 -0
- data/lib/SematextCloud/models/app_metadata.rb +268 -0
- data/lib/SematextCloud/models/basic_auth_method_dto.rb +226 -0
- data/lib/SematextCloud/models/basic_organization_dto.rb +246 -0
- data/lib/SematextCloud/models/billing_info.rb +201 -0
- data/lib/SematextCloud/models/cloud_watch_settings.rb +256 -0
- data/lib/SematextCloud/models/create_app_info.rb +220 -0
- data/lib/SematextCloud/models/data_series_filter.rb +237 -0
- data/lib/SematextCloud/models/data_series_request.rb +283 -0
- data/lib/SematextCloud/models/error.rb +192 -0
- data/lib/SematextCloud/models/filter_value.rb +230 -0
- data/lib/SematextCloud/models/generic_api_response.rb +214 -0
- data/lib/SematextCloud/models/invitation.rb +326 -0
- data/lib/SematextCloud/models/notification_integration.rb +324 -0
- data/lib/SematextCloud/models/plan.rb +337 -0
- data/lib/SematextCloud/models/report_info.rb +247 -0
- data/lib/SematextCloud/models/saved_query.rb +291 -0
- data/lib/SematextCloud/models/service_integration.rb +282 -0
- data/lib/SematextCloud/models/update_app_info.rb +289 -0
- data/lib/SematextCloud/models/user_info.rb +183 -0
- data/lib/SematextCloud/models/user_permissions.rb +201 -0
- data/lib/SematextCloud/models/user_role.rb +247 -0
- data/lib/SematextCloud/version.rb +15 -0
- data/spec/api/alert_notifications_api_spec.rb +60 -0
- data/spec/api/alerts_api_spec.rb +90 -0
- data/spec/api/apps_api_spec.rb +113 -0
- data/spec/api/aws_settings_controller_api_spec.rb +48 -0
- data/spec/api/billing_api_spec.rb +72 -0
- data/spec/api/logs_app_api_spec.rb +46 -0
- data/spec/api/metrics_api_spec.rb +83 -0
- data/spec/api/monitoring_app_api_spec.rb +46 -0
- data/spec/api/reset_password_api_spec.rb +46 -0
- data/spec/api/saved_queries_api_spec.rb +80 -0
- data/spec/api/subscriptions_api_spec.rb +58 -0
- data/spec/api/tag_api_controller_api_spec.rb +88 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/alert_notification_request_spec.rb +59 -0
- data/spec/models/alert_rule_schedule_time_range_dto_spec.rb +47 -0
- data/spec/models/alert_rule_schedule_weekday_dto_spec.rb +65 -0
- data/spec/models/alert_rule_spec.rb +327 -0
- data/spec/models/app_description_spec.rb +41 -0
- data/spec/models/app_metadata_spec.rb +77 -0
- data/spec/models/app_spec.rb +197 -0
- data/spec/models/basic_auth_method_dto_spec.rb +51 -0
- data/spec/models/basic_organization_dto_spec.rb +63 -0
- data/spec/models/billing_info_spec.rb +53 -0
- data/spec/models/cloud_watch_settings_spec.rb +67 -0
- data/spec/models/create_app_info_spec.rb +65 -0
- data/spec/models/data_series_filter_spec.rb +57 -0
- data/spec/models/data_series_request_spec.rb +81 -0
- data/spec/models/error_spec.rb +47 -0
- data/spec/models/filter_value_spec.rb +71 -0
- data/spec/models/generic_api_response_spec.rb +59 -0
- data/spec/models/invitation_spec.rb +107 -0
- data/spec/models/notification_integration_spec.rb +107 -0
- data/spec/models/plan_spec.rb +121 -0
- data/spec/models/report_info_spec.rb +83 -0
- data/spec/models/saved_query_spec.rb +113 -0
- data/spec/models/service_integration_spec.rb +107 -0
- data/spec/models/update_app_info_spec.rb +93 -0
- data/spec/models/user_info_spec.rb +41 -0
- data/spec/models/user_permissions_spec.rb +53 -0
- data/spec/models/user_role_spec.rb +61 -0
- data/spec/spec_helper.rb +111 -0
- metadata +395 -0
@@ -0,0 +1,226 @@
|
|
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 SematextCloud
|
16
|
+
class BasicAuthMethodDto
|
17
|
+
attr_accessor :auth_type
|
18
|
+
|
19
|
+
attr_accessor :uuid
|
20
|
+
|
21
|
+
class EnumAttributeValidator
|
22
|
+
attr_reader :datatype
|
23
|
+
attr_reader :allowable_values
|
24
|
+
|
25
|
+
def initialize(datatype, allowable_values)
|
26
|
+
@allowable_values = allowable_values.map do |value|
|
27
|
+
case datatype.to_s
|
28
|
+
when /Integer/i
|
29
|
+
value.to_i
|
30
|
+
when /Float/i
|
31
|
+
value.to_f
|
32
|
+
else
|
33
|
+
value
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def valid?(value)
|
39
|
+
!value || allowable_values.include?(value)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
44
|
+
def self.attribute_map
|
45
|
+
{
|
46
|
+
:'auth_type' => :'authType',
|
47
|
+
:'uuid' => :'uuid'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
# Attribute type mapping.
|
52
|
+
def self.swagger_types
|
53
|
+
{
|
54
|
+
:'auth_type' => :'String',
|
55
|
+
:'uuid' => :'String'
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
# Initializes the object
|
60
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
61
|
+
def initialize(attributes = {})
|
62
|
+
return unless attributes.is_a?(Hash)
|
63
|
+
|
64
|
+
# convert string to symbol for hash key
|
65
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
66
|
+
|
67
|
+
if attributes.has_key?(:'authType')
|
68
|
+
self.auth_type = attributes[:'authType']
|
69
|
+
end
|
70
|
+
|
71
|
+
if attributes.has_key?(:'uuid')
|
72
|
+
self.uuid = attributes[:'uuid']
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
77
|
+
# @return Array for valid properties with the reasons
|
78
|
+
def list_invalid_properties
|
79
|
+
invalid_properties = Array.new
|
80
|
+
invalid_properties
|
81
|
+
end
|
82
|
+
|
83
|
+
# Check to see if the all the properties in the model are valid
|
84
|
+
# @return true if the model is valid
|
85
|
+
def valid?
|
86
|
+
auth_type_validator = EnumAttributeValidator.new('String', ['SEMATEXT_ACCOUNT', 'LDAP'])
|
87
|
+
return false unless auth_type_validator.valid?(@auth_type)
|
88
|
+
true
|
89
|
+
end
|
90
|
+
|
91
|
+
# Custom attribute writer method checking allowed values (enum).
|
92
|
+
# @param [Object] auth_type Object to be assigned
|
93
|
+
def auth_type=(auth_type)
|
94
|
+
validator = EnumAttributeValidator.new('String', ['SEMATEXT_ACCOUNT', 'LDAP'])
|
95
|
+
unless validator.valid?(auth_type)
|
96
|
+
fail ArgumentError, 'invalid value for "auth_type", must be one of #{validator.allowable_values}.'
|
97
|
+
end
|
98
|
+
@auth_type = auth_type
|
99
|
+
end
|
100
|
+
|
101
|
+
# Checks equality by comparing each attribute.
|
102
|
+
# @param [Object] Object to be compared
|
103
|
+
def ==(o)
|
104
|
+
return true if self.equal?(o)
|
105
|
+
self.class == o.class &&
|
106
|
+
auth_type == o.auth_type &&
|
107
|
+
uuid == o.uuid
|
108
|
+
end
|
109
|
+
|
110
|
+
# @see the `==` method
|
111
|
+
# @param [Object] Object to be compared
|
112
|
+
def eql?(o)
|
113
|
+
self == o
|
114
|
+
end
|
115
|
+
|
116
|
+
# Calculates hash code according to all attributes.
|
117
|
+
# @return [Fixnum] Hash code
|
118
|
+
def hash
|
119
|
+
[auth_type, uuid].hash
|
120
|
+
end
|
121
|
+
|
122
|
+
# Builds the object from hash
|
123
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
124
|
+
# @return [Object] Returns the model itself
|
125
|
+
def build_from_hash(attributes)
|
126
|
+
return nil unless attributes.is_a?(Hash)
|
127
|
+
self.class.swagger_types.each_pair do |key, type|
|
128
|
+
if type =~ /\AArray<(.*)>/i
|
129
|
+
# check to ensure the input is an array given that the the attribute
|
130
|
+
# is documented as an array but the input is not
|
131
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
132
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
133
|
+
end
|
134
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
135
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
136
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
137
|
+
end
|
138
|
+
|
139
|
+
self
|
140
|
+
end
|
141
|
+
|
142
|
+
# Deserializes the data based on type
|
143
|
+
# @param string type Data type
|
144
|
+
# @param string value Value to be deserialized
|
145
|
+
# @return [Object] Deserialized data
|
146
|
+
def _deserialize(type, value)
|
147
|
+
case type.to_sym
|
148
|
+
when :DateTime
|
149
|
+
DateTime.parse(value)
|
150
|
+
when :Date
|
151
|
+
Date.parse(value)
|
152
|
+
when :String
|
153
|
+
value.to_s
|
154
|
+
when :Integer
|
155
|
+
value.to_i
|
156
|
+
when :Float
|
157
|
+
value.to_f
|
158
|
+
when :BOOLEAN
|
159
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
160
|
+
true
|
161
|
+
else
|
162
|
+
false
|
163
|
+
end
|
164
|
+
when :Object
|
165
|
+
# generic object (usually a Hash), return directly
|
166
|
+
value
|
167
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
168
|
+
inner_type = Regexp.last_match[:inner_type]
|
169
|
+
value.map { |v| _deserialize(inner_type, v) }
|
170
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
171
|
+
k_type = Regexp.last_match[:k_type]
|
172
|
+
v_type = Regexp.last_match[:v_type]
|
173
|
+
{}.tap do |hash|
|
174
|
+
value.each do |k, v|
|
175
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
else # model
|
179
|
+
temp_model = SematextCloud.const_get(type).new
|
180
|
+
temp_model.build_from_hash(value)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
# Returns the string representation of the object
|
185
|
+
# @return [String] String presentation of the object
|
186
|
+
def to_s
|
187
|
+
to_hash.to_s
|
188
|
+
end
|
189
|
+
|
190
|
+
# to_body is an alias to to_hash (backward compatibility)
|
191
|
+
# @return [Hash] Returns the object in the form of hash
|
192
|
+
def to_body
|
193
|
+
to_hash
|
194
|
+
end
|
195
|
+
|
196
|
+
# Returns the object in the form of hash
|
197
|
+
# @return [Hash] Returns the object in the form of hash
|
198
|
+
def to_hash
|
199
|
+
hash = {}
|
200
|
+
self.class.attribute_map.each_pair do |attr, param|
|
201
|
+
value = self.send(attr)
|
202
|
+
next if value.nil?
|
203
|
+
hash[param] = _to_hash(value)
|
204
|
+
end
|
205
|
+
hash
|
206
|
+
end
|
207
|
+
|
208
|
+
# Outputs non-array value in the form of hash
|
209
|
+
# For object, use to_hash. Otherwise, just return the value
|
210
|
+
# @param [Object] value Any valid value
|
211
|
+
# @return [Hash] Returns the value in the form of hash
|
212
|
+
def _to_hash(value)
|
213
|
+
if value.is_a?(Array)
|
214
|
+
value.compact.map { |v| _to_hash(v) }
|
215
|
+
elsif value.is_a?(Hash)
|
216
|
+
{}.tap do |hash|
|
217
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
218
|
+
end
|
219
|
+
elsif value.respond_to? :to_hash
|
220
|
+
value.to_hash
|
221
|
+
else
|
222
|
+
value
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
@@ -0,0 +1,246 @@
|
|
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 SematextCloud
|
16
|
+
class BasicOrganizationDto
|
17
|
+
attr_accessor :auth_methods
|
18
|
+
|
19
|
+
attr_accessor :name
|
20
|
+
|
21
|
+
attr_accessor :status
|
22
|
+
|
23
|
+
attr_accessor :uuid
|
24
|
+
|
25
|
+
class EnumAttributeValidator
|
26
|
+
attr_reader :datatype
|
27
|
+
attr_reader :allowable_values
|
28
|
+
|
29
|
+
def initialize(datatype, allowable_values)
|
30
|
+
@allowable_values = allowable_values.map do |value|
|
31
|
+
case datatype.to_s
|
32
|
+
when /Integer/i
|
33
|
+
value.to_i
|
34
|
+
when /Float/i
|
35
|
+
value.to_f
|
36
|
+
else
|
37
|
+
value
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def valid?(value)
|
43
|
+
!value || allowable_values.include?(value)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
48
|
+
def self.attribute_map
|
49
|
+
{
|
50
|
+
:'auth_methods' => :'authMethods',
|
51
|
+
:'name' => :'name',
|
52
|
+
:'status' => :'status',
|
53
|
+
:'uuid' => :'uuid'
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
# Attribute type mapping.
|
58
|
+
def self.swagger_types
|
59
|
+
{
|
60
|
+
:'auth_methods' => :'Array<BasicAuthMethodDto>',
|
61
|
+
:'name' => :'String',
|
62
|
+
:'status' => :'String',
|
63
|
+
:'uuid' => :'String'
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
# Initializes the object
|
68
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
69
|
+
def initialize(attributes = {})
|
70
|
+
return unless attributes.is_a?(Hash)
|
71
|
+
|
72
|
+
# convert string to symbol for hash key
|
73
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
74
|
+
|
75
|
+
if attributes.has_key?(:'authMethods')
|
76
|
+
if (value = attributes[:'authMethods']).is_a?(Array)
|
77
|
+
self.auth_methods = value
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
if attributes.has_key?(:'name')
|
82
|
+
self.name = attributes[:'name']
|
83
|
+
end
|
84
|
+
|
85
|
+
if attributes.has_key?(:'status')
|
86
|
+
self.status = attributes[:'status']
|
87
|
+
end
|
88
|
+
|
89
|
+
if attributes.has_key?(:'uuid')
|
90
|
+
self.uuid = attributes[:'uuid']
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
95
|
+
# @return Array for valid properties with the reasons
|
96
|
+
def list_invalid_properties
|
97
|
+
invalid_properties = Array.new
|
98
|
+
invalid_properties
|
99
|
+
end
|
100
|
+
|
101
|
+
# Check to see if the all the properties in the model are valid
|
102
|
+
# @return true if the model is valid
|
103
|
+
def valid?
|
104
|
+
status_validator = EnumAttributeValidator.new('String', ['ACTIVE', 'IN_REGISTRATION', 'DISABLED', 'EXPIRED', 'INVITED', 'DEMO'])
|
105
|
+
return false unless status_validator.valid?(@status)
|
106
|
+
true
|
107
|
+
end
|
108
|
+
|
109
|
+
# Custom attribute writer method checking allowed values (enum).
|
110
|
+
# @param [Object] status Object to be assigned
|
111
|
+
def status=(status)
|
112
|
+
validator = EnumAttributeValidator.new('String', ['ACTIVE', 'IN_REGISTRATION', 'DISABLED', 'EXPIRED', 'INVITED', 'DEMO'])
|
113
|
+
unless validator.valid?(status)
|
114
|
+
fail ArgumentError, 'invalid value for "status", must be one of #{validator.allowable_values}.'
|
115
|
+
end
|
116
|
+
@status = status
|
117
|
+
end
|
118
|
+
|
119
|
+
# Checks equality by comparing each attribute.
|
120
|
+
# @param [Object] Object to be compared
|
121
|
+
def ==(o)
|
122
|
+
return true if self.equal?(o)
|
123
|
+
self.class == o.class &&
|
124
|
+
auth_methods == o.auth_methods &&
|
125
|
+
name == o.name &&
|
126
|
+
status == o.status &&
|
127
|
+
uuid == o.uuid
|
128
|
+
end
|
129
|
+
|
130
|
+
# @see the `==` method
|
131
|
+
# @param [Object] Object to be compared
|
132
|
+
def eql?(o)
|
133
|
+
self == o
|
134
|
+
end
|
135
|
+
|
136
|
+
# Calculates hash code according to all attributes.
|
137
|
+
# @return [Fixnum] Hash code
|
138
|
+
def hash
|
139
|
+
[auth_methods, name, status, uuid].hash
|
140
|
+
end
|
141
|
+
|
142
|
+
# Builds the object from hash
|
143
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
144
|
+
# @return [Object] Returns the model itself
|
145
|
+
def build_from_hash(attributes)
|
146
|
+
return nil unless attributes.is_a?(Hash)
|
147
|
+
self.class.swagger_types.each_pair do |key, type|
|
148
|
+
if type =~ /\AArray<(.*)>/i
|
149
|
+
# check to ensure the input is an array given that the the attribute
|
150
|
+
# is documented as an array but the input is not
|
151
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
152
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
153
|
+
end
|
154
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
155
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
156
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
157
|
+
end
|
158
|
+
|
159
|
+
self
|
160
|
+
end
|
161
|
+
|
162
|
+
# Deserializes the data based on type
|
163
|
+
# @param string type Data type
|
164
|
+
# @param string value Value to be deserialized
|
165
|
+
# @return [Object] Deserialized data
|
166
|
+
def _deserialize(type, value)
|
167
|
+
case type.to_sym
|
168
|
+
when :DateTime
|
169
|
+
DateTime.parse(value)
|
170
|
+
when :Date
|
171
|
+
Date.parse(value)
|
172
|
+
when :String
|
173
|
+
value.to_s
|
174
|
+
when :Integer
|
175
|
+
value.to_i
|
176
|
+
when :Float
|
177
|
+
value.to_f
|
178
|
+
when :BOOLEAN
|
179
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
180
|
+
true
|
181
|
+
else
|
182
|
+
false
|
183
|
+
end
|
184
|
+
when :Object
|
185
|
+
# generic object (usually a Hash), return directly
|
186
|
+
value
|
187
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
188
|
+
inner_type = Regexp.last_match[:inner_type]
|
189
|
+
value.map { |v| _deserialize(inner_type, v) }
|
190
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
191
|
+
k_type = Regexp.last_match[:k_type]
|
192
|
+
v_type = Regexp.last_match[:v_type]
|
193
|
+
{}.tap do |hash|
|
194
|
+
value.each do |k, v|
|
195
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
else # model
|
199
|
+
temp_model = SematextCloud.const_get(type).new
|
200
|
+
temp_model.build_from_hash(value)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
# Returns the string representation of the object
|
205
|
+
# @return [String] String presentation of the object
|
206
|
+
def to_s
|
207
|
+
to_hash.to_s
|
208
|
+
end
|
209
|
+
|
210
|
+
# to_body is an alias to to_hash (backward compatibility)
|
211
|
+
# @return [Hash] Returns the object in the form of hash
|
212
|
+
def to_body
|
213
|
+
to_hash
|
214
|
+
end
|
215
|
+
|
216
|
+
# Returns the object in the form of hash
|
217
|
+
# @return [Hash] Returns the object in the form of hash
|
218
|
+
def to_hash
|
219
|
+
hash = {}
|
220
|
+
self.class.attribute_map.each_pair do |attr, param|
|
221
|
+
value = self.send(attr)
|
222
|
+
next if value.nil?
|
223
|
+
hash[param] = _to_hash(value)
|
224
|
+
end
|
225
|
+
hash
|
226
|
+
end
|
227
|
+
|
228
|
+
# Outputs non-array value in the form of hash
|
229
|
+
# For object, use to_hash. Otherwise, just return the value
|
230
|
+
# @param [Object] value Any valid value
|
231
|
+
# @return [Hash] Returns the value in the form of hash
|
232
|
+
def _to_hash(value)
|
233
|
+
if value.is_a?(Array)
|
234
|
+
value.compact.map { |v| _to_hash(v) }
|
235
|
+
elsif value.is_a?(Hash)
|
236
|
+
{}.tap do |hash|
|
237
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
238
|
+
end
|
239
|
+
elsif value.respond_to? :to_hash
|
240
|
+
value.to_hash
|
241
|
+
else
|
242
|
+
value
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|