Serve API version list, test with an integration test.

This commit is contained in:
Daniel Smith
2014-10-28 17:20:40 -07:00
parent 1da5c444e8
commit dca7363459
6 changed files with 47 additions and 0 deletions

View File

@@ -62,6 +62,7 @@ func (c *Client) Services(namespace string) ServiceInterface {
// VersionInterface has a method to retrieve the server version.
type VersionInterface interface {
ServerVersion() (*version.Info, error)
ServerAPIVersions() (*version.APIVersions, error)
}
// APIStatus is exposed by errors that can be converted to an api.Status object
@@ -88,3 +89,17 @@ func (c *Client) ServerVersion() (*version.Info, error) {
}
return &info, nil
}
// ServerAPIVersions retrieves and parses the list of API versions the server supports.
func (c *Client) ServerAPIVersions() (*version.APIVersions, error) {
body, err := c.Get().AbsPath("/api").Do().Raw()
if err != nil {
return nil, err
}
var v version.APIVersions
err = json.Unmarshal(body, &v)
if err != nil {
return nil, fmt.Errorf("Got '%s': %v", string(body), err)
}
return &v, nil
}