Documentation
¶
Overview ¶
compute.go is the canonical /v1 resell compute surface: the cached DigitalOcean catalog (regions/sizes/GPUs, resale-priced) and per-org machine operations backed by Hanzo's house DO account. Every machine endpoint is scoped to the caller's org, which is derived from the authenticated IAM identity (never trusted from a client-supplied field). Launch is metered through commerce (per-org debit); a dryRun returns a price quote and spends nothing.
A "fleet" is not a separate entity — it is just N machines launched in one batch (count>1) named "<name>-000", "<name>-001", … and grouped by the ?name= (prefix) / ?kind= list filters. There is exactly ONE way a machine is launched, billed and destroyed (launchMetered), whether alone or as one of a batch.
Index ¶
- Constants
- Variables
- func GetUserName(user *iam.User) string
- func InitAuthConfig()
- type ApiController
- func (c *ApiController) AddAsset()
- func (c *ApiController) AddAssetTunnel()
- func (c *ApiController) AddMachine()
- func (c *ApiController) AddPlan()
- func (c *ApiController) AddProvider()
- func (c *ApiController) AddRecord()
- func (c *ApiController) AddSession()
- func (c *ApiController) AttachVolume()
- func (c *ApiController) BindAgent()
- func (c *ApiController) CommitRecord()
- func (c *ApiController) CreateImage()
- func (c *ApiController) CreateNodePool()
- func (c *ApiController) CreateVolume()
- func (c *ApiController) DeleteAsset()
- func (c *ApiController) DeleteComputeMachine()
- func (c *ApiController) DeleteMachine()
- func (c *ApiController) DeleteNodePool()
- func (c *ApiController) DeletePlan()
- func (c *ApiController) DeleteProvider()
- func (c *ApiController) DeleteRecord()
- func (c *ApiController) DeleteSession()
- func (c *ApiController) DeleteVolume()
- func (c *ApiController) DetachVolume()
- func (c *ApiController) GetAccount()
- func (c *ApiController) GetAgentBinding()
- func (c *ApiController) GetAgentBindings()
- func (c *ApiController) GetAsset()
- func (c *ApiController) GetAssetTunnel()
- func (c *ApiController) GetAssets()
- func (c *ApiController) GetComputeGPUs()
- func (c *ApiController) GetComputeMachine()
- func (c *ApiController) GetComputeRegions()
- func (c *ApiController) GetComputeSizes()
- func (c *ApiController) GetConnSession()
- func (c *ApiController) GetMachine()
- func (c *ApiController) GetMachines()
- func (c *ApiController) GetNodePool()
- func (c *ApiController) GetNodePools()
- func (c *ApiController) GetPlan()
- func (c *ApiController) GetPlans()
- func (c *ApiController) GetProvider()
- func (c *ApiController) GetProviders()
- func (c *ApiController) GetRecord()
- func (c *ApiController) GetRecords()
- func (c *ApiController) GetSessionClaims() *iam.Claims
- func (c *ApiController) GetSessionUser() *iam.User
- func (c *ApiController) GetSessionUsername() string
- func (c *ApiController) GetSessions()
- func (c *ApiController) GetVolume()
- func (c *ApiController) GetVolumes()
- func (c *ApiController) GetWhitelabel()
- func (c *ApiController) LaunchComputeMachine()
- func (c *ApiController) LaunchMachine()
- func (c *ApiController) ListComputeMachines()
- func (c *ApiController) ListImages()
- func (c *ApiController) QueryRecord()
- func (c *ApiController) RequireSignedIn() bool
- func (c *ApiController) ResizeVolume()
- func (c *ApiController) ResponseError(error string, data ...interface{})
- func (c *ApiController) ResponseOk(data ...interface{})
- func (c *ApiController) ScaleNodePool()
- func (c *ApiController) SetSessionClaims(claims *iam.Claims)
- func (c *ApiController) SetSessionUser(user *iam.User)
- func (c *ApiController) Signin()
- func (c *ApiController) Signout()
- func (c *ApiController) StartSession()
- func (c *ApiController) StopSession()
- func (c *ApiController) TunnelMonitor()
- func (c *ApiController) UnbindAgent()
- func (c *ApiController) UpdateAsset()
- func (c *ApiController) UpdateMachine()
- func (c *ApiController) UpdateNodePool()
- func (c *ApiController) UpdatePlan()
- func (c *ApiController) UpdateProvider()
- func (c *ApiController) UpdateRecord()
- func (c *ApiController) UpdateSession()
- type GuacamoleHandler
- type LaunchQuote
- type Response
Constants ¶
Variables ¶
var JwtPublicKey string
Functions ¶
func GetUserName ¶
func InitAuthConfig ¶
func InitAuthConfig()
Types ¶
type ApiController ¶
type ApiController struct {
beego.Controller
}
func (*ApiController) AddAsset ¶
func (c *ApiController) AddAsset()
AddAsset @Title AddAsset @Tag Asset API @Description add a asset @Param body body object.Asset true "The details of the asset" @Success 200 {object} controllers.Response The Response object @router /add-asset [post]
func (*ApiController) AddAssetTunnel ¶
func (c *ApiController) AddAssetTunnel()
AddAssetTunnel @Title AddAssetTunnel @Tag Session API @Description add session @Param assetId query string true "The id of asset" @Success 200 {object} Response @router /add-asset-tunnel [get]
func (*ApiController) AddMachine ¶
func (c *ApiController) AddMachine()
AddMachine @Title AddMachine @Tag Machine API @Description add a machine @Param body body object.Machine true "The details of the machine" @Success 200 {object} controllers.Response The Response object @router /add-machine [post]
func (*ApiController) AddPlan ¶
func (c *ApiController) AddPlan()
AddPlan @Title AddPlan @Tag Plan API @Description add a plan @Param body body object.Plan true "The plan" @Success 200 {object} controllers.Response @router /add-plan [post]
func (*ApiController) AddProvider ¶
func (c *ApiController) AddProvider()
AddProvider @Title AddProvider @Tag Provider API @Description add a provider @Param body body object.Provider true "The details of the provider" @Success 200 {object} controllers.Response The Response object @router /add-provider [post]
func (*ApiController) AddRecord ¶
func (c *ApiController) AddRecord()
AddRecord @Title AddRecord @Tag Record API @Description add a record @Param body body object.Record true "The details of the record" @Success 200 {object} controllers.Response The Response object @router /add-record [post]
func (*ApiController) AddSession ¶
func (c *ApiController) AddSession()
AddSession @Title AddSession @Tag Session API @Description add session @Param body body object.Session true "The session object" @Success 200 {object} Response @router /add-session [post]
func (*ApiController) AttachVolume ¶
func (c *ApiController) AttachVolume()
AttachVolume @Title AttachVolume @Tag Volume API @Description attach a volume to a machine @router /attach-volume [post]
func (*ApiController) BindAgent ¶
func (c *ApiController) BindAgent()
BindAgent @Title BindAgent @Tag AgentBinding API @Description bind a cloud Agent to a machine — mark it as running the @hanzo/bot runtime @Param id path string true "The name of the machine (scoped to the caller org)" @Param body body controllers.bindAgentRequest true "org + agentName (+ optional botVersion)" @Success 200 {object} object.AgentBinding The Response object @router /machines/:id/bind-agent [post]
func (*ApiController) CommitRecord ¶
func (c *ApiController) CommitRecord()
CommitRecord @Title CommitRecord @Tag Record API @Description commit a record @Param body body object.Record true "The details of the record" @Success 200 {object} controllers.Response The Response object @router /commit-record [post]
func (*ApiController) CreateImage ¶
func (c *ApiController) CreateImage()
CreateImage @Title CreateImage @Tag Compute API @Description upload/register a custom image from a URL (org-scoped, async) @router /images [post]
func (*ApiController) CreateNodePool ¶
func (c *ApiController) CreateNodePool()
CreateNodePool @Title CreateNodePool @Tag NodePool API @Description create a new node pool in DOKS @Param owner query string true "The owner" @Param provider query string true "The provider name" @Param clusterId query string false "The DOKS cluster ID (optional, uses provider default)" @Param body body service.CreateNodePoolSpec true "The spec for the node pool" @Success 200 {object} object.NodePool The Response object @router /create-node-pool [post]
func (*ApiController) CreateVolume ¶
func (c *ApiController) CreateVolume()
CreateVolume @Title CreateVolume @Tag Volume API @Description create a block storage volume via a provider @Param owner query string true "The owner" @Param provider query string true "The provider name" @Param body body service.CreateVolumeSpec true "The volume spec" @Success 200 {object} object.Volume @router /create-volume [post]
func (*ApiController) DeleteAsset ¶
func (c *ApiController) DeleteAsset()
DeleteAsset @Title DeleteAsset @Tag Asset API @Description delete a asset @Param body body object.Asset true "The details of the asset" @Success 200 {object} controllers.Response The Response object @router /delete-asset [post]
func (*ApiController) DeleteComputeMachine ¶
func (c *ApiController) DeleteComputeMachine()
DeleteComputeMachine @Title DeleteComputeMachine @Tag Compute API @Description delete one of the caller org's machines by id @router /machines/:id [delete]
func (*ApiController) DeleteMachine ¶
func (c *ApiController) DeleteMachine()
DeleteMachine @Title DeleteMachine @Tag Machine API @Description delete a machine @Param body body object.Machine true "The details of the machine" @Success 200 {object} controllers.Response The Response object @router /delete-machine [post]
func (*ApiController) DeleteNodePool ¶
func (c *ApiController) DeleteNodePool()
DeleteNodePool @Title DeleteNodePool @Tag NodePool API @Description delete a node pool from DOKS and DB @Param body body object.NodePool true "The details of the node pool" @Success 200 {object} controllers.Response The Response object @router /delete-node-pool [post]
func (*ApiController) DeletePlan ¶
func (c *ApiController) DeletePlan()
DeletePlan @Title DeletePlan @Tag Plan API @Description delete a plan @Param body body object.Plan true "The plan" @Success 200 {object} controllers.Response @router /delete-plan [post]
func (*ApiController) DeleteProvider ¶
func (c *ApiController) DeleteProvider()
DeleteProvider @Title DeleteProvider @Tag Provider API @Description delete a provider @Param body body object.Provider true "The details of the provider" @Success 200 {object} controllers.Response The Response object @router /delete-provider [post]
func (*ApiController) DeleteRecord ¶
func (c *ApiController) DeleteRecord()
DeleteRecord @Title DeleteRecord @Tag Record API @Description delete a record @Param body body object.Record true "The details of the record" @Success 200 {object} controllers.Response The Response object @router /delete-record [post]
func (*ApiController) DeleteSession ¶
func (c *ApiController) DeleteSession()
DeleteSession @Title DeleteSession @Tag Session API @Description delete session @Param id query string true "The id of session" @Success 200 {object} Response @router /delete-session [post]
func (*ApiController) DeleteVolume ¶
func (c *ApiController) DeleteVolume()
DeleteVolume @Title DeleteVolume @Tag Volume API @Description delete a volume @Param owner query string true "The owner" @Param provider query string true "The provider name" @Param name query string true "The volume cloud ID" @Success 200 {object} controllers.Response @router /delete-volume [post]
func (*ApiController) DetachVolume ¶
func (c *ApiController) DetachVolume()
DetachVolume @Title DetachVolume @Tag Volume API @Description detach a volume from its machine @router /detach-volume [post]
func (*ApiController) GetAccount ¶
func (c *ApiController) GetAccount()
func (*ApiController) GetAgentBinding ¶
func (c *ApiController) GetAgentBinding()
GetAgentBinding @Title GetAgentBinding @Tag AgentBinding API @Description get a machine's agent binding (status re-reconciled against live machine state) @Param id path string true "The name of the machine (scoped to the caller org)" @Success 200 {object} object.AgentBinding The Response object @router /machines/:id/agent-binding [get]
func (*ApiController) GetAgentBindings ¶
func (c *ApiController) GetAgentBindings()
GetAgentBindings @Title GetAgentBindings @Tag AgentBinding API @Description list all agent bindings owned by the caller org @Success 200 {array} object.AgentBinding The Response object @router /agent-bindings [get]
func (*ApiController) GetAsset ¶
func (c *ApiController) GetAsset()
GetAsset @Title GetAsset @Tag Asset API @Description get asset @Param id query string true "The id ( owner/name ) of the asset" @Success 200 {object} object.Asset The Response object @router /get-asset [get]
func (*ApiController) GetAssetTunnel ¶
func (c *ApiController) GetAssetTunnel()
func (*ApiController) GetAssets ¶
func (c *ApiController) GetAssets()
GetAssets @Title GetAssets @Tag Asset API @Description get all assets @Param pageSize query string true "The size of each page" @Param p query string true "The number of the page" @Success 200 {object} object.Asset The Response object @router /get-assets [get]
func (*ApiController) GetComputeGPUs ¶
func (c *ApiController) GetComputeGPUs()
GetComputeGPUs @Title GetComputeGPUs @Tag Compute API @Description list resale-priced GPU sizes (cached) @Success 200 {object} controllers.Response @router /gpus [get]
func (*ApiController) GetComputeMachine ¶
func (c *ApiController) GetComputeMachine()
GetComputeMachine @Title GetComputeMachine @Tag Compute API @Description get one of the caller org's machines by id @router /machines/:id [get]
func (*ApiController) GetComputeRegions ¶
func (c *ApiController) GetComputeRegions()
GetComputeRegions @Title GetComputeRegions @Tag Compute API @Description list DigitalOcean regions (cached) @Success 200 {object} controllers.Response @router /regions [get]
func (*ApiController) GetComputeSizes ¶
func (c *ApiController) GetComputeSizes()
GetComputeSizes @Title GetComputeSizes @Tag Compute API @Description list resale-priced sizes (cached) @Success 200 {object} controllers.Response @router /sizes [get]
func (*ApiController) GetConnSession ¶
func (c *ApiController) GetConnSession()
GetConnSession @Title GetConnSession @Tag Session API @Description get session @Param id query string true "The id of session" @Success 200 {object} object.Session @router /get-session [get]
func (*ApiController) GetMachine ¶
func (c *ApiController) GetMachine()
GetMachine @Title GetMachine @Tag Machine API @Description get machine @Param id query string true "The id ( owner/name ) of the machine" @Success 200 {object} object.Machine The Response object @router /get-machine [get]
func (*ApiController) GetMachines ¶
func (c *ApiController) GetMachines()
GetMachines @Title GetMachines @Tag Machine API @Description get all machines @Param pageSize query string true "The size of each page" @Param p query string true "The number of the page" @Success 200 {object} object.Machine The Response object @router /get-machines [get]
func (*ApiController) GetNodePool ¶
func (c *ApiController) GetNodePool()
GetNodePool @Title GetNodePool @Tag NodePool API @Description get a node pool @Param id query string true "The id ( owner/name ) of the node pool" @Success 200 {object} object.NodePool The Response object @router /get-node-pool [get]
func (*ApiController) GetNodePools ¶
func (c *ApiController) GetNodePools()
GetNodePools @Title GetNodePools @Tag NodePool API @Description get all node pools @Param owner query string true "The owner" @Param pageSize query string false "The size of each page" @Param p query string false "The number of the page" @Success 200 {object} object.NodePool The Response object @router /get-node-pools [get]
func (*ApiController) GetPlan ¶
func (c *ApiController) GetPlan()
GetPlan @Title GetPlan @Tag Plan API @Description get a single plan @Param owner query string true "The owner" @Param name query string true "The plan name" @Success 200 {object} object.Plan @router /get-plan [get]
func (*ApiController) GetPlans ¶
func (c *ApiController) GetPlans()
GetPlans @Title GetPlans @Tag Plan API @Description get active plans for a given owner @Param owner query string true "The owner" @Success 200 {array} object.Plan @router /get-plans [get]
func (*ApiController) GetProvider ¶
func (c *ApiController) GetProvider()
GetProvider @Title GetProvider @Tag Provider API @Description get provider @Param id query string true "The id ( owner/name ) of the provider" @Success 200 {object} object.Provider The Response object @router /get-provider [get]
func (*ApiController) GetProviders ¶
func (c *ApiController) GetProviders()
GetProviders @Title GetProviders @Tag Provider API @Description get all providers @Param pageSize query string true "The size of each page" @Param p query string true "The number of the page" @Success 200 {object} object.Provider The Response object @router /get-providers [get]
func (*ApiController) GetRecord ¶
func (c *ApiController) GetRecord()
GetRecord @Title GetRecord @Tag Record API @Description get record @Param id query string true "The id ( owner/name ) of the record" @Success 200 {object} object.Record The Response object @router /get-record [get]
func (*ApiController) GetRecords ¶
func (c *ApiController) GetRecords()
GetRecords @Title GetRecords @Tag Record API @Description get all records @Param pageSize query string true "The size of each page" @Param p query string true "The number of the page" @Success 200 {object} object.Record The Response object @router /get-records [get]
func (*ApiController) GetSessionClaims ¶
func (c *ApiController) GetSessionClaims() *iam.Claims
func (*ApiController) GetSessionUser ¶
func (c *ApiController) GetSessionUser() *iam.User
func (*ApiController) GetSessionUsername ¶
func (c *ApiController) GetSessionUsername() string
func (*ApiController) GetSessions ¶
func (c *ApiController) GetSessions()
GetSessions @Title GetSessions @Tag Session API @Description get all sessions @Param pageSize query string true "The size of each page" @Param p query string true "The number of the page" @Success 200 {object} object.Session The Response object @router /get-sessions [get]
func (*ApiController) GetVolume ¶
func (c *ApiController) GetVolume()
GetVolume @Title GetVolume @Tag Volume API @Description get a single volume @Param owner query string true "The owner" @Param name query string true "The volume name" @Success 200 {object} object.Volume @router /get-volume [get]
func (*ApiController) GetVolumes ¶
func (c *ApiController) GetVolumes()
GetVolumes @Title GetVolumes @Tag Volume API @Description get all volumes for an owner @Param owner query string true "The owner" @Success 200 {array} object.Volume @router /get-volumes [get]
func (*ApiController) GetWhitelabel ¶
func (c *ApiController) GetWhitelabel()
GetWhitelabel returns branding config based on the request Host header. @Title GetWhitelabel @Tag Whitelabel API @Description Get white-label branding config for the current hostname @Success 200 {object} controllers.Response @router /get-whitelabel [get]
func (*ApiController) LaunchComputeMachine ¶
func (c *ApiController) LaunchComputeMachine()
LaunchComputeMachine @Title LaunchComputeMachine @Tag Compute API @Description quote (dryRun) or launch a metered, per-org machine; count>1 launches a batch of <name>-NNN @router /machines/launch [post]
func (*ApiController) LaunchMachine ¶
func (c *ApiController) LaunchMachine()
LaunchMachine @Title LaunchMachine @Tag Machine API @Description launch a new cloud machine instance via a provider @Param body body service.CreateMachineSpec true "The spec for the machine to launch" @Param owner query string true "The owner" @Param provider query string true "The provider name" @Success 200 {object} object.Machine The Response object @router /launch-machine [post]
func (*ApiController) ListComputeMachines ¶
func (c *ApiController) ListComputeMachines()
ListComputeMachines @Title ListComputeMachines @Tag Compute API @Description list the caller org's machines, optionally filtered by ?kind= and ?name= (prefix) @Success 200 {object} controllers.Response @router /machines [get]
func (*ApiController) ListImages ¶
func (c *ApiController) ListImages()
ListImages @Title ListImages @Tag Compute API @Description list selectable images (distributions, applications, org customs) @router /images [get]
func (*ApiController) QueryRecord ¶
func (c *ApiController) QueryRecord()
QueryRecord @Title QueryRecord @Tag Record API @Description query record @Param id query string true "The id ( owner/name ) of the record" @Success 200 {object} object.Record The Response object @router /query-record [get]
func (*ApiController) RequireSignedIn ¶
func (c *ApiController) RequireSignedIn() bool
func (*ApiController) ResizeVolume ¶
func (c *ApiController) ResizeVolume()
ResizeVolume @Title ResizeVolume @Tag Volume API @Description resize a volume @router /resize-volume [post]
func (*ApiController) ResponseError ¶
func (c *ApiController) ResponseError(error string, data ...interface{})
func (*ApiController) ResponseOk ¶
func (c *ApiController) ResponseOk(data ...interface{})
func (*ApiController) ScaleNodePool ¶
func (c *ApiController) ScaleNodePool()
ScaleNodePool @Title ScaleNodePool @Tag NodePool API @Description quick-scale a node pool (just count) @Param owner query string true "The owner" @Param provider query string true "The provider name" @Param clusterId query string false "The DOKS cluster ID" @Param poolId query string true "The DOKS node pool ID" @Param count query string true "The desired node count" @Success 200 {object} object.NodePool The Response object @router /scale-node-pool [post]
func (*ApiController) SetSessionClaims ¶
func (c *ApiController) SetSessionClaims(claims *iam.Claims)
func (*ApiController) SetSessionUser ¶
func (c *ApiController) SetSessionUser(user *iam.User)
func (*ApiController) Signin ¶
func (c *ApiController) Signin()
func (*ApiController) Signout ¶
func (c *ApiController) Signout()
func (*ApiController) StartSession ¶
func (c *ApiController) StartSession()
func (*ApiController) StopSession ¶
func (c *ApiController) StopSession()
func (*ApiController) TunnelMonitor ¶
func (c *ApiController) TunnelMonitor()
func (*ApiController) UnbindAgent ¶
func (c *ApiController) UnbindAgent()
UnbindAgent @Title UnbindAgent @Tag AgentBinding API @Description remove a machine's agent binding (does not delete the machine) @Param id path string true "The name of the machine (scoped to the caller org)" @Success 200 {object} controllers.Response The Response object @router /machines/:id/agent-binding [delete]
func (*ApiController) UpdateAsset ¶
func (c *ApiController) UpdateAsset()
UpdateAsset @Title UpdateAsset @Tag Asset API @Description update asset @Param id query string true "The id ( owner/name ) of the asset" @Param body body object.Asset true "The details of the asset" @Success 200 {object} controllers.Response The Response object @router /update-asset [post]
func (*ApiController) UpdateMachine ¶
func (c *ApiController) UpdateMachine()
UpdateMachine @Title UpdateMachine @Tag Machine API @Description update machine @Param id query string true "The id ( owner/name ) of the machine" @Param body body object.Machine true "The details of the machine" @Success 200 {object} controllers.Response The Response object @router /update-machine [post]
func (*ApiController) UpdateNodePool ¶
func (c *ApiController) UpdateNodePool()
UpdateNodePool @Title UpdateNodePool @Tag NodePool API @Description update a node pool @Param id query string true "The id ( owner/name ) of the node pool" @Param body body object.NodePool true "The details of the node pool" @Success 200 {object} controllers.Response The Response object @router /update-node-pool [post]
func (*ApiController) UpdatePlan ¶
func (c *ApiController) UpdatePlan()
UpdatePlan @Title UpdatePlan @Tag Plan API @Description update a plan @Param owner query string true "The owner" @Param name query string true "The plan name" @Param body body object.Plan true "The plan" @Success 200 {object} controllers.Response @router /update-plan [post]
func (*ApiController) UpdateProvider ¶
func (c *ApiController) UpdateProvider()
UpdateProvider @Title UpdateProvider @Tag Provider API @Description update provider @Param id query string true "The id ( owner/name ) of the provider" @Param body body object.Provider true "The details of the provider" @Success 200 {object} controllers.Response The Response object @router /update-provider [post]
func (*ApiController) UpdateRecord ¶
func (c *ApiController) UpdateRecord()
UpdateRecord @Title UpdateRecord @Tag Record API @Description update record @Param id query string true "The id ( owner/name ) of the record" @Param body body object.Record true "The details of the record" @Success 200 {object} controllers.Response The Response object @router /update-record [post]
func (*ApiController) UpdateSession ¶
func (c *ApiController) UpdateSession()
UpdateSession @Title UpdateSession @Tag Session API @Description update session @Param id query string true "The id of session" @Param body body object.Session true "The session object" @Success 200 {object} Response @router /update-session [post]
type GuacamoleHandler ¶
type GuacamoleHandler struct {
// contains filtered or unexported fields
}
func NewGuacamoleHandler ¶
func NewGuacamoleHandler(ws *websocket.Conn, tunnel *guacamole.Tunnel) *GuacamoleHandler
func (GuacamoleHandler) Start ¶
func (r GuacamoleHandler) Start()
func (GuacamoleHandler) Stop ¶
func (r GuacamoleHandler) Stop()
type LaunchQuote ¶
type LaunchQuote struct {
Org string `json:"org"`
Size string `json:"size"`
Region string `json:"region"`
Currency string `json:"currency"`
PriceHourly float64 `json:"priceHourly"`
PriceMonthly float64 `json:"priceMonthly"`
GPU *service.GPUSpec `json:"gpu,omitempty"`
}
LaunchQuote is the resale price quote for a size in a region (Hanzo price only — wholesale/provider never surfaced).