a5ebab63e7
* New Providers added and updated vendoring for go-discover * Vendor.json formatted using make vendorfmt * Docs/Agent/auto-join: Added documentation for the new providers introduced in this PR * Updated the golang.org/x/sys/unix in the vendor directory * Agent: TestGoDiscoverRegistration updated to reflect the addition of new providers * Deleted terraform.tfstate from vendor. * Deleted terraform.tfstate.backup Deleted terraform state file artifacts from unknown runs. * Updated x/sys/windows vendor for Windows binary compilation
42 lines
862 B
Go
42 lines
862 B
Go
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) {
|
|
root := new(osRoot)
|
|
|
|
resp, err := s.client.DoRequest("GET", osBasePath, nil, root)
|
|
if err != nil {
|
|
return nil, resp, err
|
|
}
|
|
|
|
return root.OperatingSystems, resp, err
|
|
}
|