info.go 936 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (c) 2016 VMware, Inc. All Rights Reserved.
  2. //
  3. // This product is licensed to you under the Apache License, Version 2.0 (the "License").
  4. // You may not use this product except in compliance with the License.
  5. //
  6. // This product may include a number of subcomponents with separate copyright notices and
  7. // license terms. Your use of these subcomponents is subject to the terms and conditions
  8. // of the subcomponent's license, as noted in the LICENSE file.
  9. package photon
  10. import (
  11. "encoding/json"
  12. )
  13. type InfoAPI struct {
  14. client *Client
  15. }
  16. var infoUrl = rootUrl + "/info"
  17. // Get info
  18. func (api *InfoAPI) Get() (info *Info, err error) {
  19. res, err := api.client.restClient.Get(api.client.Endpoint+infoUrl, api.client.options.TokenOptions)
  20. if err != nil {
  21. return
  22. }
  23. defer res.Body.Close()
  24. res, err = getError(res)
  25. if err != nil {
  26. return
  27. }
  28. info = new(Info)
  29. err = json.NewDecoder(res.Body).Decode(info)
  30. return
  31. }