version.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // Copyright 2017, Andrea Funto'
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. package gitlab
  17. // VersionService handles communication with the GitLab server instance to
  18. // retrieve its version information via the GitLab API.
  19. //
  20. // GitLab API docs: https://docs.gitlab.com/ce/api/version.md
  21. type VersionService struct {
  22. client *Client
  23. }
  24. // Version represents a GitLab instance version.
  25. //
  26. // GitLab API docs: https://docs.gitlab.com/ce/api/version.md
  27. type Version struct {
  28. Version string `json:"version"`
  29. Revision string `json:"revision"`
  30. }
  31. func (s Version) String() string {
  32. return Stringify(s)
  33. }
  34. // GetVersion gets a GitLab server instance version; it is only available to
  35. // authenticated users.
  36. //
  37. // GitLab API docs: https://docs.gitlab.com/ce/api/version.md
  38. func (s *VersionService) GetVersion() (*Version, *Response, error) {
  39. req, err := s.client.NewRequest("GET", "version", nil, nil)
  40. if err != nil {
  41. return nil, nil, err
  42. }
  43. v := new(Version)
  44. resp, err := s.client.Do(req, v)
  45. if err != nil {
  46. return nil, resp, err
  47. }
  48. return v, resp, err
  49. }