55// Copyright 2025 Oxide Computer Company
66
77use crate :: schema:: { audit_log, audit_log_complete} ;
8+ use crate :: SqlU16 ;
89use chrono:: { DateTime , Utc } ;
910use diesel:: prelude:: * ;
1011use nexus_types:: external_api:: views;
@@ -71,6 +72,7 @@ pub struct AuditLogEntry {
7172 // Fields that are not present on init
7273 /// Time log entry was completed with info about result of operation
7374 pub time_completed : DateTime < Utc > ,
75+ pub http_status_code : SqlU16 ,
7476
7577 // Error information if the action failed
7678 pub error_code : Option < String > ,
@@ -108,11 +110,15 @@ impl AuditLogEntryInit {
108110#[ diesel( table_name = audit_log) ]
109111pub struct AuditLogCompletion {
110112 pub time_completed : DateTime < Utc > ,
113+ pub http_status_code : SqlU16 ,
111114}
112115
113116impl AuditLogCompletion {
114- pub fn new ( ) -> Self {
115- Self { time_completed : Utc :: now ( ) }
117+ pub fn new ( http_status_code : u16 ) -> Self {
118+ Self {
119+ time_completed : Utc :: now ( ) ,
120+ http_status_code : SqlU16 ( http_status_code) ,
121+ }
116122 }
117123}
118124
@@ -138,6 +144,7 @@ impl From<AuditLogEntry> for views::AuditLogEntry {
138144 actor_silo_id : entry. actor_silo_id ,
139145 access_method : entry. access_method ,
140146 time_completed : entry. time_completed ,
147+ http_status_code : entry. http_status_code . 0 ,
141148 error_code : entry. error_code ,
142149 error_message : entry. error_message ,
143150 }
0 commit comments