yunion.io/x/cloudmux@v0.3.10-0-alpha.1/cmd/cmx/shell/eip.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  	"yunion.io/x/cloudmux/pkg/cloudprovider"
    19  )
    20  
    21  func init() {
    22  	cmd := NewCommand("eip")
    23  
    24  	type EipListOptions struct {
    25  		ListBaseOptions
    26  		Id          string `help:"Eip id"`
    27  		AssociateId string `help:"Id of associate resource"`
    28  		Addr        string `help:"Eip address"`
    29  	}
    30  	RegionR[EipListOptions](cmd).List("list", "List eips", func(cli cloudprovider.ICloudRegion, args *EipListOptions) (any, error) {
    31  		return cli.GetIEips()
    32  	})
    33  
    34  	// type EipAllocateOptions struct {
    35  	// 	Name            string
    36  	// 	BW              int    `help:"Bandwidth limit in Mbps"`
    37  	// 	ResourceGroupId string `help:"Resource group Id"`
    38  	// }
    39  	// RegionRunner[EipAllocateOptions](cmd).Run("create", "Allocate an EIP", func(cli cloudprovider.ICloudRegion, args *EipAllocateOptions) (any, error) {
    40  	// 	eip, err := cli.AllocateEIP(args.Name, args.BW, aliyun.InternetChargeByTraffic, args.ResourceGroupId)
    41  	// 	if err != nil {
    42  	// 		return err
    43  	// 	}
    44  	// 	PrintObject(eip)
    45  	// 	return nil
    46  	// })
    47  
    48  	// type EipReleaseOptions struct {
    49  	// 	ID string `help:"EIP allocation ID"`
    50  	// }
    51  	// RegionRunner[EipReleaseOptions](cmd).Run("delete", "Release an EIP", func(cli cloudprovider.ICloudRegion, args *EipReleaseOptions) (any, error) {
    52  	// 	err := cli.DeallocateEIP(args.ID)
    53  	// 	return nil, err
    54  	// })
    55  	//
    56  	// type EipAssociateOptions struct {
    57  	// 	ID       string `help:"EIP allocation ID"`
    58  	// 	INSTANCE string `help:"Instance ID"`
    59  	// }
    60  	// RegionR(&EipAssociateOptions{}, "eip-associate", "Associate an EIP", func(cli cloudprovider.ICloudRegion, args *EipAssociateOptions) error {
    61  	// 	err := cli.AssociateEip(args.ID, args.INSTANCE)
    62  	// 	return err
    63  	// })
    64  	// RegionR(&EipAssociateOptions{}, "eip-dissociate", "Dissociate an EIP", func(cli cloudprovider.ICloudRegion, args *EipAssociateOptions) error {
    65  	// 	err := cli.DissociateEip(args.ID, args.INSTANCE)
    66  	// 	return err
    67  	// })
    68  }