xpnhost.go 844 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package google
  2. import "fmt"
  3. type SXpnHost struct {
  4. Kind string
  5. Name string
  6. }
  7. func (cli *SGoogleClient) GetXpnHosts() ([]SXpnHost, error) {
  8. res := fmt.Sprintf("projects/%s", cli.projectId)
  9. resp, err := cli.ecsPost(res, "listXpnHosts", nil, nil)
  10. if err != nil {
  11. return nil, err
  12. }
  13. ret := struct {
  14. Items []SXpnHost
  15. }{}
  16. err = resp.Unmarshal(&ret)
  17. if err != nil {
  18. return nil, err
  19. }
  20. return ret.Items, nil
  21. }
  22. type SXpnResource struct {
  23. Type string
  24. Id string
  25. }
  26. func (cli *SGoogleClient) GetXpnResources(projectId string) ([]SXpnResource, error) {
  27. res := fmt.Sprintf("projects/%s/getXpnResources", projectId)
  28. resp, err := cli.ecsList(res, nil)
  29. if err != nil {
  30. return nil, err
  31. }
  32. ret := struct {
  33. Resources []SXpnResource
  34. }{}
  35. err = resp.Unmarshal(&ret)
  36. if err != nil {
  37. return nil, err
  38. }
  39. return ret.Resources, nil
  40. }