diff --git a/Makefile b/Makefile index 4099c72d5d..954e9f200b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -export VERSION=0.1.9 +export VERSION=0.1.10 .PHONY : build build: diff --git a/base/client.go b/base/client.go index bb5a713d8b..09d22e76f1 100644 --- a/base/client.go +++ b/base/client.go @@ -1,10 +1,11 @@ package base import ( - pudisk "github.com/ucloud/ucloud-sdk-go/private/services/udisk" + pudb "github.com/ucloud/ucloud-sdk-go/private/services/udb" puhost "github.com/ucloud/ucloud-sdk-go/private/services/uhost" "github.com/ucloud/ucloud-sdk-go/services/pathx" "github.com/ucloud/ucloud-sdk-go/services/uaccount" + "github.com/ucloud/ucloud-sdk-go/services/udb" "github.com/ucloud/ucloud-sdk-go/services/udisk" "github.com/ucloud/ucloud-sdk-go/services/udpn" "github.com/ucloud/ucloud-sdk-go/services/uhost" @@ -15,12 +16,12 @@ import ( "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) -//PrivateUDiskClient 私有模块的udisk client 即未在官网开放的接口 -type PrivateUDiskClient = pudisk.UDiskClient - -//PrivateUHostClient 私有模块的udisk client 即未在官网开放的接口 +//PrivateUHostClient 私有模块的uhost client 即未在官网开放的接口 type PrivateUHostClient = puhost.UHostClient +//PrivateUDBClient 私有模块的udb client 即未在官网开放的接口 +type PrivateUDBClient = pudb.UDBClient + //Client aggregate client for business type Client struct { uaccount.UAccountClient @@ -31,7 +32,9 @@ type Client struct { pathx.PathXClient udisk.UDiskClient ulb.ULBClient + udb.UDBClient PrivateUHostClient + PrivateUDBClient } // NewClient will return a aggregate client @@ -45,6 +48,8 @@ func NewClient(config *ucloud.Config, credential *auth.Credential) *Client { *pathx.NewClient(config, credential), *udisk.NewClient(config, credential), *ulb.NewClient(config, credential), + *udb.NewClient(config, credential), *puhost.NewClient(config, credential), + *pudb.NewClient(config, credential), } } diff --git a/base/config.go b/base/config.go index f1566c814f..7ad7541ec8 100644 --- a/base/config.go +++ b/base/config.go @@ -11,6 +11,7 @@ import ( "github.com/ucloud/ucloud-sdk-go/services/uaccount" sdk "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" + "github.com/ucloud/ucloud-sdk-go/ucloud/log" ) //ConfigFile filename @@ -29,7 +30,7 @@ const DefaultBaseURL = "https://api.ucloud.cn/" const DefaultProfile = "default" //Version 版本号 -const Version = "0.1.9" +const Version = "0.1.10" //ConfigIns 配置实例, 程序加载时生成 var ConfigIns = &AggConfig{} @@ -40,6 +41,19 @@ var ClientConfig *sdk.Config //AuthCredential 创建sdk client参数 var AuthCredential *auth.Credential +//Global 全局flag +var Global GlobalFlag + +//GlobalFlag 几乎所有接口都需要的参数,例如 region zone projectID +type GlobalFlag struct { + Debug bool + JSON bool + Version bool + Completion bool + Config bool + Signup bool +} + //CLIConfig cli_config element type CLIConfig struct { ProjectID string `json:"project_id"` @@ -75,26 +89,26 @@ type AggConfig struct { func (p *AggConfig) ConfigPublicKey() error { Cxt.Print("Your public-key:") _, err := fmt.Scanf("%s\n", &p.PublicKey) - p.PublicKey = strings.TrimSpace(p.PublicKey) - AuthCredential.PublicKey = p.PublicKey - p.Save() if err != nil { Cxt.Println(err) + return err } - return err + p.PublicKey = strings.TrimSpace(p.PublicKey) + AuthCredential.PublicKey = p.PublicKey + return nil } //ConfigPrivateKey 输入私钥 func (p *AggConfig) ConfigPrivateKey() error { Cxt.Print("Your private-key:") _, err := fmt.Scanf("%s\n", &p.PrivateKey) - p.PrivateKey = strings.TrimSpace(p.PrivateKey) - AuthCredential.PrivateKey = p.PrivateKey - p.Save() if err != nil { Cxt.Println(err) + return err } - return err + p.PrivateKey = strings.TrimSpace(p.PrivateKey) + AuthCredential.PrivateKey = p.PrivateKey + return nil } //GetClientConfig 用来生成sdkClient @@ -491,8 +505,8 @@ func init() { ClientConfig = &sdk.Config{ BaseUrl: ConfigIns.BaseURL, Timeout: timeout, - UserAgent: fmt.Sprintf("UCloud CLI v%s", Version), - LogLevel: 1, + UserAgent: fmt.Sprintf("UCloud-CLI/%s", Version), + LogLevel: log.FatalLevel, } AuthCredential = &auth.Credential{ diff --git a/base/util.go b/base/util.go index 1fd2d1cdf6..44e236e09b 100644 --- a/base/util.go +++ b/base/util.go @@ -157,8 +157,8 @@ func PrintTableS(dataSet interface{}) { } //PrintList 打印表格或者JSON -func PrintList(dataSet interface{}, json bool) { - if json { +func PrintList(dataSet interface{}) { + if Global.JSON { PrintJSON(dataSet) } else { PrintTableS(dataSet) @@ -280,6 +280,9 @@ func FormatDate(seconds int) string { return time.Unix(int64(seconds), 0).Format("2006-01-02") } +//DateTimeLayout 时间格式 +const DateTimeLayout = "2006-01-02/15:04:05" + //FormatDateTime 格式化时间,把以秒为单位的时间戳格式化未年月日/时分秒 func FormatDateTime(seconds int) string { return time.Unix(int64(seconds), 0).Format("2006-01-02/15:04:05") @@ -362,14 +365,12 @@ func (p *Poller) Spoll(resourceID, pollText string, targetStates []string) { done := make(chan bool) go func() { - if resp, err := w.Wait(); err != nil { + if _, err := w.Wait(); err != nil { log.Error(err) if _, ok := err.(*waiter.TimeoutError); ok { done <- false return } - } else { - log.Infof("%#v", resp) } done <- true }() @@ -427,14 +428,12 @@ func (p *Poller) Poll(resourceID, projectID, region, zone, pollText string, targ done := make(chan bool) go func() { - if resp, err := w.Wait(); err != nil { + if _, err := w.Wait(); err != nil { log.Error(err) if _, ok := err.(*waiter.TimeoutError); ok { done <- false return } - } else { - log.Infof("%#v", resp) } done <- true }() @@ -509,7 +508,6 @@ func GetFileList(suffix string) []string { } files, err := ioutil.ReadDir(pathPrefix) if err != nil { - log.Fatal(err) return nil } names := []string{} @@ -529,3 +527,16 @@ func GetFileList(suffix string) []string { } return names } + +//Confirm 二次确认 +func Confirm(yes bool, text string) bool { + if yes { + return true + } + sure, err := ux.Prompt(text) + if err != nil { + Cxt.Println(err) + return false + } + return sure +} diff --git a/cmd/backup.go b/cmd/backup.go new file mode 100644 index 0000000000..898a9f5095 --- /dev/null +++ b/cmd/backup.go @@ -0,0 +1,528 @@ +// Copyright © 2018 NAME HERE tony.li@ucloud.cn +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cmd + +import ( + "fmt" + "io" + "strconv" + "time" + + "github.com/spf13/cobra" + + sdk "github.com/ucloud/ucloud-sdk-go/ucloud" + + "github.com/ucloud/ucloud-cli/base" +) + +//NewCmdUDBBackup ucloud udb backup +func NewCmdUDBBackup() *cobra.Command { + cmd := &cobra.Command{ + Use: "backup", + Short: "List and manipulate backups of MySQL instance", + Long: "List and manipulate backups of MySQL instance", + } + out := base.Cxt.GetWriter() + cmd.AddCommand(NewCmdUDBBackupCreate(out)) + cmd.AddCommand(NewCmdUDBBackupList()) + cmd.AddCommand(NewCmdUDBBackupDelete(out)) + cmd.AddCommand(NewCmdUDBBackupGetDownloadURL(out)) + return cmd +} + +//NewCmdUDBBackupCreate ucloud udb backup create +func NewCmdUDBBackupCreate(out io.Writer) *cobra.Command { + req := base.BizClient.NewBackupUDBInstanceRequest() + cmd := &cobra.Command{ + Use: "create", + Short: "Create backups for MySQL instance manually", + Long: "Create backups for MySQL instance manually", + Run: func(c *cobra.Command, args []string) { + *req.DBId = base.PickResourceID(*req.DBId) + _, err := base.BizClient.BackupUDBInstance(req) + if err != nil { + base.HandleError(err) + return + } + fmt.Fprintf(out, "udb[%s] backuped\n", *req.DBId) + }, + } + + flags := cmd.Flags() + flags.SortFlags = false + + req.DBId = flags.String("udb-id", "", "Required. Resource ID of UDB instnace to backup") + req.BackupName = flags.String("name", "", "Required. Name of backup") + bindProjectID(req, flags) + bindRegion(req, flags) + bindZone(req, flags) + + cmd.MarkFlagRequired("udb-id") + cmd.MarkFlagRequired("name") + + flags.SetFlagValuesFunc("udb-id", func() []string { + return getUDBIDList(nil, "sql", *req.ProjectId, *req.Region, *req.Zone) + }) + + return cmd +} + +type udbBackupRow struct { + BackupID int + BackupName string + DB string + BackupSize string + BackupType string + Status string + AvailabilityZone string + BackupBeginTime string + BackupEndTime string +} + +//NewCmdUDBBackupList ucloud udb backup list +func NewCmdUDBBackupList() *cobra.Command { + var bpType, dbType, beginTime, endTime, backupID string + bpTypeMap := map[string]int{ + "manual": 1, + "auto": 0, + } + reverseBpTypeMap := map[int]string{ + 1: "manual", + 0: "auto", + } + req := base.BizClient.NewDescribeUDBBackupRequest() + cmd := &cobra.Command{ + Use: "list", + Short: "List backups of MySQL instance", + Long: "List backups of MySQL instance", + Run: func(c *cobra.Command, args []string) { + if v, ok := bpTypeMap[bpType]; ok { + req.BackupType = &v + } + if v, ok := dbTypeMap[dbType]; ok { + req.ClassType = &v + } + if *req.DBId != "" { + *req.DBId = base.PickResourceID(*req.DBId) + } + if backupID != "" { + id, err := strconv.Atoi(base.PickResourceID(backupID)) + if err != nil { + base.HandleError(err) + return + } + req.BackupId = &id + } + if beginTime != "" { + bt, err := time.Parse("2006-01-02/15:04:05", beginTime) + if err != nil { + base.HandleError(err) + return + } + req.BeginTime = sdk.Int(int(bt.Unix())) + } + if endTime != "" { + bt, err := time.Parse("2006-01-02/15:04:05", endTime) + if err != nil { + base.HandleError(err) + return + } + req.EndTime = sdk.Int(int(bt.Unix())) + } + resp, err := base.BizClient.DescribeUDBBackup(req) + if err != nil { + base.HandleError(err) + return + } + list := []udbBackupRow{} + for _, ins := range resp.DataSet { + row := udbBackupRow{ + BackupID: ins.BackupId, + BackupName: ins.BackupName, + AvailabilityZone: ins.Zone, + DB: fmt.Sprintf("%s|%s", ins.DBName, ins.DBId), + BackupSize: fmt.Sprintf("%dB", ins.BackupSize), + BackupType: reverseBpTypeMap[ins.BackupType], + Status: ins.State, + BackupBeginTime: base.FormatDateTime(ins.BackupTime), + BackupEndTime: base.FormatDateTime(ins.BackupEndTime), + } + list = append(list, row) + } + base.PrintList(list) + }, + } + flags := cmd.Flags() + flags.SortFlags = false + + req.DBId = flags.String("udb-id", "", "Optional. Resource ID of UDB for list the backups of the specifid UDB") + flags.StringVar(&backupID, "backup-id", "", "Optional. Resource ID of backup. List the specified backup only") + flags.StringVar(&bpType, "backup-type", "", "Optional. Backup type. Accept values:auto or manual") + flags.StringVar(&dbType, "db-type", "", "Optional. Only list backups of the UDB of the specified DB type") + flags.StringVar(&beginTime, "begin-time", "", "Optional. Begin time of backup. For example, 2019-02-26/11:21:39") + flags.StringVar(&endTime, "end-time", "", "Optional. End time of backup. For example, 2019-02-26/11:31:39") + + bindRegion(req, flags) + bindZone(req, flags) + bindProjectID(req, flags) + bindOffset(req, flags) + bindLimit(req, flags) + + flags.SetFlagValues("backup-type", "auto", "manual") + flags.SetFlagValues("db-type", dbTypeList...) + flags.SetFlagValuesFunc("udb-id", func() []string { + return getUDBIDList(nil, "sql", *req.ProjectId, *req.Region, *req.Zone) + }) + + return cmd +} + +//NewCmdUDBBackupDelete ucloud udb backup delete +func NewCmdUDBBackupDelete(out io.Writer) *cobra.Command { + ids := []int{} + req := base.BizClient.NewDeleteUDBBackupRequest() + cmd := &cobra.Command{ + Use: "delete", + Short: "Delete backups of MySQL instance", + Long: "Delete backups of MySQL instance", + Example: "ucloud udb backup delete --backup-id 65534,65535", + Run: func(c *cobra.Command, args []string) { + for _, id := range ids { + req.BackupId = sdk.Int(id) + _, err := base.BizClient.DeleteUDBBackup(req) + if err != nil { + base.HandleError(err) + continue + } + fmt.Fprintf(out, "backup[%d] deleted\n", id) + } + }, + } + flags := cmd.Flags() + flags.SortFlags = false + + flags.IntSliceVar(&ids, "backup-id", nil, "Required. BackupID of backups to delete") + bindProjectID(req, flags) + bindRegion(req, flags) + bindZone(req, flags) + + cmd.MarkFlagRequired("backup-id") + return cmd +} + +//NewCmdUDBBackupGetDownloadURL ucloud udb backup get-download-url +func NewCmdUDBBackupGetDownloadURL(out io.Writer) *cobra.Command { + req := base.BizClient.NewDescribeUDBInstanceBackupURLRequest() + cmd := &cobra.Command{ + Use: "download", + Short: "Display download url of backup", + Long: "Display download url of backup", + Run: func(c *cobra.Command, args []string) { + resp, err := base.BizClient.DescribeUDBInstanceBackupURL(req) + if err != nil { + base.HandleError(err) + return + } + fmt.Fprintln(out, resp.BackupPath) + }, + } + flags := cmd.Flags() + flags.SortFlags = false + + req.BackupId = flags.Int("backup-id", -1, "Required. BackupID of backup to delete") + req.DBId = flags.String("udb-id", "", "Required. Resource ID of udb which the backup belongs to") + bindProjectID(req, flags) + bindRegion(req, flags) + bindZone(req, flags) + + cmd.MarkFlagRequired("udb-id") + cmd.MarkFlagRequired("backup-id") + flags.SetFlagValuesFunc("udb-id", func() []string { + return getUDBIDList(nil, "sql", *req.ProjectId, *req.Region, *req.Zone) + }) + return cmd +} + +//NewCmdUDBLog ucloud udb log +func NewCmdUDBLog() *cobra.Command { + cmd := &cobra.Command{ + Use: "logs", + Short: "List and manipulate logs of MySQL instance", + Long: "List and manipulate logs of MySQL instance", + } + + out := base.Cxt.GetWriter() + cmd.AddCommand(NewCmdUDBLogArchiveCreate(out)) + cmd.AddCommand(NewCmdUDBLogArchiveList(out)) + cmd.AddCommand(NewCmdUDBLogArchiveGetDownloadURL(out)) + cmd.AddCommand(NewCmdUDBLogArchiveDelete(out)) + + return cmd +} + +//NewCmdUDBLogArchiveCreate ucloud udb log archive create +func NewCmdUDBLogArchiveCreate(out io.Writer) *cobra.Command { + var region, zone, project, udbID string + var name, logType, beginTime, endTime string + cmd := &cobra.Command{ + Use: "archive", + Short: "Archive the log of mysql as a compressed file", + Long: "Archive the log of mysql as a compressed file", + Example: "ucloud mysql logs archive --name test.cli2 --udb-id udb-xxx/test.cli1 --log-type slow_query --begin-time 2019-02-23/15:30:00 --end-time 2019-02-24/15:31:00", + Run: func(c *cobra.Command, args []string) { + udbID = base.PickResourceID(udbID) + if logType == "slow_query" { + if beginTime == "" || endTime == "" { + fmt.Fprintln(out, "Error. Both begin-time and end-time can not be empty") + return + } + bt, err := time.Parse(base.DateTimeLayout, beginTime) + if err != nil { + base.HandleError(err) + return + } + et, err := time.Parse(base.DateTimeLayout, endTime) + if err != nil { + base.HandleError(err) + return + } + + req := base.BizClient.NewBackupUDBInstanceSlowLogRequest() + req.BeginTime = sdk.Int(int(bt.Unix())) + req.EndTime = sdk.Int(int(et.Unix())) + req.DBId = &udbID + req.BackupName = &name + req.Region = ®ion + req.ProjectId = &project + + _, err = base.BizClient.BackupUDBInstanceSlowLog(req) + if err != nil { + base.HandleError(err) + return + } + fmt.Fprintf(out, "mysql log archive[%s] created\n", name) + } else if logType == "error" { + req := base.BizClient.NewBackupUDBInstanceErrorLogRequest() + req.DBId = &udbID + req.BackupName = &name + req.Region = ®ion + req.Zone = &zone + req.ProjectId = &project + + _, err := base.BizClient.BackupUDBInstanceErrorLog(req) + if err != nil { + base.HandleError(err) + return + } + fmt.Fprintf(out, "mysql log archive[%s] created\n", name) + } + }, + } + + flags := cmd.Flags() + flags.SortFlags = false + + flags.StringVar(&udbID, "udb-id", "", "Required. Resource ID of UDB instance which we fetch logs from") + flags.StringVar(&name, "name", "", "Required. Name of compressed file") + flags.StringVar(&logType, "log-type", "", "Required. Type of log to package. Accept values: slow_query, error") + flags.StringVar(&beginTime, "begin-time", "", "Optional. Required when log-type is slow. For example 2019-01-02/15:04:05") + flags.StringVar(&endTime, "end-time", "", "Optional. Required when log-type is slow. For example 2019-01-02/15:04:05") + bindRegionS(®ion, flags) + bindZoneS(&zone, ®ion, flags) + bindProjectIDS(&project, flags) + + cmd.MarkFlagRequired("udb-id") + cmd.MarkFlagRequired("name") + cmd.MarkFlagRequired("log-type") + + flags.SetFlagValues("log-type", "slow_query", "error") + flags.SetFlagValuesFunc("udb-id", func() []string { + return getUDBIDList(nil, "sql", project, region, base.ConfigIns.Zone) + }) + return cmd +} + +type udbArchiveRow struct { + ArchiveID int + Name string + LogType string + DB string + Size string + Status string + CreateTime string +} + +//NewCmdUDBLogArchiveList ucloud udb log archive list +func NewCmdUDBLogArchiveList(out io.Writer) *cobra.Command { + var beginTime, endTime string + logTypes := []string{} + logTypeMap := map[string]int{ + "binlog": 2, + "slow_query": 3, + "error": 4, + } + rLogTypeMap := map[int]string{ + 2: "binlog", + 3: "slow_query", + 4: "error", + } + req := base.BizClient.NewDescribeUDBLogPackageRequest() + cmd := &cobra.Command{ + Use: "list", + Short: "List mysql log archives(log files)", + Long: "List mysql log archives(log files)", + Run: func(c *cobra.Command, args []string) { + if beginTime != "" { + bt, err := time.Parse(base.DateTimeLayout, beginTime) + if err != nil { + base.HandleError(err) + return + } + req.BeginTime = sdk.Int(int(bt.Unix())) + } + if endTime != "" { + et, err := time.Parse(base.DateTimeLayout, endTime) + if err != nil { + base.HandleError(err) + return + } + req.EndTime = sdk.Int(int(et.Unix())) + } + + if *req.DBId != "" { + *req.DBId = base.PickResourceID(*req.DBId) + } + + for _, s := range logTypes { + if v, ok := logTypeMap[s]; ok { + req.Types = append(req.Types, v) + } else { + fmt.Fprintln(out, "Error, log-type should be one of 'binlog', 'slow_query' or 'error'") + } + } + + resp, err := base.BizClient.DescribeUDBLogPackage(req) + if err != nil { + base.HandleError(err) + return + } + list := []udbArchiveRow{} + for _, ins := range resp.DataSet { + row := udbArchiveRow{ + ArchiveID: ins.BackupId, + Name: ins.BackupName, + LogType: rLogTypeMap[ins.BackupType], + DB: fmt.Sprintf("%s|%s", ins.DBId, ins.DBName), + Size: fmt.Sprintf("%dB", ins.BackupSize), + Status: ins.State, + CreateTime: base.FormatDateTime(ins.BackupTime), + } + list = append(list, row) + } + base.PrintList(list) + }, + } + + flags := cmd.Flags() + flags.SortFlags = false + + flags.StringSliceVar(&logTypes, "log-type", nil, "Optional. Type of log. Accept Values: binlog, slow_query and error") + req.DBId = flags.String("udb-id", "", "Optional. Resource ID of UDB instance which the listed logs belong to") + flags.StringVar(&beginTime, "begin-time", "", "Optional. For example 2019-01-02/15:04:05") + flags.StringVar(&endTime, "end-time", "", "Optional. For example 2019-01-02/15:04:05") + bindProjectID(req, flags) + bindRegion(req, flags) + bindZone(req, flags) + bindLimit(req, flags) + bindOffset(req, flags) + + flags.SetFlagValues("log-type", "binlog", "slow_query", "error") + flags.SetFlagValuesFunc("udb-id", func() []string { + return getUDBIDList(nil, "sql", *req.ProjectId, *req.Region, *req.Zone) + }) + + return cmd +} + +//NewCmdUDBLogArchiveGetDownloadURL ucloud udb log archive get-download-url +func NewCmdUDBLogArchiveGetDownloadURL(out io.Writer) *cobra.Command { + req := base.BizClient.NewDescribeUDBBinlogBackupURLRequest() + cmd := &cobra.Command{ + Use: "download", + Short: "Display url of an archive(log file)", + Long: "Display url of an archive(log file)", + Example: "ucloud mysql logs download --udb-id udb-urixxx/test.cli1 --archive-id 35044", + Run: func(c *cobra.Command, args []string) { + *req.DBId = base.PickResourceID(*req.DBId) + resp, err := base.BizClient.DescribeUDBBinlogBackupURL(req) + if err != nil { + base.HandleError(err) + return + } + fmt.Fprintln(out, resp.BackupPath) + }, + } + flags := cmd.Flags() + flags.SortFlags = false + + req.BackupId = flags.Int("archive-id", 0, "Required. ArchiveID of archive to download") + req.DBId = flags.String("udb-id", "", "Required. Resource ID of UDB which the archive belongs to") + bindRegion(req, flags) + bindZone(req, flags) + bindProjectID(req, flags) + + cmd.MarkFlagRequired("archive-id") + cmd.MarkFlagRequired("udb-id") + + flags.SetFlagValuesFunc("udb-id", func() []string { + return getUDBIDList(nil, "sql", *req.ProjectId, *req.Region, *req.Zone) + }) + + return cmd +} + +//NewCmdUDBLogArchiveDelete ucloud udb log archive delete +func NewCmdUDBLogArchiveDelete(out io.Writer) *cobra.Command { + var ids []int + req := base.BizClient.NewDeleteUDBLogPackageRequest() + cmd := &cobra.Command{ + Use: "delete", + Short: "Delete log archives(log files)", + Long: "Delete log archives(log files)", + Example: "ucloud mysql logs delete --archive-id 35025", + Run: func(c *cobra.Command, args []string) { + for _, id := range ids { + req.BackupId = sdk.Int(id) + _, err := base.BizClient.DeleteUDBLogPackage(req) + if err != nil { + base.HandleError(err) + continue + } + fmt.Fprintf(out, "archive[%d] deleted\n", id) + } + }, + } + flags := cmd.Flags() + flags.SortFlags = false + + flags.IntSliceVar(&ids, "archive-id", nil, "Optional. ArchiveID of log archives to delete") + bindRegion(req, flags) + bindZone(req, flags) + bindProjectID(req, flags) + + cmd.MarkFlagRequired("archive-id") + + return cmd +} diff --git a/cmd/bandwidth.go b/cmd/bandwidth.go index e011527a5c..d24304a6ce 100644 --- a/cmd/bandwidth.go +++ b/cmd/bandwidth.go @@ -132,11 +132,7 @@ func NewCmdSharedBWList() *cobra.Command { row.EIP = strings.Join(eipList, "\n") list = append(list, row) } - if global.json { - base.PrintJSON(list) - } else { - base.PrintTableS(list) - } + base.PrintList(list) }, } flags := cmd.Flags() @@ -361,11 +357,7 @@ func NewCmdBandwidthPkgList() *cobra.Command { row.EIP = eip list = append(list, row) } - if global.json { - base.PrintJSON(list) - } else { - base.PrintTableS(list) - } + base.PrintList(list) }, } flags := cmd.Flags() diff --git a/cmd/configure.go b/cmd/configure.go index d518e5b68a..64970fa392 100644 --- a/cmd/configure.go +++ b/cmd/configure.go @@ -20,6 +20,8 @@ import ( "github.com/spf13/cobra" + uerr "github.com/ucloud/ucloud-sdk-go/ucloud/error" + "github.com/ucloud/ucloud-cli/base" ) @@ -52,6 +54,12 @@ func NewCmdInit() *cobra.Command { region, zone, err := getDefaultRegion() if err != nil { + if uErr, ok := err.(uerr.Error); ok { + if uErr.Code() == 172 { + fmt.Println("public key or private key is invalid.") + return + } + } base.Cxt.Println(err) return } @@ -82,11 +90,13 @@ func NewCmdInit() *cobra.Command { func printHello() { userInfo, err := getUserInfo() - base.Cxt.Printf("You are logged in as: [%s]\n", userInfo.UserEmail) - certified := isUserCertified(userInfo) if err != nil { base.Cxt.PrintErr(err) - } else if certified == false { + return + } + base.Cxt.Printf("You are logged in as: [%s]\n", userInfo.UserEmail) + certified := isUserCertified(userInfo) + if !certified { base.Cxt.Println("\nWarning: Please authenticate the account with your valid documentation at 'https://accountv2.ucloud.cn/authentication'.") } base.Cxt.Println(helloUcloud) @@ -202,7 +212,7 @@ func NewCmdConfigList() *cobra.Command { Short: "list all settings", Long: `list all settings`, Run: func(c *cobra.Command, args []string) { - base.ListAggConfig(global.json) + base.ListAggConfig(global.JSON) }, } return cmd diff --git a/cmd/disk.go b/cmd/disk.go index 3f60f3bd61..4178f13cb8 100644 --- a/cmd/disk.go +++ b/cmd/disk.go @@ -222,11 +222,7 @@ func NewCmdDiskList() *cobra.Command { } list = append(list, row) } - if global.json { - base.PrintJSON(list) - } else { - base.PrintTableS(list) - } + base.PrintList(list) }, } flags := cmd.Flags() @@ -516,7 +512,6 @@ func NewCmdDiskExpand() *cobra.Command { req.ProjectId = flags.String("project-id", base.ConfigIns.ProjectID, "Optional. Assign project-id") req.Region = flags.String("region", base.ConfigIns.Region, "Optional. Assign region") req.Zone = flags.String("zone", base.ConfigIns.Zone, "Optional. Assign availability zone") - req.CouponId = flags.String("coupon-id", "", "Optional. Coupon ID, The Coupon can deduct part of the payment,see https://accountv2.ucloud.cn") flags.SetFlagValuesFunc("udisk-id", func() []string { return getDiskList([]string{status.DISK_AVAILABLE}, *req.ProjectId, *req.Region, *req.Zone) @@ -675,11 +670,7 @@ func NewCmdSnapshotList(out io.Writer) *cobra.Command { } list = append(list, row) } - if global.json { - base.PrintJSON(list) - } else { - base.PrintTableS(list) - } + base.PrintList(list) }, } diff --git a/cmd/eip.go b/cmd/eip.go index 07c73f84b7..51ea2db4c1 100644 --- a/cmd/eip.go +++ b/cmd/eip.go @@ -108,11 +108,7 @@ func NewCmdEIPList() *cobra.Command { row.ExpirationTime = time.Unix(int64(eip.ExpireTime), 0).Format("2006-01-02") list = append(list, row) } - if global.json { - base.PrintJSON(list) - } else { - base.PrintTableS(list) - } + base.PrintList(list) }, } diff --git a/cmd/firewall.go b/cmd/firewall.go index 3a5359c0cf..1b7aade303 100644 --- a/cmd/firewall.go +++ b/cmd/firewall.go @@ -94,11 +94,7 @@ func NewCmdFirewallList() *cobra.Command { } list = append(list, row) } - if global.json { - base.PrintJSON(list) - } else { - base.PrintTableS(list) - } + base.PrintList(list) }, } flags := cmd.Flags() @@ -493,11 +489,7 @@ func NewCmdFirewallResource() *cobra.Command { row.Remark = rs.Remark list = append(list, row) } - if global.json { - base.PrintJSON(list) - } else { - base.PrintTableS(list) - } + base.PrintList(list) }, } flags := cmd.Flags() diff --git a/cmd/globalssh.go b/cmd/globalssh.go index 755acf9c38..b5c04bc027 100644 --- a/cmd/globalssh.go +++ b/cmd/globalssh.go @@ -90,7 +90,7 @@ func NewCmdGsshList() *cobra.Command { } list = append(list, row) } - base.PrintList(list, global.json) + base.PrintList(list) } }, } diff --git a/cmd/image.go b/cmd/image.go index 07bdebc18c..d48d3fb03e 100644 --- a/cmd/image.go +++ b/cmd/image.go @@ -84,7 +84,7 @@ func NewCmdUImageList() *cobra.Command { list = append(list, row) } } - base.PrintList(list, global.json) + base.PrintList(list) }, } req.ProjectId = cmd.Flags().String("project-id", base.ConfigIns.ProjectID, "Optional. Assign project-id") diff --git a/cmd/mysql.go b/cmd/mysql.go new file mode 100644 index 0000000000..46745edb9b --- /dev/null +++ b/cmd/mysql.go @@ -0,0 +1,896 @@ +// Copyright © 2018 NAME HERE tony.li@ucloud.cn +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cmd + +import ( + "fmt" + "io" + "strconv" + "strings" + "time" + + "github.com/spf13/cobra" + + "github.com/ucloud/ucloud-sdk-go/services/udb" + sdk "github.com/ucloud/ucloud-sdk-go/ucloud" + + "github.com/ucloud/ucloud-cli/base" + "github.com/ucloud/ucloud-cli/model/status" +) + +var dbVersionList = []string{"mysql-5.1", "mysql-5.5", "mysql-5.6", "mysql-5.7", "percona-5.5", "percona-5.6", "percona-5.7", "mariadb-10.0"} +var dbDiskTypeList = []string{"normal", "sata_ssd", "pcie_ssd"} + +var poller = base.NewSpoller(describeUdbByID, base.Cxt.GetWriter()) + +//NewCmdMysql ucloud mysql +func NewCmdMysql() *cobra.Command { + cmd := &cobra.Command{ + Use: "mysql", + Short: "Manipulate MySQL on UCloud platform", + Long: "Manipulate MySQL on UCloud platform", + } + out := base.Cxt.GetWriter() + cmd.AddCommand(NewCmdMysqlDB(out)) + cmd.AddCommand(NewCmdUDBConf()) + cmd.AddCommand(NewCmdUDBBackup()) + cmd.AddCommand(NewCmdUDBLog()) + return cmd +} + +//NewCmdMysqlDB ucloud mysql db +func NewCmdMysqlDB(out io.Writer) *cobra.Command { + cmd := &cobra.Command{ + Use: "db", + Short: "Manange MySQL instances", + Long: "Manange MySQL instances", + } + + cmd.AddCommand(NewCmdUDBList()) + cmd.AddCommand(NewCmdMysqlCreate(out)) + cmd.AddCommand(NewCmdUDBDelete(out)) + cmd.AddCommand(NewCmdUDBStart(out)) + cmd.AddCommand(NewCmdUDBStop(out)) + cmd.AddCommand(NewCmdUDBRestart(out)) + cmd.AddCommand(NewCmdUDBResize(out)) + cmd.AddCommand(NewCmdUDBRestore(out)) + cmd.AddCommand(NewCmdUDBResetPassword(out)) + cmd.AddCommand(NewCmdUDBCreateSlave(out)) + cmd.AddCommand(NewCmdUDBPromoteSlave(out)) + // cmd.AddCommand(NewCmdUDBPromoteToHA(out)) + + return cmd +} + +//NewCmdMysqlCreate ucloud mysql create +func NewCmdMysqlCreate(out io.Writer) *cobra.Command { + var confID, diskType string + var backupID int + var async bool + req := base.BizClient.NewCreateUDBInstanceRequest() + cmd := &cobra.Command{ + Use: "create", + Short: "Create MySQL instance on UCloud platform", + Long: "Create MySQL instance on UCloud platform", + Run: func(c *cobra.Command, args []string) { + confID = base.PickResourceID(confID) + id, err := strconv.Atoi(confID) + if err != nil { + base.HandleError(err) + return + } + req.ParamGroupId = &id + if len(*req.Name) < 6 { + fmt.Fprintln(out, "Error, length of name shoud be larger than 5") + return + } + if *req.DiskSpace > 3000 || *req.DiskSpace < 20 { + fmt.Fprintln(out, "Error, disk-size-gb should be between 20 and 3000") + return + } + if *req.MemoryLimit < 1 || *req.MemoryLimit > 128 { + fmt.Fprintln(out, "Error, memory-size-gb should be between 1 and 128") + return + } + if backupID != -1 { + req.BackupId = &backupID + } + *req.MemoryLimit = *req.MemoryLimit * 1000 + switch diskType { + case "normal": + req.UseSSD = sdk.Bool(false) + case "sata_ssd": + req.UseSSD = sdk.Bool(true) + req.SSDType = sdk.String("SATA") + case "pcie_ssd": + req.UseSSD = sdk.Bool(true) + req.SSDType = sdk.String("PCI-E") + default: + if diskType != "" { + req.UseSSD = sdk.Bool(true) + req.SSDType = sdk.String(diskType) + } + } + resp, err := base.BizClient.CreateUDBInstance(req) + if err != nil { + base.HandleError(err) + return + } + text := fmt.Sprintf("udb[%s] is initializing", resp.DBId) + if async { + fmt.Fprintf(out, "udb[%s] is initializing\n", resp.DBId) + } else { + poller.Spoll(resp.DBId, text, []string{status.UDB_RUNNING, status.UDB_FAIL}) + } + }, + } + + flags := cmd.Flags() + flags.SortFlags = false + bindProjectID(req, flags) + bindRegion(req, flags) + bindZone(req, flags) + req.DBTypeId = flags.String("version", "", "Required. Version of udb instance") + req.Name = flags.String("name", "", "Required. Name of udb instance to create, at least 6 letters") + flags.StringVar(&confID, "conf-id", "", "Required. ConfID of configuration. see 'ucloud mysql conf list'") + req.AdminUser = flags.String("admin-user-name", "root", "Optional. Name of udb instance's administrator") + req.AdminPassword = flags.String("password", "", "Required. Password of udb instance's administrator") + flags.IntVar(&backupID, "backup-id", -1, "Optional. BackupID of the backup which the newly created UDB instance will recover from if specified. See 'ucloud mysql backup list'") + req.Port = flags.Int("port", 3306, "Optional. Port of udb instance") + flags.StringVar(&diskType, "disk-type", "", "Optional. Setting this flag means using SSD disk. Accept values: 'normal','sata_ssd','pcie_ssd'") + req.DiskSpace = flags.Int("disk-size-gb", 20, "Optional. Disk size of udb instance. From 20 to 3000 according to memory size. Unit GB") + req.MemoryLimit = flags.Int("memory-size-gb", 1, "Optional. Memory size of udb instance. From 1 to 128. Unit GB") + req.InstanceMode = flags.String("mode", "Normal", "Optional. Mode of udb instance. Normal or HA, HA means high-availability. Both the normal and high-availability versions can create master-slave synchronization for data redundancy and read/write separation. The high-availability version provides a dual-master hot standby architecture to avoid database unavailability due to downtime or hardware failure. One more thing. It does better job for master-slave synchronization and disaster recovery using the InnoDB engine") + req.VPCId = flags.String("vpc-id", "", "Optional. Resource ID of VPC which the UDB to create belong to. See 'ucloud vpc list'") + req.SubnetId = flags.String("subnet-id", "", "Optional. Resource ID of subnet that the UDB to create belong to. See 'ucloud subnet list'") + flags.BoolVar(&async, "async", false, "Optional. Do not wait for the long-running operation to finish.") + bindChargeType(req, flags) + bindQuantity(req, flags) + + flags.SetFlagValues("version", dbVersionList...) + flags.SetFlagValues("disk-type", dbDiskTypeList...) + flags.SetFlagValuesFunc("vpc-id", func() []string { + return getAllVPCIdNames(*req.ProjectId, *req.Region) + }) + flags.SetFlagValuesFunc("subnet-id", func() []string { + return getAllSubnetIDNames(*req.VPCId, *req.ProjectId, *req.Region) + }) + flags.SetFlagValuesFunc("conf-id", func() []string { + return getConfIDList(*req.DBTypeId, *req.ProjectId, *req.Region, *req.Zone) + }) + + cmd.MarkFlagRequired("version") + cmd.MarkFlagRequired("name") + cmd.MarkFlagRequired("password") + cmd.MarkFlagRequired("conf-id") + return cmd +} + +//UDBMysqlRow 表格行 +type UDBMysqlRow struct { + Name string + ResourceID string + Role string + Status string + Config string + Mode string + DiskType string + IP string + Group string + Zone string + VPC string + Subnet string + // CreateTime string +} + +//NewCmdUDBList ucloud udb list +func NewCmdUDBList() *cobra.Command { + req := base.BizClient.NewDescribeUDBInstanceRequest() + cmd := &cobra.Command{ + Use: "list", + Short: "List MySQL instances", + Long: "List MySQL instances", + Run: func(c *cobra.Command, args []string) { + if *req.DBId != "" { + *req.DBId = base.PickResourceID(*req.DBId) + } + resp, err := base.BizClient.DescribeUDBInstance(req) + if err != nil { + base.HandleError(err) + return + } + list := []UDBMysqlRow{} + for _, ins := range resp.DataSet { + row := UDBMysqlRow{} + row.Name = ins.Name + row.Zone = ins.Zone + row.Role = ins.Role + row.ResourceID = ins.DBId + row.Group = ins.Tag + row.VPC = ins.VPCId + row.Subnet = ins.SubnetId + row.IP = ins.VirtualIP + row.Mode = ins.InstanceMode + row.DiskType = ins.InstanceType + row.Status = ins.State + row.Config = fmt.Sprintf("%s|%dG|%dG", ins.DBTypeId, ins.MemoryLimit/1000, ins.DiskSpace) + list = append(list, row) + for _, slave := range ins.DataSet { + row := UDBMysqlRow{} + row.Name = slave.Name + row.Zone = slave.Zone + row.Role = fmt.Sprintf("\u2b91 %s", slave.Role) + row.ResourceID = slave.DBId + row.Group = slave.Tag + row.VPC = slave.VPCId + row.Subnet = slave.SubnetId + row.IP = slave.VirtualIP + row.Mode = slave.InstanceMode + row.DiskType = slave.InstanceType + row.Config = fmt.Sprintf("%s|%dG|%dG", slave.DBTypeId, slave.MemoryLimit/1000, slave.DiskSpace) + row.Status = slave.State + list = append(list, row) + } + } + base.PrintList(list) + }, + } + flags := cmd.Flags() + flags.SortFlags = false + + req.DBId = flags.String("udb-id", "", "Optional. List the specified mysql") + bindProjectID(req, flags) + bindRegion(req, flags) + bindZone(req, flags) + bindLimit(req, flags) + bindOffset(req, flags) + req.IncludeSlaves = flags.Bool("include-slaves", false, "Optional. When specifying the udb-id, whether to display its slaves together. Accept values:true, false") + req.ClassType = sdk.String("sql") + + flags.SetFlagValues("include-slaves", "true", "false") + flags.SetFlagValuesFunc("udb-id", func() []string { + return getUDBIDList(nil, "sql", *req.ProjectId, *req.Region, *req.Zone) + }) + + return cmd +} + +//NewCmdUDBDelete ucloud udb delete +func NewCmdUDBDelete(out io.Writer) *cobra.Command { + var idNames []string + var yes bool + req := base.BizClient.NewDeleteUDBInstanceRequest() + cmd := &cobra.Command{ + Use: "delete", + Short: "Delete MySQL instances by udb-id", + Long: "Delete MySQL instances by udb-id", + Run: func(c *cobra.Command, args []string) { + ok := base.Confirm(yes, "Are you sure you want to delete the udb(s)?") + if !ok { + return + } + for _, idname := range idNames { + id := base.PickResourceID(idname) + any, err := describeUdbByID(id) + if err != nil { + base.HandleError(err) + continue + } + req.DBId = &id + ins, ok := any.(*udb.UDBInstanceSet) + if ok && ins.State == status.UDB_RUNNING { + stopReq := base.BizClient.NewStopUDBInstanceRequest() + stopReq.ProjectId = req.ProjectId + stopReq.Region = req.Region + stopReq.Zone = req.Zone + stopReq.DBId = req.DBId + stopUdbIns(stopReq, false, out) + } + _, err = base.BizClient.DeleteUDBInstance(req) + if err != nil { + base.HandleError(err) + continue + } + fmt.Fprintf(out, "udb[%s] deleted\n", idname) + } + }, + } + flags := cmd.Flags() + flags.SortFlags = false + + flags.StringSliceVar(&idNames, "udb-id", nil, "Required. Resource ID of UDB instances to delete") + bindRegion(req, flags) + bindZone(req, flags) + bindProjectID(req, flags) + flags.BoolVarP(&yes, "yes", "y", false, "Optional. Do not prompt for confirmation.") + + cmd.MarkFlagRequired("udb-id") + flags.SetFlagValuesFunc("udb-id", func() []string { + return getUDBIDList(nil, "", *req.ProjectId, *req.Region, *req.Zone) + }) + return cmd +} + +//NewCmdUDBStop ucloud udb stop +func NewCmdUDBStop(out io.Writer) *cobra.Command { + var idNames []string + var async bool + req := base.BizClient.NewStopUDBInstanceRequest() + cmd := &cobra.Command{ + Use: "stop", + Short: "Stop MySQL instances by udb-id", + Long: "Stop MySQL instances by udb-id", + Run: func(c *cobra.Command, args []string) { + for _, idname := range idNames { + req.DBId = sdk.String(base.PickResourceID(idname)) + stopUdbIns(req, async, out) + } + }, + } + + flags := cmd.Flags() + flags.SortFlags = false + + flags.StringSliceVar(&idNames, "udb-id", nil, "Required. Resource ID of UDB instances to stop") + bindRegion(req, flags) + bindZone(req, flags) + bindProjectID(req, flags) + req.ForceToKill = flags.Bool("force", false, "Optional. Stop UDB instances by force or not") + flags.BoolVarP(&async, "async", "a", false, "Optional. Do not wait for the long-running operation to finish.") + + cmd.MarkFlagRequired("udb-id") + + flags.SetFlagValues("force", "true", "false") + flags.SetFlagValuesFunc("udb-id", func() []string { + return getUDBIDList([]string{status.UDB_RUNNING}, "", *req.ProjectId, *req.Region, *req.Zone) + }) + + return cmd +} + +//NewCmdUDBStart ucloud udb start +func NewCmdUDBStart(out io.Writer) *cobra.Command { + var async bool + var idNames []string + req := base.BizClient.NewStartUDBInstanceRequest() + cmd := &cobra.Command{ + Use: "start", + Short: "Start MySQL instances by udb-id", + Long: "Start MySQL instances by udb-id", + Run: func(c *cobra.Command, args []string) { + for _, idname := range idNames { + id := base.PickResourceID(idname) + req.DBId = &id + _, err := base.BizClient.StartUDBInstance(req) + if err != nil { + base.HandleError(err) + continue + } + if async { + fmt.Fprintf(out, "udb[%s] is starting\n", idname) + } else { + text := fmt.Sprintf("udb[%s] is starting", idname) + poller.Spoll(*req.DBId, text, []string{status.UDB_RUNNING, status.UDB_FAIL}) + } + } + }, + } + + flags := cmd.Flags() + flags.SortFlags = false + + flags.StringSliceVar(&idNames, "udb-id", nil, "Required. Resource ID of UDB instances to start") + bindRegion(req, flags) + bindZone(req, flags) + bindProjectID(req, flags) + flags.BoolVarP(&async, "async", "a", false, "Optional. Do not wait for the long-running operation to finish.") + + cmd.MarkFlagRequired("udb-id") + + flags.SetFlagValuesFunc("udb-id", func() []string { + return getUDBIDList([]string{status.UDB_SHUTOFF}, "", *req.ProjectId, *req.Region, *req.Zone) + }) + return cmd +} + +//NewCmdUDBRestart ucloud udb restart +func NewCmdUDBRestart(out io.Writer) *cobra.Command { + var async bool + var idNames []string + req := base.BizClient.NewRestartUDBInstanceRequest() + cmd := &cobra.Command{ + Use: "restart", + Short: "Restart MySQL instances by udb-id", + Long: "Restart MySQL instances by udb-id", + Run: func(c *cobra.Command, args []string) { + for _, idname := range idNames { + id := base.PickResourceID(idname) + req.DBId = &id + _, err := base.BizClient.RestartUDBInstance(req) + if err != nil { + base.HandleError(err) + continue + } + if async { + fmt.Fprintf(out, "udb[%s] is restarting\n", idname) + } else { + text := fmt.Sprintf("udb[%s] is restarting", idname) + poller.Spoll(*req.DBId, text, []string{status.UDB_RUNNING, status.UDB_FAIL}) + } + } + }, + } + + flags := cmd.Flags() + flags.SortFlags = false + + flags.StringSliceVar(&idNames, "udb-id", nil, "Required. Resource ID of UDB instances to restart") + bindRegion(req, flags) + bindZone(req, flags) + bindProjectID(req, flags) + flags.BoolVarP(&async, "async", "a", false, "Optional. Do not wait for the long-running operation to finish.") + + cmd.MarkFlagRequired("udb-id") + flags.SetFlagValuesFunc("udb-id", func() []string { + return getUDBIDList(nil, "", *req.ProjectId, *req.Region, *req.Zone) + }) + return cmd +} + +//NewCmdUDBResize ucloud udb resize +func NewCmdUDBResize(out io.Writer) *cobra.Command { + var diskTypes = []string{"normal", "sata_ssd", "pcie_ssd", "normal_volume", "sata_ssd_volume", "pcie_ssd_volume"} + var async, yes bool + var idNames []string + var memory, disk int + var diskType string + req := base.BizClient.NewResizeUDBInstanceRequest() + cmd := &cobra.Command{ + Use: "resize", + Short: "Reszie MySQL instances, such as memory size, disk size and disk type", + Long: "Reszie MySQL instances, such as memory size, disk size and disk type", + Run: func(c *cobra.Command, args []string) { + if diskType != "" { + switch diskType { + case "normal": + req.InstanceType = sdk.String("Normal") + case "sata_ssd": + req.InstanceType = sdk.String("SATA_SSD") + case "pcie_ssd": + req.InstanceType = sdk.String("PCIE_SSD") + case "normal_volume": + req.InstanceType = sdk.String("Normal_Volume") + case "sata_ssd_volume": + req.InstanceType = sdk.String("SATA_SSD_Volume") + case "pcie_ssd_volume": + req.InstanceType = sdk.String("PCIE_SSD_Volume") + default: + req.InstanceType = &diskType + } + } + + for _, idname := range idNames { + id := base.PickResourceID(idname) + req.DBId = &id + any, err := describeUdbByID(id) + if err != nil { + base.HandleError(err) + continue + } + + ins, ok := any.(*udb.UDBInstanceSet) + if !ok { + continue + } + + if memory != 0 { + req.MemoryLimit = sdk.Int(memory * 1000) + } else { + req.MemoryLimit = &ins.MemoryLimit + } + if disk != 0 { + req.DiskSpace = &disk + } else { + req.DiskSpace = &ins.DiskSpace + } + + if ins.State == status.UDB_RUNNING { + ok := base.Confirm(yes, fmt.Sprintf("Need to shut down udb[%s] before upgrading, whether to continue?", idname)) + if !ok { + continue + } + stopReq := base.BizClient.NewStopUDBInstanceRequest() + stopReq.ProjectId = req.ProjectId + stopReq.Region = req.Region + stopReq.Zone = req.Zone + stopReq.DBId = req.DBId + stopUdbIns(stopReq, false, out) + } + _, err = base.BizClient.ResizeUDBInstance(req) + if err != nil { + base.HandleError(err) + continue + } + if async { + fmt.Fprintf(out, "udb[%s] is resizing\n", idname) + } else { + text := fmt.Sprintf("udb[%s] is resizing", idname) + poller.Spoll(*req.DBId, text, []string{status.UDB_RUNNING, status.UDB_SHUTOFF, status.UDB_FAIL, status.UDB_UPGRADE_FAIL}) + } + } + }, + } + + flags := cmd.Flags() + flags.SortFlags = false + + flags.StringSliceVar(&idNames, "udb-id", nil, "Required. Resource ID of UDB instances to restart") + bindRegion(req, flags) + bindZone(req, flags) + bindProjectID(req, flags) + flags.IntVar(&memory, "memory-size-gb", 0, "Optional. Memory size of udb instance. From 1 to 128. Unit GB") + flags.IntVar(&disk, "disk-size-gb", 0, "Optional. Disk size of udb instance. From 20 to 3000 according to memory size. Unit GB. Step 10GB") + flags.StringVar(&diskType, "disk-type", "", fmt.Sprintf("Optional. Disk type of udb instance. Accept values:%s", strings.Join(diskTypes, ", "))) + req.StartAfterUpgrade = flags.Bool("start-after-upgrade", true, "Optional. Automatic start the UDB instances after upgrade") + flags.BoolVarP(&async, "async", "a", false, "Optional. Do not wait for the long-running operation to finish") + flags.BoolVarP(&yes, "yes", "y", false, "Optional. Do not prompt for confirmation") + + flags.SetFlagValues("disk-type", diskTypes...) + flags.SetFlagValuesFunc("udb-id", func() []string { + return getUDBIDList(nil, "", *req.ProjectId, *req.Region, *req.Zone) + }) + + cmd.MarkFlagRequired("udb-id") + + return cmd +} + +//NewCmdUDBResetPassword ucloud udb reset-password +func NewCmdUDBResetPassword(out io.Writer) *cobra.Command { + var idNames []string + req := base.BizClient.NewModifyUDBInstancePasswordRequest() + cmd := &cobra.Command{ + Use: "reset-password", + Short: "Reset password of MySQL instances", + Long: "Reset password of MySQL instances", + Run: func(c *cobra.Command, args []string) { + for _, idname := range idNames { + id := base.PickResourceID(idname) + req.DBId = &id + _, err := base.BizClient.ModifyUDBInstancePassword(req) + if err != nil { + base.HandleError(err) + continue + } + fmt.Fprintf(out, "udb[%s]'s password modified\n", idname) + } + }, + } + + flags := cmd.Flags() + flags.SortFlags = false + + flags.StringSliceVar(&idNames, "udb-id", nil, "Required. Resource ID of UDB instances to reset password") + req.Password = flags.String("password", "", "Required. New password") + bindProjectID(req, flags) + bindRegion(req, flags) + bindZone(req, flags) + + cmd.MarkFlagRequired("udb-id") + cmd.MarkFlagRequired("password") + + flags.SetFlagValuesFunc("udb-id", func() []string { + return getUDBIDList(nil, "", *req.ProjectId, *req.Region, *req.Zone) + }) + + return cmd +} + +//NewCmdUDBRestore ucloud udb restore +func NewCmdUDBRestore(out io.Writer) *cobra.Command { + var datetime, diskType string + var async bool + req := base.BizClient.NewCreateUDBInstanceByRecoveryRequest() + cmd := &cobra.Command{ + Use: "restore", + Short: "Create MySQL instance and restore the newly created db to the specified DB at a specified point in time", + Long: "Create MySQL instance and restore the newly created db to the specified DB at a specified point in time", + Run: func(c *cobra.Command, args []string) { + t, err := time.Parse(time.RFC3339, datetime) + if err != nil { + base.HandleError(err) + return + } + req.RecoveryTime = sdk.Int(int(t.Unix())) + req.SrcDBId = sdk.String(base.PickResourceID(*req.SrcDBId)) + if diskType == "" { + any, err := describeUdbByID(*req.SrcDBId) + if err != nil { + base.HandleError(err) + return + } + ins, ok := any.(*udb.UDBInstanceSet) + if !ok { + fmt.Fprintln(out, fmt.Sprintf("fetch udb[%s] instance", *req.SrcDBId)) + } + req.UseSSD = &ins.UseSSD + } else if diskType == "normal" { + req.UseSSD = sdk.Bool(false) + } else if diskType == "ssd" { + req.UseSSD = sdk.Bool(true) + } + resp, err := base.BizClient.CreateUDBInstanceByRecovery(req) + if async { + fmt.Fprintf(out, "udb[%s] is restorting from udb[%s] at time point %s", resp.DBId, *req.SrcDBId, datetime) + } else { + text := fmt.Sprintf("udb[%s] is restorting from udb[%s] at time point %s", resp.DBId, *req.SrcDBId, datetime) + poller.Spoll(resp.DBId, text, []string{status.UDB_RUNNING, status.UDB_RECOVER_FAIL, status.UDB_FAIL}) + } + }, + } + flags := cmd.Flags() + flags.SortFlags = false + + req.Name = flags.String("name", "", "Required. Name of UDB instance to create") + req.SrcDBId = flags.String("src-udb-id", "", "Required. Resource ID of source UDB") + flags.StringVar(&datetime, "restore-to-time", "", "Required. The date and time to restore the DB to. Value must be a time in Universal Coordinated Time (UTC) format.Example: 2019-02-23T23:45:00Z") + bindRegion(req, flags) + bindZone(req, flags) + bindProjectID(req, flags) + flags.StringVar(&diskType, "disk-type", "", "Optional. Disk type. The default is to be consistent with the source database. Accept values: normal, ssd") + bindChargeType(req, flags) + bindQuantity(req, flags) + flags.BoolVarP(&async, "async", "a", false, "Optional. Do not wait for the long-running operation to finish") + + cmd.MarkFlagRequired("name") + cmd.MarkFlagRequired("src-udb-id") + cmd.MarkFlagRequired("restore-to-time") + + flags.SetFlagValues("disk-type", "noraml", "ssd") + flags.SetFlagValuesFunc("src-udb-id", func() []string { + return getUDBIDList(nil, "sql", *req.ProjectId, *req.Region, *req.Zone) + }) + + return cmd +} + +//NewCmdUDBCreateSlave ucloud udb create-slave +func NewCmdUDBCreateSlave(out io.Writer) *cobra.Command { + var diskType string + var async bool + req := base.BizClient.NewCreateUDBSlaveRequest() + cmd := &cobra.Command{ + Use: "create-slave", + Short: "Create slave database", + Long: "Create slave database", + Run: func(c *cobra.Command, args []string) { + *req.SrcId = base.PickResourceID(*req.SrcId) + switch diskType { + case "normal": + req.UseSSD = sdk.Bool(false) + case "sata_ssd": + req.UseSSD = sdk.Bool(true) + req.SSDType = sdk.String("SATA") + case "pcie_ssd": + req.UseSSD = sdk.Bool(true) + req.SSDType = sdk.String("PCI-E") + } + *req.MemoryLimit *= 1000 + resp, err := base.BizClient.CreateUDBSlave(req) + if err != nil { + base.HandleError(err) + return + } + if async { + fmt.Fprintf(out, "udb[%s] is initializing\n", resp.DBId) + } else { + poller.Spoll(resp.DBId, fmt.Sprintf("udb[%s] is initializing", resp.DBId), []string{status.UDB_RUNNING, status.UDB_FAIL}) + } + }, + } + flags := cmd.Flags() + flags.SortFlags = false + + req.SrcId = flags.String("master-udb-id", "", "Required. Resource ID of master UDB instance") + req.Name = flags.String("name", "", "Required. Name of the slave DB to create") + req.Port = flags.Int("port", 3306, "Optional. Port of the slave db service") + bindRegion(req, flags) + bindZone(req, flags) + bindProjectID(req, flags) + flags.StringVar(&diskType, "disk-type", "Normal", fmt.Sprintf("Optional. Setting this flag means using SSD disk. Accept values: %s", strings.Join(dbDiskTypeList, ", "))) + req.MemoryLimit = flags.Int("memory-size-gb", 1, "Optional. Memory size of udb instance. From 1 to 128. Unit GB") + flags.BoolVar(&async, "async", false, "Optional. Do not wait for the long-running operation to finish") + req.IsLock = flags.Bool("is-lock", false, "Optional. Lock master DB or not") + + cmd.MarkFlagRequired("master-udb-id") + cmd.MarkFlagRequired("name") + + flags.SetFlagValues("disk-type", dbDiskTypeList...) + flags.SetFlagValuesFunc("master-udb-id", func() []string { + return getUDBIDList(nil, "", *req.ProjectId, *req.Region, *req.Zone) + }) + return cmd +} + +//NewCmdUDBPromoteSlave ucloud udb promote-slave +func NewCmdUDBPromoteSlave(out io.Writer) *cobra.Command { + var ids []string + req := base.BizClient.NewPromoteUDBSlaveRequest() + cmd := &cobra.Command{ + Use: "promote-slave", + Short: "Promote slave db to master", + Long: "Promote slave db to master", + Run: func(c *cobra.Command, args []string) { + for _, id := range ids { + req.DBId = sdk.String(id) + _, err := base.BizClient.PromoteUDBSlave(req) + if err != nil { + base.HandleError(err) + return + } + fmt.Fprintf(out, "udb[%s] was promoted\n", *req.DBId) + } + }, + } + + flags := cmd.Flags() + flags.SortFlags = false + + flags.StringSliceVar(&ids, "udb-id", nil, "Required. Resource ID of slave db to promote") + req.IsForce = flags.Bool("is-force", false, "Optional. Force to promote slave db or not. If the slave db falls behind, the force promote may lose some data") + bindRegion(req, flags) + bindZone(req, flags) + bindProjectID(req, flags) + + cmd.MarkFlagRequired("udb-id") + + return cmd +} + +//NewCmdUDBPromoteToHA ucloud udb promote-to-ha 低频操作 暂不开放 +func NewCmdUDBPromoteToHA(out io.Writer) *cobra.Command { + var idNames []string + req := base.BizClient.NewPromoteUDBInstanceToHARequest() + cmd := &cobra.Command{ + Use: "promote-to-ha", + Short: "Promote db of normal mode to high availability db. ", + Long: "Promote db of normal mode to high availability db", + Run: func(c *cobra.Command, args []string) { + for _, idname := range idNames { + id := base.PickResourceID(idname) + req.DBId = &id + _, err := base.BizClient.PromoteUDBInstanceToHA(req) + if err != nil { + base.HandleError(err) + continue + } + poller.Spoll(id, fmt.Sprintf("udb[%s] is synchronizing data", id), []string{status.UDB_TOBE_SWITCH, status.UDB_FAIL}) + any, err := describeUdbByID(id) + if err != nil { + fmt.Fprintf(out, "udb[%s] promoted failed, please contact technical support; %v\n", idname, err) + continue + } + ins, ok := any.(*udb.UDBInstanceSet) + if !ok { + fmt.Fprintf(out, "udb[%s] promoted failed, please contact technical support. \n", idname) + continue + } + if ins.State != status.UDB_TOBE_SWITCH { + fmt.Fprintf(out, "udb[%s] promoted failed, please contact technical support. udb[%s]'s status:%s\n", idname, idname, ins.State) + continue + } + switchReq := base.BizClient.NewSwitchUDBInstanceToHARequest() + switchReq.DBId = &id + switchReq.Region = req.Region + switchReq.ProjectId = req.ProjectId + switchReq.ChargeType = &ins.ChargeType + switchReq.Quantity = sdk.String("0") + switchReq.Zone = &base.ConfigIns.Zone + switchResp, err := base.BizClient.SwitchUDBInstanceToHA(switchReq) + if err != nil { + fmt.Fprintf(out, "udb[%s] promoted failed, please contact technical support; %v\n", idname, err) + continue + } + poller.Spoll(switchResp.DBId, fmt.Sprintf("udb[%s] is switching to high availability mode", switchResp.DBId), []string{status.UDB_RUNNING, status.UDB_FAIL}) + } + }, + } + flags := cmd.Flags() + flags.SortFlags = false + + bindRegion(req, flags) + bindProjectID(req, flags) + flags.StringSliceVar(&idNames, "udb-id", nil, "Required. Resource ID of UDB instances to be promoted as high availability mode") + + cmd.MarkFlagRequired("udb-id") + flags.SetFlagValuesFunc("udb-id", func() []string { + return getUDBIDList(nil, "", *req.ProjectId, *req.Region, "") + }) + return cmd +} + +func stopUdbIns(req *udb.StopUDBInstanceRequest, async bool, out io.Writer) { + _, err := base.BizClient.StopUDBInstance(req) + if err != nil { + base.HandleError(err) + return + } + text := fmt.Sprintf("udb[%s] is stopping", *req.DBId) + if async { + fmt.Fprintln(out, text) + } else { + poller.Spoll(*req.DBId, text, []string{status.UDB_SHUTOFF, status.UDB_FAIL}) + } +} + +func getUDBIDList(states []string, dbType, project, region, zone string) []string { + udbs, err := getUDBList(states, dbType, project, region, zone) + if err != nil { + return nil + } + list := []string{} + for _, db := range udbs { + list = append(list, fmt.Sprintf("%s/%s", db.DBId, db.Name)) + } + return list +} + +func getUDBList(states []string, dbType, project, region, zone string) ([]udb.UDBInstanceSet, error) { + req := base.BizClient.NewDescribeUDBInstanceRequest() + if dbType == "" { + dbType = "sql" + } + req.ClassType = &dbType + req.ProjectId = &project + req.Region = ®ion + req.Zone = &zone + list := []udb.UDBInstanceSet{} + for offset, limit := 0, 50; ; offset += limit { + req.Offset = sdk.Int(offset) + req.Limit = sdk.Int(limit) + resp, err := base.BizClient.DescribeUDBInstance(req) + if err != nil { + return nil, err + } + for _, ins := range resp.DataSet { + if states != nil { + for _, s := range states { + if s == ins.State { + list = append(list, ins) + } + } + } else { + list = append(list, resp.DataSet...) + } + } + if offset+limit >= resp.TotalCount { + break + } + } + return list, nil +} + +func describeUdbByID(udbID string) (interface{}, error) { + req := base.BizClient.NewDescribeUDBInstanceRequest() + req.DBId = sdk.String(udbID) + resp, err := base.BizClient.DescribeUDBInstance(req) + if err != nil { + return nil, err + } + if len(resp.DataSet) < 1 { + return nil, fmt.Errorf("udb[%s] may not exist", udbID) + } + return &resp.DataSet[0], nil +} diff --git a/cmd/project.go b/cmd/project.go index 93f837bc3e..3eea71dbbf 100644 --- a/cmd/project.go +++ b/cmd/project.go @@ -141,7 +141,7 @@ func listProject() error { if resp.RetCode != 0 { return base.HandleBizError(resp) } - if global.json { + if global.JSON { base.PrintJSON(resp.ProjectSet) } else { base.PrintTable(resp.ProjectSet, []string{"ProjectId", "ProjectName"}) diff --git a/cmd/region.go b/cmd/region.go index ef6124dcc0..e27dbb4cd4 100644 --- a/cmd/region.go +++ b/cmd/region.go @@ -44,11 +44,7 @@ func NewCmdRegion() *cobra.Command { for region, zones := range regionMap { regionList = append(regionList, RegionTable{region, strings.Join(zones, ", ")}) } - if global.json { - base.PrintJSON(regionList) - } else { - base.PrintTableS(regionList) - } + base.PrintList(regionList) }, } return cmd diff --git a/cmd/root.go b/cmd/root.go index 88bcd6a548..0c7d479ae2 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -18,23 +18,14 @@ import ( "fmt" "os" - "github.com/Sirupsen/logrus" "github.com/spf13/cobra" + "github.com/ucloud/ucloud-sdk-go/ucloud/log" + "github.com/ucloud/ucloud-cli/base" ) -//GlobalFlag 几乎所有接口都需要的参数,例如 region zone projectID -type GlobalFlag struct { - debug bool - json bool - version bool - completion bool - config bool - signup bool -} - -var global GlobalFlag +var global = base.Global //NewCmdRoot 创建rootCmd rootCmd represents the base command when called without any subcommands func NewCmdRoot() *cobra.Command { @@ -45,13 +36,13 @@ func NewCmdRoot() *cobra.Command { Long: `UCloud CLI - manage UCloud resources and developer workflow`, BashCompletionFunction: "__ucloud_init_completion", Run: func(cmd *cobra.Command, args []string) { - if global.version { + if global.Version { base.Cxt.Printf("ucloud cli %s\n", base.Version) - } else if global.completion { + } else if global.Completion { NewCmdCompletion().Run(cmd, args) - } else if global.config { - base.ListAggConfig(global.json) - } else if global.signup { + } else if global.Config { + base.ListAggConfig(global.JSON) + } else if global.Signup { NewCmdSignup().Run(cmd, args) } else { cmd.HelpFunc()(cmd, args) @@ -59,12 +50,12 @@ func NewCmdRoot() *cobra.Command { }, } - cmd.PersistentFlags().BoolVarP(&global.debug, "debug", "d", false, "Running in debug mode") - cmd.PersistentFlags().BoolVarP(&global.json, "json", "j", false, "Print result in JSON format whenever possible") - cmd.Flags().BoolVarP(&global.version, "version", "v", false, "Display version") - cmd.Flags().BoolVar(&global.completion, "completion", false, "Turn on auto completion according to the prompt") - cmd.Flags().BoolVar(&global.config, "config", false, "Display configuration") - cmd.Flags().BoolVar(&global.signup, "signup", false, "Launch UCloud sign up page in browser") + cmd.PersistentFlags().BoolVarP(&global.Debug, "debug", "d", false, "Running in debug mode") + cmd.PersistentFlags().BoolVarP(&global.JSON, "json", "j", false, "Print result in JSON format whenever possible") + cmd.Flags().BoolVarP(&global.Version, "version", "v", false, "Display version") + cmd.Flags().BoolVar(&global.Completion, "completion", false, "Turn on auto completion according to the prompt") + cmd.Flags().BoolVar(&global.Config, "config", false, "Display configuration") + cmd.Flags().BoolVar(&global.Signup, "signup", false, "Launch UCloud sign up page in browser") cmd.AddCommand(NewCmdInit()) cmd.AddCommand(NewCmdConfig()) @@ -81,6 +72,7 @@ func NewCmdRoot() *cobra.Command { cmd.AddCommand(NewCmdBandwidth()) cmd.AddCommand(NewCmdUDPN(out)) cmd.AddCommand(NewCmdULB()) + cmd.AddCommand(NewCmdMysql()) return cmd } @@ -132,8 +124,6 @@ func Execute() { rootCmd.SetUsageTemplate(usageTmpl) resetHelpFunc(rootCmd) - // err := doc.GenReSTTree(rootCmd, "./doc") - // fmt.Println(err) if err := rootCmd.Execute(); err != nil { os.Exit(1) } @@ -170,8 +160,8 @@ func initialize(cmd *cobra.Command) { base.ClientConfig.Zone = zone } - if global.debug { - logrus.SetLevel(logrus.DebugLevel) + if global.Debug { + log.SetLevel(log.DebugLevel) } userInfo, err := base.LoadUserInfo() diff --git a/cmd/udb.go b/cmd/udb.go new file mode 100644 index 0000000000..9e91adafd4 --- /dev/null +++ b/cmd/udb.go @@ -0,0 +1,640 @@ +// Copyright © 2018 NAME HERE tony.li@ucloud.cn +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cmd + +import ( + "bufio" + "encoding/base64" + "fmt" + "io" + "os" + "strconv" + "strings" + + "github.com/spf13/cobra" + + "github.com/ucloud/ucloud-sdk-go/services/udb" + sdk "github.com/ucloud/ucloud-sdk-go/ucloud" + + "github.com/ucloud/ucloud-cli/base" + "github.com/ucloud/ucloud-cli/model/status" +) + +//NewCmdUDBConf ucloud udb conf +func NewCmdUDBConf() *cobra.Command { + cmd := &cobra.Command{ + Use: "conf", + Short: "List and manipulate configuration files of MySQL instances", + Long: "List and manipulate configuration files of MySQL instances", + } + out := base.Cxt.GetWriter() + cmd.AddCommand(NewCmdUDBConfList()) + cmd.AddCommand(NewCmdUDBConfDescribe(out)) + cmd.AddCommand(NewCmdUDBConfClone(out)) + cmd.AddCommand(NewCmdUDBConfUpload(out)) + cmd.AddCommand(NewCmdUDBConfUpdate(out)) + cmd.AddCommand(NewCmdUDBConfDelete(out)) + cmd.AddCommand(NewCmdUDBConfApply(out)) + cmd.AddCommand(NewCmdUDBConfDownload(out)) + return cmd +} + +//UDBConfRow 表格行 +type UDBConfRow struct { + ConfID int + DBVersion string + Name string + Description string + Modifiable bool + Zone string +} + +var dbTypeMap = map[string]string{ + "mysql": "sql", + "mongodb": "nosql", + "postgresql": "postgresql", + "sqlserver": "sqlserver", +} + +var dbTypeList = []string{"mysql", "mongodb", "postgresql", "sqlserver"} + +//NewCmdUDBConfList ucloud mysql conf list +func NewCmdUDBConfList() *cobra.Command { + req := base.BizClient.NewDescribeUDBParamGroupRequest() + cmd := &cobra.Command{ + Use: "list", + Short: "List configuartion files of MySQL instances", + Long: "List configuartion files of MySQL instances", + Run: func(c *cobra.Command, args []string) { + if *req.GroupId == 0 { + req.GroupId = nil + } + resp, err := base.BizClient.DescribeUDBParamGroup(req) + if err != nil { + base.HandleError(err) + return + } + list := []UDBConfRow{} + for _, ins := range resp.DataSet { + row := UDBConfRow{ + ConfID: ins.GroupId, + Name: ins.GroupName, + Zone: ins.Zone, + DBVersion: ins.DBTypeId, + Description: ins.Description, + Modifiable: ins.Modifiable, + } + list = append(list, row) + } + base.PrintList(list) + }, + } + + flags := cmd.Flags() + flags.SortFlags = false + + bindRegion(req, flags) + bindZone(req, flags) + bindProjectID(req, flags) + bindOffset(req, flags) + bindLimit(req, flags) + req.GroupId = flags.Int("conf-id", 0, "Optional. Configuration identifier for the configuration to be described") + req.ClassType = sdk.String("sql") + + flags.SetFlagValuesFunc("conf-id", func() []string { + return getConfIDList(*req.ClassType, *req.ProjectId, *req.Region, *req.Zone) + }) + + return cmd +} + +//UDBConfParamRow 参数配置展示表格行 +type UDBConfParamRow struct { + Key string + Value string +} + +//NewCmdUDBConfDescribe ucloud udb conf describe +func NewCmdUDBConfDescribe(out io.Writer) *cobra.Command { + var confID string + req := base.BizClient.NewDescribeUDBParamGroupRequest() + req.RegionFlag = sdk.Bool(false) + cmd := &cobra.Command{ + Use: "describe", + Short: "Display details about a configuration file of MySQL instance", + Long: "Display details about a configuration file of MySQL instance", + Run: func(c *cobra.Command, args []string) { + id, err := strconv.Atoi(base.PickResourceID(confID)) + if err != nil { + base.HandleError(err) + return + } + req.GroupId = &id + resp, err := base.BizClient.DescribeUDBParamGroup(req) + if err != nil { + base.HandleError(err) + return + } + if len(resp.DataSet) != 1 { + fmt.Fprintf(out, "Error, conf-id[%d] may not be exist\n", req.GroupId) + return + } + conf := resp.DataSet[0] + attrs := []base.DescribeTableRow{ + base.DescribeTableRow{Attribute: "ConfID", Content: strconv.Itoa(conf.GroupId)}, + base.DescribeTableRow{Attribute: "DBVersion", Content: conf.DBTypeId}, + base.DescribeTableRow{Attribute: "Name", Content: conf.GroupName}, + base.DescribeTableRow{Attribute: "Description", Content: conf.Description}, + base.DescribeTableRow{Attribute: "Modifiable", Content: strconv.FormatBool(conf.Modifiable)}, + base.DescribeTableRow{Attribute: "Zone", Content: conf.Zone}, + } + fmt.Fprintln(out, "Attributes:") + base.PrintList(attrs) + + params := []UDBConfParamRow{} + for _, p := range conf.ParamMember { + if p.Value == "" { + continue + } + row := UDBConfParamRow{ + Key: p.Key, + Value: p.Value, + } + params = append(params, row) + } + fmt.Fprintln(out, "\nParameters:") + base.PrintList(params) + + }, + } + flags := cmd.Flags() + flags.SortFlags = false + + flags.StringVar(&confID, "conf-id", "", "Requried. Configuration identifier for the configuration to be described") + bindRegion(req, flags) + bindZone(req, flags) + bindProjectID(req, flags) + + cmd.MarkFlagRequired("conf-id") + flags.SetFlagValuesFunc("conf-id", func() []string { + return getConfIDList("sql", *req.ProjectId, *req.Region, *req.Zone) + }) + + return cmd +} + +//NewCmdUDBConfClone ucloud udb conf clone +func NewCmdUDBConfClone(out io.Writer) *cobra.Command { + var srcConfID string + req := base.BizClient.NewCreateUDBParamGroupRequest() + cmd := &cobra.Command{ + Use: "clone", + Short: "Create configuration file by cloning existed configuration", + Long: "Create configuration file by cloning existed configuration", + Run: func(c *cobra.Command, args []string) { + id, err := strconv.Atoi(base.PickResourceID(srcConfID)) + if err != nil { + base.HandleError(err) + return + } + if *req.DBTypeId == "" { + confIns, err := getConfByID(id, *req.ProjectId, *req.Region, *req.Zone) + if err != nil { + base.HandleError(err) + return + } + req.DBTypeId = sdk.String(confIns.DBTypeId) + } + req.SrcGroupId = &id + resp, err := base.BizClient.CreateUDBParamGroup(req) + if err != nil { + base.HandleError(err) + return + } + fmt.Fprintf(out, "conf[%d] created\n", resp.GroupId) + }, + } + + flags := cmd.Flags() + flags.SortFlags = false + + req.DBTypeId = flags.String("db-version", "", fmt.Sprintf("Required. Version of DB. Accept values:%s", strings.Join(dbVersionList, ", "))) + req.GroupName = flags.String("name", "", "Required. Name of configuration. It's length should be between 6 and 63") + req.Description = flags.String("description", " ", "Optional. Description of the configuration to clone") + bindRegion(req, flags) + bindZone(req, flags) + bindProjectID(req, flags) + flags.StringVar(&srcConfID, "src-conf-id", "", "Optional. The ConfID of source configuration which to be cloned from") + + flags.SetFlagValues("db-version", dbVersionList...) + flags.SetFlagValuesFunc("src-conf-id", func() []string { + return getConfIDList("sql", *req.ProjectId, *req.Region, *req.Zone) + }) + + cmd.MarkFlagRequired("name") + cmd.MarkFlagRequired("src-conf-id") + return cmd +} + +var udbSubtypeMap = map[string]int{ + "unknow": 0, + "Shardsvr-MMAPv1": 1, + "Shardsvr-WiredTiger": 2, + "Configsvr-MMAPv1": 3, + "Configsvr-WiredTiger": 4, + "Mongos": 5, + "Mysql": 10, + "Postgresql": 20, +} + +var subtypeList = []string{"Shardsvr-MMAPv1", "Shardsvr-WiredTiger", "Configsvr-MMAPv1", "Configsvr-WiredTiger", "Mongos", "Mysql", "Postgresql"} + +//NewCmdUDBConfUpload ucloud udb conf upload +func NewCmdUDBConfUpload(out io.Writer) *cobra.Command { + var file string + req := base.BizClient.NewUploadUDBParamGroupRequest() + cmd := &cobra.Command{ + Use: "upload", + Short: "Create configuration file by uploading local DB configuration file", + Long: "Create configuration file by uploading local DB configuration file", + Run: func(c *cobra.Command, args []string) { + content, err := readFile(file) + if err != nil { + base.HandleError(err) + return + } + if l := len(*req.GroupName); l < 6 || l > 63 { + fmt.Fprintln(out, "Error, length of name shoud be between 6 and 63") + return + } + req.Content = sdk.String(base64.StdEncoding.EncodeToString([]byte(content))) + req.ParamGroupTypeId = sdk.Int(10) + resp, err := base.BizClient.UploadUDBParamGroup(req) + if err != nil { + base.HandleError(err) + return + } + fmt.Fprintf(out, "conf[%d] uploaded\n", resp.GroupId) + }, + } + flags := cmd.Flags() + flags.SortFlags = false + + flags.StringVar(&file, "conf-file", "", "Required. Path of local configuration file") + req.DBTypeId = flags.String("db-version", "", fmt.Sprintf("Required. Version of DB. Accept values:%s", strings.Join(dbVersionList, ", "))) + req.GroupName = flags.String("name", "", "Required. Name of configuration. It's length should be between 6 and 63") + req.Description = flags.String("description", " ", "Optional. Description of the configuration to clone") + // flags.StringVar(&subtype, "db-type", "", fmt.Sprintf("Optional. DB type. Accept values: %s", strings.Join(subtypeList, ", "))) + bindRegion(req, flags) + bindZone(req, flags) + bindProjectID(req, flags) + + cmd.MarkFlagRequired("conf-file") + cmd.MarkFlagRequired("name") + cmd.MarkFlagRequired("db-version") + // cmd.MarkFlagRequired("db-type") + + flags.SetFlagValues("db-version", dbVersionList...) + // flags.SetFlagValues("db-type", subtypeList...) + flags.SetFlagValuesFunc("conf-file", func() []string { + return base.GetFileList("") + }) + return cmd +} + +//NewCmdUDBConfUpdate ucloud udb conf update +func NewCmdUDBConfUpdate(out io.Writer) *cobra.Command { + var confID, key, value, file string + req := base.BizClient.NewUpdateUDBParamGroupRequest() + cmd := &cobra.Command{ + Use: "update", + Short: "Update parameters of DB's configuration", + Long: "Update parameters of DB's configuration", + Run: func(c *cobra.Command, args []string) { + id, err := strconv.Atoi(base.PickResourceID(confID)) + if err != nil { + base.HandleError(err) + return + } + req.GroupId = &id + + if key != "" && value != "" { + req.Key = &key + req.Value = &value + _, err := base.BizClient.UpdateUDBParamGroup(req) + if err != nil { + base.HandleError(err) + } else { + fmt.Printf("conf[%s]'sparameter[%s = %s] updated\n", confID, key, value) + } + } + if file != "" { + params, err := parseParam(file) + if err != nil { + base.HandleError(err) + return + } + for _, p := range params { + req.Key = sdk.String(p.Key) + req.Value = sdk.String(p.Value) + _, err := base.BizClient.UpdateUDBParamGroup(req) + if err != nil { + fmt.Printf("conf[%s]'sparameter[%s = %s] failed\n", confID, p.Key, p.Value) + base.HandleError(err) + } else { + fmt.Printf("conf[%s]'sparameter[%s = %s] updated\n", confID, p.Key, p.Value) + } + fmt.Println("") + } + } + }, + } + + flags := cmd.Flags() + flags.SortFlags = false + + bindRegion(req, flags) + bindZone(req, flags) + bindProjectID(req, flags) + + flags.StringVar(&confID, "conf-id", "", "Required. ConfID of configuration to update") + flags.StringVar(&key, "key", "", "Optional. Key of parameter") + flags.StringVar(&value, "value", "", "Optional. Value of parameter") + flags.StringVar(&file, "file", "", "Optional. Path of file in which each parameter occupies one line with format 'key = value'") + + flags.SetFlagValuesFunc("conf-id", func() []string { + return getModifiableConfIDList("", *req.ProjectId, *req.Region, *req.Zone) + }) + flags.SetFlagValuesFunc("file", func() []string { + return base.GetFileList("") + }) + + cmd.MarkFlagRequired("conf-id") + return cmd +} + +//NewCmdUDBConfDelete ucloud udb conf delete +func NewCmdUDBConfDelete(out io.Writer) *cobra.Command { + var confID string + req := base.BizClient.NewDeleteUDBParamGroupRequest() + cmd := &cobra.Command{ + Use: "delete", + Short: "Delete configuration of udb by conf-id", + Long: "Delete configuration of udb by conf-id", + Run: func(c *cobra.Command, args []string) { + id, err := strconv.Atoi(base.PickResourceID(confID)) + if err != nil { + base.HandleError(err) + return + } + req.GroupId = &id + _, err = base.BizClient.DeleteUDBParamGroup(req) + if err != nil { + base.HandleError(err) + return + } + fmt.Fprintf(out, "conf[%s] deleted\n", confID) + }, + } + flags := cmd.Flags() + flags.SortFlags = false + + flags.StringVar(&confID, "conf-id", "", "Required. ConfID of the configuration to delete") + bindRegion(req, flags) + bindZone(req, flags) + bindProjectID(req, flags) + + cmd.MarkFlagRequired("conf-id") + flags.SetFlagValuesFunc("conf-id", func() []string { + return getModifiableConfIDList("", *req.ProjectId, *req.Region, *req.Zone) + }) + return cmd +} + +// NewCmdUDBConfApply ucloud udb conf apply +func NewCmdUDBConfApply(out io.Writer) *cobra.Command { + var confID string + var udbIDs []string + var restart, yes, async bool + + req := base.BizClient.NewChangeUDBParamGroupRequest() + cmd := &cobra.Command{ + Use: "apply", + Short: "Apply configuration for UDB instances", + Long: "Apply configuration for UDB instances", + Run: func(c *cobra.Command, args []string) { + req.GroupId = sdk.String(base.PickResourceID(confID)) + for _, idname := range udbIDs { + req.DBId = sdk.String(base.PickResourceID(idname)) + _, err := base.BizClient.ChangeUDBParamGroup(req) + if err != nil { + base.HandleError(err) + continue + } + fmt.Fprintf(out, "conf[%s] has applied for udb[%s]\n", confID, idname) + if !restart { + continue + } + ok := base.Confirm(yes, fmt.Sprintf("udb[%s] is about to restart, do you want to continue?", idname)) + if !ok { + continue + } + restartReq := base.BizClient.NewRestartUDBInstanceRequest() + restartReq.Region = req.Region + restartReq.Zone = req.Zone + restartReq.ProjectId = req.ProjectId + restartReq.DBId = req.DBId + _, err = base.BizClient.RestartUDBInstance(restartReq) + if err != nil { + base.HandleError(err) + continue + } + if async { + fmt.Fprintf(out, "udb[%s] is restarting\n", idname) + } else { + text := fmt.Sprintf("udb[%s] is restarting", idname) + poller.Spoll(*req.DBId, text, []string{status.UDB_FAIL, status.UDB_RUNNING}) + } + } + }, + } + + flags := cmd.Flags() + flags.SortFlags = false + + flags.StringVar(&confID, "conf-id", "", "Required. ConfID of the configuration to be applied") + flags.StringSliceVar(&udbIDs, "udb-id", nil, "Required. Resource ID of UDB instances to change configuration") + flags.BoolVar(&restart, "restart-after-apply", true, "Optional. The new configuration will take effect after DB restarts") + flags.BoolVarP(&yes, "yes", "y", false, "Optional. Do not prompt for confirmation") + flags.BoolVarP(&async, "async", "a", false, "Optional. Do not wait for the long-running operation to finish.") + bindRegion(req, flags) + bindZone(req, flags) + bindProjectID(req, flags) + + cmd.MarkFlagRequired("conf-id") + cmd.MarkFlagRequired("udb-id") + + flags.SetFlagValuesFunc("conf-id", func() []string { + return getModifiableConfIDList("", *req.ProjectId, *req.Region, *req.Zone) + }) + flags.SetFlagValuesFunc("udb-id", func() []string { + return getUDBIDList(nil, "", *req.ProjectId, *req.Region, *req.Zone) + }) + + return cmd +} + +//NewCmdUDBConfDownload ucloud udb conf download +func NewCmdUDBConfDownload(out io.Writer) *cobra.Command { + var confID string + req := base.BizClient.NewExtractUDBParamGroupRequest() + cmd := &cobra.Command{ + Use: "download", + Short: "Download UDB configuration", + Long: "Download UDB configuration", + Run: func(c *cobra.Command, args []string) { + id, err := strconv.Atoi(base.PickResourceID(confID)) + if err != nil { + base.HandleError(err) + return + } + + req.GroupId = &id + resp, err := base.BizClient.ExtractUDBParamGroup(req) + if err != nil { + base.HandleError(err) + return + } + fmt.Fprint(out, resp.Content) + }, + } + + flags := cmd.Flags() + flags.SortFlags = false + + flags.StringVar(&confID, "conf-id", "", "Required. ConfID of configuration to download") + bindRegion(req, flags) + bindZone(req, flags) + bindProjectID(req, flags) + + cmd.MarkFlagRequired("conf-id") + + flags.SetFlagValuesFunc("conf-id", func() []string { + return getConfIDList("sql", *req.ProjectId, *req.Region, *req.Zone) + }) + + return cmd +} + +type confParam struct { + Key string + Value string +} + +func parseParam(filePath string) ([]confParam, error) { + file, err := os.Open(filePath) + if err != nil { + return nil, err + } + defer file.Close() + params := []confParam{} + scanner := bufio.NewScanner(file) + for scanner.Scan() { + line := scanner.Text() + line = strings.TrimSpace(line) + if len(line) == 0 { + continue + } + strs := strings.SplitN(line, "=", 2) + if len(strs) < 2 { + continue + } + param := confParam{ + Key: strings.TrimSpace(strs[0]), + Value: strings.TrimSpace(strs[1]), + } + params = append(params, param) + } + if err := scanner.Err(); err != nil { + return nil, err + } + return params, nil +} + +func getConfByID(confID int, project, region, zone string) (*udb.UDBParamGroupSet, error) { + req := base.BizClient.NewDescribeUDBParamGroupRequest() + req.ProjectId = &project + req.Region = ®ion + req.Zone = &zone + req.GroupId = &confID + resp, err := base.BizClient.DescribeUDBParamGroup(req) + if err != nil { + return nil, err + } + if len(resp.DataSet) != 1 { + return nil, fmt.Errorf("conf-id[%d] may not exist", *req.GroupId) + } + return &resp.DataSet[0], nil +} + +func getConfList(dbType, project, region, zone string) ([]udb.UDBParamGroupSet, error) { + req := base.BizClient.NewDescribeUDBParamGroupRequest() + req.ClassType = &dbType + req.ProjectId = &project + req.Region = ®ion + req.Zone = &zone + list := []udb.UDBParamGroupSet{} + for offset, limit := 0, 50; ; offset += limit { + req.Offset = sdk.Int(offset) + req.Limit = sdk.Int(limit) + resp, err := base.BizClient.DescribeUDBParamGroup(req) + if err != nil { + return nil, err + } + for _, conf := range resp.DataSet { + list = append(list, conf) + } + if resp.TotalCount <= offset+limit { + break + } + } + return list, nil +} + +func getModifiableConfIDList(dbType, project, region, zone string) []string { + confs, err := getConfList(dbType, project, region, zone) + if err != nil { + return nil + } + list := []string{} + for _, conf := range confs { + if conf.Modifiable == true { + list = append(list, fmt.Sprintf("%d/%s", conf.GroupId, conf.GroupName)) + } + } + return list +} + +func getConfIDList(dbType, project, region, zone string) []string { + confs, err := getConfList(dbType, project, region, zone) + if err != nil { + return nil + } + list := []string{} + for _, conf := range confs { + list = append(list, fmt.Sprintf("%d/%s", conf.GroupId, conf.GroupName)) + } + return list +} diff --git a/cmd/uhost.go b/cmd/uhost.go index fbc1d54a8b..749577886d 100644 --- a/cmd/uhost.go +++ b/cmd/uhost.go @@ -113,7 +113,7 @@ func NewCmdUHostList() *cobra.Command { row.Type = host.UHostType + "/" + host.HostType list = append(list, row) } - base.PrintList(list, global.json) + base.PrintList(list) }, } cmd.Flags().SortFlags = false @@ -230,8 +230,7 @@ func NewCmdUHostCreate(out io.Writer) *cobra.Command { req.Quantity = flags.Int("quantity", 1, "Optional. The duration of the instance. N years/months.") bindProjectID(req, flags) bindRegion(req, flags) - // bindZone(req, flags) - req.Zone = flags.String("zone", base.ConfigIns.Zone, "Optional. Override default available zone, see 'ucloud region'") + bindZone(req, flags) req.UHostType = flags.String("type", defaultUhostType, "Optional. Default is 'N2' of which cpu is V4 and sata disk. also support 'N1' means V3 cpu and sata disk;'I2' means V4 cpu and ssd disk;'D1' means big data model;'G1' means GPU type, model for K80;'G2' model for P40; 'G3' model for V100") req.NetCapability = flags.String("net-capability", "Normal", "Optional. Default is 'Normal', also support 'Super' which will enhance multiple times network capability as before") @@ -272,7 +271,7 @@ func NewCmdUHostCreate(out io.Writer) *cobra.Command { }) cmd.MarkFlagRequired("cpu") - cmd.MarkFlagRequired("memory") + cmd.MarkFlagRequired("memory-gb") cmd.MarkFlagRequired("password") cmd.MarkFlagRequired("image-id") @@ -347,7 +346,7 @@ func NewCmdUHostDelete(out io.Writer) *cobra.Command { cmd.Flags().SetFlagValues("release-eip", "true", "false") cmd.Flags().SetFlagValues("delete-cloud-disk", "true", "false") cmd.Flags().SetFlagValuesFunc("uhost-id", func() []string { - return getUhostList([]string{status.HOST_RUNNING, status.HOST_FAIL, status.HOST_FAIL}, *req.ProjectId, *req.Region, *req.Zone) + return getUhostList([]string{status.HOST_RUNNING, status.HOST_STOPPED, status.HOST_FAIL}, *req.ProjectId, *req.Region, *req.Zone) }) cmd.MarkFlagRequired("uhost-id") @@ -391,7 +390,7 @@ func stopUhostIns(req *uhost.StopUHostInstanceRequest, async bool, out io.Writer if err != nil { base.HandleError(err) } else { - text := fmt.Sprintf("uhost:[%v] is shutting down", resp.UhostId) + text := fmt.Sprintf("uhost[%v] is shutting down", resp.UhostId) if async { fmt.Fprintln(out, text) } else { diff --git a/cmd/ulb.go b/cmd/ulb.go index 684ad18ece..fb677d486c 100644 --- a/cmd/ulb.go +++ b/cmd/ulb.go @@ -95,7 +95,7 @@ func NewCmdULBList() *cobra.Command { list = append(list, row) } - base.PrintList(list, global.json) + base.PrintList(list) }, } @@ -417,7 +417,7 @@ func NewCmdULBVServerList(out io.Writer) *cobra.Command { row.HealthCheckPath = vs.Path list = append(list, row) } - base.PrintList(list, global.json) + base.PrintList(list) }, } @@ -721,7 +721,7 @@ func NewCmdULBVServerListNode(out io.Writer) *cobra.Command { } list = append(list, row) } - base.PrintList(list, global.json) + base.PrintList(list) }, } flags := cmd.Flags() @@ -1036,7 +1036,7 @@ func NewCmdULBVServerListPolicy(out io.Writer) *cobra.Command { row.Backends = strings.Join(nodes, ",") list = append(list, row) } - base.PrintList(list, global.json) + base.PrintList(list) } }, } @@ -1264,7 +1264,7 @@ func NewCmdSSLList() *cobra.Command { row.BindResource = strings.Join(targets, ",") rows = append(rows, row) } - base.PrintList(rows, global.json) + base.PrintList(rows) }, } flags := cmd.Flags() @@ -1335,7 +1335,7 @@ func NewCmdSSLDescribe(out io.Writer) *cobra.Command { Content: sslcf.SSLContent, }, } - base.PrintDescribe(rows, global.json) + base.PrintDescribe(rows, global.JSON) }, } flags := cmd.Flags() diff --git a/cmd/unet.go b/cmd/unet.go index a132fa40c1..92eb281006 100644 --- a/cmd/unet.go +++ b/cmd/unet.go @@ -133,11 +133,7 @@ func NewCmdUDPNList(out io.Writer) *cobra.Command { row.CreationTime = base.FormatDate(udpn.CreateTime) list = append(list, row) } - if global.json { - base.PrintJSON(list) - } else { - base.PrintTableS(list) - } + base.PrintList(list) }, } diff --git a/cmd/util.go b/cmd/util.go index d0dc06d577..ab9dde9c81 100644 --- a/cmd/util.go +++ b/cmd/util.go @@ -25,13 +25,21 @@ func bindRegionS(region *string, flags *pflag.FlagSet) { func bindZone(req request.Common, flags *pflag.FlagSet) { var zone string - flags.StringVar(&zone, "zone", base.ConfigIns.Zone, "Optional. Override default available zone, see 'ucloud region'") + flags.StringVar(&zone, "zone", base.ConfigIns.Zone, "Optional. Override default availability zone, see 'ucloud region'") flags.SetFlagValuesFunc("zone", func() []string { return getZoneList(req.GetRegion()) }) req.SetZoneRef(&zone) } +func bindZoneS(zone, region *string, flags *pflag.FlagSet) { + *zone = base.ConfigIns.Zone + flags.StringVar(zone, "zone", base.ConfigIns.Zone, "Optional. Override default availability zone, see 'ucloud region'") + flags.SetFlagValuesFunc("zone", func() []string { + return getZoneList(*region) + }) +} + func bindProjectID(req request.Common, flags *pflag.FlagSet) { var project string flags.StringVar(&project, "project-id", base.ConfigIns.ProjectID, "Optional. Override default project-id, see 'ucloud project list'") @@ -60,8 +68,23 @@ func bindLimit(req interface{}, flags *pflag.FlagSet) { } func bindOffset(req interface{}, flags *pflag.FlagSet) { - limit := flags.Int("offset", 0, "Optional. The index(a number) of resource which start to list") + offset := flags.Int("offset", 0, "Optional. The index(a number) of resource which start to list") v := reflect.ValueOf(req).Elem() - f := v.FieldByName("Limit") - f.Set(reflect.ValueOf(limit)) + f := v.FieldByName("Offset") + f.Set(reflect.ValueOf(offset)) +} + +func bindChargeType(req interface{}, flags *pflag.FlagSet) { + chargeType := flags.String("charge-type", "Month", "Optional. Enumeration value.'Year',pay yearly;'Month',pay monthly;'Dynamic', pay hourly(requires permission),'Trial', free trial(need permission)") + v := reflect.ValueOf(req).Elem() + f := v.FieldByName("ChargeType") + f.Set(reflect.ValueOf(chargeType)) + flags.SetFlagValues("charge-type", "Month", "Dynamic", "Year") +} + +func bindQuantity(req interface{}, flags *pflag.FlagSet) { + quanitiy := flags.Int("quantity", 1, "Optional. The duration of the instance. N years/months.") + v := reflect.ValueOf(req).Elem() + f := v.FieldByName("Quantity") + f.Set(reflect.ValueOf(quanitiy)) } diff --git a/cmd/vpc.go b/cmd/vpc.go index d2f4a6187b..9042f1bd8f 100644 --- a/cmd/vpc.go +++ b/cmd/vpc.go @@ -19,8 +19,8 @@ import ( func NewCmdVpc() *cobra.Command { cmd := &cobra.Command{ Use: "vpc", - Short: "List and manipulate vpc instances", - Long: "List and manipulate vpc instances", + Short: "List and manipulate VPC instances", + Long: "List and manipulate VPC instances", Args: cobra.NoArgs, } @@ -72,11 +72,7 @@ func NewCmdVPCList() *cobra.Command { row.CreationTime = base.FormatDate(vpc.CreateTime) list = append(list, row) } - if global.json { - base.PrintJSON(list) - } else { - base.PrintTableS(list) - } + base.PrintList(list) }, } flags := cmd.Flags() @@ -254,11 +250,7 @@ func NewCmdVpcListPeer() *cobra.Command { row.Group = VPCIntercom.Tag list = append(list, row) } - if global.json { - base.PrintJSON(list) - } else { - base.PrintTableS(list) - } + base.PrintList(list) }, } req.VPCId = cmd.Flags().String("vpc-id", "", "Required. The vpc id which you wnat to describe the information") @@ -391,11 +383,7 @@ func NewCmdSubnetList() *cobra.Command { row.CreationTime = base.FormatDate(sn.CreateTime) list = append(list, row) } - if global.json { - base.PrintJSON(list) - } else { - base.PrintTableS(list) - } + base.PrintList(list) }, } @@ -528,7 +516,7 @@ func NewCmdSubnetListResource(out io.Writer) *cobra.Command { } list = append(list, row) } - base.PrintList(list, global.json) + base.PrintList(list) }, } flags := cmd.Flags() diff --git a/model/status/status.go b/model/status/status.go index 8f48b862b5..f4516032a3 100644 --- a/model/status/status.go +++ b/model/status/status.go @@ -14,6 +14,15 @@ const DISK_AVAILABLE = "Available" const DISK_FAILED = "Failed" const DISK_RESTORING = "Restoring" +const UDB_INIT = "Init" +const UDB_FAIL = "Fail" +const UDB_RUNNING = "Running" +const UDB_SHUTOFF = "Shutoff" +const UDB_DELETE = "Delete" +const UDB_RECOVER_FAIL = "Recover fail" +const UDB_UPGRADE_FAIL = "UpgradeFail" +const UDB_TOBE_SWITCH = "WaitForSwitch" + const SNAPSHOT_NORMAL = "Normal" const EIP_FREE = "free" diff --git a/vendor/github.com/Sirupsen/logrus/CHANGELOG.md b/vendor/github.com/Sirupsen/logrus/CHANGELOG.md index 1bd1deb294..a7294193c8 100644 --- a/vendor/github.com/Sirupsen/logrus/CHANGELOG.md +++ b/vendor/github.com/Sirupsen/logrus/CHANGELOG.md @@ -1,3 +1,57 @@ +# 1.3.0 +This new release introduces: + * Log, Logf, Logln functions for Logger and Entry that take a Level + +Fixes: + * Building prometheus node_exporter on AIX (#840) + * Race condition in TextFormatter (#468) + * Travis CI import path (#868) + * Remove coloured output on Windows (#862) + * Pointer to func as field in JSONFormatter (#870) + * Properly marshal Levels (#873) + +# 1.2.0 +This new release introduces: + * A new method `SetReportCaller` in the `Logger` to enable the file, line and calling function from which the trace has been issued + * A new trace level named `Trace` whose level is below `Debug` + * A configurable exit function to be called upon a Fatal trace + * The `Level` object now implements `encoding.TextUnmarshaler` interface + +# 1.1.1 +This is a bug fix release. + * fix the build break on Solaris + * don't drop a whole trace in JSONFormatter when a field param is a function pointer which can not be serialized + +# 1.1.0 +This new release introduces: + * several fixes: + * a fix for a race condition on entry formatting + * proper cleanup of previously used entries before putting them back in the pool + * the extra new line at the end of message in text formatter has been removed + * a new global public API to check if a level is activated: IsLevelEnabled + * the following methods have been added to the Logger object + * IsLevelEnabled + * SetFormatter + * SetOutput + * ReplaceHooks + * introduction of go module + * an indent configuration for the json formatter + * output colour support for windows + * the field sort function is now configurable for text formatter + * the CLICOLOR and CLICOLOR\_FORCE environment variable support in text formater + +# 1.0.6 + +This new release introduces: + * a new api WithTime which allows to easily force the time of the log entry + which is mostly useful for logger wrapper + * a fix reverting the immutability of the entry given as parameter to the hooks + a new configuration field of the json formatter in order to put all the fields + in a nested dictionnary + * a new SetOutput method in the Logger + * a new configuration of the textformatter to configure the name of the default keys + * a new configuration of the text formatter to disable the level truncation + # 1.0.5 * Fix hooks race (#707) diff --git a/vendor/github.com/Sirupsen/logrus/README.md b/vendor/github.com/Sirupsen/logrus/README.md index 072e99be31..a4796eb07d 100644 --- a/vendor/github.com/Sirupsen/logrus/README.md +++ b/vendor/github.com/Sirupsen/logrus/README.md @@ -56,8 +56,39 @@ time="2015-03-26T01:27:38-04:00" level=warning msg="The group's number increased time="2015-03-26T01:27:38-04:00" level=debug msg="Temperature changes" temperature=-4 time="2015-03-26T01:27:38-04:00" level=panic msg="It's over 9000!" animal=orca size=9009 time="2015-03-26T01:27:38-04:00" level=fatal msg="The ice breaks!" err=&{0x2082280c0 map[animal:orca size:9009] 2015-03-26 01:27:38.441574009 -0400 EDT panic It's over 9000!} number=100 omg=true -exit status 1 ``` +To ensure this behaviour even if a TTY is attached, set your formatter as follows: + +```go + log.SetFormatter(&log.TextFormatter{ + DisableColors: true, + FullTimestamp: true, + }) +``` + +#### Logging Method Name + +If you wish to add the calling method as a field, instruct the logger via: +```go +log.SetReportCaller(true) +``` +This adds the caller as 'method' like so: + +```json +{"animal":"penguin","level":"fatal","method":"github.com/sirupsen/arcticcreatures.migrate","msg":"a penguin swims by", +"time":"2014-03-10 19:57:38.562543129 -0400 EDT"} +``` + +```text +time="2015-03-26T01:27:38-04:00" level=fatal method=github.com/sirupsen/arcticcreatures.migrate msg="a penguin swims by" animal=penguin +``` +Note that this does add measurable overhead - the cost will depend on the version of Go, but is +between 20 and 40% in recent tests with 1.6 and 1.7. You can validate this in your +environment via benchmarks: +``` +go test -bench=.*CallerTracing +``` + #### Case-sensitivity @@ -246,9 +277,10 @@ A list of currently known of service hook can be found in this wiki [page](https #### Level logging -Logrus has six logging levels: Debug, Info, Warning, Error, Fatal and Panic. +Logrus has seven logging levels: Trace, Debug, Info, Warning, Error, Fatal and Panic. ```go +log.Trace("Something very low level.") log.Debug("Useful debugging information.") log.Info("Something noteworthy happened!") log.Warn("You should probably take a look at this.") @@ -329,9 +361,11 @@ The built-in logging formatters are: Third party logging formatters: * [`FluentdFormatter`](https://github.com/joonix/log). Formats entries that can be parsed by Kubernetes and Google Container Engine. +* [`GELF`](https://github.com/fabienm/go-logrus-formatters). Formats entries so they comply to Graylog's [GELF 1.1 specification](http://docs.graylog.org/en/2.4/pages/gelf.html). * [`logstash`](https://github.com/bshuster-repo/logrus-logstash-hook). Logs fields as [Logstash](http://logstash.net) Events. * [`prefixed`](https://github.com/x-cray/logrus-prefixed-formatter). Displays log entry source along with alternative layout. * [`zalgo`](https://github.com/aybabtme/logzalgo). Invoking the P͉̫o̳̼̊w̖͈̰͎e̬͔̭͂r͚̼̹̲ ̫͓͉̳͈ō̠͕͖̚f̝͍̠ ͕̲̞͖͑Z̖̫̤̫ͪa͉̬͈̗l͖͎g̳̥o̰̥̅!̣͔̲̻͊̄ ̙̘̦̹̦. +* [`nested-logrus-formatter`](https://github.com/antonfisher/nested-logrus-formatter). Converts logrus fields to a nested structure. You can define your formatter by implementing the `Formatter` interface, requiring a `Format` method. `Format` takes an `*Entry`. `entry.Data` is a diff --git a/vendor/github.com/Sirupsen/logrus/alt_exit.go b/vendor/github.com/Sirupsen/logrus/alt_exit.go index 8af90637a9..8fd189e1cc 100644 --- a/vendor/github.com/Sirupsen/logrus/alt_exit.go +++ b/vendor/github.com/Sirupsen/logrus/alt_exit.go @@ -51,9 +51,9 @@ func Exit(code int) { os.Exit(code) } -// RegisterExitHandler adds a Logrus Exit handler, call logrus.Exit to invoke -// all handlers. The handlers will also be invoked when any Fatal log entry is -// made. +// RegisterExitHandler appends a Logrus Exit handler to the list of handlers, +// call logrus.Exit to invoke all handlers. The handlers will also be invoked when +// any Fatal log entry is made. // // This method is useful when a caller wishes to use logrus to log a fatal // message but also needs to gracefully shutdown. An example usecase could be @@ -62,3 +62,15 @@ func Exit(code int) { func RegisterExitHandler(handler func()) { handlers = append(handlers, handler) } + +// DeferExitHandler prepends a Logrus Exit handler to the list of handlers, +// call logrus.Exit to invoke all handlers. The handlers will also be invoked when +// any Fatal log entry is made. +// +// This method is useful when a caller wishes to use logrus to log a fatal +// message but also needs to gracefully shutdown. An example usecase could be +// closing database connections, or sending a alert that the application is +// closing. +func DeferExitHandler(handler func()) { + handlers = append([]func(){handler}, handlers...) +} diff --git a/vendor/github.com/Sirupsen/logrus/entry.go b/vendor/github.com/Sirupsen/logrus/entry.go index c2b2e493d8..fd377286c2 100644 --- a/vendor/github.com/Sirupsen/logrus/entry.go +++ b/vendor/github.com/Sirupsen/logrus/entry.go @@ -4,11 +4,30 @@ import ( "bytes" "fmt" "os" + "reflect" + "runtime" + "strings" "sync" "time" ) -var bufferPool *sync.Pool +var ( + bufferPool *sync.Pool + + // qualified package name, cached at first use + logrusPackage string + + // Positions in the call stack when tracing to report the calling method + minimumCallerDepth int + + // Used for caller information initialisation + callerInitOnce sync.Once +) + +const ( + maximumCallerDepth int = 25 + knownLogrusFrames int = 4 +) func init() { bufferPool = &sync.Pool{ @@ -16,15 +35,18 @@ func init() { return new(bytes.Buffer) }, } + + // start at the bottom of the stack before the package-name cache is primed + minimumCallerDepth = 1 } // Defines the key when adding errors using WithError. var ErrorKey = "error" // An entry is the final or intermediate Logrus logging entry. It contains all -// the fields passed with WithField{,s}. It's finally logged when Debug, Info, -// Warn, Error, Fatal or Panic is called on it. These objects can be reused and -// passed around as much as you wish to avoid field duplication. +// the fields passed with WithField{,s}. It's finally logged when Trace, Debug, +// Info, Warn, Error, Fatal or Panic is called on it. These objects can be +// reused and passed around as much as you wish to avoid field duplication. type Entry struct { Logger *Logger @@ -34,22 +56,28 @@ type Entry struct { // Time at which the log entry was created Time time.Time - // Level the log entry was logged at: Debug, Info, Warn, Error, Fatal or Panic + // Level the log entry was logged at: Trace, Debug, Info, Warn, Error, Fatal or Panic // This field will be set on entry firing and the value will be equal to the one in Logger struct field. Level Level - // Message passed to Debug, Info, Warn, Error, Fatal or Panic + // Calling method, with package name + Caller *runtime.Frame + + // Message passed to Trace, Debug, Info, Warn, Error, Fatal or Panic Message string - // When formatter is called in entry.log(), an Buffer may be set to entry + // When formatter is called in entry.log(), a Buffer may be set to entry Buffer *bytes.Buffer + + // err may contain a field formatting error + err string } func NewEntry(logger *Logger) *Entry { return &Entry{ Logger: logger, - // Default is five fields, give a little extra room - Data: make(Fields, 5), + // Default is three fields, plus one optional. Give a little extra room. + Data: make(Fields, 6), } } @@ -80,15 +108,85 @@ func (entry *Entry) WithFields(fields Fields) *Entry { for k, v := range entry.Data { data[k] = v } + fieldErr := entry.err for k, v := range fields { - data[k] = v + isErrField := false + if t := reflect.TypeOf(v); t != nil { + switch t.Kind() { + case reflect.Func: + isErrField = true + case reflect.Ptr: + isErrField = t.Elem().Kind() == reflect.Func + } + } + if isErrField { + tmp := fmt.Sprintf("can not add field %q", k) + if fieldErr != "" { + fieldErr = entry.err + ", " + tmp + } else { + fieldErr = tmp + } + } else { + data[k] = v + } } - return &Entry{Logger: entry.Logger, Data: data, Time: entry.Time} + return &Entry{Logger: entry.Logger, Data: data, Time: entry.Time, err: fieldErr} } // Overrides the time of the Entry. func (entry *Entry) WithTime(t time.Time) *Entry { - return &Entry{Logger: entry.Logger, Data: entry.Data, Time: t} + return &Entry{Logger: entry.Logger, Data: entry.Data, Time: t, err: entry.err} +} + +// getPackageName reduces a fully qualified function name to the package name +// There really ought to be to be a better way... +func getPackageName(f string) string { + for { + lastPeriod := strings.LastIndex(f, ".") + lastSlash := strings.LastIndex(f, "/") + if lastPeriod > lastSlash { + f = f[:lastPeriod] + } else { + break + } + } + + return f +} + +// getCaller retrieves the name of the first non-logrus calling function +func getCaller() *runtime.Frame { + // Restrict the lookback frames to avoid runaway lookups + pcs := make([]uintptr, maximumCallerDepth) + depth := runtime.Callers(minimumCallerDepth, pcs) + frames := runtime.CallersFrames(pcs[:depth]) + + // cache this package's fully-qualified name + callerInitOnce.Do(func() { + logrusPackage = getPackageName(runtime.FuncForPC(pcs[0]).Name()) + + // now that we have the cache, we can skip a minimum count of known-logrus functions + // XXX this is dubious, the number of frames may vary store an entry in a logger interface + minimumCallerDepth = knownLogrusFrames + }) + + for f, again := frames.Next(); again; f, again = frames.Next() { + pkg := getPackageName(f.Function) + + // If the caller isn't part of this package, we're done + if pkg != logrusPackage { + return &f + } + } + + // if we got here, we failed to find the caller's context + return nil +} + +func (entry Entry) HasCaller() (has bool) { + return entry.Logger != nil && + entry.Logger.ReportCaller && + entry.Caller != nil } // This function is not declared with a pointer value because otherwise @@ -107,6 +205,9 @@ func (entry Entry) log(level Level, msg string) { entry.Level = level entry.Message = msg + if entry.Logger.ReportCaller { + entry.Caller = getCaller() + } entry.fireHooks() @@ -150,26 +251,30 @@ func (entry *Entry) write() { } } -func (entry *Entry) Debug(args ...interface{}) { - if entry.Logger.level() >= DebugLevel { - entry.log(DebugLevel, fmt.Sprint(args...)) +func (entry *Entry) Log(level Level, args ...interface{}) { + if entry.Logger.IsLevelEnabled(level) { + entry.log(level, fmt.Sprint(args...)) } } +func (entry *Entry) Trace(args ...interface{}) { + entry.Log(TraceLevel, args...) +} + +func (entry *Entry) Debug(args ...interface{}) { + entry.Log(DebugLevel, args...) +} + func (entry *Entry) Print(args ...interface{}) { entry.Info(args...) } func (entry *Entry) Info(args ...interface{}) { - if entry.Logger.level() >= InfoLevel { - entry.log(InfoLevel, fmt.Sprint(args...)) - } + entry.Log(InfoLevel, args...) } func (entry *Entry) Warn(args ...interface{}) { - if entry.Logger.level() >= WarnLevel { - entry.log(WarnLevel, fmt.Sprint(args...)) - } + entry.Log(WarnLevel, args...) } func (entry *Entry) Warning(args ...interface{}) { @@ -177,37 +282,37 @@ func (entry *Entry) Warning(args ...interface{}) { } func (entry *Entry) Error(args ...interface{}) { - if entry.Logger.level() >= ErrorLevel { - entry.log(ErrorLevel, fmt.Sprint(args...)) - } + entry.Log(ErrorLevel, args...) } func (entry *Entry) Fatal(args ...interface{}) { - if entry.Logger.level() >= FatalLevel { - entry.log(FatalLevel, fmt.Sprint(args...)) - } - Exit(1) + entry.Log(FatalLevel, args...) + entry.Logger.Exit(1) } func (entry *Entry) Panic(args ...interface{}) { - if entry.Logger.level() >= PanicLevel { - entry.log(PanicLevel, fmt.Sprint(args...)) - } + entry.Log(PanicLevel, args...) panic(fmt.Sprint(args...)) } // Entry Printf family functions -func (entry *Entry) Debugf(format string, args ...interface{}) { - if entry.Logger.level() >= DebugLevel { - entry.Debug(fmt.Sprintf(format, args...)) +func (entry *Entry) Logf(level Level, format string, args ...interface{}) { + if entry.Logger.IsLevelEnabled(level) { + entry.Log(level, fmt.Sprintf(format, args...)) } } +func (entry *Entry) Tracef(format string, args ...interface{}) { + entry.Logf(TraceLevel, format, args...) +} + +func (entry *Entry) Debugf(format string, args ...interface{}) { + entry.Logf(DebugLevel, format, args...) +} + func (entry *Entry) Infof(format string, args ...interface{}) { - if entry.Logger.level() >= InfoLevel { - entry.Info(fmt.Sprintf(format, args...)) - } + entry.Logf(InfoLevel, format, args...) } func (entry *Entry) Printf(format string, args ...interface{}) { @@ -215,9 +320,7 @@ func (entry *Entry) Printf(format string, args ...interface{}) { } func (entry *Entry) Warnf(format string, args ...interface{}) { - if entry.Logger.level() >= WarnLevel { - entry.Warn(fmt.Sprintf(format, args...)) - } + entry.Logf(WarnLevel, format, args...) } func (entry *Entry) Warningf(format string, args ...interface{}) { @@ -225,36 +328,36 @@ func (entry *Entry) Warningf(format string, args ...interface{}) { } func (entry *Entry) Errorf(format string, args ...interface{}) { - if entry.Logger.level() >= ErrorLevel { - entry.Error(fmt.Sprintf(format, args...)) - } + entry.Logf(ErrorLevel, format, args...) } func (entry *Entry) Fatalf(format string, args ...interface{}) { - if entry.Logger.level() >= FatalLevel { - entry.Fatal(fmt.Sprintf(format, args...)) - } - Exit(1) + entry.Logf(FatalLevel, format, args...) + entry.Logger.Exit(1) } func (entry *Entry) Panicf(format string, args ...interface{}) { - if entry.Logger.level() >= PanicLevel { - entry.Panic(fmt.Sprintf(format, args...)) - } + entry.Logf(PanicLevel, format, args...) } // Entry Println family functions -func (entry *Entry) Debugln(args ...interface{}) { - if entry.Logger.level() >= DebugLevel { - entry.Debug(entry.sprintlnn(args...)) +func (entry *Entry) Logln(level Level, args ...interface{}) { + if entry.Logger.IsLevelEnabled(level) { + entry.Log(level, entry.sprintlnn(args...)) } } +func (entry *Entry) Traceln(args ...interface{}) { + entry.Logln(TraceLevel, args...) +} + +func (entry *Entry) Debugln(args ...interface{}) { + entry.Logln(DebugLevel, args...) +} + func (entry *Entry) Infoln(args ...interface{}) { - if entry.Logger.level() >= InfoLevel { - entry.Info(entry.sprintlnn(args...)) - } + entry.Logln(InfoLevel, args...) } func (entry *Entry) Println(args ...interface{}) { @@ -262,9 +365,7 @@ func (entry *Entry) Println(args ...interface{}) { } func (entry *Entry) Warnln(args ...interface{}) { - if entry.Logger.level() >= WarnLevel { - entry.Warn(entry.sprintlnn(args...)) - } + entry.Logln(WarnLevel, args...) } func (entry *Entry) Warningln(args ...interface{}) { @@ -272,22 +373,16 @@ func (entry *Entry) Warningln(args ...interface{}) { } func (entry *Entry) Errorln(args ...interface{}) { - if entry.Logger.level() >= ErrorLevel { - entry.Error(entry.sprintlnn(args...)) - } + entry.Logln(ErrorLevel, args...) } func (entry *Entry) Fatalln(args ...interface{}) { - if entry.Logger.level() >= FatalLevel { - entry.Fatal(entry.sprintlnn(args...)) - } - Exit(1) + entry.Logln(FatalLevel, args...) + entry.Logger.Exit(1) } func (entry *Entry) Panicln(args ...interface{}) { - if entry.Logger.level() >= PanicLevel { - entry.Panic(entry.sprintlnn(args...)) - } + entry.Logln(PanicLevel, args...) } // Sprintlnn => Sprint no newline. This is to get the behavior of how diff --git a/vendor/github.com/Sirupsen/logrus/exported.go b/vendor/github.com/Sirupsen/logrus/exported.go index eb612a6f3e..7342613c37 100644 --- a/vendor/github.com/Sirupsen/logrus/exported.go +++ b/vendor/github.com/Sirupsen/logrus/exported.go @@ -21,30 +21,33 @@ func SetOutput(out io.Writer) { // SetFormatter sets the standard logger formatter. func SetFormatter(formatter Formatter) { - std.mu.Lock() - defer std.mu.Unlock() - std.Formatter = formatter + std.SetFormatter(formatter) +} + +// SetReportCaller sets whether the standard logger will include the calling +// method as a field. +func SetReportCaller(include bool) { + std.SetReportCaller(include) } // SetLevel sets the standard logger level. func SetLevel(level Level) { - std.mu.Lock() - defer std.mu.Unlock() std.SetLevel(level) } // GetLevel returns the standard logger level. func GetLevel() Level { - std.mu.Lock() - defer std.mu.Unlock() - return std.level() + return std.GetLevel() +} + +// IsLevelEnabled checks if the log level of the standard logger is greater than the level param +func IsLevelEnabled(level Level) bool { + return std.IsLevelEnabled(level) } // AddHook adds a hook to the standard logger hooks. func AddHook(hook Hook) { - std.mu.Lock() - defer std.mu.Unlock() - std.Hooks.Add(hook) + std.AddHook(hook) } // WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key. @@ -80,6 +83,11 @@ func WithTime(t time.Time) *Entry { return std.WithTime(t) } +// Trace logs a message at level Trace on the standard logger. +func Trace(args ...interface{}) { + std.Trace(args...) +} + // Debug logs a message at level Debug on the standard logger. func Debug(args ...interface{}) { std.Debug(args...) @@ -120,6 +128,11 @@ func Fatal(args ...interface{}) { std.Fatal(args...) } +// Tracef logs a message at level Trace on the standard logger. +func Tracef(format string, args ...interface{}) { + std.Tracef(format, args...) +} + // Debugf logs a message at level Debug on the standard logger. func Debugf(format string, args ...interface{}) { std.Debugf(format, args...) @@ -160,6 +173,11 @@ func Fatalf(format string, args ...interface{}) { std.Fatalf(format, args...) } +// Traceln logs a message at level Trace on the standard logger. +func Traceln(args ...interface{}) { + std.Traceln(args...) +} + // Debugln logs a message at level Debug on the standard logger. func Debugln(args ...interface{}) { std.Debugln(args...) diff --git a/vendor/github.com/Sirupsen/logrus/formatter.go b/vendor/github.com/Sirupsen/logrus/formatter.go index 83c74947be..408883773e 100644 --- a/vendor/github.com/Sirupsen/logrus/formatter.go +++ b/vendor/github.com/Sirupsen/logrus/formatter.go @@ -2,7 +2,16 @@ package logrus import "time" -const defaultTimestampFormat = time.RFC3339 +// Default key names for the default fields +const ( + defaultTimestampFormat = time.RFC3339 + FieldKeyMsg = "msg" + FieldKeyLevel = "level" + FieldKeyTime = "time" + FieldKeyLogrusError = "logrus_error" + FieldKeyFunc = "func" + FieldKeyFile = "file" +) // The Formatter interface is used to implement a custom Formatter. It takes an // `Entry`. It exposes all the fields, including the default ones: @@ -18,7 +27,7 @@ type Formatter interface { Format(*Entry) ([]byte, error) } -// This is to not silently overwrite `time`, `msg` and `level` fields when +// This is to not silently overwrite `time`, `msg`, `func` and `level` fields when // dumping it. If this code wasn't there doing: // // logrus.WithField("level", 1).Info("hello") @@ -30,7 +39,7 @@ type Formatter interface { // // It's not exported because it's still using Data in an opinionated way. It's to // avoid code duplication between the two default formatters. -func prefixFieldClashes(data Fields, fieldMap FieldMap) { +func prefixFieldClashes(data Fields, fieldMap FieldMap, reportCaller bool) { timeKey := fieldMap.resolve(FieldKeyTime) if t, ok := data[timeKey]; ok { data["fields."+timeKey] = t @@ -48,4 +57,22 @@ func prefixFieldClashes(data Fields, fieldMap FieldMap) { data["fields."+levelKey] = l delete(data, levelKey) } + + logrusErrKey := fieldMap.resolve(FieldKeyLogrusError) + if l, ok := data[logrusErrKey]; ok { + data["fields."+logrusErrKey] = l + delete(data, logrusErrKey) + } + + // If reportCaller is not set, 'func' will not conflict. + if reportCaller { + funcKey := fieldMap.resolve(FieldKeyFunc) + if l, ok := data[funcKey]; ok { + data["fields."+funcKey] = l + } + fileKey := fieldMap.resolve(FieldKeyFile) + if l, ok := data[fileKey]; ok { + data["fields."+fileKey] = l + } + } } diff --git a/vendor/github.com/Sirupsen/logrus/go.mod b/vendor/github.com/Sirupsen/logrus/go.mod new file mode 100644 index 0000000000..94574cc635 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/go.mod @@ -0,0 +1,11 @@ +module github.com/sirupsen/logrus + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/konsorten/go-windows-terminal-sequences v1.0.1 + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stretchr/objx v0.1.1 // indirect + github.com/stretchr/testify v1.2.2 + golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 + golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 +) diff --git a/vendor/github.com/Sirupsen/logrus/go.sum b/vendor/github.com/Sirupsen/logrus/go.sum new file mode 100644 index 0000000000..133d34ae11 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/go.sum @@ -0,0 +1,15 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe h1:CHRGQ8V7OlCYtwaKPJi3iA7J+YdNKdo8j7nG5IgDhjs= +github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= diff --git a/vendor/github.com/Sirupsen/logrus/json_formatter.go b/vendor/github.com/Sirupsen/logrus/json_formatter.go index b13f0cda35..c494d073d4 100644 --- a/vendor/github.com/Sirupsen/logrus/json_formatter.go +++ b/vendor/github.com/Sirupsen/logrus/json_formatter.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "fmt" + "runtime" ) type fieldKey string @@ -11,13 +12,6 @@ type fieldKey string // FieldMap allows customization of the key names for default fields. type FieldMap map[fieldKey]string -// Default key names for the default fields -const ( - FieldKeyMsg = "msg" - FieldKeyLevel = "level" - FieldKeyTime = "time" -) - func (f FieldMap) resolve(key fieldKey) string { if k, ok := f[key]; ok { return k @@ -41,17 +35,27 @@ type JSONFormatter struct { // As an example: // formatter := &JSONFormatter{ // FieldMap: FieldMap{ - // FieldKeyTime: "@timestamp", + // FieldKeyTime: "@timestamp", // FieldKeyLevel: "@level", - // FieldKeyMsg: "@message", + // FieldKeyMsg: "@message", + // FieldKeyFunc: "@caller", // }, // } FieldMap FieldMap + + // CallerPrettyfier can be set by the user to modify the content + // of the function and file keys in the json data when ReportCaller is + // activated. If any of the returned value is the empty string the + // corresponding key will be removed from json fields. + CallerPrettyfier func(*runtime.Frame) (function string, file string) + + // PrettyPrint will indent all json logs + PrettyPrint bool } // Format renders a single log entry func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { - data := make(Fields, len(entry.Data)+3) + data := make(Fields, len(entry.Data)+4) for k, v := range entry.Data { switch v := v.(type) { case error: @@ -69,18 +73,35 @@ func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { data = newData } - prefixFieldClashes(data, f.FieldMap) + prefixFieldClashes(data, f.FieldMap, entry.HasCaller()) timestampFormat := f.TimestampFormat if timestampFormat == "" { timestampFormat = defaultTimestampFormat } + if entry.err != "" { + data[f.FieldMap.resolve(FieldKeyLogrusError)] = entry.err + } if !f.DisableTimestamp { data[f.FieldMap.resolve(FieldKeyTime)] = entry.Time.Format(timestampFormat) } data[f.FieldMap.resolve(FieldKeyMsg)] = entry.Message data[f.FieldMap.resolve(FieldKeyLevel)] = entry.Level.String() + if entry.HasCaller() { + funcVal := entry.Caller.Function + fileVal := fmt.Sprintf("%s:%d", entry.Caller.File, entry.Caller.Line) + if f.CallerPrettyfier != nil { + funcVal, fileVal = f.CallerPrettyfier(entry.Caller) + fmt.Println(funcVal, fileVal) + } + if funcVal != "" { + data[f.FieldMap.resolve(FieldKeyFunc)] = funcVal + } + if fileVal != "" { + data[f.FieldMap.resolve(FieldKeyFile)] = fileVal + } + } var b *bytes.Buffer if entry.Buffer != nil { @@ -88,9 +109,14 @@ func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { } else { b = &bytes.Buffer{} } - err := json.NewEncoder(b).Encode(data) - if err != nil { + + encoder := json.NewEncoder(b) + if f.PrettyPrint { + encoder.SetIndent("", " ") + } + if err := encoder.Encode(data); err != nil { return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) } + return b.Bytes(), nil } diff --git a/vendor/github.com/Sirupsen/logrus/logger.go b/vendor/github.com/Sirupsen/logrus/logger.go index 7fa8d7d92a..4b95ab1cf6 100644 --- a/vendor/github.com/Sirupsen/logrus/logger.go +++ b/vendor/github.com/Sirupsen/logrus/logger.go @@ -11,7 +11,7 @@ import ( type Logger struct { // The logs are `io.Copy`'d to this in a mutex. It's common to set this to a // file, or leave it default which is `os.Stderr`. You can also set this to - // something more adventorous, such as logging to Kafka. + // something more adventurous, such as logging to Kafka. Out io.Writer // Hooks for the logger instance. These allow firing events based on logging // levels and log entries. For example, to send errors to an error tracking @@ -24,6 +24,10 @@ type Logger struct { // own that implements the `Formatter` interface, see the `README` or included // formatters for examples. Formatter Formatter + + // Flag for whether to log caller info (off by default) + ReportCaller bool + // The logging level the logger should log at. This is typically (and defaults // to) `logrus.Info`, which allows Info(), Warn(), Error() and Fatal() to be // logged. @@ -32,8 +36,12 @@ type Logger struct { mu MutexWrap // Reusable empty entry entryPool sync.Pool + // Function to exit the application, defaults to `os.Exit()` + ExitFunc exitFunc } +type exitFunc func(int) + type MutexWrap struct { lock sync.Mutex disabled bool @@ -69,10 +77,12 @@ func (mw *MutexWrap) Disable() { // It's recommended to make this a global instance called `log`. func New() *Logger { return &Logger{ - Out: os.Stderr, - Formatter: new(TextFormatter), - Hooks: make(LevelHooks), - Level: InfoLevel, + Out: os.Stderr, + Formatter: new(TextFormatter), + Hooks: make(LevelHooks), + Level: InfoLevel, + ExitFunc: os.Exit, + ReportCaller: false, } } @@ -121,20 +131,24 @@ func (logger *Logger) WithTime(t time.Time) *Entry { return entry.WithTime(t) } -func (logger *Logger) Debugf(format string, args ...interface{}) { - if logger.level() >= DebugLevel { +func (logger *Logger) Logf(level Level, format string, args ...interface{}) { + if logger.IsLevelEnabled(level) { entry := logger.newEntry() - entry.Debugf(format, args...) + entry.Logf(level, format, args...) logger.releaseEntry(entry) } } +func (logger *Logger) Tracef(format string, args ...interface{}) { + logger.Logf(TraceLevel, format, args...) +} + +func (logger *Logger) Debugf(format string, args ...interface{}) { + logger.Logf(DebugLevel, format, args...) +} + func (logger *Logger) Infof(format string, args ...interface{}) { - if logger.level() >= InfoLevel { - entry := logger.newEntry() - entry.Infof(format, args...) - logger.releaseEntry(entry) - } + logger.Logf(InfoLevel, format, args...) } func (logger *Logger) Printf(format string, args ...interface{}) { @@ -144,123 +158,91 @@ func (logger *Logger) Printf(format string, args ...interface{}) { } func (logger *Logger) Warnf(format string, args ...interface{}) { - if logger.level() >= WarnLevel { - entry := logger.newEntry() - entry.Warnf(format, args...) - logger.releaseEntry(entry) - } + logger.Logf(WarnLevel, format, args...) } func (logger *Logger) Warningf(format string, args ...interface{}) { - if logger.level() >= WarnLevel { - entry := logger.newEntry() - entry.Warnf(format, args...) - logger.releaseEntry(entry) - } + logger.Warnf(format, args...) } func (logger *Logger) Errorf(format string, args ...interface{}) { - if logger.level() >= ErrorLevel { - entry := logger.newEntry() - entry.Errorf(format, args...) - logger.releaseEntry(entry) - } + logger.Logf(ErrorLevel, format, args...) } func (logger *Logger) Fatalf(format string, args ...interface{}) { - if logger.level() >= FatalLevel { - entry := logger.newEntry() - entry.Fatalf(format, args...) - logger.releaseEntry(entry) - } - Exit(1) + logger.Logf(FatalLevel, format, args...) + logger.Exit(1) } func (logger *Logger) Panicf(format string, args ...interface{}) { - if logger.level() >= PanicLevel { + logger.Logf(PanicLevel, format, args...) +} + +func (logger *Logger) Log(level Level, args ...interface{}) { + if logger.IsLevelEnabled(level) { entry := logger.newEntry() - entry.Panicf(format, args...) + entry.Log(level, args...) logger.releaseEntry(entry) } } +func (logger *Logger) Trace(args ...interface{}) { + logger.Log(TraceLevel, args...) +} + func (logger *Logger) Debug(args ...interface{}) { - if logger.level() >= DebugLevel { - entry := logger.newEntry() - entry.Debug(args...) - logger.releaseEntry(entry) - } + logger.Log(DebugLevel, args...) } func (logger *Logger) Info(args ...interface{}) { - if logger.level() >= InfoLevel { - entry := logger.newEntry() - entry.Info(args...) - logger.releaseEntry(entry) - } + logger.Log(InfoLevel, args...) } func (logger *Logger) Print(args ...interface{}) { entry := logger.newEntry() - entry.Info(args...) + entry.Print(args...) logger.releaseEntry(entry) } func (logger *Logger) Warn(args ...interface{}) { - if logger.level() >= WarnLevel { - entry := logger.newEntry() - entry.Warn(args...) - logger.releaseEntry(entry) - } + logger.Log(WarnLevel, args...) } func (logger *Logger) Warning(args ...interface{}) { - if logger.level() >= WarnLevel { - entry := logger.newEntry() - entry.Warn(args...) - logger.releaseEntry(entry) - } + logger.Warn(args...) } func (logger *Logger) Error(args ...interface{}) { - if logger.level() >= ErrorLevel { - entry := logger.newEntry() - entry.Error(args...) - logger.releaseEntry(entry) - } + logger.Log(ErrorLevel, args...) } func (logger *Logger) Fatal(args ...interface{}) { - if logger.level() >= FatalLevel { - entry := logger.newEntry() - entry.Fatal(args...) - logger.releaseEntry(entry) - } - Exit(1) + logger.Log(FatalLevel, args...) + logger.Exit(1) } func (logger *Logger) Panic(args ...interface{}) { - if logger.level() >= PanicLevel { + logger.Log(PanicLevel, args...) +} + +func (logger *Logger) Logln(level Level, args ...interface{}) { + if logger.IsLevelEnabled(level) { entry := logger.newEntry() - entry.Panic(args...) + entry.Logln(level, args...) logger.releaseEntry(entry) } } +func (logger *Logger) Traceln(args ...interface{}) { + logger.Logln(TraceLevel, args...) +} + func (logger *Logger) Debugln(args ...interface{}) { - if logger.level() >= DebugLevel { - entry := logger.newEntry() - entry.Debugln(args...) - logger.releaseEntry(entry) - } + logger.Logln(DebugLevel, args...) } func (logger *Logger) Infoln(args ...interface{}) { - if logger.level() >= InfoLevel { - entry := logger.newEntry() - entry.Infoln(args...) - logger.releaseEntry(entry) - } + logger.Logln(InfoLevel, args...) } func (logger *Logger) Println(args ...interface{}) { @@ -270,44 +252,32 @@ func (logger *Logger) Println(args ...interface{}) { } func (logger *Logger) Warnln(args ...interface{}) { - if logger.level() >= WarnLevel { - entry := logger.newEntry() - entry.Warnln(args...) - logger.releaseEntry(entry) - } + logger.Logln(WarnLevel, args...) } func (logger *Logger) Warningln(args ...interface{}) { - if logger.level() >= WarnLevel { - entry := logger.newEntry() - entry.Warnln(args...) - logger.releaseEntry(entry) - } + logger.Warnln(args...) } func (logger *Logger) Errorln(args ...interface{}) { - if logger.level() >= ErrorLevel { - entry := logger.newEntry() - entry.Errorln(args...) - logger.releaseEntry(entry) - } + logger.Logln(ErrorLevel, args...) } func (logger *Logger) Fatalln(args ...interface{}) { - if logger.level() >= FatalLevel { - entry := logger.newEntry() - entry.Fatalln(args...) - logger.releaseEntry(entry) - } - Exit(1) + logger.Logln(FatalLevel, args...) + logger.Exit(1) } func (logger *Logger) Panicln(args ...interface{}) { - if logger.level() >= PanicLevel { - entry := logger.newEntry() - entry.Panicln(args...) - logger.releaseEntry(entry) + logger.Logln(PanicLevel, args...) +} + +func (logger *Logger) Exit(code int) { + runHandlers() + if logger.ExitFunc == nil { + logger.ExitFunc = os.Exit } + logger.ExitFunc(code) } //When file is opened with appending mode, it's safe to @@ -321,18 +291,53 @@ func (logger *Logger) level() Level { return Level(atomic.LoadUint32((*uint32)(&logger.Level))) } +// SetLevel sets the logger level. func (logger *Logger) SetLevel(level Level) { atomic.StoreUint32((*uint32)(&logger.Level), uint32(level)) } -func (logger *Logger) SetOutput(out io.Writer) { - logger.mu.Lock() - defer logger.mu.Unlock() - logger.Out = out +// GetLevel returns the logger level. +func (logger *Logger) GetLevel() Level { + return logger.level() } +// AddHook adds a hook to the logger hooks. func (logger *Logger) AddHook(hook Hook) { logger.mu.Lock() defer logger.mu.Unlock() logger.Hooks.Add(hook) } + +// IsLevelEnabled checks if the log level of the logger is greater than the level param +func (logger *Logger) IsLevelEnabled(level Level) bool { + return logger.level() >= level +} + +// SetFormatter sets the logger formatter. +func (logger *Logger) SetFormatter(formatter Formatter) { + logger.mu.Lock() + defer logger.mu.Unlock() + logger.Formatter = formatter +} + +// SetOutput sets the logger output. +func (logger *Logger) SetOutput(output io.Writer) { + logger.mu.Lock() + defer logger.mu.Unlock() + logger.Out = output +} + +func (logger *Logger) SetReportCaller(reportCaller bool) { + logger.mu.Lock() + defer logger.mu.Unlock() + logger.ReportCaller = reportCaller +} + +// ReplaceHooks replaces the logger hooks and returns the old ones +func (logger *Logger) ReplaceHooks(hooks LevelHooks) LevelHooks { + logger.mu.Lock() + oldHooks := logger.Hooks + logger.Hooks = hooks + logger.mu.Unlock() + return oldHooks +} diff --git a/vendor/github.com/Sirupsen/logrus/logrus.go b/vendor/github.com/Sirupsen/logrus/logrus.go index dd38999741..8644761f73 100644 --- a/vendor/github.com/Sirupsen/logrus/logrus.go +++ b/vendor/github.com/Sirupsen/logrus/logrus.go @@ -14,22 +14,11 @@ type Level uint32 // Convert the Level to a string. E.g. PanicLevel becomes "panic". func (level Level) String() string { - switch level { - case DebugLevel: - return "debug" - case InfoLevel: - return "info" - case WarnLevel: - return "warning" - case ErrorLevel: - return "error" - case FatalLevel: - return "fatal" - case PanicLevel: - return "panic" + if b, err := level.MarshalText(); err == nil { + return string(b) + } else { + return "unknown" } - - return "unknown" } // ParseLevel takes a string level and returns the Logrus log level constant. @@ -47,12 +36,47 @@ func ParseLevel(lvl string) (Level, error) { return InfoLevel, nil case "debug": return DebugLevel, nil + case "trace": + return TraceLevel, nil } var l Level return l, fmt.Errorf("not a valid logrus Level: %q", lvl) } +// UnmarshalText implements encoding.TextUnmarshaler. +func (level *Level) UnmarshalText(text []byte) error { + l, err := ParseLevel(string(text)) + if err != nil { + return err + } + + *level = Level(l) + + return nil +} + +func (level Level) MarshalText() ([]byte, error) { + switch level { + case TraceLevel: + return []byte("trace"), nil + case DebugLevel: + return []byte("debug"), nil + case InfoLevel: + return []byte("info"), nil + case WarnLevel: + return []byte("warning"), nil + case ErrorLevel: + return []byte("error"), nil + case FatalLevel: + return []byte("fatal"), nil + case PanicLevel: + return []byte("panic"), nil + } + + return nil, fmt.Errorf("not a valid logrus level %d", level) +} + // A constant exposing all logging levels var AllLevels = []Level{ PanicLevel, @@ -61,6 +85,7 @@ var AllLevels = []Level{ WarnLevel, InfoLevel, DebugLevel, + TraceLevel, } // These are the different logging levels. You can set the logging level to log @@ -69,7 +94,7 @@ const ( // PanicLevel level, highest level of severity. Logs and then calls panic with the // message passed to Debug, Info, ... PanicLevel Level = iota - // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the + // FatalLevel level. Logs and then calls `logger.Exit(1)`. It will exit even if the // logging level is set to Panic. FatalLevel // ErrorLevel level. Logs. Used for errors that should definitely be noted. @@ -82,6 +107,8 @@ const ( InfoLevel // DebugLevel level. Usually only enabled when debugging. Very verbose logging. DebugLevel + // TraceLevel level. Designates finer-grained informational events than the Debug. + TraceLevel ) // Won't compile if StdLogger can't be realized by a log.Logger @@ -140,4 +167,20 @@ type FieldLogger interface { Errorln(args ...interface{}) Fatalln(args ...interface{}) Panicln(args ...interface{}) + + // IsDebugEnabled() bool + // IsInfoEnabled() bool + // IsWarnEnabled() bool + // IsErrorEnabled() bool + // IsFatalEnabled() bool + // IsPanicEnabled() bool +} + +// Ext1FieldLogger (the first extension to FieldLogger) is superfluous, it is +// here for consistancy. Do not use. Use Logger or Entry instead. +type Ext1FieldLogger interface { + FieldLogger + Tracef(format string, args ...interface{}) + Trace(args ...interface{}) + Traceln(args ...interface{}) } diff --git a/vendor/github.com/Sirupsen/logrus/terminal_bsd.go b/vendor/github.com/Sirupsen/logrus/terminal_bsd.go deleted file mode 100644 index 5b6212d24c..0000000000 --- a/vendor/github.com/Sirupsen/logrus/terminal_bsd.go +++ /dev/null @@ -1,10 +0,0 @@ -// +build darwin freebsd openbsd netbsd dragonfly -// +build !appengine,!js - -package logrus - -import "golang.org/x/sys/unix" - -const ioctlReadTermios = unix.TIOCGETA - -type Termios unix.Termios diff --git a/vendor/github.com/Sirupsen/logrus/terminal_check_aix.go b/vendor/github.com/Sirupsen/logrus/terminal_check_aix.go new file mode 100644 index 0000000000..04fdb7ba37 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/terminal_check_aix.go @@ -0,0 +1,9 @@ +// +build !appengine,!js,!windows,aix + +package logrus + +import "io" + +func checkIfTerminal(w io.Writer) bool { + return false +} diff --git a/vendor/github.com/Sirupsen/logrus/terminal_check_notappengine.go b/vendor/github.com/Sirupsen/logrus/terminal_check_notappengine.go index 87f0b8097f..d46556509e 100644 --- a/vendor/github.com/Sirupsen/logrus/terminal_check_notappengine.go +++ b/vendor/github.com/Sirupsen/logrus/terminal_check_notappengine.go @@ -1,4 +1,4 @@ -// +build !appengine,!js +// +build !appengine,!js,!windows,!aix package logrus diff --git a/vendor/github.com/Sirupsen/logrus/terminal_check_windows.go b/vendor/github.com/Sirupsen/logrus/terminal_check_windows.go new file mode 100644 index 0000000000..3b9d2864ca --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/terminal_check_windows.go @@ -0,0 +1,20 @@ +// +build !appengine,!js,windows + +package logrus + +import ( + "io" + "os" + "syscall" +) + +func checkIfTerminal(w io.Writer) bool { + switch v := w.(type) { + case *os.File: + var mode uint32 + err := syscall.GetConsoleMode(syscall.Handle(v.Fd()), &mode) + return err == nil + default: + return false + } +} diff --git a/vendor/github.com/Sirupsen/logrus/terminal_linux.go b/vendor/github.com/Sirupsen/logrus/terminal_linux.go deleted file mode 100644 index 634e39b301..0000000000 --- a/vendor/github.com/Sirupsen/logrus/terminal_linux.go +++ /dev/null @@ -1,14 +0,0 @@ -// Based on ssh/terminal: -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !appengine,!js - -package logrus - -import "golang.org/x/sys/unix" - -const ioctlReadTermios = unix.TCGETS - -type Termios unix.Termios diff --git a/vendor/github.com/Sirupsen/logrus/terminal_notwindows.go b/vendor/github.com/Sirupsen/logrus/terminal_notwindows.go new file mode 100644 index 0000000000..3dbd237203 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/terminal_notwindows.go @@ -0,0 +1,8 @@ +// +build !windows + +package logrus + +import "io" + +func initTerminal(w io.Writer) { +} diff --git a/vendor/github.com/Sirupsen/logrus/terminal_windows.go b/vendor/github.com/Sirupsen/logrus/terminal_windows.go new file mode 100644 index 0000000000..b4ef5286cd --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/terminal_windows.go @@ -0,0 +1,18 @@ +// +build !appengine,!js,windows + +package logrus + +import ( + "io" + "os" + "syscall" + + sequences "github.com/konsorten/go-windows-terminal-sequences" +) + +func initTerminal(w io.Writer) { + switch v := w.(type) { + case *os.File: + sequences.EnableVirtualTerminalProcessing(syscall.Handle(v.Fd()), true) + } +} diff --git a/vendor/github.com/Sirupsen/logrus/text_formatter.go b/vendor/github.com/Sirupsen/logrus/text_formatter.go index beb628f3a6..b3b1a30cab 100644 --- a/vendor/github.com/Sirupsen/logrus/text_formatter.go +++ b/vendor/github.com/Sirupsen/logrus/text_formatter.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "os" + "runtime" "sort" "strings" "sync" @@ -11,18 +12,13 @@ import ( ) const ( - nocolor = 0 - red = 31 - green = 32 - yellow = 33 - blue = 36 - gray = 37 + red = 31 + yellow = 33 + blue = 36 + gray = 37 ) -var ( - baseTimestamp time.Time - emptyFieldMap FieldMap -) +var baseTimestamp time.Time func init() { baseTimestamp = time.Now() @@ -55,6 +51,9 @@ type TextFormatter struct { // be desired. DisableSorting bool + // The keys sorting function, when uninitialized it uses sort.Strings. + SortingFunc func([]string) + // Disables the truncation of the level text to 4 characters. DisableLevelTruncation bool @@ -73,17 +72,27 @@ type TextFormatter struct { // FieldKeyMsg: "@message"}} FieldMap FieldMap - sync.Once + // CallerPrettyfier can be set by the user to modify the content + // of the function and file keys in the json data when ReportCaller is + // activated. If any of the returned value is the empty string the + // corresponding key will be removed from json fields. + CallerPrettyfier func(*runtime.Frame) (function string, file string) + + terminalInitOnce sync.Once } func (f *TextFormatter) init(entry *Entry) { if entry.Logger != nil { f.isTerminal = checkIfTerminal(entry.Logger.Out) + + if f.isTerminal { + initTerminal(entry.Logger.Out) + } } } func (f *TextFormatter) isColored() bool { - isColored := f.ForceColors || f.isTerminal + isColored := f.ForceColors || (f.isTerminal && (runtime.GOOS != "windows")) if f.EnvironmentOverrideColors { if force, ok := os.LookupEnv("CLICOLOR_FORCE"); ok && force != "0" { @@ -100,15 +109,54 @@ func (f *TextFormatter) isColored() bool { // Format renders a single log entry func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { - prefixFieldClashes(entry.Data, f.FieldMap) - - keys := make([]string, 0, len(entry.Data)) - for k := range entry.Data { + data := make(Fields) + for k, v := range entry.Data { + data[k] = v + } + prefixFieldClashes(data, f.FieldMap, entry.HasCaller()) + keys := make([]string, 0, len(data)) + for k := range data { keys = append(keys, k) } + var funcVal, fileVal string + + fixedKeys := make([]string, 0, 4+len(data)) + if !f.DisableTimestamp { + fixedKeys = append(fixedKeys, f.FieldMap.resolve(FieldKeyTime)) + } + fixedKeys = append(fixedKeys, f.FieldMap.resolve(FieldKeyLevel)) + if entry.Message != "" { + fixedKeys = append(fixedKeys, f.FieldMap.resolve(FieldKeyMsg)) + } + if entry.err != "" { + fixedKeys = append(fixedKeys, f.FieldMap.resolve(FieldKeyLogrusError)) + } + if entry.HasCaller() { + fixedKeys = append(fixedKeys, + f.FieldMap.resolve(FieldKeyFunc), f.FieldMap.resolve(FieldKeyFile)) + if f.CallerPrettyfier != nil { + funcVal, fileVal = f.CallerPrettyfier(entry.Caller) + } else { + funcVal = entry.Caller.Function + fileVal = fmt.Sprintf("%s:%d", entry.Caller.File, entry.Caller.Line) + } + } + if !f.DisableSorting { - sort.Strings(keys) + if f.SortingFunc == nil { + sort.Strings(keys) + fixedKeys = append(fixedKeys, keys...) + } else { + if !f.isColored() { + fixedKeys = append(fixedKeys, keys...) + f.SortingFunc(fixedKeys) + } else { + f.SortingFunc(keys) + } + } + } else { + fixedKeys = append(fixedKeys, keys...) } var b *bytes.Buffer @@ -118,24 +166,35 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { b = &bytes.Buffer{} } - f.Do(func() { f.init(entry) }) + f.terminalInitOnce.Do(func() { f.init(entry) }) timestampFormat := f.TimestampFormat if timestampFormat == "" { timestampFormat = defaultTimestampFormat } if f.isColored() { - f.printColored(b, entry, keys, timestampFormat) + f.printColored(b, entry, keys, data, timestampFormat) } else { - if !f.DisableTimestamp { - f.appendKeyValue(b, f.FieldMap.resolve(FieldKeyTime), entry.Time.Format(timestampFormat)) - } - f.appendKeyValue(b, f.FieldMap.resolve(FieldKeyLevel), entry.Level.String()) - if entry.Message != "" { - f.appendKeyValue(b, f.FieldMap.resolve(FieldKeyMsg), entry.Message) - } - for _, key := range keys { - f.appendKeyValue(b, key, entry.Data[key]) + + for _, key := range fixedKeys { + var value interface{} + switch { + case key == f.FieldMap.resolve(FieldKeyTime): + value = entry.Time.Format(timestampFormat) + case key == f.FieldMap.resolve(FieldKeyLevel): + value = entry.Level.String() + case key == f.FieldMap.resolve(FieldKeyMsg): + value = entry.Message + case key == f.FieldMap.resolve(FieldKeyLogrusError): + value = entry.err + case key == f.FieldMap.resolve(FieldKeyFunc) && entry.HasCaller(): + value = funcVal + case key == f.FieldMap.resolve(FieldKeyFile) && entry.HasCaller(): + value = fileVal + default: + value = data[key] + } + f.appendKeyValue(b, key, value) } } @@ -143,10 +202,10 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { return b.Bytes(), nil } -func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []string, timestampFormat string) { +func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []string, data Fields, timestampFormat string) { var levelColor int switch entry.Level { - case DebugLevel: + case DebugLevel, TraceLevel: levelColor = gray case WarnLevel: levelColor = yellow @@ -161,15 +220,31 @@ func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []strin levelText = levelText[0:4] } + // Remove a single newline if it already exists in the message to keep + // the behavior of logrus text_formatter the same as the stdlib log package + entry.Message = strings.TrimSuffix(entry.Message, "\n") + + caller := "" + + if entry.HasCaller() { + funcVal := fmt.Sprintf("%s()", entry.Caller.Function) + fileVal := fmt.Sprintf("%s:%d", entry.Caller.File, entry.Caller.Line) + + if f.CallerPrettyfier != nil { + funcVal, fileVal = f.CallerPrettyfier(entry.Caller) + } + caller = fileVal + " " + funcVal + } + if f.DisableTimestamp { - fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m %-44s ", levelColor, levelText, entry.Message) + fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m%s %-44s ", levelColor, levelText, caller, entry.Message) } else if !f.FullTimestamp { - fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d] %-44s ", levelColor, levelText, int(entry.Time.Sub(baseTimestamp)/time.Second), entry.Message) + fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d]%s %-44s ", levelColor, levelText, int(entry.Time.Sub(baseTimestamp)/time.Second), caller, entry.Message) } else { - fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s] %-44s ", levelColor, levelText, entry.Time.Format(timestampFormat), entry.Message) + fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s]%s %-44s ", levelColor, levelText, entry.Time.Format(timestampFormat), caller, entry.Message) } for _, k := range keys { - v := entry.Data[k] + v := data[k] fmt.Fprintf(b, " \x1b[%dm%s\x1b[0m=", levelColor, k) f.appendValue(b, v) } diff --git a/vendor/github.com/Sirupsen/logrus/writer.go b/vendor/github.com/Sirupsen/logrus/writer.go index 7bdebedc60..9e1f751359 100644 --- a/vendor/github.com/Sirupsen/logrus/writer.go +++ b/vendor/github.com/Sirupsen/logrus/writer.go @@ -24,6 +24,8 @@ func (entry *Entry) WriterLevel(level Level) *io.PipeWriter { var printFunc func(args ...interface{}) switch level { + case TraceLevel: + printFunc = entry.Trace case DebugLevel: printFunc = entry.Debug case InfoLevel: diff --git a/vendor/github.com/konsorten/go-windows-terminal-sequences/LICENSE b/vendor/github.com/konsorten/go-windows-terminal-sequences/LICENSE new file mode 100644 index 0000000000..14127cd831 --- /dev/null +++ b/vendor/github.com/konsorten/go-windows-terminal-sequences/LICENSE @@ -0,0 +1,9 @@ +(The MIT License) + +Copyright (c) 2017 marvin + konsorten GmbH (open-source@konsorten.de) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/konsorten/go-windows-terminal-sequences/README.md b/vendor/github.com/konsorten/go-windows-terminal-sequences/README.md new file mode 100644 index 0000000000..195333e51d --- /dev/null +++ b/vendor/github.com/konsorten/go-windows-terminal-sequences/README.md @@ -0,0 +1,41 @@ +# Windows Terminal Sequences + +This library allow for enabling Windows terminal color support for Go. + +See [Console Virtual Terminal Sequences](https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences) for details. + +## Usage + +```go +import ( + "syscall" + + sequences "github.com/konsorten/go-windows-terminal-sequences" +) + +func main() { + sequences.EnableVirtualTerminalProcessing(syscall.Stdout, true) +} + +``` + +## Authors + +The tool is sponsored by the [marvin + konsorten GmbH](http://www.konsorten.de). + +We thank all the authors who provided code to this library: + +* Felix Kollmann +* Nicolas Perraut + +## License + +(The MIT License) + +Copyright (c) 2018 marvin + konsorten GmbH (open-source@konsorten.de) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod b/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod new file mode 100644 index 0000000000..716c613125 --- /dev/null +++ b/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod @@ -0,0 +1 @@ +module github.com/konsorten/go-windows-terminal-sequences diff --git a/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences.go b/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences.go new file mode 100644 index 0000000000..ef18d8f978 --- /dev/null +++ b/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences.go @@ -0,0 +1,36 @@ +// +build windows + +package sequences + +import ( + "syscall" + "unsafe" +) + +var ( + kernel32Dll *syscall.LazyDLL = syscall.NewLazyDLL("Kernel32.dll") + setConsoleMode *syscall.LazyProc = kernel32Dll.NewProc("SetConsoleMode") +) + +func EnableVirtualTerminalProcessing(stream syscall.Handle, enable bool) error { + const ENABLE_VIRTUAL_TERMINAL_PROCESSING uint32 = 0x4 + + var mode uint32 + err := syscall.GetConsoleMode(syscall.Stdout, &mode) + if err != nil { + return err + } + + if enable { + mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING + } else { + mode &^= ENABLE_VIRTUAL_TERMINAL_PROCESSING + } + + ret, _, err := setConsoleMode.Call(uintptr(unsafe.Pointer(stream)), uintptr(mode)) + if ret == 0 { + return err + } + + return nil +} diff --git a/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences_dummy.go b/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences_dummy.go new file mode 100644 index 0000000000..df61a6f2f6 --- /dev/null +++ b/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences_dummy.go @@ -0,0 +1,11 @@ +// +build linux darwin + +package sequences + +import ( + "fmt" +) + +func EnableVirtualTerminalProcessing(stream uintptr, enable bool) error { + return fmt.Errorf("windows only package") +} diff --git a/vendor/github.com/spf13/cobra/doc/man_docs.go b/vendor/github.com/spf13/cobra/doc/man_docs.go deleted file mode 100644 index e5dbda2dad..0000000000 --- a/vendor/github.com/spf13/cobra/doc/man_docs.go +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright 2015 Red Hat Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package doc - -import ( - "bytes" - "fmt" - "io" - "os" - "path/filepath" - "sort" - "strings" - "time" - - "github.com/cpuguy83/go-md2man/md2man" - "github.com/spf13/cobra" - "github.com/spf13/pflag" -) - -// GenManTree will generate a man page for this command and all descendants -// in the directory given. The header may be nil. This function may not work -// correctly if your command names have `-` in them. If you have `cmd` with two -// subcmds, `sub` and `sub-third`, and `sub` has a subcommand called `third` -// it is undefined which help output will be in the file `cmd-sub-third.1`. -func GenManTree(cmd *cobra.Command, header *GenManHeader, dir string) error { - return GenManTreeFromOpts(cmd, GenManTreeOptions{ - Header: header, - Path: dir, - CommandSeparator: "-", - }) -} - -// GenManTreeFromOpts generates a man page for the command and all descendants. -// The pages are written to the opts.Path directory. -func GenManTreeFromOpts(cmd *cobra.Command, opts GenManTreeOptions) error { - header := opts.Header - if header == nil { - header = &GenManHeader{} - } - for _, c := range cmd.Commands() { - if !c.IsAvailableCommand() || c.IsAdditionalHelpTopicCommand() { - continue - } - if err := GenManTreeFromOpts(c, opts); err != nil { - return err - } - } - section := "1" - if header.Section != "" { - section = header.Section - } - - separator := "_" - if opts.CommandSeparator != "" { - separator = opts.CommandSeparator - } - basename := strings.Replace(cmd.CommandPath(), " ", separator, -1) - filename := filepath.Join(opts.Path, basename+"."+section) - f, err := os.Create(filename) - if err != nil { - return err - } - defer f.Close() - - headerCopy := *header - return GenMan(cmd, &headerCopy, f) -} - -// GenManTreeOptions is the options for generating the man pages. -// Used only in GenManTreeFromOpts. -type GenManTreeOptions struct { - Header *GenManHeader - Path string - CommandSeparator string -} - -// GenManHeader is a lot like the .TH header at the start of man pages. These -// include the title, section, date, source, and manual. We will use the -// current time if Date is unset and will use "Auto generated by spf13/cobra" -// if the Source is unset. -type GenManHeader struct { - Title string - Section string - Date *time.Time - date string - Source string - Manual string -} - -// GenMan will generate a man page for the given command and write it to -// w. The header argument may be nil, however obviously w may not. -func GenMan(cmd *cobra.Command, header *GenManHeader, w io.Writer) error { - if header == nil { - header = &GenManHeader{} - } - fillHeader(header, cmd.CommandPath()) - - b := genMan(cmd, header) - _, err := w.Write(md2man.Render(b)) - return err -} - -func fillHeader(header *GenManHeader, name string) { - if header.Title == "" { - header.Title = strings.ToUpper(strings.Replace(name, " ", "\\-", -1)) - } - if header.Section == "" { - header.Section = "1" - } - if header.Date == nil { - now := time.Now() - header.Date = &now - } - header.date = (*header.Date).Format("Jan 2006") - if header.Source == "" { - header.Source = "Auto generated by spf13/cobra" - } -} - -func manPreamble(buf *bytes.Buffer, header *GenManHeader, cmd *cobra.Command, dashedName string) { - description := cmd.Long - if len(description) == 0 { - description = cmd.Short - } - - buf.WriteString(fmt.Sprintf(`%% %s(%s)%s -%% %s -%% %s -# NAME -`, header.Title, header.Section, header.date, header.Source, header.Manual)) - buf.WriteString(fmt.Sprintf("%s \\- %s\n\n", dashedName, cmd.Short)) - buf.WriteString("# SYNOPSIS\n") - buf.WriteString(fmt.Sprintf("**%s**\n\n", cmd.UseLine())) - buf.WriteString("# DESCRIPTION\n") - buf.WriteString(description + "\n\n") -} - -func manPrintFlags(buf *bytes.Buffer, flags *pflag.FlagSet) { - flags.VisitAll(func(flag *pflag.Flag) { - if len(flag.Deprecated) > 0 || flag.Hidden { - return - } - format := "" - if len(flag.Shorthand) > 0 && len(flag.ShorthandDeprecated) == 0 { - format = fmt.Sprintf("**-%s**, **--%s**", flag.Shorthand, flag.Name) - } else { - format = fmt.Sprintf("**--%s**", flag.Name) - } - if len(flag.NoOptDefVal) > 0 { - format += "[" - } - if flag.Value.Type() == "string" { - // put quotes on the value - format += "=%q" - } else { - format += "=%s" - } - if len(flag.NoOptDefVal) > 0 { - format += "]" - } - format += "\n\t%s\n\n" - buf.WriteString(fmt.Sprintf(format, flag.DefValue, flag.Usage)) - }) -} - -func manPrintOptions(buf *bytes.Buffer, command *cobra.Command) { - flags := command.NonInheritedFlags() - if flags.HasAvailableFlags() { - buf.WriteString("# OPTIONS\n") - manPrintFlags(buf, flags) - buf.WriteString("\n") - } - flags = command.InheritedFlags() - if flags.HasAvailableFlags() { - buf.WriteString("# OPTIONS INHERITED FROM PARENT COMMANDS\n") - manPrintFlags(buf, flags) - buf.WriteString("\n") - } -} - -func genMan(cmd *cobra.Command, header *GenManHeader) []byte { - cmd.InitDefaultHelpCmd() - cmd.InitDefaultHelpFlag() - - // something like `rootcmd-subcmd1-subcmd2` - dashCommandName := strings.Replace(cmd.CommandPath(), " ", "-", -1) - - buf := new(bytes.Buffer) - - manPreamble(buf, header, cmd, dashCommandName) - manPrintOptions(buf, cmd) - if len(cmd.Example) > 0 { - buf.WriteString("# EXAMPLE\n") - buf.WriteString(fmt.Sprintf("```\n%s\n```\n", cmd.Example)) - } - if hasSeeAlso(cmd) { - buf.WriteString("# SEE ALSO\n") - seealsos := make([]string, 0) - if cmd.HasParent() { - parentPath := cmd.Parent().CommandPath() - dashParentPath := strings.Replace(parentPath, " ", "-", -1) - seealso := fmt.Sprintf("**%s(%s)**", dashParentPath, header.Section) - seealsos = append(seealsos, seealso) - cmd.VisitParents(func(c *cobra.Command) { - if c.DisableAutoGenTag { - cmd.DisableAutoGenTag = c.DisableAutoGenTag - } - }) - } - children := cmd.Commands() - sort.Sort(byName(children)) - for _, c := range children { - if !c.IsAvailableCommand() || c.IsAdditionalHelpTopicCommand() { - continue - } - seealso := fmt.Sprintf("**%s-%s(%s)**", dashCommandName, c.Name(), header.Section) - seealsos = append(seealsos, seealso) - } - buf.WriteString(strings.Join(seealsos, ", ") + "\n") - } - if !cmd.DisableAutoGenTag { - buf.WriteString(fmt.Sprintf("# HISTORY\n%s Auto generated by spf13/cobra\n", header.Date.Format("2-Jan-2006"))) - } - return buf.Bytes() -} diff --git a/vendor/github.com/spf13/cobra/doc/man_docs.md b/vendor/github.com/spf13/cobra/doc/man_docs.md deleted file mode 100644 index 3709160f34..0000000000 --- a/vendor/github.com/spf13/cobra/doc/man_docs.md +++ /dev/null @@ -1,31 +0,0 @@ -# Generating Man Pages For Your Own cobra.Command - -Generating man pages from a cobra command is incredibly easy. An example is as follows: - -```go -package main - -import ( - "log" - - "github.com/spf13/cobra" - "github.com/spf13/cobra/doc" -) - -func main() { - cmd := &cobra.Command{ - Use: "test", - Short: "my test program", - } - header := &doc.GenManHeader{ - Title: "MINE", - Section: "3", - } - err := doc.GenManTree(cmd, header, "/tmp") - if err != nil { - log.Fatal(err) - } -} -``` - -That will get you a man page `/tmp/test.3` diff --git a/vendor/github.com/spf13/cobra/doc/md_docs.go b/vendor/github.com/spf13/cobra/doc/md_docs.go deleted file mode 100644 index d76f6d5ecb..0000000000 --- a/vendor/github.com/spf13/cobra/doc/md_docs.go +++ /dev/null @@ -1,159 +0,0 @@ -//Copyright 2015 Red Hat Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package doc - -import ( - "bytes" - "fmt" - "io" - "os" - "path/filepath" - "sort" - "strings" - "time" - - "github.com/spf13/cobra" -) - -func printOptions(buf *bytes.Buffer, cmd *cobra.Command, name string) error { - flags := cmd.NonInheritedFlags() - flags.SetOutput(buf) - if flags.HasAvailableFlags() { - buf.WriteString("### Options\n\n```\n") - flags.PrintDefaults() - buf.WriteString("```\n\n") - } - - parentFlags := cmd.InheritedFlags() - parentFlags.SetOutput(buf) - if parentFlags.HasAvailableFlags() { - buf.WriteString("### Options inherited from parent commands\n\n```\n") - parentFlags.PrintDefaults() - buf.WriteString("```\n\n") - } - return nil -} - -// GenMarkdown creates markdown output. -func GenMarkdown(cmd *cobra.Command, w io.Writer) error { - return GenMarkdownCustom(cmd, w, func(s string) string { return s }) -} - -// GenMarkdownCustom creates custom markdown output. -func GenMarkdownCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string) string) error { - cmd.InitDefaultHelpCmd() - cmd.InitDefaultHelpFlag() - - buf := new(bytes.Buffer) - name := cmd.CommandPath() - - short := cmd.Short - long := cmd.Long - if len(long) == 0 { - long = short - } - - buf.WriteString("## " + name + "\n\n") - buf.WriteString(short + "\n\n") - buf.WriteString("### Synopsis\n\n") - buf.WriteString(long + "\n\n") - - if cmd.Runnable() { - buf.WriteString(fmt.Sprintf("```\n%s\n```\n\n", cmd.UseLine())) - } - - if len(cmd.Example) > 0 { - buf.WriteString("### Examples\n\n") - buf.WriteString(fmt.Sprintf("```\n%s\n```\n\n", cmd.Example)) - } - - if err := printOptions(buf, cmd, name); err != nil { - return err - } - if hasSeeAlso(cmd) { - buf.WriteString("### SEE ALSO\n\n") - if cmd.HasParent() { - parent := cmd.Parent() - pname := parent.CommandPath() - link := pname + ".md" - link = strings.Replace(link, " ", "_", -1) - buf.WriteString(fmt.Sprintf("* [%s](%s)\t - %s\n", pname, linkHandler(link), parent.Short)) - cmd.VisitParents(func(c *cobra.Command) { - if c.DisableAutoGenTag { - cmd.DisableAutoGenTag = c.DisableAutoGenTag - } - }) - } - - children := cmd.Commands() - sort.Sort(byName(children)) - - for _, child := range children { - if !child.IsAvailableCommand() || child.IsAdditionalHelpTopicCommand() { - continue - } - cname := name + " " + child.Name() - link := cname + ".md" - link = strings.Replace(link, " ", "_", -1) - buf.WriteString(fmt.Sprintf("* [%s](%s)\t - %s\n", cname, linkHandler(link), child.Short)) - } - buf.WriteString("\n") - } - if !cmd.DisableAutoGenTag { - buf.WriteString("###### Auto generated by spf13/cobra on " + time.Now().Format("2-Jan-2006") + "\n") - } - _, err := buf.WriteTo(w) - return err -} - -// GenMarkdownTree will generate a markdown page for this command and all -// descendants in the directory given. The header may be nil. -// This function may not work correctly if your command names have `-` in them. -// If you have `cmd` with two subcmds, `sub` and `sub-third`, -// and `sub` has a subcommand called `third`, it is undefined which -// help output will be in the file `cmd-sub-third.1`. -func GenMarkdownTree(cmd *cobra.Command, dir string) error { - identity := func(s string) string { return s } - emptyStr := func(s string) string { return "" } - return GenMarkdownTreeCustom(cmd, dir, emptyStr, identity) -} - -// GenMarkdownTreeCustom is the the same as GenMarkdownTree, but -// with custom filePrepender and linkHandler. -func GenMarkdownTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHandler func(string) string) error { - for _, c := range cmd.Commands() { - if !c.IsAvailableCommand() || c.IsAdditionalHelpTopicCommand() { - continue - } - if err := GenMarkdownTreeCustom(c, dir, filePrepender, linkHandler); err != nil { - return err - } - } - - basename := strings.Replace(cmd.CommandPath(), " ", "_", -1) + ".md" - filename := filepath.Join(dir, basename) - f, err := os.Create(filename) - if err != nil { - return err - } - defer f.Close() - - if _, err := io.WriteString(f, filePrepender(filename)); err != nil { - return err - } - if err := GenMarkdownCustom(cmd, f, linkHandler); err != nil { - return err - } - return nil -} diff --git a/vendor/github.com/spf13/cobra/doc/md_docs.md b/vendor/github.com/spf13/cobra/doc/md_docs.md deleted file mode 100644 index 56ce9fe819..0000000000 --- a/vendor/github.com/spf13/cobra/doc/md_docs.md +++ /dev/null @@ -1,115 +0,0 @@ -# Generating Markdown Docs For Your Own cobra.Command - -Generating man pages from a cobra command is incredibly easy. An example is as follows: - -```go -package main - -import ( - "log" - - "github.com/spf13/cobra" - "github.com/spf13/cobra/doc" -) - -func main() { - cmd := &cobra.Command{ - Use: "test", - Short: "my test program", - } - err := doc.GenMarkdownTree(cmd, "/tmp") - if err != nil { - log.Fatal(err) - } -} -``` - -That will get you a Markdown document `/tmp/test.md` - -## Generate markdown docs for the entire command tree - -This program can actually generate docs for the kubectl command in the kubernetes project - -```go -package main - -import ( - "log" - "io/ioutil" - "os" - - "k8s.io/kubernetes/pkg/kubectl/cmd" - cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" - - "github.com/spf13/cobra/doc" -) - -func main() { - kubectl := cmd.NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, ioutil.Discard, ioutil.Discard) - err := doc.GenMarkdownTree(kubectl, "./") - if err != nil { - log.Fatal(err) - } -} -``` - -This will generate a whole series of files, one for each command in the tree, in the directory specified (in this case "./") - -## Generate markdown docs for a single command - -You may wish to have more control over the output, or only generate for a single command, instead of the entire command tree. If this is the case you may prefer to `GenMarkdown` instead of `GenMarkdownTree` - -```go - out := new(bytes.Buffer) - err := doc.GenMarkdown(cmd, out) - if err != nil { - log.Fatal(err) - } -``` - -This will write the markdown doc for ONLY "cmd" into the out, buffer. - -## Customize the output - -Both `GenMarkdown` and `GenMarkdownTree` have alternate versions with callbacks to get some control of the output: - -```go -func GenMarkdownTreeCustom(cmd *Command, dir string, filePrepender, linkHandler func(string) string) error { - //... -} -``` - -```go -func GenMarkdownCustom(cmd *Command, out *bytes.Buffer, linkHandler func(string) string) error { - //... -} -``` - -The `filePrepender` will prepend the return value given the full filepath to the rendered Markdown file. A common use case is to add front matter to use the generated documentation with [Hugo](http://gohugo.io/): - -```go -const fmTemplate = `--- -date: %s -title: "%s" -slug: %s -url: %s ---- -` - -filePrepender := func(filename string) string { - now := time.Now().Format(time.RFC3339) - name := filepath.Base(filename) - base := strings.TrimSuffix(name, path.Ext(name)) - url := "/commands/" + strings.ToLower(base) + "/" - return fmt.Sprintf(fmTemplate, now, strings.Replace(base, "_", " ", -1), base, url) -} -``` - -The `linkHandler` can be used to customize the rendered internal links to the commands, given a filename: - -```go -linkHandler := func(name string) string { - base := strings.TrimSuffix(name, path.Ext(name)) - return "/commands/" + strings.ToLower(base) + "/" -} -``` diff --git a/vendor/github.com/spf13/cobra/doc/rest_docs.go b/vendor/github.com/spf13/cobra/doc/rest_docs.go deleted file mode 100644 index 051d8dc832..0000000000 --- a/vendor/github.com/spf13/cobra/doc/rest_docs.go +++ /dev/null @@ -1,185 +0,0 @@ -//Copyright 2015 Red Hat Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package doc - -import ( - "bytes" - "fmt" - "io" - "os" - "path/filepath" - "sort" - "strings" - "time" - - "github.com/spf13/cobra" -) - -func printOptionsReST(buf *bytes.Buffer, cmd *cobra.Command, name string) error { - flags := cmd.NonInheritedFlags() - flags.SetOutput(buf) - if flags.HasAvailableFlags() { - buf.WriteString("Options\n") - buf.WriteString("~~~~~~~\n\n::\n\n") - flags.PrintDefaults() - buf.WriteString("\n") - } - - parentFlags := cmd.InheritedFlags() - parentFlags.SetOutput(buf) - if parentFlags.HasAvailableFlags() { - buf.WriteString("Options inherited from parent commands\n") - buf.WriteString("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n::\n\n") - parentFlags.PrintDefaults() - buf.WriteString("\n") - } - return nil -} - -// linkHandler for default ReST hyperlink markup -func defaultLinkHandler(name, ref string) string { - return fmt.Sprintf("`%s <%s.rst>`_", name, ref) -} - -// GenReST creates reStructured Text output. -func GenReST(cmd *cobra.Command, w io.Writer) error { - return GenReSTCustom(cmd, w, defaultLinkHandler) -} - -// GenReSTCustom creates custom reStructured Text output. -func GenReSTCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string, string) string) error { - cmd.InitDefaultHelpCmd() - cmd.InitDefaultHelpFlag() - - buf := new(bytes.Buffer) - name := cmd.CommandPath() - - short := cmd.Short - long := cmd.Long - if len(long) == 0 { - long = short - } - ref := strings.Replace(name, " ", "_", -1) - - buf.WriteString(".. _" + ref + ":\n\n") - buf.WriteString(name + "\n") - buf.WriteString(strings.Repeat("-", len(name)) + "\n\n") - buf.WriteString(short + "\n\n") - buf.WriteString("Synopsis\n") - buf.WriteString("~~~~~~~~\n\n") - buf.WriteString("\n" + long + "\n\n") - - if cmd.Runnable() { - buf.WriteString(fmt.Sprintf("::\n\n %s\n\n", cmd.UseLine())) - } - - if len(cmd.Example) > 0 { - buf.WriteString("Examples\n") - buf.WriteString("~~~~~~~~\n\n") - buf.WriteString(fmt.Sprintf("::\n\n%s\n\n", indentString(cmd.Example, " "))) - } - - if err := printOptionsReST(buf, cmd, name); err != nil { - return err - } - if hasSeeAlso(cmd) { - buf.WriteString("SEE ALSO\n") - buf.WriteString("~~~~~~~~\n\n") - if cmd.HasParent() { - parent := cmd.Parent() - pname := parent.CommandPath() - ref = strings.Replace(pname, " ", "_", -1) - buf.WriteString(fmt.Sprintf("* %s \t - %s\n", linkHandler(pname, ref), parent.Short)) - cmd.VisitParents(func(c *cobra.Command) { - if c.DisableAutoGenTag { - cmd.DisableAutoGenTag = c.DisableAutoGenTag - } - }) - } - - children := cmd.Commands() - sort.Sort(byName(children)) - - for _, child := range children { - if !child.IsAvailableCommand() || child.IsAdditionalHelpTopicCommand() { - continue - } - cname := name + " " + child.Name() - ref = strings.Replace(cname, " ", "_", -1) - buf.WriteString(fmt.Sprintf("* %s \t - %s\n", linkHandler(cname, ref), child.Short)) - } - buf.WriteString("\n") - } - if !cmd.DisableAutoGenTag { - buf.WriteString("*Auto generated by spf13/cobra on " + time.Now().Format("2-Jan-2006") + "*\n") - } - _, err := buf.WriteTo(w) - return err -} - -// GenReSTTree will generate a ReST page for this command and all -// descendants in the directory given. -// This function may not work correctly if your command names have `-` in them. -// If you have `cmd` with two subcmds, `sub` and `sub-third`, -// and `sub` has a subcommand called `third`, it is undefined which -// help output will be in the file `cmd-sub-third.1`. -func GenReSTTree(cmd *cobra.Command, dir string) error { - emptyStr := func(s string) string { return "" } - return GenReSTTreeCustom(cmd, dir, emptyStr, defaultLinkHandler) -} - -// GenReSTTreeCustom is the the same as GenReSTTree, but -// with custom filePrepender and linkHandler. -func GenReSTTreeCustom(cmd *cobra.Command, dir string, filePrepender func(string) string, linkHandler func(string, string) string) error { - for _, c := range cmd.Commands() { - if !c.IsAvailableCommand() || c.IsAdditionalHelpTopicCommand() { - continue - } - if err := GenReSTTreeCustom(c, dir, filePrepender, linkHandler); err != nil { - return err - } - } - - basename := strings.Replace(cmd.CommandPath(), " ", "_", -1) + ".rst" - filename := filepath.Join(dir, basename) - f, err := os.Create(filename) - if err != nil { - return err - } - defer f.Close() - - if _, err := io.WriteString(f, filePrepender(filename)); err != nil { - return err - } - if err := GenReSTCustom(cmd, f, linkHandler); err != nil { - return err - } - return nil -} - -// adapted from: https://github.com/kr/text/blob/main/indent.go -func indentString(s, p string) string { - var res []byte - b := []byte(s) - prefix := []byte(p) - bol := true - for _, c := range b { - if bol && c != '\n' { - res = append(res, prefix...) - } - res = append(res, c) - bol = c == '\n' - } - return string(res) -} diff --git a/vendor/github.com/spf13/cobra/doc/rest_docs.md b/vendor/github.com/spf13/cobra/doc/rest_docs.md deleted file mode 100644 index 6098430eff..0000000000 --- a/vendor/github.com/spf13/cobra/doc/rest_docs.md +++ /dev/null @@ -1,114 +0,0 @@ -# Generating ReStructured Text Docs For Your Own cobra.Command - -Generating ReST pages from a cobra command is incredibly easy. An example is as follows: - -```go -package main - -import ( - "log" - - "github.com/spf13/cobra" - "github.com/spf13/cobra/doc" -) - -func main() { - cmd := &cobra.Command{ - Use: "test", - Short: "my test program", - } - err := doc.GenReSTTree(cmd, "/tmp") - if err != nil { - log.Fatal(err) - } -} -``` - -That will get you a ReST document `/tmp/test.rst` - -## Generate ReST docs for the entire command tree - -This program can actually generate docs for the kubectl command in the kubernetes project - -```go -package main - -import ( - "log" - "io/ioutil" - "os" - - "k8s.io/kubernetes/pkg/kubectl/cmd" - cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" - - "github.com/spf13/cobra/doc" -) - -func main() { - kubectl := cmd.NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, ioutil.Discard, ioutil.Discard) - err := doc.GenReSTTree(kubectl, "./") - if err != nil { - log.Fatal(err) - } -} -``` - -This will generate a whole series of files, one for each command in the tree, in the directory specified (in this case "./") - -## Generate ReST docs for a single command - -You may wish to have more control over the output, or only generate for a single command, instead of the entire command tree. If this is the case you may prefer to `GenReST` instead of `GenReSTTree` - -```go - out := new(bytes.Buffer) - err := doc.GenReST(cmd, out) - if err != nil { - log.Fatal(err) - } -``` - -This will write the ReST doc for ONLY "cmd" into the out, buffer. - -## Customize the output - -Both `GenReST` and `GenReSTTree` have alternate versions with callbacks to get some control of the output: - -```go -func GenReSTTreeCustom(cmd *Command, dir string, filePrepender func(string) string, linkHandler func(string, string) string) error { - //... -} -``` - -```go -func GenReSTCustom(cmd *Command, out *bytes.Buffer, linkHandler func(string, string) string) error { - //... -} -``` - -The `filePrepender` will prepend the return value given the full filepath to the rendered ReST file. A common use case is to add front matter to use the generated documentation with [Hugo](http://gohugo.io/): - -```go -const fmTemplate = `--- -date: %s -title: "%s" -slug: %s -url: %s ---- -` -filePrepender := func(filename string) string { - now := time.Now().Format(time.RFC3339) - name := filepath.Base(filename) - base := strings.TrimSuffix(name, path.Ext(name)) - url := "/commands/" + strings.ToLower(base) + "/" - return fmt.Sprintf(fmTemplate, now, strings.Replace(base, "_", " ", -1), base, url) -} -``` - -The `linkHandler` can be used to customize the rendered links to the commands, given a command name and reference. This is useful while converting rst to html or while generating documentation with tools like Sphinx where `:ref:` is used: - -```go -// Sphinx cross-referencing format -linkHandler := func(name, ref string) string { - return fmt.Sprintf(":ref:`%s <%s>`", name, ref) -} -``` diff --git a/vendor/github.com/spf13/cobra/doc/util.go b/vendor/github.com/spf13/cobra/doc/util.go deleted file mode 100644 index 8d3dbecec8..0000000000 --- a/vendor/github.com/spf13/cobra/doc/util.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2015 Red Hat Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package doc - -import ( - "strings" - - "github.com/spf13/cobra" -) - -// Test to see if we have a reason to print See Also information in docs -// Basically this is a test for a parent commend or a subcommand which is -// both not deprecated and not the autogenerated help command. -func hasSeeAlso(cmd *cobra.Command) bool { - if cmd.HasParent() { - return true - } - for _, c := range cmd.Commands() { - if !c.IsAvailableCommand() || c.IsAdditionalHelpTopicCommand() { - continue - } - return true - } - return false -} - -// Temporary workaround for yaml lib generating incorrect yaml with long strings -// that do not contain \n. -func forceMultiLine(s string) string { - if len(s) > 60 && !strings.Contains(s, "\n") { - s = s + "\n" - } - return s -} - -type byName []*cobra.Command - -func (s byName) Len() int { return len(s) } -func (s byName) Swap(i, j int) { s[i], s[j] = s[j], s[i] } -func (s byName) Less(i, j int) bool { return s[i].Name() < s[j].Name() } diff --git a/vendor/github.com/spf13/cobra/doc/yaml_docs.go b/vendor/github.com/spf13/cobra/doc/yaml_docs.go deleted file mode 100644 index ea00af07e8..0000000000 --- a/vendor/github.com/spf13/cobra/doc/yaml_docs.go +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright 2016 French Ben. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package doc - -import ( - "fmt" - "io" - "os" - "path/filepath" - "sort" - "strings" - - "github.com/spf13/cobra" - "github.com/spf13/pflag" - "gopkg.in/yaml.v2" -) - -type cmdOption struct { - Name string - Shorthand string `yaml:",omitempty"` - DefaultValue string `yaml:"default_value,omitempty"` - Usage string `yaml:",omitempty"` -} - -type cmdDoc struct { - Name string - Synopsis string `yaml:",omitempty"` - Description string `yaml:",omitempty"` - Options []cmdOption `yaml:",omitempty"` - InheritedOptions []cmdOption `yaml:"inherited_options,omitempty"` - Example string `yaml:",omitempty"` - SeeAlso []string `yaml:"see_also,omitempty"` -} - -// GenYamlTree creates yaml structured ref files for this command and all descendants -// in the directory given. This function may not work -// correctly if your command names have `-` in them. If you have `cmd` with two -// subcmds, `sub` and `sub-third`, and `sub` has a subcommand called `third` -// it is undefined which help output will be in the file `cmd-sub-third.1`. -func GenYamlTree(cmd *cobra.Command, dir string) error { - identity := func(s string) string { return s } - emptyStr := func(s string) string { return "" } - return GenYamlTreeCustom(cmd, dir, emptyStr, identity) -} - -// GenYamlTreeCustom creates yaml structured ref files. -func GenYamlTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHandler func(string) string) error { - for _, c := range cmd.Commands() { - if !c.IsAvailableCommand() || c.IsAdditionalHelpTopicCommand() { - continue - } - if err := GenYamlTreeCustom(c, dir, filePrepender, linkHandler); err != nil { - return err - } - } - - basename := strings.Replace(cmd.CommandPath(), " ", "_", -1) + ".yaml" - filename := filepath.Join(dir, basename) - f, err := os.Create(filename) - if err != nil { - return err - } - defer f.Close() - - if _, err := io.WriteString(f, filePrepender(filename)); err != nil { - return err - } - if err := GenYamlCustom(cmd, f, linkHandler); err != nil { - return err - } - return nil -} - -// GenYaml creates yaml output. -func GenYaml(cmd *cobra.Command, w io.Writer) error { - return GenYamlCustom(cmd, w, func(s string) string { return s }) -} - -// GenYamlCustom creates custom yaml output. -func GenYamlCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string) string) error { - cmd.InitDefaultHelpCmd() - cmd.InitDefaultHelpFlag() - - yamlDoc := cmdDoc{} - yamlDoc.Name = cmd.CommandPath() - - yamlDoc.Synopsis = forceMultiLine(cmd.Short) - yamlDoc.Description = forceMultiLine(cmd.Long) - - if len(cmd.Example) > 0 { - yamlDoc.Example = cmd.Example - } - - flags := cmd.NonInheritedFlags() - if flags.HasFlags() { - yamlDoc.Options = genFlagResult(flags) - } - flags = cmd.InheritedFlags() - if flags.HasFlags() { - yamlDoc.InheritedOptions = genFlagResult(flags) - } - - if hasSeeAlso(cmd) { - result := []string{} - if cmd.HasParent() { - parent := cmd.Parent() - result = append(result, parent.CommandPath()+" - "+parent.Short) - } - children := cmd.Commands() - sort.Sort(byName(children)) - for _, child := range children { - if !child.IsAvailableCommand() || child.IsAdditionalHelpTopicCommand() { - continue - } - result = append(result, child.Name()+" - "+child.Short) - } - yamlDoc.SeeAlso = result - } - - final, err := yaml.Marshal(&yamlDoc) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - if _, err := w.Write(final); err != nil { - return err - } - return nil -} - -func genFlagResult(flags *pflag.FlagSet) []cmdOption { - var result []cmdOption - - flags.VisitAll(func(flag *pflag.Flag) { - // Todo, when we mark a shorthand is deprecated, but specify an empty message. - // The flag.ShorthandDeprecated is empty as the shorthand is deprecated. - // Using len(flag.ShorthandDeprecated) > 0 can't handle this, others are ok. - if !(len(flag.ShorthandDeprecated) > 0) && len(flag.Shorthand) > 0 { - opt := cmdOption{ - flag.Name, - flag.Shorthand, - flag.DefValue, - forceMultiLine(flag.Usage), - } - result = append(result, opt) - } else { - opt := cmdOption{ - Name: flag.Name, - DefaultValue: forceMultiLine(flag.DefValue), - Usage: forceMultiLine(flag.Usage), - } - result = append(result, opt) - } - }) - - return result -} diff --git a/vendor/github.com/spf13/cobra/doc/yaml_docs.md b/vendor/github.com/spf13/cobra/doc/yaml_docs.md deleted file mode 100644 index 1a9b7c6a3c..0000000000 --- a/vendor/github.com/spf13/cobra/doc/yaml_docs.md +++ /dev/null @@ -1,112 +0,0 @@ -# Generating Yaml Docs For Your Own cobra.Command - -Generating yaml files from a cobra command is incredibly easy. An example is as follows: - -```go -package main - -import ( - "log" - - "github.com/spf13/cobra" - "github.com/spf13/cobra/doc" -) - -func main() { - cmd := &cobra.Command{ - Use: "test", - Short: "my test program", - } - err := doc.GenYamlTree(cmd, "/tmp") - if err != nil { - log.Fatal(err) - } -} -``` - -That will get you a Yaml document `/tmp/test.yaml` - -## Generate yaml docs for the entire command tree - -This program can actually generate docs for the kubectl command in the kubernetes project - -```go -package main - -import ( - "io/ioutil" - "log" - "os" - - "k8s.io/kubernetes/pkg/kubectl/cmd" - cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" - - "github.com/spf13/cobra/doc" -) - -func main() { - kubectl := cmd.NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, ioutil.Discard, ioutil.Discard) - err := doc.GenYamlTree(kubectl, "./") - if err != nil { - log.Fatal(err) - } -} -``` - -This will generate a whole series of files, one for each command in the tree, in the directory specified (in this case "./") - -## Generate yaml docs for a single command - -You may wish to have more control over the output, or only generate for a single command, instead of the entire command tree. If this is the case you may prefer to `GenYaml` instead of `GenYamlTree` - -```go - out := new(bytes.Buffer) - doc.GenYaml(cmd, out) -``` - -This will write the yaml doc for ONLY "cmd" into the out, buffer. - -## Customize the output - -Both `GenYaml` and `GenYamlTree` have alternate versions with callbacks to get some control of the output: - -```go -func GenYamlTreeCustom(cmd *Command, dir string, filePrepender, linkHandler func(string) string) error { - //... -} -``` - -```go -func GenYamlCustom(cmd *Command, out *bytes.Buffer, linkHandler func(string) string) error { - //... -} -``` - -The `filePrepender` will prepend the return value given the full filepath to the rendered Yaml file. A common use case is to add front matter to use the generated documentation with [Hugo](http://gohugo.io/): - -```go -const fmTemplate = `--- -date: %s -title: "%s" -slug: %s -url: %s ---- -` - -filePrepender := func(filename string) string { - now := time.Now().Format(time.RFC3339) - name := filepath.Base(filename) - base := strings.TrimSuffix(name, path.Ext(name)) - url := "/commands/" + strings.ToLower(base) + "/" - return fmt.Sprintf(fmTemplate, now, strings.Replace(base, "_", " ", -1), base, url) -} -``` - -The `linkHandler` can be used to customize the rendered internal links to the commands, given a filename: - -```go -linkHandler := func(name string) string { - base := strings.TrimSuffix(name, path.Ext(name)) - return "/commands/" + strings.ToLower(base) + "/" -} -``` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/protocol/http/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/protocol/http/client.go index 0d3e05dbe9..66330b34a4 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/private/protocol/http/client.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/protocol/http/client.go @@ -7,10 +7,13 @@ import ( "io/ioutil" "net/http" "time" - - "github.com/pkg/errors" ) +// Client is the interface of http client +type Client interface { + Send(*HttpRequest) (*HttpResponse, error) +} + // HttpClient used to send a real request via http to server type HttpClient struct { } @@ -54,7 +57,7 @@ func (c *HttpClient) doHTTPRequest(client *http.Client, req *http.Request) (*Htt // send request httpResp, err := client.Do(req) if err != nil { - return nil, errors.Errorf("cannot send request, %s", err) + return nil, err } defer httpResp.Body.Close() @@ -66,17 +69,12 @@ func (c *HttpClient) doHTTPRequest(client *http.Client, req *http.Request) (*Htt // read content body, err := ioutil.ReadAll(httpResp.Body) if err != nil { - return nil, errors.Errorf("cannot read response, %s", err) + return nil, err } // build response wrapper resp := NewHttpResponse() resp.setHttpReponse(httpResp) - resp.setBody(body) + resp.SetBody(body) return resp, nil } - -func (c *HttpClient) buildHTTPRequestWithTracer(req *http.Request) (*http.Request, error) { - // TODO: implement trace via httptrace - return req, nil -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/protocol/http/defaults.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/protocol/http/defaults.go index c2d0714b12..c8440bcc5e 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/private/protocol/http/defaults.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/protocol/http/defaults.go @@ -4,9 +4,16 @@ import ( "time" ) +type mimeType string + +const ( + mimeFormURLEncoded mimeType = "application/x-www-form-urlencoded" + mimeJSON mimeType = "application/json" +) + // DefaultHeaders defined default http headers var DefaultHeaders = map[string]string{ - "Content-Type": "application/x-www-form-urlencoded", + "Content-Type": string(mimeFormURLEncoded), // "X-SDK-VERSION": VERSION, } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/protocol/http/request.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/protocol/http/request.go index 2a2a0fc11d..a771ff1faa 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/private/protocol/http/request.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/protocol/http/request.go @@ -1,6 +1,7 @@ package http import ( + "bytes" "fmt" "net/http" "net/url" @@ -20,22 +21,22 @@ type HttpRequest struct { queryMap map[string]string queryString string headers map[string]string - - // body payload - formData map[string]string requestBody []byte - - timeout time.Duration + timeout time.Duration } // NewHttpRequest will create a http request -func NewHttpRequest() HttpRequest { - return HttpRequest{ +func NewHttpRequest() *HttpRequest { + r := &HttpRequest{ queryMap: make(map[string]string), headers: make(map[string]string), - formData: make(map[string]string), timeout: DefaultTimeout, } + + for k, v := range DefaultHeaders { + r.headers[k] = v + } + return r } // SetURL will set url into request @@ -51,7 +52,7 @@ func (h *HttpRequest) SetURL(val string) error { return err } - h.url = val + h.url = fmt.Sprintf("%s://%s%s", uri.Scheme, uri.Host, uri.Path) return nil } @@ -135,6 +136,14 @@ func (h *HttpRequest) SetQuery(k, v string) error { return nil } +// GetQuery will get value by key from map +func (h *HttpRequest) GetQuery(k string) string { + if v, ok := h.queryMap[k]; ok { + return v + } + return "" +} + // GetQueryMap will get all of query as a map func (h *HttpRequest) GetQueryMap() map[string]string { return h.queryMap @@ -183,15 +192,26 @@ func (h *HttpRequest) String() string { return h.GetURL() } +func (h *HttpRequest) getContentType() string { + if v, ok := h.headers["Content-Type"]; ok { + return v + } + return string(mimeFormURLEncoded) +} + func (h *HttpRequest) buildHTTPRequest() (*http.Request, error) { qs, err := h.BuildQueryString() if err != nil { return nil, errors.Errorf("cannot build query string, %s", err) } - // NOTE: api.ucloud.cn has been supported request via form urlencoded data - url := fmt.Sprintf("%s?%s", h.GetURL(), qs) - httpReq, err := http.NewRequest(h.GetMethod(), url, nil) + var httpReq *http.Request + if h.getContentType() == string(mimeFormURLEncoded) && len(h.GetRequestBody()) == 0 { + httpReq, err = http.NewRequest(h.GetMethod(), h.GetURL(), strings.NewReader(qs)) + } else { + httpReq, err = http.NewRequest(h.GetMethod(), h.String(), bytes.NewReader(h.GetRequestBody())) + } + if err != nil { return nil, errors.Errorf("cannot build request, %s", err) } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/protocol/http/response.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/protocol/http/response.go index 1654fde351..372879d17f 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/private/protocol/http/response.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/protocol/http/response.go @@ -7,6 +7,7 @@ import ( // HttpResponse is a simple wrapper of "net/http" response type HttpResponse struct { body []byte + statusCode int originHttpResponse *http.Response // origin "net/http" response } @@ -20,19 +21,25 @@ func (h *HttpResponse) GetBody() []byte { return h.body } -// GetStatusCode will return status code of origin http response -func (h *HttpResponse) GetStatusCode() int { - return h.originHttpResponse.StatusCode -} - -// setBody will set body into http response +// SetBody will set body into http response // it usually used for restore the body already read from an stream // it will also cause extra memory usage -func (h *HttpResponse) setBody(body []byte) error { +func (h *HttpResponse) SetBody(body []byte) error { h.body = body return nil } +// GetStatusCode will return status code of origin http response +func (h *HttpResponse) GetStatusCode() int { + return h.statusCode +} + +// SetStatusCode will return status code of origin http response +func (h *HttpResponse) SetStatusCode(code int) { + h.statusCode = code +} + func (h *HttpResponse) setHttpReponse(resp *http.Response) { + h.statusCode = resp.StatusCode h.originHttpResponse = resp } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udb/change_udbparam_group.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udb/change_udbparam_group.go new file mode 100644 index 0000000000..1e0c215c05 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udb/change_udbparam_group.go @@ -0,0 +1,59 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB ChangeUDBParamGroup + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// ChangeUDBParamGroupRequest is request schema for ChangeUDBParamGroup action +type ChangeUDBParamGroupRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // DB实例Id + DBId *string `required:"true"` + + // 参数组Id + GroupId *string `required:"true"` +} + +// ChangeUDBParamGroupResponse is response schema for ChangeUDBParamGroup action +type ChangeUDBParamGroupResponse struct { + response.CommonBase +} + +// NewChangeUDBParamGroupRequest will create request of ChangeUDBParamGroup action. +func (c *UDBClient) NewChangeUDBParamGroupRequest() *ChangeUDBParamGroupRequest { + req := &ChangeUDBParamGroupRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// ChangeUDBParamGroup - 修改配置文件 +func (c *UDBClient) ChangeUDBParamGroup(req *ChangeUDBParamGroupRequest) (*ChangeUDBParamGroupResponse, error) { + var err error + var res ChangeUDBParamGroupResponse + + err = c.client.InvokeAction("ChangeUDBParamGroup", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udb/check_udbinstance_allowance.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udb/check_udbinstance_allowance.go new file mode 100644 index 0000000000..1b755b9cbb --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udb/check_udbinstance_allowance.go @@ -0,0 +1,83 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB CheckUDBInstanceAllowance + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// CheckUDBInstanceAllowanceRequest is request schema for CheckUDBInstanceAllowance action +type CheckUDBInstanceAllowanceRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"true"` + + // DB种类,分为SQL和NOSQL,取值分别为sql、nosql、postgresql + ClassType *string `required:"true"` + + // 申请资源的内存限制 + MemoryLimit *int `required:"true"` + + // 申请资源的磁盘空间 + DiskSpace *int `required:"true"` + + // 是否使用SSD资源,true代表使用,false代表不使用 + UseSSD *bool `required:"true"` + + // 资源申请个数,默认为一个 + Count *int `required:"true"` + + // UDB实例的部署模式:可选值为:Normal: 普通单点实例,HA: 高可用部署实例 + InstanceMode *string `required:"true"` + + // SSD类型,可选值为"SATA"、"PCI-E",如果UseSSD为true ,则需要指定SSD类型 + SSDType *string `required:"false"` + + // 如果是从库创建核查,需要指定SrcId + SrcId *string `required:"false"` + + // 跨可用区备库所在可用区, 参见 [可用区列表](../summary/regionlist.html) + BackupZone *string `required:"false"` + + // 专区ID + UDBCId *string `required:"false"` + + // 专区里面DB升降级需要原来DB的信息 + DBId *string `required:"false"` +} + +// CheckUDBInstanceAllowanceResponse is response schema for CheckUDBInstanceAllowance action +type CheckUDBInstanceAllowanceResponse struct { + response.CommonBase + + // 资源核查部分成功情况下,成功个数 + Count int +} + +// NewCheckUDBInstanceAllowanceRequest will create request of CheckUDBInstanceAllowance action. +func (c *UDBClient) NewCheckUDBInstanceAllowanceRequest() *CheckUDBInstanceAllowanceRequest { + req := &CheckUDBInstanceAllowanceRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// CheckUDBInstanceAllowance - 核查UDB资源余量 +func (c *UDBClient) CheckUDBInstanceAllowance(req *CheckUDBInstanceAllowanceRequest) (*CheckUDBInstanceAllowanceResponse, error) { + var err error + var res CheckUDBInstanceAllowanceResponse + + err = c.client.InvokeAction("CheckUDBInstanceAllowance", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udb/client.go similarity index 60% rename from vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/client.go rename to vendor/github.com/ucloud/ucloud-sdk-go/private/services/udb/client.go index f0ae4c4737..7e41f44399 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/client.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udb/client.go @@ -1,19 +1,19 @@ -package udisk +package udb import ( "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) -// UDiskClient is the client of UDisk -type UDiskClient struct { +// UDBClient is the client of UDB +type UDBClient struct { client *ucloud.Client } -// NewClient will return a instance of UDiskClient -func NewClient(config *ucloud.Config, credential *auth.Credential) *UDiskClient { +// NewClient will return a instance of UDBClient +func NewClient(config *ucloud.Config, credential *auth.Credential) *UDBClient { client := ucloud.NewClient(config, credential) - return &UDiskClient{ + return &UDBClient{ client: client, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udb/describe_udbinstance_by_param_group.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udb/describe_udbinstance_by_param_group.go new file mode 100644 index 0000000000..8bf2d2fcb7 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udb/describe_udbinstance_by_param_group.go @@ -0,0 +1,62 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DescribeUDBInstanceByParamGroup + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DescribeUDBInstanceByParamGroupRequest is request schema for DescribeUDBInstanceByParamGroup action +type DescribeUDBInstanceByParamGroupRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 参数组id + GroupId *string `required:"true"` + + // 是否是跨可用区的配置文件 + RegionFlag *string `required:"false"` +} + +// DescribeUDBInstanceByParamGroupResponse is response schema for DescribeUDBInstanceByParamGroup action +type DescribeUDBInstanceByParamGroupResponse struct { + response.CommonBase + + // DB实例信息列表 + DataSet []UDBInstanceByParamGroup +} + +// NewDescribeUDBInstanceByParamGroupRequest will create request of DescribeUDBInstanceByParamGroup action. +func (c *UDBClient) NewDescribeUDBInstanceByParamGroupRequest() *DescribeUDBInstanceByParamGroupRequest { + req := &DescribeUDBInstanceByParamGroupRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DescribeUDBInstanceByParamGroup - 根据配置文件获取UDB实例信息 +func (c *UDBClient) DescribeUDBInstanceByParamGroup(req *DescribeUDBInstanceByParamGroupRequest) (*DescribeUDBInstanceByParamGroupResponse, error) { + var err error + var res DescribeUDBInstanceByParamGroupResponse + + err = c.client.InvokeAction("DescribeUDBInstanceByParamGroup", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udb/extract_udbparam_group.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udb/extract_udbparam_group.go new file mode 100644 index 0000000000..fe0d5845b6 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udb/extract_udbparam_group.go @@ -0,0 +1,59 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB ExtractUDBParamGroup + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// ExtractUDBParamGroupRequest is request schema for ExtractUDBParamGroup action +type ExtractUDBParamGroupRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // 配置id + GroupId *int `required:"true"` + + // 是否跨可用区,RegionFlag为true时表示跨可用区配置文件 + RegionFlag *bool `required:"false"` +} + +// ExtractUDBParamGroupResponse is response schema for ExtractUDBParamGroup action +type ExtractUDBParamGroupResponse struct { + response.CommonBase + + // 配置文件内容 + Content string +} + +// NewExtractUDBParamGroupRequest will create request of ExtractUDBParamGroup action. +func (c *UDBClient) NewExtractUDBParamGroupRequest() *ExtractUDBParamGroupRequest { + req := &ExtractUDBParamGroupRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// ExtractUDBParamGroup - 获取配置文件内容 +func (c *UDBClient) ExtractUDBParamGroup(req *ExtractUDBParamGroupRequest) (*ExtractUDBParamGroupResponse, error) { + var err error + var res ExtractUDBParamGroupResponse + + err = c.client.InvokeAction("ExtractUDBParamGroup", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udb/types_udbinstance_by_param_group.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udb/types_udbinstance_by_param_group.go new file mode 100644 index 0000000000..7cf7a4e912 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udb/types_udbinstance_by_param_group.go @@ -0,0 +1,34 @@ +package udb + +/* +UDBInstanceByParamGroup - DescribeUDBInstanceByParamGroup + +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. +*/ +type UDBInstanceByParamGroup struct { + + // DB实例Id + DBId string + + // 实例名称 + Name string + + // DB实例虚ip + VirtualIP string + + // 端口号 + Port string + + // DB状态标记 + State string + + // DB实例创建时间 + CreateTime string + + // DB实例过期时间 + ExpiredTime string + + // DB实例角色 + Role string +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/delete_udisk_snapshot.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/delete_udisk_snapshot.go deleted file mode 100644 index d6d72e2fe3..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/delete_udisk_snapshot.go +++ /dev/null @@ -1,53 +0,0 @@ -//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. -//go:generate ucloud-gen-go-api UDisk DeleteUDiskSnapshot - -package udisk - -import ( - "github.com/ucloud/ucloud-sdk-go/ucloud/request" - "github.com/ucloud/ucloud-sdk-go/ucloud/response" -) - -// DeleteUDiskSnapshotRequest is request schema for DeleteUDiskSnapshot action -type DeleteUDiskSnapshotRequest struct { - request.CommonBase - - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"true"` - - // 快照Id - SnapshotId *string `required:"true"` - - // UDisk Id,删除该盘所创建出来的所有快照 - UDiskId *string `required:"false"` -} - -// DeleteUDiskSnapshotResponse is response schema for DeleteUDiskSnapshot action -type DeleteUDiskSnapshotResponse struct { - response.CommonBase -} - -// NewDeleteUDiskSnapshotRequest will create request of DeleteUDiskSnapshot action. -func (c *UDiskClient) NewDeleteUDiskSnapshotRequest() *DeleteUDiskSnapshotRequest { - req := &DeleteUDiskSnapshotRequest{} - - // setup request with client config - c.client.SetupRequest(req) - - // setup retryable with default retry policy (retry for non-create action and common error) - req.SetRetryable(true) - return req -} - -// DeleteUDiskSnapshot - 删除Snapshot -func (c *UDiskClient) DeleteUDiskSnapshot(req *DeleteUDiskSnapshotRequest) (*DeleteUDiskSnapshotResponse, error) { - var err error - var res DeleteUDiskSnapshotResponse - - err = c.client.InvokeAction("DeleteUDiskSnapshot", req, &res) - if err != nil { - return &res, err - } - - return &res, nil -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/describe_udisk_snapshot.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/describe_udisk_snapshot.go deleted file mode 100644 index f0d8dcdc19..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/describe_udisk_snapshot.go +++ /dev/null @@ -1,65 +0,0 @@ -//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. -//go:generate ucloud-gen-go-api UDisk DescribeUDiskSnapshot - -package udisk - -import ( - "github.com/ucloud/ucloud-sdk-go/ucloud/request" - "github.com/ucloud/ucloud-sdk-go/ucloud/response" -) - -// DescribeUDiskSnapshotRequest is request schema for DescribeUDiskSnapshot action -type DescribeUDiskSnapshotRequest struct { - request.CommonBase - - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` - - // 数据偏移量, 默认为0 - Offset *int `required:"false"` - - // 返回数据长度, 默认为20 - Limit *int `required:"false"` - - // UDiskId,返回该盘所做快照.(必须同时传Zone) - UDiskId *string `required:"false"` - - // 快照id,SnapshotId , UDiskId 同时传SnapshotId优先 - SnapshotId *string `required:"false"` -} - -// DescribeUDiskSnapshotResponse is response schema for DescribeUDiskSnapshot action -type DescribeUDiskSnapshotResponse struct { - response.CommonBase - - // JSON 格式的Snapshot列表, 详细参见 UDiskSnapshotSet - DataSet []UDiskSnapshotSet - - // 根据过滤条件得到的总数 - TotalCount int -} - -// NewDescribeUDiskSnapshotRequest will create request of DescribeUDiskSnapshot action. -func (c *UDiskClient) NewDescribeUDiskSnapshotRequest() *DescribeUDiskSnapshotRequest { - req := &DescribeUDiskSnapshotRequest{} - - // setup request with client config - c.client.SetupRequest(req) - - // setup retryable with default retry policy (retry for non-create action and common error) - req.SetRetryable(true) - return req -} - -// DescribeUDiskSnapshot - 获取UDisk快照 -func (c *UDiskClient) DescribeUDiskSnapshot(req *DescribeUDiskSnapshotRequest) (*DescribeUDiskSnapshotResponse, error) { - var err error - var res DescribeUDiskSnapshotResponse - - err = c.client.InvokeAction("DescribeUDiskSnapshot", req, &res) - if err != nil { - return &res, err - } - - return &res, nil -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/types_udisk_snapshot_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/types_udisk_snapshot_set.go deleted file mode 100644 index 6ca32072a4..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/types_udisk_snapshot_set.go +++ /dev/null @@ -1,49 +0,0 @@ -package udisk - -/* -UDiskSnapshotSet - DescribeUDiskSnapshot - -this model is auto created by ucloud code generater for open api, -you can also see https://docs.ucloud.cn for detail. -*/ -type UDiskSnapshotSet struct { - - // 快照Id - SnapshotId string - - // 快照名称 - Name string - - // 快照的源UDisk的Id - UDiskId string - - // 快照的源UDisk的Name - UDiskName string - - // 创建时间 - CreateTime int - - // 过期时间 - ExpiredTime int - - // 容量单位GB - Size int - - // 快照描述 - Comment string - - // 快照状态,Normal:正常,Failed:失败,Creating:制作中 - Status string - - // 对应磁盘是否处于可用状态 - IsUDiskAvailable bool - - // 快照版本 - Version string - - // 对应磁盘制作快照时所挂载的主机 - UHostId string - - // 磁盘类型,0:数据盘,1:系统盘 - DiskType int -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/types_snapshot_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/types_snapshot_set.go index 17f6f5ed7a..6444e0b0e3 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/types_snapshot_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/types_snapshot_set.go @@ -38,9 +38,9 @@ type SnapshotSet struct { // 指定的制作快照时间,unix时间 SnapshotTime int - // 可用区id - Zone string - // 资源名字。本地盘对应主机名字,网络盘对应udisk名字 ResourceName string + + // 配置文件所在的可用区 + Zone string } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/utils/collection.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/utils/collection.go index f18b6e68f4..0d5d8ab7dd 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/private/utils/collection.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/utils/collection.go @@ -16,7 +16,7 @@ func MergeMap(args ...map[string]string) map[string]string { return m } -// SetMapIfNotExists will set a +// SetMapIfNotExists will set a key-value of the map if the key is not exists func SetMapIfNotExists(m map[string]string, k string, v string) { if _, ok := m[k]; !ok && v != "" { m[k] = v diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/utils/patch.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/utils/patch.go index 75988e977f..fdeeb85bfc 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/private/utils/patch.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/utils/patch.go @@ -25,11 +25,17 @@ func NewRegexpPatcher(regex string, repl string) *RegexpPatcher { // Patch will convert a bytes to another bytes with patch rules func (p *RegexpPatcher) Patch(body []byte) []byte { - return p.pattern.ReplaceAll(body, []byte(p.replacement)) + // TODO: ensure why the pattern will be disabled when there are multiple goroutines for bytes replacement + return []byte(p.PatchString(string(body))) +} + +// PatchString will convert a string to another string with patch rules +func (p *RegexpPatcher) PatchString(body string) string { + return p.pattern.ReplaceAllString(body, p.replacement) } // RetCodePatcher will convert `RetCode` as integer var RetCodePatcher = NewRegexpPatcher(`"RetCode":\s*"(\d+)"`, `"RetCode": $1`) -// PortPatcher will convert `RetCode` as integer +// PortPatcher will convert `Port` as integer var PortPatcher = NewRegexpPatcher(`"Port":\s*"(\d+)"`, `"Port": $1`) diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/modify_project.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/modify_project.go index 2696885145..21027cd696 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/modify_project.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/modify_project.go @@ -12,6 +12,9 @@ import ( type ModifyProjectRequest struct { request.CommonBase + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // 新的项目名称 ProjectName *string `required:"true"` } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/terminate_project.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/terminate_project.go index 9f635f0e33..b7ae516d0b 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/terminate_project.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/terminate_project.go @@ -11,6 +11,10 @@ import ( // TerminateProjectRequest is request schema for TerminateProject action type TerminateProjectRequest struct { request.CommonBase + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + } // TerminateProjectResponse is response schema for TerminateProject action diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/backup_udbinstance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/backup_udbinstance.go new file mode 100644 index 0000000000..60ae118329 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/backup_udbinstance.go @@ -0,0 +1,62 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB BackupUDBInstance + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// BackupUDBInstanceRequest is request schema for BackupUDBInstance action +type BackupUDBInstanceRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // DB实例Id,该值可以通过DescribeUDBInstance获取 + DBId *string `required:"true"` + + // 备份名称 + BackupName *string `required:"true"` + + // 是否使用黑名单备份,默认false + UseBlacklist *bool `required:"false"` +} + +// BackupUDBInstanceResponse is response schema for BackupUDBInstance action +type BackupUDBInstanceResponse struct { + response.CommonBase +} + +// NewBackupUDBInstanceRequest will create request of BackupUDBInstance action. +func (c *UDBClient) NewBackupUDBInstanceRequest() *BackupUDBInstanceRequest { + req := &BackupUDBInstanceRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(false) + return req +} + +// BackupUDBInstance - 备份UDB实例 +func (c *UDBClient) BackupUDBInstance(req *BackupUDBInstanceRequest) (*BackupUDBInstanceResponse, error) { + var err error + var res BackupUDBInstanceResponse + + err = c.client.InvokeAction("BackupUDBInstance", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/backup_udbinstance_binlog.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/backup_udbinstance_binlog.go new file mode 100644 index 0000000000..268775143d --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/backup_udbinstance_binlog.go @@ -0,0 +1,62 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB BackupUDBInstanceBinlog + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// BackupUDBInstanceBinlogRequest is request schema for BackupUDBInstanceBinlog action +type BackupUDBInstanceBinlogRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // DB实例Id,该值可以通过DescribeUDBInstance获取 + DBId *string `required:"true"` + + // 需要备份文件,可通过DescribeUDBInstanceBinlog获得 如果要传入多个文件名,以空格键分割,用单引号包含. + BackupFile *string `required:"true"` + + // DB备份文件名称 + BackupName *string `required:"false"` +} + +// BackupUDBInstanceBinlogResponse is response schema for BackupUDBInstanceBinlog action +type BackupUDBInstanceBinlogResponse struct { + response.CommonBase +} + +// NewBackupUDBInstanceBinlogRequest will create request of BackupUDBInstanceBinlog action. +func (c *UDBClient) NewBackupUDBInstanceBinlogRequest() *BackupUDBInstanceBinlogRequest { + req := &BackupUDBInstanceBinlogRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// BackupUDBInstanceBinlog - 备份UDB指定时间段的binlog列表 +func (c *UDBClient) BackupUDBInstanceBinlog(req *BackupUDBInstanceBinlogRequest) (*BackupUDBInstanceBinlogResponse, error) { + var err error + var res BackupUDBInstanceBinlogResponse + + err = c.client.InvokeAction("BackupUDBInstanceBinlog", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/backup_udbinstance_error_log.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/backup_udbinstance_error_log.go new file mode 100644 index 0000000000..5c76cdc857 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/backup_udbinstance_error_log.go @@ -0,0 +1,59 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB BackupUDBInstanceErrorLog + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// BackupUDBInstanceErrorLogRequest is request schema for BackupUDBInstanceErrorLog action +type BackupUDBInstanceErrorLogRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // DB实例Id,该值可以通过DescribeUDBInstance获取 + DBId *string `required:"true"` + + // 备份名称 + BackupName *string `required:"true"` +} + +// BackupUDBInstanceErrorLogResponse is response schema for BackupUDBInstanceErrorLog action +type BackupUDBInstanceErrorLogResponse struct { + response.CommonBase +} + +// NewBackupUDBInstanceErrorLogRequest will create request of BackupUDBInstanceErrorLog action. +func (c *UDBClient) NewBackupUDBInstanceErrorLogRequest() *BackupUDBInstanceErrorLogRequest { + req := &BackupUDBInstanceErrorLogRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// BackupUDBInstanceErrorLog - 备份UDB指定时间段的errorlog +func (c *UDBClient) BackupUDBInstanceErrorLog(req *BackupUDBInstanceErrorLogRequest) (*BackupUDBInstanceErrorLogResponse, error) { + var err error + var res BackupUDBInstanceErrorLogResponse + + err = c.client.InvokeAction("BackupUDBInstanceErrorLog", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/backup_udbinstance_slow_log.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/backup_udbinstance_slow_log.go new file mode 100644 index 0000000000..397376177d --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/backup_udbinstance_slow_log.go @@ -0,0 +1,62 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB BackupUDBInstanceSlowLog + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// BackupUDBInstanceSlowLogRequest is request schema for BackupUDBInstanceSlowLog action +type BackupUDBInstanceSlowLogRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // DB实例Id,该值可以通过DescribeUDBInstance获取 + DBId *string `required:"true"` + + // 过滤条件:起始时间(时间戳) + BeginTime *int `required:"true"` + + // 过滤条件:结束时间(时间戳) + EndTime *int `required:"true"` + + // 备份文件名称 + BackupName *string `required:"true"` +} + +// BackupUDBInstanceSlowLogResponse is response schema for BackupUDBInstanceSlowLog action +type BackupUDBInstanceSlowLogResponse struct { + response.CommonBase +} + +// NewBackupUDBInstanceSlowLogRequest will create request of BackupUDBInstanceSlowLog action. +func (c *UDBClient) NewBackupUDBInstanceSlowLogRequest() *BackupUDBInstanceSlowLogRequest { + req := &BackupUDBInstanceSlowLogRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// BackupUDBInstanceSlowLog - 备份UDB指定时间段的slowlog分析结果 +func (c *UDBClient) BackupUDBInstanceSlowLog(req *BackupUDBInstanceSlowLogRequest) (*BackupUDBInstanceSlowLogResponse, error) { + var err error + var res BackupUDBInstanceSlowLogResponse + + err = c.client.InvokeAction("BackupUDBInstanceSlowLog", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/check_recover_udbinstance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/check_recover_udbinstance.go new file mode 100644 index 0000000000..6700d3322e --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/check_recover_udbinstance.go @@ -0,0 +1,59 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB CheckRecoverUDBInstance + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// CheckRecoverUDBInstanceRequest is request schema for CheckRecoverUDBInstance action +type CheckRecoverUDBInstanceRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 源实例的Id(只支持普通版DB不支持高可用) + SrcDBId *string `required:"true"` +} + +// CheckRecoverUDBInstanceResponse is response schema for CheckRecoverUDBInstance action +type CheckRecoverUDBInstanceResponse struct { + response.CommonBase + + // 核查成功返回值为可以回档到的最近时刻,核查失败不返回 + LastestTime int +} + +// NewCheckRecoverUDBInstanceRequest will create request of CheckRecoverUDBInstance action. +func (c *UDBClient) NewCheckRecoverUDBInstanceRequest() *CheckRecoverUDBInstanceRequest { + req := &CheckRecoverUDBInstanceRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// CheckRecoverUDBInstance - 核查db是否可以使用回档功能 +func (c *UDBClient) CheckRecoverUDBInstance(req *CheckRecoverUDBInstanceRequest) (*CheckRecoverUDBInstanceResponse, error) { + var err error + var res CheckRecoverUDBInstanceResponse + + err = c.client.InvokeAction("CheckRecoverUDBInstance", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/check_udbinstance_to_haallowance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/check_udbinstance_to_haallowance.go new file mode 100644 index 0000000000..17aafbfa95 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/check_udbinstance_to_haallowance.go @@ -0,0 +1,56 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB CheckUDBInstanceToHAAllowance + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// CheckUDBInstanceToHAAllowanceRequest is request schema for CheckUDBInstanceToHAAllowance action +type CheckUDBInstanceToHAAllowanceRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 实例的Id,该值可以通过DescribeUDBInstance获取 + DBId *string `required:"true"` +} + +// CheckUDBInstanceToHAAllowanceResponse is response schema for CheckUDBInstanceToHAAllowance action +type CheckUDBInstanceToHAAllowanceResponse struct { + response.CommonBase + + // Yes ,No ,Yes即可以升级,No为不可以升级 + Allowance string +} + +// NewCheckUDBInstanceToHAAllowanceRequest will create request of CheckUDBInstanceToHAAllowance action. +func (c *UDBClient) NewCheckUDBInstanceToHAAllowanceRequest() *CheckUDBInstanceToHAAllowanceRequest { + req := &CheckUDBInstanceToHAAllowanceRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// CheckUDBInstanceToHAAllowance - 核查db是否可以升级为高可用 +func (c *UDBClient) CheckUDBInstanceToHAAllowance(req *CheckUDBInstanceToHAAllowanceRequest) (*CheckUDBInstanceToHAAllowanceResponse, error) { + var err error + var res CheckUDBInstanceToHAAllowanceResponse + + err = c.client.InvokeAction("CheckUDBInstanceToHAAllowance", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/clear_udblog.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/clear_udblog.go new file mode 100644 index 0000000000..c356620cb4 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/clear_udblog.go @@ -0,0 +1,62 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB ClearUDBLog + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// ClearUDBLogRequest is request schema for ClearUDBLog action +type ClearUDBLogRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // DB实例的id,该值可以通过DescribeUDBInstance获取 + DBId *string `required:"true"` + + // 日志类型,10-error(暂不支持)、20-slow(暂不支持 )、30-binlog + LogType *int `required:"true"` + + // 删除时间点(至少前一天)之前log,采用时间戳(秒),默认当 前时间点前一天 + BeforeTime *int `required:"false"` +} + +// ClearUDBLogResponse is response schema for ClearUDBLog action +type ClearUDBLogResponse struct { + response.CommonBase +} + +// NewClearUDBLogRequest will create request of ClearUDBLog action. +func (c *UDBClient) NewClearUDBLogRequest() *ClearUDBLogRequest { + req := &ClearUDBLogRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// ClearUDBLog - 清除UDB实例的log +func (c *UDBClient) ClearUDBLog(req *ClearUDBLogRequest) (*ClearUDBLogResponse, error) { + var err error + var res ClearUDBLogResponse + + err = c.client.InvokeAction("ClearUDBLog", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/client.go new file mode 100644 index 0000000000..7e41f44399 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/client.go @@ -0,0 +1,19 @@ +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud" + "github.com/ucloud/ucloud-sdk-go/ucloud/auth" +) + +// UDBClient is the client of UDB +type UDBClient struct { + client *ucloud.Client +} + +// NewClient will return a instance of UDBClient +func NewClient(config *ucloud.Config, credential *auth.Credential) *UDBClient { + client := ucloud.NewClient(config, credential) + return &UDBClient{ + client: client, + } +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/create_udbinstance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/create_udbinstance.go new file mode 100644 index 0000000000..81aa09ae51 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/create_udbinstance.go @@ -0,0 +1,137 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB CreateUDBInstance + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// CreateUDBInstanceRequest is request schema for CreateUDBInstance action +type CreateUDBInstanceRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 实例名称,至少6位 + Name *string `required:"true"` + + // 管理员密码 + AdminPassword *string `required:"true"` + + // DB类型id,mysql/mongodb/postgesql按版本细分 1:mysql-5.1,2:mysql-5.5,3:percona-5.5,4:mysql-5.6,5:percona-5.6,6:mysql-5.7,7:percona-5.7,8:mariadb-10.0,9:mongodb-2.4,10:mongodb-2.6,11:mongodb-3.0,12:mongodb-3.2,13:postgresql-9.4,14:postgresql-9.6,14:postgresql-10.4 + DBTypeId *string `required:"true"` + + // 端口号,mysql默认3306,mongodb默认27017,postgresql默认5432 + Port *int `required:"true"` + + // 磁盘空间(GB), 暂时支持20G - 3000G + DiskSpace *int `required:"true"` + + // DB实例使用的配置参数组id + ParamGroupId *int `required:"true"` + + // 内存限制(MB),目前支持以下几档 1000M/2000M/4000M/ 6000M/8000M/12000M/16000M/ 24000M/32000M/48000M/ 64000M/96000M + MemoryLimit *int `required:"true"` + + // 当DB类型(DBTypeId)为mongodb时,需要指定mongo的角色,可选值为configsrv (配置节点),shardsrv (数据节点) + ClusterRole *string `required:"false"` + + // Year, Month, Dynamic,Trial,默认: Month + ChargeType *string `required:"false"` + + // 购买时长,默认值1 + Quantity *int `required:"false"` + + // 管理员帐户名,默认root + AdminUser *string `required:"false"` + + // 备份策略,每周备份数量,默认7次 + BackupCount *int `required:"false"` + + // 备份策略,备份开始时间,单位小时计,默认1点 + BackupTime *int `required:"false"` + + // 备份策略,备份时间间隔,单位小时计,默认24小时 + BackupDuration *int `required:"false"` + + // 备份id,如果指定,则表明从备份恢复实例 + BackupId *int `required:"false"` + + // 是否使用SSD,默认为false + UseSSD *bool `required:"false"` + + // SSD类型,可选值为"SATA"、"PCI-E",如果UseSSD为true ,则必选 + SSDType *string `required:"false"` + + // UDB实例模式类型, 可选值如下: "Normal": 普通版UDB实例 "HA": 高可用版UDB实例 默认是"Normal" + InstanceMode *string `required:"false"` + + // 专区ID信息(如果这个参数存在这说明是在专区中创建DB) + UDBCId *string `required:"false"` + + // cpu核数 + CPU *int `required:"false"` + + // UDB数据库机型 + InstanceType *string `required:"false"` + + // 跨可用区高可用备库所在可用区,参见 [可用区列表](../summary/regionlist.html) + BackupZone *string `required:"false"` + + // 子网ID + SubnetId *string `required:"false"` + + // VPC的ID + VPCId *string `required:"false"` + + // 是否开启异步高可用,默认不填,可置为true + DisableSemisync *bool `required:"false"` + + // 使用的代金券id + CouponId *string `required:"false"` + + // 业务组 + Tag *string `required:"false"` +} + +// CreateUDBInstanceResponse is response schema for CreateUDBInstance action +type CreateUDBInstanceResponse struct { + response.CommonBase + + // db实例id + DBId string +} + +// NewCreateUDBInstanceRequest will create request of CreateUDBInstance action. +func (c *UDBClient) NewCreateUDBInstanceRequest() *CreateUDBInstanceRequest { + req := &CreateUDBInstanceRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(false) + return req +} + +// CreateUDBInstance - 创建UDB实例(包括创建mysql master节点、mongodb primary/configsvr节点和从备份恢复实例) +func (c *UDBClient) CreateUDBInstance(req *CreateUDBInstanceRequest) (*CreateUDBInstanceResponse, error) { + var err error + var res CreateUDBInstanceResponse + + err = c.client.InvokeAction("CreateUDBInstance", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/create_udbinstance_by_recovery.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/create_udbinstance_by_recovery.go new file mode 100644 index 0000000000..70eaaf684a --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/create_udbinstance_by_recovery.go @@ -0,0 +1,80 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB CreateUDBInstanceByRecovery + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// CreateUDBInstanceByRecoveryRequest is request schema for CreateUDBInstanceByRecovery action +type CreateUDBInstanceByRecoveryRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 实例名称,至少6位 + Name *string `required:"true"` + + // 源实例的Id + SrcDBId *string `required:"true"` + + // 恢复到某个时间点的时间戳(UTC时间格式,默认单位秒) + RecoveryTime *int `required:"true"` + + // 指定是否是否使用SSD,默认使用主库的配置 + UseSSD *bool `required:"false"` + + // Year, Month, Dynamic,Trial,默认: Dynamic + ChargeType *string `required:"false"` + + // 购买时长,默认值1 + Quantity *int `required:"false"` + + // 专区的Id + UDBCId *string `required:"false"` + + // 使用的代金券id + CouponId *string `required:"false"` +} + +// CreateUDBInstanceByRecoveryResponse is response schema for CreateUDBInstanceByRecovery action +type CreateUDBInstanceByRecoveryResponse struct { + response.CommonBase + + // db实例id + DBId string +} + +// NewCreateUDBInstanceByRecoveryRequest will create request of CreateUDBInstanceByRecovery action. +func (c *UDBClient) NewCreateUDBInstanceByRecoveryRequest() *CreateUDBInstanceByRecoveryRequest { + req := &CreateUDBInstanceByRecoveryRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(false) + return req +} + +// CreateUDBInstanceByRecovery - 创建db,将新创建的db恢复到指定db某个指定时间点 +func (c *UDBClient) CreateUDBInstanceByRecovery(req *CreateUDBInstanceByRecoveryRequest) (*CreateUDBInstanceByRecoveryResponse, error) { + var err error + var res CreateUDBInstanceByRecoveryResponse + + err = c.client.InvokeAction("CreateUDBInstanceByRecovery", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/create_udbparam_group.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/create_udbparam_group.go new file mode 100644 index 0000000000..853a7ca104 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/create_udbparam_group.go @@ -0,0 +1,71 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB CreateUDBParamGroup + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// CreateUDBParamGroupRequest is request schema for CreateUDBParamGroup action +type CreateUDBParamGroupRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 新配置参数组名称 + GroupName *string `required:"true"` + + // 参数组描述 + Description *string `required:"true"` + + // 源参数组id + SrcGroupId *int `required:"true"` + + // DB类型id,mysql/mongodb/postgesql按版本细分 1:mysql-5.1,2:mysql-5.5,3:percona-5.5,4:mysql-5.6,5:percona-5.6,6:mysql-5.7,7:percona-5.7,8:mariadb-10.0,9:mongodb-2.4,10:mongodb-2.6,11:mongodb-3.0,12:mongodb-3.2,13:postgresql-9.4,14:postgresql-9.6 + DBTypeId *string `required:"true"` + + // 是否是地域级别的配置文件,默认是false + RegionFlag *bool `required:"false"` +} + +// CreateUDBParamGroupResponse is response schema for CreateUDBParamGroup action +type CreateUDBParamGroupResponse struct { + response.CommonBase + + // 新配置参数组id + GroupId int +} + +// NewCreateUDBParamGroupRequest will create request of CreateUDBParamGroup action. +func (c *UDBClient) NewCreateUDBParamGroupRequest() *CreateUDBParamGroupRequest { + req := &CreateUDBParamGroupRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(false) + return req +} + +// CreateUDBParamGroup - 从已有配置文件创建新配置文件 +func (c *UDBClient) CreateUDBParamGroup(req *CreateUDBParamGroupRequest) (*CreateUDBParamGroupResponse, error) { + var err error + var res CreateUDBParamGroupResponse + + err = c.client.InvokeAction("CreateUDBParamGroup", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/create_udbreplication_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/create_udbreplication_instance.go new file mode 100644 index 0000000000..76c4ed2495 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/create_udbreplication_instance.go @@ -0,0 +1,74 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB CreateUDBReplicationInstance + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// CreateUDBReplicationInstanceRequest is request schema for CreateUDBReplicationInstance action +type CreateUDBReplicationInstanceRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // primary节点的DBId,该值可以通过DescribeUDBInstance获取 + SrcId *string `required:"true"` + + // 实例名称,至少6位 + Name *string `required:"true"` + + // 端口号,默认27017,取值范围3306至65535。 + Port *int `required:"false"` + + // 是否是仲裁节点,默认false,仲裁节点按最小机型创建 + IsArbiter *bool `required:"false"` + + // 是否使用SSD,默认不使用 + UseSSD *bool `required:"false"` + + // 使用的代金券id + CouponId *string `required:"false"` +} + +// CreateUDBReplicationInstanceResponse is response schema for CreateUDBReplicationInstance action +type CreateUDBReplicationInstanceResponse struct { + response.CommonBase + + // 创建从节点的DBId + DBId string +} + +// NewCreateUDBReplicationInstanceRequest will create request of CreateUDBReplicationInstance action. +func (c *UDBClient) NewCreateUDBReplicationInstanceRequest() *CreateUDBReplicationInstanceRequest { + req := &CreateUDBReplicationInstanceRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(false) + return req +} + +// CreateUDBReplicationInstance - 创建MongoDB的副本节点(包括仲裁) +func (c *UDBClient) CreateUDBReplicationInstance(req *CreateUDBReplicationInstanceRequest) (*CreateUDBReplicationInstanceResponse, error) { + var err error + var res CreateUDBReplicationInstanceResponse + + err = c.client.InvokeAction("CreateUDBReplicationInstance", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/create_udbroute_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/create_udbroute_instance.go new file mode 100644 index 0000000000..2d585c6575 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/create_udbroute_instance.go @@ -0,0 +1,89 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB CreateUDBRouteInstance + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// CreateUDBRouteInstanceRequest is request schema for CreateUDBRouteInstance action +type CreateUDBRouteInstanceRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // DB类型id,mongodb按版本细分有1:mongodb-2.4,2:mongodb-2.6,3:mongodb-3.0,4:mongodb-3.2 + DBTypeId *string `required:"true"` + + // 实例名称,至少6位 + Name *string `required:"true"` + + // 端口号,mongodb默认27017 + Port *int `required:"true"` + + // DB实例使用的配置参数组id + ParamGroupId *int `required:"true"` + + // 内存限制(MB),目前支持以下几档 600M/1500M/3000M /6000M/15000M/30000M + MemoryLimit *int `required:"true"` + + // 磁盘空间(GB), 暂时支持20G - 500G + DiskSpace *int `required:"true"` + + // 配置服务器的dbid,允许一个或者三个 + ConfigsvrId []string `required:"true"` + + // Year, Month, Dynamic,Trial,默认: Month + ChargeType *string `required:"false"` + + // 购买时长,默认值1 + Quantity *int `required:"false"` + + // 是否使用SSD,默认为false + UseSSD *bool `required:"false"` + + // 使用的代金券id + CouponId *string `required:"false"` +} + +// CreateUDBRouteInstanceResponse is response schema for CreateUDBRouteInstance action +type CreateUDBRouteInstanceResponse struct { + response.CommonBase + + // db实例id + DBId string +} + +// NewCreateUDBRouteInstanceRequest will create request of CreateUDBRouteInstance action. +func (c *UDBClient) NewCreateUDBRouteInstanceRequest() *CreateUDBRouteInstanceRequest { + req := &CreateUDBRouteInstanceRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(false) + return req +} + +// CreateUDBRouteInstance - 创建mongos实例 +func (c *UDBClient) CreateUDBRouteInstance(req *CreateUDBRouteInstanceRequest) (*CreateUDBRouteInstanceResponse, error) { + var err error + var res CreateUDBRouteInstanceResponse + + err = c.client.InvokeAction("CreateUDBRouteInstance", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/create_udbslave.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/create_udbslave.go new file mode 100644 index 0000000000..5d2a1f8edc --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/create_udbslave.go @@ -0,0 +1,92 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB CreateUDBSlave + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// CreateUDBSlaveRequest is request schema for CreateUDBSlave action +type CreateUDBSlaveRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // master实例的DBId,该值可以通过DescribeUDBInstance获取 + SrcId *string `required:"true"` + + // 实例名称,至少6位 + Name *string `required:"true"` + + // 端口号,mysql默认3306 + Port *int `required:"false"` + + // 是否使用SSD,默认为false + UseSSD *bool `required:"false"` + + // SSD类型,可选值为"SATA"、"PCI-E",如果UseSSD为true ,则必选 + SSDType *string `required:"false"` + + // 内存限制(MB),目前支持以下几档 1000M/2000M/4000M/ 6000M/8000M/12000M/16000M/ 24000M/32000M/48000M/ 64000M/96000M + MemoryLimit *int `required:"false"` + + // 磁盘空间(GB), 暂时支持20G - 3000G(API支持,前端暂时只开放内存定制) + DiskSpace *int `required:"false"` + + // 是否锁主库,默认为true + IsLock *bool `required:"false"` + + // UDB实例部署模式,可选值如下:Normal: 普通单点实例HA: 高可用部署实例 + InstanceMode *string `required:"false"` + + // UDB实例类型:Normal和SATA_SSD + InstanceType *string `required:"false"` + + // 使用的代金券id + CouponId *string `required:"false"` + + // 配置参数组 ID + ParamGroupId *string `required:"false"` +} + +// CreateUDBSlaveResponse is response schema for CreateUDBSlave action +type CreateUDBSlaveResponse struct { + response.CommonBase + + // 创建slave的DBId + DBId string +} + +// NewCreateUDBSlaveRequest will create request of CreateUDBSlave action. +func (c *UDBClient) NewCreateUDBSlaveRequest() *CreateUDBSlaveRequest { + req := &CreateUDBSlaveRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(false) + return req +} + +// CreateUDBSlave - 创建UDB实例的slave +func (c *UDBClient) CreateUDBSlave(req *CreateUDBSlaveRequest) (*CreateUDBSlaveResponse, error) { + var err error + var res CreateUDBSlaveResponse + + err = c.client.InvokeAction("CreateUDBSlave", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/delete_udbbackup.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/delete_udbbackup.go new file mode 100644 index 0000000000..a345c726a2 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/delete_udbbackup.go @@ -0,0 +1,59 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DeleteUDBBackup + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DeleteUDBBackupRequest is request schema for DeleteUDBBackup action +type DeleteUDBBackupRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 备份id,可通过DescribeUDBBackup获得 + BackupId *int `required:"true"` + + // 跨可用区高可用备库所在可用区,参见[可用区列表] + BackupZone *string `required:"false"` +} + +// DeleteUDBBackupResponse is response schema for DeleteUDBBackup action +type DeleteUDBBackupResponse struct { + response.CommonBase +} + +// NewDeleteUDBBackupRequest will create request of DeleteUDBBackup action. +func (c *UDBClient) NewDeleteUDBBackupRequest() *DeleteUDBBackupRequest { + req := &DeleteUDBBackupRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DeleteUDBBackup - 删除UDB实例备份 +func (c *UDBClient) DeleteUDBBackup(req *DeleteUDBBackupRequest) (*DeleteUDBBackupResponse, error) { + var err error + var res DeleteUDBBackupResponse + + err = c.client.InvokeAction("DeleteUDBBackup", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/delete_udbinstance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/delete_udbinstance.go new file mode 100644 index 0000000000..0996ba4e57 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/delete_udbinstance.go @@ -0,0 +1,59 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DeleteUDBInstance + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DeleteUDBInstanceRequest is request schema for DeleteUDBInstance action +type DeleteUDBInstanceRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // DB实例的id,该值可以通过DescribeUDBInstance获取 + DBId *string `required:"true"` + + // 专区ID + UDBCId *string `required:"false"` +} + +// DeleteUDBInstanceResponse is response schema for DeleteUDBInstance action +type DeleteUDBInstanceResponse struct { + response.CommonBase +} + +// NewDeleteUDBInstanceRequest will create request of DeleteUDBInstance action. +func (c *UDBClient) NewDeleteUDBInstanceRequest() *DeleteUDBInstanceRequest { + req := &DeleteUDBInstanceRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DeleteUDBInstance - 删除UDB实例 +func (c *UDBClient) DeleteUDBInstance(req *DeleteUDBInstanceRequest) (*DeleteUDBInstanceResponse, error) { + var err error + var res DeleteUDBInstanceResponse + + err = c.client.InvokeAction("DeleteUDBInstance", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/delete_udblog_package.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/delete_udblog_package.go new file mode 100644 index 0000000000..9bad1a5846 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/delete_udblog_package.go @@ -0,0 +1,59 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DeleteUDBLogPackage + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DeleteUDBLogPackageRequest is request schema for DeleteUDBLogPackage action +type DeleteUDBLogPackageRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 日志包id,可通过DescribeUDBLogPackage获得 + BackupId *int `required:"true"` + + // 跨可用区高可用备库所在可用区 + BackupZone *string `required:"false"` +} + +// DeleteUDBLogPackageResponse is response schema for DeleteUDBLogPackage action +type DeleteUDBLogPackageResponse struct { + response.CommonBase +} + +// NewDeleteUDBLogPackageRequest will create request of DeleteUDBLogPackage action. +func (c *UDBClient) NewDeleteUDBLogPackageRequest() *DeleteUDBLogPackageRequest { + req := &DeleteUDBLogPackageRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DeleteUDBLogPackage - 删除UDB日志包 +func (c *UDBClient) DeleteUDBLogPackage(req *DeleteUDBLogPackageRequest) (*DeleteUDBLogPackageResponse, error) { + var err error + var res DeleteUDBLogPackageResponse + + err = c.client.InvokeAction("DeleteUDBLogPackage", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/delete_udbparam_group.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/delete_udbparam_group.go new file mode 100644 index 0000000000..b85fc95316 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/delete_udbparam_group.go @@ -0,0 +1,59 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DeleteUDBParamGroup + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DeleteUDBParamGroupRequest is request schema for DeleteUDBParamGroup action +type DeleteUDBParamGroupRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 参数组id,可通过DescribeUDBParamGroup获取 + GroupId *int `required:"true"` + + // 是否属于地域级别 + RegionFlag *bool `required:"false"` +} + +// DeleteUDBParamGroupResponse is response schema for DeleteUDBParamGroup action +type DeleteUDBParamGroupResponse struct { + response.CommonBase +} + +// NewDeleteUDBParamGroupRequest will create request of DeleteUDBParamGroup action. +func (c *UDBClient) NewDeleteUDBParamGroupRequest() *DeleteUDBParamGroupRequest { + req := &DeleteUDBParamGroupRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DeleteUDBParamGroup - 删除配置参数组 +func (c *UDBClient) DeleteUDBParamGroup(req *DeleteUDBParamGroupRequest) (*DeleteUDBParamGroupResponse, error) { + var err error + var res DeleteUDBParamGroupResponse + + err = c.client.InvokeAction("DeleteUDBParamGroup", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbbackup.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbbackup.go new file mode 100644 index 0000000000..0ac0da071a --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbbackup.go @@ -0,0 +1,83 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DescribeUDBBackup + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DescribeUDBBackupRequest is request schema for DescribeUDBBackup action +type DescribeUDBBackupRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 分页显示的起始偏移,列表操作则指定 + Offset *int `required:"true"` + + // 分页显示的条目数,列表操作则指定 + Limit *int `required:"true"` + + // DB实例Id,如果指定,则只获取该db的备份信息 该值可以通过DescribeUDBInstance获取 + DBId *string `required:"false"` + + // 备份类型,取值为0或1,0表示自动,1表示手动 + BackupType *int `required:"false"` + + // 过滤条件:起始时间(Unix时间戳) + BeginTime *int `required:"false"` + + // 过滤条件:结束时间(Unix时间戳) + EndTime *int `required:"false"` + + // 如果未指定GroupId,则可选是否选取特定DB类型的配置(sql, nosql, postgresql, sqlserver) + ClassType *string `required:"false"` + + // 如果填了BackupId, 那么只拉取这个备份的记录 + BackupId *int `required:"false"` +} + +// DescribeUDBBackupResponse is response schema for DescribeUDBBackup action +type DescribeUDBBackupResponse struct { + response.CommonBase + + // 备份信息 参照UDBBackupSet + DataSet []UDBBackupSet + + // 满足条件备份总数,如果指定dbid,则是该db备份总数 + TotalCount int +} + +// NewDescribeUDBBackupRequest will create request of DescribeUDBBackup action. +func (c *UDBClient) NewDescribeUDBBackupRequest() *DescribeUDBBackupRequest { + req := &DescribeUDBBackupRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DescribeUDBBackup - 列表UDB实例备份信息.Zone不填表示多可用区,填代表单可用区 +func (c *UDBClient) DescribeUDBBackup(req *DescribeUDBBackupRequest) (*DescribeUDBBackupResponse, error) { + var err error + var res DescribeUDBBackupResponse + + err = c.client.InvokeAction("DescribeUDBBackup", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbbackup_blacklist.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbbackup_blacklist.go new file mode 100644 index 0000000000..bb5798c31f --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbbackup_blacklist.go @@ -0,0 +1,59 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DescribeUDBBackupBlacklist + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DescribeUDBBackupBlacklistRequest is request schema for DescribeUDBBackupBlacklist action +type DescribeUDBBackupBlacklistRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // DB实例Id,该值可以通过DescribeUDBInstance获取 + DBId *string `required:"true"` +} + +// DescribeUDBBackupBlacklistResponse is response schema for DescribeUDBBackupBlacklist action +type DescribeUDBBackupBlacklistResponse struct { + response.CommonBase + + // DB的黑名单列表, db.%为指定库 dbname.tablename为指定表 + Blacklist string +} + +// NewDescribeUDBBackupBlacklistRequest will create request of DescribeUDBBackupBlacklist action. +func (c *UDBClient) NewDescribeUDBBackupBlacklistRequest() *DescribeUDBBackupBlacklistRequest { + req := &DescribeUDBBackupBlacklistRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DescribeUDBBackupBlacklist - 获取UDB实例的备份黑名单 +func (c *UDBClient) DescribeUDBBackupBlacklist(req *DescribeUDBBackupBlacklistRequest) (*DescribeUDBBackupBlacklistResponse, error) { + var err error + var res DescribeUDBBackupBlacklistResponse + + err = c.client.InvokeAction("DescribeUDBBackupBlacklist", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbbinlog_backup_url.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbbinlog_backup_url.go new file mode 100644 index 0000000000..ea39b02b6c --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbbinlog_backup_url.go @@ -0,0 +1,59 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DescribeUDBBinlogBackupURL + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DescribeUDBBinlogBackupURLRequest is request schema for DescribeUDBBinlogBackupURL action +type DescribeUDBBinlogBackupURLRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // DB实例Id + DBId *string `required:"true"` + + // DB实例备份ID + BackupId *int `required:"true"` +} + +// DescribeUDBBinlogBackupURLResponse is response schema for DescribeUDBBinlogBackupURL action +type DescribeUDBBinlogBackupURLResponse struct { + response.CommonBase + + // DB实例备份文件的地址 + BackupPath string +} + +// NewDescribeUDBBinlogBackupURLRequest will create request of DescribeUDBBinlogBackupURL action. +func (c *UDBClient) NewDescribeUDBBinlogBackupURLRequest() *DescribeUDBBinlogBackupURLRequest { + req := &DescribeUDBBinlogBackupURLRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DescribeUDBBinlogBackupURL - 获取UDB的Binlog备份地址 +func (c *UDBClient) DescribeUDBBinlogBackupURL(req *DescribeUDBBinlogBackupURLRequest) (*DescribeUDBBinlogBackupURLResponse, error) { + var err error + var res DescribeUDBBinlogBackupURLResponse + + err = c.client.InvokeAction("DescribeUDBBinlogBackupURL", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance.go new file mode 100644 index 0000000000..245a442c2f --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance.go @@ -0,0 +1,80 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DescribeUDBInstance + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DescribeUDBInstanceRequest is request schema for DescribeUDBInstance action +type DescribeUDBInstanceRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // DB种类,分为sql和nosql,如果是列表操作,则需要指定 + ClassType *string `required:"true"` + + // 分页显示起始偏移位置,列表操作则指定 + Offset *int `required:"true"` + + // 分页显示数量,列表操作则指定 + Limit *int `required:"true"` + + // DB实例id,如果指定则获取描述,否则为列表操作, 指定Offset/Limit/ClassType DBId可通过DescribeUDBInstance获取 + DBId *string `required:"false"` + + // 是否查看专区里面DB + IsInUDBC *bool `required:"false"` + + // IsInUDBC为True,UDBCId为空,说明查看整个可用区的专区的db,如果UDBId不为空则只查看此专区下面的db + UDBCId *string `required:"false"` + + // 当只获取这个特定DBId的信息时,如果有该选项,那么把这个DBId实例的所有从库信息一起拉取并返回 + IncludeSlaves *bool `required:"false"` +} + +// DescribeUDBInstanceResponse is response schema for DescribeUDBInstance action +type DescribeUDBInstanceResponse struct { + response.CommonBase + + // DB实例信息列表 UDBInstanceSet + DataSet []UDBInstanceSet + + // 用户db组的数量,对于 mysql: 主从结对数量,没有slave,则只有master mongodb: 副本集数量 + TotalCount int +} + +// NewDescribeUDBInstanceRequest will create request of DescribeUDBInstance action. +func (c *UDBClient) NewDescribeUDBInstanceRequest() *DescribeUDBInstanceRequest { + req := &DescribeUDBInstanceRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DescribeUDBInstance - 获取UDB实例信息,支持两类操作:(1)指定DBId用于获取该db的信息;(2)指定ClassType、Offset、Limit用于列表操作,查询某一个类型db。 +func (c *UDBClient) DescribeUDBInstance(req *DescribeUDBInstanceRequest) (*DescribeUDBInstanceResponse, error) { + var err error + var res DescribeUDBInstanceResponse + + err = c.client.InvokeAction("DescribeUDBInstance", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_backup_state.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_backup_state.go new file mode 100644 index 0000000000..70eb208185 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_backup_state.go @@ -0,0 +1,68 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DescribeUDBInstanceBackupState + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DescribeUDBInstanceBackupStateRequest is request schema for DescribeUDBInstanceBackupState action +type DescribeUDBInstanceBackupStateRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 备份记录ID + BackupId *int `required:"true"` + + // 跨可用区高可用备库所在可用区,参见[可用区列表] + BackupZone *string `required:"false"` +} + +// DescribeUDBInstanceBackupStateResponse is response schema for DescribeUDBInstanceBackupState action +type DescribeUDBInstanceBackupStateResponse struct { + response.CommonBase + + // 备份状态 0 Backuping // 备份中 1 Success // 备份成功 2 Failed // 备份失败 3 Expired // 备份过期 + State string + + // 备份所占空间大小 + BackupSize int + + // 备份截止时间 + BackupEndTime int +} + +// NewDescribeUDBInstanceBackupStateRequest will create request of DescribeUDBInstanceBackupState action. +func (c *UDBClient) NewDescribeUDBInstanceBackupStateRequest() *DescribeUDBInstanceBackupStateRequest { + req := &DescribeUDBInstanceBackupStateRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DescribeUDBInstanceBackupState - 获取UDB实例备份状态 +func (c *UDBClient) DescribeUDBInstanceBackupState(req *DescribeUDBInstanceBackupStateRequest) (*DescribeUDBInstanceBackupStateResponse, error) { + var err error + var res DescribeUDBInstanceBackupStateResponse + + err = c.client.InvokeAction("DescribeUDBInstanceBackupState", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_backup_url.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_backup_url.go new file mode 100644 index 0000000000..51fc30f7f8 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_backup_url.go @@ -0,0 +1,62 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DescribeUDBInstanceBackupURL + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DescribeUDBInstanceBackupURLRequest is request schema for DescribeUDBInstanceBackupURL action +type DescribeUDBInstanceBackupURLRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // DB实例Id,该值可通过DescribeUDBInstance获取 + DBId *string `required:"true"` + + // DB实例备份ID,该值可以通过DescribeUDBBackup获取 + BackupId *int `required:"true"` +} + +// DescribeUDBInstanceBackupURLResponse is response schema for DescribeUDBInstanceBackupURL action +type DescribeUDBInstanceBackupURLResponse struct { + response.CommonBase + + // DB实例备份文件公网的地址 + BackupPath string +} + +// NewDescribeUDBInstanceBackupURLRequest will create request of DescribeUDBInstanceBackupURL action. +func (c *UDBClient) NewDescribeUDBInstanceBackupURLRequest() *DescribeUDBInstanceBackupURLRequest { + req := &DescribeUDBInstanceBackupURLRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DescribeUDBInstanceBackupURL - 获取UDB备份下载地址 +func (c *UDBClient) DescribeUDBInstanceBackupURL(req *DescribeUDBInstanceBackupURLRequest) (*DescribeUDBInstanceBackupURLResponse, error) { + var err error + var res DescribeUDBInstanceBackupURLResponse + + err = c.client.InvokeAction("DescribeUDBInstanceBackupURL", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_binlog.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_binlog.go new file mode 100644 index 0000000000..1033e6890e --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_binlog.go @@ -0,0 +1,65 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DescribeUDBInstanceBinlog + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DescribeUDBInstanceBinlogRequest is request schema for DescribeUDBInstanceBinlog action +type DescribeUDBInstanceBinlogRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // DB实例Id + DBId *string `required:"true"` + + // 过滤条件:起始时间(时间戳) + BeginTime *int `required:"true"` + + // 过滤条件:结束时间(时间戳) + EndTime *int `required:"true"` +} + +// DescribeUDBInstanceBinlogResponse is response schema for DescribeUDBInstanceBinlog action +type DescribeUDBInstanceBinlogResponse struct { + response.CommonBase + + // 获取的Binlog信息列表 UDBInstanceBinlogSet + DataSet []UDBInstanceBinlogSet +} + +// NewDescribeUDBInstanceBinlogRequest will create request of DescribeUDBInstanceBinlog action. +func (c *UDBClient) NewDescribeUDBInstanceBinlogRequest() *DescribeUDBInstanceBinlogRequest { + req := &DescribeUDBInstanceBinlogRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DescribeUDBInstanceBinlog - 获取UDB指定时间段的binlog列表 +func (c *UDBClient) DescribeUDBInstanceBinlog(req *DescribeUDBInstanceBinlogRequest) (*DescribeUDBInstanceBinlogResponse, error) { + var err error + var res DescribeUDBInstanceBinlogResponse + + err = c.client.InvokeAction("DescribeUDBInstanceBinlog", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_binlog_backup_state.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_binlog_backup_state.go new file mode 100644 index 0000000000..68f51dd3b2 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_binlog_backup_state.go @@ -0,0 +1,62 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DescribeUDBInstanceBinlogBackupState + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DescribeUDBInstanceBinlogBackupStateRequest is request schema for DescribeUDBInstanceBinlogBackupState action +type DescribeUDBInstanceBinlogBackupStateRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 备份记录ID + BackupId *int `required:"true"` + + // 跨可用区高可用备库所在可用区 + BackupZone *string `required:"false"` +} + +// DescribeUDBInstanceBinlogBackupStateResponse is response schema for DescribeUDBInstanceBinlogBackupState action +type DescribeUDBInstanceBinlogBackupStateResponse struct { + response.CommonBase + + // 备份状态 0 Backuping // 备份中 1 Success // 备份成功 2 Failed // 备份失败 3 Expired // 备份过期 + State string +} + +// NewDescribeUDBInstanceBinlogBackupStateRequest will create request of DescribeUDBInstanceBinlogBackupState action. +func (c *UDBClient) NewDescribeUDBInstanceBinlogBackupStateRequest() *DescribeUDBInstanceBinlogBackupStateRequest { + req := &DescribeUDBInstanceBinlogBackupStateRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DescribeUDBInstanceBinlogBackupState - 获取udb实例备份状态 +func (c *UDBClient) DescribeUDBInstanceBinlogBackupState(req *DescribeUDBInstanceBinlogBackupStateRequest) (*DescribeUDBInstanceBinlogBackupStateResponse, error) { + var err error + var res DescribeUDBInstanceBinlogBackupStateResponse + + err = c.client.InvokeAction("DescribeUDBInstanceBinlogBackupState", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_price.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_price.go new file mode 100644 index 0000000000..f90938adfa --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_price.go @@ -0,0 +1,80 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DescribeUDBInstancePrice + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DescribeUDBInstancePriceRequest is request schema for DescribeUDBInstancePrice action +type DescribeUDBInstancePriceRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // 内存限制(MB),单位为MB.目前支持:1000-96000 + MemoryLimit *int `required:"true"` + + // 磁盘空间(GB),暂时支持20(GB) - 3000(GB), 输入不带单位 + DiskSpace *int `required:"true"` + + // 购买DB实例数量,最大数量为10台, 默认为1台 + Count *int `required:"false"` + + // Year,按年付费; Month,按月付费 Dynamic,按需付费(需开启权限) Trial,试用(需开启权限)默认为月付 + ChargeType *string `required:"false"` + + // DB购买多少个"计费时间单位",默认值为1。比如:买2个月,Quantity就是2。如果计费单位是“按月”,并且Quantity为0,表示“购买到月底” + Quantity *int `required:"false"` + + // 是否使用SSD,默认为false + UseSSD *bool `required:"false"` + + // SSD类型,可选值为"SATA"、"PCI-E",如果UseSSD为true ,则必填 + SSDType *string `required:"false"` + + // UDB实例的DB版本字符串, 默认值为mysql-5.6 + DBTypeId *string `required:"false"` + + // 实例的部署类型。可选值为:Normal: 普通单点实例,HA: 高可用部署实例,默认是Normal + InstanceMode *string `required:"false"` +} + +// DescribeUDBInstancePriceResponse is response schema for DescribeUDBInstancePrice action +type DescribeUDBInstancePriceResponse struct { + response.CommonBase + + // 价格 参照UDBInstancePriceSet + DataSet []UDBInstancePriceSet +} + +// NewDescribeUDBInstancePriceRequest will create request of DescribeUDBInstancePrice action. +func (c *UDBClient) NewDescribeUDBInstancePriceRequest() *DescribeUDBInstancePriceRequest { + req := &DescribeUDBInstancePriceRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DescribeUDBInstancePrice - 获取UDB实例价格信息 +func (c *UDBClient) DescribeUDBInstancePrice(req *DescribeUDBInstancePriceRequest) (*DescribeUDBInstancePriceResponse, error) { + var err error + var res DescribeUDBInstancePriceResponse + + err = c.client.InvokeAction("DescribeUDBInstancePrice", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_state.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_state.go new file mode 100644 index 0000000000..357f59e876 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_state.go @@ -0,0 +1,59 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DescribeUDBInstanceState + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DescribeUDBInstanceStateRequest is request schema for DescribeUDBInstanceState action +type DescribeUDBInstanceStateRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 实例的Id,该值可以通过DescribeUDBInstance获取 + DBId *string `required:"true"` +} + +// DescribeUDBInstanceStateResponse is response schema for DescribeUDBInstanceState action +type DescribeUDBInstanceStateResponse struct { + response.CommonBase + + // DB状态标记 Init:初始化中;Fail:安装失败; Starting:启动中; Running : 运行 ;Shutdown:关闭中; Shutoff :已关闭; Delete:已删除; Upgrading:升级中; Promoting: 提升为独库进行中; Recovering: 恢复中; Recover fail:恢复失败。 + State string +} + +// NewDescribeUDBInstanceStateRequest will create request of DescribeUDBInstanceState action. +func (c *UDBClient) NewDescribeUDBInstanceStateRequest() *DescribeUDBInstanceStateRequest { + req := &DescribeUDBInstanceStateRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DescribeUDBInstanceState - 获取UDB实例状态 +func (c *UDBClient) DescribeUDBInstanceState(req *DescribeUDBInstanceStateRequest) (*DescribeUDBInstanceStateResponse, error) { + var err error + var res DescribeUDBInstanceStateResponse + + err = c.client.InvokeAction("DescribeUDBInstanceState", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_upgrade_price.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_upgrade_price.go new file mode 100644 index 0000000000..da9baaf9ac --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbinstance_upgrade_price.go @@ -0,0 +1,71 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DescribeUDBInstanceUpgradePrice + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DescribeUDBInstanceUpgradePriceRequest is request schema for DescribeUDBInstanceUpgradePrice action +type DescribeUDBInstanceUpgradePriceRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 实例的Id + DBId *string `required:"true"` + + // 内存限制(MB) + MemoryLimit *int `required:"true"` + + // 磁盘空间(GB), 暂时支持20G - 500G + DiskSpace *int `required:"true"` + + // 是否使用SSD,默认为false + UseSSD *bool `required:"false"` + + // SSD类型,可选值为"SATA"、"PCI-E",如果UseSSD为true ,则必选 + SSDType *string `required:"false"` +} + +// DescribeUDBInstanceUpgradePriceResponse is response schema for DescribeUDBInstanceUpgradePrice action +type DescribeUDBInstanceUpgradePriceResponse struct { + response.CommonBase + + // 价格,单位分 + Price float64 +} + +// NewDescribeUDBInstanceUpgradePriceRequest will create request of DescribeUDBInstanceUpgradePrice action. +func (c *UDBClient) NewDescribeUDBInstanceUpgradePriceRequest() *DescribeUDBInstanceUpgradePriceRequest { + req := &DescribeUDBInstanceUpgradePriceRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DescribeUDBInstanceUpgradePrice - 获取UDB实例升降级价格信息 +func (c *UDBClient) DescribeUDBInstanceUpgradePrice(req *DescribeUDBInstanceUpgradePriceRequest) (*DescribeUDBInstanceUpgradePriceResponse, error) { + var err error + var res DescribeUDBInstanceUpgradePriceResponse + + err = c.client.InvokeAction("DescribeUDBInstanceUpgradePrice", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udblog_backup_url.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udblog_backup_url.go new file mode 100644 index 0000000000..be8a1dc584 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udblog_backup_url.go @@ -0,0 +1,59 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DescribeUDBLogBackupURL + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DescribeUDBLogBackupURLRequest is request schema for DescribeUDBLogBackupURL action +type DescribeUDBLogBackupURLRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // DB实例Id + DBId *string `required:"true"` + + // DB实例备份ID + BackupId *int `required:"true"` +} + +// DescribeUDBLogBackupURLResponse is response schema for DescribeUDBLogBackupURL action +type DescribeUDBLogBackupURLResponse struct { + response.CommonBase + + // DB实例备份文件的地址 + BackupPath string +} + +// NewDescribeUDBLogBackupURLRequest will create request of DescribeUDBLogBackupURL action. +func (c *UDBClient) NewDescribeUDBLogBackupURLRequest() *DescribeUDBLogBackupURLRequest { + req := &DescribeUDBLogBackupURLRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DescribeUDBLogBackupURL - 获取UDB的slowlog备份地址 +func (c *UDBClient) DescribeUDBLogBackupURL(req *DescribeUDBLogBackupURLRequest) (*DescribeUDBLogBackupURLResponse, error) { + var err error + var res DescribeUDBLogBackupURLResponse + + err = c.client.InvokeAction("DescribeUDBLogBackupURL", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udblog_package.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udblog_package.go new file mode 100644 index 0000000000..f6d832aa9a --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udblog_package.go @@ -0,0 +1,80 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DescribeUDBLogPackage + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DescribeUDBLogPackageRequest is request schema for DescribeUDBLogPackage action +type DescribeUDBLogPackageRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 分页显示的起始偏移,列表操作则指定 + Offset *int `required:"true"` + + // 分页显示的条目数,列表操作则指定 + Limit *int `required:"true"` + + // 需要列出的备份文件类型,每种文件的值如下 2 : BINLOG\_BACKUP 3 : SLOW\_QUERY\_BACKUP 4 : ERRORLOG\_BACKUP + Type *int `required:"false"` + + // Types作为Type的补充,支持多值传入,可以获取多个类型的日志记录,如:Types.0=2&Types.1=3 + Types []int `required:"false"` + + // DB实例Id,如果指定,则只获取该db的备份信息 + DBId *string `required:"false"` + + // 过滤条件:起始时间(时间戳) + BeginTime *int `required:"false"` + + // 过滤条件:结束时间(时间戳) + EndTime *int `required:"false"` +} + +// DescribeUDBLogPackageResponse is response schema for DescribeUDBLogPackage action +type DescribeUDBLogPackageResponse struct { + response.CommonBase + + // 备份信息 参见LogPackageDataSet + DataSet []LogPackageDataSet + + // 备份总数,如果指定dbid,则是该db备份总数 + TotalCount int +} + +// NewDescribeUDBLogPackageRequest will create request of DescribeUDBLogPackage action. +func (c *UDBClient) NewDescribeUDBLogPackageRequest() *DescribeUDBLogPackageRequest { + req := &DescribeUDBLogPackageRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DescribeUDBLogPackage - 列表UDB实例binlog或slowlog或errorlog备份信息 +func (c *UDBClient) DescribeUDBLogPackage(req *DescribeUDBLogPackageRequest) (*DescribeUDBLogPackageResponse, error) { + var err error + var res DescribeUDBLogPackageResponse + + err = c.client.InvokeAction("DescribeUDBLogPackage", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbparam_group.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbparam_group.go new file mode 100644 index 0000000000..5f6053fd6f --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbparam_group.go @@ -0,0 +1,77 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DescribeUDBParamGroup + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DescribeUDBParamGroupRequest is request schema for DescribeUDBParamGroup action +type DescribeUDBParamGroupRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 分页显示的起始偏移,列表操作则指定 + Offset *int `required:"true"` + + // 分页显示的条目数,列表操作则指定 + Limit *int `required:"true"` + + // 参数组id,如果指定则获取描述,否则是列表操作,需要 指定Offset/Limit + GroupId *int `required:"false"` + + // 是否选取专区中配置 + IsInUDBC *bool `required:"false"` + + // 当请求没有填写Zone时,如果指定为true,表示只拉取跨可用区的相关配置文件,否则,拉取所有机房的配置文件(包括每个单可用区和跨可用区) + RegionFlag *bool `required:"false"` + + // 如果未指定GroupId,则可选是否选取特定DB类型的配置(sql, nosql, postgresql, sqlserver) + ClassType *string `required:"false"` +} + +// DescribeUDBParamGroupResponse is response schema for DescribeUDBParamGroup action +type DescribeUDBParamGroupResponse struct { + response.CommonBase + + // 参数组列表 参照UDBParamGroupSet + DataSet []UDBParamGroupSet + + // 参数组总数,列表操作时才会有该参数 + TotalCount int +} + +// NewDescribeUDBParamGroupRequest will create request of DescribeUDBParamGroup action. +func (c *UDBClient) NewDescribeUDBParamGroupRequest() *DescribeUDBParamGroupRequest { + req := &DescribeUDBParamGroupRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DescribeUDBParamGroup - 获取参数组详细参数信息 +func (c *UDBClient) DescribeUDBParamGroup(req *DescribeUDBParamGroupRequest) (*DescribeUDBParamGroupResponse, error) { + var err error + var res DescribeUDBParamGroupResponse + + err = c.client.InvokeAction("DescribeUDBParamGroup", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbtype.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbtype.go new file mode 100644 index 0000000000..ae7f51f9cc --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/describe_udbtype.go @@ -0,0 +1,54 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB DescribeUDBType + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DescribeUDBTypeRequest is request schema for DescribeUDBType action +type DescribeUDBTypeRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + +} + +// DescribeUDBTypeResponse is response schema for DescribeUDBType action +type DescribeUDBTypeResponse struct { + response.CommonBase + + // DB类型列表 参数见 UDBTypeSet + DataSet []UDBTypeSet +} + +// NewDescribeUDBTypeRequest will create request of DescribeUDBType action. +func (c *UDBClient) NewDescribeUDBTypeRequest() *DescribeUDBTypeRequest { + req := &DescribeUDBTypeRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// DescribeUDBType - 获取UDB支持的类型信息 +func (c *UDBClient) DescribeUDBType(req *DescribeUDBTypeRequest) (*DescribeUDBTypeResponse, error) { + var err error + var res DescribeUDBTypeResponse + + err = c.client.InvokeAction("DescribeUDBType", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/doc.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/doc.go new file mode 100644 index 0000000000..1be07d1a56 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/doc.go @@ -0,0 +1,11 @@ +/* +Package udb include resources of ucloud udb product + +See also + + - API: https://docs.ucloud.cn/api/udb-api/index + - Product: https://www.ucloud.cn/site/product/udb.html + +for detail. +*/ +package udb diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/edit_udbbackup_blacklist.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/edit_udbbackup_blacklist.go new file mode 100644 index 0000000000..2ad82afee0 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/edit_udbbackup_blacklist.go @@ -0,0 +1,59 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB EditUDBBackupBlacklist + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// EditUDBBackupBlacklistRequest is request schema for EditUDBBackupBlacklist action +type EditUDBBackupBlacklistRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // DB实例Id,该值可以通过DescribeUDBInstance获取 + DBId *string `required:"true"` + + // 黑名单,规范示例,指定库mysql.%;test.%; 指定表city.address; + Blacklist *string `required:"true"` +} + +// EditUDBBackupBlacklistResponse is response schema for EditUDBBackupBlacklist action +type EditUDBBackupBlacklistResponse struct { + response.CommonBase +} + +// NewEditUDBBackupBlacklistRequest will create request of EditUDBBackupBlacklist action. +func (c *UDBClient) NewEditUDBBackupBlacklistRequest() *EditUDBBackupBlacklistRequest { + req := &EditUDBBackupBlacklistRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// EditUDBBackupBlacklist - 编辑UDB实例的备份黑名单 +func (c *UDBClient) EditUDBBackupBlacklist(req *EditUDBBackupBlacklistRequest) (*EditUDBBackupBlacklistResponse, error) { + var err error + var res EditUDBBackupBlacklistResponse + + err = c.client.InvokeAction("EditUDBBackupBlacklist", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/fetch_udbinstance_earliest_recover_time.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/fetch_udbinstance_earliest_recover_time.go new file mode 100644 index 0000000000..377af0cd22 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/fetch_udbinstance_earliest_recover_time.go @@ -0,0 +1,59 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB FetchUDBInstanceEarliestRecoverTime + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// FetchUDBInstanceEarliestRecoverTimeRequest is request schema for FetchUDBInstanceEarliestRecoverTime action +type FetchUDBInstanceEarliestRecoverTimeRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // DB实例Id + DBId *string `required:"true"` +} + +// FetchUDBInstanceEarliestRecoverTimeResponse is response schema for FetchUDBInstanceEarliestRecoverTime action +type FetchUDBInstanceEarliestRecoverTimeResponse struct { + response.CommonBase + + // 获取最早可回档时间点 + EarliestTime int +} + +// NewFetchUDBInstanceEarliestRecoverTimeRequest will create request of FetchUDBInstanceEarliestRecoverTime action. +func (c *UDBClient) NewFetchUDBInstanceEarliestRecoverTimeRequest() *FetchUDBInstanceEarliestRecoverTimeRequest { + req := &FetchUDBInstanceEarliestRecoverTimeRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// FetchUDBInstanceEarliestRecoverTime - 获取UDB最早可回档的时间点 +func (c *UDBClient) FetchUDBInstanceEarliestRecoverTime(req *FetchUDBInstanceEarliestRecoverTimeRequest) (*FetchUDBInstanceEarliestRecoverTimeResponse, error) { + var err error + var res FetchUDBInstanceEarliestRecoverTimeResponse + + err = c.client.InvokeAction("FetchUDBInstanceEarliestRecoverTime", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/modify_udbinstance_name.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/modify_udbinstance_name.go new file mode 100644 index 0000000000..7f0488e2dd --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/modify_udbinstance_name.go @@ -0,0 +1,59 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB ModifyUDBInstanceName + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// ModifyUDBInstanceNameRequest is request schema for ModifyUDBInstanceName action +type ModifyUDBInstanceNameRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 实例的Id,该值可以通过DescribeUDBInstance获取 + DBId *string `required:"true"` + + // 实例的新名字, 长度要求为6~63位 + Name *string `required:"true"` +} + +// ModifyUDBInstanceNameResponse is response schema for ModifyUDBInstanceName action +type ModifyUDBInstanceNameResponse struct { + response.CommonBase +} + +// NewModifyUDBInstanceNameRequest will create request of ModifyUDBInstanceName action. +func (c *UDBClient) NewModifyUDBInstanceNameRequest() *ModifyUDBInstanceNameRequest { + req := &ModifyUDBInstanceNameRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// ModifyUDBInstanceName - 重命名UDB实例 +func (c *UDBClient) ModifyUDBInstanceName(req *ModifyUDBInstanceNameRequest) (*ModifyUDBInstanceNameResponse, error) { + var err error + var res ModifyUDBInstanceNameResponse + + err = c.client.InvokeAction("ModifyUDBInstanceName", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/modify_udbinstance_password.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/modify_udbinstance_password.go new file mode 100644 index 0000000000..19ad701422 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/modify_udbinstance_password.go @@ -0,0 +1,62 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB ModifyUDBInstancePassword + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// ModifyUDBInstancePasswordRequest is request schema for ModifyUDBInstancePassword action +type ModifyUDBInstancePasswordRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 实例的ID,该值可以通过DescribeUDBInstance获取 + DBId *string `required:"true"` + + // 实例的新密码 + Password *string `required:"true"` + + // sqlserver帐号,仅在sqlserver的情况下填该参数 + AccountName *string `required:"false"` +} + +// ModifyUDBInstancePasswordResponse is response schema for ModifyUDBInstancePassword action +type ModifyUDBInstancePasswordResponse struct { + response.CommonBase +} + +// NewModifyUDBInstancePasswordRequest will create request of ModifyUDBInstancePassword action. +func (c *UDBClient) NewModifyUDBInstancePasswordRequest() *ModifyUDBInstancePasswordRequest { + req := &ModifyUDBInstancePasswordRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// ModifyUDBInstancePassword - 修改DB实例的管理员密码 +func (c *UDBClient) ModifyUDBInstancePassword(req *ModifyUDBInstancePasswordRequest) (*ModifyUDBInstancePasswordResponse, error) { + var err error + var res ModifyUDBInstancePasswordResponse + + err = c.client.InvokeAction("ModifyUDBInstancePassword", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/promote_udbinstance_to_ha.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/promote_udbinstance_to_ha.go new file mode 100644 index 0000000000..b823b905a2 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/promote_udbinstance_to_ha.go @@ -0,0 +1,56 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB PromoteUDBInstanceToHA + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// PromoteUDBInstanceToHARequest is request schema for PromoteUDBInstanceToHA action +type PromoteUDBInstanceToHARequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 实例的Id,该值可以通过DescribeUDBInstance获取 + DBId *string `required:"true"` + + // 升级时是否锁库,默认为锁库。不锁定:false;锁定:true。现在统一为不锁库,即false + IsLock *bool `required:"false"` +} + +// PromoteUDBInstanceToHAResponse is response schema for PromoteUDBInstanceToHA action +type PromoteUDBInstanceToHAResponse struct { + response.CommonBase +} + +// NewPromoteUDBInstanceToHARequest will create request of PromoteUDBInstanceToHA action. +func (c *UDBClient) NewPromoteUDBInstanceToHARequest() *PromoteUDBInstanceToHARequest { + req := &PromoteUDBInstanceToHARequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// PromoteUDBInstanceToHA - 普通db升级为高可用(只针对mysql5.5及以上版本) +func (c *UDBClient) PromoteUDBInstanceToHA(req *PromoteUDBInstanceToHARequest) (*PromoteUDBInstanceToHAResponse, error) { + var err error + var res PromoteUDBInstanceToHAResponse + + err = c.client.InvokeAction("PromoteUDBInstanceToHA", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/promote_udbslave.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/promote_udbslave.go new file mode 100644 index 0000000000..2850b60a0c --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/promote_udbslave.go @@ -0,0 +1,59 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB PromoteUDBSlave + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// PromoteUDBSlaveRequest is request schema for PromoteUDBSlave action +type PromoteUDBSlaveRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 实例的Id,该值可以通过DescribeUDBInstance获取 + DBId *string `required:"true"` + + // 是否强制(如果从库落后可能会禁止提升),默认false 如果落后情况下,强制提升丢失数据 + IsForce *bool `required:"false"` +} + +// PromoteUDBSlaveResponse is response schema for PromoteUDBSlave action +type PromoteUDBSlaveResponse struct { + response.CommonBase +} + +// NewPromoteUDBSlaveRequest will create request of PromoteUDBSlave action. +func (c *UDBClient) NewPromoteUDBSlaveRequest() *PromoteUDBSlaveRequest { + req := &PromoteUDBSlaveRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// PromoteUDBSlave - 从库提升为独立库 +func (c *UDBClient) PromoteUDBSlave(req *PromoteUDBSlaveRequest) (*PromoteUDBSlaveResponse, error) { + var err error + var res PromoteUDBSlaveResponse + + err = c.client.InvokeAction("PromoteUDBSlave", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/resize_udbinstance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/resize_udbinstance.go new file mode 100644 index 0000000000..78ef133abe --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/resize_udbinstance.go @@ -0,0 +1,83 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB ResizeUDBInstance + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// ResizeUDBInstanceRequest is request schema for ResizeUDBInstance action +type ResizeUDBInstanceRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *int `required:"false"` + + // 实例的Id + DBId *string `required:"true"` + + // 内存限制(MB),目前支持以下几档 1000M/2000M/4000M/ 6000M/8000M/ 12000M/16000M/ 24000M/32000M/ 48000M/64000M/96000M。 + MemoryLimit *int `required:"true"` + + // 磁盘空间(GB), 暂时支持20G-3000G + DiskSpace *int `required:"true"` + + // 是否使用SSD,默认为false + UseSSD *bool `required:"false"` + + // SSD类型,可选值为"SATA"、"PCI-E",如果UseSSD为true ,则必选 + SSDType *string `required:"false"` + + // 专区的ID,如果有值表示专区中的DB配置升降级 + UDBCId *string `required:"false"` + + // UDB数据库机型: "Normal": "标准机型" , "SATA_SSD": "SSD机型" , "PCIE_SSD": "SSD高性能机型" , "Normal_Volume": "标准大容量机型", "SATA_SSD_Volume": "SSD大容量机型" , "PCIE_SSD_Volume": "SSD高性能大容量机型" + InstanceType *string `required:"false"` + + // UDB实例模式类型, 可选值如下: "Normal": 普通版UDB实例 "HA": 高可用版UDB实例 默认是"Normal" + InstanceMode *string `required:"false"` + + // DB关闭状态下升降级,升降级后是否启动DB,默认为false + StartAfterUpgrade *bool `required:"false"` + + // 使用的代金券id + CouponId *string `required:"false"` +} + +// ResizeUDBInstanceResponse is response schema for ResizeUDBInstance action +type ResizeUDBInstanceResponse struct { + response.CommonBase +} + +// NewResizeUDBInstanceRequest will create request of ResizeUDBInstance action. +func (c *UDBClient) NewResizeUDBInstanceRequest() *ResizeUDBInstanceRequest { + req := &ResizeUDBInstanceRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// ResizeUDBInstance - 修改(升级和降级)UDB实例的配置,包括内存和磁盘的配置,对于内存升级无需关闭实例,其他场景需要事先关闭实例。两套参数可以配置升降机:1.配置UseSSD和SSDType 2.配置InstanceType,不需要配置InstanceMode。这两套第二套参数的优先级更高 +func (c *UDBClient) ResizeUDBInstance(req *ResizeUDBInstanceRequest) (*ResizeUDBInstanceResponse, error) { + var err error + var res ResizeUDBInstanceResponse + + err = c.client.InvokeAction("ResizeUDBInstance", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/restart_udbinstance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/restart_udbinstance.go new file mode 100644 index 0000000000..8ba16a8331 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/restart_udbinstance.go @@ -0,0 +1,56 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB RestartUDBInstance + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// RestartUDBInstanceRequest is request schema for RestartUDBInstance action +type RestartUDBInstanceRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 实例的Id,该值可以通过DescribeUDBInstance获取 + DBId *string `required:"true"` +} + +// RestartUDBInstanceResponse is response schema for RestartUDBInstance action +type RestartUDBInstanceResponse struct { + response.CommonBase +} + +// NewRestartUDBInstanceRequest will create request of RestartUDBInstance action. +func (c *UDBClient) NewRestartUDBInstanceRequest() *RestartUDBInstanceRequest { + req := &RestartUDBInstanceRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// RestartUDBInstance - 重启UDB实例 +func (c *UDBClient) RestartUDBInstance(req *RestartUDBInstanceRequest) (*RestartUDBInstanceResponse, error) { + var err error + var res RestartUDBInstanceResponse + + err = c.client.InvokeAction("RestartUDBInstance", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/start_udbinstance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/start_udbinstance.go new file mode 100644 index 0000000000..b491f1b738 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/start_udbinstance.go @@ -0,0 +1,56 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB StartUDBInstance + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// StartUDBInstanceRequest is request schema for StartUDBInstance action +type StartUDBInstanceRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 实例的Id,该值可以通过DescribeUDBInstance获取 + DBId *string `required:"true"` +} + +// StartUDBInstanceResponse is response schema for StartUDBInstance action +type StartUDBInstanceResponse struct { + response.CommonBase +} + +// NewStartUDBInstanceRequest will create request of StartUDBInstance action. +func (c *UDBClient) NewStartUDBInstanceRequest() *StartUDBInstanceRequest { + req := &StartUDBInstanceRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// StartUDBInstance - 启动UDB实例 +func (c *UDBClient) StartUDBInstance(req *StartUDBInstanceRequest) (*StartUDBInstanceResponse, error) { + var err error + var res StartUDBInstanceResponse + + err = c.client.InvokeAction("StartUDBInstance", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/stop_udbinstance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/stop_udbinstance.go new file mode 100644 index 0000000000..7116fb2c2c --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/stop_udbinstance.go @@ -0,0 +1,59 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB StopUDBInstance + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// StopUDBInstanceRequest is request schema for StopUDBInstance action +type StopUDBInstanceRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 实例的Id,该值可以通过DescribeUDBInstance获取 + DBId *string `required:"true"` + + // 是否使用强制手段关闭DB,默认是false + ForceToKill *bool `required:"false"` +} + +// StopUDBInstanceResponse is response schema for StopUDBInstance action +type StopUDBInstanceResponse struct { + response.CommonBase +} + +// NewStopUDBInstanceRequest will create request of StopUDBInstance action. +func (c *UDBClient) NewStopUDBInstanceRequest() *StopUDBInstanceRequest { + req := &StopUDBInstanceRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// StopUDBInstance - 关闭UDB实例 +func (c *UDBClient) StopUDBInstance(req *StopUDBInstanceRequest) (*StopUDBInstanceResponse, error) { + var err error + var res StopUDBInstanceResponse + + err = c.client.InvokeAction("StopUDBInstance", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/switch_udbinstance_to_ha.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/switch_udbinstance_to_ha.go new file mode 100644 index 0000000000..a43e7edf3b --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/switch_udbinstance_to_ha.go @@ -0,0 +1,65 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB SwitchUDBInstanceToHA + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// SwitchUDBInstanceToHARequest is request schema for SwitchUDBInstanceToHA action +type SwitchUDBInstanceToHARequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 实例的Id,该值可以通过DescribeUDBInstance获取 + DBId *string `required:"true"` + + // Year, Month, Dynamic,Trial,不填则按现在单点计费执行 + ChargeType *string `required:"false"` + + // 购买时长,需要和 ChargeType 搭配使用,否则使用单点计费策略的值 + Quantity *string `required:"false"` + + // 业务组 + Tag *string `required:"false"` +} + +// SwitchUDBInstanceToHAResponse is response schema for SwitchUDBInstanceToHA action +type SwitchUDBInstanceToHAResponse struct { + response.CommonBase + + // 切换后高可用db实例的Id + DBId string +} + +// NewSwitchUDBInstanceToHARequest will create request of SwitchUDBInstanceToHA action. +func (c *UDBClient) NewSwitchUDBInstanceToHARequest() *SwitchUDBInstanceToHARequest { + req := &SwitchUDBInstanceToHARequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// SwitchUDBInstanceToHA - 普通UDB切换为高可用,原db状态为WaitForSwitch时,调用该api +func (c *UDBClient) SwitchUDBInstanceToHA(req *SwitchUDBInstanceToHARequest) (*SwitchUDBInstanceToHAResponse, error) { + var err error + var res SwitchUDBInstanceToHAResponse + + err = c.client.InvokeAction("SwitchUDBInstanceToHA", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_log_package_data_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_log_package_data_set.go new file mode 100644 index 0000000000..ada92a190e --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_log_package_data_set.go @@ -0,0 +1,40 @@ +package udb + +/* +LogPackageDataSet - DescribeUDBLogPackage + +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. +*/ +type LogPackageDataSet struct { + + // 备份id + BackupId int + + // 备份名称 + BackupName string + + // 备份时间 + BackupTime int + + // 备份文件大小 + BackupSize int + + // 备份类型,包括2-binlog备份,3-slowlog备份 + BackupType int + + // 备份状态 Backuping // 备份中 Success // 备份成功 Failed // 备份失败 Expired // 备份过期 + State string + + // dbid + DBId string + + // 对应的db名称 + DBName string + + // 所在可用区 + Zone string + + // 跨可用区高可用备库所在可用区 + BackupZone string +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbbackup_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbbackup_set.go new file mode 100644 index 0000000000..282c48fbf0 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbbackup_set.go @@ -0,0 +1,43 @@ +package udb + +/* +UDBBackupSet - DescribeUDBBackup + +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. +*/ +type UDBBackupSet struct { + + // 备份id + BackupId int + + // 备份名称 + BackupName string + + // 备份时间(Unix时间戳) + BackupTime int + + // 备份文件大小(字节) + BackupSize int + + // 备份类型,取值为0或1,0表示自动,1表示手动 + BackupType int + + // 备份状态 Backuping // 备份中 Success // 备份成功 Failed // 备份失败 Expired // 备份过期 + State string + + // dbid + DBId string + + // 对应的db名称 + DBName string + + // 备份所在可用区 + Zone string + + // 跨机房高可用备库所在可用区 + BackupZone string + + // 备份完成时间(Unix时间戳) + BackupEndTime int +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbinstance_binlog_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbinstance_binlog_set.go new file mode 100644 index 0000000000..1d044c15b2 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbinstance_binlog_set.go @@ -0,0 +1,22 @@ +package udb + +/* +UDBInstanceBinlogSet - DescribeUDBInstanceBinlog + +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. +*/ +type UDBInstanceBinlogSet struct { + + // Binlog文件名 + Name string + + // Binlog文件大小 + Size int + + // Binlog文件生成时间(时间戳) + BeginTime int + + // Binlog文件结束时间(时间戳) + EndTime int +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbinstance_price_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbinstance_price_set.go new file mode 100644 index 0000000000..16e4f5b230 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbinstance_price_set.go @@ -0,0 +1,16 @@ +package udb + +/* +UDBInstancePriceSet - DescribeUDBInstancePrice + +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. +*/ +type UDBInstancePriceSet struct { + + // Year, Month, Dynamic,Trial + ChargeType string + + // 价格,单位为分,保留小数点后两位 + Price float64 +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbinstance_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbinstance_set.go new file mode 100644 index 0000000000..85933b6562 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbinstance_set.go @@ -0,0 +1,119 @@ +package udb + +/* +UDBInstanceSet - DescribeUDBInstance + +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. +*/ +type UDBInstanceSet struct { + + // DB实例所在可用区 + Zone string + + // 当DB类型为mongodb时,返回该实例所在集群中的角色,包括:mongos、configsrv_sccc、configsrv_csrs、shardsrv_datanode、shardsrv_arbiter,其中congfigsrv分为sccc和csrs两种模式,shardsrv分为datanode和arbiter两种模式 + CluserRole string + + // DB实例id + DBId string + + // 实例名称,至少6位 + Name string + + // DB类型id,mysql/mongodb按版本细分各有一个id 目前id的取值范围为[1,7],数值对应的版本如下: 1:mysql-5.5,2:mysql-5.1,3:percona-5.5 4:mongodb-2.4,5:mongodb-2.6,6:mysql-5.6, 7:percona-5.6 + DBTypeId string + + // DB实例使用的配置参数组id + ParamGroupId int + + // 管理员帐户名,默认root + AdminUser string + + // DB实例虚ip + VirtualIP string + + // DB实例虚ip的mac地址 + VirtualIPMac string + + // 端口号,mysql默认3306,mongodb默认27017 + Port int + + // 对mysql的slave而言是master的DBId,对master则为空, 对mongodb则是副本集id + SrcDBId string + + // 备份策略,不可修改,备份文件保留的数量,默认7次 + BackupCount int + + // 备份策略,不可修改,开始时间,单位小时计,默认3点 + BackupBeginTime int + + // 备份策略,一天内备份时间间隔,单位小时,默认24小时 + BackupDuration int + + // 备份策略,备份黑名单,mongodb则不适用 + BackupBlacklist string + + // DB状态标记 Init:初始化中,Fail:安装失败,Starting:启动中,Running:运行,Shutdown:关闭中,Shutoff:已关闭,Delete:已删除,Upgrading:升级中,Promoting:提升为独库进行中,Recovering:恢复中,Recover fail:恢复失败 + State string + + // DB实例创建时间,采用UTC计时时间戳 + CreateTime int + + // DB实例修改时间,采用UTC计时时间戳 + ModifyTime int + + // DB实例过期时间,采用UTC计时时间戳 + ExpiredTime int + + // Year, Month, Dynamic,Trial,默认: Dynamic + ChargeType string + + // 内存限制(MB),默认根据配置机型 + MemoryLimit int + + // 磁盘空间(GB), 默认根据配置机型 + DiskSpace int + + // 是否使用SSD + UseSSD bool + + // SSD类型,SATA/PCI-E + SSDType string + + // DB实例角色,mysql区分master/slave,mongodb多种角色 + Role string + + // DB实例磁盘已使用空间,单位GB + DiskUsedSize float64 + + // DB实例数据文件大小,单位GB + DataFileSize float64 + + // DB实例系统文件大小,单位GB + SystemFileSize float64 + + // DB实例日志文件大小,单位GB + LogFileSize float64 + + // 备份日期标记位。共7位,每一位为一周中一天的备份情况 0表示关闭当天备份,1表示打开当天备份。最右边的一位 为星期天的备份开关,其余从右到左依次为星期一到星期 六的备份配置开关,每周必须至少设置两天备份。 例如:1100000 表示打开星期六和星期五的自动备份功能 + BackupDate string + + // UDB实例模式类型, 可选值如下: “Normal”: 普通版UDB实例 “HA”: 高可用版UDB实例 + InstanceMode string + InstanceType string + + // 如果列表操作,则有从库DB实例信息列表 参数同UDBSlaveInstanceSet + DataSet []UDBSlaveInstanceSet + + // 跨可用区高可用备库所在可用区 + BackupZone string + + // 业务组 + Tag string + + // VPC ID + VPCId string + + // Subnet Id + SubnetId string +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbparam_group_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbparam_group_set.go new file mode 100644 index 0000000000..6c1b5184f6 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbparam_group_set.go @@ -0,0 +1,29 @@ +package udb + +/* +UDBParamGroupSet - DescribeUDBParamGroup + +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. +*/ +type UDBParamGroupSet struct { + + // 参数组id + GroupId int + + // 参数组名称 + GroupName string + Zone string + + // DB类型id,mysql/mongodb按版本细分各有一个id 目前id的取值范围为[1,7],数值对应的版本如下 1:mysql-5.5,2:mysql-5.1,3:percona-5.5 4:mongodb-2.4,5:mongodb-2.6,6:mysql-5.6 7:percona-5.6 + DBTypeId string + + // 参数组描述 + Description string + + // 参数组是否可修改 + Modifiable bool + + // 参数的键值对表 UDBParamMemberSet + ParamMember []UDBParamMemberSet +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbparam_member_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbparam_member_set.go new file mode 100644 index 0000000000..ad23ffaa11 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbparam_member_set.go @@ -0,0 +1,31 @@ +package udb + +/* +UDBParamMemberSet - DescribeUDBParamGroup + +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. +*/ +type UDBParamMemberSet struct { + + // 参数名称 + Key string + + // 参数值 + Value string + + // 参数值应用类型,取值范围为{0,10,20,30},各值 代表意义为 0-unknown、10-int、20-string、 30-bool + ValueType int + + // 允许的值(根据参数类型,用分隔符表示) + AllowedVal string + + // 参数值应用类型,取值范围为{0,10,20},各值代表 意义为0-unknown、10-static、20-dynamic + ApplyType int + + // 是否可更改,默认为false + Modifiable bool + + // 允许值的格式类型,取值范围为{0,10,20},意义分 别为PVFT_UNKOWN=0,PVFT_RANGE=10, PVFT_ENUM=20 + FormatType int +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbslave_instance_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbslave_instance_set.go new file mode 100644 index 0000000000..a048719aa7 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbslave_instance_set.go @@ -0,0 +1,103 @@ +package udb + +/* +UDBSlaveInstanceSet - DescribeUDBSlaveInstance + +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. +*/ +type UDBSlaveInstanceSet struct { + + // DB实例id + DBId string + + // 实例名称,至少6位 + Name string + + // DB类型id,mysql/mongodb按版本细分各有一个id 目前id的取值范围为[1,7],数值对应的版本如下: 1:mysql-5.5,2:mysql-5.1,3:percona-5.5 4:mongodb-2.4,5:mongodb-2.6,6:mysql-5.6, 7:percona-5.6 + DBTypeId string + + // DB实例使用的配置参数组id + ParamGroupId int + + // 管理员帐户名,默认root + AdminUser string + + // DB实例虚ip + VirtualIP string + + // DB实例虚ip的mac地址 + VirtualIPMac string + + // 端口号,mysql默认3306,mongodb默认27017 + Port int + + // 对mysql的slave而言是master的DBId,对master则为空, 对mongodb则是副本集id + SrcDBId string + + // 备份策略,不可修改,备份文件保留的数量,默认7次 + BackupCount int + + // 备份策略,不可修改,开始时间,单位小时计,默认3点 + BackupBeginTime int + + // 备份策略,一天内备份时间间隔,单位小时,默认24小时 + BackupDuration int + + // 备份策略,备份黑名单,mongodb则不适用 + BackupBlacklist string + + // DB状态标记 Init:初始化中,Fail:安装失败,Starting:启动中,Running:运行,Shutdown:关闭中,Shutoff:已关闭,Delete:已删除,Upgrading:升级中,Promoting:提升为独库进行中,Recovering:恢复中,Recover fail:恢复失败 + State string + + // DB实例创建时间,采用UTC计时时间戳 + CreateTime int + + // DB实例修改时间,采用UTC计时时间戳 + ModifyTime int + + // DB实例过期时间,采用UTC计时时间戳 + ExpiredTime int + + // Year, Month, Dynamic,Trial,默认: Dynamic + ChargeType string + + // 内存限制(MB),默认根据配置机型 + MemoryLimit int + + // 磁盘空间(GB), 默认根据配置机型 + DiskSpace int + + // 是否使用SSD + UseSSD bool + + // SSD类型,SATA/PCI-E + SSDType string + + // DB实例角色,mysql区分master/slave,mongodb多种角色 + Role string + + // DB实例磁盘已使用空间,单位GB + DiskUsedSize float64 + + // DB实例数据文件大小,单位GB + DataFileSize float64 + + // DB实例系统文件大小,单位GB + SystemFileSize float64 + + // DB实例日志文件大小,单位GB + LogFileSize float64 + + // 备份日期标记位。共7位,每一位为一周中一天的备份情况 0表示关闭当天备份,1表示打开当天备份。最右边的一位 为星期天的备份开关,其余从右到左依次为星期一到星期 六的备份配置开关,每周必须至少设置两天备份。 例如:1100000 表示打开星期六和星期五的自动备份功能 + BackupDate string + + // UDB实例模式类型, 可选值如下: "Normal": 普通版UDB实例;"HA": 高可用版UDB实例 + InstanceMode string + + InstanceType string + Zone string + Tag string + VPCId string + SubnetId string +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbtype_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbtype_set.go new file mode 100644 index 0000000000..5d3b52112a --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/types_udbtype_set.go @@ -0,0 +1,13 @@ +package udb + +/* +UDBTypeSet - DescribeUDBType + +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. +*/ +type UDBTypeSet struct { + + // DB类型id,mysql/mongodb按版本细分各有一个id, 目前id的取值范围为[1,7],数值对应的版本如下: 1:mysql-5.5,2:mysql-5.1,3:percona-5.5 4:mongodb-2.4,5:mongodb-2.6,6:mysql-5.6, 7:percona-5.6 + DBTypeId string +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/update_udbinstance_backup_strategy.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/update_udbinstance_backup_strategy.go new file mode 100644 index 0000000000..7430a127c9 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/update_udbinstance_backup_strategy.go @@ -0,0 +1,65 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB UpdateUDBInstanceBackupStrategy + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// UpdateUDBInstanceBackupStrategyRequest is request schema for UpdateUDBInstanceBackupStrategy action +type UpdateUDBInstanceBackupStrategyRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 主节点的Id + DBId *string `required:"true"` + + // 备份的整点时间,范围[0,23] + BackupTime *int `required:"false"` + + // 备份时期标记位。共7位,每一位为一周中一天的备份情况,0表示关闭当天备份,1表示打开当天备份。最右边的一位为星期天的备份开关,其余从右到左依次为星期一到星期六的备份配置开关,每周必须至少设置两天备份。例如:1100000表示打开星期六和星期五的备份功能 + BackupDate *string `required:"false"` + + // 当导出某些数据遇到问题后,是否强制导出其他剩余数据默认是false + ForceDump *bool `required:"false"` +} + +// UpdateUDBInstanceBackupStrategyResponse is response schema for UpdateUDBInstanceBackupStrategy action +type UpdateUDBInstanceBackupStrategyResponse struct { + response.CommonBase +} + +// NewUpdateUDBInstanceBackupStrategyRequest will create request of UpdateUDBInstanceBackupStrategy action. +func (c *UDBClient) NewUpdateUDBInstanceBackupStrategyRequest() *UpdateUDBInstanceBackupStrategyRequest { + req := &UpdateUDBInstanceBackupStrategyRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// UpdateUDBInstanceBackupStrategy - 修改UDB自动备份策略 +func (c *UDBClient) UpdateUDBInstanceBackupStrategy(req *UpdateUDBInstanceBackupStrategyRequest) (*UpdateUDBInstanceBackupStrategyResponse, error) { + var err error + var res UpdateUDBInstanceBackupStrategyResponse + + err = c.client.InvokeAction("UpdateUDBInstanceBackupStrategy", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/update_udbinstance_slave_backup_switch.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/update_udbinstance_slave_backup_switch.go new file mode 100644 index 0000000000..49e0e9a014 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/update_udbinstance_slave_backup_switch.go @@ -0,0 +1,62 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB UpdateUDBInstanceSlaveBackupSwitch + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// UpdateUDBInstanceSlaveBackupSwitchRequest is request schema for UpdateUDBInstanceSlaveBackupSwitch action +type UpdateUDBInstanceSlaveBackupSwitchRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 主库的Id + MasterDBId *string `required:"true"` + + // 从库的备份开关,范围[0,1],0表示从库备份功能关闭,1 表示从库备份开关打开。 + BackupSwitch *int `required:"true"` + + // 从库的Id,如果从库备份开关设定为打开,则必须赋值。 + SlaveDBId *string `required:"false"` +} + +// UpdateUDBInstanceSlaveBackupSwitchResponse is response schema for UpdateUDBInstanceSlaveBackupSwitch action +type UpdateUDBInstanceSlaveBackupSwitchResponse struct { + response.CommonBase +} + +// NewUpdateUDBInstanceSlaveBackupSwitchRequest will create request of UpdateUDBInstanceSlaveBackupSwitch action. +func (c *UDBClient) NewUpdateUDBInstanceSlaveBackupSwitchRequest() *UpdateUDBInstanceSlaveBackupSwitchRequest { + req := &UpdateUDBInstanceSlaveBackupSwitchRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// UpdateUDBInstanceSlaveBackupSwitch - 开启或者关闭UDB从库备份 +func (c *UDBClient) UpdateUDBInstanceSlaveBackupSwitch(req *UpdateUDBInstanceSlaveBackupSwitchRequest) (*UpdateUDBInstanceSlaveBackupSwitchResponse, error) { + var err error + var res UpdateUDBInstanceSlaveBackupSwitchResponse + + err = c.client.InvokeAction("UpdateUDBInstanceSlaveBackupSwitch", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/update_udbparam_group.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/update_udbparam_group.go new file mode 100644 index 0000000000..6bcc3f2fa8 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/update_udbparam_group.go @@ -0,0 +1,65 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB UpdateUDBParamGroup + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// UpdateUDBParamGroupRequest is request schema for UpdateUDBParamGroup action +type UpdateUDBParamGroupRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // 配置参数组id,使用DescribeUDBParamGroup获得 + GroupId *int `required:"true"` + + // 参数名称 + Key *string `required:"true"` + + // 参数值 + Value *string `required:"true"` + + // 该配置文件是否是地域级别配置文件,默认是false + RegionFlag *bool `required:"false"` +} + +// UpdateUDBParamGroupResponse is response schema for UpdateUDBParamGroup action +type UpdateUDBParamGroupResponse struct { + response.CommonBase +} + +// NewUpdateUDBParamGroupRequest will create request of UpdateUDBParamGroup action. +func (c *UDBClient) NewUpdateUDBParamGroupRequest() *UpdateUDBParamGroupRequest { + req := &UpdateUDBParamGroupRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// UpdateUDBParamGroup - 更新UDB配置参数项 +func (c *UDBClient) UpdateUDBParamGroup(req *UpdateUDBParamGroupRequest) (*UpdateUDBParamGroupResponse, error) { + var err error + var res UpdateUDBParamGroupResponse + + err = c.client.InvokeAction("UpdateUDBParamGroup", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/upload_udbparam_group.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/upload_udbparam_group.go new file mode 100644 index 0000000000..9848848562 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udb/upload_udbparam_group.go @@ -0,0 +1,74 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UDB UploadUDBParamGroup + +package udb + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// UploadUDBParamGroupRequest is request schema for UploadUDBParamGroup action +type UploadUDBParamGroupRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // DB类型id,DB类型id,mysql/mongodb/postgesql按版本细分 1:mysql-5.1,2:mysql-5.5,3:percona-5.5,4:mysql-5.6,5:percona-5.6,6:mysql-5.7,7:percona-5.7,8:mariadb-10.0,9:mongodb-2.4,10:mongodb-2.6,11:mongodb-3.0,12:mongodb-3.2,13:postgresql-9.4,14:postgresql-9.6 + DBTypeId *string `required:"true"` + + // 配置参数组名称 + GroupName *string `required:"true"` + + // 参数组描述 + Description *string `required:"true"` + + // 配置内容,导入的配置内容采用base64编码 + Content *string `required:"true"` + + // 该配置文件是否是地域级别配置文件,默认是false + RegionFlag *bool `required:"false"` + + // 配置文件子类型 0-未知, 1-Shardsvr-MMAPv1, 2-Shardsvr-WiredTiger, 3-Configsvr-MMAPv1, 4-Configsvr-WiredTiger, 5-Mongos + ParamGroupTypeId *int `required:"false"` +} + +// UploadUDBParamGroupResponse is response schema for UploadUDBParamGroup action +type UploadUDBParamGroupResponse struct { + response.CommonBase + + // 配置参数组id + GroupId int +} + +// NewUploadUDBParamGroupRequest will create request of UploadUDBParamGroup action. +func (c *UDBClient) NewUploadUDBParamGroupRequest() *UploadUDBParamGroupRequest { + req := &UploadUDBParamGroupRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(false) + return req +} + +// UploadUDBParamGroup - 导入UDB配置 +func (c *UDBClient) UploadUDBParamGroup(req *UploadUDBParamGroupRequest) (*UploadUDBParamGroupResponse, error) { + var err error + var res UploadUDBParamGroupResponse + + err = c.client.InvokeAction("UploadUDBParamGroup", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/attach_udisk.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/attach_udisk.go index 65b6460ae1..78e624aee8 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/attach_udisk.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/attach_udisk.go @@ -12,13 +12,19 @@ import ( type AttachUDiskRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"true"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // UHost实例ID UHostId *string `required:"true"` - // 需要挂载的UDisk实例ID + // 需要挂载的UDisk实例ID. UDiskId *string `required:"true"` } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/clone_udisk.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/clone_udisk.go index b2a0ca80f9..4dfb70be95 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/clone_udisk.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/clone_udisk.go @@ -12,8 +12,14 @@ import ( type CloneUDiskRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"true"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // 实例名称 Name *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/clone_udisk_snapshot.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/clone_udisk_snapshot.go index 3fbf25414b..ec8f9306de 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/clone_udisk_snapshot.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/clone_udisk_snapshot.go @@ -12,8 +12,14 @@ import ( type CloneUDiskSnapshotRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"true"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // 实例名称 Name *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/create_udisk.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/create_udisk.go index 87c7b1a9cd..629ff24e4e 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/create_udisk.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/create_udisk.go @@ -12,8 +12,14 @@ import ( type CreateUDiskRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"true"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // 购买UDisk大小,单位:GB,普通盘: 范围[1~2000], 权限位控制可达8T,若需要请申请开通相关权限;SSD盘: 范围[1~4000]。 Size *int `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/create_udisk_snapshot.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/create_udisk_snapshot.go index 001be5ebf1..d1fa60bab5 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/create_udisk_snapshot.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/create_udisk_snapshot.go @@ -12,8 +12,14 @@ import ( type CreateUDiskSnapshotRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"true"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // 快照的UDisk的Id UDiskId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/delete_udisk.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/delete_udisk.go index 6e9775f9fb..7ab06e7bad 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/delete_udisk.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/delete_udisk.go @@ -12,8 +12,14 @@ import ( type DeleteUDiskRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"true"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // 要删除的UDisk的Id UDiskId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/delete_udisk_snapshot.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/delete_udisk_snapshot.go index d6d72e2fe3..f8cc3af484 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/delete_udisk_snapshot.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/delete_udisk_snapshot.go @@ -12,8 +12,14 @@ import ( type DeleteUDiskSnapshotRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"true"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // 快照Id SnapshotId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/describe_udisk.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/describe_udisk.go index 7a8f878df8..f4ab5005cf 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/describe_udisk.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/describe_udisk.go @@ -12,8 +12,14 @@ import ( type DescribeUDiskRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // UDisk Id(留空返回全部) UDiskId *string `required:"false"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/describe_udisk_price.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/describe_udisk_price.go index 5959af93bd..cf89edd564 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/describe_udisk_price.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/describe_udisk_price.go @@ -12,8 +12,14 @@ import ( type DescribeUDiskPriceRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"true"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // 购买UDisk大小,单位:GB,范围[1~1000] Size *int `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/describe_udisk_snapshot.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/describe_udisk_snapshot.go index f0d8dcdc19..2c14548728 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/describe_udisk_snapshot.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/describe_udisk_snapshot.go @@ -12,8 +12,14 @@ import ( type DescribeUDiskSnapshotRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // 数据偏移量, 默认为0 Offset *int `required:"false"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/describe_udisk_upgrade_price.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/describe_udisk_upgrade_price.go index 73e5f59240..fed17fd652 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/describe_udisk_upgrade_price.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/describe_udisk_upgrade_price.go @@ -12,8 +12,14 @@ import ( type DescribeUDiskUpgradePriceRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"true"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` // 购买UDisk大小,单位:GB,范围[1~2000], 权限位控制可达8T,若需要请申请开通相关权限。 Size *int `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/detach_udisk.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/detach_udisk.go index 063f4419b2..bbf8dccd3a 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/detach_udisk.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/detach_udisk.go @@ -12,8 +12,14 @@ import ( type DetachUDiskRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"true"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // UHost实例ID UHostId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/rename_udisk.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/rename_udisk.go index 663f30a574..8403d9cb65 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/rename_udisk.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/rename_udisk.go @@ -12,8 +12,14 @@ import ( type RenameUDiskRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"true"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // 重命名的UDisk的Id UDiskId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/resize_udisk.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/resize_udisk.go index 277a7678b2..2d8b5c9fe3 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/resize_udisk.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/resize_udisk.go @@ -12,8 +12,14 @@ import ( type ResizeUDiskRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"true"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // UDisk Id UDiskId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/restore_udisk.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/restore_udisk.go index d4b5d670af..4f0f40d45d 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/restore_udisk.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/restore_udisk.go @@ -12,8 +12,14 @@ import ( type RestoreUDiskRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"true"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // 需要恢复的盘id UDiskId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/set_udisk_udata_ark_mode.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/set_udisk_udata_ark_mode.go index 0b34fb3a09..4e50cb9909 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/set_udisk_udata_ark_mode.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/set_udisk_udata_ark_mode.go @@ -12,8 +12,14 @@ import ( type SetUDiskUDataArkModeRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"true"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` // 需要设置数据方舟的UDisk的Id UDiskId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/types_udisk_data_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/types_udisk_data_set.go index 45ce08378e..e7ce25abba 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/types_udisk_data_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/types_udisk_data_set.go @@ -64,4 +64,13 @@ type UDiskDataSet struct { // 云硬盘类型: 普通数据盘:DataDisk,普通系统盘:SystemDisk,SSD数据盘:SSDDataDisk DiskType string + + // 是否支持克隆,1支持 ,0不支持 + CloneEnable int + + // 是否支持快照,1支持 ,0不支持 + SnapEnable int + + // 是否支持开启方舟,1支持 ,0不支持 + ArkSwitchEnable int } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/allocate_udpn.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/allocate_udpn.go index fb30f94c6f..1ed069bb1c 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/allocate_udpn.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/allocate_udpn.go @@ -12,6 +12,12 @@ import ( type AllocateUDPNRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 专线可用区1,支持地域:北京二:cn-bj2, 上海二:cn-sh2, 广东:cn-gd, 亚太: hk, 上海一:cn-sh1, 法兰克福:ge-fra, 新加坡:sg, 洛杉矶:us-la, 华盛顿:us-ws, 东京:jpn-tky Peer1 *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/describe_udpn.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/describe_udpn.go index 4be675c836..4607b8ea3b 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/describe_udpn.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/describe_udpn.go @@ -12,6 +12,12 @@ import ( type DescribeUDPNRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 申请到的 UDPN 资源 ID。若为空,则查询该用户在机房所有的专线信息。非默认项目资源,需填写ProjectId UDPNId *string `required:"false"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/get_udpnline_list.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/get_udpnline_list.go index c78cd1bf36..34326f0311 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/get_udpnline_list.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/get_udpnline_list.go @@ -11,6 +11,10 @@ import ( // GetUDPNLineListRequest is request schema for GetUDPNLineList action type GetUDPNLineListRequest struct { request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"false"` + } // GetUDPNLineListResponse is response schema for GetUDPNLineList action diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/get_udpnprice.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/get_udpnprice.go index be767064d0..9ef6e01758 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/get_udpnprice.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/get_udpnprice.go @@ -12,6 +12,9 @@ import ( type GetUDPNPriceRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"false"` + // 专线可用区1,支持地域:北京二:cn-bj2, 上海二:cn-sh2, 广东:cn-gd, 亚太: hk, 上海一:cn-sh1, 法兰克福:ge-fra, 新加坡:sg, 洛杉矶:us-la, 华盛顿:us-ws, 东京:jpn-tky Peer1 *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/get_udpnupgrade_price.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/get_udpnupgrade_price.go index 59ca220cfb..a11855f672 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/get_udpnupgrade_price.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/get_udpnupgrade_price.go @@ -12,6 +12,12 @@ import ( type GetUDPNUpgradePriceRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 专线带宽资源 Id UDPNId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/modify_udpnbandwidth.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/modify_udpnbandwidth.go index a3d4505d3b..24dc0d4000 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/modify_udpnbandwidth.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/modify_udpnbandwidth.go @@ -12,6 +12,12 @@ import ( type ModifyUDPNBandwidthRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // UDPN Id UDPNId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/release_udpn.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/release_udpn.go index cdd550ffd5..deed0050cd 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/release_udpn.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udpn/release_udpn.go @@ -12,6 +12,12 @@ import ( type ReleaseUDPNRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // UDPN 资源 Id UDPNId *string `required:"true"` } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/copy_custom_image.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/copy_custom_image.go index 6461dcd181..56c08be7da 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/copy_custom_image.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/copy_custom_image.go @@ -12,8 +12,14 @@ import ( type CopyCustomImageRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // 源镜像Id, 参见 DescribeImage SourceImageId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/create_custom_image.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/create_custom_image.go index c9744eee66..67b3465dc1 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/create_custom_image.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/create_custom_image.go @@ -12,8 +12,14 @@ import ( type CreateCustomImageRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) UHostId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_image.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_image.go index ddcd885565..c953fe6b52 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_image.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_image.go @@ -12,8 +12,14 @@ import ( type DescribeImageRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // 镜像类型。标准镜像:Base,镜像市场:Business, 自定义镜像:Custom,默认返回所有类型 ImageType *string `required:"false"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_uhost_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_uhost_instance.go index e4d650d72e..a905c22c10 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_uhost_instance.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_uhost_instance.go @@ -12,8 +12,14 @@ import ( type DescribeUHostInstanceRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // 【数组】UHost主机的资源ID,例如UHostIds.0代表希望获取信息 的主机1,UHostIds.1代表主机2。 如果不传入,则返回当前Region 所有符合条件的UHost实例。 UHostIds []string `required:"false"` @@ -29,6 +35,9 @@ type DescribeUHostInstanceRequest struct { // 返回数据长度,默认为20,最大100 Limit *int `required:"false"` + + // 硬件隔离组id + IsolationGroup *string `required:"false"` } // DescribeUHostInstanceResponse is response schema for DescribeUHostInstance action diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_uhost_tags.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_uhost_tags.go index e276e9c79b..aa364e3c18 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_uhost_tags.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_uhost_tags.go @@ -12,8 +12,15 @@ import ( type DescribeUHostTagsRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + } // DescribeUHostTagsResponse is response schema for DescribeUHostTags action diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_instance_price.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_instance_price.go index ee63a960e1..b35a12d9dd 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_instance_price.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_instance_price.go @@ -9,46 +9,51 @@ import ( type GetUHostInstancePriceRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // 镜像Id,可通过 [DescribeImage](describe_image.html) 获取镜像ID ImageId *string `required:"true"` - // 虚拟CPU核心数,单位: 个,范围: [1,16],最小值为1,其他值是2的整数倍 + // 虚拟CPU核数。可选参数:1-32(可选范围与UHostType相关)。默认值: 4 CPU *int `required:"true"` - // 内存容量大小,单位: MB,范围: [2048,65536],步长: 2048 不同机房的网络增强支持情况不同。详情请参考控制台。 + // 内存大小。单位:MB。范围 :[1024, 262144],取值为1024的倍数(可选范围与UHostType相关)。默认值:8192 Memory *int `required:"true"` - // 购买台数,范围[1,5] - Count *int `required:"true"` + // 【未启用】购买台数,范围[1,5] + Count *int `required:"false"` // 磁盘列表 Disks []UHostDisk - // GPU核心数,单位:个,范围[0,4] + // GPU卡核心数。仅GPU机型支持此字段(可选范围与UHostType相关)。 GPU *int `required:"false"` - // 计费类型。Year,Month,Dynamic,默认返回全部计费方式对应的价格 + // 计费模式。枚举值为: \\ > Year,按年付费; \\ > Month,按月付费;\\ > Dynamic,按小时付费 \\ 默认为月付。 ChargeType *string `required:"false"` - // 磁盘类型,同时设定系统盘和数据盘, 枚举值为:LocalDisk,本地磁盘; UDisk,云硬盘; 默认为LocalDisk 仅部分可用区支持云硬盘方式的主机存储方式,具体请查询控制台。 + // 【待废弃】磁盘类型,同时设定系统盘和数据盘, 枚举值为:LocalDisk,本地磁盘; UDisk,云硬盘; 默认为LocalDisk 仅部分可用区支持云硬盘方式的主机存储方式,具体请查询控制台。 StorageType *string `required:"false"` - // 数据盘大小,单位: GB,范围[0,1000],步长: 10,默认值: 0 + // 【待废弃】数据盘大小,单位: GB,范围[0,1000],步长: 10,默认值: 0 DiskSpace *int `required:"false"` - // 网络增强 默认是Normal, 目前仅支持Normal(不开启) 和 Super(开启网络增强)。 不同机房的网络增强支持情况不同。详情请参考控制台。 + // 网络增强。枚举值:\\ > Normal,不开启 \\ > Super,开启 \\ 默认值未为Normal。 NetCapability *string `required:"false"` - // 方舟机型。No,Yes。默认是No。 + // 【待废弃】方舟机型。No,Yes。默认是No。 TimemachineFeature *string `required:"false"` // 主机类型 Normal: 标准机型 SSD:SSD机型 BigData:大数据 GPU:GPU型G1(原GPU型) GPU_G2:GPU型G2 GPU_G3:GPU型G3 不同机房的主机类型支持情况不同。详情请参考控制台。 UHostType *string `required:"false"` - - // 1:普通云主机;2:抢占性云主机;默认普通 + // 【未支持】1:普通云主机;2:抢占性云主机;默认普通 LifeCycle *int `required:"false"` // 购买时长。默认: 1。按小时购买(Dynamic)时无需此参数。 月付时,此参数传0,代表了购买至月末。 diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_instance_vnc_info.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_instance_vnc_info.go index 8a5f3ff108..9881c77c24 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_instance_vnc_info.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_instance_vnc_info.go @@ -12,8 +12,14 @@ import ( type GetUHostInstanceVncInfoRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // UHost实例ID 参见 [DescribeUHostInstance](./describe_uhost_instance.html) UHostId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_upgrade_price.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_upgrade_price.go index 5ac3d14806..c7efbb2457 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_upgrade_price.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_upgrade_price.go @@ -12,22 +12,28 @@ import ( type GetUHostUpgradePriceRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` - // UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + + // UHost实例ID。 参见 [DescribeUHostInstance](describe_uhost_instance.html)。 UHostId *string `required:"true"` - // 虚拟CPU核心数,单位: 个,范围: [1,16],最小值为1,其他值是2的整数倍 默认值是该主机当前CPU数。 + // 虚拟CPU核数。可选参数:1-32(可选范围与UHostType相关)。默认值为当前实例的CPU核数。 CPU *int `required:"false"` - // 内存容量大小,单位: MB,范围: [2048,65536],步长: 2048 北京BGP C机房最小支持1024(限Linux系统)。 默认值是该主机当前内存大小。 + // 内存大小。单位:MB。范围 :[1024, 262144],取值为1024的倍数(可选范围与UHostType相关)。默认值为当前实例的内存大小。 Memory *int `required:"false"` - // 数据盘大小,单位: GB,范围[0,1000],步长: 10, 默认值是该主机当前数据盘大小。 + // 【待废弃】数据盘大小,单位: GB,范围[0,1000],步长: 10, 默认值是该主机当前数据盘大小。 DiskSpace *int `required:"false"` - // 系统大小,单位: GB,范围[20,100],步长: 10。 + // 【待废弃】系统大小,单位: GB,范围[20,100],步长: 10。 BootDiskSpace *int `required:"false"` // 方舟机型。No,Yes。默认是No。 @@ -36,7 +42,7 @@ type GetUHostUpgradePriceRequest struct { // 网卡升降级(1,表示升级,2表示降级,0表示不变) NetCapValue *int `required:"false"` - // 主机系列,目前支持N1,N2 + // 【待废弃】主机系列,目前支持N1,N2 HostType *string `required:"false"` } @@ -44,7 +50,7 @@ type GetUHostUpgradePriceRequest struct { type GetUHostUpgradePriceResponse struct { response.CommonBase - // 升级差价 + // 规格调整差价。精确到小数点后2位。 Price float64 } @@ -60,7 +66,7 @@ func (c *UHostClient) NewGetUHostUpgradePriceRequest() *GetUHostUpgradePriceRequ return req } -// GetUHostUpgradePrice - 获取UHost实例升级配置的价格。 +// GetUHostUpgradePrice - 获取UHost实例升级配置的价格。可选配置范围请参考[[api:uhost-api:uhost_type|云主机机型说明]]。 func (c *UHostClient) GetUHostUpgradePrice(req *GetUHostUpgradePriceRequest) (*GetUHostUpgradePriceResponse, error) { var err error var res GetUHostUpgradePriceResponse diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/import_custom_image.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/import_custom_image.go index b6a58e1419..159a4bd0fd 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/import_custom_image.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/import_custom_image.go @@ -12,6 +12,12 @@ import ( type ImportCustomImageRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 镜像名称 ImageName *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_name.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_name.go index c66d6a46b6..436170cdbf 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_name.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_name.go @@ -12,8 +12,14 @@ import ( type ModifyUHostInstanceNameRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) UHostId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_remark.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_remark.go index 6d9019f5b7..224a660f8e 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_remark.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_remark.go @@ -12,8 +12,14 @@ import ( type ModifyUHostInstanceRemarkRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) UHostId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_tag.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_tag.go index b2da020e1d..54d6dac917 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_tag.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_tag.go @@ -12,8 +12,14 @@ import ( type ModifyUHostInstanceTagRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) UHostId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/poweroff_uhost_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/poweroff_uhost_instance.go index 476ca63a28..3cd0bdbc37 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/poweroff_uhost_instance.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/poweroff_uhost_instance.go @@ -12,8 +12,14 @@ import ( type PoweroffUHostInstanceRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // UHost实例ID 参见 [DescribeUHostInstance](./describe_uhost_instance.html) UHostId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/reboot_uhost_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/reboot_uhost_instance.go index 0b000b1ced..5acf24b90c 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/reboot_uhost_instance.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/reboot_uhost_instance.go @@ -12,8 +12,14 @@ import ( type RebootUHostInstanceRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) UHostId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/reinstall_uhost_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/reinstall_uhost_instance.go index 9b865530e7..e18fc22c53 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/reinstall_uhost_instance.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/reinstall_uhost_instance.go @@ -27,6 +27,9 @@ type ReinstallUHostInstanceRequest struct { // 镜像Id,默认使用原镜像 参见 [DescribeImage](describe_image.html) ImageId *string `required:"false"` + // 系统盘大小。 单位:GB, 范围[20,100], 步长:10 + BootDiskSpace *int `required:"false"` + // 是否保留数据盘,保留:Yes,不报留:No, 默认:Yes;如果是从Windows重装为Linux或反之,则无法保留数据盘 ReserveDisk *string `required:"false"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/reset_uhost_instance_password.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/reset_uhost_instance_password.go index 2e84aad430..1ddca8cee0 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/reset_uhost_instance_password.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/reset_uhost_instance_password.go @@ -15,8 +15,14 @@ import ( type ResetUHostInstancePasswordRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // UHost实例ID UHostId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/resize_uhost_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/resize_uhost_instance.go index 4cd85b71bf..c9608cd3fb 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/resize_uhost_instance.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/resize_uhost_instance.go @@ -12,8 +12,14 @@ import ( type ResizeUHostInstanceRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) UHostId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/start_uhost_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/start_uhost_instance.go index 9e9a343872..6ffab425ea 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/start_uhost_instance.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/start_uhost_instance.go @@ -12,11 +12,20 @@ import ( type StartUHostInstanceRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) UHostId *string `required:"true"` + + // 加密盘密码 + DiskPassword *string `required:"false"` } // StartUHostInstanceResponse is response schema for StartUHostInstance action diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/stop_uhost_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/stop_uhost_instance.go index f33a323f53..bf74bced6b 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/stop_uhost_instance.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/stop_uhost_instance.go @@ -12,8 +12,14 @@ import ( type StopUHostInstanceRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) UHostId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/terminate_custom_image.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/terminate_custom_image.go index 7bc7710be1..5501e0d6cb 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/terminate_custom_image.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/terminate_custom_image.go @@ -12,8 +12,11 @@ import ( type TerminateCustomImageRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // 自制镜像ID 参见 [DescribeImage](describe_image.html) ImageId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/terminate_uhost_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/terminate_uhost_instance.go index edbc01357e..e12284cdf5 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/terminate_uhost_instance.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/terminate_uhost_instance.go @@ -12,8 +12,14 @@ import ( type TerminateUHostInstanceRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // UHost资源Id 参见 [DescribeUHostInstance](describe_uhost_instance.html) UHostId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_disk_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_disk_set.go index c32978ea3b..1c9863d8c6 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_disk_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_disk_set.go @@ -23,12 +23,12 @@ type UHostDiskSet struct { // 磁盘大小,单位: GB Size int + // 备份方案。若开通了数据方舟,则为DataArk + BackupType string + // 是否是系统盘 IsBoot string // 磁盘类型 DiskType string - - // 备份类型,DataArk - BackupType string } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_image_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_image_set.go index b3be06cb1c..043b28e9bc 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_image_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_image_set.go @@ -8,15 +8,15 @@ you can also see https://docs.ucloud.cn for detail. */ type UHostImageSet struct { + // 可用区,参见 [可用区列表](../summary/regionlist.html) | + Zone string + // 镜像ID ImageId string // 镜像名称 ImageName string - // 可用区,参见 [可用区列表](../summary/regionlist.html) | - Zone string - // 操作系统类型:Liunx,Windows OsType string @@ -26,7 +26,7 @@ type UHostImageSet struct { // 镜像类型 标准镜像:Base, 行业镜像:Business,自定义镜像:Custom ImageType string - // 特殊状态标识, 目前只有[NetEnhnced](高包量机型) + // 特殊状态标识, 目前包含NetEnhnced(网络增强1.0), NetEnhanced_Ultra](网络增强2.0) Features []string // 行业镜像类型(仅行业镜像将返回这个值) @@ -52,4 +52,7 @@ type UHostImageSet struct { // 镜像大小 ImageSize int + + // 默认值为空'''。当CentOS 7.3/7.4/7.5等镜像会标记为“Broadwell” + MinimalCPU string } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_instance_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_instance_set.go index 1e7a006407..2c4bdac264 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_instance_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_instance_set.go @@ -65,7 +65,7 @@ type UHostInstanceSet struct { // 详细信息见 UHostIPSet IPSet []UHostIPSet - // 网络增强。目前仅支持Normal和Super + // 网络增强。Normal: 无;Super: 网络增强1.0; Ultra: 网络增强2.0 NetCapability string // 【建议不再使用】网络状态。 连接:Connected, 断开:NotConnected @@ -106,4 +106,7 @@ type UHostInstanceSet struct { // 总的存储空间。包含系统盘与全部数据盘的总容量。 TotalDiskSpace int + + // 隔离组id,不在隔离组则返回"" + IsolationGroup string } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_ipset.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_ipset.go index 690439bec4..d9c3993c9c 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_ipset.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_ipset.go @@ -8,7 +8,7 @@ you can also see https://docs.ucloud.cn for detail. */ type UHostIPSet struct { - // 电信: China-telecom,联通: China-unicom, 国际: Internationl,BGP: Bgp,内网: Private 双线: Duplet + // 国际: Internation,BGP: BGP,内网: Private Type string // IP资源ID (内网IP无对应的资源ID) @@ -17,12 +17,15 @@ type UHostIPSet struct { // IP地址 IP string + // IP对应的带宽, 单位: Mb (内网IP不显示带宽信息) + Bandwidth int + + // 是否默认的弹性网卡的信息。true: 是默认弹性网卡;其他值:不是。 + Default string + // VPC ID VPCId string // Subnet Id SubnetId string - - // IP对应的带宽, 单位: Mb (内网IP不显示带宽信息) - Bandwidth int } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/upgrade_to_ark_uhost_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/upgrade_to_ark_uhost_instance.go index 2db25d0ea8..d43572ee4e 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/upgrade_to_ark_uhost_instance.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/upgrade_to_ark_uhost_instance.go @@ -12,8 +12,11 @@ import ( type UpgradeToArkUHostInstanceRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"true"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"true"` // UHost主机的资源ID,例如UHostIds.0代表希望升级的主机1,UHostIds.1代表主机2。 UHostIds []string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/allocate_backend.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/allocate_backend.go index fb1c8abfe2..58c73caac2 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/allocate_backend.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/allocate_backend.go @@ -12,6 +12,12 @@ import ( type AllocateBackendRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // 负载均衡实例的ID ULBId *string `required:"true"` @@ -27,9 +33,11 @@ type AllocateBackendRequest struct { // 所添加的后端资源服务端口,取值范围[1-65535],默认80 Port *int `required:"false"` + // 所添加的后端RS权重(在加权轮询算法下有效),取值范围[0-100],默认为1 + Weight *int `required:"false"` + // 后端实例状态开关,枚举值: 1:启用; 0:禁用 默认为启用 Enabled *int `required:"false"` - Weight *int } // AllocateBackendResponse is response schema for AllocateBackend action diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/allocate_backend_batch.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/allocate_backend_batch.go index 302d37e374..4ded0c7707 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/allocate_backend_batch.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/allocate_backend_batch.go @@ -12,13 +12,19 @@ import ( type AllocateBackendBatchRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // 负载均衡实例的ID ULBId *string `required:"true"` // VServer实例的ID VServerId *string `required:"true"` - // 用| 分割字段,格式:ResourceId| ResourceType| Port| Enabled|IP。ResourceId:所添加的后端资源的资源ID;ResourceType:所添加的后端资源的类型,枚举值:UHost -> 云主机;UPM -> 物理云主机; UDHost -> 私有专区主机;UDocker -> 容器,默认值为“UHost”;Port:所添加的后端资源服务端口,取值范围[1-65535];Enabled:后端实例状态开关,枚举值: 1:启用; 0:禁用;IP:后端资源内网ip; + // 用| 分割字段,格式:ResourceId| ResourceType| Port| Enabled|IP| Weight。ResourceId:所添加的后端资源的资源ID;ResourceType:所添加的后端资源的类型,枚举值:UHost -> 云主机;UPM -> 物理云主机; UDHost -> 私有专区主机;UDocker -> 容器,默认值为“UHost”;Port:所添加的后端资源服务端口,取值范围[1-65535];Enabled:后端实例状态开关,枚举值: 1:启用; 0:禁用;IP:后端资源内网ip;Weight:所添加的后端RS权重(在加权轮询算法下有效),取值范围[0-100],默认为1 Backends []string `required:"true"` // 已弃用,指定 Api 版本 diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/bind_ssl.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/bind_ssl.go index 654f983a4e..ed57f8733a 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/bind_ssl.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/bind_ssl.go @@ -12,6 +12,12 @@ import ( type BindSSLRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // 所绑定ULB实例ID ULBId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_policy.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_policy.go index f1a2197377..741a03736c 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_policy.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_policy.go @@ -12,6 +12,12 @@ import ( type CreatePolicyRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // 需要添加内容转发策略的负载均衡实例ID ULBId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_ssl.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_ssl.go index c95d2eb10b..c5e2a1dfff 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_ssl.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_ssl.go @@ -12,6 +12,12 @@ import ( type CreateSSLRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // SSL证书的名字,默认值为空 SSLName *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_ulb.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_ulb.go index 5c41030b97..56b9b2310f 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_ulb.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_ulb.go @@ -12,6 +12,12 @@ import ( type CreateULBRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // 负载均衡的名字,默认值为“ULB” ULBName *string `required:"false"` @@ -27,6 +33,9 @@ type CreateULBRequest struct { // 创建的ULB是否为内网模式 InnerMode *string `required:"false"` + // 创建内网ULB时指定内网IP。若不传值,则随机分配当前子网下的IP(暂时不对外开放,创建外网ULB该字段会忽略) + PrivateIp *string `required:"false"` + // 付费方式 ChargeType *string `required:"false"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_vserver.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_vserver.go index e75dbef127..c9a06efc77 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_vserver.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_vserver.go @@ -12,6 +12,12 @@ import ( type CreateVServerRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 负载均衡实例ID ULBId *string `required:"true"` @@ -27,7 +33,7 @@ type CreateVServerRequest struct { // VServer后端端口,取值范围[1-65535];默认值为80 FrontendPort *int `required:"false"` - // VServer负载均衡模式,枚举值:Roundrobin -> 轮询;Source -> 源地址;ConsistentHash -> 一致性哈希;SourcePort -> 源地址(计算端口);ConsistentHashPort -> 一致性哈希(计算端口)。ConsistentHash,SourcePort,ConsistentHashPort 只在报文转发中使用;Roundrobin和Source在请求代理和报文转发中使用。默认为:"Roundrobin" + // VServer负载均衡模式,枚举值:Roundrobin -> 轮询;Source -> 源地址;ConsistentHash -> 一致性哈希;SourcePort -> 源地址(计算端口);ConsistentHashPort -> 一致性哈希(计算端口); WeightRoundrobin -> 加权轮询; Leastconn -> 最小连接数。ConsistentHash,SourcePort,ConsistentHashPort 只在报文转发中使用;Leastconn只在请求代理中使用;Roundrobin、Source和WeightRoundrobin在请求代理和报文转发中使用。默认为:"Roundrobin" Method *string `required:"false"` // VServer会话保持方式,默认关闭会话保持。枚举值:None -> 关闭;ServerInsert -> 自动生成KEY;UserDefined -> 用户自定义KEY。 diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_policy.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_policy.go index fd0ed2f9d0..1ccdf84897 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_policy.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_policy.go @@ -12,6 +12,12 @@ import ( type DeletePolicyRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // 内容转发策略ID PolicyId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_ssl.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_ssl.go index 2488577293..cbc26e3684 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_ssl.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_ssl.go @@ -12,6 +12,12 @@ import ( type DeleteSSLRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // SSL证书的ID SSLId *string `required:"true"` } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_ulb.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_ulb.go index da7ac6d7c4..cf07d59e96 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_ulb.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_ulb.go @@ -12,6 +12,12 @@ import ( type DeleteULBRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // 负载均衡实例的ID ULBId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_vserver.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_vserver.go index 3456788241..fe89cf3cdd 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_vserver.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_vserver.go @@ -12,6 +12,12 @@ import ( type DeleteVServerRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // 负载均衡实例的ID ULBId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_ssl.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_ssl.go index 168060459c..c00a5f0ab6 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_ssl.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_ssl.go @@ -12,6 +12,12 @@ import ( type DescribeSSLRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // SSL证书的Id SSLId *string `required:"false"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_ulb.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_ulb.go index e12372006d..1446e80dad 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_ulb.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_ulb.go @@ -12,6 +12,12 @@ import ( type DescribeULBRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // 数据偏移量,默认为0 Offset *int `required:"false"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_vserver.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_vserver.go index 9ac69bc6cd..99bc86abaf 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_vserver.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_vserver.go @@ -12,6 +12,12 @@ import ( type DescribeVServerRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // 负载均衡实例的Id ULBId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/release_backend.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/release_backend.go index 91fae690b6..fb9c061dee 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/release_backend.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/release_backend.go @@ -12,6 +12,12 @@ import ( type ReleaseBackendRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // 负载均衡实例的ID ULBId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbbackend_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbbackend_set.go index e35fe60bf7..3d6eba0258 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbbackend_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbbackend_set.go @@ -34,5 +34,7 @@ type ULBBackendSet struct { // 后端资源实例的资源所在的子网的ID SubnetId string - Weight int + + // ULB 后端实例的权重 + Weight int } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/unbind_ssl.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/unbind_ssl.go index 4be85058ba..2bfb2fd04c 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/unbind_ssl.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/unbind_ssl.go @@ -12,6 +12,12 @@ import ( type UnbindSSLRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // 所绑定ULB实例ID ULBId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_backend_attribute.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_backend_attribute.go index d143d0bb68..af6a74d576 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_backend_attribute.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_backend_attribute.go @@ -12,6 +12,12 @@ import ( type UpdateBackendAttributeRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // 负载均衡资源ID ULBId *string `required:"true"` @@ -21,9 +27,11 @@ type UpdateBackendAttributeRequest struct { // 后端资源服务端口,取值范围[1-65535] Port *int `required:"false"` + // 所添加的后端RS权重(在加权轮询算法下有效),取值范围[0-100],默认为1 + Weight *int `required:"false"` + // 后端实例状态开关 Enabled *int `required:"false"` - Weight *int } // UpdateBackendAttributeResponse is response schema for UpdateBackendAttribute action diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_policy.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_policy.go index 6b34c7b85b..6d2619db32 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_policy.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_policy.go @@ -12,6 +12,12 @@ import ( type UpdatePolicyRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // 需要添加内容转发策略的负载均衡实例ID ULBId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_ulbattribute.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_ulbattribute.go index 1af3bbfa34..9c32c752dd 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_ulbattribute.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_ulbattribute.go @@ -12,6 +12,12 @@ import ( type UpdateULBAttributeRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // ULB资源ID ULBId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_vserver_attribute.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_vserver_attribute.go index a1120bf13f..739d145230 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_vserver_attribute.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_vserver_attribute.go @@ -12,6 +12,12 @@ import ( type UpdateVServerAttributeRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // 负载均衡实例ID ULBId *string `required:"true"` @@ -24,7 +30,7 @@ type UpdateVServerAttributeRequest struct { // VServer协议类型,请求代理只支持修改为 HTTP/HTTPS,报文转发VServer只支持修改为 TCP/UDP Protocol *string `required:"false"` - // VServer负载均衡算法,ConsistentHash,SourcePort,ConsistentHashPort 只在报文转发中使用;Roundrobin和Source在请求代理和报文转发中使用。 + // VServer负载均衡模式,枚举值:Roundrobin -> 轮询;Source -> 源地址;ConsistentHash -> 一致性哈希;SourcePort -> 源地址(计算端口);ConsistentHashPort -> 一致性哈希(计算端口); WeightRoundrobin -> 加权轮询; Leastconn -> 最小连接数。ConsistentHash,SourcePort,ConsistentHashPort 只在报文转发中使用;Leastconn只在请求代理中使用;Roundrobin、Source和WeightRoundrobin在请求代理和报文转发中使用。默认为:"Roundrobin" Method *string `required:"false"` // VServer会话保持模式,若无此字段则不做修改。枚举值:None:关闭;ServerInsert:自动生成KEY;UserDefined:用户自定义KEY。 diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/allocate_eip.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/allocate_eip.go index 9904675990..a8be75637f 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/allocate_eip.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/allocate_eip.go @@ -12,6 +12,12 @@ import ( type AllocateEIPRequest struct { request.CommonBase + // [公共参数] 地域。 + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 + // ProjectId *string `required:"false"` + // 弹性IP的线路如下: 国际: International BGP: Bgp 各地域允许的线路参数如下: cn-sh1: Bgp cn-sh2: Bgp cn-gd: Bgp cn-bj1: Bgp cn-bj2: Bgp hk: International us-ca: International th-bkk: International kr-seoul:International us-ws:International ge-fra:International sg:International tw-kh:International.其他海外线路均为 International OperatorName *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/allocate_share_bandwidth.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/allocate_share_bandwidth.go index 720886febc..2934d71e6f 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/allocate_share_bandwidth.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/allocate_share_bandwidth.go @@ -12,6 +12,12 @@ import ( type AllocateShareBandwidthRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 + // ProjectId *string `required:"false"` + // 共享带宽名字 Name *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/allocate_vip.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/allocate_vip.go index 643f3c2ffa..430de24ae3 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/allocate_vip.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/allocate_vip.go @@ -12,8 +12,14 @@ import ( type AllocateVIPRequest struct { request.CommonBase - // 可用区 - Zone *string `required:"false"` + // [公共参数] 地域 + // Region *string `required:"true"` + + // [公共参数] 可用区 + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // 指定vip所属的VPC VPCId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/associate_eipwith_share_bandwidth.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/associate_eipwith_share_bandwidth.go index 519c4c3448..fcd026ff77 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/associate_eipwith_share_bandwidth.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/associate_eipwith_share_bandwidth.go @@ -12,6 +12,12 @@ import ( type AssociateEIPWithShareBandwidthRequest struct { request.CommonBase + // [公共参数] 地域。 + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 + // ProjectId *string `required:"false"` + // 要加入共享带宽的EIP的资源Id EIPIds []string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/bind_eip.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/bind_eip.go index bff7ed0f3f..1e41889eca 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/bind_eip.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/bind_eip.go @@ -12,10 +12,16 @@ import ( type BindEIPRequest struct { request.CommonBase + // [公共参数] 地域 + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写 + // ProjectId *string `required:"false"` + // 弹性IP的资源Id EIPId *string `required:"true"` - // 弹性IP请求绑定的资源类型, 枚举值为: uhost: 云主机; vrouter: 虚拟路由器; ulb, 负载均衡器 upm: 物理机; hadoophost: 大数据集群;fortresshost:堡垒机;udockhost:容器;udhost:私有专区主机;natgw:natgw;udb:udb;vpngw:ipsec vpn;ucdr:云灾备;dbaudit:数据库审计; + // 弹性IP请求绑定的资源类型, 枚举值为: uhost: 云主机; ulb, 负载均衡器 upm: 物理机; hadoophost: 大数据集群;fortresshost:堡垒机;udockhost:容器;udhost:私有专区主机;natgw:natgw;udb:udb;vpngw:ipsec vpn;ucdr:云灾备;dbaudit:数据库审计; ResourceType *string `required:"true"` // 弹性IP请求绑定的资源ID diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/create_bandwidth_package.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/create_bandwidth_package.go index d307de3900..50e110da45 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/create_bandwidth_package.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/create_bandwidth_package.go @@ -12,6 +12,12 @@ import ( type CreateBandwidthPackageRequest struct { request.CommonBase + // [公共参数] 地域 + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 + // ProjectId *string `required:"false"` + // 带宽大小(单位Mbps), 取值范围[2,800] (最大值受地域限制) Bandwidth *int `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/create_firewall.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/create_firewall.go index e40db899b0..c46318c489 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/create_firewall.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/create_firewall.go @@ -12,11 +12,17 @@ import ( type CreateFirewallRequest struct { request.CommonBase + // [公共参数] 地域 + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写 + // ProjectId *string `required:"false"` + // 防火墙规则,例如:TCP|22|192.168.1.1/22|DROP|LOW|禁用22端口,第一个参数代表协议:第二个参数代表端口号,第三个参数为ip,第四个参数为ACCEPT(接受)和DROP(拒绝),第五个参数优先级:HIGH(高),MEDIUM(中),LOW(低),第六个参数为该条规则的自定义备注 Rule []string `required:"true"` - // 防火墙名称, 默认为Firewall - Name *string `required:"false"` + // 防火墙名称 + Name *string `required:"true"` // 防火墙业务组,默认为Default Tag *string `required:"false"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/delete_bandwidth_package.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/delete_bandwidth_package.go index e1477a2bde..7b9a52ebde 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/delete_bandwidth_package.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/delete_bandwidth_package.go @@ -12,6 +12,12 @@ import ( type DeleteBandwidthPackageRequest struct { request.CommonBase + // [公共参数] 地域 + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写 + // ProjectId *string `required:"false"` + // 带宽包资源ID BandwidthPackageId *string `required:"true"` } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/delete_firewall.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/delete_firewall.go index bf9e9f44d4..0f2cd7267a 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/delete_firewall.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/delete_firewall.go @@ -12,6 +12,12 @@ import ( type DeleteFirewallRequest struct { request.CommonBase + // [公共参数] 地域 + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写 + // ProjectId *string `required:"false"` + // 防火墙资源ID FWId *string `required:"true"` } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_bandwidth_package.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_bandwidth_package.go index 20d9ceeca0..dfaf47d33e 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_bandwidth_package.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_bandwidth_package.go @@ -12,6 +12,12 @@ import ( type DescribeBandwidthPackageRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 返回数据分页值, 取值范围为 [0,10000000] 之间的整数, 默认为20 Limit *int `required:"false"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_bandwidth_usage.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_bandwidth_usage.go index 68b00174d2..610dd779bd 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_bandwidth_usage.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_bandwidth_usage.go @@ -12,6 +12,12 @@ import ( type DescribeBandwidthUsageRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 返回数据分页值, 取值范围为 [0,10000000] 之间的整数, 默认为20 Limit *int `required:"false"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_eip.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_eip.go index d514970496..68a3ec9809 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_eip.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_eip.go @@ -12,6 +12,12 @@ import ( type DescribeEIPRequest struct { request.CommonBase + // [公共参数] 地域 + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写 + // ProjectId *string `required:"false"` + // 弹性IP的资源ID如果为空, 则返回当前 Region中符合条件的的所有EIP EIPIds []string `required:"false"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_firewall.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_firewall.go index 4fa885868f..59b506e8cc 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_firewall.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_firewall.go @@ -12,10 +12,16 @@ import ( type DescribeFirewallRequest struct { request.CommonBase + // [公共参数] 地域 + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写 + // ProjectId *string `required:"false"` + // 防火墙ID,默认为返回所有防火墙 FWId *string `required:"false"` - // 绑定防火墙组的资源类型,如uhost + // 绑定防火墙组的资源类型,默认为全部资源类型。枚举值为:"unatgw",NAT网关; "uhost",云主机; "upm",物理云主机; "hadoophost",hadoop节点; "fortresshost",堡垒机; "udhost",私有专区主机;"udockhost",容器;"dbaudit",数据库审计. ResourceType *string `required:"false"` // 绑定防火墙组的资源ID @@ -33,7 +39,9 @@ type DescribeFirewallResponse struct { response.CommonBase // 获取的防火墙组详细信息 参见 FirewallDataSet - DataSet []FirewallDataSet + DataSet []FirewallDataSet + + // 数量 TotalCount int } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_firewall_resource.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_firewall_resource.go index be0f28e800..4ebd84eacc 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_firewall_resource.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_firewall_resource.go @@ -12,6 +12,12 @@ import ( type DescribeFirewallResourceRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 防火墙ID FWId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_share_bandwidth.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_share_bandwidth.go index e953e599cf..bf7c417a0d 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_share_bandwidth.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_share_bandwidth.go @@ -12,6 +12,12 @@ import ( type DescribeShareBandwidthRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 需要返回的共享带宽Id ShareBandwidthIds []string `required:"false"` } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_vip.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_vip.go index 3822c94b57..738121588a 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_vip.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_vip.go @@ -12,8 +12,14 @@ import ( type DescribeVIPRequest struct { request.CommonBase - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone *string `required:"false"` + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html) + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` // vpc的id,指定SubnetId时必填 VPCId *string `required:"false"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/disassociate_eipwith_share_bandwidth.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/disassociate_eipwith_share_bandwidth.go index d30c255d3e..0947ceeaaa 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/disassociate_eipwith_share_bandwidth.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/disassociate_eipwith_share_bandwidth.go @@ -12,6 +12,12 @@ import ( type DisassociateEIPWithShareBandwidthRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 共享带宽ID ShareBandwidthId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eippay_mode.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eippay_mode.go index e1054bf11b..5cdc372080 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eippay_mode.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eippay_mode.go @@ -12,6 +12,12 @@ import ( type GetEIPPayModeRequest struct { request.CommonBase + // [公共参数] 地域 + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写 + // ProjectId *string `required:"false"` + // 弹性IP的资源Id EIPId []string `required:"true"` } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eipprice.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eipprice.go index 9dc1bb4a98..51be44fc01 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eipprice.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eipprice.go @@ -12,6 +12,12 @@ import ( type GetEIPPriceRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 弹性IP的线路如下: 国际: International BGP: Bgp 各地域允许的线路参数如下: cn-sh1: Bgp cn-sh2: Bgp cn-gd: Bgp cn-bj1: Bgp cn-bj2: Bgp hk: International us-ca: International th-bkk: International kr-seoul:International us-ws:International ge-fra:International sg:International tw-kh:International.其他海外线路均为 International OperatorName *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eipupgrade_price.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eipupgrade_price.go index 97e9ff3997..f2b24ba5b0 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eipupgrade_price.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eipupgrade_price.go @@ -12,6 +12,12 @@ import ( type GetEIPUpgradePriceRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 弹性IP的资源ID EIPId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/grant_firewall.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/grant_firewall.go index 9dab5ca863..f4c6d19a29 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/grant_firewall.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/grant_firewall.go @@ -12,10 +12,16 @@ import ( type GrantFirewallRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 防火墙资源ID FWId *string `required:"true"` - // 所应用资源类型,如UHost + // 绑定防火墙组的资源类型,默认为全部资源类型。枚举值为:"unatgw",NAT网关; "uhost",云主机; "upm",物理云主机; "hadoophost",hadoop节点; "fortresshost",堡垒机; "udhost",私有专区主机;"udockhost",容器;"dbaudit",数据库审计. ResourceType *string `required:"true"` // 所应用资源ID diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/modify_eipbandwidth.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/modify_eipbandwidth.go index 39d47b098e..f3a5c7d7d1 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/modify_eipbandwidth.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/modify_eipbandwidth.go @@ -12,6 +12,12 @@ import ( type ModifyEIPBandwidthRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 弹性IP的资源ID EIPId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/modify_eipweight.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/modify_eipweight.go index 5a02f10547..2e2f5a22ff 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/modify_eipweight.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/modify_eipweight.go @@ -12,6 +12,12 @@ import ( type ModifyEIPWeightRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 弹性IP的资源ID EIPId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_eip.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_eip.go index 04a8e67150..2eb41a3d65 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_eip.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_eip.go @@ -12,6 +12,12 @@ import ( type ReleaseEIPRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 弹性IP的资源ID EIPId *string `required:"true"` } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_share_bandwidth.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_share_bandwidth.go index 5f2f03bcf4..e2e2fa57b8 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_share_bandwidth.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_share_bandwidth.go @@ -12,6 +12,12 @@ import ( type ReleaseShareBandwidthRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 共享带宽ID ShareBandwidthId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_vip.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_vip.go index 6cc0aced00..685699cceb 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_vip.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_vip.go @@ -12,8 +12,14 @@ import ( type ReleaseVIPRequest struct { request.CommonBase - // 可用区 - Zone *string `required:"false"` + // [公共参数] 地域 + // Region *string `required:"true"` + + // [公共参数] 可用区 + // Zone *string `required:"false"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写 + // ProjectId *string `required:"false"` // 内网VIP的id VIPId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/resize_share_bandwidth.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/resize_share_bandwidth.go index 606483c99e..d7e26e56c4 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/resize_share_bandwidth.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/resize_share_bandwidth.go @@ -12,6 +12,12 @@ import ( type ResizeShareBandwidthRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 带宽值,单位为Mb,范围 [20-5000] (最大值受地域限制) ShareBandwidth *int `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/set_eippay_mode.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/set_eippay_mode.go index 72e8c454dd..f61c6288d9 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/set_eippay_mode.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/set_eippay_mode.go @@ -12,6 +12,12 @@ import ( type SetEIPPayModeRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 弹性IP的资源Id EIPId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_eipaddr_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_eipaddr_set.go index 463104bebb..78206f3f24 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_eipaddr_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_eipaddr_set.go @@ -1,14 +1,14 @@ package unet /* -EIPAddrSet - DescribeShareBandwidth +EIPAddrSet - DescribeBandwidthPackage this model is auto created by ucloud code generater for open api, you can also see https://docs.ucloud.cn for detail. */ type EIPAddrSet struct { - // 运营商信息, 枚举值为: Telecom 电信; Unicom: 联通; Duplet: 双线; Bgp: BGP; International: 国际. + // 运营商信息, 枚举值为: BGP: BGP; International: 国际. OperatorName string // 弹性IP地址 diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_firewall_rule_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_firewall_rule_set.go index 53bf2fb62e..9b1bcc1528 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_firewall_rule_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_firewall_rule_set.go @@ -22,4 +22,7 @@ type FirewallRuleSet struct { // 防火墙动作 RuleAction string + + // 防火墙规则备注 + Remark string } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_resource_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_resource_set.go index 3231584d5c..d039a79258 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_resource_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_resource_set.go @@ -8,6 +8,9 @@ you can also see https://docs.ucloud.cn for detail. */ type ResourceSet struct { + // 可用区 + Zone int + // 名称 Name string @@ -20,7 +23,7 @@ type ResourceSet struct { // 绑定该防火墙的资源id ResourceID string - // 绑定资源的资源类型 + // 绑定防火墙组的资源类型。"unatgw",NAT网关; "uhost",云主机; "upm",物理云主机; "hadoophost",hadoop节点; "fortresshost",堡垒机; "udhost",私有专区主机;"udockhost",容器;"dbaudit",数据库审计. ResourceType string // 状态 @@ -28,7 +31,4 @@ type ResourceSet struct { // 业务组 Tag string - - // 可用区 - Zone int } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipaddr_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipaddr_set.go index 6f53fef5d7..d3498072b9 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipaddr_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipaddr_set.go @@ -1,14 +1,14 @@ package unet /* -UnetEIPAddrSet - DescribeEIP +UnetEIPAddrSet - AllocateEIP this model is auto created by ucloud code generater for open api, you can also see https://docs.ucloud.cn for detail. */ type UnetEIPAddrSet struct { - // 运营商信息如: 电信: Telecom, 联通: Unicom, 国际: International, Duplet: 双线IP(电信+联通), BGP: Bgp + // 运营商信息如: 国际: International, BGP: BGP OperatorName string // IP地址 diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipresource_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipresource_set.go index 4746a5ed8d..ac0c7fd584 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipresource_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipresource_set.go @@ -8,7 +8,7 @@ you can also see https://docs.ucloud.cn for detail. */ type UnetEIPResourceSet struct { - // 已绑定的资源类型, 枚举值为: uhost, 云主机;vrouter:虚拟路由器;ulb:负载均衡器 + // 已绑定的资源类型, 枚举值为: uhost, 云主机;natgw:NAT网关;ulb:负载均衡器;upm: 物理机; hadoophost: 大数据集群;fortresshost:堡垒机;udockhost:容器;udhost:私有专区主机;vpngw:IPSec VPN;ucdr:云灾备;dbaudit:数据库审计。 ResourceType string // 已绑定的资源名称 diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/un_bind_eip.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/un_bind_eip.go index 6d539eaf8f..b26da07de4 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/un_bind_eip.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/un_bind_eip.go @@ -12,10 +12,16 @@ import ( type UnBindEIPRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 弹性IP的资源Id EIPId *string `required:"true"` - // 弹性IP请求解绑的资源类型, 枚举值为: uhost: 云主机; vrouter: 虚拟路由器; ulb, 负载均衡器 upm: 物理机; hadoophost: 大数据集群;fortresshost:堡垒机;udockhost:容器;udhost:私有专区主机;natgw:natgw;udb:udb;vpngw:ipsec vpn;ucdr:云灾备;dbaudit:数据库审计; + // 弹性IP请求解绑的资源类型, 枚举值为: uhost: 云主机; ulb, 负载均衡器 upm: 物理机; hadoophost: 大数据集群;fortresshost:堡垒机;udockhost:容器;udhost:私有专区主机;natgw:NAT网关;udb:udb;vpngw:ipsec vpn;ucdr:云灾备;dbaudit:数据库审计; ResourceType *string `required:"true"` // 弹性IP请求解绑的资源ID diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_eipattribute.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_eipattribute.go index 2c655dfe4a..22e707ef16 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_eipattribute.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_eipattribute.go @@ -12,6 +12,12 @@ import ( type UpdateEIPAttributeRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // EIP资源ID EIPId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_firewall.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_firewall.go index 8d96a55df3..012014ef45 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_firewall.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_firewall.go @@ -12,6 +12,12 @@ import ( type UpdateFirewallRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 防火墙资源ID FWId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_firewall_attribute.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_firewall_attribute.go index 55eac0b6bf..bfe652815d 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_firewall_attribute.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_firewall_attribute.go @@ -12,6 +12,12 @@ import ( type UpdateFirewallAttributeRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 防火墙资源ID FWId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/add_vpcnetwork.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/add_vpcnetwork.go index 20e8c3bcf4..26d2a886c9 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/add_vpcnetwork.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/add_vpcnetwork.go @@ -12,6 +12,12 @@ import ( type AddVPCNetworkRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 源VPC短ID VPCId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_subnet.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_subnet.go index 08ed3f7afd..5e34ee7209 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_subnet.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_subnet.go @@ -12,6 +12,12 @@ import ( type CreateSubnetRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // VPC资源ID VPCId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_vpc.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_vpc.go index 15f58a2c2f..f7c77b7895 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_vpc.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_vpc.go @@ -12,6 +12,12 @@ import ( type CreateVPCRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // VPC名称 Name *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_vpcintercom.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_vpcintercom.go index 647605dc3a..a64c67ac1e 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_vpcintercom.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_vpcintercom.go @@ -12,16 +12,22 @@ import ( type CreateVPCIntercomRequest struct { request.CommonBase + // [公共参数] 源VPC所在地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 源VPC所在项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 源VPC短ID VPCId *string `required:"true"` // 目的VPC短ID DstVPCId *string `required:"true"` - // 目的所在地域(如果目的VPC和源VPC不在同一个地域,两个地域需要建立跨域通道,且该字段必选) + // 目的VPC所在地域,默认与源VPC同地域。 DstRegion *string `required:"false"` - // 目的项目ID + // 目的VPC项目ID。默认与源VPC同项目。 DstProjectId *string `required:"false"` } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_subnet.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_subnet.go index 57c902582e..689460a620 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_subnet.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_subnet.go @@ -12,6 +12,12 @@ import ( type DeleteSubnetRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 子网ID SubnetId *string `required:"true"` } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_vpc.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_vpc.go index c1f64340ff..3562457a4f 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_vpc.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_vpc.go @@ -12,6 +12,12 @@ import ( type DeleteVPCRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // VPC资源Id VPCId *string `required:"true"` } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_vpcintercom.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_vpcintercom.go index a4cec8382b..bafa6b9912 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_vpcintercom.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_vpcintercom.go @@ -12,16 +12,22 @@ import ( type DeleteVPCIntercomRequest struct { request.CommonBase + // [公共参数] 源VPC所在地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 源VPC所在项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 源VPC短ID VPCId *string `required:"true"` // 目的VPC短ID DstVPCId *string `required:"true"` - // 目的所在地域 + // 目的VPC所在地域,默认为源VPC所在地域 DstRegion *string `required:"false"` - // 目的项目ID(如果目的VPC和源VPC不在同一个地域,两个地域需要建立跨域通道,且该字段必选) + // 目的VPC所在项目ID,默认为源VPC所在项目ID DstProjectId *string `required:"false"` } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_subnet.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_subnet.go index 140652be47..77d3570b02 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_subnet.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_subnet.go @@ -12,6 +12,12 @@ import ( type DescribeSubnetRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 子网id数组,适用于一次查询多个子网信息 SubnetIds []string `required:"false"` @@ -27,10 +33,10 @@ type DescribeSubnetRequest struct { // 业务组 BusinessId *string `required:"false"` - // 默认为0 + // 偏移量,默认为0 Offset *int `required:"false"` - // 默认为20 + // 列表长度,默认为20 Limit *int `required:"false"` } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_subnet_resource.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_subnet_resource.go index 90e41d5043..4e29a32b79 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_subnet_resource.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_subnet_resource.go @@ -12,16 +12,22 @@ import ( type DescribeSubnetResourceRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 子网id SubnetId *string `required:"true"` - // 资源类型 + // 资源类型,默认为全部资源类型。枚举值为:UHOST,云主机;PHOST,物理云主机;ULB,负载均衡;UHADOOP_HOST,hadoop节点;UFORTRESS_HOST,堡垒机;UNATGW,NAT网关;UKAFKA,Kafka消息队列;UMEM,内存存储;DOCKER,容器集群;UDB,数据库;UDW,数据仓库;VIP,内网VIP. ResourceType *string `required:"false"` - // 分页号 + // 列表起始位置偏移量,默认为0 Offset *int `required:"false"` - // 单页limit + // 单页返回数据长度,默认为20 Limit *int `required:"false"` } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_vpc.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_vpc.go index f0177bdc3f..6d500cac8d 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_vpc.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_vpc.go @@ -12,6 +12,12 @@ import ( type DescribeVPCRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + // VPCId VPCIds []string `required:"false"` @@ -23,7 +29,7 @@ type DescribeVPCRequest struct { type DescribeVPCResponse struct { response.CommonBase - // vpc信息 + // vpc信息,具体结构见下方VPCInfo DataSet []VPCInfo } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_vpcintercom.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_vpcintercom.go index 8ebb329be0..471c68466a 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_vpcintercom.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_vpcintercom.go @@ -12,13 +12,19 @@ import ( type DescribeVPCIntercomRequest struct { request.CommonBase + // [公共参数] 源VPC所在地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 源VPC所在项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // VPC短ID VPCId *string `required:"true"` - // 目的地域 + // 目的VPC所在地域,默认为全部地域 DstRegion *string `required:"false"` - // 目的项目ID + // 目的项目ID,默认为全部项目 DstProjectId *string `required:"false"` } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/update_subnet_attribute.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/update_subnet_attribute.go index 46aac90b6b..72977b932f 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/update_subnet_attribute.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/update_subnet_attribute.go @@ -12,6 +12,12 @@ import ( type UpdateSubnetAttributeRequest struct { request.CommonBase + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"false"` + // 子网ID SubnetId *string `required:"true"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/update_vpcnetwork.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/update_vpcnetwork.go new file mode 100644 index 0000000000..aea7b89736 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/update_vpcnetwork.go @@ -0,0 +1,59 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api VPC UpdateVPCNetwork + +package vpc + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// UpdateVPCNetworkRequest is request schema for UpdateVPCNetwork action +type UpdateVPCNetworkRequest struct { + request.CommonBase + + // [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html) + // Region *string `required:"true"` + + // [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) + // ProjectId *string `required:"true"` + + // VPC的ID + VPCId *string `required:"true"` + + // 更新的全量网段 + Network []string `required:"true"` +} + +// UpdateVPCNetworkResponse is response schema for UpdateVPCNetwork action +type UpdateVPCNetworkResponse struct { + response.CommonBase + + // 错误信息 + Message string +} + +// NewUpdateVPCNetworkRequest will create request of UpdateVPCNetwork action. +func (c *VPCClient) NewUpdateVPCNetworkRequest() *UpdateVPCNetworkRequest { + req := &UpdateVPCNetworkRequest{} + + // setup request with client config + c.client.SetupRequest(req) + + // setup retryable with default retry policy (retry for non-create action and common error) + req.SetRetryable(true) + return req +} + +// UpdateVPCNetwork - 修改VPC地址空间,只支持删除地址空间 +func (c *VPCClient) UpdateVPCNetwork(req *UpdateVPCNetworkRequest) (*UpdateVPCNetworkResponse, error) { + var err error + var res UpdateVPCNetworkResponse + + err = c.client.InvokeAction("UpdateVPCNetwork", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/client.go index f6147f2490..07a2e40097 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/client.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/client.go @@ -10,6 +10,7 @@ import ( "github.com/ucloud/ucloud-sdk-go/private/protocol/http" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" + uerr "github.com/ucloud/ucloud-sdk-go/ucloud/error" "github.com/ucloud/ucloud-sdk-go/ucloud/log" "github.com/ucloud/ucloud-sdk-go/ucloud/request" "github.com/ucloud/ucloud-sdk-go/ucloud/response" @@ -17,10 +18,17 @@ import ( // Client 客户端 type Client struct { + // configurations credential *auth.Credential config *Config - httpClient *http.HttpClient + // composited instances + httpClient http.Client + logger log.Logger + + // internal properties + requestHandlers []RequestHandler + httpRequestHandlers []HttpRequestHandler responseHandlers []ReponseHandler httpResponseHandlers []HttpReponseHandler } @@ -32,12 +40,23 @@ func NewClient(config *Config, credential *auth.Credential) *Client { config: config, } + client.requestHandlers = append(client.requestHandlers, defaultRequestHandlers...) + client.httpRequestHandlers = append(client.httpRequestHandlers, defaultHttpRequestHandlers...) client.responseHandlers = append(client.responseHandlers, defaultResponseHandlers...) client.httpResponseHandlers = append(client.httpResponseHandlers, defaultHttpResponseHandlers...) - log.Init(config.LogLevel) + + client.logger = log.New() + client.logger.SetLevel(config.LogLevel) + return &client } +// SetHttpClient will setup a http client +func (c *Client) SetHttpClient(httpClient http.Client) error { + c.httpClient = httpClient + return nil +} + // GetCredential will return the creadential config of client. func (c *Client) GetCredential() *auth.Credential { return c.credential @@ -55,36 +74,52 @@ func (c *Client) InvokeAction(action string, req request.Common, resp response.C // InvokeActionWithPatcher will invoke action by patchers func (c *Client) InvokeActionWithPatcher(action string, req request.Common, resp response.Common, patches ...utils.Patch) error { + var err error req.SetAction(action) req.SetRequestTime(time.Now()) + for _, handler := range c.requestHandlers { + req, err = handler(c, req) + if err != nil { + return uerr.NewClientError(uerr.ErrInvalidRequest, err) + } + } + httpReq, err := c.buildHTTPRequest(req) if err != nil { - return err + return uerr.NewClientError(uerr.ErrInvalidRequest, err) } - httpClient := http.NewHttpClient() - httpResp, err := httpClient.Send(httpReq) - if err != nil { - return err + for _, handler := range c.httpRequestHandlers { + httpReq, err = handler(c, httpReq) + if err != nil { + return uerr.NewClientError(uerr.ErrInvalidRequest, err) + } } + if c.httpClient == nil { + httpClient := http.NewHttpClient() + c.httpClient = &httpClient + } + + httpResp, err := c.httpClient.Send(httpReq) + // use response middleware to handle http response // such as convert some http status to error for _, handler := range c.httpResponseHandlers { httpResp, err = handler(c, httpReq, httpResp, err) } - // use patch object to resolve the http response body - // in general, it will be fix common server error before server bugfix is released. - body := httpResp.GetBody() - for _, patch := range patches { - body = patch.Patch(body) - } + if err == nil { + // use patch object to resolve the http response body + // in general, it will be fix common server error before server bugfix is released. + body := httpResp.GetBody() - err = c.unmarshalHTTPReponse(body, resp) - if err != nil { - return err + for _, patch := range patches { + body = patch.Patch(body) + } + + err = c.unmarshalHTTPReponse(body, resp) } // use response middle to build and convert response when response has been created. @@ -95,3 +130,27 @@ func (c *Client) InvokeActionWithPatcher(action string, req request.Common, resp return err } + +// AddHttpRequestHandler will append a reponse handler to client +func (c *Client) AddHttpRequestHandler(h HttpRequestHandler) error { + c.httpRequestHandlers = append([]HttpRequestHandler{h}, c.httpRequestHandlers...) + return nil +} + +// AddRequestHandler will append a reponse handler to client +func (c *Client) AddRequestHandler(h RequestHandler) error { + c.requestHandlers = append([]RequestHandler{h}, c.requestHandlers...) + return nil +} + +// AddHttpResponseHandler will append a http reponse handler to client +func (c *Client) AddHttpResponseHandler(h HttpReponseHandler) error { + c.httpResponseHandlers = append(c.httpResponseHandlers, h) + return nil +} + +// AddResponseHandler will append a reponse handler to client +func (c *Client) AddResponseHandler(h ReponseHandler) error { + c.responseHandlers = append(c.responseHandlers, h) + return nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/config.go b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/config.go index a0faa6dbc5..2b79bc119e 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/config.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/config.go @@ -44,15 +44,33 @@ type Config struct { // LogLevel is equal to logrus level, // if logLevel not be set, use INFO level as default. LogLevel log.Level `default:"log.InfoLevel"` + + // Logging level by action, used to filter logging messages by action + // use SetActionLevel() and GetActionLevel() to modify + actionLoggingLevels map[string]log.Level } // NewConfig will return a new client config with default options. func NewConfig() Config { cfg := Config{ - BaseUrl: "https://api.ucloud.cn", - Timeout: 30 * time.Second, - MaxRetries: 0, - LogLevel: log.WarnLevel, + BaseUrl: "https://api.ucloud.cn", + Timeout: 30 * time.Second, + MaxRetries: 0, + LogLevel: log.WarnLevel, + actionLoggingLevels: make(map[string]log.Level), } return cfg } + +// GetActionLevel will return the log level of action +func (c *Config) GetActionLevel(action string) log.Level { + if level, ok := c.actionLoggingLevels[action]; ok { + return level + } + return c.LogLevel +} + +// SetActionLevel will return the log level of action +func (c *Config) SetActionLevel(action string, level log.Level) { + c.actionLoggingLevels[action] = level +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/error/client_error.go b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/error/client_error.go index c7679cd51b..3f9b9db59c 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/error/client_error.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/error/client_error.go @@ -18,8 +18,8 @@ var ( // ErrNetwork is retryable ErrNetwork = "client.NetworkError" - // ErrUnexcepted is the error for any unexcepted error - ErrUnexcepted = "client.UnexceptedError" + // ErrUnexpected is the error for any unexpected error + ErrUnexpected = "client.UnexpectedError" ) // ClientError is the ucloud common errorfor server response diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/error/error.go b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/error/error.go index e5ea08e3d8..5a2437ce44 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/error/error.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/error/error.go @@ -38,7 +38,7 @@ func NewRetryableError(err error) Error { return e } - e := NewClientError(ErrUnexcepted, err) + e := NewClientError(ErrUnexpected, err) e.retryable = true return e } @@ -55,7 +55,7 @@ func NewNonRetryableError(err error) Error { return e } - e := NewClientError(ErrUnexcepted, err) + e := NewClientError(ErrUnexpected, err) e.retryable = false return e } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/handlers.go b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/handlers.go index 1ed0862bc1..582c1bf3d0 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/handlers.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/handlers.go @@ -11,29 +11,37 @@ import ( "github.com/ucloud/ucloud-sdk-go/ucloud/response" ) +// RequestHandler receive request and write data into this request memory area +type RequestHandler func(c *Client, req request.Common) (request.Common, error) + +// HttpRequestHandler receive http request and return a new http request +type HttpRequestHandler func(c *Client, req *http.HttpRequest) (*http.HttpRequest, error) + // ReponseHandler receive response and write data into this response memory area type ReponseHandler func(c *Client, req request.Common, resp response.Common, err error) (response.Common, error) // HttpReponseHandler receive http response and return a new http response type HttpReponseHandler func(c *Client, req *http.HttpRequest, resp *http.HttpResponse, err error) (*http.HttpResponse, error) +var defaultRequestHandlers = []RequestHandler{} +var defaultHttpRequestHandlers = []HttpRequestHandler{} var defaultResponseHandlers = []ReponseHandler{errorHandler, logHandler, retryHandler} var defaultHttpResponseHandlers = []HttpReponseHandler{errorHTTPHandler, logDebugHTTPHandler} func retryHandler(c *Client, req request.Common, resp response.Common, err error) (response.Common, error) { - retryCount := req.GetRetryCount() - retryCount++ - req.SetRetryCount(retryCount) - if !req.GetRetryable() || err == nil || !err.(uerr.Error).Retryable() { return resp, err } + retryCount := req.GetRetryCount() + // if max retries number is reached, stop and raise last error - if req.GetRetryCount() > req.GetMaxretries() { + if retryCount >= req.GetMaxretries() { return resp, err } + req.SetRetryCount(retryCount + 1) + // use exponential backoff constant as retry delay delay := getExpBackoffDelay(retryCount) <-time.After(delay) @@ -74,32 +82,75 @@ func errorHandler(c *Client, req request.Common, resp response.Common, err error } func errorHTTPHandler(c *Client, req *http.HttpRequest, resp *http.HttpResponse, err error) (*http.HttpResponse, error) { + if err == nil { + return resp, err + } + if statusErr, ok := err.(http.StatusError); ok { return resp, uerr.NewServerStatusError(statusErr.StatusCode, statusErr.Message) } + return resp, err } func logHandler(c *Client, req request.Common, resp response.Common, err error) (response.Common, error) { action := req.GetAction() - if err != nil { - log.Warnf("do %s failed, %s", action, err) - } else { - log.Infof("do %s successful!", action) + + // get strictest logging level + level := c.config.GetActionLevel(action) + + if err != nil && level >= log.WarnLevel { + c.logger.Warnf("do %s failed, %s", action, err) + } else if level >= log.InfoLevel { + c.logger.Infof("do %s successful!", action) } return resp, err } func logDebugHTTPHandler(c *Client, req *http.HttpRequest, resp *http.HttpResponse, err error) (*http.HttpResponse, error) { - log.Debugf("%s", req) + action := req.GetQuery("Action") + // logging request + c.logActionDebugf(action, "%s", req) + + // logging error if err != nil { - log.Errorf("%s", err) - } else if resp.GetStatusCode() > 400 { - log.Warnf("%s", resp.GetStatusCode()) - } else { - log.Debugf("%s - %v", resp.GetBody(), resp.GetStatusCode()) + c.logActionErrorf(action, "%s", err) + } + + // logging response code text + if resp != nil && resp.GetStatusCode() >= 400 { + c.logActionWarnf(action, "%s", resp.GetStatusCode()) + } + + // logging response body + if resp != nil && resp.GetStatusCode() < 400 { + c.logActionDebugf(action, "%s - %v", resp.GetBody(), resp.GetStatusCode()) } return resp, err } + +func (c *Client) logActionErrorf(action, format string, args ...interface{}) { + level := c.config.GetActionLevel(action) + + if log.ErrorLevel <= level { + c.logger.Errorf(format, args...) + } +} + +func (c *Client) logActionWarnf(action, format string, args ...interface{}) { + level := c.config.GetActionLevel(action) + + if log.WarnLevel <= level { + c.logger.Warnf(format, args...) + } +} + +func (c *Client) logActionDebugf(action, format string, args ...interface{}) { + level := c.config.GetActionLevel(action) + + if log.DebugLevel <= level { + c.logger.Debugf(format, args...) + } +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/log/logger.go b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/log/logger.go index 2d58a1c3a5..5bee2db448 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/log/logger.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/log/logger.go @@ -4,23 +4,80 @@ Package log is the log utilities of sdk package log import ( + "io" "os" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) -// Init will init with level and default output (stdout) and formatter (text without color) -func Init(level Level) { - logrus.SetLevel(logrus.Level(level)) - logrus.SetOutput(os.Stdout) - logrus.SetFormatter(&logrus.TextFormatter{ +// Logger is the interface of SDK +type Logger interface { + Debug(...interface{}) + Print(...interface{}) + Info(...interface{}) + Warn(...interface{}) + Warning(...interface{}) + Error(...interface{}) + Panic(...interface{}) + Fatal(...interface{}) + + Debugf(string, ...interface{}) + Printf(string, ...interface{}) + Infof(string, ...interface{}) + Warnf(string, ...interface{}) + Warningf(string, ...interface{}) + Errorf(string, ...interface{}) + Panicf(string, ...interface{}) + Fatalf(string, ...interface{}) + + SetOutput(io.Writer) + SetFormatter(Formatter) + SetLevel(Level) + GetLevel() Level +} + +// BasicLogger is the logger (wrapper for logrus) +type BasicLogger struct { + *logrus.Logger +} + +// Level is the log level of logger (wrapper for logrus) +type Level logrus.Level + +// Formatter is the formatter of logger (wrapper for logrus) +type Formatter logrus.Formatter + +// New will return a logger pointer +func New() *BasicLogger { + logger := &BasicLogger{logrus.New()} + logger.Out = os.Stdout + logger.Level = logrus.Level(DebugLevel) + logger.Formatter = &logrus.TextFormatter{ DisableColors: false, FullTimestamp: true, - }) + } + return logger } -// Level is the log level of sdk logger -type Level logrus.Level +// SetOutput sets the logger output. +func (logger *BasicLogger) SetOutput(out io.Writer) { + logger.Out = out +} + +// SetFormatter sets the logger formatter. +func (logger *BasicLogger) SetFormatter(formatter Formatter) { + logger.Formatter = logrus.Formatter(formatter) +} + +// SetLevel sets the logger level. +func (logger *BasicLogger) SetLevel(level Level) { + logger.Level = logrus.Level(level) +} + +// GetLevel returns the logger level. +func (logger *BasicLogger) GetLevel() Level { + return Level(logger.Level) +} var ( PanicLevel = Level(logrus.PanicLevel) @@ -56,3 +113,13 @@ var ( Panicf = logrus.Panicf Fatalf = logrus.Fatalf ) + +// Init (Deprecated) will init with level and default output (stdout) and formatter (text without color) to global logger +func Init(level Level) { + logrus.SetLevel(logrus.Level(level)) + logrus.SetOutput(os.Stdout) + logrus.SetFormatter(&logrus.TextFormatter{ + DisableColors: false, + FullTimestamp: true, + }) +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/marshaler.go b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/marshaler.go index 68c53ccb45..a1b693f41c 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/marshaler.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/marshaler.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "runtime" + "strings" "github.com/pkg/errors" @@ -59,7 +60,7 @@ func (c *Client) buildHTTPRequest(req request.Common) (*http.HttpRequest, error) config := c.GetConfig() httpReq := http.NewHttpRequest() httpReq.SetURL(config.BaseUrl) - httpReq.SetMethod("GET") + httpReq.SetMethod("POST") // set timeout with client configuration httpReq.SetTimeout(config.Timeout) @@ -68,14 +69,14 @@ func (c *Client) buildHTTPRequest(req request.Common) (*http.HttpRequest, error) httpReq.SetQueryString(credential.BuildCredentialedQuery(query)) ua := fmt.Sprintf("GO/%s GO-SDK/%s %s", runtime.Version(), version.Version, config.UserAgent) - httpReq.SetHeader("User-Agent", ua) + httpReq.SetHeader("User-Agent", strings.TrimSpace(ua)) - return &httpReq, nil + return httpReq, nil } // unmarshalHTTPReponse will get body from http response and unmarshal it's data into response struct func (c *Client) unmarshalHTTPReponse(body []byte, resp response.Common) error { - if len(body) < 0 { + if len(body) == 0 { return nil } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/version/version.go b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/version/version.go index bfb012beb2..ef7134e191 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/version/version.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/version/version.go @@ -4,4 +4,4 @@ Package version is the version of sdk package version // Version see also semantic version: https://semver.org/ -const Version = "0.6.2" +const Version = "0.7.1" diff --git a/vendor/vendor.json b/vendor/vendor.json index 87b48f7db1..c26c68f672 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -14,6 +14,12 @@ "revision": "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75", "revisionTime": "2014-10-17T20:07:13Z" }, + { + "checksumSHA1": "Aulh7C5SVOA4Jzt5eHNH6197Mbk=", + "path": "github.com/konsorten/go-windows-terminal-sequences", + "revision": "f55edac94c9bbba5d6182a4be46d86a2c9b5b50e", + "revisionTime": "2019-02-26T22:47:05Z" + }, { "checksumSHA1": "ljd3FhYRJ91cLZz3wsH9BQQ2JbA=", "path": "github.com/pkg/errors", @@ -21,46 +27,46 @@ "revisionTime": "2018-03-11T21:45:15Z" }, { - "checksumSHA1": "YcW7CHAiI6Ch0gmYpcL1759s8nU=", + "checksumSHA1": "bDOq0pmy+ahdStuf+4Cgq+ghaN8=", + "path": "github.com/sirupsen/logrus", + "revision": "fa3c1df5136d05b1b54b72794cf89579f2b39f7b", + "revisionTime": "2019-02-27T12:42:49Z" + }, + { + "checksumSHA1": "1nDHkiFm79ufUiLc80zG1Y/L9cg=", "path": "github.com/spf13/cobra", "revision": "8d114be902bc9f08717804830a55c48378108a28", "revisionTime": "2018-09-15T22:22:04Z" }, { - "checksumSHA1": "8jPcnwUo/UUnNvfFKdcKYtJJUYM=", - "path": "github.com/spf13/cobra/doc", - "revision": "ff9bf816a1557ee800e8afc7299bfa4c05eb7a05", - "revisionTime": "2018-12-27T10:25:35Z" - }, - { - "checksumSHA1": "9ay5PqAnQlhXvDO8XEmizyHGl2g=", + "checksumSHA1": "OJI0OgC5V8gZtfS1e0CDYMhkDNc=", "path": "github.com/spf13/pflag", "revision": "3ebe029320b2676d667ae88da602a5f854788a8a", "revisionTime": "2018-06-01T13:25:42Z" }, { - "checksumSHA1": "THNAbJj3DHSRxNJh5ZGJjbNtzBI=", + "checksumSHA1": "Q/ErwMWix4hsHRwEbp/4SkMiGew=", "path": "github.com/ucloud/ucloud-sdk-go/private/protocol/http", - "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", - "revisionTime": "2018-11-21T10:11:50Z" + "revision": "8acf672fd9a0504d60ccaf7543fbaac25c5963e1", + "revisionTime": "2019-02-21T08:22:29Z" }, { - "checksumSHA1": "gvEfWRCM4e9t6XoaLM0epW3vnmE=", - "path": "github.com/ucloud/ucloud-sdk-go/private/services/udisk", - "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", - "revisionTime": "2018-11-21T10:11:50Z" + "checksumSHA1": "w5oqK4Qz4fWXk+zCiWNODme1+lk=", + "path": "github.com/ucloud/ucloud-sdk-go/private/services/udb", + "revision": "8acf672fd9a0504d60ccaf7543fbaac25c5963e1", + "revisionTime": "2019-02-21T08:22:29Z" }, { - "checksumSHA1": "6VGaaGQb6mJv9DJdl+DJUeIjHD0=", + "checksumSHA1": "eSEPPd5tMrjMVh4gUZsmqf7xQcA=", "path": "github.com/ucloud/ucloud-sdk-go/private/services/uhost", - "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", - "revisionTime": "2018-11-21T10:11:50Z" + "revision": "8acf672fd9a0504d60ccaf7543fbaac25c5963e1", + "revisionTime": "2019-02-21T08:22:29Z" }, { - "checksumSHA1": "7d7zSGzF3PLkOenjzNpm4qp08vc=", + "checksumSHA1": "2PHkrBvHFRMHUPtQ7BXssxk8Mqg=", "path": "github.com/ucloud/ucloud-sdk-go/private/utils", - "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", - "revisionTime": "2018-11-21T10:11:50Z" + "revision": "8acf672fd9a0504d60ccaf7543fbaac25c5963e1", + "revisionTime": "2019-02-21T08:22:29Z" }, { "checksumSHA1": "A8H7kEMjrdhpEvbK21+RLBCCd24=", @@ -69,94 +75,82 @@ "revisionTime": "2018-11-21T10:11:50Z" }, { - "checksumSHA1": "dyL5BqmH44GkLhHexeEfY1QXeVc=", + "checksumSHA1": "eEYfH1aFMx6JGHdpB8oSJclBO7E=", "path": "github.com/ucloud/ucloud-sdk-go/services/uaccount", - "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", - "revisionTime": "2018-11-21T10:11:50Z" + "revision": "8acf672fd9a0504d60ccaf7543fbaac25c5963e1", + "revisionTime": "2019-02-21T08:22:29Z" }, { - "checksumSHA1": "qD7m2MHO4UJ/m/2fC1PWQsWgeRQ=", + "checksumSHA1": "iWLWJu5eqiYps0SU5AB7qHoImH8=", "path": "github.com/ucloud/ucloud-sdk-go/services/udisk", - "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", - "revisionTime": "2018-11-21T10:11:50Z" - }, - { - "checksumSHA1": "dF+V9PFP/Kf2cfd81uAlCd0Usqw=", - "path": "github.com/ucloud/ucloud-sdk-go/services/udpn", - "revision": "d5828884a7a4a702815a15ff6417df0fd2b50893", - "revisionTime": "2018-12-18T04:06:49Z" + "revision": "8acf672fd9a0504d60ccaf7543fbaac25c5963e1", + "revisionTime": "2019-02-21T08:22:29Z" }, { - "checksumSHA1": "1misM0pqLF7LVdkEtemvhvAs+nQ=", + "checksumSHA1": "HzwxwjpWDLUG8+VrrccQGs2HU0U=", "path": "github.com/ucloud/ucloud-sdk-go/services/uhost", - "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", - "revisionTime": "2018-11-21T10:11:50Z" + "revision": "8acf672fd9a0504d60ccaf7543fbaac25c5963e1", + "revisionTime": "2019-02-21T08:22:29Z" }, { - "checksumSHA1": "PHNVFy9+X1evds8wKHba4tsNROw=", - "path": "github.com/ucloud/ucloud-sdk-go/services/ulb", - "revision": "9ad84960331eeace7b8e427ed07104deadc74217", - "revisionTime": "2019-01-22T02:05:40Z" - }, - { - "checksumSHA1": "rTHjcXtmwEqyvuTz0gxXANcPoOc=", + "checksumSHA1": "wwJwpgyuuAouiUXxS7mw8CpGUMg=", "path": "github.com/ucloud/ucloud-sdk-go/services/unet", - "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", - "revisionTime": "2018-11-21T10:11:50Z" + "revision": "8acf672fd9a0504d60ccaf7543fbaac25c5963e1", + "revisionTime": "2019-02-21T08:22:29Z" }, { - "checksumSHA1": "ehgKHU9X7+3T8JAkPrB8LHesNBU=", + "checksumSHA1": "ytXB78CUrP4Uehq/rN97r/vd0FU=", "path": "github.com/ucloud/ucloud-sdk-go/services/vpc", - "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", - "revisionTime": "2018-11-21T10:11:50Z" + "revision": "8acf672fd9a0504d60ccaf7543fbaac25c5963e1", + "revisionTime": "2019-02-21T08:22:29Z" }, { - "checksumSHA1": "Q45sgjS2JMVzJPZSasoy18x5Sak=", + "checksumSHA1": "pxbBkWZq4yZKWbfiOi+2jQ4OUbU=", "path": "github.com/ucloud/ucloud-sdk-go/ucloud", - "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", - "revisionTime": "2018-11-21T10:11:50Z" + "revision": "8acf672fd9a0504d60ccaf7543fbaac25c5963e1", + "revisionTime": "2019-02-21T08:22:29Z" }, { "checksumSHA1": "SYdYJOqUQHfcEMAOSQok5aQ+xGU=", "path": "github.com/ucloud/ucloud-sdk-go/ucloud/auth", - "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", - "revisionTime": "2018-11-21T10:11:50Z" + "revision": "8acf672fd9a0504d60ccaf7543fbaac25c5963e1", + "revisionTime": "2019-02-21T08:22:29Z" }, { - "checksumSHA1": "OYlW/BJ3hfOqZoAM3IuqP/R+N/Q=", + "checksumSHA1": "JDCYsHub95XRKz8pA/Sa42NzALs=", "path": "github.com/ucloud/ucloud-sdk-go/ucloud/error", - "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", - "revisionTime": "2018-11-21T10:11:50Z" + "revision": "8acf672fd9a0504d60ccaf7543fbaac25c5963e1", + "revisionTime": "2019-02-21T08:22:29Z" }, { "checksumSHA1": "WMTXD2ama/EmXjmBbAheUSie7P4=", "path": "github.com/ucloud/ucloud-sdk-go/ucloud/helpers/waiter", - "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", - "revisionTime": "2018-11-21T10:11:50Z" + "revision": "8acf672fd9a0504d60ccaf7543fbaac25c5963e1", + "revisionTime": "2019-02-21T08:22:29Z" }, { - "checksumSHA1": "H4lbTse9PlCXOogfpLCpqXSD8iE=", + "checksumSHA1": "pchcm+RYR24DGAlpzxXKDOmsZ8s=", "path": "github.com/ucloud/ucloud-sdk-go/ucloud/log", - "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", - "revisionTime": "2018-11-21T10:11:50Z" + "revision": "8acf672fd9a0504d60ccaf7543fbaac25c5963e1", + "revisionTime": "2019-02-21T08:22:29Z" }, { - "checksumSHA1": "subTc2MHCUgBF9kDR0GOOivl7hI=", + "checksumSHA1": "2vpzD0YBksN+tyhaQMnkIp2hT6U=", "path": "github.com/ucloud/ucloud-sdk-go/ucloud/request", - "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", - "revisionTime": "2018-11-21T10:11:50Z" + "revision": "8acf672fd9a0504d60ccaf7543fbaac25c5963e1", + "revisionTime": "2019-02-21T08:22:29Z" }, { "checksumSHA1": "UYVTJ2g0IVPxfhSUS0l0/RHyrGg=", "path": "github.com/ucloud/ucloud-sdk-go/ucloud/response", - "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", - "revisionTime": "2018-11-21T10:11:50Z" + "revision": "8acf672fd9a0504d60ccaf7543fbaac25c5963e1", + "revisionTime": "2019-02-21T08:22:29Z" }, { - "checksumSHA1": "fBACuzKR1u0WMySyxLrIWCByRUI=", + "checksumSHA1": "JOJrQZmLZ62G8hX/hNIc32mAZR8=", "path": "github.com/ucloud/ucloud-sdk-go/ucloud/version", - "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", - "revisionTime": "2018-11-21T10:11:50Z" + "revision": "8acf672fd9a0504d60ccaf7543fbaac25c5963e1", + "revisionTime": "2019-02-21T08:22:29Z" }, { "checksumSHA1": "BGm8lKZmvJbf/YOJLeL1rw2WVjA=",