gtm3.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package aliyun
  15. import "fmt"
  16. type SGtmInstanceConfigs struct {
  17. InstanceId string
  18. ScheduleDomainName string
  19. ScheduleZoneName string
  20. AddressPools struct {
  21. AddressPool []struct {
  22. AddressPoolId string
  23. AddressPoolName string
  24. }
  25. }
  26. }
  27. func (self *SAliyunClient) ListCloudGtmInstanceConfigs() ([]SGtmInstanceConfigs, error) {
  28. params := map[string]string{"PageSize": "100"}
  29. ret := []SGtmInstanceConfigs{}
  30. pageNumber := 1
  31. for {
  32. params["PageNumber"] = fmt.Sprintf("%d", pageNumber)
  33. resp, err := self.alidnsRequest("ListCloudGtmInstanceConfigs", params)
  34. if err != nil {
  35. return nil, err
  36. }
  37. part := struct {
  38. InstanceConfigs struct {
  39. InstanceConfig []SGtmInstanceConfigs
  40. }
  41. TotalItems int
  42. }{}
  43. err = resp.Unmarshal(&part)
  44. if err != nil {
  45. return nil, err
  46. }
  47. ret = append(ret, part.InstanceConfigs.InstanceConfig...)
  48. if len(ret) >= part.TotalItems || len(part.InstanceConfigs.InstanceConfig) == 0 {
  49. break
  50. }
  51. pageNumber++
  52. }
  53. return ret, nil
  54. }
  55. type SGtmAddressPool struct {
  56. AddressPoolId string
  57. Addresses struct {
  58. Address []struct {
  59. Address string
  60. }
  61. }
  62. }
  63. func (self *SAliyunClient) DescribeCloudGtmAddressPool(id string) (*SGtmAddressPool, error) {
  64. params := map[string]string{"AddressPoolId": id}
  65. resp, err := self.alidnsRequest("DescribeCloudGtmAddressPool", params)
  66. if err != nil {
  67. return nil, err
  68. }
  69. ret := &SGtmAddressPool{}
  70. err = resp.Unmarshal(ret)
  71. if err != nil {
  72. return nil, err
  73. }
  74. return ret, nil
  75. }