Class: Conductor::Http::Api::TaskResourceApi

Inherits:
Object
  • Object
show all
Defined in:
lib/conductor/http/api/task_resource_api.rb

Overview

TaskResourceApi - API for task operations

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = nil) ⇒ TaskResourceApi

Initialize TaskResourceApi

Parameters:

  • api_client (ApiClient) (defaults to: nil)

    Optional API client



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_clientObject

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_detailsHash<String, Integer>

Get all queue details

Returns:

  • (Hash<String, Integer>)

    Map of task type to queue size



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_verboseHash

Get all queue details (verbose)

Returns:

  • (Hash)

    Verbose queue details



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

Parameters:

  • task_type (String)

    Task type to poll

  • count (Integer) (defaults to: 1)

    Number of tasks to poll (default: 1, max: 100)

  • timeout (Integer) (defaults to: 100)

    Timeout in milliseconds (default: 100)

  • worker_id (String) (defaults to: nil)

    Worker ID (optional)

  • domain (String) (defaults to: nil)

    Domain (optional)

Returns:

  • (Array<Task>)

    Array of 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_dataArray<PollData>

Get all poll data

Returns:

  • (Array<PollData>)


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

Parameters:

  • task_type (String)

    Task type

  • start (Integer) (defaults to: 0)

    Start index (default: 0)

  • count (Integer) (defaults to: 100)

    Number of tasks (default: 100)

Returns:

  • (Array<Task>)

    Array of pending tasks



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

Parameters:

  • task_type (String)

    Task type name

Returns:

  • (Array<PollData>)


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

Parameters:

  • task_types (Array<String>)

    List of task type names

Returns:

  • (Hash<String, Integer>)


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

Parameters:

  • task_id (String)

    Task ID

Returns:

  • (Task)

    Task object



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

Parameters:

  • task_id (String)

    Task ID

Returns:

  • (Array<TaskExecLog>)

    Array of 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

Parameters:

  • task_type (String)

    Task type

Returns:

  • (Hash)

    Queue details



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

Parameters:

  • task_id (String)

    Task ID

  • log (String)

    Log message



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

Parameters:

  • task_type (String)

    Task type to poll

  • worker_id (String) (defaults to: nil)

    Worker ID (optional)

  • domain (String) (defaults to: nil)

    Domain (optional)

Returns:

  • (Task, nil)

    Task object or nil if no task available



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

Parameters:

  • task_type (String)

    Task type

  • task_id (String)

    Task ID



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

Parameters:

  • task_type (String)

    Task type name

Returns:

  • (String)


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

Parameters:

  • start (Integer) (defaults to: 0)

    Start index (default: 0)

  • size (Integer) (defaults to: 100)

    Page size (default: 100)

  • sort (String) (defaults to: nil)

    Sort order (optional)

  • free_text (String) (defaults to: '*')

    Free text search (default: '*')

  • query (String) (defaults to: nil)

    Query string (optional)

Returns:

  • (SearchResult)


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

Parameters:

  • task_types (Array<String>) (defaults to: nil)

    List of task types (optional)

Returns:

  • (Hash<String, Integer>)

    Map of task type to queue size



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

Parameters:

  • body (TaskResult)

    Task result

Returns:

  • (String)

    Task ID



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

Parameters:

  • workflow_id (String)

    Workflow ID

  • task_ref_name (String)

    Task reference name

  • status (String)

    New status

  • output (Hash) (defaults to: nil)

    Task output data (optional)

  • worker_id (String) (defaults to: nil)

    Worker ID (optional)

Returns:

  • (String)

    Updated workflow ID



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)

Parameters:

  • workflow_id (String)

    Workflow ID

  • task_ref_name (String)

    Task reference name

  • status (String)

    New status

  • output (Hash) (defaults to: nil)

    Task output data

  • worker_id (String) (defaults to: nil)

    Worker ID (optional)

Returns:



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