2025-09-23 14:34:24 +03:00
|
|
|
package audit
|
|
|
|
|
|
2026-11-20 17:14:41 +03:00
|
|
|
import "encoding/json"
|
|
|
|
|
|
2025-09-23 14:34:24 +03:00
|
|
|
// Main info about audit
|
|
|
|
|
type RecordAudit struct {
|
2026-11-20 17:14:41 +03:00
|
|
|
// Arguments as JSON text
|
2025-09-23 14:34:24 +03:00
|
|
|
Arguments string `json:"args"`
|
|
|
|
|
|
|
|
|
|
// Call
|
|
|
|
|
Call string `json:"call"`
|
|
|
|
|
|
|
|
|
|
// GUID
|
|
|
|
|
GUID string `json:"guid"`
|
|
|
|
|
|
2025-09-27 01:06:15 +03:00
|
|
|
// Correlation ID
|
|
|
|
|
CorrelationID string `json:"correlation_id"`
|
|
|
|
|
|
2026-11-20 17:14:41 +03:00
|
|
|
// Keyword arguments as JSON text
|
2025-09-23 14:34:24 +03:00
|
|
|
Kwargs string `json:"kwargs"`
|
|
|
|
|
|
|
|
|
|
// RemoteAddr
|
|
|
|
|
RemoteAddr string `json:"remote_addr"`
|
|
|
|
|
|
|
|
|
|
// Response time
|
|
|
|
|
ResponseTime float64 `json:"responsetime"`
|
|
|
|
|
|
|
|
|
|
// Result
|
|
|
|
|
Result string `json:"result"`
|
|
|
|
|
|
|
|
|
|
// Status code
|
|
|
|
|
StatusCode uint64 `json:"statuscode"`
|
|
|
|
|
|
|
|
|
|
// Tags
|
|
|
|
|
Tags string `json:"tags"`
|
|
|
|
|
|
|
|
|
|
// Timestamp
|
|
|
|
|
Timestamp float64 `json:"timestamp"`
|
|
|
|
|
|
|
|
|
|
// TimestampEnd
|
|
|
|
|
TimestampEnd float64 `json:"timestampEnd"`
|
|
|
|
|
|
|
|
|
|
// User
|
|
|
|
|
User string `json:"user"`
|
2026-09-04 17:29:39 +04:00
|
|
|
|
|
|
|
|
// Public Session ID
|
|
|
|
|
PublicSessionID string `json:"public_session_id"`
|
2026-11-20 17:14:41 +03:00
|
|
|
|
|
|
|
|
// TTL
|
|
|
|
|
TTL string `json:"_ttl"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UnmarshalJSON accepts both JSON-encoded strings and structured arguments.
|
|
|
|
|
func (r *RecordAudit) UnmarshalJSON(data []byte) error {
|
|
|
|
|
type recordAudit RecordAudit
|
|
|
|
|
response := struct {
|
|
|
|
|
*recordAudit
|
|
|
|
|
Arguments auditJSONText `json:"args"`
|
|
|
|
|
Kwargs auditJSONText `json:"kwargs"`
|
|
|
|
|
}{
|
|
|
|
|
recordAudit: (*recordAudit)(r),
|
|
|
|
|
Arguments: auditJSONText{value: &r.Arguments, opening: '['},
|
|
|
|
|
Kwargs: auditJSONText{value: &r.Kwargs, opening: '{'},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return json.Unmarshal(data, &response)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type auditJSONText struct {
|
|
|
|
|
value *string
|
|
|
|
|
opening byte
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (f *auditJSONText) UnmarshalJSON(data []byte) error {
|
|
|
|
|
if len(data) > 0 && data[0] == f.opening {
|
|
|
|
|
*f.value = string(data)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
return json.Unmarshal(data, f.value)
|
2025-09-23 14:34:24 +03:00
|
|
|
}
|
2025-09-27 01:06:15 +03:00
|
|
|
|
|
|
|
|
// Main info about audit
|
|
|
|
|
type ItemAudit struct {
|
|
|
|
|
// Args
|
|
|
|
|
Args string `json:"args"`
|
|
|
|
|
|
|
|
|
|
// Call
|
|
|
|
|
Call string `json:"call"`
|
|
|
|
|
|
|
|
|
|
// GUID
|
|
|
|
|
GUID string `json:"guid"`
|
|
|
|
|
|
|
|
|
|
// Correlation ID
|
|
|
|
|
CorrelationID string `json:"correlation_id"`
|
|
|
|
|
|
|
|
|
|
// Kwargs
|
|
|
|
|
Kwargs string `json:"kwargs"`
|
|
|
|
|
|
|
|
|
|
// RemoteAddr
|
|
|
|
|
RemoteAddr string `json:"remote_addr"`
|
|
|
|
|
|
|
|
|
|
// Response time
|
|
|
|
|
ResponseTime float64 `json:"responsetime"`
|
|
|
|
|
|
|
|
|
|
// Result
|
|
|
|
|
Result string `json:"result"`
|
|
|
|
|
|
|
|
|
|
// Status code
|
|
|
|
|
StatusCode uint64 `json:"statuscode"`
|
|
|
|
|
|
|
|
|
|
// Timestamp
|
|
|
|
|
Timestamp float64 `json:"timestamp"`
|
|
|
|
|
|
|
|
|
|
// Timestamp End
|
|
|
|
|
TimestampEnd float64 `json:"timestampEnd"`
|
|
|
|
|
|
|
|
|
|
// User
|
|
|
|
|
User string `json:"user"`
|
|
|
|
|
|
2026-09-04 17:29:39 +04:00
|
|
|
// Public Session ID
|
|
|
|
|
PublicSessionID string `json:"public_session_id"`
|
|
|
|
|
|
2025-09-27 01:06:15 +03:00
|
|
|
// TTL
|
|
|
|
|
TTL string `json:"_ttl"`
|
2026-09-28 13:20:06 +03:00
|
|
|
|
|
|
|
|
// Resource group ID
|
|
|
|
|
ResgroupID uint64 `json:"resgroup_id"`
|
|
|
|
|
|
|
|
|
|
// Account ID
|
|
|
|
|
AccountID uint64 `json:"account_id"`
|
|
|
|
|
|
|
|
|
|
// Compute ID
|
|
|
|
|
ComputeID uint64 `json:"compute_id"`
|
|
|
|
|
|
|
|
|
|
// VINS ID
|
|
|
|
|
VINSID uint64 `json:"vins_id"`
|
|
|
|
|
|
|
|
|
|
// Service ID
|
|
|
|
|
ServiceID uint64 `json:"service_id"`
|
|
|
|
|
|
|
|
|
|
// K8S ID
|
|
|
|
|
K8SID uint64 `json:"k8s_id"`
|
|
|
|
|
|
|
|
|
|
// FLIPGroup ID
|
|
|
|
|
FLIPGroupID uint64 `json:"flipgroup_id"`
|
|
|
|
|
|
|
|
|
|
// Load balancer ID
|
|
|
|
|
LBID uint64 `json:"lb_id"`
|
|
|
|
|
|
|
|
|
|
// SEP ID
|
|
|
|
|
SEPID uint64 `json:"sep_id"`
|
|
|
|
|
|
|
|
|
|
// Node IDs
|
|
|
|
|
NodeIDs []uint64 `json:"node_ids"`
|
|
|
|
|
|
|
|
|
|
// Persistent disk IDs associated with the operation
|
|
|
|
|
DiskIDs []uint64 `json:"disk_ids"`
|
|
|
|
|
|
2026-10-23 16:13:20 +03:00
|
|
|
// VM folder ID
|
|
|
|
|
VMFolderID uint64 `json:"vmfolder_id"`
|
|
|
|
|
|
2026-09-28 13:20:06 +03:00
|
|
|
// API task ID for asynchronous calls
|
|
|
|
|
APITask string `json:"apitask"`
|
2025-09-27 01:06:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// List of audits
|
|
|
|
|
type ListAudits struct {
|
|
|
|
|
// Data
|
|
|
|
|
Data []ItemAudit `json:"data"`
|
|
|
|
|
|
|
|
|
|
// EntryCount
|
|
|
|
|
EntryCount uint64 `json:"entryCount"`
|
|
|
|
|
}
|