yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/apsara/shell/dbinstance_account.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/multicloud/apsara" 19 "yunion.io/x/onecloud/pkg/util/shellutils" 20 ) 21 22 func init() { 23 24 type DBInstanceIdExtraOptions struct { 25 ID string `help:"ID of instances to show"` 26 Limit int `help:"page size"` 27 Offset int `help:"page offset"` 28 } 29 30 shellutils.R(&DBInstanceIdExtraOptions{}, "dbinstance-account-list", "List dbintance accounts", func(cli *apsara.SRegion, args *DBInstanceIdExtraOptions) error { 31 accounts, _, err := cli.GetDBInstanceAccounts(args.ID, args.Offset, args.Limit) 32 if err != nil { 33 return err 34 } 35 printList(accounts, 0, 0, 0, []string{}) 36 return nil 37 }) 38 39 type DBInstanceAccountCreateOptions struct { 40 INSTANCE string `help:"ID of instances"` 41 NAME string `help:"account name"` 42 PASSWORD string `help:"account password"` 43 Desc string 44 } 45 46 shellutils.R(&DBInstanceAccountCreateOptions{}, "dbinstance-account-create", "Create dbintance account", func(cli *apsara.SRegion, args *DBInstanceAccountCreateOptions) error { 47 return cli.CreateDBInstanceAccount(args.INSTANCE, args.NAME, args.PASSWORD, args.Desc) 48 }) 49 50 type DBInstanceAccountDeleteOptions struct { 51 INSTANCE string 52 NAME string 53 } 54 55 shellutils.R(&DBInstanceAccountDeleteOptions{}, "dbinstance-account-delete", "Delete dbintance account", func(cli *apsara.SRegion, args *DBInstanceAccountDeleteOptions) error { 56 return cli.DeleteDBInstanceAccount(args.INSTANCE, args.NAME) 57 }) 58 59 type DBInstanceAccountResetOptions struct { 60 INSTANCE string `help:"ID of instances"` 61 NAME string `help:"account name"` 62 PASSWORD string `help:"account password"` 63 AccountType string `help:"account type" choices:"Normal|Super" default:"Normal"` 64 } 65 66 shellutils.R(&DBInstanceAccountResetOptions{}, "dbinstance-account-reset-password", "Reset dbintance account password", func(cli *apsara.SRegion, args *DBInstanceAccountResetOptions) error { 67 return cli.ResetDBInstanceAccountPassword(args.INSTANCE, args.NAME, args.PASSWORD, args.AccountType) 68 }) 69 70 }