models

package
v1.0.53 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalToEventData added in v1.0.35

func MarshalToEventData(data interface{}, output interface{})

func ProcessDiscordEvent added in v1.0.35

func ProcessDiscordEvent(url string, event *AccountIntegrationEvent) error

func ProcessWebhookEvent added in v1.0.35

func ProcessWebhookEvent(url string, event *AccountIntegrationEvent) (string, error)

Types

type API_AccountCreateAgent_PostData added in v1.0.42

type API_AccountCreateAgent_PostData struct {
	AccountId  primitive.ObjectID `json:"accountid" bson:"accountId"`
	AgentName  string             `json:"servername" bson:"serverName"`
	Port       int                `json:"serverPort" bson:"serverPort"`
	Memory     int64              `json:"serverMemory" bson:"serverMemory"`
	AdminPass  string             `json:"serverAdminPass" bson:"serverAdminPass"`
	ClientPass string             `json:"serverClientPass" bson:"serverClientPass"`
	APIKey     string             `json:"serverAPIKey" bson:"serverApiKey"`
}

type AccountAudit added in v1.0.14

type AccountAudit struct {
	ID      primitive.ObjectID `json:"_id" bson:"_id"`
	Type    string             `json:"type" bson:"type"`
	Message string             `json:"message" bson:"message"`

	CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
}

type AccountIntegrationEvent added in v1.0.35

type AccountIntegrationEvent struct {
	ID           primitive.ObjectID   `json:"_id" bson:"_id"`
	Type         IntegrationEventType `json:"type" bson:"type"`
	Retries      int                  `json:"retries" bson:"retries"`
	Status       string               `json:"status" bson:"status"`
	Data         interface{}          `json:"data" bson:"data"`
	ResponseData interface{}          `json:"responseData" bson:"responseData"`
	Completed    bool                 `json:"completed" bson:"completed"`
	Failed       bool                 `json:"failed" bson:"failed"`
	CreatedAt    time.Time            `json:"createdAt" bson:"createdAt"`
	UpdatedAt    time.Time            `json:"updatedAt" bson:"updatedAt"`
}

type AccountIntegrations added in v1.0.35

type AccountIntegrations struct {
	ID         primitive.ObjectID        `json:"_id" bson:"_id"`
	Type       IntegrationType           `json:"type" bson:"type"`
	Url        string                    `json:"url" bson:"url"`
	EventTypes []IntegrationEventType    `json:"eventTypes" bson:"eventTypes"`
	Events     []AccountIntegrationEvent `json:"events" bson:"events"`
	CreatedAt  time.Time                 `json:"createdAt" bson:"createdAt"`
	UpdatedAt  time.Time                 `json:"updatedAt" bson:"updatedAt"`
}

func (*AccountIntegrations) AddEvent added in v1.0.35

func (obj *AccountIntegrations) AddEvent(eventType IntegrationEventType, data interface{}) error

func (*AccountIntegrations) ProcessEvents added in v1.0.35

func (obj *AccountIntegrations) ProcessEvents() error

type AccountSessions

type AccountSessions struct {
	ID        primitive.ObjectID `json:"_id" bson:"_id"`
	AccountID primitive.ObjectID `json:"accountId" bson:"accountId"`
	UserID    primitive.ObjectID `json:"userId" bson:"userId"`
	Expiry    time.Time          `json:"expiry" bson:"expiry"`
}

type AccountState

type AccountState struct {
	Inactive       bool      `json:"inactive" bson:"inactive"`
	InactivityDate time.Time `json:"inactivityDate" bson:"inactivityDate"`
	DeleteDate     time.Time `json:"deleteDate" bson:"deleteDate"`
}

type Accounts

type Accounts struct {
	ID          primitive.ObjectID `json:"_id" bson:"_id"`
	AccountName string             `json:"accountName" bson:"accountName"`

	Sessions       primitive.A       `json:"-" bson:"sessions" mson:"collection=accountsessions"`
	SessionObjects []AccountSessions `json:"sessions" bson:"-"`

	Users       primitive.A `json:"-" bson:"users" mson:"collection=users"`
	UserObjects []Users     `json:"users" bson:"-"`

	Agents       primitive.A `json:"-" bson:"agents" mson:"collection=agents"`
	AgentObjects []Agents    `json:"agents" bson:"-"`

	Audit        primitive.A    `json:"-" bson:"audit" mson:"collection=accountaudit"`
	AuditObjects []AccountAudit `json:"audit" bson:"-"`

	State AccountState `json:"state" bson:"state"`

	Integrations       primitive.A           `json:"-" bson:"integrations" mson:"collection=accountintegrations"`
	IntegrationObjects []AccountIntegrations `json:"integrations" bson:"-"`

	CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"`
}

func (*Accounts) AddAudit added in v1.0.14

func (obj *Accounts) AddAudit(auditType string, message string) error

func (*Accounts) AddIntegration added in v1.0.36

func (obj *Accounts) AddIntegration(newIntegration AccountIntegrations) error

func (*Accounts) CreateIntegrationEvent added in v1.0.35

func (obj *Accounts) CreateIntegrationEvent(eventType IntegrationEventType, data interface{}) error

func (*Accounts) DeleteIntegration added in v1.0.36

func (obj *Accounts) DeleteIntegration(integrationId primitive.ObjectID) error

func (*Accounts) PopulateAgents

func (obj *Accounts) PopulateAgents() error

func (*Accounts) PopulateAudit added in v1.0.14

func (obj *Accounts) PopulateAudit() error

func (*Accounts) PopulateFromURLQuery added in v1.0.35

func (obj *Accounts) PopulateFromURLQuery(populateStrings []string) error

func (*Accounts) PopulateIntegrations added in v1.0.35

func (obj *Accounts) PopulateIntegrations() error

func (*Accounts) PopulateSessions

func (obj *Accounts) PopulateSessions() error

func (*Accounts) PopulateUsers

func (obj *Accounts) PopulateUsers() error

func (*Accounts) ProcessIntegrationEvents added in v1.0.35

func (obj *Accounts) ProcessIntegrationEvents() error

func (*Accounts) UpdateIntegration added in v1.0.36

func (obj *Accounts) UpdateIntegration(updatedIntegration AccountIntegrations) error

type AgentBackup added in v1.0.14

type AgentBackup struct {
	UUID     string `json:"uuid" bson:"uuid"`
	FileName string `json:"fileName" bson:"fileName"`
	Size     int64  `json:"size" bson:"size"`

	CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"`
}

type AgentConfig

type AgentConfig struct {
	Version          string  `json:"version" bson:"version"`
	Port             int     `json:"port" bson:"port"`
	Memory           int64   `json:"memory" bson:"memory"`
	IP               string  `json:"ip" bson:"ip"`
	BackupKeepAmount int     `json:"backupKeepAmount" bson:"backupKeepAmount"`
	BackupInterval   float32 `json:"backupInterval" bson:"backupInterval"`
}

type AgentLogs added in v1.0.14

type AgentLogs struct {
	ID        primitive.ObjectID `json:"_id" bson:"_id"`
	FileName  string             `json:"fileName" bson:"fileName"`
	Type      string             `json:"type" bson:"type"`
	Snippet   string             `json:"snippet" bson:"snippet"`
	CreatedAt time.Time          `json:"createdAt" bson:"createdAt"`
	UpdatedAt time.Time          `json:"updatedAt" bson:"updatedAt"`
}

type AgentMapData

type AgentMapData struct {
	Players   []AgentMapDataPlayer   `json:"players" bson:"players"`
	Buildings []AgentMapDataBuilding `json:"buildings" bson:"buildings"`
}

type AgentMapDataBuilding

type AgentMapDataBuilding struct {
	Name        string      `json:"name" bson:"name"`
	Class       string      `json:"class" bson:"class"`
	Location    Vector3F    `json:"location" bson:"location"`
	Rotation    float32     `json:"rotation" bson:"rotation"`
	BoundingBox BoundingBox `json:"boundingBox" bson:"boundingBox"`
}

type AgentMapDataPlayer

type AgentMapDataPlayer struct {
	Username string   `json:"username" bson:"username"`
	Location Vector3F `json:"location" bson:"location"`
	Online   bool     `json:"online" bson:"online"`
}

type AgentModConfig added in v1.0.14

type AgentModConfig struct {
	LatestSMLVersion    string                      `json:"lastestSMLVersion" bson:"lastestSMLVersion"`
	InstalledSMLVersion string                      `json:"installedSMLVersion" bson:"installedSMLVersion"`
	SelectedMods        []AgentModConfigSelectedMod `json:"selectedMods" bson:"selectedMods"`
}

type AgentModConfigSelectedMod added in v1.0.14

type AgentModConfigSelectedMod struct {
	Mod              primitive.ObjectID `json:"-" bson:"mod" mson:"collection=mods"`
	ModObject        Mods               `json:"mod" bson:"-"`
	DesiredVersion   string             `json:"desiredVersion" bson:"desiredVersion"`
	InstalledVersion string             `json:"installedVersion" bson:"installedVersion"`
	Installed        bool               `json:"installed" bson:"installed"`
	NeedsUpdate      bool               `json:"needsUpdate" bson:"needsUpdate"`
	Config           string             `json:"config" bson:"config"`
}

func (*AgentModConfigSelectedMod) PopulateMod added in v1.0.14

func (obj *AgentModConfigSelectedMod) PopulateMod()

type AgentSave added in v1.0.14

type AgentSave struct {
	UUID     string    `json:"uuid" bson:"uuid"`
	FileName string    `json:"fileName" bson:"fileName"`
	Size     int64     `json:"size" bson:"size"`
	ModTime  time.Time `json:"modTime" bson:"modTime"`

	CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"`
}

type AgentServerConfig

type AgentServerConfig struct {
	UpdateOnStart bool   `json:"updateOnStart" bson:"updateOnStart"`
	Branch        string `json:"branch" bson:"branch"`
	WorkerThreads int    `json:"workerThreads" bson:"workerThreads"`

	AutoRestart bool `json:"autoRestart" bson:"autoRestart"`

	// Settings for Server Ini files
	MaxPlayers            int  `json:"maxPlayers" bson:"maxPlayers"`
	AutoPause             bool `json:"autoPause" bson:"autoPause"`
	AutoSaveOnDisconnect  bool `json:"autoSaveOnDisconnect" bson:"autoSaveOnDisconnect"`
	AutoSaveInterval      int  `json:"autoSaveInterval" bson:"autoSaveInterval"`
	DisableSeasonalEvents bool `json:"disableSeasonalEvents" bson:"disableSeasonalEvents"`
}

type AgentStat added in v1.0.26

type AgentStat struct {
	ID        primitive.ObjectID `json:"_id" bson:"_id"`
	Running   bool               `json:"running" bson:"running"`
	CPU       float64            `json:"cpu" bson:"cpu"`
	MEM       float32            `json:"mem" bson:"mem"`
	CreatedAt time.Time          `json:"createdAt" bson:"createdAt"`
}

type AgentStatus

type AgentStatus struct {
	Online    bool `json:"online" bson:"online"`
	Running   bool `json:"running" bson:"running"`
	Installed bool `json:"installed" bson:"installed"`

	CPU float64 `json:"cpu" bson:"cpu"`
	RAM float64 `json:"ram" bson:"ram"`

	LastCommDate time.Time `json:"lastCommDate" bson:"lastCommDate"`

	InstalledSFVersion int64 `json:"installedSFVersion"`
	LatestSFVersion    int64 `json:"latestSFVersion"`
}

type AgentTask added in v1.0.14

type AgentTask struct {
	ID        primitive.ObjectID `json:"_id" bson:"_id"`
	Action    string             `json:"action" bson:"action"`
	Data      interface{}        `json:"data" bson:"data"`
	Completed bool               `json:"completed" bson:"completed"`
	Retries   int                `json:"retries" bson:"retries"`
}

func NewAgentTask added in v1.0.14

func NewAgentTask(action string, data interface{}) AgentTask

type Agents

type Agents struct {
	ID        primitive.ObjectID `json:"_id" bson:"_id"`
	AgentName string             `json:"agentName" bson:"agentName"`
	APIKey    string             `json:"apiKey" bson:"apiKey"`
	Status    AgentStatus        `json:"status" bson:"status"`

	Config       AgentConfig       `json:"config" bson:"config"`
	ServerConfig AgentServerConfig `json:"serverConfig" bson:"serverConfig"`

	MapData AgentMapData `json:"mapData" bson:"mapData"`

	Saves   []AgentSave   `json:"saves" bson:"saves"`
	Backups []AgentBackup `json:"backups" bson:"backups"`

	Tasks []AgentTask `json:"tasks" bson:"tasks"`

	Logs       primitive.A `json:"-" bson:"logs" mson:"collection=agentlogs"`
	LogObjects []AgentLogs `json:"logs" bson:"-"`

	Stats       primitive.A `json:"-" bson:"stats" mson:"collection=agentstats"`
	StatObjects []AgentStat `json:"stats" bson:"-"`

	ModConfig AgentModConfig `json:"modConfig" bson:"modConfig"`

	LatestAgentVersion string `json:"latestAgentVersion" bson:"latestAgentVersion"`

	CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"`
}

func NewAgent

func NewAgent(agentName string, port int, memory int64, apiKey string) Agents

func (*Agents) CheckBackups added in v1.0.25

func (obj *Agents) CheckBackups(basePath string) error

func (*Agents) CheckSaves added in v1.0.51

func (obj *Agents) CheckSaves(basePath string) error

func (*Agents) CreateStat added in v1.0.29

func (obj *Agents) CreateStat(running bool, cpu float64, mem float32) error

func (*Agents) PopulateFromURLQuery added in v1.0.35

func (obj *Agents) PopulateFromURLQuery(populateStrings []string) error

func (*Agents) PopulateLogs added in v1.0.14

func (obj *Agents) PopulateLogs() error

func (*Agents) PopulateModConfig added in v1.0.14

func (obj *Agents) PopulateModConfig()

func (*Agents) PopulateStats added in v1.0.29

func (obj *Agents) PopulateStats() error

func (*Agents) PurgeStats added in v1.0.29

func (obj *Agents) PurgeStats() error

func (*Agents) PurgeTasks added in v1.0.14

func (obj *Agents) PurgeTasks() error

type BoundingBox added in v1.0.47

type BoundingBox struct {
	Min Vector3F `json:"min" bson:"min"`
	Max Vector3F `json:"max" bson:"max"`
}

type ClaimServer_PostData added in v1.0.42

type ClaimServer_PostData struct {
	AdminPass  string `json:"adminPass"`
	ClientPass string `json:"clientPass"`
}

type EventData added in v1.0.35

type EventData struct {
	IntegrationId primitive.ObjectID `json:"integrationId"`
	EventId       primitive.ObjectID `json:"eventId"`
	EventType     string             `json:"eventType"`
	EventTime     time.Time          `json:"eventTime"`
}

type EventDataAgentOffline added in v1.0.35

type EventDataAgentOffline struct {
	EventData `json:"eventData"`
	AgentName string `json:"agentName"`
}

type EventDataAgentOnline added in v1.0.35

type EventDataAgentOnline struct {
	EventData `json:"eventData"`
	AgentName string `json:"agentName"`
}

type EventDataBasic added in v1.0.35

type EventDataBasic struct {
	EventData `json:"eventData"`
}

type IntegrationEventType added in v1.0.35

type IntegrationEventType int64
const (
	IntegrationEventTypeAgentOnline  IntegrationEventType = 0
	IntegrationEventTypeAgentOffline IntegrationEventType = 1
	IntegrationEventTypePlayerJoined IntegrationEventType = 2
	IntegrationEventTypePlayerLeft   IntegrationEventType = 3
)

type IntegrationType added in v1.0.35

type IntegrationType int64
const (
	IntegrationWebhook IntegrationType = 0
	IntegrationDiscord IntegrationType = 1
)

type ModVersion added in v1.0.14

type ModVersion struct {
	ID           string                 `json:"id" bson:"id"`
	Version      string                 `json:"version" bson:"version"`
	CreatedAt    string                 `json:"created_at" bson:"created_at"`
	SMLVersion   string                 `json:"sml_version" bson:"sml_version"`
	Targets      []ModVersionTarget     `json:"targets" bson:"targets"`
	Dependencies []ModVersionDependency `json:"dependencies" bson:"dependencies"`
}

type ModVersionDependency added in v1.0.14

type ModVersionDependency struct {
	ModReference string `json:"mod_id" bson:"modReference"`
	Condition    string `json:"condition" bson:"condition"`
	Optional     bool   `json:"optional" bson:"optional"`
}

type ModVersionTarget added in v1.0.14

type ModVersionTarget struct {
	TargetName string `json:"targetName" bson:"targetName"`
	Link       string `json:"link" bson:"link"`
	Hash       string `json:"hash" bson:"hash"`
	Size       int64  `json:"size" bson:"size"`
	VersionID  string `json:"VersionID" bson:"VersionID"`
}

type Mods added in v1.0.14

type Mods struct {
	ID           primitive.ObjectID `json:"_id" bson:"_id"`
	ModID        string             `json:"id" bson:"modId"`
	ModName      string             `json:"name" bson:"modName"`
	ModReference string             `json:"mod_reference" bson:"modReference"`
	Hidden       bool               `json:"hidden" bson:"hidden"`
	LogoURL      string             `json:"logo" bson:"logoUrl"`
	Downloads    int                `json:"downloads" bson:"downloads"`
	Versions     []ModVersion       `json:"versions" bson:"versions"`
}

type User2FAState

type User2FAState struct {
	TwoFASetup  bool   `json:"twoFASetup" bson:"twoFASetup"`
	TwoFASecret string `json:"-" bson:"twoFASecret"`
}

type UserAPIKey added in v1.0.14

type UserAPIKey struct {
	Key      string `json:"-" bson:"key"`
	ShortKey string `json:"shortKey" bson:"shortKey"`
}

type Users

type Users struct {
	ID       primitive.ObjectID `json:"_id" bson:"_id"`
	Email    string             `json:"email" bson:"email"`
	Password string             `json:"-" bson:"password"`

	IsAccountAdmin bool `json:"isAccountAdmin" bson:"isAccountAdmin"`
	Active         bool `json:"active" bson:"active"`

	TwoFAState User2FAState `json:"twoFAState" bson:"twoFAState"`

	ProfileImageURL string `json:"profileImageUrl" bson:"profileImageUrl"`

	APIKeys []UserAPIKey `json:"apiKeys" bson:"apiKeys"`

	InviteCode string `json:"inviteCode" bson:"inviteCode"`

	LastActive time.Time `json:"lastActive" bson:"lastActive"`
	CreatedAt  time.Time `json:"createdAt" bson:"createdAt"`
	UpdatedAt  time.Time `json:"updatedAt" bson:"updatedAt"`
}

type Vector3F

type Vector3F struct {
	X float32 `json:"x" bson:"x"`
	Y float32 `json:"y" bson:"y"`
	Z float32 `json:"z" bson:"z"`
}

type WorkflowAction added in v1.0.42

type WorkflowAction struct {
	Type         string `json:"type" bson:"type"`
	Status       string `json:"status" bson:"status"`
	ErrorMessage string `json:"error" bson:"error"`
	RetryCount   int    `json:"retryCount" bson:"retryCount"`
}

func (*WorkflowAction) ClaimServer added in v1.0.42

func (obj *WorkflowAction) ClaimServer(workflowData API_AccountCreateAgent_PostData) error

func (*WorkflowAction) CreateAgent added in v1.0.42

func (obj *WorkflowAction) CreateAgent(workflowData API_AccountCreateAgent_PostData, theAccount *Accounts) error

func (*WorkflowAction) InstallSFServer added in v1.0.42

func (obj *WorkflowAction) InstallSFServer(workflowData API_AccountCreateAgent_PostData) error

func (*WorkflowAction) StartSFServer added in v1.0.42

func (obj *WorkflowAction) StartSFServer(workflowData API_AccountCreateAgent_PostData) error

func (*WorkflowAction) WaitForInstalled added in v1.0.42

func (obj *WorkflowAction) WaitForInstalled(workflowData API_AccountCreateAgent_PostData) (bool, error)

func (*WorkflowAction) WaitForOnline added in v1.0.42

func (obj *WorkflowAction) WaitForOnline(workflowData API_AccountCreateAgent_PostData) (bool, error)

func (*WorkflowAction) WaitForRunning added in v1.0.42

func (obj *WorkflowAction) WaitForRunning(workflowData API_AccountCreateAgent_PostData) (bool, error)

type Workflows added in v1.0.42

type Workflows struct {
	ID      primitive.ObjectID `json:"_id" bson:"_id"`
	Type    string             `json:"type" bson:"type"`
	Actions []WorkflowAction   `json:"actions" bson:"actions"`
	Status  string             `json:"status" bson:"status"`
	Data    interface{}        `json:"data" bson:"data"`
}

func (*Workflows) ProcessCurrentAction added in v1.0.42

func (obj *Workflows) ProcessCurrentAction()

func (*Workflows) ValidateStatus added in v1.0.42

func (obj *Workflows) ValidateStatus()

Jump to

Keyboard shortcuts

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