yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/apsara/shell/dbinstance_database.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-database-list", "List dbintance databases", func(cli *apsara.SRegion, args *DBInstanceIdExtraOptions) error {
    31  		databases, _, err := cli.GetDBInstanceDatabases(args.ID, "", args.Offset, args.Limit)
    32  		if err != nil {
    33  			return err
    34  		}
    35  		printList(databases, 0, 0, 0, []string{})
    36  		return nil
    37  	})
    38  
    39  	type DBInstanceDatabaseCreateOptions struct {
    40  		INSTANCE     string `help:"ID of instances"`
    41  		NAME         string `help:"database name"`
    42  		CHARACTERSET string `help:"character set for database"`
    43  		Desc         string
    44  	}
    45  
    46  	shellutils.R(&DBInstanceDatabaseCreateOptions{}, "dbinstance-database-create", "Create dbintance database", func(cli *apsara.SRegion, args *DBInstanceDatabaseCreateOptions) error {
    47  		return cli.CreateDBInstanceDatabae(args.INSTANCE, args.CHARACTERSET, args.NAME, args.Desc)
    48  	})
    49  
    50  	type DBInstanceDatabaseDeleteOptions struct {
    51  		INSTANCE string
    52  		NAME     string
    53  	}
    54  
    55  	shellutils.R(&DBInstanceDatabaseDeleteOptions{}, "dbinstance-database-delete", "Delete dbintance database", func(cli *apsara.SRegion, args *DBInstanceDatabaseDeleteOptions) error {
    56  		return cli.DeleteDBInstanceDatabase(args.INSTANCE, args.NAME)
    57  	})
    58  
    59  }