Class: Rafflesia::Jobs

Inherits:
Object
  • Object
show all
Defined in:
lib/rafflesia/jobs.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Jobs

Returns a new instance of Jobs.



9
10
11
# File 'lib/rafflesia/jobs.rb', line 9

def initialize(client)
  @client = client
end

Instance Method Details

#cancel(job_id:, request_options: {}) ⇒ Rafflesia::EnvelopeJobData

POST /v1/jobs/cancel

Parameters:

  • job_id (String)
  • request_options (Hash) (defaults to: {})

    (see Rafflesia::Types::RequestOptions)

Returns:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rafflesia/jobs.rb', line 17

def cancel(
  job_id:,
  request_options: {}
)
  params = {
    'job_id' => job_id
  }
  response = @client.request(
    method: :post,
    path: '/v1/jobs/cancel',
    auth: true,
    params: params,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeJobData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#cleanup(delete_terminal: nil, dry_run: nil, limit: nil, mark_stale_running: nil, reason: nil, stale_after_ms: nil, terminal_older_than_ms: nil, request_options: {}) ⇒ Rafflesia::EnvelopeJobCleanupData

POST /v1/jobs/cleanup

Parameters:

  • delete_terminal (Boolean, nil) (defaults to: nil)
  • dry_run (Boolean, nil) (defaults to: nil)
  • limit (Integer, nil) (defaults to: nil)
  • mark_stale_running (Boolean, nil) (defaults to: nil)
  • reason (String, nil) (defaults to: nil)
  • stale_after_ms (Integer, nil) (defaults to: nil)
  • terminal_older_than_ms (Integer, nil) (defaults to: nil)
  • request_options (Hash) (defaults to: {})

    (see Rafflesia::Types::RequestOptions)

Returns:



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/rafflesia/jobs.rb', line 46

def cleanup(
  delete_terminal: nil,
  dry_run: nil,
  limit: nil,
  mark_stale_running: nil,
  reason: nil,
  stale_after_ms: nil,
  terminal_older_than_ms: nil,
  request_options: {}
)
  body = {
    'delete_terminal' => delete_terminal,
    'dry_run' => dry_run,
    'limit' => limit,
    'mark_stale_running' => mark_stale_running,
    'reason' => reason,
    'stale_after_ms' => stale_after_ms,
    'terminal_older_than_ms' => terminal_older_than_ms
  }.compact
  response = @client.request(
    method: :post,
    path: '/v1/jobs/cleanup',
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeJobCleanupData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#create(operation:, idempotency_key: nil, input: nil, max_retries: nil, timeout_ms: nil, request_options: {}) ⇒ Rafflesia::EnvelopeJobData

POST /v1/jobs/create

Parameters:

  • idempotency_key (String, nil) (defaults to: nil)
  • input (Hash{String => Object}, nil) (defaults to: nil)
  • max_retries (Integer, nil) (defaults to: nil)
  • operation (String)
  • timeout_ms (Integer, nil) (defaults to: nil)
  • request_options (Hash) (defaults to: {})

    (see Rafflesia::Types::RequestOptions)

Returns:



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/rafflesia/jobs.rb', line 85

def create(
  operation:,
  idempotency_key: nil,
  input: nil,
  max_retries: nil,
  timeout_ms: nil,
  request_options: {}
)
  body = {
    'idempotency_key' => idempotency_key,
    'input' => input,
    'max_retries' => max_retries,
    'operation' => operation,
    'timeout_ms' => timeout_ms
  }.compact
  response = @client.request(
    method: :post,
    path: '/v1/jobs/create',
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeJobData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#diagnostics(stale_after_ms: nil, limit: nil, request_options: {}) ⇒ Rafflesia::EnvelopeJobDiagnosticData

GET /v1/jobs/diagnostics

Parameters:

  • stale_after_ms (Integer, nil) (defaults to: nil)
  • limit (Integer, nil) (defaults to: nil)
  • request_options (Hash) (defaults to: {})

    (see Rafflesia::Types::RequestOptions)

Returns:



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/rafflesia/jobs.rb', line 117

def diagnostics(
  stale_after_ms: nil,
  limit: nil,
  request_options: {}
)
  params = {
    'stale_after_ms' => stale_after_ms,
    'limit' => limit
  }.compact
  response = @client.request(
    method: :get,
    path: '/v1/jobs/diagnostics',
    auth: true,
    params: params,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeJobDiagnosticData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#events(job_id:, type: nil, limit: nil, request_options: {}) ⇒ Rafflesia::EnvelopeJobEventListData

GET /v1/jobs/events

Parameters:

  • job_id (String)
  • type (String, nil) (defaults to: nil)
  • limit (Integer, nil) (defaults to: nil)
  • request_options (Hash) (defaults to: {})

    (see Rafflesia::Types::RequestOptions)

Returns:



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/rafflesia/jobs.rb', line 144

def events(
  job_id:,
  type: nil,
  limit: nil,
  request_options: {}
)
  params = {
    'job_id' => job_id,
    'type' => type,
    'limit' => limit
  }.compact
  response = @client.request(
    method: :get,
    path: '/v1/jobs/events',
    auth: true,
    params: params,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeJobEventListData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#list(operation: nil, status: nil, worker_id: nil, has_error: nil, stale_after_ms: nil, limit: nil, request_options: {}) ⇒ Rafflesia::EnvelopeJobListData

GET /v1/jobs/list

Parameters:

  • operation (String, nil) (defaults to: nil)
  • status (String, nil) (defaults to: nil)
  • worker_id (String, nil) (defaults to: nil)
  • has_error (Boolean, nil) (defaults to: nil)
  • stale_after_ms (Integer, nil) (defaults to: nil)
  • limit (Integer, nil) (defaults to: nil)
  • request_options (Hash) (defaults to: {})

    (see Rafflesia::Types::RequestOptions)

Returns:



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/rafflesia/jobs.rb', line 176

def list(
  operation: nil,
  status: nil,
  worker_id: nil,
  has_error: nil,
  stale_after_ms: nil,
  limit: nil,
  request_options: {}
)
  params = {
    'operation' => operation,
    'status' => status,
    'worker_id' => worker_id,
    'has_error' => has_error,
    'stale_after_ms' => stale_after_ms,
    'limit' => limit
  }.compact
  response = @client.request(
    method: :get,
    path: '/v1/jobs/list',
    auth: true,
    params: params,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeJobListData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#markFailed(reason:, job_id:, request_options: {}) ⇒ Rafflesia::EnvelopeJobData

POST /v1/jobs/mark-failed

Parameters:

  • reason (String)
  • job_id (String)
  • request_options (Hash) (defaults to: {})

    (see Rafflesia::Types::RequestOptions)

Returns:



210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/rafflesia/jobs.rb', line 210

def markFailed(
  reason:,
  job_id:,
  request_options: {}
)
  params = {
    'job_id' => job_id
  }
  body = {
    'reason' => reason
  }
  response = @client.request(
    method: :post,
    path: '/v1/jobs/mark-failed',
    auth: true,
    params: params,
    body: body,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeJobData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#metrics(stale_after_ms: nil, request_options: {}) ⇒ Rafflesia::EnvelopeJobMetricsData

GET /v1/jobs/metrics

Parameters:

  • stale_after_ms (Integer, nil) (defaults to: nil)
  • request_options (Hash) (defaults to: {})

    (see Rafflesia::Types::RequestOptions)

Returns:



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/rafflesia/jobs.rb', line 238

def metrics(
  stale_after_ms: nil,
  request_options: {}
)
  params = {
    'stale_after_ms' => stale_after_ms
  }.compact
  response = @client.request(
    method: :get,
    path: '/v1/jobs/metrics',
    auth: true,
    params: params,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeJobMetricsData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#operations(request_options: {}) ⇒ Rafflesia::EnvelopeJobOperationListData

GET /v1/jobs/operations

Parameters:

  • request_options (Hash) (defaults to: {})

    (see Rafflesia::Types::RequestOptions)

Returns:



260
261
262
263
264
265
266
267
268
269
270
# File 'lib/rafflesia/jobs.rb', line 260

def operations(request_options: {})
  response = @client.request(
    method: :get,
    path: '/v1/jobs/operations',
    auth: true,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeJobOperationListData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#queue(limit: nil, request_options: {}) ⇒ Rafflesia::EnvelopeJobQueueData

GET /v1/jobs/queue

Parameters:

  • limit (Integer, nil) (defaults to: nil)
  • request_options (Hash) (defaults to: {})

    (see Rafflesia::Types::RequestOptions)

Returns:



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/rafflesia/jobs.rb', line 276

def queue(
  limit: nil,
  request_options: {}
)
  params = {
    'limit' => limit
  }.compact
  response = @client.request(
    method: :get,
    path: '/v1/jobs/queue',
    auth: true,
    params: params,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeJobQueueData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#requeue(job_id:, request_options: {}) ⇒ Rafflesia::EnvelopeJobData

POST /v1/jobs/requeue

Parameters:

  • job_id (String)
  • request_options (Hash) (defaults to: {})

    (see Rafflesia::Types::RequestOptions)

Returns:



299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/rafflesia/jobs.rb', line 299

def requeue(
  job_id:,
  request_options: {}
)
  params = {
    'job_id' => job_id
  }
  response = @client.request(
    method: :post,
    path: '/v1/jobs/requeue',
    auth: true,
    params: params,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeJobData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#result(job_id:, wait_ms: nil, request_options: {}) ⇒ Rafflesia::EnvelopeJobData

GET /v1/jobs/result

Parameters:

  • job_id (String)
  • wait_ms (Integer, nil) (defaults to: nil)
  • request_options (Hash) (defaults to: {})

    (see Rafflesia::Types::RequestOptions)

Returns:



323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# File 'lib/rafflesia/jobs.rb', line 323

def result(
  job_id:,
  wait_ms: nil,
  request_options: {}
)
  params = {
    'job_id' => job_id,
    'wait_ms' => wait_ms
  }.compact
  response = @client.request(
    method: :get,
    path: '/v1/jobs/result',
    auth: true,
    params: params,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeJobData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#retries(limit: nil, request_options: {}) ⇒ Rafflesia::EnvelopeJobRetryData

GET /v1/jobs/retries

Parameters:

  • limit (Integer, nil) (defaults to: nil)
  • request_options (Hash) (defaults to: {})

    (see Rafflesia::Types::RequestOptions)

Returns:



348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/rafflesia/jobs.rb', line 348

def retries(
  limit: nil,
  request_options: {}
)
  params = {
    'limit' => limit
  }.compact
  response = @client.request(
    method: :get,
    path: '/v1/jobs/retries',
    auth: true,
    params: params,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeJobRetryData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#retriesRun(task_id:, request_options: {}) ⇒ Rafflesia::EnvelopeEmptyData

POST /v1/jobs/retries/run

Parameters:

  • task_id (String)
  • request_options (Hash) (defaults to: {})

    (see Rafflesia::Types::RequestOptions)

Returns:



371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/rafflesia/jobs.rb', line 371

def retriesRun(
  task_id:,
  request_options: {}
)
  params = {
    'task_id' => task_id
  }
  response = @client.request(
    method: :post,
    path: '/v1/jobs/retries/run',
    auth: true,
    params: params,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeEmptyData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#retry(job_id:, request_options: {}) ⇒ Rafflesia::EnvelopeJobData

POST /v1/jobs/retry

Parameters:

  • job_id (String)
  • request_options (Hash) (defaults to: {})

    (see Rafflesia::Types::RequestOptions)

Returns:



394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/rafflesia/jobs.rb', line 394

def retry(
  job_id:,
  request_options: {}
)
  params = {
    'job_id' => job_id
  }
  response = @client.request(
    method: :post,
    path: '/v1/jobs/retry',
    auth: true,
    params: params,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeJobData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#show(job_id:, wait_ms: nil, since_version: nil, request_options: {}) ⇒ Rafflesia::EnvelopeJobData

GET /v1/jobs/show

Parameters:

  • job_id (String)
  • wait_ms (Integer, nil) (defaults to: nil)
  • since_version (Integer, nil) (defaults to: nil)
  • request_options (Hash) (defaults to: {})

    (see Rafflesia::Types::RequestOptions)

Returns:



419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
# File 'lib/rafflesia/jobs.rb', line 419

def show(
  job_id:,
  wait_ms: nil,
  since_version: nil,
  request_options: {}
)
  params = {
    'job_id' => job_id,
    'wait_ms' => wait_ms,
    'since_version' => since_version
  }.compact
  response = @client.request(
    method: :get,
    path: '/v1/jobs/show',
    auth: true,
    params: params,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeJobData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end