| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- // Copyright 2019 Yunion
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- package aliyun
- import (
- "fmt"
- "yunion.io/x/pkg/errors"
- )
- type SDnsGtmInstance struct {
- InstanceId string
- Config struct {
- PublicZoneName string
- }
- }
- func (self *SAliyunClient) DescribeDnsGtmInstances() ([]SDnsGtmInstance, error) {
- params := map[string]string{
- "PageSize": "100",
- }
- ret := []SDnsGtmInstance{}
- pageNumber := 1
- for {
- params["PageNumber"] = fmt.Sprintf("%d", pageNumber)
- resp, err := self.alidnsRequest("DescribeDnsGtmInstances", params)
- if err != nil {
- return nil, err
- }
- part := struct {
- GtmInstances []SDnsGtmInstance
- TotalItems int
- }{}
- err = resp.Unmarshal(&part)
- if err != nil {
- return nil, err
- }
- ret = append(ret, part.GtmInstances...)
- if len(ret) >= part.TotalItems || len(part.GtmInstances) == 0 {
- break
- }
- pageNumber++
- }
- return ret, nil
- }
- type SDnsGtmInstanceAddressPool struct {
- Name string
- AddrPoolId string
- AddrCount int
- Addrs struct {
- Addr []struct {
- Addr string
- }
- }
- }
- func (self *SAliyunClient) DescribeDnsGtmInstanceAddressPools(id string) ([]SDnsGtmInstanceAddressPool, error) {
- params := map[string]string{"InstanceId": id, "PageSize": "100"}
- ret := []SDnsGtmInstanceAddressPool{}
- pageNumber := 1
- for {
- params["PageNumber"] = fmt.Sprintf("%d", pageNumber)
- resp, err := self.alidnsRequest("DescribeDnsGtmInstanceAddressPools", params)
- if err != nil {
- return nil, err
- }
- part := struct {
- AddrPools struct {
- AddrPool []SDnsGtmInstanceAddressPool
- }
- TotalItems int
- }{}
- err = resp.Unmarshal(&part)
- if err != nil {
- return nil, err
- }
- ret = append(ret, part.AddrPools.AddrPool...)
- if len(ret) >= part.TotalItems || len(part.AddrPools.AddrPool) == 0 {
- break
- }
- pageNumber++
- }
- return ret, nil
- }
- func (self *SAliyunClient) DescribeDnsGtmInstanceAddressPool(id string) (*SDnsGtmInstanceAddressPool, error) {
- params := map[string]string{"AddrPoolId": id}
- resp, err := self.alidnsRequest("DescribeDnsGtmInstanceAddressPool", params)
- if err != nil {
- return nil, err
- }
- ret := &SDnsGtmInstanceAddressPool{}
- err = resp.Unmarshal(ret)
- if err != nil {
- return nil, errors.Wrapf(err, "Unmarshal")
- }
- return ret, nil
- }
|