status.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. // Contains functionality for status API.
  14. type StatusAPI struct {
  15. client *Client
  16. }
  17. var statusUrl string = rootUrl + "/status"
  18. // Returns the status of an photon endpoint.
  19. func (api *StatusAPI) Get() (status *Status, err error) {
  20. res, err := api.client.restClient.Get(api.client.Endpoint+statusUrl, api.client.options.TokenOptions)
  21. if err != nil {
  22. return
  23. }
  24. defer res.Body.Close()
  25. res, err = getError(res)
  26. if err != nil {
  27. return
  28. }
  29. status = &Status{}
  30. err = json.NewDecoder(res.Body).Decode(status)
  31. return
  32. }