worker_ruby 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +201 -0
  3. data/README.md +118 -0
  4. data/VERSION +1 -0
  5. data/VERSION.txt +1 -0
  6. data/docs/Complete.md +10 -0
  7. data/docs/CoreApi.md +200 -0
  8. data/docs/Error.md +8 -0
  9. data/docs/ErrorBody.md +9 -0
  10. data/docs/Group.md +12 -0
  11. data/docs/GroupWrapper.md +8 -0
  12. data/docs/GroupsApi.md +197 -0
  13. data/docs/GroupsWrapper.md +8 -0
  14. data/docs/IdStatus.md +9 -0
  15. data/docs/Image.md +10 -0
  16. data/docs/ImageWrapper.md +8 -0
  17. data/docs/ImagesApi.md +98 -0
  18. data/docs/ImagesWrapper.md +8 -0
  19. data/docs/Job.md +25 -0
  20. data/docs/JobWrapper.md +8 -0
  21. data/docs/JobsApi.md +684 -0
  22. data/docs/JobsWrapper.md +10 -0
  23. data/docs/Log.md +8 -0
  24. data/docs/NewJob.md +14 -0
  25. data/docs/NewJobWithImage.md +15 -0
  26. data/docs/NewJobsWrapper.md +8 -0
  27. data/docs/NewTask.md +14 -0
  28. data/docs/NewTasksWrapper.md +8 -0
  29. data/docs/Reason.md +7 -0
  30. data/docs/RunnerApi.md +170 -0
  31. data/docs/Start.md +8 -0
  32. data/docs/Task.md +25 -0
  33. data/docs/TaskWrapper.md +8 -0
  34. data/docs/TasksApi.md +684 -0
  35. data/docs/TasksWrapper.md +10 -0
  36. data/git_push.sh +67 -0
  37. data/iron_ruby.gemspec +55 -0
  38. data/iron_titan.gemspec +32 -0
  39. data/lib/iron_ruby.rb +66 -0
  40. data/lib/iron_ruby/api/groups_api.rb +262 -0
  41. data/lib/iron_ruby/api/runner_api.rb +229 -0
  42. data/lib/iron_ruby/api/tasks_api.rb +842 -0
  43. data/lib/iron_ruby/api_client.rb +378 -0
  44. data/lib/iron_ruby/api_error.rb +47 -0
  45. data/lib/iron_ruby/configuration.rb +207 -0
  46. data/lib/iron_ruby/models/complete.rb +220 -0
  47. data/lib/iron_ruby/models/error.rb +199 -0
  48. data/lib/iron_ruby/models/error_body.rb +208 -0
  49. data/lib/iron_ruby/models/group.rb +242 -0
  50. data/lib/iron_ruby/models/group_wrapper.rb +200 -0
  51. data/lib/iron_ruby/models/groups_wrapper.rb +202 -0
  52. data/lib/iron_ruby/models/id_status.rb +243 -0
  53. data/lib/iron_ruby/models/new_task.rb +270 -0
  54. data/lib/iron_ruby/models/new_tasks_wrapper.rb +202 -0
  55. data/lib/iron_ruby/models/start.rb +200 -0
  56. data/lib/iron_ruby/models/task.rb +427 -0
  57. data/lib/iron_ruby/models/task_wrapper.rb +200 -0
  58. data/lib/iron_ruby/models/tasks_wrapper.rb +221 -0
  59. data/lib/iron_ruby/version.rb +26 -0
  60. data/lib/iron_titan.rb +66 -0
  61. data/lib/iron_titan/api/core_api.rb +260 -0
  62. data/lib/iron_titan/api/groups_api.rb +262 -0
  63. data/lib/iron_titan/api/images_api.rb +138 -0
  64. data/lib/iron_titan/api/jobs_api.rb +842 -0
  65. data/lib/iron_titan/api/runner_api.rb +229 -0
  66. data/lib/iron_titan/api_client.rb +372 -0
  67. data/lib/iron_titan/api_error.rb +47 -0
  68. data/lib/iron_titan/configuration.rb +186 -0
  69. data/lib/iron_titan/models/complete.rb +220 -0
  70. data/lib/iron_titan/models/error.rb +199 -0
  71. data/lib/iron_titan/models/error_body.rb +208 -0
  72. data/lib/iron_titan/models/group.rb +242 -0
  73. data/lib/iron_titan/models/group_wrapper.rb +200 -0
  74. data/lib/iron_titan/models/groups_wrapper.rb +202 -0
  75. data/lib/iron_titan/models/id_status.rb +243 -0
  76. data/lib/iron_titan/models/image.rb +184 -0
  77. data/lib/iron_titan/models/image_wrapper.rb +161 -0
  78. data/lib/iron_titan/models/images_wrapper.rb +163 -0
  79. data/lib/iron_titan/models/job.rb +427 -0
  80. data/lib/iron_titan/models/job_array.rb +160 -0
  81. data/lib/iron_titan/models/job_wrapper.rb +200 -0
  82. data/lib/iron_titan/models/jobs_wrapper.rb +221 -0
  83. data/lib/iron_titan/models/log.rb +161 -0
  84. data/lib/iron_titan/models/new_job.rb +270 -0
  85. data/lib/iron_titan/models/new_job_array.rb +160 -0
  86. data/lib/iron_titan/models/new_job_with_image.rb +249 -0
  87. data/lib/iron_titan/models/new_jobs_wrapper.rb +202 -0
  88. data/lib/iron_titan/models/reason.rb +164 -0
  89. data/lib/iron_titan/models/start.rb +200 -0
  90. data/lib/iron_titan/version.rb +26 -0
  91. data/lib/worker_ruby.rb +66 -0
  92. data/lib/worker_ruby/api/groups_api.rb +262 -0
  93. data/lib/worker_ruby/api/runner_api.rb +229 -0
  94. data/lib/worker_ruby/api/tasks_api.rb +842 -0
  95. data/lib/worker_ruby/api_client.rb +378 -0
  96. data/lib/worker_ruby/api_error.rb +47 -0
  97. data/lib/worker_ruby/configuration.rb +207 -0
  98. data/lib/worker_ruby/models/complete.rb +220 -0
  99. data/lib/worker_ruby/models/error.rb +199 -0
  100. data/lib/worker_ruby/models/error_body.rb +208 -0
  101. data/lib/worker_ruby/models/group.rb +242 -0
  102. data/lib/worker_ruby/models/group_wrapper.rb +200 -0
  103. data/lib/worker_ruby/models/groups_wrapper.rb +202 -0
  104. data/lib/worker_ruby/models/id_status.rb +243 -0
  105. data/lib/worker_ruby/models/new_task.rb +270 -0
  106. data/lib/worker_ruby/models/new_tasks_wrapper.rb +202 -0
  107. data/lib/worker_ruby/models/start.rb +200 -0
  108. data/lib/worker_ruby/models/task.rb +427 -0
  109. data/lib/worker_ruby/models/task_wrapper.rb +200 -0
  110. data/lib/worker_ruby/models/tasks_wrapper.rb +221 -0
  111. data/lib/worker_ruby/version.rb +26 -0
  112. data/spec/api/CoreApi_spec.rb +99 -0
  113. data/spec/api/JobsApi_spec.rb +131 -0
  114. data/spec/api/core_api_spec.rb +99 -0
  115. data/spec/api/groups_api_spec.rb +94 -0
  116. data/spec/api/images_api_spec.rb +66 -0
  117. data/spec/api/jobs_api_spec.rb +220 -0
  118. data/spec/api/runner_api_spec.rb +88 -0
  119. data/spec/api/tasks_api_spec.rb +220 -0
  120. data/spec/api_client_spec.rb +237 -0
  121. data/spec/configuration_spec.rb +53 -0
  122. data/spec/models/ErrorBody_spec.rb +56 -0
  123. data/spec/models/JobArray_spec.rb +46 -0
  124. data/spec/models/JobWrapper_spec.rb +46 -0
  125. data/spec/models/NewJobArray_spec.rb +46 -0
  126. data/spec/models/NewJob_spec.rb +96 -0
  127. data/spec/models/complete_spec.rb +65 -0
  128. data/spec/models/error_body_spec.rb +59 -0
  129. data/spec/models/error_spec.rb +53 -0
  130. data/spec/models/group_spec.rb +77 -0
  131. data/spec/models/group_wrapper_spec.rb +53 -0
  132. data/spec/models/groups_wrapper_spec.rb +53 -0
  133. data/spec/models/id_status_spec.rb +63 -0
  134. data/spec/models/image_spec.rb +66 -0
  135. data/spec/models/image_wrapper_spec.rb +46 -0
  136. data/spec/models/images_wrapper_spec.rb +46 -0
  137. data/spec/models/job_array_spec.rb +46 -0
  138. data/spec/models/job_spec.rb +161 -0
  139. data/spec/models/job_wrapper_spec.rb +53 -0
  140. data/spec/models/jobs_wrapper_spec.rb +65 -0
  141. data/spec/models/log_spec.rb +46 -0
  142. data/spec/models/new_job_array_spec.rb +46 -0
  143. data/spec/models/new_job_spec.rb +89 -0
  144. data/spec/models/new_job_with_image_spec.rb +116 -0
  145. data/spec/models/new_jobs_wrapper_spec.rb +53 -0
  146. data/spec/models/new_task_spec.rb +89 -0
  147. data/spec/models/new_tasks_wrapper_spec.rb +53 -0
  148. data/spec/models/reason_spec.rb +36 -0
  149. data/spec/models/start_spec.rb +53 -0
  150. data/spec/models/task_spec.rb +163 -0
  151. data/spec/models/task_wrapper_spec.rb +53 -0
  152. data/spec/models/tasks_wrapper_spec.rb +65 -0
  153. data/spec/spec_helper.rb +122 -0
  154. data/worker_ruby-0.5.5.gem +0 -0
  155. data/worker_ruby.gemspec +55 -0
  156. metadata +420 -0
@@ -0,0 +1,202 @@
1
+ =begin
2
+ #IronWorker CE API
3
+
4
+ #The ultimate, language agnostic, container based task processing framework.
5
+
6
+ OpenAPI spec version: 0.5.7
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+
26
+ module IronWorker
27
+
28
+ class NewTasksWrapper
29
+ attr_accessor :tasks
30
+
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'tasks' => :'tasks'
36
+ }
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.swagger_types
41
+ {
42
+ :'tasks' => :'Array<NewTask>'
43
+ }
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ return unless attributes.is_a?(Hash)
50
+
51
+ # convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
53
+
54
+ if attributes.has_key?(:'tasks')
55
+ if (value = attributes[:'tasks']).is_a?(Array)
56
+ self.tasks = value
57
+ end
58
+ end
59
+
60
+ end
61
+
62
+ # Show invalid properties with the reasons. Usually used together with valid?
63
+ # @return Array for valid properies with the reasons
64
+ def list_invalid_properties
65
+ invalid_properties = Array.new
66
+ return invalid_properties
67
+ end
68
+
69
+ # Check to see if the all the properties in the model are valid
70
+ # @return true if the model is valid
71
+ def valid?
72
+ return false if @tasks.nil?
73
+ return true
74
+ end
75
+
76
+ # Checks equality by comparing each attribute.
77
+ # @param [Object] Object to be compared
78
+ def ==(o)
79
+ return true if self.equal?(o)
80
+ self.class == o.class &&
81
+ tasks == o.tasks
82
+ end
83
+
84
+ # @see the `==` method
85
+ # @param [Object] Object to be compared
86
+ def eql?(o)
87
+ self == o
88
+ end
89
+
90
+ # Calculates hash code according to all attributes.
91
+ # @return [Fixnum] Hash code
92
+ def hash
93
+ [tasks].hash
94
+ end
95
+
96
+ # Builds the object from hash
97
+ # @param [Hash] attributes Model attributes in the form of hash
98
+ # @return [Object] Returns the model itself
99
+ def build_from_hash(attributes)
100
+ return nil unless attributes.is_a?(Hash)
101
+ self.class.swagger_types.each_pair do |key, type|
102
+ if type =~ /^Array<(.*)>/i
103
+ # check to ensure the input is an array given that the the attribute
104
+ # is documented as an array but the input is not
105
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
106
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
107
+ end
108
+ elsif !attributes[self.class.attribute_map[key]].nil?
109
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
110
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
111
+ end
112
+
113
+ self
114
+ end
115
+
116
+ # Deserializes the data based on type
117
+ # @param string type Data type
118
+ # @param string value Value to be deserialized
119
+ # @return [Object] Deserialized data
120
+ def _deserialize(type, value)
121
+ case type.to_sym
122
+ when :DateTime
123
+ DateTime.parse(value)
124
+ when :Date
125
+ Date.parse(value)
126
+ when :String
127
+ value.to_s
128
+ when :Integer
129
+ value.to_i
130
+ when :Float
131
+ value.to_f
132
+ when :BOOLEAN
133
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
134
+ true
135
+ else
136
+ false
137
+ end
138
+ when :Object
139
+ # generic object (usually a Hash), return directly
140
+ value
141
+ when /\AArray<(?<inner_type>.+)>\z/
142
+ inner_type = Regexp.last_match[:inner_type]
143
+ value.map { |v| _deserialize(inner_type, v) }
144
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
145
+ k_type = Regexp.last_match[:k_type]
146
+ v_type = Regexp.last_match[:v_type]
147
+ {}.tap do |hash|
148
+ value.each do |k, v|
149
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
150
+ end
151
+ end
152
+ else # model
153
+ temp_model = IronWorker.const_get(type).new
154
+ temp_model.build_from_hash(value)
155
+ end
156
+ end
157
+
158
+ # Returns the string representation of the object
159
+ # @return [String] String presentation of the object
160
+ def to_s
161
+ to_hash.to_s
162
+ end
163
+
164
+ # to_body is an alias to to_hash (backward compatibility)
165
+ # @return [Hash] Returns the object in the form of hash
166
+ def to_body
167
+ to_hash
168
+ end
169
+
170
+ # Returns the object in the form of hash
171
+ # @return [Hash] Returns the object in the form of hash
172
+ def to_hash
173
+ hash = {}
174
+ self.class.attribute_map.each_pair do |attr, param|
175
+ value = self.send(attr)
176
+ next if value.nil?
177
+ hash[param] = _to_hash(value)
178
+ end
179
+ hash
180
+ end
181
+
182
+ # Outputs non-array value in the form of hash
183
+ # For object, use to_hash. Otherwise, just return the value
184
+ # @param [Object] value Any valid value
185
+ # @return [Hash] Returns the value in the form of hash
186
+ def _to_hash(value)
187
+ if value.is_a?(Array)
188
+ value.compact.map{ |v| _to_hash(v) }
189
+ elsif value.is_a?(Hash)
190
+ {}.tap do |hash|
191
+ value.each { |k, v| hash[k] = _to_hash(v) }
192
+ end
193
+ elsif value.respond_to? :to_hash
194
+ value.to_hash
195
+ else
196
+ value
197
+ end
198
+ end
199
+
200
+ end
201
+
202
+ end
@@ -0,0 +1,200 @@
1
+ =begin
2
+ #IronWorker CE API
3
+
4
+ #The ultimate, language agnostic, container based task processing framework.
5
+
6
+ OpenAPI spec version: 0.5.7
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+
26
+ module IronWorker
27
+
28
+ class Start
29
+ # Time when task started execution. Always in UTC.
30
+ attr_accessor :started_at
31
+
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'started_at' => :'started_at'
37
+ }
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.swagger_types
42
+ {
43
+ :'started_at' => :'DateTime'
44
+ }
45
+ end
46
+
47
+ # Initializes the object
48
+ # @param [Hash] attributes Model attributes in the form of hash
49
+ def initialize(attributes = {})
50
+ return unless attributes.is_a?(Hash)
51
+
52
+ # convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
54
+
55
+ if attributes.has_key?(:'started_at')
56
+ self.started_at = attributes[:'started_at']
57
+ end
58
+
59
+ end
60
+
61
+ # Show invalid properties with the reasons. Usually used together with valid?
62
+ # @return Array for valid properies with the reasons
63
+ def list_invalid_properties
64
+ invalid_properties = Array.new
65
+ return invalid_properties
66
+ end
67
+
68
+ # Check to see if the all the properties in the model are valid
69
+ # @return true if the model is valid
70
+ def valid?
71
+ return true
72
+ end
73
+
74
+ # Checks equality by comparing each attribute.
75
+ # @param [Object] Object to be compared
76
+ def ==(o)
77
+ return true if self.equal?(o)
78
+ self.class == o.class &&
79
+ started_at == o.started_at
80
+ end
81
+
82
+ # @see the `==` method
83
+ # @param [Object] Object to be compared
84
+ def eql?(o)
85
+ self == o
86
+ end
87
+
88
+ # Calculates hash code according to all attributes.
89
+ # @return [Fixnum] Hash code
90
+ def hash
91
+ [started_at].hash
92
+ end
93
+
94
+ # Builds the object from hash
95
+ # @param [Hash] attributes Model attributes in the form of hash
96
+ # @return [Object] Returns the model itself
97
+ def build_from_hash(attributes)
98
+ return nil unless attributes.is_a?(Hash)
99
+ self.class.swagger_types.each_pair do |key, type|
100
+ if type =~ /^Array<(.*)>/i
101
+ # check to ensure the input is an array given that the the attribute
102
+ # is documented as an array but the input is not
103
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
104
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
105
+ end
106
+ elsif !attributes[self.class.attribute_map[key]].nil?
107
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
108
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
109
+ end
110
+
111
+ self
112
+ end
113
+
114
+ # Deserializes the data based on type
115
+ # @param string type Data type
116
+ # @param string value Value to be deserialized
117
+ # @return [Object] Deserialized data
118
+ def _deserialize(type, value)
119
+ case type.to_sym
120
+ when :DateTime
121
+ DateTime.parse(value)
122
+ when :Date
123
+ Date.parse(value)
124
+ when :String
125
+ value.to_s
126
+ when :Integer
127
+ value.to_i
128
+ when :Float
129
+ value.to_f
130
+ when :BOOLEAN
131
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
132
+ true
133
+ else
134
+ false
135
+ end
136
+ when :Object
137
+ # generic object (usually a Hash), return directly
138
+ value
139
+ when /\AArray<(?<inner_type>.+)>\z/
140
+ inner_type = Regexp.last_match[:inner_type]
141
+ value.map { |v| _deserialize(inner_type, v) }
142
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
143
+ k_type = Regexp.last_match[:k_type]
144
+ v_type = Regexp.last_match[:v_type]
145
+ {}.tap do |hash|
146
+ value.each do |k, v|
147
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
148
+ end
149
+ end
150
+ else # model
151
+ temp_model = IronWorker.const_get(type).new
152
+ temp_model.build_from_hash(value)
153
+ end
154
+ end
155
+
156
+ # Returns the string representation of the object
157
+ # @return [String] String presentation of the object
158
+ def to_s
159
+ to_hash.to_s
160
+ end
161
+
162
+ # to_body is an alias to to_hash (backward compatibility)
163
+ # @return [Hash] Returns the object in the form of hash
164
+ def to_body
165
+ to_hash
166
+ end
167
+
168
+ # Returns the object in the form of hash
169
+ # @return [Hash] Returns the object in the form of hash
170
+ def to_hash
171
+ hash = {}
172
+ self.class.attribute_map.each_pair do |attr, param|
173
+ value = self.send(attr)
174
+ next if value.nil?
175
+ hash[param] = _to_hash(value)
176
+ end
177
+ hash
178
+ end
179
+
180
+ # Outputs non-array value in the form of hash
181
+ # For object, use to_hash. Otherwise, just return the value
182
+ # @param [Object] value Any valid value
183
+ # @return [Hash] Returns the value in the form of hash
184
+ def _to_hash(value)
185
+ if value.is_a?(Array)
186
+ value.compact.map{ |v| _to_hash(v) }
187
+ elsif value.is_a?(Hash)
188
+ {}.tap do |hash|
189
+ value.each { |k, v| hash[k] = _to_hash(v) }
190
+ end
191
+ elsif value.respond_to? :to_hash
192
+ value.to_hash
193
+ else
194
+ value
195
+ end
196
+ end
197
+
198
+ end
199
+
200
+ end
@@ -0,0 +1,427 @@
1
+ =begin
2
+ #IronWorker CE API
3
+
4
+ #The ultimate, language agnostic, container based task processing framework.
5
+
6
+ OpenAPI spec version: 0.5.7
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+
26
+ module IronWorker
27
+
28
+ class Task
29
+ # Name of Docker image to use. This is optional and can be used to override the image defined at the group level.
30
+ attr_accessor :image
31
+
32
+ # Payload for the task. This is what you pass into each task to make it do something.
33
+ attr_accessor :payload
34
+
35
+ # Number of seconds to wait before queueing the task for consumption for the first time. Must be a positive integer. Tasks with a delay start in state \"delayed\" and transition to \"running\" after delay seconds.
36
+ attr_accessor :delay
37
+
38
+ # Maximum runtime in seconds. If a consumer retrieves the task, but does not change it's status within timeout seconds, the task is considered failed, with reason timeout (Titan may allow a small grace period). The consumer should also kill the task after timeout seconds. If a consumer tries to change status after Titan has already timed out the task, the consumer will be ignored.
39
+ attr_accessor :timeout
40
+
41
+ # Priority of the task. Higher has more priority. 3 levels from 0-2. Tasks at same priority are processed in FIFO order.
42
+ attr_accessor :priority
43
+
44
+ # \"Number of automatic retries this task is allowed. A retry will be attempted if a task fails. Max 25. Automatic retries are performed by titan when a task reaches a failed state and has `max_retries` > 0. A retry is performed by queueing a new task with the same image id and payload. The new task's max_retries is one less than the original. The new task's `retry_of` field is set to the original Task ID. The old task's `retry_at` field is set to the new Task's ID. Titan will delay the new task for retries_delay seconds before queueing it. Cancelled or successful tasks are never automatically retried.\"
45
+ attr_accessor :max_retries
46
+
47
+ # Time in seconds to wait before retrying the task. Must be a non-negative integer.
48
+ attr_accessor :retries_delay
49
+
50
+ # Unique identifier representing a specific task.
51
+ attr_accessor :id
52
+
53
+ # States and valid transitions. +---------+ +---------> delayed <----------------+ +----+----+ | | | | | +----v----+ | +---------> queued <----------------+ +----+----+ * | * | retry * creates new task +----v----+ * | running | * +--+-+-+--+ | +---------|-|-|-----+-------------+ +---|---------+ | +-----|---------+ | | | | | | | +-----v---^-+ +--v-------^+ +--v---^-+ | success | | cancelled | | error | +-----------+ +-----------+ +--------+ * delayed - has a delay. * queued - Ready to be consumed when it's turn comes. * running - Currently consumed by a runner which will attempt to process it. * success - (or complete? success/error is common javascript terminology) * error - Something went wrong. In this case more information can be obtained by inspecting the \"reason\" field. - timeout - killed - forcibly killed by worker due to resource restrictions or access violations. - bad_exit - exited with non-zero status due to program termination/crash. * cancelled - cancelled via API. More information in the reason field. - client_request - Request was cancelled by a client.
54
+ attr_accessor :status
55
+
56
+ # Group this task belongs to.
57
+ attr_accessor :group_name
58
+
59
+ # The error message, if status is 'error'. This is errors due to things outside the task itself. Errors from user code will be found in the log.
60
+ attr_accessor :error
61
+
62
+ # Machine usable reason for task being in this state. Valid values for error status are `timeout | killed | bad_exit`. Valid values for cancelled status are `client_request`. For everything else, this is undefined.
63
+ attr_accessor :reason
64
+
65
+ # Time when task was submitted. Always in UTC.
66
+ attr_accessor :created_at
67
+
68
+ # Time when task started execution. Always in UTC.
69
+ attr_accessor :started_at
70
+
71
+ # Time when task completed, whether it was successul or failed. Always in UTC.
72
+ attr_accessor :completed_at
73
+
74
+ # If this field is set, then this task is a retry of the ID in this field.
75
+ attr_accessor :retry_of
76
+
77
+ # If this field is set, then this task was retried by the task referenced in this field.
78
+ attr_accessor :retry_at
79
+
80
+ # Env vars for the task. Comes from the ones set on the Group.
81
+ attr_accessor :env_vars
82
+
83
+ class EnumAttributeValidator
84
+ attr_reader :datatype
85
+ attr_reader :allowable_values
86
+
87
+ def initialize(datatype, allowable_values)
88
+ @allowable_values = allowable_values.map do |value|
89
+ case datatype.to_s
90
+ when /Integer/i
91
+ value.to_i
92
+ when /Float/i
93
+ value.to_f
94
+ else
95
+ value
96
+ end
97
+ end
98
+ end
99
+
100
+ def valid?(value)
101
+ !value || allowable_values.include?(value)
102
+ end
103
+ end
104
+
105
+ # Attribute mapping from ruby-style variable name to JSON key.
106
+ def self.attribute_map
107
+ {
108
+ :'image' => :'image',
109
+ :'payload' => :'payload',
110
+ :'delay' => :'delay',
111
+ :'timeout' => :'timeout',
112
+ :'priority' => :'priority',
113
+ :'max_retries' => :'max_retries',
114
+ :'retries_delay' => :'retries_delay',
115
+ :'id' => :'id',
116
+ :'status' => :'status',
117
+ :'group_name' => :'group_name',
118
+ :'error' => :'error',
119
+ :'reason' => :'reason',
120
+ :'created_at' => :'created_at',
121
+ :'started_at' => :'started_at',
122
+ :'completed_at' => :'completed_at',
123
+ :'retry_of' => :'retry_of',
124
+ :'retry_at' => :'retry_at',
125
+ :'env_vars' => :'env_vars'
126
+ }
127
+ end
128
+
129
+ # Attribute type mapping.
130
+ def self.swagger_types
131
+ {
132
+ :'image' => :'String',
133
+ :'payload' => :'String',
134
+ :'delay' => :'Integer',
135
+ :'timeout' => :'Integer',
136
+ :'priority' => :'Integer',
137
+ :'max_retries' => :'Integer',
138
+ :'retries_delay' => :'Integer',
139
+ :'id' => :'String',
140
+ :'status' => :'String',
141
+ :'group_name' => :'String',
142
+ :'error' => :'String',
143
+ :'reason' => :'String',
144
+ :'created_at' => :'DateTime',
145
+ :'started_at' => :'DateTime',
146
+ :'completed_at' => :'DateTime',
147
+ :'retry_of' => :'String',
148
+ :'retry_at' => :'String',
149
+ :'env_vars' => :'Hash<String, String>'
150
+ }
151
+ end
152
+
153
+ # Initializes the object
154
+ # @param [Hash] attributes Model attributes in the form of hash
155
+ def initialize(attributes = {})
156
+ return unless attributes.is_a?(Hash)
157
+
158
+ # convert string to symbol for hash key
159
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
160
+
161
+ if attributes.has_key?(:'image')
162
+ self.image = attributes[:'image']
163
+ end
164
+
165
+ if attributes.has_key?(:'payload')
166
+ self.payload = attributes[:'payload']
167
+ end
168
+
169
+ if attributes.has_key?(:'delay')
170
+ self.delay = attributes[:'delay']
171
+ else
172
+ self.delay = 0
173
+ end
174
+
175
+ if attributes.has_key?(:'timeout')
176
+ self.timeout = attributes[:'timeout']
177
+ else
178
+ self.timeout = 60
179
+ end
180
+
181
+ if attributes.has_key?(:'priority')
182
+ self.priority = attributes[:'priority']
183
+ end
184
+
185
+ if attributes.has_key?(:'max_retries')
186
+ self.max_retries = attributes[:'max_retries']
187
+ else
188
+ self.max_retries = 0
189
+ end
190
+
191
+ if attributes.has_key?(:'retries_delay')
192
+ self.retries_delay = attributes[:'retries_delay']
193
+ else
194
+ self.retries_delay = 60
195
+ end
196
+
197
+ if attributes.has_key?(:'id')
198
+ self.id = attributes[:'id']
199
+ end
200
+
201
+ if attributes.has_key?(:'status')
202
+ self.status = attributes[:'status']
203
+ end
204
+
205
+ if attributes.has_key?(:'group_name')
206
+ self.group_name = attributes[:'group_name']
207
+ end
208
+
209
+ if attributes.has_key?(:'error')
210
+ self.error = attributes[:'error']
211
+ end
212
+
213
+ if attributes.has_key?(:'reason')
214
+ self.reason = attributes[:'reason']
215
+ end
216
+
217
+ if attributes.has_key?(:'created_at')
218
+ self.created_at = attributes[:'created_at']
219
+ end
220
+
221
+ if attributes.has_key?(:'started_at')
222
+ self.started_at = attributes[:'started_at']
223
+ end
224
+
225
+ if attributes.has_key?(:'completed_at')
226
+ self.completed_at = attributes[:'completed_at']
227
+ end
228
+
229
+ if attributes.has_key?(:'retry_of')
230
+ self.retry_of = attributes[:'retry_of']
231
+ end
232
+
233
+ if attributes.has_key?(:'retry_at')
234
+ self.retry_at = attributes[:'retry_at']
235
+ end
236
+
237
+ if attributes.has_key?(:'env_vars')
238
+ if (value = attributes[:'env_vars']).is_a?(Array)
239
+ self.env_vars = value
240
+ end
241
+ end
242
+
243
+ end
244
+
245
+ # Show invalid properties with the reasons. Usually used together with valid?
246
+ # @return Array for valid properies with the reasons
247
+ def list_invalid_properties
248
+ invalid_properties = Array.new
249
+ return invalid_properties
250
+ end
251
+
252
+ # Check to see if the all the properties in the model are valid
253
+ # @return true if the model is valid
254
+ def valid?
255
+ return false if @image.nil?
256
+ return false if @priority.nil?
257
+ status_validator = EnumAttributeValidator.new('String', ["delayed", "queued", "running", "success", "error", "cancelled"])
258
+ return false unless status_validator.valid?(@status)
259
+ reason_validator = EnumAttributeValidator.new('String', ["timeout", "killed", "bad_exit", "client_request"])
260
+ return false unless reason_validator.valid?(@reason)
261
+ return true
262
+ end
263
+
264
+ # Custom attribute writer method checking allowed values (enum).
265
+ # @param [Object] status Object to be assigned
266
+ def status=(status)
267
+ validator = EnumAttributeValidator.new('String', ["delayed", "queued", "running", "success", "error", "cancelled"])
268
+ unless validator.valid?(status)
269
+ fail ArgumentError, "invalid value for 'status', must be one of #{validator.allowable_values}."
270
+ end
271
+ @status = status
272
+ end
273
+
274
+ # Custom attribute writer method checking allowed values (enum).
275
+ # @param [Object] reason Object to be assigned
276
+ def reason=(reason)
277
+ validator = EnumAttributeValidator.new('String', ["timeout", "killed", "bad_exit", "client_request"])
278
+ unless validator.valid?(reason)
279
+ fail ArgumentError, "invalid value for 'reason', must be one of #{validator.allowable_values}."
280
+ end
281
+ @reason = reason
282
+ end
283
+
284
+ # Checks equality by comparing each attribute.
285
+ # @param [Object] Object to be compared
286
+ def ==(o)
287
+ return true if self.equal?(o)
288
+ self.class == o.class &&
289
+ image == o.image &&
290
+ payload == o.payload &&
291
+ delay == o.delay &&
292
+ timeout == o.timeout &&
293
+ priority == o.priority &&
294
+ max_retries == o.max_retries &&
295
+ retries_delay == o.retries_delay &&
296
+ id == o.id &&
297
+ status == o.status &&
298
+ group_name == o.group_name &&
299
+ error == o.error &&
300
+ reason == o.reason &&
301
+ created_at == o.created_at &&
302
+ started_at == o.started_at &&
303
+ completed_at == o.completed_at &&
304
+ retry_of == o.retry_of &&
305
+ retry_at == o.retry_at &&
306
+ env_vars == o.env_vars
307
+ end
308
+
309
+ # @see the `==` method
310
+ # @param [Object] Object to be compared
311
+ def eql?(o)
312
+ self == o
313
+ end
314
+
315
+ # Calculates hash code according to all attributes.
316
+ # @return [Fixnum] Hash code
317
+ def hash
318
+ [image, payload, delay, timeout, priority, max_retries, retries_delay, id, status, group_name, error, reason, created_at, started_at, completed_at, retry_of, retry_at, env_vars].hash
319
+ end
320
+
321
+ # Builds the object from hash
322
+ # @param [Hash] attributes Model attributes in the form of hash
323
+ # @return [Object] Returns the model itself
324
+ def build_from_hash(attributes)
325
+ return nil unless attributes.is_a?(Hash)
326
+ self.class.swagger_types.each_pair do |key, type|
327
+ if type =~ /^Array<(.*)>/i
328
+ # check to ensure the input is an array given that the the attribute
329
+ # is documented as an array but the input is not
330
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
331
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
332
+ end
333
+ elsif !attributes[self.class.attribute_map[key]].nil?
334
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
335
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
336
+ end
337
+
338
+ self
339
+ end
340
+
341
+ # Deserializes the data based on type
342
+ # @param string type Data type
343
+ # @param string value Value to be deserialized
344
+ # @return [Object] Deserialized data
345
+ def _deserialize(type, value)
346
+ case type.to_sym
347
+ when :DateTime
348
+ DateTime.parse(value)
349
+ when :Date
350
+ Date.parse(value)
351
+ when :String
352
+ value.to_s
353
+ when :Integer
354
+ value.to_i
355
+ when :Float
356
+ value.to_f
357
+ when :BOOLEAN
358
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
359
+ true
360
+ else
361
+ false
362
+ end
363
+ when :Object
364
+ # generic object (usually a Hash), return directly
365
+ value
366
+ when /\AArray<(?<inner_type>.+)>\z/
367
+ inner_type = Regexp.last_match[:inner_type]
368
+ value.map { |v| _deserialize(inner_type, v) }
369
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
370
+ k_type = Regexp.last_match[:k_type]
371
+ v_type = Regexp.last_match[:v_type]
372
+ {}.tap do |hash|
373
+ value.each do |k, v|
374
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
375
+ end
376
+ end
377
+ else # model
378
+ temp_model = IronWorker.const_get(type).new
379
+ temp_model.build_from_hash(value)
380
+ end
381
+ end
382
+
383
+ # Returns the string representation of the object
384
+ # @return [String] String presentation of the object
385
+ def to_s
386
+ to_hash.to_s
387
+ end
388
+
389
+ # to_body is an alias to to_hash (backward compatibility)
390
+ # @return [Hash] Returns the object in the form of hash
391
+ def to_body
392
+ to_hash
393
+ end
394
+
395
+ # Returns the object in the form of hash
396
+ # @return [Hash] Returns the object in the form of hash
397
+ def to_hash
398
+ hash = {}
399
+ self.class.attribute_map.each_pair do |attr, param|
400
+ value = self.send(attr)
401
+ next if value.nil?
402
+ hash[param] = _to_hash(value)
403
+ end
404
+ hash
405
+ end
406
+
407
+ # Outputs non-array value in the form of hash
408
+ # For object, use to_hash. Otherwise, just return the value
409
+ # @param [Object] value Any valid value
410
+ # @return [Hash] Returns the value in the form of hash
411
+ def _to_hash(value)
412
+ if value.is_a?(Array)
413
+ value.compact.map{ |v| _to_hash(v) }
414
+ elsif value.is_a?(Hash)
415
+ {}.tap do |hash|
416
+ value.each { |k, v| hash[k] = _to_hash(v) }
417
+ end
418
+ elsif value.respond_to? :to_hash
419
+ value.to_hash
420
+ else
421
+ value
422
+ end
423
+ end
424
+
425
+ end
426
+
427
+ end