vm_repo

package
v0.0.0-...-e71a76f Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Collection     *mongo.Collection
	RestrictUserID *string
	Version        *string

	base_clients.ActivityResourceClient[model.VM]
	base_clients.ResourceClient[model.VM]
}

Client is used to manage VMs in the database.

func New

func New(version ...string) *Client

New returns a new VM client.

func (*Client) Create

func (client *Client) Create(id, owner string, params *model.VmCreateParams) (*model.VM, error)

Create creates a new VM.

func (*Client) DeleteSubsystem

func (client *Client) DeleteSubsystem(id, key string) error

DeleteSubsystem erases a subsystem from a VM. It prepends the key with `subsystems` and unsets it.

func (*Client) GetUsage

func (client *Client) GetUsage() (*model.VmUsage, error)

GetUsage returns the usage in CPU cores, RAM, disk size and snapshots.

func (*Client) IncludeDeletedResources

func (client *Client) IncludeDeletedResources() *Client

IncludeDeletedResources makes the client include deleted VMs.

func (*Client) LastAccessedBefore

func (client *Client) LastAccessedBefore(timestamp time.Time) *Client

LastAccessedBefore adds a filter to the client to only return VMs that were last accessed before the given timestamp.

func (*Client) ListWithAnyPendingCustomDomain

func (client *Client) ListWithAnyPendingCustomDomain() ([]model.VM, error)

ListWithAnyPendingCustomDomain returns a list of VMs that have any port with a pending custom domain. It uses aggregation to do this, so it is not very efficient.

func (*Client) MarkAccessed

func (client *Client) MarkAccessed(id string) error

MarkAccessed marks a deployment as accessed to the current time.

func (*Client) MarkRepaired

func (client *Client) MarkRepaired(id string) error

MarkRepaired marks a VM as repaired. It sets RepairedAt and unsets the repairing activity.

func (*Client) MarkUpdated

func (client *Client) MarkUpdated(id string) error

MarkUpdated marks a VM as updated. It sets UpdatedAt and unsets the updating activity.

func (*Client) OlderThan

func (client *Client) OlderThan(timestamp time.Time) *Client

OlderThan adds a filter to the client to only return VMs created before the given timestamp.

func (*Client) SetCurrentHost

func (client *Client) SetCurrentHost(name string, host *model.VmHost) error

SetCurrentHost sets the current host of a VM.

func (*Client) SetStatusByName

func (client *Client) SetStatusByName(name, status string) error

SetStatusByName sets the status of a deployment.

func (*Client) SetSubsystem

func (client *Client) SetSubsystem(id, key string, update interface{}) error

SetSubsystem sets a subsystem in a VM. It prepends the key with `subsystems` and sets it.

func (*Client) UnsetCurrentHost

func (client *Client) UnsetCurrentHost(name string) error

UnsetCurrentHost unsets the current host of a VM.

func (*Client) UpdateCustomDomainStatus

func (client *Client) UpdateCustomDomainStatus(id, portName, status string) error

UpdateCustomDomainStatus updates the status of a custom domain for a given port.

func (*Client) UpdateWithParams

func (client *Client) UpdateWithParams(id string, params *model.VmUpdateParams) error

func (*Client) WithActivities

func (client *Client) WithActivities(activities ...string) *Client

WithActivities adds a filter to the client to only return VMs that have the given activities.

func (*Client) WithCustomFilter

func (client *Client) WithCustomFilter(filter bson.D) *Client

WithCustomFilter adds a custom filter to the client.

func (*Client) WithIDs

func (client *Client) WithIDs(ids ...string) *Client

WithIDs adds a filter to the client to only return VMs with the given IDs.

func (*Client) WithNameRegex

func (client *Client) WithNameRegex(name string) *Client

WithNameRegex adds a filter to the client to only return VMs with names matching the given regex.

func (*Client) WithNoActivities

func (client *Client) WithNoActivities() *Client

WithNoActivities adds a filter to the client to only return VMs that have no activities.

func (*Client) WithOwner

func (client *Client) WithOwner(ownerID string) *Client

WithOwner adds a filter to the client to only return VMs owned by the given ownerID.

func (*Client) WithPagination

func (client *Client) WithPagination(page, pageSize int) *Client

WithPagination adds pagination to the client.

func (*Client) WithVersion

func (client *Client) WithVersion(version string) *Client

WithVersion adds a filter to the client to only return VMs with the given version.

func (*Client) WithZone

func (client *Client) WithZone(zone ...string) *Client

WithZone adds a filter to the client to only return VMs in the given zone.

Jump to

Keyboard shortcuts

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