Class: Handinger::Resources::Tasks

Inherits:
Object
  • Object
show all
Defined in:
lib/handinger/resources/tasks.rb

Overview

Run and inspect tasks against a worker.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Tasks

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Tasks.

Parameters:



87
88
89
# File 'lib/handinger/resources/tasks.rb', line 87

def initialize(client:)
  @client = client
end

Instance Method Details

#create(input:, budget: nil, stream: nil, task_id: nil, worker_id: nil, request_options: {}) ⇒ Handinger::Models::Worker

Some parameter documentations has been truncated, see Models::TaskCreateParams for more details.

Run a new task against an existing worker. Send a ‘taskId` of a prior task to add a follow-up turn instead of starting a fresh task. Send `multipart/form-data` to attach files; the bytes are bootstrapped into the worker’s workspace before the task starts.

Parameters:

  • input (String)
  • budget (Symbol, Handinger::Models::CreateTask::Budget)
  • stream (Boolean)
  • task_id (String)

    Optional client-provided task id. Reuse this id to add turns to an existing task

  • worker_id (String)

    Worker id the task belongs to. If omitted, a new worker is created on-the-fly us

  • request_options (Handinger::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



32
33
34
35
36
37
38
39
40
41
# File 'lib/handinger/resources/tasks.rb', line 32

def create(params)
  parsed, options = Handinger::TaskCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api/tasks",
    body: parsed,
    model: Handinger::Worker,
    options: options
  )
end

#delete(task_id, request_options: {}) ⇒ Handinger::Models::DeleteTaskResponse

Archive a task so it stops appearing in ‘GET /tasks` results. Turns and files are retained for audit purposes. Only the worker creator can archive a task.

Parameters:

  • task_id (String)

    Task id returned by the create task endpoint.

  • request_options (Handinger::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



75
76
77
78
79
80
81
82
# File 'lib/handinger/resources/tasks.rb', line 75

def delete(task_id, params = {})
  @client.request(
    method: :delete,
    path: ["api/tasks/%1$s", task_id],
    model: Handinger::DeleteTaskResponse,
    options: params[:request_options]
  )
end

#retrieve(task_id, request_options: {}) ⇒ Handinger::Models::TaskWithTurns

Retrieve a single task and its individual turns.

Parameters:

  • task_id (String)

    Task id returned by the create task endpoint.

  • request_options (Handinger::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



54
55
56
57
58
59
60
61
# File 'lib/handinger/resources/tasks.rb', line 54

def retrieve(task_id, params = {})
  @client.request(
    method: :get,
    path: ["api/tasks/%1$s", task_id],
    model: Handinger::TaskWithTurns,
    options: params[:request_options]
  )
end