userdata.go 421 B

123456789101112131415161718192021222324252627
  1. package metadata
  2. import (
  3. "bytes"
  4. "github.com/packethost/packngo"
  5. )
  6. const (
  7. userdataBasePath = "/userdata"
  8. )
  9. type UserdataServiceOp struct {
  10. client *packngo.Client
  11. }
  12. func (s *UserdataServiceOp) Get() (string, error) {
  13. req, err := s.client.NewRequest("GET", userdataBasePath, nil)
  14. if err != nil {
  15. return "", err
  16. }
  17. buffer := &bytes.Buffer{}
  18. _, err = s.client.Do(req, buffer)
  19. return buffer.String(), err
  20. }