-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpackages.go
More file actions
34 lines (27 loc) · 915 Bytes
/
packages.go
File metadata and controls
34 lines (27 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package gohvapi
import "strconv"
// Package struct stores the purchaced package values
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"`
}
// GetPackages external method on Client that returns a
// list of Package object from the API
func (c *Client) GetPackages() ([]Package, error) {
var packageList []Package
if err := c.get("cloud/packages", &packageList); err != nil {
return nil, err
}
return packageList, nil
}
// GetPackage external method on Client that takes an id (int) as it's sole
// argument and returns a single Package object
func (c *Client) GetPackage(id int) (pkg Package, err error) {
if err := c.get("/cloud/package/"+strconv.Itoa(id), &pkg); err != nil {
return Package{Installed: 0}, err
}
return pkg, nil
}