Class: Handinger::Resources::Workers::Schedules
- Inherits:
-
Object
- Object
- Handinger::Resources::Workers::Schedules
- Defined in:
- lib/handinger/resources/workers/schedules.rb
Overview
Manage future and recurring worker tasks.
Instance Method Summary collapse
-
#cancel(schedule_id, worker_id:, request_options: {}) ⇒ Handinger::Models::Workers::ScheduleCancelResponse
Cancel a scheduled task for a worker.
-
#create(worker_id, input:, when_:, budget: nil, request_options: {}) ⇒ Handinger::Models::Workers::WorkerSchedule::Scheduled, ...
Schedule a worker instruction for a future or recurring run.
-
#initialize(client:) ⇒ Schedules
constructor
private
A new instance of Schedules.
-
#list(worker_id, request_options: {}) ⇒ Handinger::Models::Workers::ScheduleListResponse
List scheduled tasks for a worker.
Constructor Details
#initialize(client:) ⇒ Schedules
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 Schedules.
86 87 88 |
# File 'lib/handinger/resources/workers/schedules.rb', line 86 def initialize(client:) @client = client end |
Instance Method Details
#cancel(schedule_id, worker_id:, request_options: {}) ⇒ Handinger::Models::Workers::ScheduleCancelResponse
Cancel a scheduled task for a worker.
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/handinger/resources/workers/schedules.rb', line 69 def cancel(schedule_id, params) parsed, = Handinger::Workers::ScheduleCancelParams.dump_request(params) worker_id = parsed.delete(:worker_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :delete, path: ["api/workers/%1$s/schedules/%2$s", worker_id, schedule_id], model: Handinger::Models::Workers::ScheduleCancelResponse, options: ) end |
#create(worker_id, input:, when_:, budget: nil, request_options: {}) ⇒ Handinger::Models::Workers::WorkerSchedule::Scheduled, ...
Schedule a worker instruction for a future or recurring run.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/handinger/resources/workers/schedules.rb', line 25 def create(worker_id, params) parsed, = Handinger::Workers::ScheduleCreateParams.dump_request(params) @client.request( method: :post, path: ["api/workers/%1$s/schedules", worker_id], body: parsed, model: Handinger::Workers::WorkerSchedule, options: ) end |
#list(worker_id, request_options: {}) ⇒ Handinger::Models::Workers::ScheduleListResponse
List scheduled tasks for a worker.
47 48 49 50 51 52 53 54 |
# File 'lib/handinger/resources/workers/schedules.rb', line 47 def list(worker_id, params = {}) @client.request( method: :get, path: ["api/workers/%1$s/schedules", worker_id], model: Handinger::Models::Workers::ScheduleListResponse, options: params[:request_options] ) end |