using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Unity.Pipeline.Models
{
///
/// Base class for all responses. Serve also as the base class for all errors.
///
[Serializable]
public class BaseResponse
{
///
/// Response message if no error
///
[JsonProperty("message")]
public string Message { get; set; }
///
/// Machine-actionable warnings for the caller: things the server dropped, coerced, or
/// wants the agent to correct (e.g. an unrecognized option value), without failing the
/// request. Null when there is nothing to say, and omitted from the JSON in EVERY mode
/// (an empty warnings array carries no information — attribute-level gating, so this
/// holds on all endpoints and in verbose serialization too). (AUTHAPI-21)
///
[JsonProperty("warnings", NullValueHandling = NullValueHandling.Ignore)]
public List Warnings { get; set; }
///
/// Error message if the command failed.
///
[JsonProperty("error")]
public string Error { get; set; }
///
/// Additional error details for debugging.
///
[JsonProperty("errorDetails")]
public string ErrorDetails { get; set; }
///
/// When was the response created.
///
///
/// On the /api/exec wire this is emitted only in verbose mode — the lean/verbose gating lives
/// in ExecResponseSerializer, NOT here, so every other serialization of this type
/// (status endpoints, logs, tests) keeps the field. (AUTHAPI-21)
///
[JsonProperty("executedAt")]
public DateTime ExecutedAt { get; set; }
///
/// Create a failed execution response.
///
/// Error message.
/// Additional error details for debugging.
/// A response with / set.
public static BaseResponse Failure(string error, string errorDetails)
{
return new BaseResponse
{
ExecutedAt = DateTime.UtcNow,
Error = error,
ErrorDetails = errorDetails
};
}
}
}