import "github.com/hostvirtual/gohvapi"
Package gohvapi provides a simple golang interface to the HostVirtual Rest API at https://bapi.vr.org/
- Constants
- func GetKeyFromEnv() string
- type Client
- func NewClient(apikey string) *Client
- func (c *Client) CancelServer(id int) error
- func (c *Client) CreateSSHKey(name, key string) (sshkey SSHKey, err error)
- func (c *Client) CreateServer(name, plan string, locationID, osID int, options *ServerOptions) (server Server, err error)
- func (c *Client) DeleteSSHKey(id int) error
- func (c *Client) DeleteServer(id int) error
- func (c *Client) GetLocations() ([]Location, error)
- func (c *Client) GetOSs() ([]OS, error)
- func (c *Client) GetPackage(id int) (pkg Package, err error)
- func (c *Client) GetPackages() ([]Package, error)
- func (c *Client) GetPlans() ([]Plan, error)
- func (c *Client) GetSSHKey(id int) (sshkey SSHKey, err error)
- func (c *Client) GetSSHKeys() (keys []SSHKey, err error)
- func (c *Client) GetServer(id int) (server Server, err error)
- func (c *Client) GetServers() ([]Server, error)
- func (c *Client) ProvisionServer(name string, id, locationID, osID int, options *ServerOptions) (JobID, error)
- func (c *Client) RebootServer(id int) error
- func (c *Client) StartServer(id int) error
- func (c *Client) StopServer(id int) error
- func (c *Client) UpdateSSHKey(id int, name, key string) (SSHKey, error)
- type JobID
- type Location
- type OS
- type Package
- type Plan
- type SSHKey
- type Server
- type ServerOptions
client.go locations.go os.go packages.go plans.go servers.go sshkeys.go
const (
Version = "0.0.1"
BaseEndpoint = "https://bapi.vr.org/"
ContentType = "application/json"
)func GetKeyFromEnv() stringGetKeyFromEnv is a simple function to try to yank the value for "VR_API_KEY" from the environment
type Client struct {
// contains filtered or unexported fields
}Client is the main object (struct) to which we attach most methods/functions. It has the following fields: (client, userAgent, endPoint, apiKey)
func NewClient(apikey string) *ClientNewClient is the main entrypoint for instantiating a Client struct. It takes your API Key as it's sole argument and returns the Client struct ready to talk to the API
func (*Client) CancelServer
func (c *Client) CancelServer(id int) errorCancelServer external method on Client to cancel/remove from billing an instance. this method completely removes an instance, it cannot be rebuilt afterward. billing should be prorated to the day or something like that. This method requires apikey_allow_cancel to be checked on the account.
func (*Client) CreateSSHKey
func (c *Client) CreateSSHKey(name, key string) (sshkey SSHKey, err error)func (*Client) CreateServer
func (c *Client) CreateServer(name, plan string, locationID, osID int, options *ServerOptions) (server Server, err error)CreateServer external method on Client to buy and build a new instance.
func (*Client) DeleteSSHKey
func (c *Client) DeleteSSHKey(id int) errorfunc (*Client) DeleteServer
func (c *Client) DeleteServer(id int) errorDeleteServer external method on Client to destroy an instance. This should not be used in Terraform as we will use CancelServer instead. This method requires apikey_allow_delete to be checked on the account
func (*Client) GetLocations
func (c *Client) GetLocations() ([]Location, error)GetLocations public method on Client to get a list of locations
func (c *Client) GetOSs() ([]OS, error)GetOSs returns a list of OS objects from the api
func (*Client) GetPackage
func (c *Client) GetPackage(id int) (pkg Package, err error)GetPackage external method on Client that takes an id (int) as it's sole argument and returns a single Package object
func (*Client) GetPackages
func (c *Client) GetPackages() ([]Package, error)GetPackages external method on Client that returns a list of Package object from the API
func (c *Client) GetPlans() ([]Plan, error)GetPlans external method on Client to list available Plans
func (c *Client) GetSSHKey(id int) (sshkey SSHKey, err error)func (*Client) GetSSHKeys
func (c *Client) GetSSHKeys() (keys []SSHKey, err error)func (c *Client) GetServer(id int) (server Server, err error)GetServer external method on Client to get an instance
func (*Client) GetServers
func (c *Client) GetServers() ([]Server, error)GetServers external method on Client to list your instances
func (*Client) ProvisionServer
func (c *Client) ProvisionServer(name string, id, locationID, osID int, options *ServerOptions) (JobID, error)ProvisionServer external method on Client to re-build an instance This should not be used in Terraform as we will use CreateServer instead
func (*Client) RebootServer
func (c *Client) RebootServer(id int) errorRebootServer external method on Client to reboot an instance
func (*Client) StartServer
func (c *Client) StartServer(id int) errorStartServer external method on Client to boot up an instance
func (*Client) StopServer
func (c *Client) StopServer(id int) errorStopServer external method on Client to shut down an instance
func (*Client) UpdateSSHKey
func (c *Client) UpdateSSHKey(id int, name, key string) (SSHKey, error)type JobID struct {
ID int `json:"id,string"`
}JobID struct holds the current Job Id for what's being processed
type Location struct {
ID int `json:"id,string"`
Name string `json:"name"`
}Location is a struct for storing the id and name of a location
type OS struct {
ID int `json:"id,string"`
Os string `json:"os"`
Type string `json:"type"`
Subtype string `json:"subtype"`
Size string `json:"size"`
Bits string `json:"bits"`
Tech string `json:"tech"`
}OS is a struct for storing the attributes of and OS
type Package struct {
ID int `json:"mbpkgid,string"`
Status string `json:"package_status"`
Locked string `json:"locked"`
PlanName string `json:"name"`
Installed int `json:"installed,string"`
}Package struct stores the purchaced package values
type Plan struct {
ID int `json:"plan_id,string"`
Name string `json:"plan"`
RAM string `json:"ram"`
Disk string `json:"disk"`
Transfer string `json:"transfer"`
Price string `json:"price"`
Available string `json:"available"`
}Plan struct defines the purchaceable plans/packages
type SSHKey struct {
ID int `json:"id,string"`
Name string `json:"name"`
Key string `json:"ssh_key"`
Fingerprint string `json:"fingerprint"`
}type Server struct {
Name string `json:"fqdn"`
ID int `json:"mbpkgid,string"`
OS string `json:"os"`
PrimaryIPv4 string `json:"ip"`
PrimaryIPv6 string `json:"ipv6"`
PlanID int `json:"plan_id,string"`
PkgID int `json:"pkg_id,string"`
LocationID int `json:"location_id,string"`
OSID int `json:"os_id,string"`
ServerStatus string `json:"status"`
PowerStatus string `json:"state"`
}Server struct defines what a VPS looks like
type ServerOptions struct {
SSHKeyID int
Password string
CloudConfig string
}ServerOptions struct defines some extra options including SSH Auth
Generated by godoc2md