Class: Cadenya::Resources::AgentSchedules
- Inherits:
-
Object
- Object
- Cadenya::Resources::AgentSchedules
- Defined in:
- lib/cadenya/resources/agent_schedules.rb
Instance Method Summary collapse
-
#archive(agent_id, id, workspace_id: nil, request_options: nil) ⇒ Object
Archive a schedule.
-
#create(agent_id, metadata:, spec:, workspace_id: nil, request_options: nil) ⇒ Object
Create a new schedule.
-
#delete(agent_id, id, workspace_id: nil, request_options: nil) ⇒ Object
Delete a schedule.
-
#initialize(core) ⇒ AgentSchedules
constructor
A new instance of AgentSchedules.
-
#list(agent_id, workspace_id: nil, limit: nil, cursor: nil, prefix: nil, query: nil, labels: nil, sort_order: nil, include_info: nil, request_options: nil) ⇒ Object
List schedules.
-
#pause(agent_id, id, workspace_id: nil, request_options: nil) ⇒ Object
Pause a schedule.
-
#resume(agent_id, id, workspace_id: nil, request_options: nil) ⇒ Object
Resume a schedule.
-
#retrieve(agent_id, id, workspace_id: nil, request_options: nil) ⇒ Object
Get a schedule by ID.
-
#update(agent_id, id, workspace_id: nil, metadata: nil, spec: nil, update_mask: nil, request_options: nil) ⇒ Object
Update a schedule.
Constructor Details
#initialize(core) ⇒ AgentSchedules
Returns a new instance of AgentSchedules.
8 9 10 |
# File 'lib/cadenya/resources/agent_schedules.rb', line 8 def initialize(core) @core = core end |
Instance Method Details
#archive(agent_id, id, workspace_id: nil, request_options: nil) ⇒ Object
Archive a schedule
75 76 77 78 79 80 |
# File 'lib/cadenya/resources/agent_schedules.rb', line 75 def archive(agent_id, id, workspace_id: nil, request_options: nil) workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id) _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/agents/#{Util.path_param('agentId', agent_id)}/schedules/#{Util.path_param('id', id)}:archive" _data = @core.request(:post, _path, request_options: ) Types::AgentSchedule.from_json(_data) end |
#create(agent_id, metadata:, spec:, workspace_id: nil, request_options: nil) ⇒ Object
Create a new schedule
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cadenya/resources/agent_schedules.rb', line 34 def create(agent_id, metadata:, spec:, workspace_id: nil, request_options: nil) workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id) _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/agents/#{Util.path_param('agentId', agent_id)}/schedules" _body = { "metadata" => .nil? ? nil : (->(_v) { Types.encode_CreateResourceMetadata(_v) }).call(), "spec" => spec.nil? ? nil : (->(_v) { Types.encode_AgentScheduleSpec(_v) }).call(spec), }.reject { |_k, v| v.nil? } _data = @core.request(:post, _path, body: _body, request_options: ) Types::AgentSchedule.from_json(_data) end |
#delete(agent_id, id, workspace_id: nil, request_options: nil) ⇒ Object
Delete a schedule
54 55 56 57 58 59 |
# File 'lib/cadenya/resources/agent_schedules.rb', line 54 def delete(agent_id, id, workspace_id: nil, request_options: nil) workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id) _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/agents/#{Util.path_param('agentId', agent_id)}/schedules/#{Util.path_param('id', id)}" @core.request(:delete, _path, expects_body: false, request_options: ) nil end |
#list(agent_id, workspace_id: nil, limit: nil, cursor: nil, prefix: nil, query: nil, labels: nil, sort_order: nil, include_info: nil, request_options: nil) ⇒ Object
List schedules
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cadenya/resources/agent_schedules.rb', line 13 def list(agent_id, workspace_id: nil, limit: nil, cursor: nil, prefix: nil, query: nil, labels: nil, sort_order: nil, include_info: nil, request_options: nil) workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id) _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/agents/#{Util.path_param('agentId', agent_id)}/schedules" _query = { "limit" => limit, "cursor" => cursor, "prefix" => prefix, "query" => query, "labels" => labels, "sortOrder" => sort_order, "includeInfo" => include_info, } _data = @core.request(:get, _path, query: _query, request_options: ) || {} _items = (_data["items"] || []).map { |item| Types::AgentSchedule.from_json(item) } _next_cursor = (((_data)["pagination"] || {}))["nextCursor"].to_s Page.new(_items, _next_cursor) do |_c| list(agent_id, workspace_id: workspace_id, limit: limit, cursor: _c, prefix: prefix, query: query, labels: labels, sort_order: sort_order, include_info: include_info, request_options: ) end end |
#pause(agent_id, id, workspace_id: nil, request_options: nil) ⇒ Object
Pause a schedule
83 84 85 86 87 88 |
# File 'lib/cadenya/resources/agent_schedules.rb', line 83 def pause(agent_id, id, workspace_id: nil, request_options: nil) workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id) _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/agents/#{Util.path_param('agentId', agent_id)}/schedules/#{Util.path_param('id', id)}:pause" _data = @core.request(:post, _path, request_options: ) Types::AgentSchedule.from_json(_data) end |
#resume(agent_id, id, workspace_id: nil, request_options: nil) ⇒ Object
Resume a schedule
91 92 93 94 95 96 |
# File 'lib/cadenya/resources/agent_schedules.rb', line 91 def resume(agent_id, id, workspace_id: nil, request_options: nil) workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id) _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/agents/#{Util.path_param('agentId', agent_id)}/schedules/#{Util.path_param('id', id)}:resume" _data = @core.request(:post, _path, request_options: ) Types::AgentSchedule.from_json(_data) end |
#retrieve(agent_id, id, workspace_id: nil, request_options: nil) ⇒ Object
Get a schedule by ID
46 47 48 49 50 51 |
# File 'lib/cadenya/resources/agent_schedules.rb', line 46 def retrieve(agent_id, id, workspace_id: nil, request_options: nil) workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id) _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/agents/#{Util.path_param('agentId', agent_id)}/schedules/#{Util.path_param('id', id)}" _data = @core.request(:get, _path, request_options: ) Types::AgentSchedule.from_json(_data) end |
#update(agent_id, id, workspace_id: nil, metadata: nil, spec: nil, update_mask: nil, request_options: nil) ⇒ Object
Update a schedule
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/cadenya/resources/agent_schedules.rb', line 62 def update(agent_id, id, workspace_id: nil, metadata: nil, spec: nil, update_mask: nil, request_options: nil) workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id) _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/agents/#{Util.path_param('agentId', agent_id)}/schedules/#{Util.path_param('id', id)}" _body = { "metadata" => .nil? ? nil : (->(_v) { Types.encode_UpdateResourceMetadata(_v) }).call(), "spec" => spec.nil? ? nil : (->(_v) { Types.encode_AgentScheduleSpec(_v) }).call(spec), "updateMask" => update_mask, }.reject { |_k, v| v.nil? } _data = @core.request(:patch, _path, body: _body, request_options: ) Types::AgentSchedule.from_json(_data) end |