models

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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromDBScheduledActionToActions

func FromDBScheduledActionToActions(dbactions []DBScheduledAction) []actions.Action

FromDBScheduledActionToActions transforms a slice of DBScheduledAction into a slice of Action respecting their tipe

func FromDBScheduledActionToCronAction

func FromDBScheduledActionToCronAction(action DBScheduledAction) *actions.CronAction

FromDBScheduledActionToScheduledAction translates a DBScheduledAction object into actions.ScheduledAction

func FromDBScheduledActionToScheduledAction

func FromDBScheduledActionToScheduledAction(action DBScheduledAction) *actions.ScheduledAction

FromDBScheduledActionToScheduledAction translates a DBScheduledAction object into actions.ScheduledAction

Types

type AuditLog

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

AuditLog represents an immutable record of an action taken within the system. It provides key metadata such as the action performed, the resource involved, the result, severity, and the user who triggered the event.

type ClustersSummary

type ClustersSummary struct {
	Running  int `json:"running"`
	Stopped  int `json:"stopped"`
	Archived int `json:"archived"`
}

type DBScheduledAction

type DBScheduledAction struct {
	// ID is the unique identifier of the Action
	ID string `db:"id"`

	// Type represents the type of the action (Cron based, Scheduled...)
	Type string `db:"type"`

	// Timestamp is the time when the action will be executed
	Timestamp sql.NullTime `db:"time"`

	// CronExpression is the cron string used for re-scheduling the action like a CronTab
	CronExpression sql.NullString `db:"cron_exp"`

	// Action specifies which action will be performed over the target
	Operation actions.ActionOperation `db:"operation"`

	// ClusterID specifies the cluster as the action's target
	ClusterID string `db:"cluster_id"`

	// Region is the region where the cluster is running
	Region string `db:"region"`

	// AccountName is the account where the cluster is located
	AccountName string `db:"account_name"`

	// Instances is the list of instances of the cluster that will be impacted by the aciton
	Instances pq.StringArray `db:"instances"`

	// Status represents the status of the current action. Check action_status table for more info
	Status string `db:"status"`

	// Enabled is a boolean for enable/disable this action execution
	Enable bool `db:"enabled"`
}

DBScheduledAction is an intermediate struct used to map Scheduled Actions and their target's data into actions.ScheduledActions It provides a detailed representation of when, what action, and which target the action has

type InstanceDB

type InstanceDB struct {
	// ID is the unique identifier of the instance.
	ID string `db:"id"`

	// Name represents the name of the instance.
	// In some cloud providers, the name is managed as a tag.
	Name string `db:"name"`

	// Provider specifies the cloud provider (public or private) where the instance is hosted.
	Provider inventory.CloudProvider `db:"provider"`

	// InstanceType represents the type, size, or flavor of the instance.
	InstanceType string `db:"instance_type"`

	// AvailabilityZone indicates the zone in which the instance is running.
	AvailabilityZone string `db:"availability_zone"`

	// Status is the current operational status of the instance (e.g., running, stopped).
	Status inventory.InstanceStatus `db:"status"`

	// ClusterID is the identifier of the cluster to which the instance belongs.
	ClusterID string `db:"cluster_id"`

	// TagKey is the key of a tag associated with the instance.
	TagKey string `db:"key"`

	// TagValue is the value of a tag associated with the instance.
	TagValue string `db:"value"`

	// InstanceID is a field from the tags table, used internally for parsing join results.
	// It is not needed directly in inventory.Instance objects.
	InstanceID string `db:"instance_id"`

	// LastScanTimestamp is the timestamp of the most recent scan performed on the instance.
	LastScanTimestamp time.Time `db:"last_scan_timestamp"`

	// CreationTimestamp is the timestamp when the instance was created.
	CreationTimestamp time.Time `db:"creation_timestamp"`

	// Age is the number of days since the instance was created.
	Age int `db:"age"`

	// DailyCost represents the daily cost of the instance in US dollars.
	DailyCost float64 `db:"daily_cost"`

	// TotalCost represents the total cost of the instance in US dollars since its creation.
	TotalCost float64 `db:"total_cost"`
}

InstanceDB is an intermediate struct used to map instances and their tags into inventory.Instance objects. It provides a detailed representation of an instance, including metadata, tags, and cost-related information.

type InstancesSummary

type InstancesSummary struct {
	Count int `json:"count"`
}

type OverviewSummary

type OverviewSummary struct {
	Clusters  ClustersSummary  `json:"clusters"`
	Instances InstancesSummary `json:"instances"`
	Providers ProvidersSummary `json:"providers"`
	Scanner   Scanner          `json:"scanner"`
}

type ProviderDetail

type ProviderDetail struct {
	AccountCount int `json:"account_count"`
	ClusterCount int `json:"cluster_count"`
}

type ProvidersSummary

type ProvidersSummary struct {
	AWS   ProviderDetail `json:"aws"`
	GCP   ProviderDetail `json:"gcp"`
	Azure ProviderDetail `json:"azure"`
}

type Scanner added in v0.4.2

type Scanner struct {
	LastScanTimestamp *time.Time `json:"last_scan_timestamp"`
}

type SystemAuditLogs

type SystemAuditLogs struct {
	// Base audit log data.
	AuditLog
	// Cloud provider account ID.
	AccountID string `db:"account_id"`
	// Cloud provider name (e.g., AWS, GCP).
	Provider string `db:"provider"`
}

SystemAuditLogs extends AuditLog with cloud provider metadata.

Jump to

Keyboard shortcuts

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