Class: Cadenya::Resources::Agents::Schedules

Inherits:
Object
  • Object
show all
Defined in:
lib/cadenya/resources/agents/schedules.rb

Overview

Manage recurring schedules attached to agents. Schedules trigger objectives on a cadence defined by AgentScheduleSpec.Schedule.

Instance Method Summary collapse

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.

Parameters:



213
214
215
# File 'lib/cadenya/resources/agents/schedules.rb', line 213

def initialize(client:)
  @client = client
end

Instance Method Details

#create(agent_id, workspace_id:, metadata:, spec:, request_options: {}) ⇒ Cadenya::Models::Agents::AgentSchedule

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

Creates a new schedule for an agent

Parameters:

Returns:

See Also:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/cadenya/resources/agents/schedules.rb', line 29

def create(agent_id, params)
  parsed, options = Cadenya::Agents::ScheduleCreateParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["v1/workspaces/%1$s/agents/%2$s/schedules", workspace_id, agent_id],
    body: parsed,
    model: Cadenya::Agents::AgentSchedule,
    options: options
  )
end

#delete(id, workspace_id:, agent_id:, request_options: {}) ⇒ nil

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

Deletes a schedule from an agent

Parameters:

  • id (String)

    Schedule ID. Accepts the canonical ‘as_…` form or the `external_id:<value>` form

  • workspace_id (String)

    Workspace ID.

  • agent_id (String)

    Agent ID. Accepts the canonical ‘agent_…` form or the `external_id:<value>` form

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

Returns:

  • (nil)

See Also:



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/cadenya/resources/agents/schedules.rb', line 192

def delete(id, params)
  parsed, options = Cadenya::Agents::ScheduleDeleteParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  agent_id =
    parsed.delete(:agent_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["v1/workspaces/%1$s/agents/%2$s/schedules/%3$s", workspace_id, agent_id, id],
    model: NilClass,
    options: options
  )
end

#list(agent_id, workspace_id:, bundle_key: nil, cursor: nil, include_info: nil, limit: nil, prefix: nil, query: nil, sort_order: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::Agents::AgentSchedule>

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

Lists all schedules for an agent

Parameters:

  • agent_id (String)

    Path param: Agent ID. Accepts the canonical ‘agent_…` form or the `external_id:<

  • workspace_id (String)

    Path param: Workspace ID.

  • bundle_key (String)

    Query param: Filter by bundle_key — return only resources owned by this bundle.

  • cursor (String)

    Query param: Pagination cursor from previous response.

  • include_info (Boolean)

    Query param: When true, the ‘info` field on each returned schedule is populated.

  • limit (Integer)

    Query param: Maximum number of results to return.

  • prefix (String)

    Query param: Filter expression (query param: prefix).

  • query (String)

    Query param: Free-form search query.

  • sort_order (String)

    Query param: Sort order for results (asc or desc by creation time).

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

Returns:

See Also:



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/cadenya/resources/agents/schedules.rb', line 153

def list(agent_id, params)
  parsed, options = Cadenya::Agents::ScheduleListParams.dump_request(params)
  query = Cadenya::Internal::Util.encode_query_params(parsed)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["v1/workspaces/%1$s/agents/%2$s/schedules", workspace_id, agent_id],
    query: query.transform_keys(
      bundle_key: "bundleKey",
      include_info: "includeInfo",
      sort_order: "sortOrder"
    ),
    page: Cadenya::Internal::CursorPagination,
    model: Cadenya::Agents::AgentSchedule,
    options: options
  )
end

#retrieve(id, workspace_id:, agent_id:, request_options: {}) ⇒ Cadenya::Models::Agents::AgentSchedule

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

Retrieves a schedule by ID from an agent

Parameters:

  • id (String)

    Schedule ID. Accepts the canonical ‘as_…` form or the `external_id:<value>` form

  • workspace_id (String)

    Workspace ID.

  • agent_id (String)

    Agent ID. Accepts the canonical ‘agent_…` form or the `external_id:<value>` form

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

Returns:

See Also:



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/cadenya/resources/agents/schedules.rb', line 62

def retrieve(id, params)
  parsed, options = Cadenya::Agents::ScheduleRetrieveParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  agent_id =
    parsed.delete(:agent_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["v1/workspaces/%1$s/agents/%2$s/schedules/%3$s", workspace_id, agent_id, id],
    model: Cadenya::Agents::AgentSchedule,
    options: options
  )
end

#update(id, workspace_id:, agent_id:, metadata: nil, spec: nil, update_mask: nil, request_options: {}) ⇒ Cadenya::Models::Agents::AgentSchedule

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

Updates a schedule for an agent

Parameters:

  • id (String)

    Path param: Schedule ID. Accepts the canonical ‘as_…` form or the `external_id:<

  • workspace_id (String)

    Path param: Workspace ID.

  • agent_id (String)

    Path param: Agent ID. Accepts the canonical ‘agent_…` form or the `external_id:<

  • metadata (Cadenya::Models::UpdateResourceMetadata)

    Body param: UpdateResourceMetadata contains the user-provided fields for updatin

  • spec (Cadenya::Models::Agents::AgentScheduleSpec)

    Body param: AgentScheduleSpec is the user-provided configuration for a schedule.

  • update_mask (String)

    Body param: Fields to update.

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

Returns:

See Also:



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/cadenya/resources/agents/schedules.rb', line 104

def update(id, params)
  parsed, options = Cadenya::Agents::ScheduleUpdateParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  agent_id =
    parsed.delete(:agent_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :patch,
    path: ["v1/workspaces/%1$s/agents/%2$s/schedules/%3$s", workspace_id, agent_id, id],
    body: parsed,
    model: Cadenya::Agents::AgentSchedule,
    options: options
  )
end