TuoniCommand¶
Use add_note(label, content), load_note(note_id), and
load_notes(page=0, pageSize=100, label=None, include_archived=False) to work
with tuoni.TuoniNote objects attached to this command. These methods
require the server’s v2 command-notes endpoints and the command’s agentGuid.
For older command objects without agent context, use the corresponding
TuoniC2 methods with an explicit owning agent GUID and command ID.
- class tuoni.TuoniCommand(conf, c2)[source]¶
A class that provides data and functionality for a sent command.
- command_id¶
The unique identifier of the command.
- Type:
int
- agentGuid¶
UUID of the owning agent, used by note helpers. May be None on older command responses.
- Type:
str | None
- commandTemplateId¶
The unique identifier of the command template used to create the command.
- Type:
str
- commandTemplateName¶
The name of the command template used to create the command.
- Type:
str
- configuration¶
The configuration settings for the command.
- Type:
dict
- execConf¶
The execution configuration for the command.
- Type:
dict
- status¶
Top-level lifecycle status from the server: one of
CREATED,SENT,ONGOING,CANCELED,FAILED,COMPLETE. May beNoneon older servers.- Type:
str
- created¶
The time, as a string, indicating when the command was created.
- Type:
str
- sent¶
The time, as a string, indicating when the command was sent.
- Type:
str
- result¶
The result data returned from the command execution.
- Type:
- add_note(label, content)[source]¶
Create a note on this command. Requires
SEND_COMMANDS.- Parameters:
label (str) – Nonblank label, limited to 128 characters by the server.
content (str) – Nonblank content, limited to 2,000 characters.
- Returns:
The created note. Requires a known
agentGuid.- Return type:
Examples
>>> note = command.add_note("review", "Reviewed the output.")
- get_result(reload=True)[source]¶
Retrieve the result object of the command.
- Parameters:
reload (bool) – If True, reload the command result data from the server.
- Returns:
The result object containing the data from the command execution.
- Return type:
- get_template()[source]¶
Retrieve the command template used to create this command.
- Returns:
The command template object, or None if the template could not be found.
- Return type:
- is_done(reload_from_server=False)[source]¶
Checks has the command done/finished
- Parameters:
reload_from_server (bool) – Should command data be reloaded from server.
- Returns:
Is command done
- Return type:
bool
- is_failed(reload_from_server=False)[source]¶
Checks did the command fail or get canceled
- Parameters:
reload_from_server (bool) – Should command data be reloaded from server.
- Returns:
Did command fail
- Return type:
bool
- is_ongoing(reload_from_server=False)[source]¶
Checks is the command running as ongoing command
- Parameters:
reload_from_server (bool) – Should command data be reloaded from server.
- Returns:
Is command ongoing
- Return type:
bool
- is_sent(reload_from_server=False)[source]¶
Checks was the command sent to the agent
- Parameters:
reload_from_server (bool) – Should command data be reloaded from server.
- Returns:
Is command sent to agent
- Return type:
bool
- is_success(reload_from_server=False)[source]¶
Checks was the command successful
- Parameters:
reload_from_server (bool) – Should command data be reloaded from server.
- Returns:
Was command successful
- Return type:
bool
- load_note(note_id)[source]¶
Retrieve one of this command’s notes, including archived notes.
- Parameters:
note_id (str) – Note UUID.
- Returns:
- The requested note. Requires
VIEW_RESOURCESand a known
agentGuid.
- The requested note. Requires
- Return type:
- load_notes(page=0, pageSize=100, label=None, include_archived=False)[source]¶
Load one page of this command’s notes, ordered oldest first.
- Parameters:
page (int) – Zero-based page number. Defaults to 0.
pageSize (int) – Notes per page, from 1 to 1000. Defaults to 100.
label (str | None) – Exact, case-sensitive label filter.
include_archived (bool) – Include archived notes. Defaults to False.
- Returns:
- Notes in the requested page. Requires
VIEW_RESOURCESand a knownagentGuid.
- Return type:
list[TuoniNote]
- result_status_done(reload=True)[source]¶
Check if the command has completed.
- Parameters:
reload (bool) – If True, reload the command data from the server to verify the current status.
- result_status_ongoing(reload=True)[source]¶
Check if the command is still ongoing.
- Parameters:
reload (bool) – If True, reload the command data from the server to verify the current status.
- send_update(config: dict, files: dict = None, persistence_type: str = 'TRANSIENT')[source]¶
Send an update to a running command (e.g. additional data for an ongoing operation).
- Parameters:
config (dict) – The update configuration to send (wrapped server-side as
updateConfiguration).files (dict) – Optional files to include with the update. Same format as the
filesparameter ofTuoniAgent.send_command().persistence_type (str) –
"TRANSIENT"(default) or"PERSISTENT".
Examples
>>> command.send_update({"input": "yes"})
- wait_done(interval=1, maxWait=0)[source]¶
Wait for the command to be done (success, failed, or canceled).
- Parameters:
interval (int) – The interval, in seconds, to reload the data from the server.
maxWait (int) – The maximum time to wait, in seconds, before giving up. A value of 0 means wait indefinitely.
- Returns:
The result object containing the data from the command execution, if available within the specified time. For commands that finish without a result (e.g. canceled before send), returns
Noneonce the terminal status is reached.- Return type:
- wait_result(interval=1, maxWait=0)[source]¶
Wait for the command result object to be available (command done or in case of ongoing result, the initial results)
- Parameters:
interval (int) – The interval, in seconds, to reload the data from the server.
maxWait (int) – The maximum time to wait, in seconds, before giving up. A value of 0 means wait indefinitely.
- Returns:
- The first result, or None on timeout or when a
command reaches a terminal status without producing a result.
- Return type:
TuoniResult | None
- wait_sent(interval=1, maxWait=0)[source]¶
Wait for the command to be sent
- Parameters:
interval (int) – The interval, in seconds, to reload the data from the server.
maxWait (int) – The maximum time to wait, in seconds, before giving up. A value of 0 means wait indefinitely.
- Returns:
- True if sent; False on timeout or when the command finishes
without being sent (including cancellation).
- Return type:
bool