client

package
v0.33.3 Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: AGPL-3.0 Imports: 15 Imported by: 6

Documentation

Index

Constants

View Source
const Version = "v0.33.3"

Variables

View Source
var (
	ErrNotFound = &Err{
		Err: &errNotFoundErr,
		Msg: &errNotFoundMsg,
	}

	ErrForbidden = &Err{
		Err: &errForbiddenErr,
		Msg: &errForbiddenMsg,
	}
)

Functions

func GetBool added in v0.15.0

func GetBool(b *bool) bool

func GetInt added in v0.13.0

func GetInt(i *int) int

func GetString

func GetString(s *string) string

Types

type AdminDesktop added in v0.8.0

type AdminDesktop struct {
	ID                *string `json:"id,omitempty"`
	State             *string `json:"status,omitempty"`
	Name              *string `json:"name,omitempty"`
	Description       *string `json:"description,omitempty"`
	User              *string `json:"user,omitempty"`
	HypervisorStarted *string `json:"hyp_started,omitempty"`
}

TODO: This should be removed when the admin/domains endpoint and the user/desktops endpoints are unified

type Client

type Client struct {
	BaseURL   *url.URL
	UserAgent string
	Token     string

	BeforeRequestHook func(*Client) error
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cfg *cfg.Cfg) (*Client, error)

func (*Client) AdminDesktopList added in v0.8.0

func (c *Client) AdminDesktopList(ctx context.Context) ([]*AdminDesktop, error)

func (*Client) AdminGroupCreate added in v0.14.0

func (c *Client) AdminGroupCreate(ctx context.Context, category, uid, name, description, externalAppID, externalGID string) (*Group, error)

func (*Client) AdminHypervisorOnlyForced added in v0.18.0

func (c *Client) AdminHypervisorOnlyForced(ctx context.Context, id string, onlyForced bool) error

func (*Client) AdminHypervisorUpdate added in v0.18.0

func (c *Client) AdminHypervisorUpdate(ctx context.Context, h *Hypervisor) error

func (*Client) AdminTemplateList added in v0.8.0

func (c *Client) AdminTemplateList(ctx context.Context) ([]*Template, error)

func (*Client) AdminUserCreate added in v0.6.0

func (c *Client) AdminUserCreate(ctx context.Context, provider, role, category, group, uid, username, pwd string) (*User, error)

func (*Client) AdminUserDelete added in v0.6.0

func (c *Client) AdminUserDelete(ctx context.Context, id string) error

func (*Client) AdminUserList added in v0.6.0

func (c *Client) AdminUserList(ctx context.Context) ([]*User, error)

func (*Client) AuthForm

func (c *Client) AuthForm(ctx context.Context, category, usr, pwd string) (string, error)

func (*Client) DesktopCreate

func (c *Client) DesktopCreate(ctx context.Context, name, templateID string) (*Desktop, error)

func (*Client) DesktopCreateFromScratch

func (c *Client) DesktopCreateFromScratch(ctx context.Context, name string, xml string) (*Desktop, error)

func (*Client) DesktopDelete

func (c *Client) DesktopDelete(ctx context.Context, id string) error

func (*Client) DesktopGet

func (c *Client) DesktopGet(ctx context.Context, id string) (*Desktop, error)

func (*Client) DesktopList

func (c *Client) DesktopList(ctx context.Context) ([]*Desktop, error)

func (*Client) DesktopStart

func (c *Client) DesktopStart(ctx context.Context, id string) error

func (*Client) DesktopStop

func (c *Client) DesktopStop(ctx context.Context, id string) error

func (*Client) DesktopUpdate

func (c *Client) DesktopUpdate(ctx context.Context, id string, opts DesktopUpdateOptions) error

func (*Client) DesktopViewer

func (c *Client) DesktopViewer(ctx context.Context, t DesktopViewer, id string) (string, error)

func (*Client) HypervisorGet added in v0.17.0

func (c *Client) HypervisorGet(ctx context.Context, id string) (*Hypervisor, error)

func (*Client) HypervisorList

func (c *Client) HypervisorList(ctx context.Context) ([]*Hypervisor, error)

func (*Client) Maintenance added in v0.16.0

func (c *Client) Maintenance(ctx context.Context) (bool, error)

func (*Client) OrchestratorHypervisorAddToDeadRow added in v0.24.0

func (c *Client) OrchestratorHypervisorAddToDeadRow(ctx context.Context, id string) (time.Time, error)

func (*Client) OrchestratorHypervisorGet added in v0.25.0

func (c *Client) OrchestratorHypervisorGet(ctx context.Context, id string) (*OrchestratorHypervisor, error)

func (*Client) OrchestratorHypervisorList added in v0.24.0

func (c *Client) OrchestratorHypervisorList(ctx context.Context) ([]*OrchestratorHypervisor, error)

func (*Client) OrchestratorHypervisorManage added in v0.24.0

func (c *Client) OrchestratorHypervisorManage(ctx context.Context, id string) error

func (*Client) OrchestratorHypervisorRemoveFromDeadRow added in v0.24.0

func (c *Client) OrchestratorHypervisorRemoveFromDeadRow(ctx context.Context, id string) error

func (*Client) OrchestratorHypervisorStopDesktops added in v0.25.0

func (c *Client) OrchestratorHypervisorStopDesktops(ctx context.Context, id string) error

func (*Client) OrchestratorHypervisorUnmanage added in v0.24.0

func (c *Client) OrchestratorHypervisorUnmanage(ctx context.Context, id string) error

func (*Client) SetBeforeRequestHook added in v0.23.1

func (c *Client) SetBeforeRequestHook(hook func(*Client) error)

func (*Client) SetToken added in v0.19.1

func (c *Client) SetToken(tkn string)

func (*Client) StatsCategoryList added in v0.13.0

func (c *Client) StatsCategoryList(ctx context.Context) ([]*StatsCategory, error)

func (*Client) StatsDeploymentByCategory added in v0.20.0

func (c *Client) StatsDeploymentByCategory(ctx context.Context) ([]*StatsDeploymentByCategory, error)

func (*Client) StatsDesktops added in v0.28.0

func (c *Client) StatsDesktops(ctx context.Context) ([]*StatsDesktop, error)

func (*Client) StatsHypervisors added in v0.28.0

func (c *Client) StatsHypervisors(ctx context.Context) ([]*StatsHypervisor, error)

func (*Client) StatsTemplates added in v0.28.0

func (c *Client) StatsTemplates(ctx context.Context) ([]*StatsTemplate, error)

func (*Client) StatsUsers added in v0.28.0

func (c *Client) StatsUsers(ctx context.Context) ([]*StatsUser, error)

func (*Client) TemplateCreateFromDesktop

func (c *Client) TemplateCreateFromDesktop(ctx context.Context, name string, desktopID string) (*Template, error)

func (*Client) TemplateList

func (c *Client) TemplateList(ctx context.Context) ([]*Template, error)

func (*Client) URL added in v0.30.0

func (c *Client) URL() *url.URL

func (*Client) UserOwnsDesktop added in v0.32.0

func (c *Client) UserOwnsDesktop(ctx context.Context, opts *UserOwnsDesktopOpts) error

func (*Client) UserVPN

func (c *Client) UserVPN(ctx context.Context) (string, error)

func (*Client) Version added in v0.12.0

func (c *Client) Version(ctx context.Context) (string, error)

type Desktop

type Desktop struct {
	ID          *string `json:"id,omitempty"`
	State       *string `json:"state,omitempty"`
	Type        *string `json:"type,omitempty"`
	Template    *string `json:"template,omitempty"`
	Name        *string `json:"name,omitempty"`
	Description *string `json:"description,omitempty"`
	IP          *string `json:"ip,omitempty"`
}

type DesktopUpdateOptions

type DesktopUpdateOptions struct {
	ForcedHyp []string `json:"forced_hyp,omitempty"`
}

type DesktopViewer

type DesktopViewer string
const (
	DesktopViewerSpice      DesktopViewer = "spice"
	DesktopViewerVNCBrowser DesktopViewer = "vnc-browser"
	DesktopViewerRdpGW      DesktopViewer = "rdp-gw"
	DesktopViewerRdpVPN     DesktopViewer = "rdp-vpn"
	DesktopViewerRdpBrowser DesktopViewer = "rdp-browser"
)

type DesktopViewerRsp

type DesktopViewerRsp struct {
	Kind     *string `json:"kind,omitempty"`
	Protocol *string `json:"protocol,omitempty"`
	URLP     *string `json:"urlp,omitempty"`
	Cookie   *string `json:"cookie,omitempty"`
	Content  *string `json:"content,omitempty"`
}

type Err

type Err struct {
	Err *string `json:"error,omitempty"`
	Msg *string `json:"msg,omitempty"`
}

func (*Err) Error

func (e *Err) Error() string

func (*Err) Is added in v0.27.0

func (e *Err) Is(target error) bool

type Group added in v0.14.0

type Group struct {
	ID            *string `json:"id,omitempty"`
	UID           *string `json:"uid,omitempty"`
	Category      *string `json:"parent_category,omitempty"`
	Name          *string `json:"name,omitempty"`
	Description   *string `json:"description,omitempty"`
	ExternalAppID *string `json:"external_app_id,omitempty"`
	ExternalGID   *string `json:"external_gid,omitempty"`
}

type Hypervisor

type Hypervisor struct {
	ID         *string           `json:"id,omitempty"`
	URI        *string           `json:"uri,omitempty"`
	Status     *HypervisorStatus `json:"status,omitempty"`
	OnlyForced *bool             `json:"only_forced,omitempty"`
	Buffering  *bool             `json:"buffering_hyper,omitempty"`
}

type HypervisorStatus added in v0.18.0

type HypervisorStatus string
const (
	HypervisorStatusOnline   HypervisorStatus = "Online"
	HypervisorStatusOffline  HypervisorStatus = "Offline"
	HypervisorStatusError    HypervisorStatus = "Error"
	HypervisorStatusDeleting HypervisorStatus = "Deleting"
)

type Interface added in v0.19.0

type Interface interface {
	URL() *url.URL

	Version(context.Context) (string, error)
	Maintenance(context.Context) (bool, error)

	SetBeforeRequestHook(func(*Client) error)

	AuthForm(ctx context.Context, category, usr, pwd string) (string, error)
	SetToken(string)

	UserVPN(context.Context) (string, error)
	UserOwnsDesktop(context.Context, *UserOwnsDesktopOpts) error

	AdminUserList(ctx context.Context) ([]*User, error)
	AdminUserCreate(ctx context.Context, provider, role, category, group, uid, username, pwd string) (*User, error)
	AdminUserDelete(ctx context.Context, id string) error
	AdminGroupCreate(ctx context.Context, category, uid, name, description, externalAppID, externalGID string) (*Group, error)
	AdminDesktopList(context.Context) ([]*AdminDesktop, error)
	AdminTemplateList(context.Context) ([]*Template, error)
	AdminHypervisorUpdate(context.Context, *Hypervisor) error
	AdminHypervisorOnlyForced(ctx context.Context, id string, onlyForced bool) error

	HypervisorList(context.Context) ([]*Hypervisor, error)
	HypervisorGet(ctx context.Context, id string) (*Hypervisor, error)

	DesktopList(context.Context) ([]*Desktop, error)
	DesktopGet(ctx context.Context, id string) (*Desktop, error)
	DesktopCreate(ctx context.Context, name, templateID string) (*Desktop, error)
	DesktopCreateFromScratch(ctx context.Context, name, xml string) (*Desktop, error)
	DesktopUpdate(ctx context.Context, id string, opts DesktopUpdateOptions) error
	DesktopDelete(ctx context.Context, id string) error
	DesktopStart(ctx context.Context, id string) error
	DesktopStop(ctx context.Context, id string) error
	DesktopViewer(ctx context.Context, t DesktopViewer, id string) (string, error)

	TemplateList(context.Context) ([]*Template, error)
	TemplateCreateFromDesktop(ctx context.Context, name, desktopID string) (*Template, error)

	StatsCategoryList(context.Context) ([]*StatsCategory, error)
	StatsDeploymentByCategory(ctx context.Context) ([]*StatsDeploymentByCategory, error)
	StatsUsers(ctx context.Context) ([]*StatsUser, error)
	StatsDesktops(ctx context.Context) ([]*StatsDesktop, error)
	StatsTemplates(ctx context.Context) ([]*StatsTemplate, error)
	StatsHypervisors(ctx context.Context) ([]*StatsHypervisor, error)

	OrchestratorHypervisorList(ctx context.Context) ([]*OrchestratorHypervisor, error)
	OrchestratorHypervisorGet(ctx context.Context, id string) (*OrchestratorHypervisor, error)
	OrchestratorHypervisorManage(ctx context.Context, id string) error
	OrchestratorHypervisorUnmanage(ctx context.Context, id string) error
	OrchestratorHypervisorAddToDeadRow(ctx context.Context, id string) (time.Time, error)
	OrchestratorHypervisorRemoveFromDeadRow(ctx context.Context, id string) error
	OrchestratorHypervisorStopDesktops(ctx context.Context, id string) error
}

type OrchestratorHypervisor added in v0.24.0

type OrchestratorHypervisor struct {
	ID                  string                      `json:"id,omitempty"`
	Status              HypervisorStatus            `json:"status,omitempty"`
	OnlyForced          bool                        `json:"only_forced,omitempty"`
	Buffering           bool                        `json:"buffering_hyper,omitempty"`
	DestroyTime         time.Time                   `json:"destroy_time,omitempty"`
	Stats               OrchestratorHypervisorStats `json:"stats,omitempty"`
	MinFreeMemGB        int                         `json:"min_free_mem_gb,omitempty"`
	OrchestratorManaged bool                        `json:"orchestrator_managed,omitempty"`
	DesktopsStarted     int                         `json:"desktops_started,omitempty"`
	CPU                 OrchestratorResourceLoad    `json:"-"`
	RAM                 OrchestratorResourceLoad    `json:"-"`
}

type OrchestratorHypervisorStats added in v0.24.0

type OrchestratorHypervisorStats struct {
	CPUCurrent OrchestratorHypervisorStatsCPU `json:"cpu_current,omitempty"`
	CPU5Min    OrchestratorHypervisorStatsCPU `json:"cpu_5min,omitempty"`
	Mem        OrchestratorHypervisorStatsMem `json:"mem_stats,omitempty"`
}

type OrchestratorHypervisorStatsCPU added in v0.24.0

type OrchestratorHypervisorStatsCPU struct {
	Idle   float32 `json:"idle,omitempty"`
	Iowait float32 `json:"iowait,omitempty"`
	Kernel float32 `json:"kernel,omitempty"`
	Used   float32 `json:"used,omitempty"`
	User   float32 `json:"user,omitempty"`
}

type OrchestratorHypervisorStatsMem added in v0.24.0

type OrchestratorHypervisorStatsMem struct {
	Available int `json:"available,omitempty"`
	Buffers   int `json:"buffers,omitempty"`
	Cached    int `json:"cached,omitempty"`
	Free      int `json:"free,omitempty"`
	Total     int `json:"total,omitempty"`
}

type OrchestratorResourceLoad added in v0.24.0

type OrchestratorResourceLoad struct {
	Total int
	Used  int
	Free  int
}

type StatsCategory added in v0.13.0

type StatsCategory struct {
	ID          *string
	DesktopNum  *int
	TemplateNum *int
	UserNum     *int
}

type StatsDeploymentByCategory added in v0.20.0

type StatsDeploymentByCategory struct {
	CategoryID    *string
	DeploymentNum *int
}

type StatsDesktop added in v0.28.0

type StatsDesktop struct {
	ID   *string `json:"id,omitempty"`
	User *string `json:"user,omitempty"`
}

type StatsHypervisor added in v0.28.0

type StatsHypervisor struct {
	ID         *string           `json:"id,omitempty"`
	Status     *HypervisorStatus `json:"status,omitempty"`
	OnlyForced *bool             `json:"only_forced,omitempty"`
}

type StatsTemplate added in v0.28.0

type StatsTemplate struct {
	ID *string `json:"id,omitempty"`
}

type StatsUser added in v0.28.0

type StatsUser struct {
	ID       *string `json:"id,omitempty"`
	Role     *string `json:"role,omitempty"`
	Category *string `json:"category,omitempty"`
	Group    *string `json:"group,omitempty"`
}

type Template

type Template struct {
	ID   *string
	Name *string
}

type User added in v0.6.0

type User struct {
	ID       *string `json:"id,omitempty"`
	Provider *string `json:"provider,omitempty"`
	Role     *string `json:"role,omitempty"`
	Category *string `json:"category,omitempty"`
	Group    *string `json:"group,omitempty"`
	UID      *string `json:"uid,omitempty"`
	Username *string `json:"username,omitempty"`
	Name     *string `json:"name,omitempty"`
}

type UserOwnsDesktopOpts added in v0.32.0

type UserOwnsDesktopOpts struct {
	IP             string
	ProxyVideo     string
	ProxyHyperHost string
	Port           int
}

type UserVPNRsp

type UserVPNRsp struct {
	Kind    *string `json:"kind,omitempty"`
	Content *string `json:"content,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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