yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/aliyun/shell/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 shell 16 17 import ( 18 "fmt" 19 20 "yunion.io/x/pkg/errors" 21 22 "yunion.io/x/cloudmux/pkg/multicloud/aliyun" 23 "yunion.io/x/onecloud/pkg/util/shellutils" 24 ) 25 26 func init() { 27 type WafShowOptions struct { 28 } 29 shellutils.R(&WafShowOptions{}, "waf-instance-show", "Show waf instance", func(cli *aliyun.SRegion, args *WafShowOptions) error { 30 waf, err := cli.DescribeInstanceSpecInfo() 31 if err != nil { 32 return err 33 } 34 printObject(waf) 35 return nil 36 }) 37 38 type WafIdOptions struct { 39 ID string 40 } 41 42 shellutils.R(&WafIdOptions{}, "waf-instance-delete", "Delete waf instance", func(cli *aliyun.SRegion, args *WafIdOptions) error { 43 return cli.DeleteInstance(args.ID) 44 }) 45 46 shellutils.R(&WafIdOptions{}, "waf-domain-list", "List waf instance domains", func(cli *aliyun.SRegion, args *WafIdOptions) error { 47 domains, err := cli.DescribeDomainNames(args.ID) 48 if err != nil { 49 return errors.Wrapf(err, "DescribeDomainNames") 50 } 51 fmt.Println("domains: ", domains) 52 return nil 53 }) 54 55 type WafDomainIdOptions struct { 56 ID string 57 DOMAIN string 58 } 59 60 shellutils.R(&WafDomainIdOptions{}, "waf-domain-show", "Show waf domain", func(cli *aliyun.SRegion, args *WafDomainIdOptions) error { 61 domain, err := cli.DescribeDomain(args.ID, args.DOMAIN) 62 if err != nil { 63 return err 64 } 65 printObject(domain) 66 return nil 67 }) 68 69 shellutils.R(&WafDomainIdOptions{}, "waf-domain-delete", "Delete waf domain", func(cli *aliyun.SRegion, args *WafDomainIdOptions) error { 70 return cli.DeleteDomain(args.ID, args.DOMAIN) 71 }) 72 73 }