yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/aliyun/waf.go (about) 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 15 package aliyun 16 17 import ( 18 "yunion.io/x/pkg/errors" 19 20 "yunion.io/x/cloudmux/pkg/cloudprovider" 21 ) 22 23 type SInstanceSpecs struct { 24 Code int 25 Value bool 26 } 27 28 type SWafInstance struct { 29 Version string 30 InstanceSpecInfos []SInstanceSpecs 31 InstanceId string 32 ExpireTime uint64 33 } 34 35 func (self *SRegion) DescribeInstanceSpecInfo() (*SWafInstance, error) { 36 params := map[string]string{ 37 "RegionId": self.RegionId, 38 } 39 resp, err := self.wafRequest("DescribeInstanceSpecInfo", params) 40 if err != nil { 41 return nil, errors.Wrapf(err, "DescribeInstanceSpecInfo") 42 } 43 ret := &SWafInstance{} 44 err = resp.Unmarshal(&ret) 45 if err != nil { 46 return nil, errors.Wrapf(err, "resp.Unmarshal") 47 } 48 if len(ret.InstanceId) == 0 { 49 return nil, cloudprovider.ErrNotFound 50 } 51 return ret, nil 52 } 53 54 func (self *SRegion) DeleteInstance(id string) error { 55 params := map[string]string{ 56 "RegionId": self.RegionId, 57 "InstanceId": id, 58 } 59 _, err := self.wafRequest("DeleteInstance", params) 60 return errors.Wrapf(err, "DeleteInstance") 61 }