events

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package events provides functionality for audit logging and event tracking.

Index

Constants

View Source
const (
	ResultSuccess = "Success"
	ResultFailed  = "Failed"
	ResultPending = "Pending"
)

Event states

View Source
const (
	SeverityInfo    = "Info"
	SeverityError   = "Error"
	SeverityWarning = "Warning"
)

Event severity levels

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditEvent

type AuditEvent struct {
	// Unique identifier for the log entry.
	ID int64 `json:"id"`
	// Name of the action performed (e.g., "cluster_stopped").
	ActionName actions.ActionOperation `json:"action_name"`
	// UTC timestamp of when the action occurred.
	EventTimestamp time.Time `json:"event_timestamp"`
	// Optional description for the action; can be nil.
	Description *string `json:"description,omitempty"`
	// ID of the affected resource (e.g., cluster_id, instance_id).
	ResourceID string `json:"resource_id"`
	// Type of resource affected (e.g., "cluster", "instance").
	ResourceType string `json:"resource_type"`
	// Outcome of the action (e.g., "success", "error").
	Result string `json:"result"`
	// Log severity level (e.g., "info", "warning", "error").
	Severity string `json:"severity"`
	// User or system entity responsible for the action.
	TriggeredBy string `json:"triggered_by"`
}

func ToAuditEvents

func ToAuditEvents(logs []models.AuditLog) []AuditEvent

ToAuditEvents converts AuditLogs to AuditEvents

type EventOptions

type EventOptions struct {
	Action       actions.ActionOperation
	Description  *string
	ResourceID   string
	ResourceType string
	Result       string
	Severity     string
	TriggeredBy  string
}

type EventService

type EventService struct {
	// contains filtered or unexported fields
}

func NewEventService

func NewEventService(sqlClient SQLEventClient, logger *zap.Logger) *EventService

NewEventService creates a new EventService instance.

func (*EventService) LogEvent

func (e *EventService) LogEvent(opts EventOptions) (int64, error)

LogEvent creates a new audit log entry and returns its ID.

func (*EventService) StartTracking

func (e *EventService) StartTracking(opts *EventOptions) *EventTracker

StartTracking begins tracking a new event and returns an EventTracker.

func (*EventService) UpdateEventStatus

func (e *EventService) UpdateEventStatus(eventID int64, result string) error

UpdateEventStatus updates the result status of an existing event.

type EventTracker

type EventTracker struct {
	// contains filtered or unexported fields
}

func (*EventTracker) Failed

func (t *EventTracker) Failed()

Failed marks the tracked event as failed.

func (*EventTracker) Success

func (t *EventTracker) Success()

Failed marks the tracked event status as failed.

type SQLEventClient

type SQLEventClient interface {
	AddEvent(event models.AuditLog) (int64, error)
	UpdateEventStatus(eventID int64, result string) error
}

type SystemAuditEvent

type SystemAuditEvent struct {
	AuditEvent
	// AccountID is the unique identifier of the cloud provider account.
	AccountID string `json:"account_id"`
	// Provider is the name of the cloud provider (e.g., "AWS", "GCP", "Azure").
	Provider string `json:"provider"`
}

SystemAuditEvent extends AuditEvent with system-specific fields.

func ToSystemAuditEvents

func ToSystemAuditEvents(logs []models.SystemAuditLogs) []SystemAuditEvent

ToSystemAuditEvents converts SystemAuditLogs to SystemAuditEvents

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL