hatchet-sdk 0.5.0 → 0.7.0

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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/lib/hatchet/batch.rb +58 -0
  4. data/lib/hatchet/clients/grpc/dispatcher.rb +42 -0
  5. data/lib/hatchet/clients/rest/.openapi-generator/FILES +9 -0
  6. data/lib/hatchet/clients/rest/README.md +16 -3
  7. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/filter_api.rb +4 -0
  8. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/operator_api.rb +405 -0
  9. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/webhook_api.rb +2 -0
  10. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/worker_api.rb +3 -0
  11. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/api_meta.rb +14 -4
  12. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/create_tenant_invite_request.rb +14 -4
  13. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/pause_workflow_request.rb +105 -0
  14. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/pause_workflow_request_pause.rb +343 -0
  15. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/pause_workflow_request_unpause.rb +262 -0
  16. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_invite.rb +11 -1
  17. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_member.rb +11 -1
  18. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_member_role.rb +2 -1
  19. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/update_tenant_invite_request.rb +14 -4
  20. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/update_tenant_member_request.rb +14 -4
  21. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_create_http_operator_request.rb +346 -0
  22. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_event.rb +14 -4
  23. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_http_operator.rb +372 -0
  24. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_http_operator_list.rb +231 -0
  25. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_event_type.rb +3 -1
  26. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_summary.rb +14 -4
  27. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_update_http_operator_request.rb +252 -0
  28. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_workflow_run.rb +14 -4
  29. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow.rb +43 -1
  30. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_pause_scheduled_cron_run_queue_behavior.rb +40 -0
  31. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_update_request.rb +7 -8
  32. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest.rb +9 -0
  33. data/lib/hatchet/concurrency.rb +5 -1
  34. data/lib/hatchet/context.rb +42 -3
  35. data/lib/hatchet/contracts/dispatcher/dispatcher_pb.rb +4 -1
  36. data/lib/hatchet/contracts/dispatcher/dispatcher_services_pb.rb +3 -0
  37. data/lib/hatchet/contracts/v1/workflows_pb.rb +2 -1
  38. data/lib/hatchet/durable_context.rb +5 -12
  39. data/lib/hatchet/features/cel.rb +2 -2
  40. data/lib/hatchet/features/cron.rb +5 -5
  41. data/lib/hatchet/features/events.rb +7 -7
  42. data/lib/hatchet/features/filters.rb +7 -7
  43. data/lib/hatchet/features/logs.rb +2 -2
  44. data/lib/hatchet/features/metrics.rb +6 -6
  45. data/lib/hatchet/features/rate_limits.rb +2 -2
  46. data/lib/hatchet/features/runs.rb +4 -5
  47. data/lib/hatchet/features/scheduled.rb +7 -7
  48. data/lib/hatchet/features/tenant.rb +2 -2
  49. data/lib/hatchet/features/workers.rb +5 -5
  50. data/lib/hatchet/features/workflows.rb +6 -6
  51. data/lib/hatchet/task.rb +13 -0
  52. data/lib/hatchet/version.rb +1 -1
  53. data/lib/hatchet/worker/runner.rb +113 -0
  54. data/lib/hatchet/workflow.rb +77 -33
  55. data/lib/hatchet-sdk.rb +86 -28
  56. data/sig/hatchet/batch.rbs +12 -0
  57. data/sig/hatchet/task.rbs +2 -0
  58. metadata +13 -2
@@ -0,0 +1,343 @@
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 PauseWorkflowRequestPause
18
+ # Discriminator indicating this request pauses the workflow.
19
+ attr_accessor :action
20
+
21
+ # The behavior of cron runs triggered while the workflow is paused.
22
+ attr_accessor :paused_workflow_cron_run_queue_behavior
23
+
24
+ # The behavior of scheduled runs triggered while the workflow is paused.
25
+ attr_accessor :paused_workflow_scheduled_run_queue_behavior
26
+
27
+ # The TTL for queued runs while the workflow is paused before they get dropped, expressed as a Go-style duration string (e.g. \"1d7h30m\").
28
+ attr_accessor :paused_workflow_queue_ttl
29
+
30
+ class EnumAttributeValidator
31
+ attr_reader :datatype
32
+ attr_reader :allowable_values
33
+
34
+ def initialize(datatype, allowable_values)
35
+ @allowable_values = allowable_values.map do |value|
36
+ case datatype.to_s
37
+ when /Integer/i
38
+ value.to_i
39
+ when /Float/i
40
+ value.to_f
41
+ else
42
+ value
43
+ end
44
+ end
45
+ end
46
+
47
+ def valid?(value)
48
+ !value || allowable_values.include?(value)
49
+ end
50
+ end
51
+
52
+ # Attribute mapping from ruby-style variable name to JSON key.
53
+ def self.attribute_map
54
+ {
55
+ :'action' => :'action',
56
+ :'paused_workflow_cron_run_queue_behavior' => :'pausedWorkflowCronRunQueueBehavior',
57
+ :'paused_workflow_scheduled_run_queue_behavior' => :'pausedWorkflowScheduledRunQueueBehavior',
58
+ :'paused_workflow_queue_ttl' => :'pausedWorkflowQueueTTL'
59
+ }
60
+ end
61
+
62
+ # Returns attribute mapping this model knows about
63
+ def self.acceptable_attribute_map
64
+ attribute_map
65
+ end
66
+
67
+ # Returns all the JSON keys this model knows about
68
+ def self.acceptable_attributes
69
+ acceptable_attribute_map.values
70
+ end
71
+
72
+ # Attribute type mapping.
73
+ def self.openapi_types
74
+ {
75
+ :'action' => :'String',
76
+ :'paused_workflow_cron_run_queue_behavior' => :'WorkflowPauseScheduledCronRunQueueBehavior',
77
+ :'paused_workflow_scheduled_run_queue_behavior' => :'WorkflowPauseScheduledCronRunQueueBehavior',
78
+ :'paused_workflow_queue_ttl' => :'String'
79
+ }
80
+ end
81
+
82
+ # List of attributes with nullable: true
83
+ def self.openapi_nullable
84
+ Set.new([
85
+ ])
86
+ end
87
+
88
+ # Initializes the object
89
+ # @param [Hash] attributes Model attributes in the form of hash
90
+ def initialize(attributes = {})
91
+ if (!attributes.is_a?(Hash))
92
+ fail ArgumentError, "The input argument (attributes) must be a hash in `HatchetSdkRest::PauseWorkflowRequestPause` initialize method"
93
+ end
94
+
95
+ # check to see if the attribute exists and convert string to symbol for hash key
96
+ acceptable_attribute_map = self.class.acceptable_attribute_map
97
+ attributes = attributes.each_with_object({}) { |(k, v), h|
98
+ if (!acceptable_attribute_map.key?(k.to_sym))
99
+ fail ArgumentError, "`#{k}` is not a valid attribute in `HatchetSdkRest::PauseWorkflowRequestPause`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
100
+ end
101
+ h[k.to_sym] = v
102
+ }
103
+
104
+ if attributes.key?(:'action')
105
+ self.action = attributes[:'action']
106
+ else
107
+ self.action = nil
108
+ end
109
+
110
+ if attributes.key?(:'paused_workflow_cron_run_queue_behavior')
111
+ self.paused_workflow_cron_run_queue_behavior = attributes[:'paused_workflow_cron_run_queue_behavior']
112
+ else
113
+ self.paused_workflow_cron_run_queue_behavior = nil
114
+ end
115
+
116
+ if attributes.key?(:'paused_workflow_scheduled_run_queue_behavior')
117
+ self.paused_workflow_scheduled_run_queue_behavior = attributes[:'paused_workflow_scheduled_run_queue_behavior']
118
+ else
119
+ self.paused_workflow_scheduled_run_queue_behavior = nil
120
+ end
121
+
122
+ if attributes.key?(:'paused_workflow_queue_ttl')
123
+ self.paused_workflow_queue_ttl = attributes[:'paused_workflow_queue_ttl']
124
+ else
125
+ self.paused_workflow_queue_ttl = nil
126
+ end
127
+ end
128
+
129
+ # Show invalid properties with the reasons. Usually used together with valid?
130
+ # @return Array for valid properties with the reasons
131
+ def list_invalid_properties
132
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
133
+ invalid_properties = Array.new
134
+ if @action.nil?
135
+ invalid_properties.push('invalid value for "action", action cannot be nil.')
136
+ end
137
+
138
+ if @paused_workflow_cron_run_queue_behavior.nil?
139
+ invalid_properties.push('invalid value for "paused_workflow_cron_run_queue_behavior", paused_workflow_cron_run_queue_behavior cannot be nil.')
140
+ end
141
+
142
+ if @paused_workflow_scheduled_run_queue_behavior.nil?
143
+ invalid_properties.push('invalid value for "paused_workflow_scheduled_run_queue_behavior", paused_workflow_scheduled_run_queue_behavior cannot be nil.')
144
+ end
145
+
146
+ if @paused_workflow_queue_ttl.nil?
147
+ invalid_properties.push('invalid value for "paused_workflow_queue_ttl", paused_workflow_queue_ttl cannot be nil.')
148
+ end
149
+
150
+ invalid_properties
151
+ end
152
+
153
+ # Check to see if the all the properties in the model are valid
154
+ # @return true if the model is valid
155
+ def valid?
156
+ warn '[DEPRECATED] the `valid?` method is obsolete'
157
+ return false if @action.nil?
158
+ action_validator = EnumAttributeValidator.new('String', ["pause"])
159
+ return false unless action_validator.valid?(@action)
160
+ return false if @paused_workflow_cron_run_queue_behavior.nil?
161
+ return false if @paused_workflow_scheduled_run_queue_behavior.nil?
162
+ return false if @paused_workflow_queue_ttl.nil?
163
+ true
164
+ end
165
+
166
+ # Custom attribute writer method checking allowed values (enum).
167
+ # @param [Object] action Object to be assigned
168
+ def action=(action)
169
+ validator = EnumAttributeValidator.new('String', ["pause"])
170
+ unless validator.valid?(action)
171
+ fail ArgumentError, "invalid value for \"action\", must be one of #{validator.allowable_values}."
172
+ end
173
+ @action = action
174
+ end
175
+
176
+ # Custom attribute writer method with validation
177
+ # @param [Object] paused_workflow_cron_run_queue_behavior Value to be assigned
178
+ def paused_workflow_cron_run_queue_behavior=(paused_workflow_cron_run_queue_behavior)
179
+ if paused_workflow_cron_run_queue_behavior.nil?
180
+ fail ArgumentError, 'paused_workflow_cron_run_queue_behavior cannot be nil'
181
+ end
182
+
183
+ @paused_workflow_cron_run_queue_behavior = paused_workflow_cron_run_queue_behavior
184
+ end
185
+
186
+ # Custom attribute writer method with validation
187
+ # @param [Object] paused_workflow_scheduled_run_queue_behavior Value to be assigned
188
+ def paused_workflow_scheduled_run_queue_behavior=(paused_workflow_scheduled_run_queue_behavior)
189
+ if paused_workflow_scheduled_run_queue_behavior.nil?
190
+ fail ArgumentError, 'paused_workflow_scheduled_run_queue_behavior cannot be nil'
191
+ end
192
+
193
+ @paused_workflow_scheduled_run_queue_behavior = paused_workflow_scheduled_run_queue_behavior
194
+ end
195
+
196
+ # Custom attribute writer method with validation
197
+ # @param [Object] paused_workflow_queue_ttl Value to be assigned
198
+ def paused_workflow_queue_ttl=(paused_workflow_queue_ttl)
199
+ if paused_workflow_queue_ttl.nil?
200
+ fail ArgumentError, 'paused_workflow_queue_ttl cannot be nil'
201
+ end
202
+
203
+ @paused_workflow_queue_ttl = paused_workflow_queue_ttl
204
+ end
205
+
206
+ # Checks equality by comparing each attribute.
207
+ # @param [Object] Object to be compared
208
+ def ==(o)
209
+ return true if self.equal?(o)
210
+ self.class == o.class &&
211
+ action == o.action &&
212
+ paused_workflow_cron_run_queue_behavior == o.paused_workflow_cron_run_queue_behavior &&
213
+ paused_workflow_scheduled_run_queue_behavior == o.paused_workflow_scheduled_run_queue_behavior &&
214
+ paused_workflow_queue_ttl == o.paused_workflow_queue_ttl
215
+ end
216
+
217
+ # @see the `==` method
218
+ # @param [Object] Object to be compared
219
+ def eql?(o)
220
+ self == o
221
+ end
222
+
223
+ # Calculates hash code according to all attributes.
224
+ # @return [Integer] Hash code
225
+ def hash
226
+ [action, paused_workflow_cron_run_queue_behavior, paused_workflow_scheduled_run_queue_behavior, paused_workflow_queue_ttl].hash
227
+ end
228
+
229
+ # Builds the object from hash
230
+ # @param [Hash] attributes Model attributes in the form of hash
231
+ # @return [Object] Returns the model itself
232
+ def self.build_from_hash(attributes)
233
+ return nil unless attributes.is_a?(Hash)
234
+ attributes = attributes.transform_keys(&:to_sym)
235
+ transformed_hash = {}
236
+ openapi_types.each_pair do |key, type|
237
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
238
+ transformed_hash["#{key}"] = nil
239
+ elsif type =~ /\AArray<(.*)>/i
240
+ # check to ensure the input is an array given that the attribute
241
+ # is documented as an array but the input is not
242
+ if attributes[attribute_map[key]].is_a?(Array)
243
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
244
+ end
245
+ elsif !attributes[attribute_map[key]].nil?
246
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
247
+ end
248
+ end
249
+ new(transformed_hash)
250
+ end
251
+
252
+ # Deserializes the data based on type
253
+ # @param string type Data type
254
+ # @param string value Value to be deserialized
255
+ # @return [Object] Deserialized data
256
+ def self._deserialize(type, value)
257
+ case type.to_sym
258
+ when :Time
259
+ Time.parse(value)
260
+ when :Date
261
+ Date.parse(value)
262
+ when :String
263
+ value.to_s
264
+ when :Integer
265
+ value.to_i
266
+ when :Float
267
+ value.to_f
268
+ when :Boolean
269
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
270
+ true
271
+ else
272
+ false
273
+ end
274
+ when :Object
275
+ # generic object (usually a Hash), return directly
276
+ value
277
+ when /\AArray<(?<inner_type>.+)>\z/
278
+ inner_type = Regexp.last_match[:inner_type]
279
+ value.map { |v| _deserialize(inner_type, v) }
280
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
281
+ k_type = Regexp.last_match[:k_type]
282
+ v_type = Regexp.last_match[:v_type]
283
+ {}.tap do |hash|
284
+ value.each do |k, v|
285
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
286
+ end
287
+ end
288
+ else # model
289
+ # models (e.g. Pet) or oneOf
290
+ klass = HatchetSdkRest.const_get(type)
291
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
292
+ end
293
+ end
294
+
295
+ # Returns the string representation of the object
296
+ # @return [String] String presentation of the object
297
+ def to_s
298
+ to_hash.to_s
299
+ end
300
+
301
+ # to_body is an alias to to_hash (backward compatibility)
302
+ # @return [Hash] Returns the object in the form of hash
303
+ def to_body
304
+ to_hash
305
+ end
306
+
307
+ # Returns the object in the form of hash
308
+ # @return [Hash] Returns the object in the form of hash
309
+ def to_hash
310
+ hash = {}
311
+ self.class.attribute_map.each_pair do |attr, param|
312
+ value = self.send(attr)
313
+ if value.nil?
314
+ is_nullable = self.class.openapi_nullable.include?(attr)
315
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
316
+ end
317
+
318
+ hash[param] = _to_hash(value)
319
+ end
320
+ hash
321
+ end
322
+
323
+ # Outputs non-array value in the form of hash
324
+ # For object, use to_hash. Otherwise, just return the value
325
+ # @param [Object] value Any valid value
326
+ # @return [Hash] Returns the value in the form of hash
327
+ def _to_hash(value)
328
+ if value.is_a?(Array)
329
+ value.compact.map { |v| _to_hash(v) }
330
+ elsif value.is_a?(Hash)
331
+ {}.tap do |hash|
332
+ value.each { |k, v| hash[k] = _to_hash(v) }
333
+ end
334
+ elsif value.respond_to? :to_hash
335
+ value.to_hash
336
+ else
337
+ value
338
+ end
339
+ end
340
+
341
+ end
342
+
343
+ end
@@ -0,0 +1,262 @@
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 PauseWorkflowRequestUnpause
18
+ # Discriminator indicating this request unpauses the workflow.
19
+ attr_accessor :action
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
+ :'action' => :'action'
47
+ }
48
+ end
49
+
50
+ # Returns attribute mapping this model knows about
51
+ def self.acceptable_attribute_map
52
+ attribute_map
53
+ end
54
+
55
+ # Returns all the JSON keys this model knows about
56
+ def self.acceptable_attributes
57
+ acceptable_attribute_map.values
58
+ end
59
+
60
+ # Attribute type mapping.
61
+ def self.openapi_types
62
+ {
63
+ :'action' => :'String'
64
+ }
65
+ end
66
+
67
+ # List of attributes with nullable: true
68
+ def self.openapi_nullable
69
+ Set.new([
70
+ ])
71
+ end
72
+
73
+ # Initializes the object
74
+ # @param [Hash] attributes Model attributes in the form of hash
75
+ def initialize(attributes = {})
76
+ if (!attributes.is_a?(Hash))
77
+ fail ArgumentError, "The input argument (attributes) must be a hash in `HatchetSdkRest::PauseWorkflowRequestUnpause` initialize method"
78
+ end
79
+
80
+ # check to see if the attribute exists and convert string to symbol for hash key
81
+ acceptable_attribute_map = self.class.acceptable_attribute_map
82
+ attributes = attributes.each_with_object({}) { |(k, v), h|
83
+ if (!acceptable_attribute_map.key?(k.to_sym))
84
+ fail ArgumentError, "`#{k}` is not a valid attribute in `HatchetSdkRest::PauseWorkflowRequestUnpause`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
85
+ end
86
+ h[k.to_sym] = v
87
+ }
88
+
89
+ if attributes.key?(:'action')
90
+ self.action = attributes[:'action']
91
+ else
92
+ self.action = nil
93
+ end
94
+ end
95
+
96
+ # Show invalid properties with the reasons. Usually used together with valid?
97
+ # @return Array for valid properties with the reasons
98
+ def list_invalid_properties
99
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
100
+ invalid_properties = Array.new
101
+ if @action.nil?
102
+ invalid_properties.push('invalid value for "action", action cannot be nil.')
103
+ end
104
+
105
+ invalid_properties
106
+ end
107
+
108
+ # Check to see if the all the properties in the model are valid
109
+ # @return true if the model is valid
110
+ def valid?
111
+ warn '[DEPRECATED] the `valid?` method is obsolete'
112
+ return false if @action.nil?
113
+ action_validator = EnumAttributeValidator.new('String', ["unpause"])
114
+ return false unless action_validator.valid?(@action)
115
+ true
116
+ end
117
+
118
+ # Custom attribute writer method checking allowed values (enum).
119
+ # @param [Object] action Object to be assigned
120
+ def action=(action)
121
+ validator = EnumAttributeValidator.new('String', ["unpause"])
122
+ unless validator.valid?(action)
123
+ fail ArgumentError, "invalid value for \"action\", must be one of #{validator.allowable_values}."
124
+ end
125
+ @action = action
126
+ end
127
+
128
+ # Checks equality by comparing each attribute.
129
+ # @param [Object] Object to be compared
130
+ def ==(o)
131
+ return true if self.equal?(o)
132
+ self.class == o.class &&
133
+ action == o.action
134
+ end
135
+
136
+ # @see the `==` method
137
+ # @param [Object] Object to be compared
138
+ def eql?(o)
139
+ self == o
140
+ end
141
+
142
+ # Calculates hash code according to all attributes.
143
+ # @return [Integer] Hash code
144
+ def hash
145
+ [action].hash
146
+ end
147
+
148
+ # Builds the object from hash
149
+ # @param [Hash] attributes Model attributes in the form of hash
150
+ # @return [Object] Returns the model itself
151
+ def self.build_from_hash(attributes)
152
+ return nil unless attributes.is_a?(Hash)
153
+ attributes = attributes.transform_keys(&:to_sym)
154
+ transformed_hash = {}
155
+ openapi_types.each_pair do |key, type|
156
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
157
+ transformed_hash["#{key}"] = nil
158
+ elsif type =~ /\AArray<(.*)>/i
159
+ # check to ensure the input is an array given that the attribute
160
+ # is documented as an array but the input is not
161
+ if attributes[attribute_map[key]].is_a?(Array)
162
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
163
+ end
164
+ elsif !attributes[attribute_map[key]].nil?
165
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
166
+ end
167
+ end
168
+ new(transformed_hash)
169
+ end
170
+
171
+ # Deserializes the data based on type
172
+ # @param string type Data type
173
+ # @param string value Value to be deserialized
174
+ # @return [Object] Deserialized data
175
+ def self._deserialize(type, value)
176
+ case type.to_sym
177
+ when :Time
178
+ Time.parse(value)
179
+ when :Date
180
+ Date.parse(value)
181
+ when :String
182
+ value.to_s
183
+ when :Integer
184
+ value.to_i
185
+ when :Float
186
+ value.to_f
187
+ when :Boolean
188
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
189
+ true
190
+ else
191
+ false
192
+ end
193
+ when :Object
194
+ # generic object (usually a Hash), return directly
195
+ value
196
+ when /\AArray<(?<inner_type>.+)>\z/
197
+ inner_type = Regexp.last_match[:inner_type]
198
+ value.map { |v| _deserialize(inner_type, v) }
199
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
200
+ k_type = Regexp.last_match[:k_type]
201
+ v_type = Regexp.last_match[:v_type]
202
+ {}.tap do |hash|
203
+ value.each do |k, v|
204
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
205
+ end
206
+ end
207
+ else # model
208
+ # models (e.g. Pet) or oneOf
209
+ klass = HatchetSdkRest.const_get(type)
210
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
211
+ end
212
+ end
213
+
214
+ # Returns the string representation of the object
215
+ # @return [String] String presentation of the object
216
+ def to_s
217
+ to_hash.to_s
218
+ end
219
+
220
+ # to_body is an alias to to_hash (backward compatibility)
221
+ # @return [Hash] Returns the object in the form of hash
222
+ def to_body
223
+ to_hash
224
+ end
225
+
226
+ # Returns the object in the form of hash
227
+ # @return [Hash] Returns the object in the form of hash
228
+ def to_hash
229
+ hash = {}
230
+ self.class.attribute_map.each_pair do |attr, param|
231
+ value = self.send(attr)
232
+ if value.nil?
233
+ is_nullable = self.class.openapi_nullable.include?(attr)
234
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
235
+ end
236
+
237
+ hash[param] = _to_hash(value)
238
+ end
239
+ hash
240
+ end
241
+
242
+ # Outputs non-array value in the form of hash
243
+ # For object, use to_hash. Otherwise, just return the value
244
+ # @param [Object] value Any valid value
245
+ # @return [Hash] Returns the value in the form of hash
246
+ def _to_hash(value)
247
+ if value.is_a?(Array)
248
+ value.compact.map { |v| _to_hash(v) }
249
+ elsif value.is_a?(Hash)
250
+ {}.tap do |hash|
251
+ value.each { |k, v| hash[k] = _to_hash(v) }
252
+ end
253
+ elsif value.respond_to? :to_hash
254
+ value.to_hash
255
+ else
256
+ value
257
+ end
258
+ end
259
+
260
+ end
261
+
262
+ end
@@ -29,6 +29,9 @@ module HatchetSdkRest
29
29
  # The time that this invite expires.
30
30
  attr_accessor :expires
31
31
 
32
+ # Whether the invited user can view payloads. Defaults to true.
33
+ attr_accessor :can_view_payloads
34
+
32
35
  # The tenant name for the tenant.
33
36
  attr_accessor :tenant_name
34
37
 
@@ -62,6 +65,7 @@ module HatchetSdkRest
62
65
  :'role' => :'role',
63
66
  :'tenant_id' => :'tenantId',
64
67
  :'expires' => :'expires',
68
+ :'can_view_payloads' => :'canViewPayloads',
65
69
  :'tenant_name' => :'tenantName'
66
70
  }
67
71
  end
@@ -84,6 +88,7 @@ module HatchetSdkRest
84
88
  :'role' => :'TenantMemberRole',
85
89
  :'tenant_id' => :'String',
86
90
  :'expires' => :'Time',
91
+ :'can_view_payloads' => :'Boolean',
87
92
  :'tenant_name' => :'String'
88
93
  }
89
94
  end
@@ -140,6 +145,10 @@ module HatchetSdkRest
140
145
  self.expires = nil
141
146
  end
142
147
 
148
+ if attributes.key?(:'can_view_payloads')
149
+ self.can_view_payloads = attributes[:'can_view_payloads']
150
+ end
151
+
143
152
  if attributes.key?(:'tenant_name')
144
153
  self.tenant_name = attributes[:'tenant_name']
145
154
  end
@@ -245,6 +254,7 @@ module HatchetSdkRest
245
254
  role == o.role &&
246
255
  tenant_id == o.tenant_id &&
247
256
  expires == o.expires &&
257
+ can_view_payloads == o.can_view_payloads &&
248
258
  tenant_name == o.tenant_name
249
259
  end
250
260
 
@@ -257,7 +267,7 @@ module HatchetSdkRest
257
267
  # Calculates hash code according to all attributes.
258
268
  # @return [Integer] Hash code
259
269
  def hash
260
- [metadata, email, role, tenant_id, expires, tenant_name].hash
270
+ [metadata, email, role, tenant_id, expires, can_view_payloads, tenant_name].hash
261
271
  end
262
272
 
263
273
  # Builds the object from hash
@@ -23,6 +23,9 @@ module HatchetSdkRest
23
23
  # The role of the user in the tenant.
24
24
  attr_accessor :role
25
25
 
26
+ # Whether this member can view task, event, and log payloads in the dashboard and REST API. OWNER and ADMIN always can, regardless of this flag. Defaults to true.
27
+ attr_accessor :can_view_payloads
28
+
26
29
  # The tenant associated with this tenant member.
27
30
  attr_accessor :tenant
28
31
 
@@ -57,6 +60,7 @@ module HatchetSdkRest
57
60
  :'metadata' => :'metadata',
58
61
  :'user' => :'user',
59
62
  :'role' => :'role',
63
+ :'can_view_payloads' => :'canViewPayloads',
60
64
  :'tenant' => :'tenant',
61
65
  :'manually_added' => :'manually_added'
62
66
  }
@@ -78,6 +82,7 @@ module HatchetSdkRest
78
82
  :'metadata' => :'APIResourceMeta',
79
83
  :'user' => :'UserTenantPublic',
80
84
  :'role' => :'TenantMemberRole',
85
+ :'can_view_payloads' => :'Boolean',
81
86
  :'tenant' => :'Tenant',
82
87
  :'manually_added' => :'Boolean'
83
88
  }
@@ -123,6 +128,10 @@ module HatchetSdkRest
123
128
  self.role = nil
124
129
  end
125
130
 
131
+ if attributes.key?(:'can_view_payloads')
132
+ self.can_view_payloads = attributes[:'can_view_payloads']
133
+ end
134
+
126
135
  if attributes.key?(:'tenant')
127
136
  self.tenant = attributes[:'tenant']
128
137
  end
@@ -200,6 +209,7 @@ module HatchetSdkRest
200
209
  metadata == o.metadata &&
201
210
  user == o.user &&
202
211
  role == o.role &&
212
+ can_view_payloads == o.can_view_payloads &&
203
213
  tenant == o.tenant &&
204
214
  manually_added == o.manually_added
205
215
  end
@@ -213,7 +223,7 @@ module HatchetSdkRest
213
223
  # Calculates hash code according to all attributes.
214
224
  # @return [Integer] Hash code
215
225
  def hash
216
- [metadata, user, role, tenant, manually_added].hash
226
+ [metadata, user, role, can_view_payloads, tenant, manually_added].hash
217
227
  end
218
228
 
219
229
  # Builds the object from hash