store

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProxyTargetURL     = "https://127.0.0.1:8007"        // The target server URL
	ModifiedFilePath   = "/js/proxmox-backup-gui.js"     // The specific JS file to modify
	CertFile           = "/etc/proxmox-backup/proxy.pem" // Path to generated SSL certificate
	KeyFile            = "/etc/proxmox-backup/proxy.key" // Path to generated private key
	TimerBasePath      = "/lib/systemd/system"
	DbBasePath         = "/var/lib/proxmox-backup"
	AgentMountBasePath = "/mnt/pbs-plus-mounts"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ACLRequest

type ACLRequest struct {
	Path   string `json:"path"`
	Role   string `json:"role"`
	AuthId string `json:"auth-id"`
}

type APIToken

type APIToken struct {
	TokenId string `json:"tokenid"`
	Value   string `json:"value"`
}

func GetAPITokenFromFile

func GetAPITokenFromFile() (*APIToken, error)

func (*APIToken) SaveToFile

func (token *APIToken) SaveToFile() error

type APITokenRequest

type APITokenRequest struct {
	Comment string `json:"comment"`
}

type APITokenResponse

type APITokenResponse struct {
	Data APIToken `json:"data"`
}

type Exclusion added in v0.3.0

type Exclusion struct {
	JobID   string `db:"job_id" json:"job_id"`
	Path    string `db:"path" json:"path"`
	Comment string `db:"comment" json:"comment"`
}

type Job

type Job struct {
	ID               string      `db:"id" json:"id"`
	Store            string      `db:"store" json:"store"`
	Target           string      `db:"target" json:"target"`
	Subpath          string      `db:"subpath" json:"subpath"`
	Schedule         string      `db:"schedule" json:"schedule"`
	Comment          string      `db:"comment" json:"comment"`
	NotificationMode string      `db:"notification_mode" json:"notification-mode"`
	Namespace        string      `db:"namespace" json:"ns"`
	NextRun          *int64      `db:"next_run" json:"next-run"`
	LastRunUpid      *string     `db:"last_run_upid" json:"last-run-upid"`
	LastRunState     *string     `json:"last-run-state"`
	LastRunEndtime   *int64      `json:"last-run-endtime"`
	Duration         *int64      `json:"duration"`
	Exclusions       []Exclusion `json:"exclusions"`
	RawExclusions    string      `json:"rawexclusions"`
}

Job represents the pbs-disk-backup-job-status model

type PBSStatus

type PBSStatus struct {
	BootInfo      map[string]interface{} `json:"boot-info"`
	CPU           float64                `json:"cpu"`
	CPUInfo       map[string]interface{} `json:"cpuinfo"`
	CurrentKernel map[string]interface{} `json:"current-kernel"`
	Info          map[string]string      `json:"info"`
	KVersion      string                 `json:"kversion"`
	LoadAvg       []float32              `json:"loadavg"`
	Memory        map[string]int64       `json:"memory"`
	Root          map[string]int64       `json:"root"`
	Swap          map[string]int64       `json:"swap"`
	Uptime        int64                  `json:"uptime"`
	Wait          float32                `json:"wait"`
}

type PBSStatusResponse

type PBSStatusResponse struct {
	Data PBSStatus `json:"data"`
}

type PartialFile added in v0.3.0

type PartialFile struct {
	Path    string `db:"path" json:"path"`
	Comment string `db:"comment" json:"comment"`
}

type Store

type Store struct {
	Db         *sql.DB
	LastToken  *Token
	APIToken   *APIToken
	HTTPClient *http.Client
}

Store holds the database instance

func Initialize

func Initialize() (*Store, error)

Initialize initializes the database connection and returns a Store instance

func (*Store) AgentPing

func (storeInstance *Store) AgentPing(agentTarget *Target) (bool, error)

func (*Store) CheckProxyAuth added in v0.3.2

func (storeInstance *Store) CheckProxyAuth(r *http.Request) error

func (*Store) CreateAPIToken

func (storeInstance *Store) CreateAPIToken() (*APIToken, error)

func (*Store) CreateExclusion added in v0.3.0

func (store *Store) CreateExclusion(exclusion Exclusion) error

func (*Store) CreateJob

func (store *Store) CreateJob(job Job) error

CreateJob inserts a new Job into the database

func (*Store) CreatePartialFile added in v0.3.0

func (store *Store) CreatePartialFile(partialFile PartialFile) error

func (*Store) CreateTables

func (store *Store) CreateTables() error

CreateTables creates the necessary tables in the SQLite database

func (*Store) CreateTarget

func (store *Store) CreateTarget(target Target) error

CreateTarget inserts a new Target into the database

func (*Store) DeleteExclusion added in v0.3.0

func (store *Store) DeleteExclusion(path string) error

DeleteExclusion deletes a Exclusion from the database

func (*Store) DeleteJob

func (store *Store) DeleteJob(id string) error

DeleteJob deletes a Job from the database

func (*Store) DeletePartialFile added in v0.3.0

func (store *Store) DeletePartialFile(path string) error

DeletePartialFile deletes a PartialFile from the database

func (*Store) DeleteTarget

func (store *Store) DeleteTarget(name string) error

DeleteTarget deletes a Target from the database

func (*Store) GetAllGlobalExclusions added in v0.4.0

func (store *Store) GetAllGlobalExclusions() ([]Exclusion, error)

func (*Store) GetAllJobExclusions added in v0.3.0

func (store *Store) GetAllJobExclusions(jobId string) ([]Exclusion, error)

func (*Store) GetAllJobs

func (store *Store) GetAllJobs() ([]Job, error)

GetAllJobs retrieves all Job records from the database

func (*Store) GetAllPartialFiles added in v0.3.0

func (store *Store) GetAllPartialFiles() ([]PartialFile, error)

func (*Store) GetAllTargets

func (store *Store) GetAllTargets() ([]Target, error)

func (*Store) GetAllTargetsByIP added in v0.3.2

func (store *Store) GetAllTargetsByIP(ip string) ([]Target, error)

func (*Store) GetExclusion added in v0.3.0

func (store *Store) GetExclusion(path string) (*Exclusion, error)

func (*Store) GetJob

func (store *Store) GetJob(id string) (*Job, error)

GetJob retrieves a Job by ID

func (*Store) GetJobTask added in v0.4.0

func (storeInstance *Store) GetJobTask(ctx context.Context, taskChan chan Task, job *Job) error

func (*Store) GetPBSStatus

func (storeInstance *Store) GetPBSStatus() (*PBSStatus, error)

func (*Store) GetPartialFile added in v0.3.0

func (store *Store) GetPartialFile(path string) (*PartialFile, error)

func (*Store) GetTarget

func (store *Store) GetTarget(name string) (*Target, error)

GetTarget retrieves a Target by ID

func (*Store) GetTaskByUPID

func (storeInstance *Store) GetTaskByUPID(upid string) (*Task, error)

func (*Store) GetTaskEndTime

func (storeInstance *Store) GetTaskEndTime(task *Task) (int64, error)

func (*Store) ProxmoxHTTPRequest

func (storeInstance *Store) ProxmoxHTTPRequest(method, url string, body io.Reader, respBody any) error

func (*Store) SetSchedule

func (store *Store) SetSchedule(job Job) error

func (*Store) UpdateExclusion added in v0.3.0

func (store *Store) UpdateExclusion(exclusion Exclusion) error

UpdateExclusion updates an existing Exclusion in the database

func (*Store) UpdateJob

func (store *Store) UpdateJob(job Job) error

UpdateJob updates an existing Job in the database

func (*Store) UpdatePartialFile added in v0.3.0

func (store *Store) UpdatePartialFile(partialFile PartialFile) error

UpdatePartialFile updates an existing PartialFile in the database

func (*Store) UpdateTarget

func (store *Store) UpdateTarget(target Target) error

UpdateTarget updates an existing Target in the database

type Target

type Target struct {
	Name             string `db:"name" json:"name"`
	Path             string `db:"path" json:"path"`
	IsAgent          bool   `json:"is_agent"`
	ConnectionStatus bool   `json:"connection_status"`
}

Target represents the pbs-model-targets model

type Task

type Task struct {
	WID        string `json:"id"`
	Node       string `json:"node"`
	PID        int    `json:"pid"`
	PStart     int    `json:"pstart"`
	StartTime  int64  `json:"starttime"`
	EndTime    int64  `json:"endtime"`
	UPID       string `json:"upid"`
	User       string `json:"user"`
	WorkerType string `json:"worker_type"`
	Status     string `json:"status"`
	ExitStatus string `json:"exitstatus"`
}

type TaskResponse

type TaskResponse struct {
	Data  Task `json:"data"`
	Total int  `json:"total"`
}

type TimerInfo

type TimerInfo struct {
	Next      time.Time
	Left      string
	Last      time.Time
	Passed    string
	Unit      string
	Activates string
}

type Token

type Token struct {
	CSRFToken string `json:"CSRFPreventionToken"`
	Ticket    string `json:"ticket"`
	Username  string `json:"username"`
}

type TokenRequest

type TokenRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type TokenResponse

type TokenResponse struct {
	Data Token `json:"data"`
}

Jump to

Keyboard shortcuts

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