util

package
v0.0.0-...-7c1aaf1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Divmod

func Divmod(a, b int) (int, int)

func ParseRequest

func ParseRequest[R Request, T Validatable[R]](r *http.Request, rq T) error

func VerFromDec

func VerFromDec(version int) string

Parse xxxyyyzzz to xxx.yyy.zzz for version numbers

Types

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

func (LoginRequest) Validate

func (s LoginRequest) Validate() error

type SetStateRequest

type SetStateRequest struct {
	State string `json:"state"`
}

func (SetStateRequest) Validate

func (s SetStateRequest) Validate() error

type UserCreateRequest

type UserCreateRequest struct {
	Name     string `json:"name"`
	Email    string `json:"email"`
	Password string `json:"password"`
	Disabled bool   `json:"disabled"`
	IsAdmin  bool   `json:"is_admin"`
	Remarks  string `json:"remarks"`
}

func (UserCreateRequest) Validate

func (s UserCreateRequest) Validate() error

type VMCreateRequest

type VMCreateRequest struct {
	User       uuid.UUID `json:"user"`
	Id         uuid.UUID `json:"id"`
	Hostname   string    `json:"hostname"`
	CPU        int       `json:"cpu"`
	Memory     int       `json:"memory"`
	Image      string    `json:"image"`
	Cloud      bool      `json:"cloud"`
	CloudImage string    `json:"cloud_image"`
	OSVariant  string    `json:"os_variant"`
	UserData   string    `json:"user_data"`
	MetaData   string    `json:"meta_data"`
	Disk       []struct {
		Id   int    `json:"id"`
		Size int    `json:"size"`
		Path string `json:"path"`
	} `json:"disk"`
	Iface []struct {
		Bridge string `json:"bridge"`
		MAC    string `json:"mac"`
	} `json:"iface"`
}

func (VMCreateRequest) Validate

func (s VMCreateRequest) Validate() error

type Validatable

type Validatable[T any] interface {
	Validate() error
	*T
}

Jump to

Keyboard shortcuts

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