using System; using Newtonsoft.Json; namespace Unity.Pipeline.Models { /// /// Response model for /api/exec endpoint. /// Contains execution result and metadata for remote command execution. /// [Serializable] public class CommandExecutionResponse : BaseResponse { /// /// Whether the command executed successfully. /// [JsonProperty("success")] public bool Success { get; set; } /// /// Name of the command that was executed. /// [JsonProperty("command")] public string Command { get; set; } /// /// Result returned by the command (if any). /// [JsonProperty("result")] public object Result { get; set; } /// /// Execution duration in milliseconds. /// [JsonProperty("executionTimeMs")] public long? ExecutionTimeMs { get; set; } /// /// Create a successful execution response. /// public static CommandExecutionResponse CmdSuccess(string command, object result = null, long? executionTimeMs = null) { return new CommandExecutionResponse { Success = true, Command = command, ExecutedAt = DateTime.UtcNow, Result = result, ExecutionTimeMs = executionTimeMs }; } /// /// Create a failed execution response. /// public static CommandExecutionResponse CmdFailure(string cmd, string error, string errorDetails) { return new CommandExecutionResponse { Command = cmd, Success = false, ExecutedAt = DateTime.UtcNow, Error = error, ErrorDetails = errorDetails }; } } }