hatchet-sdk 0.4.0 → 0.5.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 (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/lib/hatchet/clients/rest/.openapi-generator/FILES +24 -0
  4. data/lib/hatchet/clients/rest/README.md +31 -1
  5. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/durable_tasks_api.rb +113 -0
  6. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/feature_flags_api.rb +107 -0
  7. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/log_api.rb +156 -52
  8. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/observability_api.rb +114 -0
  9. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/rate_limits_api.rb +78 -0
  10. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/task_api.rb +71 -0
  11. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/tenant_api.rb +3 -0
  12. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/worker_api.rb +9 -0
  13. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/workflow_api.rb +170 -0
  14. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/workflow_runs_api.rb +94 -0
  15. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api_model_base.rb +88 -0
  16. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/api_meta.rb +44 -4
  17. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/feature_flag_evaluation_result.rb +238 -0
  18. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/feature_flag_id.rb +41 -0
  19. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/otel_span.rb +525 -0
  20. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/otel_span_kind.rb +44 -0
  21. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/otel_span_list.rb +242 -0
  22. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/otel_status_code.rb +41 -0
  23. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/task_status_stat.rb +13 -4
  24. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant.rb +24 -4
  25. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_member.rb +14 -4
  26. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/trigger_run_result.rb +256 -0
  27. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_additional_metadata_operator.rb +40 -0
  28. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_branch_durable_task_request.rb +310 -0
  29. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_branch_durable_task_response.rb +310 -0
  30. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_create_webhook_request_api_key.rb +14 -4
  31. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_create_webhook_request_base.rb +14 -4
  32. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_create_webhook_request_basic_auth.rb +14 -4
  33. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_create_webhook_request_hmac.rb +14 -4
  34. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_durable_event_log_entry.rb +470 -0
  35. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_durable_event_log_kind.rb +41 -0
  36. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_durable_wait_condition.rb +286 -0
  37. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_durable_wait_condition_kind.rb +41 -0
  38. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_log_line.rb +49 -1
  39. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_logs_point_metric.rb +341 -0
  40. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_logs_point_metrics.rb +222 -0
  41. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_restore_task_response.rb +237 -0
  42. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_running_detail_count.rb +265 -0
  43. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_running_filter.rb +41 -0
  44. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_event_type.rb +3 -1
  45. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_run_metric.rb +13 -4
  46. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_summary.rb +34 -4
  47. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_timing.rb +11 -1
  48. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_trigger_workflow_run_request.rb +14 -4
  49. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_update_webhook_request.rb +14 -4
  50. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_wait_item.rb +280 -0
  51. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_webhook.rb +14 -4
  52. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/worker.rb +1 -13
  53. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/worker_status.rb +41 -0
  54. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_version_idempotency.rb +265 -0
  55. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_version_task.rb +393 -0
  56. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_version_task_desired_worker_label.rb +288 -0
  57. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_version_task_rate_limit.rb +271 -0
  58. data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest.rb +24 -0
  59. data/lib/hatchet/contracts/v1/workflows_pb.rb +3 -1
  60. data/lib/hatchet/idempotency.rb +35 -1
  61. data/lib/hatchet/version.rb +1 -1
  62. data/lib/hatchet/workflow.rb +2 -2
  63. data/sig/hatchet/idempotency.rbs +8 -0
  64. metadata +31 -2
@@ -0,0 +1,256 @@
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 TriggerRunResult
18
+ # The external ID of the triggered workflow run
19
+ attr_accessor :external_id
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'external_id' => :'externalId'
25
+ }
26
+ end
27
+
28
+ # Returns attribute mapping this model knows about
29
+ def self.acceptable_attribute_map
30
+ attribute_map
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ acceptable_attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'external_id' => :'String'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `HatchetSdkRest::TriggerRunResult` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ acceptable_attribute_map = self.class.acceptable_attribute_map
60
+ attributes = attributes.each_with_object({}) { |(k, v), h|
61
+ if (!acceptable_attribute_map.key?(k.to_sym))
62
+ fail ArgumentError, "`#{k}` is not a valid attribute in `HatchetSdkRest::TriggerRunResult`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
63
+ end
64
+ h[k.to_sym] = v
65
+ }
66
+
67
+ if attributes.key?(:'external_id')
68
+ self.external_id = attributes[:'external_id']
69
+ else
70
+ self.external_id = nil
71
+ end
72
+ end
73
+
74
+ # Show invalid properties with the reasons. Usually used together with valid?
75
+ # @return Array for valid properties with the reasons
76
+ def list_invalid_properties
77
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
78
+ invalid_properties = Array.new
79
+ if @external_id.nil?
80
+ invalid_properties.push('invalid value for "external_id", external_id cannot be nil.')
81
+ end
82
+
83
+ if @external_id.to_s.length > 36
84
+ invalid_properties.push('invalid value for "external_id", the character length must be smaller than or equal to 36.')
85
+ end
86
+
87
+ if @external_id.to_s.length < 36
88
+ invalid_properties.push('invalid value for "external_id", the character length must be greater than or equal to 36.')
89
+ end
90
+
91
+ invalid_properties
92
+ end
93
+
94
+ # Check to see if the all the properties in the model are valid
95
+ # @return true if the model is valid
96
+ def valid?
97
+ warn '[DEPRECATED] the `valid?` method is obsolete'
98
+ return false if @external_id.nil?
99
+ return false if @external_id.to_s.length > 36
100
+ return false if @external_id.to_s.length < 36
101
+ true
102
+ end
103
+
104
+ # Custom attribute writer method with validation
105
+ # @param [Object] external_id Value to be assigned
106
+ def external_id=(external_id)
107
+ if external_id.nil?
108
+ fail ArgumentError, 'external_id cannot be nil'
109
+ end
110
+
111
+ if external_id.to_s.length > 36
112
+ fail ArgumentError, 'invalid value for "external_id", the character length must be smaller than or equal to 36.'
113
+ end
114
+
115
+ if external_id.to_s.length < 36
116
+ fail ArgumentError, 'invalid value for "external_id", the character length must be greater than or equal to 36.'
117
+ end
118
+
119
+ @external_id = external_id
120
+ end
121
+
122
+ # Checks equality by comparing each attribute.
123
+ # @param [Object] Object to be compared
124
+ def ==(o)
125
+ return true if self.equal?(o)
126
+ self.class == o.class &&
127
+ external_id == o.external_id
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 [Integer] Hash code
138
+ def hash
139
+ [external_id].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 self.build_from_hash(attributes)
146
+ return nil unless attributes.is_a?(Hash)
147
+ attributes = attributes.transform_keys(&:to_sym)
148
+ transformed_hash = {}
149
+ openapi_types.each_pair do |key, type|
150
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
151
+ transformed_hash["#{key}"] = nil
152
+ elsif type =~ /\AArray<(.*)>/i
153
+ # check to ensure the input is an array given that the attribute
154
+ # is documented as an array but the input is not
155
+ if attributes[attribute_map[key]].is_a?(Array)
156
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
157
+ end
158
+ elsif !attributes[attribute_map[key]].nil?
159
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
160
+ end
161
+ end
162
+ new(transformed_hash)
163
+ end
164
+
165
+ # Deserializes the data based on type
166
+ # @param string type Data type
167
+ # @param string value Value to be deserialized
168
+ # @return [Object] Deserialized data
169
+ def self._deserialize(type, value)
170
+ case type.to_sym
171
+ when :Time
172
+ Time.parse(value)
173
+ when :Date
174
+ Date.parse(value)
175
+ when :String
176
+ value.to_s
177
+ when :Integer
178
+ value.to_i
179
+ when :Float
180
+ value.to_f
181
+ when :Boolean
182
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
183
+ true
184
+ else
185
+ false
186
+ end
187
+ when :Object
188
+ # generic object (usually a Hash), return directly
189
+ value
190
+ when /\AArray<(?<inner_type>.+)>\z/
191
+ inner_type = Regexp.last_match[:inner_type]
192
+ value.map { |v| _deserialize(inner_type, v) }
193
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
194
+ k_type = Regexp.last_match[:k_type]
195
+ v_type = Regexp.last_match[:v_type]
196
+ {}.tap do |hash|
197
+ value.each do |k, v|
198
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
199
+ end
200
+ end
201
+ else # model
202
+ # models (e.g. Pet) or oneOf
203
+ klass = HatchetSdkRest.const_get(type)
204
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
205
+ end
206
+ end
207
+
208
+ # Returns the string representation of the object
209
+ # @return [String] String presentation of the object
210
+ def to_s
211
+ to_hash.to_s
212
+ end
213
+
214
+ # to_body is an alias to to_hash (backward compatibility)
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_body
217
+ to_hash
218
+ end
219
+
220
+ # Returns the object in the form of hash
221
+ # @return [Hash] Returns the object in the form of hash
222
+ def to_hash
223
+ hash = {}
224
+ self.class.attribute_map.each_pair do |attr, param|
225
+ value = self.send(attr)
226
+ if value.nil?
227
+ is_nullable = self.class.openapi_nullable.include?(attr)
228
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
229
+ end
230
+
231
+ hash[param] = _to_hash(value)
232
+ end
233
+ hash
234
+ end
235
+
236
+ # Outputs non-array value in the form of hash
237
+ # For object, use to_hash. Otherwise, just return the value
238
+ # @param [Object] value Any valid value
239
+ # @return [Hash] Returns the value in the form of hash
240
+ def _to_hash(value)
241
+ if value.is_a?(Array)
242
+ value.compact.map { |v| _to_hash(v) }
243
+ elsif value.is_a?(Hash)
244
+ {}.tap do |hash|
245
+ value.each { |k, v| hash[k] = _to_hash(v) }
246
+ end
247
+ elsif value.respond_to? :to_hash
248
+ value.to_hash
249
+ else
250
+ value
251
+ end
252
+ end
253
+
254
+ end
255
+
256
+ end
@@ -0,0 +1,40 @@
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 V1AdditionalMetadataOperator
18
+ OR = "OR".freeze
19
+ AND = "AND".freeze
20
+
21
+ def self.all_vars
22
+ @all_vars ||= [OR, AND].freeze
23
+ end
24
+
25
+ # Builds the enum from string
26
+ # @param [String] The enum value in the form of the string
27
+ # @return [String] The enum value
28
+ def self.build_from_hash(value)
29
+ new.build_from_hash(value)
30
+ end
31
+
32
+ # Builds the enum from string
33
+ # @param [String] The enum value in the form of the string
34
+ # @return [String] The enum value
35
+ def build_from_hash(value)
36
+ return value if V1AdditionalMetadataOperator.all_vars.include?(value)
37
+ raise "Invalid ENUM value #{value} for class #V1AdditionalMetadataOperator"
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,310 @@
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 V1BranchDurableTaskRequest
18
+ # The external id of the durable task to branch.
19
+ attr_accessor :task_external_id
20
+
21
+ # The node id to replay from.
22
+ attr_accessor :node_id
23
+
24
+ # The branch id to replay from.
25
+ attr_accessor :branch_id
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'task_external_id' => :'taskExternalId',
31
+ :'node_id' => :'nodeId',
32
+ :'branch_id' => :'branchId'
33
+ }
34
+ end
35
+
36
+ # Returns attribute mapping this model knows about
37
+ def self.acceptable_attribute_map
38
+ attribute_map
39
+ end
40
+
41
+ # Returns all the JSON keys this model knows about
42
+ def self.acceptable_attributes
43
+ acceptable_attribute_map.values
44
+ end
45
+
46
+ # Attribute type mapping.
47
+ def self.openapi_types
48
+ {
49
+ :'task_external_id' => :'String',
50
+ :'node_id' => :'Integer',
51
+ :'branch_id' => :'Integer'
52
+ }
53
+ end
54
+
55
+ # List of attributes with nullable: true
56
+ def self.openapi_nullable
57
+ Set.new([
58
+ ])
59
+ end
60
+
61
+ # Initializes the object
62
+ # @param [Hash] attributes Model attributes in the form of hash
63
+ def initialize(attributes = {})
64
+ if (!attributes.is_a?(Hash))
65
+ fail ArgumentError, "The input argument (attributes) must be a hash in `HatchetSdkRest::V1BranchDurableTaskRequest` initialize method"
66
+ end
67
+
68
+ # check to see if the attribute exists and convert string to symbol for hash key
69
+ acceptable_attribute_map = self.class.acceptable_attribute_map
70
+ attributes = attributes.each_with_object({}) { |(k, v), h|
71
+ if (!acceptable_attribute_map.key?(k.to_sym))
72
+ fail ArgumentError, "`#{k}` is not a valid attribute in `HatchetSdkRest::V1BranchDurableTaskRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
73
+ end
74
+ h[k.to_sym] = v
75
+ }
76
+
77
+ if attributes.key?(:'task_external_id')
78
+ self.task_external_id = attributes[:'task_external_id']
79
+ else
80
+ self.task_external_id = nil
81
+ end
82
+
83
+ if attributes.key?(:'node_id')
84
+ self.node_id = attributes[:'node_id']
85
+ else
86
+ self.node_id = nil
87
+ end
88
+
89
+ if attributes.key?(:'branch_id')
90
+ self.branch_id = attributes[:'branch_id']
91
+ else
92
+ self.branch_id = 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 @task_external_id.nil?
102
+ invalid_properties.push('invalid value for "task_external_id", task_external_id cannot be nil.')
103
+ end
104
+
105
+ if @task_external_id.to_s.length > 36
106
+ invalid_properties.push('invalid value for "task_external_id", the character length must be smaller than or equal to 36.')
107
+ end
108
+
109
+ if @task_external_id.to_s.length < 36
110
+ invalid_properties.push('invalid value for "task_external_id", the character length must be greater than or equal to 36.')
111
+ end
112
+
113
+ if @node_id.nil?
114
+ invalid_properties.push('invalid value for "node_id", node_id cannot be nil.')
115
+ end
116
+
117
+ if @branch_id.nil?
118
+ invalid_properties.push('invalid value for "branch_id", branch_id cannot be nil.')
119
+ end
120
+
121
+ invalid_properties
122
+ end
123
+
124
+ # Check to see if the all the properties in the model are valid
125
+ # @return true if the model is valid
126
+ def valid?
127
+ warn '[DEPRECATED] the `valid?` method is obsolete'
128
+ return false if @task_external_id.nil?
129
+ return false if @task_external_id.to_s.length > 36
130
+ return false if @task_external_id.to_s.length < 36
131
+ return false if @node_id.nil?
132
+ return false if @branch_id.nil?
133
+ true
134
+ end
135
+
136
+ # Custom attribute writer method with validation
137
+ # @param [Object] task_external_id Value to be assigned
138
+ def task_external_id=(task_external_id)
139
+ if task_external_id.nil?
140
+ fail ArgumentError, 'task_external_id cannot be nil'
141
+ end
142
+
143
+ if task_external_id.to_s.length > 36
144
+ fail ArgumentError, 'invalid value for "task_external_id", the character length must be smaller than or equal to 36.'
145
+ end
146
+
147
+ if task_external_id.to_s.length < 36
148
+ fail ArgumentError, 'invalid value for "task_external_id", the character length must be greater than or equal to 36.'
149
+ end
150
+
151
+ @task_external_id = task_external_id
152
+ end
153
+
154
+ # Custom attribute writer method with validation
155
+ # @param [Object] node_id Value to be assigned
156
+ def node_id=(node_id)
157
+ if node_id.nil?
158
+ fail ArgumentError, 'node_id cannot be nil'
159
+ end
160
+
161
+ @node_id = node_id
162
+ end
163
+
164
+ # Custom attribute writer method with validation
165
+ # @param [Object] branch_id Value to be assigned
166
+ def branch_id=(branch_id)
167
+ if branch_id.nil?
168
+ fail ArgumentError, 'branch_id cannot be nil'
169
+ end
170
+
171
+ @branch_id = branch_id
172
+ end
173
+
174
+ # Checks equality by comparing each attribute.
175
+ # @param [Object] Object to be compared
176
+ def ==(o)
177
+ return true if self.equal?(o)
178
+ self.class == o.class &&
179
+ task_external_id == o.task_external_id &&
180
+ node_id == o.node_id &&
181
+ branch_id == o.branch_id
182
+ end
183
+
184
+ # @see the `==` method
185
+ # @param [Object] Object to be compared
186
+ def eql?(o)
187
+ self == o
188
+ end
189
+
190
+ # Calculates hash code according to all attributes.
191
+ # @return [Integer] Hash code
192
+ def hash
193
+ [task_external_id, node_id, branch_id].hash
194
+ end
195
+
196
+ # Builds the object from hash
197
+ # @param [Hash] attributes Model attributes in the form of hash
198
+ # @return [Object] Returns the model itself
199
+ def self.build_from_hash(attributes)
200
+ return nil unless attributes.is_a?(Hash)
201
+ attributes = attributes.transform_keys(&:to_sym)
202
+ transformed_hash = {}
203
+ openapi_types.each_pair do |key, type|
204
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
205
+ transformed_hash["#{key}"] = nil
206
+ elsif type =~ /\AArray<(.*)>/i
207
+ # check to ensure the input is an array given that the attribute
208
+ # is documented as an array but the input is not
209
+ if attributes[attribute_map[key]].is_a?(Array)
210
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
211
+ end
212
+ elsif !attributes[attribute_map[key]].nil?
213
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
214
+ end
215
+ end
216
+ new(transformed_hash)
217
+ end
218
+
219
+ # Deserializes the data based on type
220
+ # @param string type Data type
221
+ # @param string value Value to be deserialized
222
+ # @return [Object] Deserialized data
223
+ def self._deserialize(type, value)
224
+ case type.to_sym
225
+ when :Time
226
+ Time.parse(value)
227
+ when :Date
228
+ Date.parse(value)
229
+ when :String
230
+ value.to_s
231
+ when :Integer
232
+ value.to_i
233
+ when :Float
234
+ value.to_f
235
+ when :Boolean
236
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
237
+ true
238
+ else
239
+ false
240
+ end
241
+ when :Object
242
+ # generic object (usually a Hash), return directly
243
+ value
244
+ when /\AArray<(?<inner_type>.+)>\z/
245
+ inner_type = Regexp.last_match[:inner_type]
246
+ value.map { |v| _deserialize(inner_type, v) }
247
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
248
+ k_type = Regexp.last_match[:k_type]
249
+ v_type = Regexp.last_match[:v_type]
250
+ {}.tap do |hash|
251
+ value.each do |k, v|
252
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
253
+ end
254
+ end
255
+ else # model
256
+ # models (e.g. Pet) or oneOf
257
+ klass = HatchetSdkRest.const_get(type)
258
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
259
+ end
260
+ end
261
+
262
+ # Returns the string representation of the object
263
+ # @return [String] String presentation of the object
264
+ def to_s
265
+ to_hash.to_s
266
+ end
267
+
268
+ # to_body is an alias to to_hash (backward compatibility)
269
+ # @return [Hash] Returns the object in the form of hash
270
+ def to_body
271
+ to_hash
272
+ end
273
+
274
+ # Returns the object in the form of hash
275
+ # @return [Hash] Returns the object in the form of hash
276
+ def to_hash
277
+ hash = {}
278
+ self.class.attribute_map.each_pair do |attr, param|
279
+ value = self.send(attr)
280
+ if value.nil?
281
+ is_nullable = self.class.openapi_nullable.include?(attr)
282
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
283
+ end
284
+
285
+ hash[param] = _to_hash(value)
286
+ end
287
+ hash
288
+ end
289
+
290
+ # Outputs non-array value in the form of hash
291
+ # For object, use to_hash. Otherwise, just return the value
292
+ # @param [Object] value Any valid value
293
+ # @return [Hash] Returns the value in the form of hash
294
+ def _to_hash(value)
295
+ if value.is_a?(Array)
296
+ value.compact.map { |v| _to_hash(v) }
297
+ elsif value.is_a?(Hash)
298
+ {}.tap do |hash|
299
+ value.each { |k, v| hash[k] = _to_hash(v) }
300
+ end
301
+ elsif value.respond_to? :to_hash
302
+ value.to_hash
303
+ else
304
+ value
305
+ end
306
+ end
307
+
308
+ end
309
+
310
+ end