Class: Oz::Resources::Schedules

Inherits:
Base
  • Object
show all
Defined in:
lib/oz/resources/schedules.rb

Overview

Manage scheduled agents (cron-triggered runs), reachable via client.agent.schedules.

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Oz::Resources::Base

Instance Method Details

#create(cron_schedule:, name:, agent_config: nil, agent_uid: nil, enabled: nil, mode: nil, prompt: nil, team: nil, **extra) ⇒ Oz::Model

Create a scheduled agent.

Parameters:

  • cron_schedule (String)

    cron expression (e.g. “0 9 * * *”)

  • name (String)

    human-readable schedule name

  • agent_config (Hash, nil) (defaults to: nil)

    cloud agent run configuration

  • agent_uid (String, nil) (defaults to: nil)

    execution principal for team schedules

  • enabled (Boolean, nil) (defaults to: nil)

    whether the schedule is active immediately

  • mode (String, nil) (defaults to: nil)

    “normal”, “plan”, or “orchestrate”

  • prompt (String, nil) (defaults to: nil)

    instruction for the agent

  • team (Boolean, nil) (defaults to: nil)

    whether to create a team-owned schedule

Returns:

  • (Oz::Model)

    the created schedule (ScheduledAgentItem)



18
19
20
21
22
23
24
25
# File 'lib/oz/resources/schedules.rb', line 18

def create(cron_schedule:, name:, agent_config: nil, agent_uid: nil, enabled: nil,
           mode: nil, prompt: nil, team: nil, **extra)
  body = compact(
    cron_schedule: cron_schedule, name: name, agent_config: agent_config,
    agent_uid: agent_uid, enabled: enabled, mode: mode, prompt: prompt, team: team
  ).merge(extra)
  model(@client.post('/agent/schedules', body: body))
end

#delete(schedule_id) ⇒ Oz::Model

Delete a schedule.

Returns:

  • (Oz::Model)

    response with a success flag



47
48
49
# File 'lib/oz/resources/schedules.rb', line 47

def delete(schedule_id)
  model(@client.delete("/agent/schedules/#{enc(schedule_id)}"))
end

#listOz::Model

List all scheduled agents.

Returns:

  • (Oz::Model)

    response with a schedules array



41
42
43
# File 'lib/oz/resources/schedules.rb', line 41

def list
  model(@client.get('/agent/schedules'))
end

#pause(schedule_id) ⇒ Oz::Model

Pause a schedule (stops triggering new runs).

Returns:



53
54
55
# File 'lib/oz/resources/schedules.rb', line 53

def pause(schedule_id)
  model(@client.post("/agent/schedules/#{enc(schedule_id)}/pause"))
end

#resume(schedule_id) ⇒ Oz::Model

Resume a paused schedule.

Returns:



59
60
61
# File 'lib/oz/resources/schedules.rb', line 59

def resume(schedule_id)
  model(@client.post("/agent/schedules/#{enc(schedule_id)}/resume"))
end

#retrieve(schedule_id) ⇒ Oz::Model

Retrieve a schedule by id.

Returns:



29
30
31
# File 'lib/oz/resources/schedules.rb', line 29

def retrieve(schedule_id)
  model(@client.get("/agent/schedules/#{enc(schedule_id)}"))
end

#update(schedule_id, **params) ⇒ Oz::Model

Update a schedule. Accepts the same fields as #create.

Returns:



35
36
37
# File 'lib/oz/resources/schedules.rb', line 35

def update(schedule_id, **params)
  model(@client.put("/agent/schedules/#{enc(schedule_id)}", body: params))
end