Class: Telnyx::Resources::AI::Missions::Runs::Events

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/ai/missions/runs/events.rb,
sig/telnyx/resources/ai/missions/runs/events.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Events

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 Events.



129
130
131
# File 'lib/telnyx/resources/ai/missions/runs/events.rb', line 129

def initialize(client:)
  @client = client
end

Instance Method Details

#get_event_details(event_id, mission_id:, run_id:, request_options: {}) ⇒ Telnyx::Models::AI::Missions::Runs::EventResponse

Returns the details of a single event logged for the specified run, including its type and payload.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/telnyx/resources/ai/missions/runs/events.rb', line 67

def get_event_details(event_id, params)
  parsed, options = Telnyx::AI::Missions::Runs::EventGetEventDetailsParams.dump_request(params)
  mission_id =
    parsed.delete(:mission_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  run_id =
    parsed.delete(:run_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["ai/missions/%1$s/runs/%2$s/events/%3$s", mission_id, run_id, event_id],
    model: Telnyx::AI::Missions::Runs::EventResponse,
    options: options
  )
end

#list(run_id, mission_id:, agent_id: nil, page_number: nil, page_size: nil, step_id: nil, type: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::AI::Missions::Runs::EventData>

Returns a paginated list of events logged for the specified run, filterable by event type, plan step, and agent, so you can reconstruct exactly what happened during execution.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/telnyx/resources/ai/missions/runs/events.rb', line 34

def list(run_id, params)
  parsed, options = Telnyx::AI::Missions::Runs::EventListParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  mission_id =
    parsed.delete(:mission_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["ai/missions/%1$s/runs/%2$s/events", mission_id, run_id],
    query: query.transform_keys(page_number: "page[number]", page_size: "page[size]"),
    page: Telnyx::Internal::DefaultFlatPagination,
    model: Telnyx::AI::Missions::Runs::EventData,
    options: options
  )
end

#log(run_id, mission_id:, summary:, type:, agent_id: nil, idempotency_key: nil, payload: nil, step_id: nil, request_options: {}) ⇒ Telnyx::Models::AI::Missions::Runs::EventResponse

Logs a new event against the specified run and returns the created event. Events form the run's audit trail and can reference a plan step or agent.



111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/telnyx/resources/ai/missions/runs/events.rb', line 111

def log(run_id, params)
  parsed, options = Telnyx::AI::Missions::Runs::EventLogParams.dump_request(params)
  mission_id =
    parsed.delete(:mission_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["ai/missions/%1$s/runs/%2$s/events", mission_id, run_id],
    body: parsed,
    model: Telnyx::AI::Missions::Runs::EventResponse,
    options: options
  )
end