1
0
mirror of https://github.com/rancher/os.git synced 2025-09-08 02:01:27 +00:00

vendor packngo

This commit is contained in:
Darren Shepherd
2015-12-22 22:34:19 -07:00
parent 9187ed724d
commit 946d353e0c
36 changed files with 12357 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
package packngo
const osBasePath = "/operating-systems"
// OSService interface defines available operating_systems methods
type OSService interface {
List() ([]OS, *Response, error)
}
type osRoot struct {
OperatingSystems []OS `json:"operating_systems"`
}
// OS represents a Packet operating system
type OS struct {
Name string `json:"name"`
Slug string `json:"slug"`
Distro string `json:"distro"`
Version string `json:"version"`
}
func (o OS) String() string {
return Stringify(o)
}
// OSServiceOp implements OSService
type OSServiceOp struct {
client *Client
}
// List returns all available operating systems
func (s *OSServiceOp) List() ([]OS, *Response, error) {
req, err := s.client.NewRequest("GET", osBasePath, nil)
if err != nil {
return nil, nil, err
}
root := new(osRoot)
resp, err := s.client.Do(req, root)
if err != nil {
return nil, resp, err
}
return root.OperatingSystems, resp, err
}