Class: Conductor::Http::Api::TaskResourceApi
- Inherits:
-
Object
- Object
- Conductor::Http::Api::TaskResourceApi
- Defined in:
- lib/conductor/http/api/task_resource_api.rb
Overview
TaskResourceApi - API for task operations
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#all_queue_details ⇒ Hash<String, Integer>
Get all queue details.
-
#all_verbose ⇒ Hash
Get all queue details (verbose).
-
#batch_poll(task_type, count: 1, timeout: 100, worker_id: nil, domain: nil) ⇒ Array<Task>
Batch poll for tasks.
-
#get_all_poll_data ⇒ Array<PollData>
Get all poll data.
-
#get_pending_task_for_task_type(task_type, start: 0, count: 100) ⇒ Array<Task>
Get pending tasks for a task type.
-
#get_poll_data(task_type) ⇒ Array<PollData>
Get poll data for a task type.
-
#get_queue_sizes_for_tasks(task_types) ⇒ Hash<String, Integer>
Get queue sizes for specific task types.
-
#get_task(task_id) ⇒ Task
Get task details.
-
#get_task_logs(task_id) ⇒ Array<TaskExecLog>
Get task execution logs.
-
#get_task_queue_details(task_type) ⇒ Hash
Get queue details for a task type.
-
#initialize(api_client = nil) ⇒ TaskResourceApi
constructor
Initialize TaskResourceApi.
-
#log(task_id, log) ⇒ void
Add task execution log.
-
#poll(task_type, worker_id: nil, domain: nil) ⇒ Task?
Poll for a task of a certain type.
-
#remove_task_from_queue(task_type, task_id) ⇒ void
Remove task from queue.
-
#requeue_pending_task(task_type) ⇒ String
Requeue pending tasks of a type.
-
#search(start: 0, size: 100, sort: nil, free_text: '*', query: nil) ⇒ SearchResult
Search for tasks.
-
#size(task_types: nil) ⇒ Hash<String, Integer>
Get task queue sizes.
-
#update_task(body) ⇒ String
Update task status.
-
#update_task_by_ref_name(workflow_id, task_ref_name, status, output: nil, worker_id: nil) ⇒ String
Update task by reference name.
-
#update_task_sync(workflow_id, task_ref_name, status, output: nil, worker_id: nil) ⇒ Workflow
Update task by reference name synchronously (returns workflow state).
Constructor Details
#initialize(api_client = nil) ⇒ TaskResourceApi
Initialize TaskResourceApi
14 15 16 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 14 def initialize(api_client = nil) @api_client = api_client || ApiClient.new end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
10 11 12 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 10 def api_client @api_client end |
Instance Method Details
#all_queue_details ⇒ Hash<String, Integer>
Get all queue details
117 118 119 120 121 122 123 124 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 117 def all_queue_details @api_client.call_api( '/tasks/queue/all', 'GET', return_type: 'Hash<String, Integer>', return_http_data_only: true ) end |
#all_verbose ⇒ Hash
Get all queue details (verbose)
236 237 238 239 240 241 242 243 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 236 def all_verbose @api_client.call_api( '/tasks/queue/all/verbose', 'GET', return_type: 'Hash<String, Object>', return_http_data_only: true ) end |
#batch_poll(task_type, count: 1, timeout: 100, worker_id: nil, domain: nil) ⇒ Array<Task>
Batch poll for tasks
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 45 def batch_poll(task_type, count: 1, timeout: 100, worker_id: nil, domain: nil) query_params = { count: [count, 100].min, timeout: timeout } query_params[:workerid] = worker_id if worker_id query_params[:domain] = domain if domain @api_client.call_api( '/tasks/poll/batch/{taskType}', 'GET', path_params: { taskType: task_type }, query_params: query_params, return_type: 'Array<Task>', return_http_data_only: true ) end |
#get_all_poll_data ⇒ Array<PollData>
Get all poll data
276 277 278 279 280 281 282 283 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 276 def get_all_poll_data @api_client.call_api( '/tasks/queue/polldata/all', 'GET', return_type: 'Array<PollData>', return_http_data_only: true ) end |
#get_pending_task_for_task_type(task_type, start: 0, count: 100) ⇒ Array<Task>
Get pending tasks for a task type
171 172 173 174 175 176 177 178 179 180 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 171 def get_pending_task_for_task_type(task_type, start: 0, count: 100) @api_client.call_api( '/tasks/in_progress/{taskType}', 'GET', path_params: { taskType: task_type }, query_params: { start: start, count: count }, return_type: 'Array<Task>', return_http_data_only: true ) end |
#get_poll_data(task_type) ⇒ Array<PollData>
Get poll data for a task type
264 265 266 267 268 269 270 271 272 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 264 def get_poll_data(task_type) @api_client.call_api( '/tasks/queue/polldata', 'GET', query_params: { taskType: task_type }, return_type: 'Array<PollData>', return_http_data_only: true ) end |
#get_queue_sizes_for_tasks(task_types) ⇒ Hash<String, Integer>
Get queue sizes for specific task types
248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 248 def get_queue_sizes_for_tasks(task_types) query_params = {} query_params[:taskType] = task_types if task_types&.any? @api_client.call_api( '/tasks/queue/sizes', 'GET', query_params: query_params, return_type: 'Hash<String, Integer>', return_http_data_only: true ) end |
#get_task(task_id) ⇒ Task
Get task details
79 80 81 82 83 84 85 86 87 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 79 def get_task(task_id) @api_client.call_api( '/tasks/{taskId}', 'GET', path_params: { taskId: task_id }, return_type: 'Task', return_http_data_only: true ) end |
#get_task_logs(task_id) ⇒ Array<TaskExecLog>
Get task execution logs
156 157 158 159 160 161 162 163 164 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 156 def get_task_logs(task_id) @api_client.call_api( '/tasks/{taskId}/log', 'GET', path_params: { taskId: task_id }, return_type: 'Array<TaskExecLog>', return_http_data_only: true ) end |
#get_task_queue_details(task_type) ⇒ Hash
Get queue details for a task type
129 130 131 132 133 134 135 136 137 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 129 def get_task_queue_details(task_type) @api_client.call_api( '/tasks/queue/all/{taskType}', 'GET', path_params: { taskType: task_type }, return_type: 'Hash<String, Object>', return_http_data_only: true ) end |
#log(task_id, log) ⇒ void
This method returns an undefined value.
Add task execution log
143 144 145 146 147 148 149 150 151 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 143 def log(task_id, log) @api_client.call_api( '/tasks/{taskId}/log', 'POST', path_params: { taskId: task_id }, body: log, return_http_data_only: true ) end |
#poll(task_type, worker_id: nil, domain: nil) ⇒ Task?
Poll for a task of a certain type
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 23 def poll(task_type, worker_id: nil, domain: nil) query_params = {} query_params[:workerid] = worker_id if worker_id query_params[:domain] = domain if domain @api_client.call_api( '/tasks/poll/{taskType}', 'GET', path_params: { taskType: task_type }, query_params: query_params, return_type: 'Task', return_http_data_only: true ) end |
#remove_task_from_queue(task_type, task_id) ⇒ void
This method returns an undefined value.
Remove task from queue
93 94 95 96 97 98 99 100 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 93 def remove_task_from_queue(task_type, task_id) @api_client.call_api( '/tasks/queue/{taskType}/{taskId}', 'DELETE', path_params: { taskType: task_type, taskId: task_id }, return_http_data_only: true ) end |
#requeue_pending_task(task_type) ⇒ String
Requeue pending tasks of a type
288 289 290 291 292 293 294 295 296 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 288 def requeue_pending_task(task_type) @api_client.call_api( '/tasks/queue/requeue/{taskType}', 'POST', path_params: { taskType: task_type }, return_type: 'String', return_http_data_only: true ) end |
#search(start: 0, size: 100, sort: nil, free_text: '*', query: nil) ⇒ SearchResult
Search for tasks
305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 305 def search(start: 0, size: 100, sort: nil, free_text: '*', query: nil) query_params = { start: start, size: size, freeText: free_text } query_params[:sort] = sort if sort query_params[:query] = query if query @api_client.call_api( '/tasks/search', 'GET', query_params: query_params, return_type: 'SearchResult', return_http_data_only: true ) end |
#size(task_types: nil) ⇒ Hash<String, Integer>
Get task queue sizes
105 106 107 108 109 110 111 112 113 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 105 def size(task_types: nil) @api_client.call_api( '/tasks/queue/sizes', 'POST', body: task_types || [], return_type: 'Hash<String, Integer>', return_http_data_only: true ) end |
#update_task(body) ⇒ String
Update task status
66 67 68 69 70 71 72 73 74 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 66 def update_task(body) @api_client.call_api( '/tasks', 'POST', body: body, return_type: 'String', return_http_data_only: true ) end |
#update_task_by_ref_name(workflow_id, task_ref_name, status, output: nil, worker_id: nil) ⇒ String
Update task by reference name
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 189 def update_task_by_ref_name(workflow_id, task_ref_name, status, output: nil, worker_id: nil) query_params = {} query_params[:workerid] = worker_id if worker_id @api_client.call_api( '/tasks/{workflowId}/{taskRefName}/{status}', 'POST', path_params: { workflowId: workflow_id, taskRefName: task_ref_name, status: status }, query_params: query_params, body: output || {}, return_type: 'String', return_http_data_only: true ) end |
#update_task_sync(workflow_id, task_ref_name, status, output: nil, worker_id: nil) ⇒ Workflow
Update task by reference name synchronously (returns workflow state)
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/conductor/http/api/task_resource_api.rb', line 215 def update_task_sync(workflow_id, task_ref_name, status, output: nil, worker_id: nil) query_params = {} query_params[:workerid] = worker_id if worker_id @api_client.call_api( '/tasks/{workflowId}/{taskRefName}/{status}/sync', 'POST', path_params: { workflowId: workflow_id, taskRefName: task_ref_name, status: status }, query_params: query_params, body: output || {}, return_type: 'Workflow', return_http_data_only: true ) end |