hatchet-sdk 0.10.0 → 0.11.1
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/CHANGELOG.md +12 -0
- data/lib/hatchet/clients/grpc/admin.rb +20 -0
- data/lib/hatchet/clients/rest/.openapi-generator/FILES +10 -0
- data/lib/hatchet/clients/rest/README.md +16 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/serverless_api.rb +405 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/streams_api.rb +80 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/tenant_api.rb +71 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/rate_limit.rb +14 -4
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_entitlements.rb +367 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_create_serverless_endpoint_request.rb +411 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_serverless_endpoint.rb +556 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_serverless_endpoint_kind.rb +40 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_serverless_endpoint_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_serverless_endpoint_status.rb +271 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_stream_topic.rb +343 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_stream_topic_list.rb +292 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_update_serverless_endpoint_request.rb +354 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow.rb +14 -4
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest.rb +10 -0
- data/lib/hatchet/context.rb +13 -0
- data/lib/hatchet/contracts/v1/dispatcher_pb.rb +2 -1
- data/lib/hatchet/contracts/workflows/workflows_pb.rb +3 -1
- data/lib/hatchet/contracts/workflows/workflows_services_pb.rb +1 -0
- data/lib/hatchet/features/rate_limits.rb +13 -0
- data/lib/hatchet/version.rb +1 -1
- data/lib/hatchet/worker/durable_event_listener.rb +5 -5
- data/lib/hatchet/worker/received_satisfied_orders.rb +49 -0
- data/lib/hatchet/worker/runner.rb +6 -2
- data/lib/hatchet-sdk.rb +1 -0
- data/sig/hatchet/clients/grpc/admin.rbs +1 -0
- data/sig/hatchet/context.rbs +1 -0
- data/sig/hatchet/features/rate_limits.rbs +1 -0
- data/sig/hatchet/worker/received_satisfied_orders.rbs +11 -0
- metadata +14 -2
|
@@ -464,6 +464,77 @@ module HatchetSdkRest
|
|
|
464
464
|
return data, status_code, headers
|
|
465
465
|
end
|
|
466
466
|
|
|
467
|
+
# Get tenant entitlements
|
|
468
|
+
# Gets the features the tenant is entitled to
|
|
469
|
+
# @param tenant [String] The tenant id
|
|
470
|
+
# @param [Hash] opts the optional parameters
|
|
471
|
+
# @return [TenantEntitlements]
|
|
472
|
+
def tenant_entitlements_get(tenant, opts = {})
|
|
473
|
+
data, _status_code, _headers = tenant_entitlements_get_with_http_info(tenant, opts)
|
|
474
|
+
data
|
|
475
|
+
end
|
|
476
|
+
|
|
477
|
+
# Get tenant entitlements
|
|
478
|
+
# Gets the features the tenant is entitled to
|
|
479
|
+
# @param tenant [String] The tenant id
|
|
480
|
+
# @param [Hash] opts the optional parameters
|
|
481
|
+
# @return [Array<(TenantEntitlements, Integer, Hash)>] TenantEntitlements data, response status code and response headers
|
|
482
|
+
def tenant_entitlements_get_with_http_info(tenant, opts = {})
|
|
483
|
+
if @api_client.config.debugging
|
|
484
|
+
@api_client.config.logger.debug 'Calling API: TenantApi.tenant_entitlements_get ...'
|
|
485
|
+
end
|
|
486
|
+
# verify the required parameter 'tenant' is set
|
|
487
|
+
if @api_client.config.client_side_validation && tenant.nil?
|
|
488
|
+
fail ArgumentError, "Missing the required parameter 'tenant' when calling TenantApi.tenant_entitlements_get"
|
|
489
|
+
end
|
|
490
|
+
if @api_client.config.client_side_validation && tenant.to_s.length > 36
|
|
491
|
+
fail ArgumentError, 'invalid value for "tenant" when calling TenantApi.tenant_entitlements_get, the character length must be smaller than or equal to 36.'
|
|
492
|
+
end
|
|
493
|
+
|
|
494
|
+
if @api_client.config.client_side_validation && tenant.to_s.length < 36
|
|
495
|
+
fail ArgumentError, 'invalid value for "tenant" when calling TenantApi.tenant_entitlements_get, the character length must be greater than or equal to 36.'
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
# resource path
|
|
499
|
+
local_var_path = '/api/v1/tenants/{tenant}/entitlements'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s))
|
|
500
|
+
|
|
501
|
+
# query parameters
|
|
502
|
+
query_params = opts[:query_params] || {}
|
|
503
|
+
|
|
504
|
+
# header parameters
|
|
505
|
+
header_params = opts[:header_params] || {}
|
|
506
|
+
# HTTP header 'Accept' (if needed)
|
|
507
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
508
|
+
|
|
509
|
+
# form parameters
|
|
510
|
+
form_params = opts[:form_params] || {}
|
|
511
|
+
|
|
512
|
+
# http body (model)
|
|
513
|
+
post_body = opts[:debug_body]
|
|
514
|
+
|
|
515
|
+
# return_type
|
|
516
|
+
return_type = opts[:debug_return_type] || 'TenantEntitlements'
|
|
517
|
+
|
|
518
|
+
# auth_names
|
|
519
|
+
auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']
|
|
520
|
+
|
|
521
|
+
new_options = opts.merge(
|
|
522
|
+
:operation => :"TenantApi.tenant_entitlements_get",
|
|
523
|
+
:header_params => header_params,
|
|
524
|
+
:query_params => query_params,
|
|
525
|
+
:form_params => form_params,
|
|
526
|
+
:body => post_body,
|
|
527
|
+
:auth_names => auth_names,
|
|
528
|
+
:return_type => return_type
|
|
529
|
+
)
|
|
530
|
+
|
|
531
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
|
532
|
+
if @api_client.config.debugging
|
|
533
|
+
@api_client.config.logger.debug "API called: TenantApi#tenant_entitlements_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
534
|
+
end
|
|
535
|
+
return data, status_code, headers
|
|
536
|
+
end
|
|
537
|
+
|
|
467
538
|
# Get tenant
|
|
468
539
|
# Get the details of a tenant
|
|
469
540
|
# @param tenant [String] The tenant id to get details for
|
|
@@ -33,6 +33,9 @@ module HatchetSdkRest
|
|
|
33
33
|
# The last time the rate limit was refilled.
|
|
34
34
|
attr_accessor :last_refill
|
|
35
35
|
|
|
36
|
+
# When the rate limit's pause ends, if it is paused. Runs that consume a paused key stay queued until then.
|
|
37
|
+
attr_accessor :paused_until
|
|
38
|
+
|
|
36
39
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
37
40
|
def self.attribute_map
|
|
38
41
|
{
|
|
@@ -41,7 +44,8 @@ module HatchetSdkRest
|
|
|
41
44
|
:'limit_value' => :'limitValue',
|
|
42
45
|
:'value' => :'value',
|
|
43
46
|
:'window' => :'window',
|
|
44
|
-
:'last_refill' => :'lastRefill'
|
|
47
|
+
:'last_refill' => :'lastRefill',
|
|
48
|
+
:'paused_until' => :'pausedUntil'
|
|
45
49
|
}
|
|
46
50
|
end
|
|
47
51
|
|
|
@@ -63,7 +67,8 @@ module HatchetSdkRest
|
|
|
63
67
|
:'limit_value' => :'Integer',
|
|
64
68
|
:'value' => :'Integer',
|
|
65
69
|
:'window' => :'String',
|
|
66
|
-
:'last_refill' => :'Time'
|
|
70
|
+
:'last_refill' => :'Time',
|
|
71
|
+
:'paused_until' => :'Time'
|
|
67
72
|
}
|
|
68
73
|
end
|
|
69
74
|
|
|
@@ -124,6 +129,10 @@ module HatchetSdkRest
|
|
|
124
129
|
else
|
|
125
130
|
self.last_refill = nil
|
|
126
131
|
end
|
|
132
|
+
|
|
133
|
+
if attributes.key?(:'paused_until')
|
|
134
|
+
self.paused_until = attributes[:'paused_until']
|
|
135
|
+
end
|
|
127
136
|
end
|
|
128
137
|
|
|
129
138
|
# Show invalid properties with the reasons. Usually used together with valid?
|
|
@@ -241,7 +250,8 @@ module HatchetSdkRest
|
|
|
241
250
|
limit_value == o.limit_value &&
|
|
242
251
|
value == o.value &&
|
|
243
252
|
window == o.window &&
|
|
244
|
-
last_refill == o.last_refill
|
|
253
|
+
last_refill == o.last_refill &&
|
|
254
|
+
paused_until == o.paused_until
|
|
245
255
|
end
|
|
246
256
|
|
|
247
257
|
# @see the `==` method
|
|
@@ -253,7 +263,7 @@ module HatchetSdkRest
|
|
|
253
263
|
# Calculates hash code according to all attributes.
|
|
254
264
|
# @return [Integer] Hash code
|
|
255
265
|
def hash
|
|
256
|
-
[key, tenant_id, limit_value, value, window, last_refill].hash
|
|
266
|
+
[key, tenant_id, limit_value, value, window, last_refill, paused_until].hash
|
|
257
267
|
end
|
|
258
268
|
|
|
259
269
|
# Builds the object from hash
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Hatchet API
|
|
3
|
+
|
|
4
|
+
#The Hatchet API
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.14.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module HatchetSdkRest
|
|
17
|
+
class TenantEntitlements
|
|
18
|
+
attr_accessor :audit_logs
|
|
19
|
+
|
|
20
|
+
attr_accessor :prometheus_metrics
|
|
21
|
+
|
|
22
|
+
attr_accessor :strict_additional_metadata_filters
|
|
23
|
+
|
|
24
|
+
attr_accessor :dag_operator
|
|
25
|
+
|
|
26
|
+
attr_accessor :durable_streams
|
|
27
|
+
|
|
28
|
+
attr_accessor :serverless_operator
|
|
29
|
+
|
|
30
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
31
|
+
def self.attribute_map
|
|
32
|
+
{
|
|
33
|
+
:'audit_logs' => :'auditLogs',
|
|
34
|
+
:'prometheus_metrics' => :'prometheusMetrics',
|
|
35
|
+
:'strict_additional_metadata_filters' => :'strictAdditionalMetadataFilters',
|
|
36
|
+
:'dag_operator' => :'dagOperator',
|
|
37
|
+
:'durable_streams' => :'durableStreams',
|
|
38
|
+
:'serverless_operator' => :'serverlessOperator'
|
|
39
|
+
}
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Returns attribute mapping this model knows about
|
|
43
|
+
def self.acceptable_attribute_map
|
|
44
|
+
attribute_map
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Returns all the JSON keys this model knows about
|
|
48
|
+
def self.acceptable_attributes
|
|
49
|
+
acceptable_attribute_map.values
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Attribute type mapping.
|
|
53
|
+
def self.openapi_types
|
|
54
|
+
{
|
|
55
|
+
:'audit_logs' => :'Boolean',
|
|
56
|
+
:'prometheus_metrics' => :'Boolean',
|
|
57
|
+
:'strict_additional_metadata_filters' => :'Boolean',
|
|
58
|
+
:'dag_operator' => :'Boolean',
|
|
59
|
+
:'durable_streams' => :'Boolean',
|
|
60
|
+
:'serverless_operator' => :'Boolean'
|
|
61
|
+
}
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# List of attributes with nullable: true
|
|
65
|
+
def self.openapi_nullable
|
|
66
|
+
Set.new([
|
|
67
|
+
])
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Initializes the object
|
|
71
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
72
|
+
def initialize(attributes = {})
|
|
73
|
+
if (!attributes.is_a?(Hash))
|
|
74
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `HatchetSdkRest::TenantEntitlements` initialize method"
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
78
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
79
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
80
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
81
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `HatchetSdkRest::TenantEntitlements`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
82
|
+
end
|
|
83
|
+
h[k.to_sym] = v
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if attributes.key?(:'audit_logs')
|
|
87
|
+
self.audit_logs = attributes[:'audit_logs']
|
|
88
|
+
else
|
|
89
|
+
self.audit_logs = nil
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
if attributes.key?(:'prometheus_metrics')
|
|
93
|
+
self.prometheus_metrics = attributes[:'prometheus_metrics']
|
|
94
|
+
else
|
|
95
|
+
self.prometheus_metrics = nil
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
if attributes.key?(:'strict_additional_metadata_filters')
|
|
99
|
+
self.strict_additional_metadata_filters = attributes[:'strict_additional_metadata_filters']
|
|
100
|
+
else
|
|
101
|
+
self.strict_additional_metadata_filters = nil
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
if attributes.key?(:'dag_operator')
|
|
105
|
+
self.dag_operator = attributes[:'dag_operator']
|
|
106
|
+
else
|
|
107
|
+
self.dag_operator = nil
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
if attributes.key?(:'durable_streams')
|
|
111
|
+
self.durable_streams = attributes[:'durable_streams']
|
|
112
|
+
else
|
|
113
|
+
self.durable_streams = nil
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
if attributes.key?(:'serverless_operator')
|
|
117
|
+
self.serverless_operator = attributes[:'serverless_operator']
|
|
118
|
+
else
|
|
119
|
+
self.serverless_operator = nil
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
124
|
+
# @return Array for valid properties with the reasons
|
|
125
|
+
def list_invalid_properties
|
|
126
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
127
|
+
invalid_properties = Array.new
|
|
128
|
+
if @audit_logs.nil?
|
|
129
|
+
invalid_properties.push('invalid value for "audit_logs", audit_logs cannot be nil.')
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
if @prometheus_metrics.nil?
|
|
133
|
+
invalid_properties.push('invalid value for "prometheus_metrics", prometheus_metrics cannot be nil.')
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
if @strict_additional_metadata_filters.nil?
|
|
137
|
+
invalid_properties.push('invalid value for "strict_additional_metadata_filters", strict_additional_metadata_filters cannot be nil.')
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
if @dag_operator.nil?
|
|
141
|
+
invalid_properties.push('invalid value for "dag_operator", dag_operator cannot be nil.')
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
if @durable_streams.nil?
|
|
145
|
+
invalid_properties.push('invalid value for "durable_streams", durable_streams cannot be nil.')
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
if @serverless_operator.nil?
|
|
149
|
+
invalid_properties.push('invalid value for "serverless_operator", serverless_operator cannot be nil.')
|
|
150
|
+
end
|
|
151
|
+
|
|
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
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
159
|
+
return false if @audit_logs.nil?
|
|
160
|
+
return false if @prometheus_metrics.nil?
|
|
161
|
+
return false if @strict_additional_metadata_filters.nil?
|
|
162
|
+
return false if @dag_operator.nil?
|
|
163
|
+
return false if @durable_streams.nil?
|
|
164
|
+
return false if @serverless_operator.nil?
|
|
165
|
+
true
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Custom attribute writer method with validation
|
|
169
|
+
# @param [Object] audit_logs Value to be assigned
|
|
170
|
+
def audit_logs=(audit_logs)
|
|
171
|
+
if audit_logs.nil?
|
|
172
|
+
fail ArgumentError, 'audit_logs cannot be nil'
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
@audit_logs = audit_logs
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Custom attribute writer method with validation
|
|
179
|
+
# @param [Object] prometheus_metrics Value to be assigned
|
|
180
|
+
def prometheus_metrics=(prometheus_metrics)
|
|
181
|
+
if prometheus_metrics.nil?
|
|
182
|
+
fail ArgumentError, 'prometheus_metrics cannot be nil'
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
@prometheus_metrics = prometheus_metrics
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# Custom attribute writer method with validation
|
|
189
|
+
# @param [Object] strict_additional_metadata_filters Value to be assigned
|
|
190
|
+
def strict_additional_metadata_filters=(strict_additional_metadata_filters)
|
|
191
|
+
if strict_additional_metadata_filters.nil?
|
|
192
|
+
fail ArgumentError, 'strict_additional_metadata_filters cannot be nil'
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
@strict_additional_metadata_filters = strict_additional_metadata_filters
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# Custom attribute writer method with validation
|
|
199
|
+
# @param [Object] dag_operator Value to be assigned
|
|
200
|
+
def dag_operator=(dag_operator)
|
|
201
|
+
if dag_operator.nil?
|
|
202
|
+
fail ArgumentError, 'dag_operator cannot be nil'
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
@dag_operator = dag_operator
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# Custom attribute writer method with validation
|
|
209
|
+
# @param [Object] durable_streams Value to be assigned
|
|
210
|
+
def durable_streams=(durable_streams)
|
|
211
|
+
if durable_streams.nil?
|
|
212
|
+
fail ArgumentError, 'durable_streams cannot be nil'
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
@durable_streams = durable_streams
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# Custom attribute writer method with validation
|
|
219
|
+
# @param [Object] serverless_operator Value to be assigned
|
|
220
|
+
def serverless_operator=(serverless_operator)
|
|
221
|
+
if serverless_operator.nil?
|
|
222
|
+
fail ArgumentError, 'serverless_operator cannot be nil'
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
@serverless_operator = serverless_operator
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
# Checks equality by comparing each attribute.
|
|
229
|
+
# @param [Object] Object to be compared
|
|
230
|
+
def ==(o)
|
|
231
|
+
return true if self.equal?(o)
|
|
232
|
+
self.class == o.class &&
|
|
233
|
+
audit_logs == o.audit_logs &&
|
|
234
|
+
prometheus_metrics == o.prometheus_metrics &&
|
|
235
|
+
strict_additional_metadata_filters == o.strict_additional_metadata_filters &&
|
|
236
|
+
dag_operator == o.dag_operator &&
|
|
237
|
+
durable_streams == o.durable_streams &&
|
|
238
|
+
serverless_operator == o.serverless_operator
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# @see the `==` method
|
|
242
|
+
# @param [Object] Object to be compared
|
|
243
|
+
def eql?(o)
|
|
244
|
+
self == o
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
# Calculates hash code according to all attributes.
|
|
248
|
+
# @return [Integer] Hash code
|
|
249
|
+
def hash
|
|
250
|
+
[audit_logs, prometheus_metrics, strict_additional_metadata_filters, dag_operator, durable_streams, serverless_operator].hash
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
# Builds the object from hash
|
|
254
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
255
|
+
# @return [Object] Returns the model itself
|
|
256
|
+
def self.build_from_hash(attributes)
|
|
257
|
+
return nil unless attributes.is_a?(Hash)
|
|
258
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
259
|
+
transformed_hash = {}
|
|
260
|
+
openapi_types.each_pair do |key, type|
|
|
261
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
262
|
+
transformed_hash["#{key}"] = nil
|
|
263
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
264
|
+
# check to ensure the input is an array given that the attribute
|
|
265
|
+
# is documented as an array but the input is not
|
|
266
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
267
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
268
|
+
end
|
|
269
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
270
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
new(transformed_hash)
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
# Deserializes the data based on type
|
|
277
|
+
# @param string type Data type
|
|
278
|
+
# @param string value Value to be deserialized
|
|
279
|
+
# @return [Object] Deserialized data
|
|
280
|
+
def self._deserialize(type, value)
|
|
281
|
+
case type.to_sym
|
|
282
|
+
when :Time
|
|
283
|
+
Time.parse(value)
|
|
284
|
+
when :Date
|
|
285
|
+
Date.parse(value)
|
|
286
|
+
when :String
|
|
287
|
+
value.to_s
|
|
288
|
+
when :Integer
|
|
289
|
+
value.to_i
|
|
290
|
+
when :Float
|
|
291
|
+
value.to_f
|
|
292
|
+
when :Boolean
|
|
293
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
294
|
+
true
|
|
295
|
+
else
|
|
296
|
+
false
|
|
297
|
+
end
|
|
298
|
+
when :Object
|
|
299
|
+
# generic object (usually a Hash), return directly
|
|
300
|
+
value
|
|
301
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
302
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
303
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
304
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
305
|
+
k_type = Regexp.last_match[:k_type]
|
|
306
|
+
v_type = Regexp.last_match[:v_type]
|
|
307
|
+
{}.tap do |hash|
|
|
308
|
+
value.each do |k, v|
|
|
309
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
310
|
+
end
|
|
311
|
+
end
|
|
312
|
+
else # model
|
|
313
|
+
# models (e.g. Pet) or oneOf
|
|
314
|
+
klass = HatchetSdkRest.const_get(type)
|
|
315
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
# Returns the string representation of the object
|
|
320
|
+
# @return [String] String presentation of the object
|
|
321
|
+
def to_s
|
|
322
|
+
to_hash.to_s
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
326
|
+
# @return [Hash] Returns the object in the form of hash
|
|
327
|
+
def to_body
|
|
328
|
+
to_hash
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
# Returns the object in the form of hash
|
|
332
|
+
# @return [Hash] Returns the object in the form of hash
|
|
333
|
+
def to_hash
|
|
334
|
+
hash = {}
|
|
335
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
336
|
+
value = self.send(attr)
|
|
337
|
+
if value.nil?
|
|
338
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
339
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
hash[param] = _to_hash(value)
|
|
343
|
+
end
|
|
344
|
+
hash
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
# Outputs non-array value in the form of hash
|
|
348
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
349
|
+
# @param [Object] value Any valid value
|
|
350
|
+
# @return [Hash] Returns the value in the form of hash
|
|
351
|
+
def _to_hash(value)
|
|
352
|
+
if value.is_a?(Array)
|
|
353
|
+
value.compact.map { |v| _to_hash(v) }
|
|
354
|
+
elsif value.is_a?(Hash)
|
|
355
|
+
{}.tap do |hash|
|
|
356
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
357
|
+
end
|
|
358
|
+
elsif value.respond_to? :to_hash
|
|
359
|
+
value.to_hash
|
|
360
|
+
else
|
|
361
|
+
value
|
|
362
|
+
end
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
end
|