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.
- checksums.yaml +4 -4
- data/README.md +87 -65
- data/docs/AlertNotificationRequest.md +6 -6
- data/docs/AlertNotificationsApi.md +11 -11
- data/docs/AlertRule.md +50 -50
- data/docs/AlertRuleScheduleTimeRangeDto.md +4 -4
- data/docs/AlertRuleScheduleWeekdayDto.md +7 -7
- data/docs/AlertsApi.md +22 -22
- data/docs/App.md +33 -29
- data/docs/AppDescription.md +3 -3
- data/docs/AppMetadata.md +7 -7
- data/docs/AppsApi.md +23 -23
- data/docs/AwsSettingsControllerApi.md +7 -7
- data/docs/BasicAuthMethodDto.md +4 -4
- data/docs/BasicOrganizationDto.md +6 -6
- data/docs/BillingApi.md +18 -18
- data/docs/BillingInfo.md +5 -5
- data/docs/CloudWatchSettings.md +6 -6
- data/docs/CreateAppInfo.md +7 -7
- data/docs/CreateTokenDto.md +7 -0
- data/docs/DataSeriesFilter.md +5 -5
- data/docs/DataSeriesRequest.md +9 -9
- data/docs/Error.md +4 -4
- data/docs/FilterValue.md +8 -8
- data/docs/GenericApiResponse.md +6 -6
- data/docs/Invitation.md +12 -12
- data/docs/LogsAppApi.md +6 -6
- data/docs/MetricsApi.md +20 -20
- data/docs/MonitoringAppApi.md +6 -6
- data/docs/NotificationIntegration.md +12 -12
- data/docs/Plan.md +15 -15
- data/docs/ReportInfo.md +10 -10
- data/docs/ResetPasswordApi.md +6 -6
- data/docs/SavedQueriesApi.md +19 -19
- data/docs/SavedQuery.md +15 -15
- data/docs/ServiceIntegration.md +14 -14
- data/docs/SubscriptionDashboardDto.md +16 -0
- data/docs/SubscriptionDto.md +17 -0
- data/docs/SubscriptionsApi.md +468 -32
- data/docs/TagApiControllerApi.md +34 -34
- data/docs/TokensApiControllerApi.md +285 -0
- data/docs/UpdateAppInfo.md +11 -11
- data/docs/UpdateSubscriptionDto.md +6 -0
- data/docs/UpdateTokenDto.md +6 -0
- data/docs/UserInfo.md +3 -3
- data/docs/UserPermissions.md +5 -5
- data/docs/UserRole.md +5 -5
- data/lib/SematextCloud/api/subscriptions_api.rb +463 -17
- data/lib/SematextCloud/api/tokens_api_controller_api.rb +313 -0
- data/lib/SematextCloud/models/create_token_dto.rb +192 -0
- data/lib/SematextCloud/models/subscription_dashboard_dto.rb +319 -0
- data/lib/SematextCloud/models/subscription_dto.rb +328 -0
- data/lib/SematextCloud/models/update_subscription_dto.rb +183 -0
- data/lib/SematextCloud/models/update_token_dto.rb +183 -0
- data/lib/SematextCloud/version.rb +1 -1
- data/spec/api/tokens_api_controller_api_spec.rb +95 -0
- data/spec/models/create_token_dto_spec.rb +47 -0
- data/spec/models/subscription_dashboard_dto_spec.rb +109 -0
- data/spec/models/subscription_dto_spec.rb +115 -0
- data/spec/models/update_subscription_dto_spec.rb +41 -0
- data/spec/models/update_token_dto_spec.rb +41 -0
- metadata +53 -29
@@ -0,0 +1,313 @@
|
|
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 'uri'
|
14
|
+
|
15
|
+
module stcloud
|
16
|
+
class TokensApiControllerApi
|
17
|
+
attr_accessor :api_client
|
18
|
+
|
19
|
+
def initialize(api_client = ApiClient.default)
|
20
|
+
@api_client = api_client
|
21
|
+
end
|
22
|
+
# Create new app token
|
23
|
+
# @param app_id appId
|
24
|
+
# @param dto dto
|
25
|
+
# @param [Hash] opts the optional parameters
|
26
|
+
# @return [GenericApiResponse]
|
27
|
+
def create_app_token(app_id, dto, opts = {})
|
28
|
+
data, _status_code, _headers = create_app_token_with_http_info(app_id, dto, opts)
|
29
|
+
data
|
30
|
+
end
|
31
|
+
|
32
|
+
# Create new app token
|
33
|
+
# @param app_id appId
|
34
|
+
# @param dto dto
|
35
|
+
# @param [Hash] opts the optional parameters
|
36
|
+
# @return [Array<(GenericApiResponse, Fixnum, Hash)>] GenericApiResponse data, response status code and response headers
|
37
|
+
def create_app_token_with_http_info(app_id, dto, opts = {})
|
38
|
+
if @api_client.config.debugging
|
39
|
+
@api_client.config.logger.debug 'Calling API: TokensApiControllerApi.create_app_token ...'
|
40
|
+
end
|
41
|
+
# verify the required parameter 'app_id' is set
|
42
|
+
if @api_client.config.client_side_validation && app_id.nil?
|
43
|
+
fail ArgumentError, "Missing the required parameter 'app_id' when calling TokensApiControllerApi.create_app_token"
|
44
|
+
end
|
45
|
+
# verify the required parameter 'dto' is set
|
46
|
+
if @api_client.config.client_side_validation && dto.nil?
|
47
|
+
fail ArgumentError, "Missing the required parameter 'dto' when calling TokensApiControllerApi.create_app_token"
|
48
|
+
end
|
49
|
+
# resource path
|
50
|
+
local_var_path = '/users-web/api/v3/apps/{appId}/tokens'.sub('{' + 'appId' + '}', app_id.to_s)
|
51
|
+
|
52
|
+
# query parameters
|
53
|
+
query_params = {}
|
54
|
+
|
55
|
+
# header parameters
|
56
|
+
header_params = {}
|
57
|
+
# HTTP header 'Accept' (if needed)
|
58
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
59
|
+
# HTTP header 'Content-Type'
|
60
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
61
|
+
|
62
|
+
# form parameters
|
63
|
+
form_params = {}
|
64
|
+
|
65
|
+
# http body (model)
|
66
|
+
post_body = @api_client.object_to_http_body(dto)
|
67
|
+
auth_names = ['api_key']
|
68
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
69
|
+
:header_params => header_params,
|
70
|
+
:query_params => query_params,
|
71
|
+
:form_params => form_params,
|
72
|
+
:body => post_body,
|
73
|
+
:auth_names => auth_names,
|
74
|
+
:return_type => 'GenericApiResponse')
|
75
|
+
if @api_client.config.debugging
|
76
|
+
@api_client.config.logger.debug "API called: TokensApiControllerApi#create_app_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
77
|
+
end
|
78
|
+
return data, status_code, headers
|
79
|
+
end
|
80
|
+
# Delete app token
|
81
|
+
# @param app_id appId
|
82
|
+
# @param token_id tokenId
|
83
|
+
# @param [Hash] opts the optional parameters
|
84
|
+
# @return [GenericApiResponse]
|
85
|
+
def delete_app_token1(app_id, token_id, opts = {})
|
86
|
+
data, _status_code, _headers = delete_app_token1_with_http_info(app_id, token_id, opts)
|
87
|
+
data
|
88
|
+
end
|
89
|
+
|
90
|
+
# Delete app token
|
91
|
+
# @param app_id appId
|
92
|
+
# @param token_id tokenId
|
93
|
+
# @param [Hash] opts the optional parameters
|
94
|
+
# @return [Array<(GenericApiResponse, Fixnum, Hash)>] GenericApiResponse data, response status code and response headers
|
95
|
+
def delete_app_token1_with_http_info(app_id, token_id, opts = {})
|
96
|
+
if @api_client.config.debugging
|
97
|
+
@api_client.config.logger.debug 'Calling API: TokensApiControllerApi.delete_app_token1 ...'
|
98
|
+
end
|
99
|
+
# verify the required parameter 'app_id' is set
|
100
|
+
if @api_client.config.client_side_validation && app_id.nil?
|
101
|
+
fail ArgumentError, "Missing the required parameter 'app_id' when calling TokensApiControllerApi.delete_app_token1"
|
102
|
+
end
|
103
|
+
# verify the required parameter 'token_id' is set
|
104
|
+
if @api_client.config.client_side_validation && token_id.nil?
|
105
|
+
fail ArgumentError, "Missing the required parameter 'token_id' when calling TokensApiControllerApi.delete_app_token1"
|
106
|
+
end
|
107
|
+
# resource path
|
108
|
+
local_var_path = '/users-web/api/v3/apps/{appId}/tokens/{tokenId}'.sub('{' + 'appId' + '}', app_id.to_s).sub('{' + 'tokenId' + '}', token_id.to_s)
|
109
|
+
|
110
|
+
# query parameters
|
111
|
+
query_params = {}
|
112
|
+
|
113
|
+
# header parameters
|
114
|
+
header_params = {}
|
115
|
+
# HTTP header 'Accept' (if needed)
|
116
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
117
|
+
# HTTP header 'Content-Type'
|
118
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
119
|
+
|
120
|
+
# form parameters
|
121
|
+
form_params = {}
|
122
|
+
|
123
|
+
# http body (model)
|
124
|
+
post_body = nil
|
125
|
+
auth_names = ['api_key']
|
126
|
+
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
|
127
|
+
:header_params => header_params,
|
128
|
+
:query_params => query_params,
|
129
|
+
:form_params => form_params,
|
130
|
+
:body => post_body,
|
131
|
+
:auth_names => auth_names,
|
132
|
+
:return_type => 'GenericApiResponse')
|
133
|
+
if @api_client.config.debugging
|
134
|
+
@api_client.config.logger.debug "API called: TokensApiControllerApi#delete_app_token1\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
135
|
+
end
|
136
|
+
return data, status_code, headers
|
137
|
+
end
|
138
|
+
# Get app available tokens
|
139
|
+
# @param app_id appId
|
140
|
+
# @param [Hash] opts the optional parameters
|
141
|
+
# @return [GenericApiResponse]
|
142
|
+
def get_app_tokens1(app_id, opts = {})
|
143
|
+
data, _status_code, _headers = get_app_tokens1_with_http_info(app_id, opts)
|
144
|
+
data
|
145
|
+
end
|
146
|
+
|
147
|
+
# Get app available tokens
|
148
|
+
# @param app_id appId
|
149
|
+
# @param [Hash] opts the optional parameters
|
150
|
+
# @return [Array<(GenericApiResponse, Fixnum, Hash)>] GenericApiResponse data, response status code and response headers
|
151
|
+
def get_app_tokens1_with_http_info(app_id, opts = {})
|
152
|
+
if @api_client.config.debugging
|
153
|
+
@api_client.config.logger.debug 'Calling API: TokensApiControllerApi.get_app_tokens1 ...'
|
154
|
+
end
|
155
|
+
# verify the required parameter 'app_id' is set
|
156
|
+
if @api_client.config.client_side_validation && app_id.nil?
|
157
|
+
fail ArgumentError, "Missing the required parameter 'app_id' when calling TokensApiControllerApi.get_app_tokens1"
|
158
|
+
end
|
159
|
+
# resource path
|
160
|
+
local_var_path = '/users-web/api/v3/apps/{appId}/tokens'.sub('{' + 'appId' + '}', app_id.to_s)
|
161
|
+
|
162
|
+
# query parameters
|
163
|
+
query_params = {}
|
164
|
+
|
165
|
+
# header parameters
|
166
|
+
header_params = {}
|
167
|
+
# HTTP header 'Accept' (if needed)
|
168
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
169
|
+
# HTTP header 'Content-Type'
|
170
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
171
|
+
|
172
|
+
# form parameters
|
173
|
+
form_params = {}
|
174
|
+
|
175
|
+
# http body (model)
|
176
|
+
post_body = nil
|
177
|
+
auth_names = ['api_key']
|
178
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
|
179
|
+
:header_params => header_params,
|
180
|
+
:query_params => query_params,
|
181
|
+
:form_params => form_params,
|
182
|
+
:body => post_body,
|
183
|
+
:auth_names => auth_names,
|
184
|
+
:return_type => 'GenericApiResponse')
|
185
|
+
if @api_client.config.debugging
|
186
|
+
@api_client.config.logger.debug "API called: TokensApiControllerApi#get_app_tokens1\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
187
|
+
end
|
188
|
+
return data, status_code, headers
|
189
|
+
end
|
190
|
+
# Regenerate app token)
|
191
|
+
# @param app_id appId
|
192
|
+
# @param token_id tokenId
|
193
|
+
# @param [Hash] opts the optional parameters
|
194
|
+
# @return [GenericApiResponse]
|
195
|
+
def regenerate_app_token(app_id, token_id, opts = {})
|
196
|
+
data, _status_code, _headers = regenerate_app_token_with_http_info(app_id, token_id, opts)
|
197
|
+
data
|
198
|
+
end
|
199
|
+
|
200
|
+
# Regenerate app token)
|
201
|
+
# @param app_id appId
|
202
|
+
# @param token_id tokenId
|
203
|
+
# @param [Hash] opts the optional parameters
|
204
|
+
# @return [Array<(GenericApiResponse, Fixnum, Hash)>] GenericApiResponse data, response status code and response headers
|
205
|
+
def regenerate_app_token_with_http_info(app_id, token_id, opts = {})
|
206
|
+
if @api_client.config.debugging
|
207
|
+
@api_client.config.logger.debug 'Calling API: TokensApiControllerApi.regenerate_app_token ...'
|
208
|
+
end
|
209
|
+
# verify the required parameter 'app_id' is set
|
210
|
+
if @api_client.config.client_side_validation && app_id.nil?
|
211
|
+
fail ArgumentError, "Missing the required parameter 'app_id' when calling TokensApiControllerApi.regenerate_app_token"
|
212
|
+
end
|
213
|
+
# verify the required parameter 'token_id' is set
|
214
|
+
if @api_client.config.client_side_validation && token_id.nil?
|
215
|
+
fail ArgumentError, "Missing the required parameter 'token_id' when calling TokensApiControllerApi.regenerate_app_token"
|
216
|
+
end
|
217
|
+
# resource path
|
218
|
+
local_var_path = '/users-web/api/v3/apps/{appId}/tokens/{tokenId}/regenerate'.sub('{' + 'appId' + '}', app_id.to_s).sub('{' + 'tokenId' + '}', token_id.to_s)
|
219
|
+
|
220
|
+
# query parameters
|
221
|
+
query_params = {}
|
222
|
+
|
223
|
+
# header parameters
|
224
|
+
header_params = {}
|
225
|
+
# HTTP header 'Accept' (if needed)
|
226
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
227
|
+
# HTTP header 'Content-Type'
|
228
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
229
|
+
|
230
|
+
# form parameters
|
231
|
+
form_params = {}
|
232
|
+
|
233
|
+
# http body (model)
|
234
|
+
post_body = nil
|
235
|
+
auth_names = ['api_key']
|
236
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
237
|
+
:header_params => header_params,
|
238
|
+
:query_params => query_params,
|
239
|
+
:form_params => form_params,
|
240
|
+
:body => post_body,
|
241
|
+
:auth_names => auth_names,
|
242
|
+
:return_type => 'GenericApiResponse')
|
243
|
+
if @api_client.config.debugging
|
244
|
+
@api_client.config.logger.debug "API called: TokensApiControllerApi#regenerate_app_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
245
|
+
end
|
246
|
+
return data, status_code, headers
|
247
|
+
end
|
248
|
+
# Update app token (enable/disable)
|
249
|
+
# @param app_id appId
|
250
|
+
# @param token_id tokenId
|
251
|
+
# @param dto dto
|
252
|
+
# @param [Hash] opts the optional parameters
|
253
|
+
# @return [GenericApiResponse]
|
254
|
+
def update_app_token1(app_id, token_id, dto, opts = {})
|
255
|
+
data, _status_code, _headers = update_app_token1_with_http_info(app_id, token_id, dto, opts)
|
256
|
+
data
|
257
|
+
end
|
258
|
+
|
259
|
+
# Update app token (enable/disable)
|
260
|
+
# @param app_id appId
|
261
|
+
# @param token_id tokenId
|
262
|
+
# @param dto dto
|
263
|
+
# @param [Hash] opts the optional parameters
|
264
|
+
# @return [Array<(GenericApiResponse, Fixnum, Hash)>] GenericApiResponse data, response status code and response headers
|
265
|
+
def update_app_token1_with_http_info(app_id, token_id, dto, opts = {})
|
266
|
+
if @api_client.config.debugging
|
267
|
+
@api_client.config.logger.debug 'Calling API: TokensApiControllerApi.update_app_token1 ...'
|
268
|
+
end
|
269
|
+
# verify the required parameter 'app_id' is set
|
270
|
+
if @api_client.config.client_side_validation && app_id.nil?
|
271
|
+
fail ArgumentError, "Missing the required parameter 'app_id' when calling TokensApiControllerApi.update_app_token1"
|
272
|
+
end
|
273
|
+
# verify the required parameter 'token_id' is set
|
274
|
+
if @api_client.config.client_side_validation && token_id.nil?
|
275
|
+
fail ArgumentError, "Missing the required parameter 'token_id' when calling TokensApiControllerApi.update_app_token1"
|
276
|
+
end
|
277
|
+
# verify the required parameter 'dto' is set
|
278
|
+
if @api_client.config.client_side_validation && dto.nil?
|
279
|
+
fail ArgumentError, "Missing the required parameter 'dto' when calling TokensApiControllerApi.update_app_token1"
|
280
|
+
end
|
281
|
+
# resource path
|
282
|
+
local_var_path = '/users-web/api/v3/apps/{appId}/tokens/{tokenId}'.sub('{' + 'appId' + '}', app_id.to_s).sub('{' + 'tokenId' + '}', token_id.to_s)
|
283
|
+
|
284
|
+
# query parameters
|
285
|
+
query_params = {}
|
286
|
+
|
287
|
+
# header parameters
|
288
|
+
header_params = {}
|
289
|
+
# HTTP header 'Accept' (if needed)
|
290
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
291
|
+
# HTTP header 'Content-Type'
|
292
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
293
|
+
|
294
|
+
# form parameters
|
295
|
+
form_params = {}
|
296
|
+
|
297
|
+
# http body (model)
|
298
|
+
post_body = @api_client.object_to_http_body(dto)
|
299
|
+
auth_names = ['api_key']
|
300
|
+
data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
|
301
|
+
:header_params => header_params,
|
302
|
+
:query_params => query_params,
|
303
|
+
:form_params => form_params,
|
304
|
+
:body => post_body,
|
305
|
+
:auth_names => auth_names,
|
306
|
+
:return_type => 'GenericApiResponse')
|
307
|
+
if @api_client.config.debugging
|
308
|
+
@api_client.config.logger.debug "API called: TokensApiControllerApi#update_app_token1\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
309
|
+
end
|
310
|
+
return data, status_code, headers
|
311
|
+
end
|
312
|
+
end
|
313
|
+
end
|
@@ -0,0 +1,192 @@
|
|
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 CreateTokenDto
|
17
|
+
attr_accessor :readable
|
18
|
+
|
19
|
+
attr_accessor :writeable
|
20
|
+
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
22
|
+
def self.attribute_map
|
23
|
+
{
|
24
|
+
:'readable' => :'readable',
|
25
|
+
:'writeable' => :'writeable'
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# Attribute type mapping.
|
30
|
+
def self.swagger_types
|
31
|
+
{
|
32
|
+
:'readable' => :'BOOLEAN',
|
33
|
+
:'writeable' => :'BOOLEAN'
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
# Initializes the object
|
38
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
39
|
+
def initialize(attributes = {})
|
40
|
+
return unless attributes.is_a?(Hash)
|
41
|
+
|
42
|
+
# convert string to symbol for hash key
|
43
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
44
|
+
|
45
|
+
if attributes.has_key?(:'readable')
|
46
|
+
self.readable = attributes[:'readable']
|
47
|
+
end
|
48
|
+
|
49
|
+
if attributes.has_key?(:'writeable')
|
50
|
+
self.writeable = attributes[:'writeable']
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
55
|
+
# @return Array for valid properties with the reasons
|
56
|
+
def list_invalid_properties
|
57
|
+
invalid_properties = Array.new
|
58
|
+
invalid_properties
|
59
|
+
end
|
60
|
+
|
61
|
+
# Check to see if the all the properties in the model are valid
|
62
|
+
# @return true if the model is valid
|
63
|
+
def valid?
|
64
|
+
true
|
65
|
+
end
|
66
|
+
|
67
|
+
# Checks equality by comparing each attribute.
|
68
|
+
# @param [Object] Object to be compared
|
69
|
+
def ==(o)
|
70
|
+
return true if self.equal?(o)
|
71
|
+
self.class == o.class &&
|
72
|
+
readable == o.readable &&
|
73
|
+
writeable == o.writeable
|
74
|
+
end
|
75
|
+
|
76
|
+
# @see the `==` method
|
77
|
+
# @param [Object] Object to be compared
|
78
|
+
def eql?(o)
|
79
|
+
self == o
|
80
|
+
end
|
81
|
+
|
82
|
+
# Calculates hash code according to all attributes.
|
83
|
+
# @return [Fixnum] Hash code
|
84
|
+
def hash
|
85
|
+
[readable, writeable].hash
|
86
|
+
end
|
87
|
+
|
88
|
+
# Builds the object from hash
|
89
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
90
|
+
# @return [Object] Returns the model itself
|
91
|
+
def build_from_hash(attributes)
|
92
|
+
return nil unless attributes.is_a?(Hash)
|
93
|
+
self.class.swagger_types.each_pair do |key, type|
|
94
|
+
if type =~ /\AArray<(.*)>/i
|
95
|
+
# check to ensure the input is an array given that the the attribute
|
96
|
+
# is documented as an array but the input is not
|
97
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
98
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
99
|
+
end
|
100
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
101
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
102
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
103
|
+
end
|
104
|
+
|
105
|
+
self
|
106
|
+
end
|
107
|
+
|
108
|
+
# Deserializes the data based on type
|
109
|
+
# @param string type Data type
|
110
|
+
# @param string value Value to be deserialized
|
111
|
+
# @return [Object] Deserialized data
|
112
|
+
def _deserialize(type, value)
|
113
|
+
case type.to_sym
|
114
|
+
when :DateTime
|
115
|
+
DateTime.parse(value)
|
116
|
+
when :Date
|
117
|
+
Date.parse(value)
|
118
|
+
when :String
|
119
|
+
value.to_s
|
120
|
+
when :Integer
|
121
|
+
value.to_i
|
122
|
+
when :Float
|
123
|
+
value.to_f
|
124
|
+
when :BOOLEAN
|
125
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
126
|
+
true
|
127
|
+
else
|
128
|
+
false
|
129
|
+
end
|
130
|
+
when :Object
|
131
|
+
# generic object (usually a Hash), return directly
|
132
|
+
value
|
133
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
134
|
+
inner_type = Regexp.last_match[:inner_type]
|
135
|
+
value.map { |v| _deserialize(inner_type, v) }
|
136
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
137
|
+
k_type = Regexp.last_match[:k_type]
|
138
|
+
v_type = Regexp.last_match[:v_type]
|
139
|
+
{}.tap do |hash|
|
140
|
+
value.each do |k, v|
|
141
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
else # model
|
145
|
+
temp_model = stcloud.const_get(type).new
|
146
|
+
temp_model.build_from_hash(value)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# Returns the string representation of the object
|
151
|
+
# @return [String] String presentation of the object
|
152
|
+
def to_s
|
153
|
+
to_hash.to_s
|
154
|
+
end
|
155
|
+
|
156
|
+
# to_body is an alias to to_hash (backward compatibility)
|
157
|
+
# @return [Hash] Returns the object in the form of hash
|
158
|
+
def to_body
|
159
|
+
to_hash
|
160
|
+
end
|
161
|
+
|
162
|
+
# Returns the object in the form of hash
|
163
|
+
# @return [Hash] Returns the object in the form of hash
|
164
|
+
def to_hash
|
165
|
+
hash = {}
|
166
|
+
self.class.attribute_map.each_pair do |attr, param|
|
167
|
+
value = self.send(attr)
|
168
|
+
next if value.nil?
|
169
|
+
hash[param] = _to_hash(value)
|
170
|
+
end
|
171
|
+
hash
|
172
|
+
end
|
173
|
+
|
174
|
+
# Outputs non-array value in the form of hash
|
175
|
+
# For object, use to_hash. Otherwise, just return the value
|
176
|
+
# @param [Object] value Any valid value
|
177
|
+
# @return [Hash] Returns the value in the form of hash
|
178
|
+
def _to_hash(value)
|
179
|
+
if value.is_a?(Array)
|
180
|
+
value.compact.map { |v| _to_hash(v) }
|
181
|
+
elsif value.is_a?(Hash)
|
182
|
+
{}.tap do |hash|
|
183
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
184
|
+
end
|
185
|
+
elsif value.respond_to? :to_hash
|
186
|
+
value.to_hash
|
187
|
+
else
|
188
|
+
value
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|