From 7c43df8ab1cf23506b4f31ca96fd79868c6f68e6 Mon Sep 17 00:00:00 2001 From: lixiaojun Date: Wed, 12 Dec 2018 15:50:25 +0800 Subject: [PATCH] uhost clone&reset-password&create-image and udisk snapshost manage --- CHANGELOG.md | 7 + base/client.go | 13 +- base/config.go | 1 - base/util.go | 190 +++++-- cmd/disk.go | 410 +++++++++++--- cmd/eip.go | 19 +- cmd/globalssh.go | 12 +- cmd/image.go | 177 +++++- cmd/project.go | 13 + cmd/region.go | 28 + cmd/root.go | 36 +- cmd/root_test.go | 10 +- cmd/uhost.go | 518 ++++++++++++++---- cmd/uhost_test.go | 69 ++- model/cli/cli_const.go | 6 + model/context.go | 5 + model/status/status.go | 8 + ux/prompt.go | 4 +- ux/spinner.go | 31 +- vendor/github.com/spf13/cobra/command.go | 3 +- .../github.com/ucloud/ucloud-sdk-go/LICENSE | 202 +++++++ .../private/protocol/http/defaults.go | 1 + .../private/protocol/http/request.go | 7 +- .../ulb => private/services/udisk}/client.go | 10 +- .../services/udisk/delete_udisk_snapshot.go | 53 ++ .../services/udisk/describe_udisk_snapshot.go | 65 +++ .../udisk/types_udisk_snapshot_set.go | 49 ++ .../private/services/uhost/client.go | 19 + .../private/services/uhost/delete_snapshot.go | 53 ++ .../services/uhost/describe_snapshot.go | 80 +++ .../services/uhost/restore_uhost_disk.go | 59 ++ .../services/uhost/types_snapshot_set.go | 46 ++ .../ucloud-sdk-go/private/utils/accessor.go | 19 +- .../ucloud-sdk-go/private/utils/collection.go | 10 +- .../ucloud-sdk-go/private/utils/patch.go | 35 ++ .../ucloud-sdk-go/private/utils/waiter.go | 4 +- .../ucloud-sdk-go/services/pathx/client.go | 2 + .../ucloud-sdk-go/services/pathx/doc.go | 10 +- .../services/pathx/modify_global_sshremark.go | 5 + .../services/pathx/types_global_ssharea.go | 6 +- .../services/pathx/types_global_sshinfo.go | 6 +- .../ucloud-sdk-go/services/uaccount/client.go | 2 + .../ucloud-sdk-go/services/uaccount/doc.go | 10 +- .../uaccount/types_project_list_info.go | 6 +- .../services/uaccount/types_region_info.go | 6 +- .../services/uaccount/types_user_info.go | 6 +- .../ucloud-sdk-go/services/udisk/client.go | 4 +- .../services/udisk/clone_udisk_snapshot.go | 5 + .../services/udisk/create_udisk_snapshot.go | 5 + .../services/udisk/delete_udisk_snapshot.go | 53 ++ .../services/udisk/describe_udisk_snapshot.go | 65 +++ .../ucloud-sdk-go/services/udisk/doc.go | 10 +- .../services/udisk/types_udisk_data_set.go | 9 +- .../udisk/types_udisk_price_data_set.go | 6 +- .../udisk/types_udisk_snapshot_set.go | 49 ++ .../ucloud-sdk-go/services/uhost/client.go | 2 + .../services/uhost/create_uhost_instance.go | 3 - .../ucloud-sdk-go/services/uhost/doc.go | 10 +- .../services/uhost/import_custom_image.go | 68 +++ .../uhost/reinstall_uhost_instance.go | 4 + .../uhost/reset_uhost_instance_password.go | 4 + .../services/uhost/resize_uhost_instance.go | 10 +- .../services/uhost/start_uhost_instance.go | 3 - .../uhost/terminate_uhost_instance.go | 12 +- .../services/uhost/types_uhost_disk_query.go | 2 +- .../services/uhost/types_uhost_disk_set.go | 6 +- .../services/uhost/types_uhost_image_set.go | 6 +- .../uhost/types_uhost_instance_set.go | 30 +- .../services/uhost/types_uhost_ipset.go | 14 +- .../services/uhost/types_uhost_price_set.go | 6 +- .../services/uhost/types_uhost_tag_set.go | 6 +- .../uhost/wait_until_uhost_instance_state.go | 5 +- .../services/ulb/allocate_backend.go | 65 --- .../services/ulb/allocate_backend_batch.go | 59 -- .../services/ulb/create_policy.go | 62 --- .../ucloud-sdk-go/services/ulb/create_ulb.go | 74 --- .../services/ulb/create_vserver.go | 83 --- .../services/ulb/delete_policy.go | 53 -- .../ucloud-sdk-go/services/ulb/delete_ulb.go | 47 -- .../services/ulb/delete_vserver.go | 50 -- .../services/ulb/describe_ulb.go | 68 --- .../services/ulb/describe_vserver.go | 62 --- .../ucloud/ucloud-sdk-go/services/ulb/doc.go | 11 - .../services/ulb/release_backend.go | 50 -- .../services/ulb/types_backend_set.go | 16 - .../services/ulb/types_policy_backend_set.go | 25 - .../ulb/types_ulb_policy_backend_set.go | 19 - .../ulb/types_ulb_policy_group_set.go | 19 - .../services/ulb/types_ulb_policy_set.go | 25 - .../services/ulb/types_ulbbackend_set.go | 37 -- .../services/ulb/types_ulbipset.go | 19 - .../services/ulb/types_ulbpolicy_set.go | 34 -- .../services/ulb/types_ulbset.go | 61 --- .../services/ulb/types_ulbsslset.go | 16 - .../services/ulb/types_ulbvserver_set.go | 58 -- .../services/ulb/update_backend_attribute.go | 56 -- .../services/ulb/update_policy.go | 65 --- .../services/ulb/update_ulbattribute.go | 56 -- .../services/ulb/update_vserver_attribute.go | 77 --- .../services/unet/allocate_share_bandwidth.go | 2 +- .../ucloud-sdk-go/services/unet/client.go | 2 + .../services/unet/create_firewall.go | 4 +- .../unet/describe_firewall_resource.go | 2 +- .../services/unet/describe_vip.go | 2 +- .../ucloud/ucloud-sdk-go/services/unet/doc.go | 10 +- .../services/unet/types_eipaddr_set.go | 6 +- .../services/unet/types_eippay_mode_set.go | 6 +- .../unet/types_eipprice_detail_set.go | 6 +- .../services/unet/types_eipset_data.go | 8 +- .../services/unet/types_firewall_data_set.go | 18 +- .../services/unet/types_firewall_rule_set.go | 6 +- .../services/unet/types_resource_set.go | 8 +- .../unet/types_share_bandwidth_set.go | 6 +- .../unet/types_unet_allocate_eipset.go | 6 +- .../unet/types_unet_bandwidth_package_set.go | 6 +- .../unet/types_unet_bandwidth_usage_eipset.go | 6 +- .../services/unet/types_unet_eipaddr_set.go | 6 +- .../unet/types_unet_eipresource_set.go | 6 +- .../services/unet/types_unet_eipset.go | 6 +- .../unet/types_unet_share_bandwidth_set.go | 6 +- .../services/unet/types_vipdetail_set.go | 12 +- .../services/unet/types_vipset.go | 6 +- .../services/unet/update_firewall.go | 2 +- .../ucloud-sdk-go/services/vpc/client.go | 2 + .../ucloud/ucloud-sdk-go/services/vpc/doc.go | 2 +- .../services/vpc/types_resource_info.go | 6 +- .../services/vpc/types_vpcintercom_info.go | 6 +- .../services/vpc/types_vpcsubnet_info_set.go | 6 +- .../ucloud/ucloud-sdk-go/ucloud/client.go | 16 +- .../ucloud/ucloud-sdk-go/ucloud/config.go | 5 + .../ucloud/error/server_error.go | 10 +- .../ucloud/ucloud-sdk-go/ucloud/log/logger.go | 1 + .../ucloud/ucloud-sdk-go/ucloud/marshaler.go | 21 +- .../ucloud-sdk-go/ucloud/request/common.go | 18 + .../ucloud-sdk-go/ucloud/version/version.go | 2 +- vendor/vendor.json | 108 ++-- 136 files changed, 2527 insertions(+), 1819 deletions(-) create mode 100644 model/cli/cli_const.go create mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/LICENSE rename vendor/github.com/ucloud/ucloud-sdk-go/{services/ulb => private/services/udisk}/client.go (60%) create mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/delete_udisk_snapshot.go create mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/describe_udisk_snapshot.go create mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/types_udisk_snapshot_set.go create mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/client.go create mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/delete_snapshot.go create mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/describe_snapshot.go create mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/restore_uhost_disk.go create mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/types_snapshot_set.go create mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/private/utils/patch.go create mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/delete_udisk_snapshot.go create mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/describe_udisk_snapshot.go create mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/types_udisk_snapshot_set.go create mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/import_custom_image.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/allocate_backend.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/allocate_backend_batch.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_policy.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_ulb.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_vserver.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_policy.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_ulb.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_vserver.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_ulb.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_vserver.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/doc.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/release_backend.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_backend_set.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_policy_backend_set.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulb_policy_backend_set.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulb_policy_group_set.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulb_policy_set.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbbackend_set.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbipset.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbpolicy_set.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbset.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbsslset.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbvserver_set.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_backend_attribute.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_policy.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_ulbattribute.go delete mode 100644 vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_vserver_attribute.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 3979ba3f6b..182ecc6167 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ ## Change Log +v0.1.5 +* support batch operation. + +v0.1.4 +* add udisk. +* polling udisk and uhost long time operation +* async complete resource-id v0.1.3 * integrate auto completion. diff --git a/base/client.go b/base/client.go index ecd923827f..be8e99d6ee 100644 --- a/base/client.go +++ b/base/client.go @@ -1,26 +1,33 @@ package base import ( + pudisk "github.com/ucloud/ucloud-sdk-go/private/services/udisk" + 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/udisk" "github.com/ucloud/ucloud-sdk-go/services/uhost" - "github.com/ucloud/ucloud-sdk-go/services/ulb" "github.com/ucloud/ucloud-sdk-go/services/unet" "github.com/ucloud/ucloud-sdk-go/services/vpc" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) +//PrivateUDiskClient 私有模块的udisk client 即未在官网开放的接口 +type PrivateUDiskClient = pudisk.UDiskClient + +//PrivateUHostClient 私有模块的udisk client 即未在官网开放的接口 +type PrivateUHostClient = puhost.UHostClient + //Client aggregate client for business type Client struct { uaccount.UAccountClient uhost.UHostClient unet.UNetClient - ulb.ULBClient vpc.VPCClient pathx.PathXClient udisk.UDiskClient + PrivateUHostClient } // NewClient will return a aggregate client @@ -29,9 +36,9 @@ func NewClient(config *ucloud.Config, credential *auth.Credential) *Client { *uaccount.NewClient(config, credential), *uhost.NewClient(config, credential), *unet.NewClient(config, credential), - *ulb.NewClient(config, credential), *vpc.NewClient(config, credential), *pathx.NewClient(config, credential), *udisk.NewClient(config, credential), + *puhost.NewClient(config, credential), } } diff --git a/base/config.go b/base/config.go index 62bfb0622b..109707f9f9 100644 --- a/base/config.go +++ b/base/config.go @@ -187,7 +187,6 @@ func init() { ConfigInstance.LoadConfig() timeout, _ := time.ParseDuration("15s") ClientConfig = &sdk.Config{ - ProjectId: ConfigInstance.ProjectID, BaseUrl: "https://api.ucloud.cn/", Timeout: timeout, UserAgent: fmt.Sprintf("UCloud CLI v%s", Version), diff --git a/base/util.go b/base/util.go index 3539fdb9ab..8b1e5a043f 100644 --- a/base/util.go +++ b/base/util.go @@ -20,6 +20,7 @@ import ( "github.com/ucloud/ucloud-sdk-go/ucloud/response" "github.com/ucloud/ucloud-cli/model" + "github.com/ucloud/ucloud-cli/ux" ) //ConfigPath 配置文件路径 @@ -263,59 +264,162 @@ var RegionLabel = map[string]string{ "afr-nigeria": "Lagos", } -//Poll 轮询 -func Poll(describeFunc func(string, string, string, string) (interface{}, error)) func(string, string, string, string, []string) chan bool { - stateFields := []string{"State", "Status"} - return func(resourceID, projectID, region, zone string, targetState []string) chan bool { - w := waiter.StateWaiter{ - Pending: []string{"pending"}, - Target: []string{"avaliable"}, - Refresh: func() (interface{}, string, error) { - inst, err := describeFunc(resourceID, projectID, region, zone) - if err != nil { - return nil, "", err - } +//Poller 轮询器 +type Poller struct { + stateFields []string + DescribeFunc func(string, string, string, string) (interface{}, error) + Out io.Writer + Timeout time.Duration + SdescribeFunc func(string) (interface{}, error) +} + +//Spoll 简化版 +func (p *Poller) Spoll(resourceID, pollText string, targetStates []string) { + w := waiter.StateWaiter{ + Pending: []string{"pending"}, + Target: []string{"avaliable"}, + Refresh: func() (interface{}, string, error) { + inst, err := p.SdescribeFunc(resourceID) + if err != nil { + return nil, "", err + } - if inst == nil { - return nil, "pending", nil + if inst == nil { + return nil, "pending", nil + } + instValue := reflect.ValueOf(inst) + instValue = reflect.Indirect(instValue) + instType := instValue.Type() + if instValue.Kind() != reflect.Struct { + return nil, "", fmt.Errorf("Instance is not struct") + } + state := "" + for i := 0; i < instValue.NumField(); i++ { + for _, sf := range p.stateFields { + if instType.Field(i).Name == sf { + state = instValue.Field(i).String() + } } - instValue := reflect.ValueOf(inst) - instValue = reflect.Indirect(instValue) - instType := instValue.Type() - if instValue.Kind() != reflect.Struct { - return nil, "", fmt.Errorf("Instance is not struct") + } + if state != "" { + for _, t := range targetStates { + if t == state { + return inst, "avaliable", nil + } } - state := "" - for i := 0; i < instValue.NumField(); i++ { - for _, sf := range stateFields { - if instType.Field(i).Name == sf { - state = instValue.Field(i).String() - } + } + return nil, "pending", nil + + }, + Timeout: p.Timeout, + } + + done := make(chan bool) + go func() { + if resp, err := w.Wait(); err != nil { + log.Error(err) + if _, ok := err.(*waiter.TimeoutError); ok { + done <- false + return + } + } else { + log.Infof("%#v", resp) + } + done <- true + }() + + spinner := ux.NewDotSpinner(p.Out) + spinner.Start(pollText) + ret := <-done + if ret { + spinner.Stop() + } else { + spinner.Timeout() + } +} + +//Poll function +func (p *Poller) Poll(resourceID, projectID, region, zone, pollText string, targetState []string) { + w := waiter.StateWaiter{ + Pending: []string{"pending"}, + Target: []string{"avaliable"}, + Refresh: func() (interface{}, string, error) { + inst, err := p.DescribeFunc(resourceID, projectID, region, zone) + if err != nil { + return nil, "", err + } + + if inst == nil { + return nil, "pending", nil + } + instValue := reflect.ValueOf(inst) + instValue = reflect.Indirect(instValue) + instType := instValue.Type() + if instValue.Kind() != reflect.Struct { + return nil, "", fmt.Errorf("Instance is not struct") + } + state := "" + for i := 0; i < instValue.NumField(); i++ { + for _, sf := range p.stateFields { + if instType.Field(i).Name == sf { + state = instValue.Field(i).String() } } - if state != "" { - for _, t := range targetState { - if t == state { - return inst, "avaliable", nil - } + } + if state != "" { + for _, t := range targetState { + if t == state { + return inst, "avaliable", nil } } - return nil, "pending", nil + } + return nil, "pending", nil - }, - Timeout: 5 * time.Minute, - } + }, + Timeout: p.Timeout, + } - done := make(chan bool) - go func() { - if resp, err := w.Wait(); err != nil { - log.Error(err) - } else { - log.Infof("%#v", resp) + done := make(chan bool) + go func() { + if resp, err := w.Wait(); err != nil { + log.Error(err) + if _, ok := err.(*waiter.TimeoutError); ok { + done <- false + return } - done <- true - }() - return done + } else { + log.Infof("%#v", resp) + } + done <- true + }() + + spinner := ux.NewDotSpinner(p.Out) + spinner.Start(pollText) + ret := <-done + if ret { + spinner.Stop() + } else { + spinner.Timeout() + } +} + +//NewSpoller simple +func NewSpoller(describeFunc func(string) (interface{}, error), out io.Writer) *Poller { + return &Poller{ + SdescribeFunc: describeFunc, + Out: out, + stateFields: []string{"State", "Status"}, + Timeout: 10 * time.Minute, + } +} + +//NewPoller 轮询 +func NewPoller(describeFunc func(string, string, string, string) (interface{}, error), out io.Writer) *Poller { + return &Poller{ + DescribeFunc: describeFunc, + Out: out, + stateFields: []string{"State", "Status"}, + Timeout: 10 * time.Minute, } } diff --git a/cmd/disk.go b/cmd/disk.go index 96de339b2e..73b884d14f 100644 --- a/cmd/disk.go +++ b/cmd/disk.go @@ -16,10 +16,12 @@ package cmd import ( "fmt" + "io" "strings" "github.com/spf13/cobra" + "github.com/ucloud/ucloud-sdk-go/private/services/uhost" "github.com/ucloud/ucloud-sdk-go/services/udisk" sdk "github.com/ucloud/ucloud-sdk-go/ucloud" @@ -35,22 +37,28 @@ func NewCmdDisk() *cobra.Command { Short: "Read and manipulate udisk instances", Long: "Read and manipulate udisk instances", } - cmd.AddCommand(NewCmdDiskCreate()) + writer := base.Cxt.GetWriter() + cmd.AddCommand(NewCmdDiskCreate(writer)) cmd.AddCommand(NewCmdDiskList()) - cmd.AddCommand(NewCmdDiskAttach()) - cmd.AddCommand(NewCmdDiskDetach()) + cmd.AddCommand(NewCmdDiskAttach(writer)) + cmd.AddCommand(NewCmdDiskDetach(writer)) cmd.AddCommand(NewCmdDiskDelete()) - cmd.AddCommand(NewCmdDiskClone()) + cmd.AddCommand(NewCmdDiskClone(writer)) cmd.AddCommand(NewCmdDiskExpand()) + cmd.AddCommand(NewCmdDiskSnapshot(writer)) + cmd.AddCommand(NewCmdDiskRestore(writer)) + cmd.AddCommand(NewCmdSnapshotList(writer)) + cmd.AddCommand(NewCmdSnapshotDelete(writer)) return cmd } //NewCmdDiskCreate ucloud udisk create -func NewCmdDiskCreate() *cobra.Command { +func NewCmdDiskCreate(out io.Writer) *cobra.Command { var async *bool var count *int + var enableDataArk *string + var snapshotID *string req := base.BizClient.NewCreateUDiskRequest() - enableDataArk := sdk.String("false") cmd := &cobra.Command{ Use: "create", Short: "Create udisk instance", @@ -71,23 +79,57 @@ func NewCmdDiskCreate() *cobra.Command { } else if *req.DiskType == "SSD" { *req.DiskType = "SSDDataDisk" } - for i := 0; i < *count; i++ { - resp, err := base.BizClient.CreateUDisk(req) - if err != nil { - base.HandleError(err) - return + if *snapshotID != "" { + cloneReq := base.BizClient.NewCloneUDiskSnapshotRequest() + cloneReq.UDataArkMode = req.UDataArkMode + cloneReq.SourceId = snapshotID + cloneReq.ProjectId = req.ProjectId + cloneReq.Region = req.Region + cloneReq.Zone = req.Zone + cloneReq.Name = req.Name + cloneReq.Size = req.Size + cloneReq.ChargeType = req.ChargeType + cloneReq.Quantity = req.Quantity + for i := 0; i < *count; i++ { + resp, err := base.BizClient.CloneUDiskSnapshot(cloneReq) + if err != nil { + base.HandleError(err) + return + } + if count := len(resp.UDiskId); count == 1 { + text := fmt.Sprintf("udisk:%v is initializing", resp.UDiskId) + if *async { + fmt.Fprintln(out, text) + } else { + poller := base.NewSpoller(describeUdiskByID, out) + poller.Spoll(resp.UDiskId[0], text, []string{status.DISK_AVAILABLE, status.DISK_FAILED}) + } + } else if count > 1 { + base.Cxt.Printf("udisk:%v created\n", resp.UDiskId) + } else { + base.Cxt.PrintErr(fmt.Errorf("none udisk created")) + } } - if count := len(resp.UDiskId); count == 1 { - text := fmt.Sprintf("udisk:%v is initializing", resp.UDiskId) - if *async { - base.Cxt.Println(text) + } else { + for i := 0; i < *count; i++ { + resp, err := base.BizClient.CreateUDisk(req) + if err != nil { + base.HandleError(err) + return + } + if count := len(resp.UDiskId); count == 1 { + text := fmt.Sprintf("udisk:%v is initializing", resp.UDiskId) + if *async { + fmt.Fprintln(out, text) + } else { + poller := base.NewSpoller(describeUdiskByID, out) + poller.Spoll(resp.UDiskId[0], text, []string{status.DISK_AVAILABLE, status.DISK_FAILED}) + } + } else if count > 1 { + base.Cxt.Printf("udisk:%v created\n", resp.UDiskId) } else { - pollDisk(resp.UDiskId[0], *req.ProjectId, *req.Region, *req.Zone, text, []string{status.DISK_AVAILABLE, status.DISK_FAILED}) + base.Cxt.PrintErr(fmt.Errorf("none udisk created")) } - } else if count > 1 { - base.Cxt.Printf("udisk:%v created\n", resp.UDiskId) - } else { - base.Cxt.PrintErr(fmt.Errorf("none udisk created")) } } }, @@ -96,6 +138,7 @@ func NewCmdDiskCreate() *cobra.Command { flags.SortFlags = false req.Name = flags.String("name", "", "Required. Name of the udisk to create") req.Size = flags.Int("size-gb", 10, "Required. Size of the udisk to create. Unit:GB. Normal udisk [1,8000]; SSD udisk [1,4000] ") + snapshotID = flags.String("snapshot-id", "", "Optional. Resource ID of a snapshot, which will apply to the udisk being created. If you set this option, 'udisk-type' will be omitted.") req.ProjectId = flags.String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") req.Region = flags.String("region", base.ConfigInstance.Region, "Optional. Assign region") req.Zone = flags.String("zone", base.ConfigInstance.Zone, "Optional. Assign availability zone") @@ -104,7 +147,6 @@ func NewCmdDiskCreate() *cobra.Command { enableDataArk = flags.String("enable-data-ark", "false", "Optional. DataArk supports real-time backup, which can restore the udisk back to any moment within the last 12 hours.") req.Tag = flags.String("group", "Default", "Optional. Business group") req.DiskType = flags.String("udisk-type", "Oridinary", "Optional. 'Ordinary' or 'SSD'") - req.CouponId = flags.String("coupon-id", "", "Optional. Coupon ID, The Coupon can deduct part of the payment.See https://accountv2.ucloud.cn") async = flags.Bool("async", false, "Optional. Do not wait for the long-running operation to finish.") count = flags.Int("count", 1, "Optional. The count of udisk to create. Range [1,10]") @@ -192,7 +234,7 @@ func NewCmdDiskList() *cobra.Command { req.ProjectId = flags.String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") req.Region = flags.String("region", base.ConfigInstance.Region, "Optional. Assign region") req.Zone = flags.String("zone", base.ConfigInstance.Zone, "Optional. Assign availability zone") - req.UDiskId = flags.String("resource-id", "", "Optional. Resource ID of the udisk to search") + req.UDiskId = flags.String("udisk-id", "", "Optional. Resource ID of the udisk to search") req.DiskType = flags.String("udisk-type", "", "Optional. Optional. Type of the udisk to search. 'Oridinary-Data-Disk','Oridinary-System-Disk' or 'SSD-Data-Disk'") req.Offset = cmd.Flags().Int("offset", 0, "Optional. Offset") req.Limit = cmd.Flags().Int("limit", 50, "Optional. Limit") @@ -201,7 +243,7 @@ func NewCmdDiskList() *cobra.Command { } //NewCmdDiskAttach ucloud disk attach -func NewCmdDiskAttach() *cobra.Command { +func NewCmdDiskAttach(out io.Writer) *cobra.Command { var async *bool var udiskIDs *[]string @@ -223,9 +265,10 @@ func NewCmdDiskAttach() *cobra.Command { } text := fmt.Sprintf("udisk[%s] is attaching to uhost uhost[%s]", *req.UDiskId, *req.UHostId) if *async { - base.Cxt.Println(text) + fmt.Fprintln(out, text) } else { - pollDisk(resp.UDiskId, *req.ProjectId, *req.Region, *req.Zone, text, []string{status.DISK_INUSE, status.DISK_FAILED}) + poller := base.NewSpoller(describeUdiskByID, out) + poller.Spoll(resp.UDiskId, text, []string{status.DISK_INUSE, status.DISK_FAILED}) } } }, @@ -253,7 +296,7 @@ func NewCmdDiskAttach() *cobra.Command { } //NewCmdDiskDetach ucloud udisk detach -func NewCmdDiskDetach() *cobra.Command { +func NewCmdDiskDetach(out io.Writer) *cobra.Command { var async, yes *bool var udiskIDs *[]string req := base.BizClient.NewDetachUDiskRequest() @@ -275,34 +318,11 @@ func NewCmdDiskDetach() *cobra.Command { } for _, id := range *udiskIDs { id = base.PickResourceID(id) - any, err := describeUdiskByID(id, *req.ProjectId, *req.Region, *req.Zone) + err := detachUdisk(*async, id, out) if err != nil { - base.HandleError(err) - continue - } - if any == nil { - base.Cxt.PrintErr(fmt.Errorf("udisk[%v] is not exist", any)) - continue - } - ins, ok := any.(*udisk.UDiskDataSet) - if !ok { - base.Cxt.PrintErr(fmt.Errorf("%#v convert to udisk failed", any)) + base.Cxt.Println(err) continue } - req.UHostId = &ins.UHostId - req.UDiskId = &id - *req.UHostId = base.PickResourceID(*req.UHostId) - resp, err := base.BizClient.DetachUDisk(req) - if err != nil { - base.HandleError(err) - continue - } - text := fmt.Sprintf("udisk[%s] is detaching from uhost[%s]", resp.UDiskId, resp.UHostId) - if *async { - base.Cxt.Println(text) - } else { - pollDisk(resp.UDiskId, *req.ProjectId, *req.Region, *req.Zone, text, []string{status.DISK_AVAILABLE, status.DISK_FAILED}) - } } }, } @@ -312,7 +332,7 @@ func NewCmdDiskDetach() *cobra.Command { req.ProjectId = flags.String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") req.Region = flags.String("region", base.ConfigInstance.Region, "Optional. Assign region") req.Zone = flags.String("zone", base.ConfigInstance.Zone, "Optional. Assign availability zone") - async = flags.Bool("async", false, "Optional. Do not wait for the long-running operation to finish.") + async = flags.BoolP("async", "a", false, "Optional. Do not wait for the long-running operation to finish.") yes = flags.BoolP("yes", "y", false, "Optional. Do not prompt for confirmation.") flags.SetFlagValuesFunc("udisk-id", func() []string { @@ -323,6 +343,35 @@ func NewCmdDiskDetach() *cobra.Command { return cmd } +func detachUdisk(async bool, udiskID string, out io.Writer) error { + any, err := describeUdiskByID(udiskID) + if err != nil { + return err + } + if any == nil { + return fmt.Errorf("udisk[%v] is not exist", any) + } + ins, ok := any.(*udisk.UDiskDataSet) + if !ok { + return fmt.Errorf("%#v convert to udisk failed", any) + } + req := base.BizClient.NewDetachUDiskRequest() + req.UHostId = sdk.String(ins.UHostId) + req.UDiskId = sdk.String(udiskID) + resp, err := base.BizClient.DetachUDisk(req) + if err != nil { + return err + } + text := fmt.Sprintf("udisk[%s] is detaching from uhost[%s]", resp.UDiskId, resp.UHostId) + if async { + fmt.Fprintln(out, text) + } else { + poller := base.NewSpoller(describeUdiskByID, out) + poller.Spoll(udiskID, text, []string{status.DISK_AVAILABLE, status.DISK_FAILED}) + } + return nil +} + //NewCmdDiskDelete ucloud udisk delete func NewCmdDiskDelete() *cobra.Command { var yes *bool @@ -374,7 +423,7 @@ func NewCmdDiskDelete() *cobra.Command { } //NewCmdDiskClone ucloud disk clone -func NewCmdDiskClone() *cobra.Command { +func NewCmdDiskClone(out io.Writer) *cobra.Command { var async *bool req := base.BizClient.NewCloneUDiskRequest() enableDataArk := sdk.String("false") @@ -399,9 +448,10 @@ func NewCmdDiskClone() *cobra.Command { if len(resp.UDiskId) == 1 { text := fmt.Sprintf("cloned udisk:[%s] is initializing", resp.UDiskId[0]) if *async { - base.Cxt.Println(text) + fmt.Fprintln(out, text) } else { - pollDisk(resp.UDiskId[0], *req.ProjectId, *req.Region, *req.Zone, text, []string{status.DISK_AVAILABLE, status.DISK_FAILED}) + poller := base.NewSpoller(describeUdiskByID, out) + poller.Spoll(resp.UDiskId[0], text, []string{status.DISK_AVAILABLE, status.DISK_FAILED}) } } else { base.Cxt.Printf("udisk[%v] cloned", resp.UDiskId) @@ -478,6 +528,208 @@ func NewCmdDiskExpand() *cobra.Command { return cmd } +//NewCmdDiskSnapshot ucloud udisk snapshot +func NewCmdDiskSnapshot(out io.Writer) *cobra.Command { + var async *bool + var udiskIDs *[]string + req := base.BizClient.NewCreateUDiskSnapshotRequest() + cmd := &cobra.Command{ + Use: "snapshot", + Short: "Create shapshots for udisks", + Long: "Create shapshots for udisks", + Run: func(c *cobra.Command, args []string) { + for _, id := range *udiskIDs { + id = base.PickResourceID(id) + req.UDiskId = &id + resp, err := base.BizClient.CreateUDiskSnapshot(req) + if err != nil { + base.HandleError(err) + return + } + if len(resp.SnapshotId) == 1 { + text := fmt.Sprintf("snapshot[%s] is creating", resp.SnapshotId[0]) + if *async { + fmt.Fprintln(out, text) + } else { + poller := base.NewSpoller(describeSnapshotByID, out) + poller.Spoll(resp.SnapshotId[0], text, []string{status.SNAPSHOT_NORMAL}) + } + } else { + fmt.Fprintf(out, "snapshot%v is creating. expect snapshot count 1, accept %d\n", resp.SnapshotId, len(resp.SnapshotId)) + } + } + }, + } + flags := cmd.Flags() + flags.SortFlags = false + udiskIDs = flags.StringSlice("udisk-id", nil, "Required. Resource ID of udisks to snapshot") + req.Name = flags.String("name", "", "Required. Name of snapshots") + req.ProjectId = flags.String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") + req.Region = flags.String("region", base.ConfigInstance.Region, "Optional. Assign region") + req.Zone = flags.String("zone", base.ConfigInstance.Zone, "Optional. Assign availability zone") + req.Comment = flags.String("comment", "", "Optional. Description of snapshots") + async = flags.BoolP("async", "a", false, "Optional. Do not wait for the long-running operation to finish.") + flags.SetFlagValuesFunc("udisk-id", func() []string { + return getDiskList([]string{status.DISK_AVAILABLE, status.DISK_INUSE}, *req.ProjectId, *req.Region, *req.Zone) + }) + cmd.MarkFlagRequired("udisk-id") + cmd.MarkFlagRequired("name") + return cmd +} + +//NewCmdDiskRestore ucloud udisk restore +func NewCmdDiskRestore(out io.Writer) *cobra.Command { + var snapshotIDs *[]string + req := base.BizClient.NewRestoreUHostDiskRequest() + cmd := &cobra.Command{ + Use: "restore", + Short: "Restore udisk from snapshot", + Long: "Restore udisk from snapshot", + Run: func(cmd *cobra.Command, args []string) { + for _, snapshotID := range *snapshotIDs { + snapshotID = base.PickResourceID(snapshotID) + any, err := describeSnapshotByID(snapshotID) + if err != nil { + base.HandleError(err) + continue + } + snapshot, ok := any.(*uhost.SnapshotSet) + if !ok { + fmt.Fprintf(out, "snapshot[%s] doesn't exist\n", snapshotID) + continue + } + if snapshot.UHostId != "" { + text := fmt.Sprintf("can we detach udisk[%s] from uhost[%s]?", snapshot.DiskId, snapshot.UHostId) + sure, err := ux.Prompt(text) + if err != nil { + base.HandleError(err) + continue + } + if !sure { + continue + } + detachUdisk(false, snapshot.DiskId, out) + } + req.SnapshotIds = append(req.SnapshotIds, snapshotID) + _, err = base.BizClient.RestoreUHostDisk(req) + + if err != nil { + base.HandleError(err) + return + } + + text := fmt.Sprintf("udisk[%s] has been restored from snapshot[%s]", snapshot.DiskId, snapshot.SnapshotId) + fmt.Fprintln(out, text) + } + }, + } + flags := cmd.Flags() + flags.SortFlags = false + snapshotIDs = flags.StringSlice("snapshot-id", nil, "Required. Resourece ID of the snapshots to restore from") + req.ProjectId = flags.String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") + req.Region = flags.String("region", base.ConfigInstance.Region, "Optional. Assign region") + req.Zone = flags.String("zone", base.ConfigInstance.Zone, "Optional. Assign availability zone") + flags.SetFlagValuesFunc("snapshot-id", func() []string { + return getSnapshotList([]string{status.SNAPSHOT_NORMAL}, *req.ProjectId, *req.Region, *req.Zone) + }) + cmd.MarkFlagRequired("snapshot-id") + return cmd +} + +//SnapshotRow 表格行 +type SnapshotRow struct { + Name string + ResourceID string + AvailabilityZone string + BoundUDisk string + Size string + State string + UDiskType string + CreationTime string +} + +//NewCmdSnapshotList ucloud udisk list-snapshot +func NewCmdSnapshotList(out io.Writer) *cobra.Command { + req := base.BizClient.NewDescribeSnapshotRequest() + cmd := &cobra.Command{ + Use: "list-snapshot", + Short: "List snaphosts", + Long: "List snaphosts", + Run: func(c *cobra.Command, args []string) { + resp, err := base.BizClient.DescribeSnapshot(req) + if err != nil { + base.HandleError(err) + return + } + list := []SnapshotRow{} + for _, snapshot := range resp.UHostSnapshotSet { + row := SnapshotRow{ + Name: snapshot.SnapshotName, + ResourceID: snapshot.SnapshotId, + AvailabilityZone: snapshot.Zone, + BoundUDisk: snapshot.DiskId, + Size: fmt.Sprintf("%dGB", snapshot.Size), + State: snapshot.State, + UDiskType: snapshot.DiskType, + CreationTime: base.FormatDate(snapshot.CreateTime), + } + list = append(list, row) + } + if global.json { + base.PrintJSON(list) + } else { + base.PrintTableS(list) + } + }, + } + + flags := cmd.Flags() + flags.SortFlags = false + + req.ProjectId = flags.String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") + req.Region = flags.String("region", base.ConfigInstance.Region, "Optional. Assign region") + req.Zone = flags.String("zone", base.ConfigInstance.Zone, "Optional. Assign availability zone") + req.SnapshotIds = *flags.StringSlice("snaphost-id", nil, "Optional. Resource ID of snapshots to list") + req.UHostId = flags.String("uhost-id", "", "Optional. Snapshots of the uhost") + req.DiskId = flags.String("disk-id", "", "Optional. Snapshots of the udisk") + req.Offset = cmd.Flags().Int("offset", 0, "Optional. Offset") + req.Limit = cmd.Flags().Int("limit", 50, "Optional. Limit, length of snaphost list") + + return cmd +} + +//NewCmdSnapshotDelete ucloud udisk delete-snapshot +func NewCmdSnapshotDelete(out io.Writer) *cobra.Command { + var snapshotIds *[]string + req := base.BizClient.NewDeleteSnapshotRequest() + cmd := &cobra.Command{ + Use: "delete-snapshot", + Short: "Delete snapshots", + Long: "Delete snapshots", + Run: func(c *cobra.Command, args []string) { + for _, snapshotID := range *snapshotIds { + req.SnapshotId = sdk.String(base.PickResourceID(snapshotID)) + resp, err := base.BizClient.DeleteSnapshot(req) + if err != nil { + base.HandleError(err) + return + } + fmt.Fprintf(out, "snapshot[%s] deleted\n", resp.SnapshotId) + } + }, + } + + flags := cmd.Flags() + flags.SortFlags = false + + req.ProjectId = flags.String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") + req.Region = flags.String("region", base.ConfigInstance.Region, "Optional. Assign region") + req.Zone = flags.String("zone", base.ConfigInstance.Zone, "Optional. Assign availability zone") + snapshotIds = flags.StringSlice("snaphost-id", nil, "Optional. Resource ID of snapshots to delete") + cmd.MarkFlagRequired("snapshot-id") + return cmd +} + func getDiskList(states []string, project, region, zone string) []string { req := base.BizClient.NewDescribeUDiskRequest() req.ProjectId = sdk.String(project) @@ -500,20 +752,9 @@ func getDiskList(states []string, project, region, zone string) []string { return list } -func pollDisk(resourceID, projectID, region, zone, pollText string, targetState []string) { - pollFunc := base.Poll(describeUdiskByID) - done := pollFunc(resourceID, projectID, region, zone, targetState) - ux.DotSpinner.Start(pollText) - <-done - ux.DotSpinner.Stop() -} - -func describeUdiskByID(udiskID, project, region, zone string) (interface{}, error) { +func describeUdiskByID(udiskID string) (interface{}, error) { req := base.BizClient.NewDescribeUDiskRequest() req.UDiskId = sdk.String(udiskID) - req.ProjectId = sdk.String(project) - req.Region = sdk.String(region) - req.Zone = sdk.String(zone) req.Limit = sdk.Int(50) resp, err := base.BizClient.DescribeUDisk(req) if err != nil { @@ -524,3 +765,38 @@ func describeUdiskByID(udiskID, project, region, zone string) (interface{}, erro } return &resp.DataSet[0], nil } + +func getSnapshotList(states []string, project, region, zone string) []string { + req := base.BizClient.NewDescribeUDiskSnapshotRequest() + req.Limit = sdk.Int(50) + req.ProjectId = &project + req.Region = ®ion + req.Zone = &zone + resp, err := base.BizClient.DescribeUDiskSnapshot(req) + if err != nil { + return nil + } + list := []string{} + for _, snapshot := range resp.DataSet { + for _, s := range states { + if snapshot.Status == s { + list = append(list, snapshot.SnapshotId+"/"+strings.Replace(snapshot.Name, " ", "-", -1)) + } + } + } + return list +} + +func describeSnapshotByID(snapshotID string) (interface{}, error) { + req := base.BizClient.NewDescribeSnapshotRequest() + req.SnapshotIds = append(req.SnapshotIds, snapshotID) + req.Limit = sdk.Int(50) + resp, err := base.BizClient.DescribeSnapshot(req) + if err != nil { + return nil, err + } + if len(resp.UHostSnapshotSet) != 1 { + return nil, nil + } + return &resp.UHostSnapshotSet[0], nil +} diff --git a/cmd/eip.go b/cmd/eip.go index f397cd3e0d..76faec3717 100644 --- a/cmd/eip.go +++ b/cmd/eip.go @@ -18,6 +18,7 @@ import ( "fmt" "net" "strconv" + "strings" "time" "github.com/ucloud/ucloud-sdk-go/services/unet" @@ -158,6 +159,22 @@ func fetchAllEip(projectID, region string) ([]unet.UnetEIPSet, error) { return list, nil } +func getAllEip(states []string, projectID, region string) []string { + list, err := fetchAllEip(projectID, region) + if err != nil { + return nil + } + strs := []string{} + for _, item := range list { + ips := []string{} + for _, ip := range item.EIPAddr { + ips = append(ips, ip.IP) + } + strs = append(strs, item.EIPId+"/"+strings.Join(ips, ",")) + } + return strs +} + //NewCmdEIPAllocate ucloud eip allocate func NewCmdEIPAllocate() *cobra.Command { var count *int @@ -166,7 +183,7 @@ func NewCmdEIPAllocate() *cobra.Command { Use: "allocate", Short: "Allocate EIP", Long: "Allocate EIP", - Example: "ucloud eip allocate --line Bgp --bandwidth 2", + Example: "ucloud eip allocate --line BGP --bandwidth 2", Run: func(cmd *cobra.Command, args []string) { if *req.OperatorName == "BGP" { *req.OperatorName = "Bgp" diff --git a/cmd/globalssh.go b/cmd/globalssh.go index 999e2d5725..13770a1420 100644 --- a/cmd/globalssh.go +++ b/cmd/globalssh.go @@ -203,7 +203,7 @@ func NewCmdGsshDelete() *cobra.Command { Use: "delete", Short: "Delete GlobalSSH instance", Long: "Delete GlobalSSH instance", - Example: "ucloud gssh delete --resource-id uga-xx1 --id uga-xx2", + Example: "ucloud gssh delete --gssh-id uga-xx1 --id uga-xx2", Run: func(cmd *cobra.Command, args []string) { for _, id := range *gsshIds { req.InstanceId = &id @@ -217,10 +217,10 @@ func NewCmdGsshDelete() *cobra.Command { }, } cmd.Flags().SortFlags = false - gsshIds = cmd.Flags().StringArray("resource-id", make([]string, 0), "Required. ID of the GlobalSSH instances you want to delete. Multiple values specified by multiple flags") + gsshIds = cmd.Flags().StringArray("gssh-id", make([]string, 0), "Required. ID of the GlobalSSH instances you want to delete. Multiple values specified by multiple flags") req.ProjectId = cmd.Flags().String("project-id", ConfigInstance.ProjectID, "Optional. Assign project-id") req.Region = cmd.Flags().String("region", ConfigInstance.Region, "Optional. Assign region") - cmd.MarkFlagRequired("resource-id") + cmd.MarkFlagRequired("gssh-id") return cmd } @@ -234,7 +234,7 @@ func NewCmdGsshModify() *cobra.Command { Use: "update", Short: "Update GlobalSSH instance", Long: "Update GlobalSSH instance, including port and remark attribute", - Example: "ucloud gssh update --resource-id uga-xxx --port 22", + Example: "ucloud gssh update --gssh-id uga-xxx --port 22", Run: func(cmd *cobra.Command, args []string) { gsshModifyPortReq.Region = sdk.String(region) gsshModifyPortReq.ProjectId = sdk.String(project) @@ -268,11 +268,11 @@ func NewCmdGsshModify() *cobra.Command { }, } cmd.Flags().SortFlags = false - gsshModifyRemarkReq.InstanceId = cmd.Flags().String("resource-id", "", "Required. InstanceID of your GlobalSSH") + gsshModifyRemarkReq.InstanceId = cmd.Flags().String("gssh-id", "", "Required. InstanceID of your GlobalSSH") cmd.Flags().StringVar(®ion, "region", ConfigInstance.Region, "Optional. Assign region") cmd.Flags().StringVar(&project, "project-id", ConfigInstance.ProjectID, "Optional. Assign project-id") gsshModifyPortReq.Port = cmd.Flags().Int("port", 0, "Optional. Port of SSH service.") gsshModifyRemarkReq.Remark = cmd.Flags().String("remark", "", "Optional. Remark of your GlobalSSH.") - cmd.MarkFlagRequired("resource-id") + cmd.MarkFlagRequired("gssh-id") return cmd } diff --git a/cmd/image.go b/cmd/image.go index ecce651e6c..29b2aefb9e 100644 --- a/cmd/image.go +++ b/cmd/image.go @@ -15,11 +15,17 @@ package cmd import ( + "fmt" + "io" "strings" "github.com/spf13/cobra" - . "github.com/ucloud/ucloud-cli/base" + sdk "github.com/ucloud/ucloud-sdk-go/ucloud" + + "github.com/ucloud/ucloud-cli/base" + "github.com/ucloud/ucloud-cli/model/cli" + "github.com/ucloud/ucloud-cli/model/status" ) //NewCmdUImage ucloud uimage @@ -30,7 +36,13 @@ func NewCmdUImage() *cobra.Command { Long: `List images`, Args: cobra.NoArgs, } + writer := base.Cxt.GetWriter() cmd.AddCommand(NewCmdUImageList()) + cmd.AddCommand(NewCmdImageCopy(writer)) + cmd.AddCommand(NewCmdUImageDelete()) + createImageCmd := NewCmdUhostCreateImage(writer) + createImageCmd.Use = "create" + cmd.AddCommand(createImageCmd) return cmd } @@ -47,20 +59,20 @@ type ImageRow struct { //NewCmdUImageList ucloud uimage list func NewCmdUImageList() *cobra.Command { - req := BizClient.NewDescribeImageRequest() + req := base.BizClient.NewDescribeImageRequest() cmd := &cobra.Command{ Use: "list", Short: "List image", Long: "List image", Example: "ucloud image list --image-type Base", Run: func(cmd *cobra.Command, args []string) { - resp, err := BizClient.DescribeImage(req) + resp, err := base.BizClient.DescribeImage(req) if err != nil { - HandleError(err) + base.HandleError(err) return } if global.json { - PrintJSON(resp.ImageSet) + base.PrintJSON(resp.ImageSet) } else { list := make([]ImageRow, 0) for _, image := range resp.ImageSet { @@ -69,24 +81,159 @@ func NewCmdUImageList() *cobra.Command { row.ImageID = image.ImageId row.BasicImage = image.OsName row.ExtensibleFeature = strings.Join(image.Features, ",") - row.CreationTime = FormatDate(image.CreateTime) + row.CreationTime = base.FormatDate(image.CreateTime) row.State = image.State if row.State == "Available" { list = append(list, row) } } - PrintTable(list, []string{"ImageName", "ImageID", "BasicImage", "ExtensibleFeature", "CreationTime"}) + base.PrintTable(list, []string{"ImageName", "ImageID", "BasicImage", "ExtensibleFeature", "CreationTime"}) } }, } - req.ProjectId = cmd.Flags().String("project-id", ConfigInstance.ProjectID, "Assign project-id") - req.Region = cmd.Flags().String("region", ConfigInstance.Region, "Assign region") - req.Zone = cmd.Flags().String("zone", ConfigInstance.Zone, "Assign availability zone") - req.ImageType = cmd.Flags().String("image-type", "", "'Base',Standard image; 'Business',image market; 'Custom',custom image; Return all types by default") - req.OsType = cmd.Flags().String("os-type", "", "Linux or Windows. Return all types by default") - req.ImageId = cmd.Flags().String("image-id", "", "iamge id such as 'uimage-xxx'") - req.Offset = cmd.Flags().Int("offset", 0, "offset default 0") - req.Limit = cmd.Flags().Int("limit", 500, "max count") + req.ProjectId = cmd.Flags().String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") + req.Region = cmd.Flags().String("region", base.ConfigInstance.Region, "Optional. Assign region") + req.Zone = cmd.Flags().String("zone", "", "Optional. Assign availability zone") + req.ImageType = cmd.Flags().String("image-type", "", "Optional. 'Base',Standard image; 'Business',image market; 'Custom',custom image; Return all types by default") + req.OsType = cmd.Flags().String("os-type", "", "Optional. Linux or Windows. Return all types by default") + req.ImageId = cmd.Flags().String("image-id", "", "Optional. Resource ID of image") + req.Offset = cmd.Flags().Int("offset", 0, "Optional. Offset default 0") + req.Limit = cmd.Flags().Int("limit", 500, "Optional. Max count") cmd.Flags().SetFlagValues("image-type", "Base", "Business", "Custom") return cmd } + +// func NewCmdImageImport() *cobra.Command { +// req := BizClient.NewImportCustomImageRequest() +// } + +//NewCmdUImageDelete ucloud image delete +func NewCmdUImageDelete() *cobra.Command { + var imageIDs *[]string + req := base.BizClient.NewTerminateCustomImageRequest() + cmd := &cobra.Command{ + Use: "delete", + Short: "Delete custom images", + Long: "Delete custom images", + Run: func(cmd *cobra.Command, args []string) { + for _, id := range *imageIDs { + req.ImageId = sdk.String(base.PickResourceID(id)) + resp, err := base.BizClient.TerminateCustomImage(req) + if err != nil { + base.HandleError(err) + return + } + base.Cxt.Printf("image[%s] deleted\n", resp.ImageId) + } + }, + } + flags := cmd.Flags() + flags.SortFlags = false + + imageIDs = cmd.Flags().StringSlice("image-id", nil, "Required. Resource ID of images") + req.ProjectId = cmd.Flags().String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") + req.Region = cmd.Flags().String("region", base.ConfigInstance.Region, "Optional. Assign region") + req.Zone = cmd.Flags().String("zone", "", "Optional. Assign availability zone") + cmd.MarkFlagRequired("image-id") + flags.SetFlagValuesFunc("image-id", func() []string { + return getImageList([]string{status.IMAGE_AVAILABLE, status.IMAGE_COPYING, status.IMAGE_MAKING}, cli.IAMGE_CUSTOM, *req.ProjectId, *req.Region, "") + }) + return cmd +} + +//NewCmdImageCopy ucloud image copy +func NewCmdImageCopy(out io.Writer) *cobra.Command { + var imageIDs *[]string + var async *bool + req := base.BizClient.NewCopyCustomImageRequest() + cmd := &cobra.Command{ + Use: "copy", + Short: "Copy custom images", + Long: "Copy custom images", + Run: func(c *cobra.Command, args []string) { + *req.ProjectId = base.PickResourceID(*req.ProjectId) + *req.TargetProjectId = base.PickResourceID(*req.TargetProjectId) + for _, id := range *imageIDs { + id = base.PickResourceID(id) + req.SourceImageId = &id + resp, err := base.BizClient.CopyCustomImage(req) + if err != nil { + base.HandleError(err) + return + } + text := fmt.Sprintf("image[%s] is coping", resp.TargetImageId) + if *async { + fmt.Fprintln(out, text) + } else { + poller := base.NewPoller(describeImageByID, out) + poller.Poll(resp.TargetImageId, *req.TargetProjectId, *req.TargetRegion, "", text, []string{status.IMAGE_AVAILABLE, status.IMAGE_UNAVAILABLE}) + } + } + }, + } + flags := cmd.Flags() + flags.SortFlags = false + imageIDs = cmd.Flags().StringSlice("source-image-id", nil, "Required. Resource ID of source image") + req.ProjectId = cmd.Flags().String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") + req.Region = cmd.Flags().String("region", base.ConfigInstance.Region, "Optional. Assign region") + req.Zone = cmd.Flags().String("zone", base.ConfigInstance.Zone, "Optional. Assign availability zone") + req.TargetRegion = flags.String("target-region", base.ConfigInstance.Region, "Optional. Target region. See 'ucloud region'") + req.TargetProjectId = flags.String("target-project", base.ConfigInstance.ProjectID, "Optional. Target Project ID. See 'ucloud project list'") + req.TargetImageName = flags.String("target-image-name", "", "Optional. Name of target image") + req.TargetImageDescription = flags.String("target-image-desc", "", "Optional. Description of target image") + async = flags.Bool("async", false, "Optional. Do not wait for the long-running operation to finish.") + + flags.SetFlagValuesFunc("source-image-id", func() []string { + return getImageList([]string{status.IMAGE_AVAILABLE}, cli.IAMGE_CUSTOM, *req.ProjectId, *req.Region, *req.Zone) + }) + flags.SetFlagValuesFunc("project-id", getProjectList) + flags.SetFlagValuesFunc("region", getRegionList) + flags.SetFlagValuesFunc("zone", getZoneList) + flags.SetFlagValuesFunc("target-region", getRegionList) + flags.SetFlagValuesFunc("target-project", getProjectList) + + cmd.MarkFlagRequired("source-image-id") + + return cmd +} + +func getImageList(states []string, imageType, project, region, zone string) []string { + req := base.BizClient.NewDescribeImageRequest() + req.ProjectId = &project + req.Region = ®ion + req.Zone = &zone + req.Limit = sdk.Int(1000) + if imageType != cli.IMAGE_ALL { + req.ImageType = sdk.String(imageType) + } + resp, err := base.BizClient.DescribeImage(req) + if err != nil { + return nil + } + list := []string{} + for _, image := range resp.ImageSet { + for _, s := range states { + if image.State == s { + list = append(list, image.ImageId+"/"+image.ImageName) + } + } + } + return list +} + +func describeImageByID(imageID, project, region, zone string) (interface{}, error) { + req := base.BizClient.NewDescribeImageRequest() + req.ImageId = sdk.String(imageID) + req.ProjectId = sdk.String(project) + req.Region = sdk.String(region) + req.Zone = sdk.String(zone) + req.Limit = sdk.Int(50) + resp, err := base.BizClient.DescribeImage(req) + if err != nil { + return nil, err + } + if len(resp.ImageSet) < 1 { + return nil, nil + } + return &resp.ImageSet[0], nil +} diff --git a/cmd/project.go b/cmd/project.go index 4a7648fa77..0ef9063305 100644 --- a/cmd/project.go +++ b/cmd/project.go @@ -148,3 +148,16 @@ func listProject() error { } return nil } + +func getProjectList() []string { + req := &uaccount.GetProjectListRequest{} + resp, err := BizClient.GetProjectList(req) + if err != nil { + return nil + } + list := []string{} + for _, p := range resp.ProjectSet { + list = append(list, p.ProjectId+"/"+p.ProjectName) + } + return list +} diff --git a/cmd/region.go b/cmd/region.go index 1e66911fc2..2150c1fd58 100644 --- a/cmd/region.go +++ b/cmd/region.go @@ -90,8 +90,36 @@ func fetchRegion() (map[string][]string, error) { return regionMap, nil } +func getRegionList() []string { + regionMap, err := fetchRegion() + if err != nil { + return nil + } + list := []string{} + for region := range regionMap { + list = append(list, region) + } + return list +} + +func getZoneList() []string { + regionMap, err := fetchRegion() + if err != nil { + return nil + } + list := []string{} + for _, zones := range regionMap { + list = append(list, zones...) + } + return list +} + +// func setupRequest(req request.Common) { +// req.SetZone() +// } func getDefaultProject() (string, string, error) { req := BizClient.NewGetProjectListRequest() + resp, err := BizClient.GetProjectList(req) if err != nil { return "", "", err diff --git a/cmd/root.go b/cmd/root.go index fec3ce1117..c44560d0d7 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -21,7 +21,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/spf13/cobra" - . "github.com/ucloud/ucloud-cli/base" + "github.com/ucloud/ucloud-cli/base" ) //GlobalFlag 几乎所有接口都需要的参数,例如 region zone projectID @@ -40,12 +40,12 @@ var global GlobalFlag func NewCmdRoot() *cobra.Command { var cmd = &cobra.Command{ Use: "ucloud", - Short: "UCloud CLI v" + Version, + Short: "UCloud CLI v" + base.Version, Long: `UCloud CLI - manage UCloud resources and developer workflow`, BashCompletionFunction: "__ucloud_init_completion", Run: func(cmd *cobra.Command, args []string) { if global.version { - Cxt.Printf("ucloud cli %s\n", Version) + base.Cxt.Printf("ucloud cli %s\n", base.Version) } else if global.completion { NewCmdCompletion().Run(cmd, args) } else if global.config { @@ -135,7 +135,7 @@ func Execute() { func init() { cobra.EnableCommandSorting = false cobra.OnInitialize(initialize) - Cxt.AppendInfo("command", fmt.Sprintf("%v", os.Args)) + base.Cxt.AppendInfo("command", fmt.Sprintf("%v", os.Args)) } func resetHelpFunc(cmd *cobra.Command) { @@ -147,25 +147,41 @@ func resetHelpFunc(cmd *cobra.Command) { } func initialize(cmd *cobra.Command) { + flags := cmd.Flags() + project, err := flags.GetString("project-id") + if err == nil { + base.ClientConfig.ProjectId = project + } + + region, err := flags.GetString("region") + if err == nil { + base.ClientConfig.Region = region + } + + zone, err := flags.GetString("zone") + if err == nil { + base.ClientConfig.Zone = zone + } + if global.debug { logrus.SetLevel(logrus.DebugLevel) } - userInfo, err := LoadUserInfo() + userInfo, err := base.LoadUserInfo() if err == nil { - Cxt.AppendInfo("userName", userInfo.UserEmail) - Cxt.AppendInfo("companyName", userInfo.CompanyName) + base.Cxt.AppendInfo("userName", userInfo.UserEmail) + base.Cxt.AppendInfo("companyName", userInfo.CompanyName) } else { - Cxt.PrintErr(err) + base.Cxt.PrintErr(err) } if (cmd.Name() != "config" && cmd.Name() != "init" && cmd.Name() != "version") && (cmd.Parent() != nil && cmd.Parent().Name() != "config") { if config.PrivateKey == "" { - Cxt.Println("private-key is empty. Execute command 'ucloud init' or 'ucloud config' to configure your private-key") + base.Cxt.Println("private-key is empty. Execute command 'ucloud init' or 'ucloud config' to configure your private-key") os.Exit(0) } if config.PublicKey == "" { - Cxt.Println("public-key is empty. Execute command 'ucloud init' or 'ucloud config' to configure your public-key") + base.Cxt.Println("public-key is empty. Execute command 'ucloud init' or 'ucloud config' to configure your public-key") os.Exit(0) } } diff --git a/cmd/root_test.go b/cmd/root_test.go index 4529a1d7da..91c4071e9d 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -1,8 +1,6 @@ package cmd -import "testing" - -func TestCmdRoot(t *testing.T) { - root := NewCmdRoot() - root.Execute() -} +// func TestCmdRoot(t *testing.T) { +// root := NewCmdRoot() +// root.Execute() +// } diff --git a/cmd/uhost.go b/cmd/uhost.go index d031297128..2409655802 100644 --- a/cmd/uhost.go +++ b/cmd/uhost.go @@ -15,7 +15,9 @@ package cmd import ( + "encoding/base64" "fmt" + "io" "net" "strings" @@ -25,6 +27,7 @@ import ( sdk "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-cli/base" + "github.com/ucloud/ucloud-cli/model/cli" "github.com/ucloud/ucloud-cli/model/status" "github.com/ucloud/ucloud-cli/ux" ) @@ -37,14 +40,19 @@ func NewCmdUHost() *cobra.Command { Long: `List,create,delete,stop,restart,poweroff or resize UHost instance`, Args: cobra.NoArgs, } + writer := base.Cxt.GetWriter() cmd.AddCommand(NewCmdUHostList()) - cmd.AddCommand(NewCmdUHostCreate()) - cmd.AddCommand(NewCmdUHostDelete()) - cmd.AddCommand(NewCmdUHostStop()) - cmd.AddCommand(NewCmdUHostStart()) - cmd.AddCommand(NewCmdUHostReboot()) + cmd.AddCommand(NewCmdUHostCreate(writer)) + cmd.AddCommand(NewCmdUHostDelete(writer)) + cmd.AddCommand(NewCmdUHostStop(writer)) + cmd.AddCommand(NewCmdUHostStart(writer)) + cmd.AddCommand(NewCmdUHostReboot(writer)) cmd.AddCommand(NewCmdUHostPoweroff()) - cmd.AddCommand(NewCmdUHostResize()) + cmd.AddCommand(NewCmdUHostResize(writer)) + cmd.AddCommand(NewCmdUHostClone(writer)) + cmd.AddCommand(NewCmdUhostResetPassword(writer)) + cmd.AddCommand(NewCmdUhostReinstallOS(writer)) + cmd.AddCommand(NewCmdUhostCreateImage(writer)) return cmd } @@ -117,7 +125,7 @@ func NewCmdUHostList() *cobra.Command { req.ProjectId = cmd.Flags().String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") req.Region = cmd.Flags().String("region", base.ConfigInstance.Region, "Optional. Assign region") req.Zone = cmd.Flags().String("zone", "", "Optional. Assign availability zone") - cmd.Flags().StringSliceVar(&req.UHostIds, "resource-id", make([]string, 0), "Optional. UHost Instance ID, multiple values separated by comma(without space)") + cmd.Flags().StringSliceVar(&req.UHostIds, "uhost-id", make([]string, 0), "Optional. UHost Instance ID, multiple values separated by comma(without space)") req.Tag = cmd.Flags().String("group", "", "Optional. Group") req.Offset = cmd.Flags().Int("offset", 0, "Optional. Offset default 0") req.Limit = cmd.Flags().Int("limit", 50, "Optional. Limit default 50, max value 100") @@ -126,7 +134,7 @@ func NewCmdUHostList() *cobra.Command { } //NewCmdUHostCreate [ucloud uhost create] -func NewCmdUHostCreate() *cobra.Command { +func NewCmdUHostCreate(out io.Writer) *cobra.Command { var bindEipID *string var async *bool @@ -139,10 +147,7 @@ func NewCmdUHostCreate() *cobra.Command { Run: func(cmd *cobra.Command, args []string) { *req.Memory *= 1024 req.LoginMode = sdk.String("Password") - images := strings.SplitN(*req.ImageId, "/", 2) - if len(images) >= 2 { - *req.ImageId = images[0] - } + req.ImageId = sdk.String(base.PickResourceID(*req.ImageId)) resp, err := base.BizClient.CreateUHostInstance(req) if err != nil { @@ -150,16 +155,17 @@ func NewCmdUHostCreate() *cobra.Command { return } - if !*async { - if len(resp.UHostIds) == 1 { - text := fmt.Sprintf("UHost:[%s] is initializing", resp.UHostIds[0]) - done := pollUhost(resp.UHostIds[0], *req.ProjectId, *req.Region, *req.Zone, []string{status.HOST_RUNNING, status.HOST_FAIL}) - ux.DotSpinner.Start(text) - <-done - ux.DotSpinner.Stop() + if len(resp.UHostIds) == 1 { + text := fmt.Sprintf("uhost[%s] is initializing", resp.UHostIds[0]) + if *async { + fmt.Fprintln(out, text) + } else { + poller := base.NewPoller(describeUHostByID, out) + poller.Poll(resp.UHostIds[0], *req.ProjectId, *req.Region, *req.Zone, text, []string{status.HOST_RUNNING, status.HOST_FAIL}) } } else { - base.Cxt.Printf("UHost:%v created\n", resp.UHostIds) + fmt.Fprintf(out, "expect uhost count 1 , accept %d", len(resp.UHostIds)) + return } if *bindEipID != "" && len(resp.UHostIds) == 1 { @@ -176,15 +182,13 @@ func NewCmdUHostCreate() *cobra.Command { } if *eipReq.OperatorName != "" && *eipReq.Bandwidth != 0 { - if *eipReq.OperatorName == "BGP" { - *eipReq.OperatorName = "Bgp" - } eipReq.ChargeType = req.ChargeType eipReq.Tag = req.Tag eipReq.Quantity = req.Quantity eipReq.Region = req.Region eipReq.ProjectId = req.ProjectId eipResp, err := base.BizClient.AllocateEIP(eipReq) + if err != nil { base.HandleError(err) } else { @@ -248,10 +252,8 @@ func NewCmdUHostCreate() *cobra.Command { req.Disks[1].Type = flags.String("data-disk-type", "LOCAL_NORMAL", "Optional. Enumeration value. 'LOCAL_NORMAL', Ordinary local disk; 'CLOUD_NORMAL', Ordinary cloud disk; 'LOCAL_SSD',local ssd disk; 'CLOUD_SSD',cloud ssd disk; 'EXCLUSIVE_LOCAL_DISK',big data. The disk only supports a limited combination.") req.Disks[1].Size = flags.Int("data-disk-size-gb", 20, "Optional. Disk size. Unit GB") req.Disks[1].BackupType = flags.String("data-disk-backup-type", "NONE", "Optional. Enumeration value, 'NONE' or 'DATAARK'. DataArk supports real-time backup, which can restore the disk back to any moment within the last 12 hours. (Normal Local Disk and Normal Cloud Disk Only)") - req.NetworkId = flags.String("network-id", "", "Optional. Network ID (no need to fill in the case of VPC2.0). In the case of VPC1.0, if not filled in, we will choose the basic network; if it is filled in, we will choose the subnet. See 'ucloud subnet list'.") req.SecurityGroupId = flags.String("firewall-id", "", "Optional. Firewall Id, default: Web recommended firewall. see 'ucloud firewall list'.") req.Tag = flags.String("group", "Default", "Optional. Business group") - req.CouponId = flags.String("coupon-id", "", "Optional. Coupon ID, The Coupon can deduct part of the payment,see https://accountv2.ucloud.cn") cmd.Flags().SetFlagValues("charge-type", "Month", "Year", "Dynamic", "Trial") cmd.Flags().SetFlagValues("cpu", "1", "2", "4", "8", "12", "16", "24", "32") @@ -265,37 +267,7 @@ func NewCmdUHostCreate() *cobra.Command { cmd.Flags().SetFlagValues("create-eip-charge-mode", "Bandwidth", "Traffic", "ShareBandwidth") cmd.Flags().SetFlagValuesFunc("image-id", func() []string { - req := base.BizClient.NewDescribeImageRequest() - projectID, _ := flags.GetString("project-id") - if projectID == "" { - projectID = base.ConfigInstance.ProjectID - } - req.ProjectId = sdk.String(projectID) - - region, _ := flags.GetString("region") - if region == "" { - region = base.ConfigInstance.Region - } - req.Region = sdk.String(region) - - zone, _ := flags.GetString("zone") - if zone == "" { - zone = base.ConfigInstance.Zone - } - req.Zone = sdk.String(zone) - req.ImageType = sdk.String("Base") - req.Limit = sdk.Int(1000) - result := make([]string, 0) - resp, err := base.BizClient.DescribeImage(req) - if err == nil { - for _, image := range resp.ImageSet { - if image.State == "Available" { - imageName := strings.Replace(image.ImageName, " ", "-", -1) - result = append(result, fmt.Sprintf("%s/%s", image.ImageId, imageName)) - } - } - } - return result + return getImageList([]string{status.IMAGE_AVAILABLE}, cli.IMAGE_BASE, *req.ProjectId, *req.Region, *req.Zone) }) cmd.MarkFlagRequired("cpu") @@ -307,7 +279,7 @@ func NewCmdUHostCreate() *cobra.Command { } //NewCmdUHostDelete ucloud uhost delete -func NewCmdUHostDelete() *cobra.Command { +func NewCmdUHostDelete(out io.Writer) *cobra.Command { var uhostIDs *[]string var isDestory = sdk.Bool(false) var yes *bool @@ -319,7 +291,7 @@ func NewCmdUHostDelete() *cobra.Command { Long: "Delete Uhost instance", Run: func(cmd *cobra.Command, args []string) { if !*yes { - sure, err := ux.Prompt("Are you sure you want to delete this host?") + sure, err := ux.Prompt("Are you sure you want to delete the host(s)?") if err != nil { base.Cxt.Println(err) return @@ -347,20 +319,20 @@ func NewCmdUHostDelete() *cobra.Command { _req.Region = req.Region _req.Zone = req.Zone _req.UHostId = req.UHostId - stopUhostIns(_req, false) + stopUhostIns(_req, false, out) } } resp, err := base.BizClient.TerminateUHostInstance(req) if err != nil { base.HandleError(err) } else { - base.Cxt.Printf("UHost:[%v] deleted\n", resp.UHostId) + base.Cxt.Printf("uhost:[%s] deleted\n", resp.UHostId) } } }, } cmd.Flags().SortFlags = false - uhostIDs = cmd.Flags().StringSlice("resource-id", nil, "Requried. ResourceIDs(UhostIds) of the uhost instance") + uhostIDs = cmd.Flags().StringSlice("uhost-id", nil, "Requried. ResourceIDs(UhostIds) of the uhost instance") req.ProjectId = cmd.Flags().String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") req.Region = cmd.Flags().String("region", base.ConfigInstance.Region, "Optional. Assign region") req.Zone = cmd.Flags().String("zone", "", "Optional. availability zone") @@ -371,16 +343,16 @@ func NewCmdUHostDelete() *cobra.Command { cmd.Flags().SetFlagValues("destory", "true", "false") cmd.Flags().SetFlagValues("release-eip", "true", "false") cmd.Flags().SetFlagValues("delete-cloud-disk", "true", "false") - cmd.Flags().SetFlagValuesFunc("resource-id", func() []string { + 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) }) - cmd.MarkFlagRequired("resource-id") + cmd.MarkFlagRequired("uhost-id") return cmd } //NewCmdUHostStop ucloud uhost stop -func NewCmdUHostStop() *cobra.Command { +func NewCmdUHostStop(out io.Writer) *cobra.Command { var uhostIDs *[]string var async *bool req := base.BizClient.NewStopUHostInstanceRequest() @@ -388,48 +360,46 @@ func NewCmdUHostStop() *cobra.Command { Use: "stop", Short: "Shut down uhost instance", Long: "Shut down uhost instance", - Example: "ucloud uhost stop --resource-id uhost-xxx1,uhost-xxx2", + Example: "ucloud uhost stop --uhost-id uhost-xxx1,uhost-xxx2", Run: func(cmd *cobra.Command, args []string) { for _, id := range *uhostIDs { id = base.PickResourceID(id) req.UHostId = &id - stopUhostIns(req, *async) + stopUhostIns(req, *async, out) } }, } cmd.Flags().SortFlags = false - uhostIDs = cmd.Flags().StringSlice("resource-id", nil, "Required. ResourceIDs(UHostIds) of the uhost instances") + uhostIDs = cmd.Flags().StringSlice("uhost-id", nil, "Required. ResourceIDs(UHostIds) of the uhost instances") req.ProjectId = cmd.Flags().String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") req.Region = cmd.Flags().String("region", base.ConfigInstance.Region, "Optional. Assign region") req.Zone = cmd.Flags().String("zone", "", "Optional. Assign availability zone") async = cmd.Flags().Bool("async", false, "Optional. Do not wait for the long-running operation to finish.") - cmd.Flags().SetFlagValuesFunc("resource-id", func() []string { + cmd.Flags().SetFlagValuesFunc("uhost-id", func() []string { return getUhostList([]string{status.HOST_RUNNING}, *req.ProjectId, *req.Region, *req.Zone) }) - cmd.MarkFlagRequired("resource-id") + cmd.MarkFlagRequired("uhost-id") return cmd } -func stopUhostIns(req *uhost.StopUHostInstanceRequest, async bool) { +func stopUhostIns(req *uhost.StopUHostInstanceRequest, async bool, out io.Writer) { resp, err := base.BizClient.StopUHostInstance(req) 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 { - base.Cxt.Println(text) + fmt.Fprintln(out, text) } else { - done := pollUhost(resp.UhostId, *req.ProjectId, *req.Region, *req.Zone, []string{status.HOST_STOPPED, status.HOST_FAIL}) - ux.DotSpinner.Start(text) - <-done - ux.DotSpinner.Stop() + poller := base.NewPoller(describeUHostByID, out) + poller.Poll(resp.UhostId, *req.ProjectId, *req.Region, *req.Zone, text, []string{status.HOST_STOPPED, status.HOST_FAIL}) } } } //NewCmdUHostStart ucloud uhost start -func NewCmdUHostStart() *cobra.Command { +func NewCmdUHostStart(out io.Writer) *cobra.Command { var async *bool var uhostIDs *[]string req := base.BizClient.NewStartUHostInstanceRequest() @@ -437,7 +407,7 @@ func NewCmdUHostStart() *cobra.Command { Use: "start", Short: "Start Uhost instance", Long: "Start Uhost instance", - Example: "ucloud uhost start --resource-id uhost-xxx1,uhost-xxx2", + Example: "ucloud uhost start --uhost-id uhost-xxx1,uhost-xxx2", Run: func(cmd *cobra.Command, args []string) { for _, id := range *uhostIDs { id := base.PickResourceID(id) @@ -446,36 +416,32 @@ func NewCmdUHostStart() *cobra.Command { if err != nil { base.HandleError(err) } else { - text := fmt.Sprintf("UHost:[%v] is starting", resp.UhostId) + text := fmt.Sprintf("uhost:[%v] is starting", resp.UhostId) if *async { - base.Cxt.Println(text) + fmt.Fprintln(out, text) } else { - done := pollUhost(resp.UhostId, *req.ProjectId, *req.Region, *req.Zone, []string{status.HOST_RUNNING, status.HOST_FAIL}) - dotSpinner := ux.NewDotSpinner() - dotSpinner.Start(text) - <-done - dotSpinner.Stop() + poller := base.NewPoller(describeUHostByID, out) + poller.Poll(resp.UhostId, *req.ProjectId, *req.Region, *req.Zone, text, []string{status.HOST_RUNNING, status.HOST_FAIL}) } } } }, } cmd.Flags().SortFlags = false - uhostIDs = cmd.Flags().StringSlice("resource-id", nil, "Requried. ResourceIDs(UHostIds) of the uhost instance") + uhostIDs = cmd.Flags().StringSlice("uhost-id", nil, "Requried. ResourceIDs(UHostIds) of the uhost instance") req.ProjectId = cmd.Flags().String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") req.Region = cmd.Flags().String("region", base.ConfigInstance.Region, "Optional. Assign region") req.Zone = cmd.Flags().String("zone", "", "Optional. Assign availability zone") - req.DiskPassword = cmd.Flags().String("disk-password", "", "Optional. Encrypted disk password") async = cmd.Flags().Bool("async", false, "Optional. Do not wait for the long-running operation to finish.") - cmd.Flags().SetFlagValuesFunc("resource-id", func() []string { + cmd.Flags().SetFlagValuesFunc("uhost-id", func() []string { return getUhostList([]string{status.HOST_STOPPED}, *req.ProjectId, *req.Region, *req.Zone) }) - cmd.MarkFlagRequired("resource-id") + cmd.MarkFlagRequired("uhost-id") return cmd } //NewCmdUHostReboot ucloud uhost restart -func NewCmdUHostReboot() *cobra.Command { +func NewCmdUHostReboot(out io.Writer) *cobra.Command { var uhostIDs *[]string var async *bool req := base.BizClient.NewRebootUHostInstanceRequest() @@ -483,7 +449,7 @@ func NewCmdUHostReboot() *cobra.Command { Use: "restart", Short: "Restart uhost instance", Long: "Restart uhost instance", - Example: "ucloud uhost restart --resource-id uhost-xxx1,uhost-xxx2", + Example: "ucloud uhost restart --uhost-id uhost-xxx1,uhost-xxx2", Run: func(cmd *cobra.Command, args []string) { for _, id := range *uhostIDs { id = base.PickResourceID(id) @@ -494,28 +460,26 @@ func NewCmdUHostReboot() *cobra.Command { } else { text := fmt.Sprintf("UHost:[%v] is restarting", resp.UhostId) if *async { - base.Cxt.Println(text) + fmt.Fprintln(out, text) } else { - done := pollUhost(resp.UhostId, *req.ProjectId, *req.Region, *req.Zone, []string{status.HOST_RUNNING, status.HOST_FAIL}) - ux.DotSpinner.Start(text) - <-done - ux.DotSpinner.Stop() + poller := base.NewPoller(describeUHostByID, out) + poller.Poll(resp.UhostId, *req.ProjectId, *req.Region, *req.Zone, text, []string{status.HOST_RUNNING, status.HOST_FAIL}) } } } }, } cmd.Flags().SortFlags = false - uhostIDs = cmd.Flags().StringSlice("resource-id", nil, "Required. ResourceIDs(UHostIds) of the uhost instance") + uhostIDs = cmd.Flags().StringSlice("uhost-id", nil, "Required. ResourceIDs(UHostIds) of the uhost instance") req.ProjectId = cmd.Flags().String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") req.Region = cmd.Flags().String("region", base.ConfigInstance.Region, "Optional. Assign region") req.Zone = cmd.Flags().String("zone", "", "Optional. Assign availability zone") req.DiskPassword = cmd.Flags().String("disk-password", "", "Optional. Encrypted disk password") async = cmd.Flags().Bool("async", false, "Optional. Do not wait for the long-running operation to finish.") - cmd.Flags().SetFlagValuesFunc("resource-id", func() []string { + cmd.Flags().SetFlagValuesFunc("uhost-id", func() []string { return getUhostList([]string{status.HOST_FAIL, status.HOST_RUNNING, status.HOST_STOPPED}, *req.ProjectId, *req.Region, *req.Zone) }) - cmd.MarkFlagRequired("resource-id") + cmd.MarkFlagRequired("uhost-id") return cmd } @@ -528,7 +492,7 @@ func NewCmdUHostPoweroff() *cobra.Command { Use: "poweroff", Short: "Analog power off Uhost instnace", Long: "Analog power off Uhost instnace", - Example: "ucloud uhost poweroff --resource-id uhost-xxx1,uhost-xxx2", + Example: "ucloud uhost poweroff --uhost-id uhost-xxx1,uhost-xxx2", Run: func(cmd *cobra.Command, args []string) { if !*yes { confirmText := "Danger, it may affect data integrity. Are you sure you want to poweroff this uhost?" @@ -557,25 +521,25 @@ func NewCmdUHostPoweroff() *cobra.Command { }, } cmd.Flags().SortFlags = false - uhostIDs = cmd.Flags().StringSlice("resource-id", nil, "ResourceIDs(UHostIds) of the uhost instance") + uhostIDs = cmd.Flags().StringSlice("uhost-id", nil, "ResourceIDs(UHostIds) of the uhost instance") req.ProjectId = cmd.Flags().String("project-id", base.ConfigInstance.ProjectID, "Assign project-id") req.Region = cmd.Flags().String("region", base.ConfigInstance.Region, "Assign region") req.Zone = cmd.Flags().String("zone", "", "Assign availability zone") yes = cmd.Flags().BoolP("yes", "y", false, "Optional. Do not prompt for confirmation.") - cmd.MarkFlagRequired("resource-id") + cmd.MarkFlagRequired("uhost-id") return cmd } //NewCmdUHostResize ucloud uhost resize -func NewCmdUHostResize() *cobra.Command { - var yes *bool +func NewCmdUHostResize(out io.Writer) *cobra.Command { + var yes, async *bool var uhostIDs *[]string req := base.BizClient.NewResizeUHostInstanceRequest() cmd := &cobra.Command{ Use: "resize", Short: "Resize uhost instance,such as cpu core count, memory size and disk size", Long: "Resize uhost instance,such as cpu core count, memory size and disk size", - Example: "ucloud uhost resize --resource-id uhost-xxx1,uhost-xxx2 --cpu 4 --memory-gb 8", + Example: "ucloud uhost resize --uhost-id uhost-xxx1,uhost-xxx2 --cpu 4 --memory-gb 8", Run: func(cmd *cobra.Command, args []string) { if *req.CPU == 0 { req.CPU = nil @@ -620,20 +584,26 @@ func NewCmdUHostResize() *cobra.Command { _req.Region = req.Region _req.Zone = req.Zone _req.UHostId = &id - stopUhostIns(_req, false) + stopUhostIns(_req, false, out) } resp, err := base.BizClient.ResizeUHostInstance(req) if err != nil { base.HandleError(err) } else { - base.Cxt.Printf("UHost:[%v] resized\n", resp.UhostId) + text := fmt.Sprintf("UHost:[%v] resized", resp.UhostId) + if *async { + fmt.Fprintln(out, text) + } else { + poller := base.NewPoller(describeUHostByID, out) + poller.Poll(resp.UhostId, *req.ProjectId, *req.Region, *req.Zone, text, []string{status.HOST_RUNNING, status.HOST_STOPPED, status.HOST_FAIL}) + } } } }, } cmd.Flags().SortFlags = false - uhostIDs = cmd.Flags().StringSlice("resource-id", nil, "Required. ResourceIDs(or UhostIDs) of the uhost instances") + uhostIDs = cmd.Flags().StringSlice("uhost-id", nil, "Required. ResourceIDs(or UhostIDs) of the uhost instances") req.ProjectId = cmd.Flags().String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") req.Region = cmd.Flags().String("region", base.ConfigInstance.Region, "Optional. Assign region") req.Zone = cmd.Flags().String("zone", "", "Optional. Assign availability zone") @@ -643,15 +613,14 @@ func NewCmdUHostResize() *cobra.Command { req.BootDiskSpace = cmd.Flags().Int("system-disk-size-gb", 0, "Optional. System disk size, unit GB. Range[20,100]. Step 10. System disk does not support shrinkage") req.NetCapValue = cmd.Flags().Int("net-cap", 0, "Optional. NIC scale. 1,upgrade; 2,downgrade; 0,unchanged") yes = cmd.Flags().BoolP("yes", "y", false, "Optional. Do not prompt for confirmation.") - cmd.Flags().SetFlagValuesFunc("resource-id", func() []string { + async = cmd.Flags().BoolP("async", "a", false, "Optional. Do not wait for the long-running operation to finish.") + cmd.Flags().SetFlagValuesFunc("uhost-id", func() []string { return getUhostList([]string{status.HOST_RUNNING, status.HOST_STOPPED, status.HOST_FAIL}, *req.ProjectId, *req.Region, *req.Zone) }) - cmd.MarkFlagRequired("resource-id") + cmd.MarkFlagRequired("uhost-id") return cmd } -var pollUhost = base.Poll(describeUHostByID) - func describeUHostByID(uhostID, projectID, region, zone string) (interface{}, error) { req := base.BizClient.NewDescribeUHostInstanceRequest() req.UHostIds = []string{uhostID} @@ -691,3 +660,328 @@ func getUhostList(states []string, project, region, zone string) []string { } return list } + +//NewCmdUHostClone ucloud uhost clone +func NewCmdUHostClone(out io.Writer) *cobra.Command { + var uhostID *string + var async *bool + req := base.BizClient.NewCreateUHostInstanceRequest() + cmd := &cobra.Command{ + Use: "clone", + Short: "Create an uhost with the same configuration as another uhost", + Long: "Create an uhost with the same configuration as another uhost, excluding bound eip and udisk", + Run: func(com *cobra.Command, args []string) { + *uhostID = base.PickResourceID(*uhostID) + queryReq := base.BizClient.NewDescribeUHostInstanceRequest() + queryReq.ProjectId = req.ProjectId + queryReq.Region = req.Region + queryReq.Zone = req.Zone + queryReq.UHostIds = []string{*uhostID} + queryResp, err := base.BizClient.DescribeUHostInstance(queryReq) + if err != nil { + base.HandleError(err) + return + } + if len(queryResp.UHostSet) < 1 { + base.Cxt.PrintErr(fmt.Errorf("uhost[%s] not exist", *uhostID)) + return + } + queryFirewallReq := base.BizClient.NewDescribeFirewallRequest() + queryFirewallReq.ProjectId = req.ProjectId + queryFirewallReq.Region = req.Region + queryFirewallReq.ResourceId = uhostID + queryFirewallReq.ResourceType = sdk.String("uhost") + + firewallResp, err := base.BizClient.DescribeFirewall(queryFirewallReq) + if err != nil { + base.HandleError(err) + return + } + + if len(firewallResp.DataSet) == 1 { + req.SecurityGroupId = &firewallResp.DataSet[0].FWId + } + + uhostIns := queryResp.UHostSet[0] + + req.ImageId = &uhostIns.BasicImageId + req.CPU = &uhostIns.CPU + req.Memory = &uhostIns.Memory + for _, ip := range uhostIns.IPSet { + if ip.Type == "Private" { + req.VPCId = &ip.VPCId + req.SubnetId = &ip.SubnetId + } + } + req.ChargeType = &uhostIns.ChargeType + req.UHostType = &uhostIns.UHostType + req.NetCapability = &uhostIns.NetCapability + + for index := 0; index < 2; index++ { + disk := uhostIns.DiskSet[index] + item := uhost.UHostDisk{ + Size: sdk.Int(disk.Size), + Type: sdk.String(disk.DiskType), + IsBoot: sdk.String(disk.IsBoot), + } + if disk.BackupType != "" { + item.BackupType = sdk.String(disk.BackupType) + } + req.Disks = append(req.Disks, item) + } + req.Tag = &uhostIns.Tag + req.LoginMode = sdk.String("Password") + resp, err := base.BizClient.CreateUHostInstance(req) + if err != nil { + base.HandleError(err) + return + } + if len(resp.UHostIds) == 1 { + text := fmt.Sprintf("cloned uhost:[%s] is initializing", resp.UHostIds[0]) + if *async { + fmt.Fprintln(out, text) + } else { + poller := base.NewPoller(describeUHostByID, out) + poller.Poll(resp.UHostIds[0], *req.ProjectId, *req.Region, *req.Zone, text, []string{status.HOST_RUNNING, status.HOST_FAIL}) + } + } else { + base.HandleError(fmt.Errorf("expect uhost count 1, accept %d", len(resp.UHostIds))) + return + } + }, + } + flags := cmd.Flags() + flags.SortFlags = false + uhostID = flags.String("uhost-id", "", "Required. Resource ID of the uhost to clone from") + req.Password = flags.String("password", "", "Required. Password of the uhost user(root/ubuntu)") + req.Name = flags.String("name", "", "Optional. Name of the uhost to clone") + req.ProjectId = flags.String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") + req.Region = flags.String("region", base.ConfigInstance.Region, "Optional. Assign region") + req.Zone = flags.String("zone", base.ConfigInstance.Zone, "Optional. Assign availability zone") + async = flags.Bool("async", false, "Optional. Do not wait for the long-running operation to finish.") + flags.SetFlagValuesFunc("uhost-id", func() []string { + return getUhostList([]string{status.HOST_RUNNING, status.HOST_STOPPED}, *req.ProjectId, *req.Region, *req.Zone) + }) + cmd.MarkFlagRequired("uhost-id") + cmd.MarkFlagRequired("password") + return cmd +} + +//NewCmdUhostCreateImage ucloud uhost create-image +func NewCmdUhostCreateImage(out io.Writer) *cobra.Command { + var async *bool + req := base.BizClient.NewCreateCustomImageRequest() + cmd := &cobra.Command{ + Use: "create-image", + Short: "Create image from an uhost instance", + Long: "Create image from an uhost instance", + Run: func(cmd *cobra.Command, args []string) { + req.UHostId = sdk.String(base.PickResourceID(*req.UHostId)) + resp, err := base.BizClient.CreateCustomImage(req) + if err != nil { + base.HandleError(err) + return + } + text := fmt.Sprintf("iamge[%s] is making", resp.ImageId) + if *async { + fmt.Fprintln(out, text) + } else { + poller := base.NewPoller(describeImageByID, out) + poller.Poll(resp.ImageId, *req.ProjectId, *req.Region, *req.Zone, text, []string{status.IMAGE_AVAILABLE, status.IMAGE_UNAVAILABLE}) + } + }, + } + flags := cmd.Flags() + flags.SortFlags = false + + req.UHostId = flags.String("uhost-id", "", "Resource ID of uhost to create image from") + req.ImageName = flags.String("image-name", "", "Required. Name of the image to create") + req.ImageDescription = flags.String("image-desc", "", "Optional. Description of the image to create") + req.ProjectId = flags.String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") + req.Region = flags.String("region", base.ConfigInstance.Region, "Optional. Assign region") + req.Zone = flags.String("zone", base.ConfigInstance.Zone, "Optional. Assign availability zone") + async = flags.BoolP("async", "a", false, "Optional. Do not wait for the long-running operation to finish.") + + flags.SetFlagValuesFunc("uhost-id", func() []string { + return getUhostList([]string{status.HOST_RUNNING, status.HOST_STOPPED}, *req.ProjectId, *req.Region, *req.Zone) + }) + + cmd.MarkFlagRequired("uhost-id") + cmd.MarkFlagRequired("image-name") + return cmd +} + +//NewCmdUhostResetPassword ucloud uhost reset-password +func NewCmdUhostResetPassword(out io.Writer) *cobra.Command { + var yes *bool + var uhostIDs *[]string + req := base.BizClient.NewResetUHostInstancePasswordRequest() + cmd := &cobra.Command{ + Use: "reset-password", + Short: "Reset the administrator password for the UHost instances.", + Long: "Reset the administrator password for the UHost instances.", + Run: func(cmd *cobra.Command, args []string) { + for _, id := range *uhostIDs { + id = base.PickResourceID(id) + req.UHostId = &id + err := checkAndCloseUhost(*yes, false, id, *req.ProjectId, *req.Region, *req.Zone, out) + if err != nil { + base.Cxt.Println(err) + continue + } + host, err := describeUHostByID(id, *req.ProjectId, *req.Region, *req.Zone) + inst, ok := host.(*uhost.UHostInstanceSet) + if !ok { + return + } + if inst.BootDiskState == "Initializing" { + fmt.Fprintf(out, "uhost[%s] boot disk in initializing, wait 10 minutes\n", id) + return + } + resp, err := base.BizClient.ResetUHostInstancePassword(req) + if err != nil { + base.HandleError(err) + return + } + fmt.Fprintf(out, "uhost[%s] reset password\n", resp.UhostId) + } + }, + } + flags := cmd.Flags() + flags.SortFlags = false + + uhostIDs = flags.StringSlice("uhost-id", nil, "Required. Resource IDs of the uhosts to reset the administrator's password") + req.Password = flags.String("password", "", "Required. New Password") + req.ProjectId = flags.String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") + req.Region = flags.String("region", base.ConfigInstance.Region, "Optional. Assign region") + req.Zone = flags.String("zone", base.ConfigInstance.Zone, "Optional. Assign availability zone") + yes = cmd.Flags().BoolP("yes", "y", false, "Optional. Do not prompt for confirmation.") + flags.SetFlagValuesFunc("uhost-id", func() []string { + return getUhostList([]string{status.HOST_RUNNING, status.HOST_STOPPED}, *req.ProjectId, *req.Region, *req.Zone) + }) + cmd.MarkFlagRequired("uhost-id") + cmd.MarkFlagRequired("password") + return cmd +} + +func checkAndCloseUhost(yes, async bool, uhostID, project, region, zone string, out io.Writer) error { + host, err := describeUHostByID(uhostID, project, region, zone) + if err != nil { + return err + } + inst, ok := host.(*uhost.UHostInstanceSet) + if ok { + if inst.State == "Running" { + if !yes { + confirmText := fmt.Sprintf("uhost[%s] will be stopped, can we do this?", uhostID) + agreeClose, err := ux.Prompt(confirmText) + if err != nil { + return err + } + if !agreeClose { + return fmt.Errorf("skip, you do not agree to stop uhost") + } + } + _req := base.BizClient.NewStopUHostInstanceRequest() + _req.ProjectId = &project + _req.Region = ®ion + _req.Zone = &zone + _req.UHostId = &uhostID + stopUhostIns(_req, async, out) + } + } else { + return fmt.Errorf("Something wrong, uhost[%s] may not exist", uhostID) + } + return nil +} + +//NewCmdUhostReinstallOS ucloud uhost reinstall-os +func NewCmdUhostReinstallOS(out io.Writer) *cobra.Command { + var isReserveDataDisk, yes, async *bool + req := base.BizClient.NewReinstallUHostInstanceRequest() + cmd := &cobra.Command{ + Use: "reinstall-os", + Short: "Reinstall the operating system of the UHost instance", + Long: "Reinstall the operating system of the UHost instance. we will detach all udisk disks if the uhost attached some, and then stop the uhost if it's running", + Run: func(cmd *cobra.Command, args []string) { + if *isReserveDataDisk { + req.ReserveDisk = sdk.String("Yes") + } else { + req.ReserveDisk = sdk.String("No") + } + req.UHostId = sdk.String(base.PickResourceID(*req.UHostId)) + req.Password = sdk.String(base64.StdEncoding.EncodeToString([]byte(sdk.StringValue(req.Password)))) + + any, err := describeUHostByID(*req.UHostId, *req.ProjectId, *req.Region, *req.Zone) + if err != nil { + base.Cxt.Println(err) + return + } + uhostIns, ok := any.(*uhost.UHostInstanceSet) + if ok { + for _, disk := range uhostIns.DiskSet { + if disk.Type == "Udisk" { + sure := false + if !*yes { + text := fmt.Sprintf("udisk[%s/%s] will be detached, can we do this?", disk.DiskId, disk.Name) + sure, err = ux.Prompt(text) + if err != nil { + base.Cxt.PrintErr(err) + return + } + if !sure { + base.Cxt.Printf("you don't agree to detach udisk\n") + return + } + } + if *yes || sure { + err := detachUdisk(false, disk.DiskId, out) + if err != nil { + base.Cxt.Println(err) + return + } + } + } + } + } else { + base.Cxt.Printf("Something wrong, uhost[%s] may not exist\n", *req.UHostId) + return + } + + err = checkAndCloseUhost(*yes, *async, *req.UHostId, *req.ProjectId, *req.Region, *req.Zone, out) + if err != nil { + base.Cxt.Println(err) + return + } + resp, err := base.BizClient.ReinstallUHostInstance(req) + if err != nil { + base.Cxt.Println(err) + return + } + text := fmt.Sprintf("uhost[%s] is reinstalling OS", *req.UHostId) + if *async { + fmt.Fprintln(out, text) + } else { + poller := base.NewPoller(describeUHostByID, out) + poller.Poll(resp.UhostId, *req.ProjectId, *req.Region, *req.Zone, text, []string{status.HOST_RUNNING, status.HOST_FAIL}) + } + }, + } + flags := cmd.Flags() + flags.SortFlags = false + req.UHostId = flags.String("uhost-id", "", "Required. Resource ID of the uhost to reinstall operating system") + req.Password = flags.String("password", "", "Required. Password of the administrator") + req.ImageId = flags.String("image-id", "", "Optional. Resource ID the image to install. See 'ucloud image list'. Default is original image of the uhost") + req.ProjectId = flags.String("project-id", base.ConfigInstance.ProjectID, "Optional. Assign project-id") + req.Region = flags.String("region", base.ConfigInstance.Region, "Optional. Assign region") + req.Zone = flags.String("zone", base.ConfigInstance.Zone, "Optional. Assign availability zone") + isReserveDataDisk = flags.Bool("keep-data-disk", false, "Keep data disk or not. If you keep data disk, you can't change OS type(Linux->Window,e.g.)") + yes = cmd.Flags().BoolP("yes", "y", false, "Optional. Do not prompt for confirmation.") + async = flags.BoolP("async", "a", false, "Optional. Do not wait for the long-running operation to finish.") + flags.SetFlagValuesFunc("uhost-id", func() []string { + return getUhostList([]string{status.HOST_RUNNING, status.HOST_STOPPED}, *req.ProjectId, *req.Region, *req.Zone) + }) + cmd.MarkFlagRequired("uhost-id") + cmd.MarkFlagRequired("password") + return cmd +} diff --git a/cmd/uhost_test.go b/cmd/uhost_test.go index 1c930a9daa..2f7c2469c0 100644 --- a/cmd/uhost_test.go +++ b/cmd/uhost_test.go @@ -1,6 +1,10 @@ package cmd import ( + "bytes" + "fmt" + "regexp" + "strings" "testing" ) @@ -11,13 +15,70 @@ type listUhostTest struct { func (test listUhostTest) run(t *testing.T) { cmd := NewCmdUHostList() - cmd.SetArgs([]string{"--project-id", "org-4nfe1i"}) if err := cmd.Execute(); err != nil { t.Fatalf("unexpected error executing command:%v", err) } } -func TestListUhost(t *testing.T) { - test := listUhostTest{} - test.run(t) +type createUHostTest struct { + flags []string + uhostIds []string + expectedOutRegexp *regexp.Regexp +} + +func (test createUHostTest) run(t *testing.T) { + buf := bytes.NewBuffer([]byte{}) + cmd := NewCmdUHostCreate(buf) + cmd.Flags().Parse(test.flags) + if err := cmd.Execute(); err != nil { + t.Fatalf("unexpected error executing command: %v, flags: %v", err, test.flags) + } + list := test.expectedOutRegexp.FindStringSubmatch(buf.String()) + if list == nil { + t.Errorf("unexpect output:%s", buf.String()) + } else { + if len(list) == 2 { + test.uhostIds = append(test.uhostIds, list[1]) + } + } +} + +type deleteUHostTest struct { + flags []string + uhostIds []string + expectedOutRegexp *regexp.Regexp +} + +func (test deleteUHostTest) run(t *testing.T) { + buf := bytes.NewBuffer([]byte{}) + cmd := NewCmdUHostDelete(buf) + cmd.Flags().Parse(test.flags) + if err := cmd.Execute(); err != nil { + t.Fatalf("unexpected error executing command: %v, flags: %v", err, test.flags) + } + list := test.expectedOutRegexp.FindStringSubmatch(buf.String()) + if list == nil { + t.Errorf("unexpect output:%s", buf.String()) + } +} + +func TestCreateUhost(t *testing.T) { + createT := createUHostTest{ + expectedOutRegexp: regexp.MustCompile(`uhost\[([\w-]+)\] is initializing...done`), + flags: []string{ + "--cpu=1", + "--memory-gb=1", + "--image-id=uimage-aaee5e", + "--password=test.lxj", + }, + } + createT.run(t) + + deleteT := deleteUHostTest{ + uhostIds: createT.uhostIds, + expectedOutRegexp: regexp.MustCompile(`uhost:\[[w-]+\] deleted`), + flags: []string{"--yes"}, + } + deleteT.flags = append(deleteT.flags, fmt.Sprintf("--uhost-id=%s", strings.Join(deleteT.uhostIds, ","))) + deleteT.run(t) } diff --git a/model/cli/cli_const.go b/model/cli/cli_const.go new file mode 100644 index 0000000000..7004649a01 --- /dev/null +++ b/model/cli/cli_const.go @@ -0,0 +1,6 @@ +package cli + +const IMAGE_BASE = "Base" +const IMAGE_BUSINESS = "Business" +const IAMGE_CUSTOM = "Custom" +const IMAGE_ALL = "*" diff --git a/model/context.go b/model/context.go index d02076e84f..5de2d03d9d 100644 --- a/model/context.go +++ b/model/context.go @@ -48,6 +48,11 @@ func (c *Context) AppendInfo(key string, content interface{}) { c.data[key] = content } +//GetWriter 获取Writer +func (c *Context) GetWriter() io.Writer { + return c.writer +} + // GetContext 创建一个单例的Context func GetContext(writer io.Writer) *Context { once.Do(func() { diff --git a/model/status/status.go b/model/status/status.go index 34431a2fb2..5f78ed0162 100644 --- a/model/status/status.go +++ b/model/status/status.go @@ -4,6 +4,14 @@ const HOST_RUNNING = "Running" const HOST_STOPPED = "Stopped" const HOST_FAIL = "Install Fail" +const IMAGE_MAKING = "Making" +const IMAGE_AVAILABLE = "Available" +const IMAGE_UNAVAILABLE = "Unavailable" +const IMAGE_COPYING = "Copying" + const DISK_INUSE = "InUse" const DISK_AVAILABLE = "Available" const DISK_FAILED = "Failed" +const DISK_RESTORING = "Restoring" + +const SNAPSHOT_NORMAL = "Normal" diff --git a/ux/prompt.go b/ux/prompt.go index ba2a93cae2..045d38384b 100644 --- a/ux/prompt.go +++ b/ux/prompt.go @@ -3,8 +3,6 @@ package ux import ( "fmt" "strings" - - "github.com/ucloud/ucloud-cli/base" ) // Prompt confirm @@ -12,7 +10,7 @@ func Prompt(text string) (bool, error) { if !strings.HasSuffix(text, "(y/n):") { text += " (y/n):" } - base.Cxt.Printf(text) + fmt.Printf(text) var agreeClose string _, err := fmt.Scanf("%s\n", &agreeClose) if err != nil { diff --git a/ux/spinner.go b/ux/spinner.go index 0d268983af..eefabd0c95 100644 --- a/ux/spinner.go +++ b/ux/spinner.go @@ -4,6 +4,8 @@ package ux import ( "fmt" + "io" + "os" "time" "github.com/ucloud/ucloud-cli/ansi" @@ -11,15 +13,17 @@ import ( // Spinner type type Spinner struct { + out io.Writer frames []rune framesPerSecond int DoingText string DoneText string + TimeoutText string ticker *time.Ticker output string } -// Start start rendor +// Start start render func (s *Spinner) Start(doingText string) { if doingText != "" { s.DoingText = doingText @@ -28,12 +32,20 @@ func (s *Spinner) Start(doingText string) { s.render() } -// Stop stop rendor +// Stop stop render func (s *Spinner) Stop() { s.ticker.Stop() s.reset() output := fmt.Sprintf("%s...%s\n", s.DoingText, s.DoneText) - fmt.Printf(output) + fmt.Fprintf(s.out, output) +} + +// Timeout stop render +func (s *Spinner) Timeout() { + s.ticker.Stop() + s.reset() + output := fmt.Sprintf("%s...%s\n", s.DoingText, s.TimeoutText) + fmt.Fprintf(s.out, output) } func (s *Spinner) reset() { @@ -69,9 +81,16 @@ func (s *Spinner) newFrameFactory() func() rune { var spinnerFrames = []rune{'⣾', '⣽', '⣻', '⢿', '⡿', '⣟', '⣯', '⣷'} // DotSpinner dot spinner -var DotSpinner = &Spinner{frames: spinnerFrames, framesPerSecond: 12, DoingText: "running", DoneText: "done"} +var DotSpinner = NewDotSpinner(os.Stdout) //NewDotSpinner get new DotSpinner instance -func NewDotSpinner() *Spinner { - return &Spinner{frames: spinnerFrames, framesPerSecond: 12, DoingText: "running", DoneText: "done"} +func NewDotSpinner(out io.Writer) *Spinner { + return &Spinner{ + out: out, + frames: spinnerFrames, + framesPerSecond: 12, + DoingText: "running", + DoneText: "done", + TimeoutText: "timeout", + } } diff --git a/vendor/github.com/spf13/cobra/command.go b/vendor/github.com/spf13/cobra/command.go index c7b309715c..f5c1870444 100644 --- a/vendor/github.com/spf13/cobra/command.go +++ b/vendor/github.com/spf13/cobra/command.go @@ -1000,7 +1000,8 @@ func (c *Command) complete() error { } currentWord := string(chars[lastSpaceIndex+1 : p]) args := strings.Fields(compLine)[1:] - compCmd, _, err := c.Root().Find(args) + compCmd, flags, err := c.Root().Find(args) + compCmd.ParseFlags(flags) if err != nil { compCmd = c } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/LICENSE b/vendor/github.com/ucloud/ucloud-sdk-go/LICENSE new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. 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 899602ad9b..c2d0714b12 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 @@ -10,4 +10,5 @@ var DefaultHeaders = map[string]string{ // "X-SDK-VERSION": VERSION, } +// DefaultTimeout is the default timeout of each request var DefaultTimeout = 30 * time.Second 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 6cb5b10e89..2a2a0fc11d 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 @@ -11,8 +11,9 @@ import ( "github.com/ucloud/ucloud-sdk-go/private/utils" ) -var avaliableHTTPMethods = []string{"GET", "POST", "PUT", "DELETE", "OPTION", "HEAD", "PATCH"} +var availableHTTPMethods = []string{"GET", "POST", "PUT", "DELETE", "OPTION", "HEAD", "PATCH"} +// HttpRequest is the internal http request of sdk, don't use it at your code type HttpRequest struct { url string method string @@ -61,7 +62,7 @@ func (h *HttpRequest) GetURL() string { // SetMethod will set method of current request func (h *HttpRequest) SetMethod(val string) error { - err := utils.CheckStringIn(val, avaliableHTTPMethods) + err := utils.CheckStringIn(val, availableHTTPMethods) if err != nil { return errors.Errorf("method is invalid, %s", err) } @@ -104,7 +105,7 @@ func (h *HttpRequest) BuildQueryString() (string, error) { } // if query string is not set by user, - // otherwise needn't keep them ordered, encode immediatly. + // otherwise needn't keep them ordered, encode immediately. if h.queryString == "" { return values.Encode(), nil } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/client.go similarity index 60% rename from vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/client.go rename to vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/client.go index 648a2b1f90..f0ae4c4737 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/client.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/client.go @@ -1,17 +1,19 @@ -package ulb +package udisk import ( "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) -type ULBClient struct { +// UDiskClient is the client of UDisk +type UDiskClient struct { client *ucloud.Client } -func NewClient(config *ucloud.Config, credential *auth.Credential) *ULBClient { +// NewClient will return a instance of UDiskClient +func NewClient(config *ucloud.Config, credential *auth.Credential) *UDiskClient { client := ucloud.NewClient(config, credential) - return &ULBClient{ + return &UDiskClient{ client: client, } } 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 new file mode 100644 index 0000000000..d6d72e2fe3 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/delete_udisk_snapshot.go @@ -0,0 +1,53 @@ +//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 new file mode 100644 index 0000000000..f0d8dcdc19 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/describe_udisk_snapshot.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 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 new file mode 100644 index 0000000000..6ca32072a4 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/udisk/types_udisk_snapshot_set.go @@ -0,0 +1,49 @@ +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/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/client.go new file mode 100644 index 0000000000..c1792b7ab0 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/client.go @@ -0,0 +1,19 @@ +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud" + "github.com/ucloud/ucloud-sdk-go/ucloud/auth" +) + +// UHostClient is the client of UHost +type UHostClient struct { + client *ucloud.Client +} + +// NewClient will return a instance of UHostClient +func NewClient(config *ucloud.Config, credential *auth.Credential) *UHostClient { + client := ucloud.NewClient(config, credential) + return &UHostClient{ + client: client, + } +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/delete_snapshot.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/delete_snapshot.go new file mode 100644 index 0000000000..a4594818c6 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/delete_snapshot.go @@ -0,0 +1,53 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UHost DeleteSnapshot + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DeleteSnapshotRequest is request schema for DeleteSnapshot action +type DeleteSnapshotRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"true"` + + // 快照Id + SnapshotId *string `required:"true"` +} + +// DeleteSnapshotResponse is response schema for DeleteSnapshot action +type DeleteSnapshotResponse struct { + response.CommonBase + + // 快照Id + SnapshotId string +} + +// NewDeleteSnapshotRequest will create request of DeleteSnapshot action. +func (c *UHostClient) NewDeleteSnapshotRequest() *DeleteSnapshotRequest { + req := &DeleteSnapshotRequest{} + + // 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 +} + +// DeleteSnapshot - 删除快照 +func (c *UHostClient) DeleteSnapshot(req *DeleteSnapshotRequest) (*DeleteSnapshotResponse, error) { + var err error + var res DeleteSnapshotResponse + + err = c.client.InvokeAction("DeleteSnapshot", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/describe_snapshot.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/describe_snapshot.go new file mode 100644 index 0000000000..94985b35d4 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/describe_snapshot.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 UHost DescribeSnapshot + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// DescribeSnapshotRequest is request schema for DescribeSnapshot action +type DescribeSnapshotRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"true"` + + // 快照的资源ID,例如SnapshotIds.0代表希望获取信息的快照1,SnapshotIds.2代表快照2。 如果不传,则返回当前Region所有符合条件的快照。 + SnapshotIds []string `required:"false"` + + // 列表起始位置偏移量,默认为0 + Offset *int `required:"false"` + + // 返回数据长度,默认为20,最大10000000 + Limit *int `required:"false"` + + // 若传,则返回该主机下的所有快照 + UHostId *string `required:"false"` + + // 磁盘id,若磁盘传入,对应的UHostId必须一同传入 + DiskId *string `required:"false"` +} + +// DescribeSnapshotResponse is response schema for DescribeSnapshot action +type DescribeSnapshotResponse struct { + response.CommonBase + + // 满足条件的快照总数 + TotalCount int + + // 快照列表,每项参数可见下面SnapshotSet + UHostSnapshotSet []SnapshotSet + + // 总配额数 + TotalQuota int + + // 已使用的配额数 + TotalUsed int + + // 每块磁盘的快照配额 + PerDiskQuota int + + // 每块磁盘已经使用的配额数。如果不传DiskId,则返回0. + DiskUsed int +} + +// NewDescribeSnapshotRequest will create request of DescribeSnapshot action. +func (c *UHostClient) NewDescribeSnapshotRequest() *DescribeSnapshotRequest { + req := &DescribeSnapshotRequest{} + + // 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 +} + +// DescribeSnapshot - 拉取快照列表 +func (c *UHostClient) DescribeSnapshot(req *DescribeSnapshotRequest) (*DescribeSnapshotResponse, error) { + var err error + var res DescribeSnapshotResponse + + err = c.client.InvokeAction("DescribeSnapshot", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/restore_uhost_disk.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/restore_uhost_disk.go new file mode 100644 index 0000000000..557015a82c --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/restore_uhost_disk.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 UHost RestoreUHostDisk + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// RestoreUHostDiskRequest is request schema for RestoreUHostDisk action +type RestoreUHostDiskRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"true"` + + // 快照所属主机.仅当网盘数据盘未挂载时才可以不传。 + UHostId *string `required:"false"` + + // 主机上要恢复的磁盘Id. 对于本地盘主机,支持单独恢复系统盘或数据盘,也可以同时恢复系统盘和数据盘;对于网盘主机,只能恢复系统盘。从数据方舟恢复磁盘时必传。 + DiskIds []string `required:"false"` + + // 恢复的盘的时间戳,顺序与DiskIds.n保持对应。从数据方舟恢复磁盘时必传。 + RestoreTimestamps []string `required:"false"` + + // 快照Id. 对于本地盘主机,支持单独恢复系统盘或数据盘,也可以同时恢复系统盘和数据盘;对于网盘主机,只能恢复系统盘。从快照恢复磁盘时必传。 + SnapshotIds []string `required:"false"` +} + +// RestoreUHostDiskResponse is response schema for RestoreUHostDisk action +type RestoreUHostDiskResponse struct { + response.CommonBase +} + +// NewRestoreUHostDiskRequest will create request of RestoreUHostDisk action. +func (c *UHostClient) NewRestoreUHostDiskRequest() *RestoreUHostDiskRequest { + req := &RestoreUHostDiskRequest{} + + // 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 +} + +// RestoreUHostDisk - 从数据方舟或者快照,恢复主机的磁盘。必须在关机状态下进行。 +func (c *UHostClient) RestoreUHostDisk(req *RestoreUHostDiskRequest) (*RestoreUHostDiskResponse, error) { + var err error + var res RestoreUHostDiskResponse + + err = c.client.InvokeAction("RestoreUHostDisk", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} 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 new file mode 100644 index 0000000000..17f6f5ed7a --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/services/uhost/types_snapshot_set.go @@ -0,0 +1,46 @@ +package uhost + +/* +SnapshotSet - DescribeSnapshot + +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. +*/ +type SnapshotSet struct { + + // 快照Id + SnapshotId string + + // 磁盘Id。仅当为网络盘时返回此id。 + DiskId string + + // 主机Id。若udisk没有挂载,则不返回。 + UHostId string + + // 磁盘类型,枚举值为:LocalBoot,本地系统盘;LocalData,本地数据盘;UDiskBoot,云系统盘;UDiskData,云数据盘 + DiskType string + + // 大小 + Size int + + // 快照状态,枚举值为:Normal,可用;Creating,制作中;Failed,制作失败 + State string + + // 快照名称 + SnapshotName string + + // 快照描述 + SnapshotDescription string + + // 创建成功时间,unix时间 + CreateTime int + + // 指定的制作快照时间,unix时间 + SnapshotTime int + + // 可用区id + Zone string + + // 资源名字。本地盘对应主机名字,网络盘对应udisk名字 + ResourceName string +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/utils/accessor.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/utils/accessor.go index 6b0e7d2c84..efe834c6b8 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/private/utils/accessor.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/utils/accessor.go @@ -8,6 +8,7 @@ import ( "github.com/pkg/errors" ) +// ValueAtPath will get struct attribute value by recursive func ValueAtPath(v interface{}, path string) (interface{}, error) { components := strings.Split(path, ".") @@ -36,10 +37,10 @@ func ValueAtPath(v interface{}, path string) (interface{}, error) { } if len(components) > 1 { - return ValueAtPath(itemV.Interface(), strings.Join(components[1:len(components)], ".")) - } else { - return itemV.Interface(), nil + return ValueAtPath(itemV.Interface(), strings.Join(components[1:], ".")) } + + return itemV.Interface(), nil } if rv.Kind() == reflect.Map && !rv.IsNil() { @@ -49,10 +50,10 @@ func ValueAtPath(v interface{}, path string) (interface{}, error) { } if len(components) > 1 { - return ValueAtPath(itemV.Interface(), strings.Join(components[1:len(components)], ".")) - } else { - return itemV.Interface(), nil + return ValueAtPath(itemV.Interface(), strings.Join(components[1:], ".")) } + + return itemV.Interface(), nil } if rv.Kind() == reflect.Struct { @@ -62,10 +63,10 @@ func ValueAtPath(v interface{}, path string) (interface{}, error) { } if len(components) > 1 { - return ValueAtPath(itemV.Interface(), strings.Join(components[1:len(components)], ".")) - } else { - return itemV.Interface(), nil + return ValueAtPath(itemV.Interface(), strings.Join(components[1:], ".")) } + + return itemV.Interface(), nil } return nil, errors.Errorf("object %#v is invalid, need map or struct", v) 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 74fca88445..f18b6e68f4 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 @@ -24,8 +24,8 @@ func SetMapIfNotExists(m map[string]string, k string, v string) { } // IsStringIn will return if the value is contains by an array -func IsStringIn(val string, avaliables []string) bool { - for _, choice := range avaliables { +func IsStringIn(val string, availables []string) bool { + for _, choice := range availables { if val == choice { return true } @@ -35,9 +35,9 @@ func IsStringIn(val string, avaliables []string) bool { } // CheckStringIn will check if the value is contains by an array -func CheckStringIn(val string, avaliables []string) error { - if IsStringIn(val, avaliables) { +func CheckStringIn(val string, availables []string) error { + if IsStringIn(val, availables) { return nil } - return fmt.Errorf("got %s, should be one of %s", val, strings.Join(avaliables, ",")) + return fmt.Errorf("got %s, should be one of %s", val, strings.Join(availables, ",")) } 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 new file mode 100644 index 0000000000..75988e977f --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/utils/patch.go @@ -0,0 +1,35 @@ +package utils + +import ( + "regexp" +) + +// Patch is the patch object to provider a converter function +type Patch interface { + Patch([]byte) []byte +} + +// RegexpPatcher a patch object to provider a converter function from regular expression +type RegexpPatcher struct { + pattern *regexp.Regexp + replacement string +} + +// NewRegexpPatcher will return a patch object to provider a converter function from regular expression +func NewRegexpPatcher(regex string, repl string) *RegexpPatcher { + return &RegexpPatcher{ + pattern: regexp.MustCompile(regex), + replacement: repl, + } +} + +// 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)) +} + +// RetCodePatcher will convert `RetCode` as integer +var RetCodePatcher = NewRegexpPatcher(`"RetCode":\s*"(\d+)"`, `"RetCode": $1`) + +// PortPatcher will convert `RetCode` as integer +var PortPatcher = NewRegexpPatcher(`"Port":\s*"(\d+)"`, `"Port": $1`) diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/private/utils/waiter.go b/vendor/github.com/ucloud/ucloud-sdk-go/private/utils/waiter.go index e1c4152b35..7433a9139c 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/private/utils/waiter.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/private/utils/waiter.go @@ -23,14 +23,14 @@ type FuncWaiter struct { cancel chan struct{} } -// WaitForCompletion will wait until the state of consdition is avaliable. +// WaitForCompletion will wait until the state of consdition is available. // It will call the condition function to ensure state with interval. func (w *FuncWaiter) WaitForCompletion() error { for i := 0; ; i++ { log.Infof("Waiting for completion ... attempted %v times, %v total", i, w.MaxAttempts) if i >= w.MaxAttempts { - return errors.New("maximum attemps are reached") + return errors.New("maximum attempts are reached") } if ok, err := w.Checker(); ok || (!w.IgnoreError && err != nil) { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/client.go index 91e4b38762..e6fede2188 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/client.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/client.go @@ -5,10 +5,12 @@ import ( "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) +// PathXClient is the client of PathX type PathXClient struct { client *ucloud.Client } +// NewClient will return a instance of PathXClient func NewClient(config *ucloud.Config, credential *auth.Credential) *PathXClient { client := ucloud.NewClient(config, credential) return &PathXClient{ diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/doc.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/doc.go index 3ed3fc692a..ed9c9fb50e 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/doc.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/doc.go @@ -1,11 +1,11 @@ /* - Package uhost include resources of ucloud host product +Package pathx include resources of ucloud pathx product - See also +See also - - API: https://docs.ucloud.cn/api/pathx-api/index - - Product: https://www.ucloud.cn/site/product/pathx.html + - API: https://docs.ucloud.cn/api/pathx-api/index + - Product: https://www.ucloud.cn/site/product/pathx.html - for detail. +for detail. */ package pathx diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/modify_global_sshremark.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/modify_global_sshremark.go index d9fbc8b9a3..58f8104201 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/modify_global_sshremark.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/modify_global_sshremark.go @@ -30,7 +30,12 @@ type ModifyGlobalSSHRemarkResponse struct { // NewModifyGlobalSSHRemarkRequest will create request of ModifyGlobalSSHRemark action. func (c *PathXClient) NewModifyGlobalSSHRemarkRequest() *ModifyGlobalSSHRemarkRequest { req := &ModifyGlobalSSHRemarkRequest{} + + // 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 } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/types_global_ssharea.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/types_global_ssharea.go index b0012ebaef..dcce0c4b2d 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/types_global_ssharea.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/types_global_ssharea.go @@ -1,10 +1,10 @@ package pathx /* - GlobalSSHArea - GlobalSSH覆盖地区,包括关联的UCloud机房信息 +GlobalSSHArea - GlobalSSH覆盖地区,包括关联的UCloud机房信息 - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type GlobalSSHArea struct { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/types_global_sshinfo.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/types_global_sshinfo.go index 03531069b6..074996b05c 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/types_global_sshinfo.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/types_global_sshinfo.go @@ -1,10 +1,10 @@ package pathx /* - GlobalSSHInfo - GlobalSSH实例信息 +GlobalSSHInfo - GlobalSSH实例信息 - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type GlobalSSHInfo struct { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/client.go index 8624f71631..773234fd4f 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/client.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/client.go @@ -5,10 +5,12 @@ import ( "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) +// UAccountClient is the client of UAccount type UAccountClient struct { client *ucloud.Client } +// NewClient will return a instance of UAccountClient func NewClient(config *ucloud.Config, credential *auth.Credential) *UAccountClient { client := ucloud.NewClient(config, credential) return &UAccountClient{ diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/doc.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/doc.go index 7b104998a9..1f28c926f7 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/doc.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/doc.go @@ -1,11 +1,11 @@ /* - Package uhost include resources of ucloud host product +Package uaccount include resources of ucloud uaccount product - See also +See also - - API: https://docs.ucloud.cn/api/uaccount-api/index - - Product: https://www.ucloud.cn/site/product/uaccount.html + - API: https://docs.ucloud.cn/api/uaccount-api/index + - Product: https://www.ucloud.cn/site/product/uaccount.html - for detail. +for detail. */ package uaccount diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_project_list_info.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_project_list_info.go index 8df6549c11..c0daa5707d 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_project_list_info.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_project_list_info.go @@ -1,10 +1,10 @@ package uaccount /* - ProjectListInfo - 项目信息 +ProjectListInfo - 项目信息 - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type ProjectListInfo struct { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_region_info.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_region_info.go index 99eb846908..4a8510eac8 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_region_info.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_region_info.go @@ -1,10 +1,10 @@ package uaccount /* - RegionInfo - 数据中心信息 +RegionInfo - 数据中心信息 - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type RegionInfo struct { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_user_info.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_user_info.go index 7d99026c4c..e933f9b0e1 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_user_info.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_user_info.go @@ -1,10 +1,10 @@ package uaccount /* - UserInfo - 用户信息 +UserInfo - 用户信息 - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type UserInfo struct { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/client.go index a58904bf91..f0ae4c4737 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/client.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/client.go @@ -5,12 +5,12 @@ import ( "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) -// UDiskClient is the client of ucloud disk +// UDiskClient is the client of UDisk type UDiskClient struct { client *ucloud.Client } -// NewClient will create an instance of UDiskClient +// NewClient will return a instance of UDiskClient func NewClient(config *ucloud.Config, credential *auth.Credential) *UDiskClient { client := ucloud.NewClient(config, credential) return &UDiskClient{ 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 013df95b6b..3fbf25414b 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 @@ -51,7 +51,12 @@ type CloneUDiskSnapshotResponse struct { // NewCloneUDiskSnapshotRequest will create request of CloneUDiskSnapshot action. func (c *UDiskClient) NewCloneUDiskSnapshotRequest() *CloneUDiskSnapshotRequest { req := &CloneUDiskSnapshotRequest{} + + // 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 } 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 d6326886a6..001be5ebf1 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 @@ -42,7 +42,12 @@ type CreateUDiskSnapshotResponse struct { // NewCreateUDiskSnapshotRequest will create request of CreateUDiskSnapshot action. func (c *UDiskClient) NewCreateUDiskSnapshotRequest() *CreateUDiskSnapshotRequest { req := &CreateUDiskSnapshotRequest{} + + // 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 } 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 new file mode 100644 index 0000000000..d6d72e2fe3 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/delete_udisk_snapshot.go @@ -0,0 +1,53 @@ +//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/services/udisk/describe_udisk_snapshot.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/describe_udisk_snapshot.go new file mode 100644 index 0000000000..f0d8dcdc19 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/describe_udisk_snapshot.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 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/services/udisk/doc.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/doc.go index 2602d14c91..1bde5d7706 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/doc.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/doc.go @@ -1,11 +1,11 @@ /* - Package udisk include resources of ucloud disk product +Package udisk include resources of ucloud disk product - See also +See also - - API: https://docs.ucloud.cn/api/udisk-api/index - - Product: https://www.ucloud.cn/site/product/udisk.html + - API: https://docs.ucloud.cn/api/udisk-api/index + - Product: https://www.ucloud.cn/site/product/udisk.html - for detail. +for detail. */ package udisk 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 b102f20d25..45ce08378e 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 @@ -1,13 +1,16 @@ package udisk /* - UDiskDataSet - DescribeUDisk +UDiskDataSet - DescribeUDisk - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type UDiskDataSet struct { + // 可用区 + Zone string + // UDisk实例Id UDiskId string diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/types_udisk_price_data_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/types_udisk_price_data_set.go index cf9273e4bc..b9c242b867 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/types_udisk_price_data_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/types_udisk_price_data_set.go @@ -1,10 +1,10 @@ package udisk /* - UDiskPriceDataSet - DescribeUDiskPrice +UDiskPriceDataSet - DescribeUDiskPrice - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type UDiskPriceDataSet struct { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/types_udisk_snapshot_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/types_udisk_snapshot_set.go new file mode 100644 index 0000000000..6ca32072a4 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/udisk/types_udisk_snapshot_set.go @@ -0,0 +1,49 @@ +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/services/uhost/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/client.go index 0943fb1875..c1792b7ab0 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/client.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/client.go @@ -5,10 +5,12 @@ import ( "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) +// UHostClient is the client of UHost type UHostClient struct { client *ucloud.Client } +// NewClient will return a instance of UHostClient func NewClient(config *ucloud.Config, credential *auth.Credential) *UHostClient { client := ucloud.NewClient(config, credential) return &UHostClient{ diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/create_uhost_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/create_uhost_instance.go index 385642714e..2a0c0a3c9f 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/create_uhost_instance.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/create_uhost_instance.go @@ -72,9 +72,6 @@ type CreateUHostInstanceRequest struct { // 是否开启热升级特性。True为开启,False为未开启,默认False。仅系列1云主机需要使用此字段,系列2云主机根据镜像是否支持云主机。 HotplugFeature *bool `required:"false"` - // 加密盘的密码。若输入此字段,自动选择加密盘。加密盘需要权限位。 - DiskPassword *string `required:"false"` - // 网络ID(VPC2.0情况下无需填写)。VPC1.0情况下,若不填写,代表选择基础网络; 若填写,代表选择子网。参见DescribeSubnet。 NetworkId *string `required:"false"` diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/doc.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/doc.go index 8bf244c698..88c303ffe0 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/doc.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/doc.go @@ -1,11 +1,11 @@ /* - Package uhost include resources of ucloud host product +Package uhost include resources of ucloud host product - See also +See also - - API: https://docs.ucloud.cn/api/uhost-api/index - - Product: https://www.ucloud.cn/site/product/uhost.html + - API: https://docs.ucloud.cn/api/uhost-api/index + - Product: https://www.ucloud.cn/site/product/uhost.html - for detail. +for detail. */ package uhost 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 new file mode 100644 index 0000000000..b6a58e1419 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/import_custom_image.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 UHost ImportCustomImage + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud/request" + "github.com/ucloud/ucloud-sdk-go/ucloud/response" +) + +// ImportCustomImageRequest is request schema for ImportCustomImage action +type ImportCustomImageRequest struct { + request.CommonBase + + // 镜像名称 + ImageName *string `required:"true"` + + // UFile私有空间地址 + UFileUrl *string `required:"true"` + + // 操作系统平台,比如CentOS、Ubuntu、Windows、RedHat等,请参考控制台的镜像版本;若导入控制台上没有的操作系统,参数为Other + OsType *string `required:"true"` + + // 操作系统详细版本,请参考控制台的镜像版本;OsType为Other时,输入参数为Other + OsName *string `required:"true"` + + // 镜像格式,可选RAW、VHD、VMDK、qcow2 + Format *string `required:"true"` + + // 是否授权。必须填true + Auth *bool `required:"true"` + + // 镜像描述 + ImageDescription *string `required:"false"` +} + +// ImportCustomImageResponse is response schema for ImportCustomImage action +type ImportCustomImageResponse struct { + response.CommonBase + + // 镜像Id + ImageId string +} + +// NewImportCustomImageRequest will create request of ImportCustomImage action. +func (c *UHostClient) NewImportCustomImageRequest() *ImportCustomImageRequest { + req := &ImportCustomImageRequest{} + + // 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 +} + +// ImportCustomImage - 把UFile的镜像文件导入到UHost,生成自定义镜像 +func (c *UHostClient) ImportCustomImage(req *ImportCustomImageRequest) (*ImportCustomImageResponse, error) { + var err error + var res ImportCustomImageResponse + + err = c.client.InvokeAction("ImportCustomImage", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} 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 5349592af8..9b865530e7 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 @@ -4,6 +4,9 @@ package uhost import ( + "encoding/base64" + + "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/request" "github.com/ucloud/ucloud-sdk-go/ucloud/response" ) @@ -58,6 +61,7 @@ func (c *UHostClient) NewReinstallUHostInstanceRequest() *ReinstallUHostInstance func (c *UHostClient) ReinstallUHostInstance(req *ReinstallUHostInstanceRequest) (*ReinstallUHostInstanceResponse, error) { var err error var res ReinstallUHostInstanceResponse + req.Password = ucloud.String(base64.StdEncoding.EncodeToString([]byte(ucloud.StringValue(req.Password)))) err = c.client.InvokeAction("ReinstallUHostInstance", req, &res) if err != nil { 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 e46872b961..2e84aad430 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 @@ -4,6 +4,9 @@ package uhost import ( + "encoding/base64" + + "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/request" "github.com/ucloud/ucloud-sdk-go/ucloud/response" ) @@ -46,6 +49,7 @@ func (c *UHostClient) NewResetUHostInstancePasswordRequest() *ResetUHostInstance func (c *UHostClient) ResetUHostInstancePassword(req *ResetUHostInstancePasswordRequest) (*ResetUHostInstancePasswordResponse, error) { var err error var res ResetUHostInstancePasswordResponse + req.Password = ucloud.String(base64.StdEncoding.EncodeToString([]byte(ucloud.StringValue(req.Password)))) err = c.client.InvokeAction("ResetUHostInstancePassword", req, &res) if err != nil { 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 6497ed2b59..4cd85b71bf 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 @@ -18,16 +18,16 @@ type ResizeUHostInstanceRequest struct { // UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) UHostId *string `required:"true"` - // 虚拟CPU核数,单位:个,系列1范围:[1,16],系列2范围:[1,32],最小值为1,其他值是2的倍数,默认值为当前实例的CPU核数 + // 虚拟CPU核数。可选参数:1-32(可选范围与UHostType相关)。默认值为当前实例的CPU核数 CPU *int `required:"false"` - // 内存大小,单位:MB,范围[2048,131072],步长:2048,默认值为当前实例的内存大小(BGP-C数据中心最小支持1024,限Linux系统) + // 内存大小。单位:MB。范围 :[1024, 262144],取值为1024的倍数(可选范围与UHostType相关)。默认值为当前实例的内存大小。 Memory *int `required:"false"` - // 数据盘大小,单位:GB,范围[10,1000]; SSD机型,单位:GB,范围[100,500];步长:10,默认值为当前实例的数据盘大小,数据盘不支持缩容,因此不允许输入比当前实例数据盘大小的值 + // 【待废弃】数据盘大小,单位:GB,范围[10,1000]; SSD机型,单位:GB,范围[100,500];步长:10,默认值为当前实例的数据盘大小,数据盘不支持缩容,因此不允许输入比当前实例数据盘大小的值 DiskSpace *int `required:"false"` - // 系统盘大小,单位:GB,范围[20,100],步长:10,系统盘不支持缩容,因此不允许输入比当前实例系统盘小的值 + // 【待废弃】系统盘大小,单位:GB,范围[20,100],步长:10,系统盘不支持缩容,因此不允许输入比当前实例系统盘小的值 BootDiskSpace *int `required:"false"` // 网卡升降级(1,表示升级,2表示降级,0表示不变) @@ -54,7 +54,7 @@ func (c *UHostClient) NewResizeUHostInstanceRequest() *ResizeUHostInstanceReques return req } -// ResizeUHostInstance - 修改指定UHost实例的资源配置,如CPU核心数,内存容量大小,磁盘空间大小,网络增强等。 +// ResizeUHostInstance - 修改指定UHost实例的资源配置,如CPU核心数,内存容量大小,网络增强等。可选配置范围请参考[[api:uhost-api:uhost_type|云主机机型说明]]。 func (c *UHostClient) ResizeUHostInstance(req *ResizeUHostInstanceRequest) (*ResizeUHostInstanceResponse, error) { var err error var res ResizeUHostInstanceResponse 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 886eda967d..9e9a343872 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 @@ -17,9 +17,6 @@ type StartUHostInstanceRequest struct { // 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/terminate_uhost_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/terminate_uhost_instance.go index baafa4248a..edbc01357e 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 @@ -21,9 +21,10 @@ type TerminateUHostInstanceRequest struct { // 是否直接删除,0表示按照原来的逻辑(有回收站权限,则进入回收站),1表示直接删除 Destroy *int `required:"false"` - // 是否释放绑定的EIP。yes: 解绑EIP后,并释放;其他值或不填:解绑EIP。 - // EIPReleased *string `required:"false"` - ReleaseEIP *bool `required:"false"` + // 是否释放绑定的EIP。true: 解绑EIP后,并释放;其他值或不填:解绑EIP。 + ReleaseEIP *bool `required:"false"` + + // 是否删除挂载的数据盘。true删除,其他不删除。 ReleaseUDisk *bool `required:"false"` } @@ -31,13 +32,10 @@ type TerminateUHostInstanceRequest struct { type TerminateUHostInstanceResponse struct { response.CommonBase - // UHost 实例 Id - UHostIds []string - // 放入回收站:"Yes", 彻底删除:“No” InRecycle string - // 主机 ID + // UHost 实例 Id UHostId string } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_disk_query.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_disk_query.go index 264e5aeaf3..34c6ecb2fb 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_disk_query.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_disk_query.go @@ -1,7 +1,7 @@ package uhost /* - UHostDisk - the request query for disk of uhost +UHostDisk - the request query for disk of uhost */ type UHostDisk struct { // 磁盘大小,单位GB。 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 7ec98645a5..c32978ea3b 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 @@ -1,10 +1,10 @@ package uhost /* - UHostDiskSet - DescribeUHostInstance +UHostDiskSet - DescribeUHostInstance - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type UHostDiskSet struct { 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 330ad37752..b3be06cb1c 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 @@ -1,10 +1,10 @@ package uhost /* - UHostImageSet - DescribeImage +UHostImageSet - DescribeImage - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type UHostImageSet struct { 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 c1360fd15a..1e7a006407 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 @@ -1,10 +1,10 @@ package uhost /* - UHostInstanceSet - DescribeUHostInstance +UHostInstanceSet - DescribeUHostInstance - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type UHostInstanceSet struct { @@ -14,13 +14,13 @@ type UHostInstanceSet struct { // UHost实例ID UHostId string - // UHost类型,枚举为:N1:标准型系列1;N2:标准型系列2 ;I1:高IO型系列1;I2:高IO型系列2;D1:大数据型系列1;G1:GPU型系列1;G2:GPU型系列2;G3:GPU型系列2 + // 云主机机型。参考[[api:uhost-api:uhost_type|云主机机型说明]]。 UHostType string - // 系统盘与数据盘的磁盘类型。 枚举值为:LocalDisk,本地磁盘; UDisk,云硬盘 + // 【建议不再使用】主机磁盘类型。 枚举值为:\\ > LocalDisk,本地磁盘; \\ > UDisk 云盘。\\只要有一块磁盘为本地盘,即返回LocalDisk。 StorageType string - // 镜像ID + // 【建议不再使用】主机的系统盘ID。 ImageId string // 基础镜像ID(指当前自定义镜像的来源镜像) @@ -38,7 +38,7 @@ type UHostInstanceSet struct { // UHost实例名称 Name string - // 实例状态, 初始化: Initializing; 启动中: Starting; 运行中: Running; 关机中: Stopping; 关机: Stopped 安装失败: Install Fail; 重启中: Rebooting + // 实例状态,枚举值:\\ >初始化: Initializing; \\ >启动中: Starting; \\> 运行中: Running; \\> 关机中: Stopping; \\ >关机: Stopped \\ >安装失败: Install Fail; \\ >重启中: Rebooting State string // 创建时间,格式为Unix时间戳 @@ -68,25 +68,25 @@ type UHostInstanceSet struct { // 网络增强。目前仅支持Normal和Super NetCapability string - // 网络状态 连接:Connected, 断开:NotConnected + // 【建议不再使用】网络状态。 连接:Connected, 断开:NotConnected NetworkState string - // yes: 开启方舟; no,未开启方舟 + // 【建议不再使用】数据方舟模式。枚举值:\\ > Yes: 开启方舟; \\ > no,未开启方舟 TimemachineFeature string // true: 开启热升级; false,未开启热升级 HotplugFeature bool - // 基础网络:Default;子网:Private + // 【建议不再使用】仅北京A的云主机会返回此字段。基础网络模式:Default;子网模式:Private SubnetType string - // 内网或者子网的IP地址 + // 内网的IP地址 IPs []string - // Os名称 + // 创建主机的最初来源镜像的操作系统名称(若直接通过基础镜像创建,此处返回和BasicImageName一致) OsName string - // "Linux"或者"Windows" + // 操作系统类别。返回"Linux"或者"Windows" OsType string // 删除时间,格式为Unix时间戳 @@ -101,9 +101,9 @@ type UHostInstanceSet struct { // GPU个数 GPU int - // 系统盘状态 Normal表示初始化完成;Initializing表示在初始化 + // 系统盘状态 Normal表示初始化完成;Initializing表示在初始化。仍在初始化的系统盘无法制作镜像。 BootDiskState string - // 总的存储空间 + // 总的存储空间。包含系统盘与全部数据盘的总容量。 TotalDiskSpace int } 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 ecbe6a8916..690439bec4 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 @@ -1,14 +1,14 @@ package uhost /* - UHostIPSet - DescribeUHostInstance +UHostIPSet - DescribeUHostInstance - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type UHostIPSet struct { - // 电信: China-telecom,联通: China-unicom, 国际: Internation,BGP: Bgp,内网: Private 双线: Duplet + // 电信: China-telecom,联通: China-unicom, 国际: Internationl,BGP: Bgp,内网: Private 双线: Duplet Type string // IP资源ID (内网IP无对应的资源ID) @@ -17,12 +17,12 @@ type UHostIPSet struct { // IP地址 IP string - // IP对应的带宽, 单位: Mb (内网IP不显示带宽信息) - Bandwidth int - // 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/types_uhost_price_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_price_set.go index de93d1407e..6ca352c14c 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_price_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_price_set.go @@ -1,10 +1,10 @@ package uhost /* - UHostPriceSet - 主机价格 +UHostPriceSet - 主机价格 - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type UHostPriceSet struct { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_tag_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_tag_set.go index 7eceabcb3b..58ae887484 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_tag_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_tag_set.go @@ -1,10 +1,10 @@ package uhost /* - UHostTagSet - DescribeUHostTags +UHostTagSet - DescribeUHostTags - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type UHostTagSet struct { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/wait_until_uhost_instance_state.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/wait_until_uhost_instance_state.go index c8860e851e..53a21d2a13 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/wait_until_uhost_instance_state.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/wait_until_uhost_instance_state.go @@ -10,6 +10,7 @@ import ( "github.com/ucloud/ucloud-sdk-go/ucloud/request" ) +// WaitUntilUHostInstanceStateRequest is the request of uhost instance state waiter type WaitUntilUHostInstanceStateRequest struct { request.CommonBase @@ -61,9 +62,9 @@ func (c *UHostClient) WaitUntilUHostInstanceState(req *WaitUntilUHostInstanceSta if len(resp.UHostSet) > 0 { return true, nil - } else { - return false, nil } + + return false, nil }, } return waiter.WaitForCompletion() 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 deleted file mode 100644 index 109438f86a..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/allocate_backend.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 ULB AllocateBackend - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/ucloud/request" - "github.com/ucloud/ucloud-sdk-go/ucloud/response" -) - -// AllocateBackendRequest is request schema for AllocateBackend action -type AllocateBackendRequest struct { - request.CommonBase - - // 负载均衡实例的ID - ULBId *string `required:"true"` - - // VServer实例的ID - VServerId *string `required:"true"` - - // 所添加的后端资源的类型,枚举值:UHost -> 云主机;UPM -> 物理云主机; UDHost -> 私有专区主机;UDocker -> 容器,默认值为“UHost” - ResourceType *string `required:"true"` - - // 所添加的后端资源的资源ID - ResourceId *string `required:"true"` - - // 所添加的后端资源服务端口,取值范围[1-65535],默认80 - Port *int `required:"false"` - - // 后端实例状态开关,枚举值: 1:启用; 0:禁用 默认为启用 - Enabled *int `required:"false"` -} - -// AllocateBackendResponse is response schema for AllocateBackend action -type AllocateBackendResponse struct { - response.CommonBase - - // 所添加的后端资源在ULB中的对象ID,(为ULB系统中使用,与资源自身ID无关),可用于 UpdateBackendAttribute/UpdateBackendAttributeBatch/ReleaseBackend - BackendId string -} - -// NewAllocateBackendRequest will create request of AllocateBackend action. -func (c *ULBClient) NewAllocateBackendRequest() *AllocateBackendRequest { - req := &AllocateBackendRequest{} - - // 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 -} - -// AllocateBackend - 添加ULB后端资源实例 -func (c *ULBClient) AllocateBackend(req *AllocateBackendRequest) (*AllocateBackendResponse, error) { - var err error - var res AllocateBackendResponse - - err = c.client.InvokeAction("AllocateBackend", req, &res) - if err != nil { - return &res, err - } - - return &res, nil -} 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 deleted file mode 100644 index 302d37e374..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/allocate_backend_batch.go +++ /dev/null @@ -1,59 +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 ULB AllocateBackendBatch - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/ucloud/request" - "github.com/ucloud/ucloud-sdk-go/ucloud/response" -) - -// AllocateBackendBatchRequest is request schema for AllocateBackendBatch action -type AllocateBackendBatchRequest struct { - request.CommonBase - - // 负载均衡实例的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; - Backends []string `required:"true"` - - // 已弃用,指定 Api 版本 - ApiVersion *int `required:"false"` -} - -// AllocateBackendBatchResponse is response schema for AllocateBackendBatch action -type AllocateBackendBatchResponse struct { - response.CommonBase - - // 所添加的后端资源ID,(为ULB系统中使用,与资源自身ID无关),可用于 UpdateBackendAttribute/UpdateBackendAttributeBatch/ReleaseBackend - BackendSet []BackendSet -} - -// NewAllocateBackendBatchRequest will create request of AllocateBackendBatch action. -func (c *ULBClient) NewAllocateBackendBatchRequest() *AllocateBackendBatchRequest { - req := &AllocateBackendBatchRequest{} - - // 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 -} - -// AllocateBackendBatch - 批量添加VServer后端节点 -func (c *ULBClient) AllocateBackendBatch(req *AllocateBackendBatchRequest) (*AllocateBackendBatchResponse, error) { - var err error - var res AllocateBackendBatchResponse - - err = c.client.InvokeAction("AllocateBackendBatch", req, &res) - if err != nil { - return &res, err - } - - return &res, nil -} 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 deleted file mode 100644 index f1a2197377..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_policy.go +++ /dev/null @@ -1,62 +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 ULB CreatePolicy - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/ucloud/request" - "github.com/ucloud/ucloud-sdk-go/ucloud/response" -) - -// CreatePolicyRequest is request schema for CreatePolicy action -type CreatePolicyRequest struct { - request.CommonBase - - // 需要添加内容转发策略的负载均衡实例ID - ULBId *string `required:"true"` - - // 需要添加内容转发策略的VServer实例ID - VServerId *string `required:"true"` - - // 内容转发策略应用的后端资源实例的ID,来源于 AllocateBackend 返回的 BackendId - BackendId []string `required:"true"` - - // 内容转发匹配字段 - Match *string `required:"true"` - - // 内容转发匹配字段的类型 - Type *string `required:"false"` -} - -// CreatePolicyResponse is response schema for CreatePolicy action -type CreatePolicyResponse struct { - response.CommonBase - - // 内容转发策略ID - PolicyId string -} - -// NewCreatePolicyRequest will create request of CreatePolicy action. -func (c *ULBClient) NewCreatePolicyRequest() *CreatePolicyRequest { - req := &CreatePolicyRequest{} - - // 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 -} - -// CreatePolicy - 创建VServer内容转发策略 -func (c *ULBClient) CreatePolicy(req *CreatePolicyRequest) (*CreatePolicyResponse, error) { - var err error - var res CreatePolicyResponse - - err = c.client.InvokeAction("CreatePolicy", req, &res) - if err != nil { - return &res, err - } - - return &res, nil -} 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 deleted file mode 100644 index 5c41030b97..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_ulb.go +++ /dev/null @@ -1,74 +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 ULB CreateULB - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/ucloud/request" - "github.com/ucloud/ucloud-sdk-go/ucloud/response" -) - -// CreateULBRequest is request schema for CreateULB action -type CreateULBRequest struct { - request.CommonBase - - // 负载均衡的名字,默认值为“ULB” - ULBName *string `required:"false"` - - // 业务组 - Tag *string `required:"false"` - - // 备注 - Remark *string `required:"false"` - - // 创建的ULB是否为外网模式,默认即为外网模式 - OuterMode *string `required:"false"` - - // 创建的ULB是否为内网模式 - InnerMode *string `required:"false"` - - // 付费方式 - ChargeType *string `required:"false"` - - // ULB所在的VPC的ID, 如果不传则使用默认的VPC - VPCId *string `required:"false"` - - // 内网ULB 所属的子网ID,如果不传则使用默认的子网 - SubnetId *string `required:"false"` - - // ULB 所属的业务组ID,如果不传则使用默认的业务组 - BusinessId *string `required:"false"` -} - -// CreateULBResponse is response schema for CreateULB action -type CreateULBResponse struct { - response.CommonBase - - // 负载均衡实例的Id - ULBId string -} - -// NewCreateULBRequest will create request of CreateULB action. -func (c *ULBClient) NewCreateULBRequest() *CreateULBRequest { - req := &CreateULBRequest{} - - // 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 -} - -// CreateULB - 创建负载均衡实例,可以选择内网或者外网 -func (c *ULBClient) CreateULB(req *CreateULBRequest) (*CreateULBResponse, error) { - var err error - var res CreateULBResponse - - err = c.client.InvokeAction("CreateULB", req, &res) - if err != nil { - return &res, err - } - - return &res, nil -} 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 deleted file mode 100644 index 279e60a702..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_vserver.go +++ /dev/null @@ -1,83 +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 ULB CreateVServer - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/ucloud/request" - "github.com/ucloud/ucloud-sdk-go/ucloud/response" -) - -// CreateVServerRequest is request schema for CreateVServer action -type CreateVServerRequest struct { - request.CommonBase - - // 负载均衡实例ID - ULBId *string `required:"true"` - - // VServer实例名称,默认为"VServer" - VServerName *string `required:"false"` - - // 监听器类型,枚举值为:RequestProxy -> 请求代理;PacketsTransmit -> 报文转发;默认为"RequestProxy" - ListenType *string `required:"false"` - - // VServer实例的协议,请求代理模式下有 HTTP、HTTPS、TCP,报文转发下有 TCP,UDP。默认为“HTTP" - Protocol *string `required:"false"` - - // VServer后端端口,取值范围[1-65535];默认值为80 - FrontendPort *int `required:"false"` - - // VServer负载均衡模式,枚举值:Roundrobin -> 轮询;Source -> 源地址;ConsistentHash -> 一致性哈希;SourcePort -> 源地址(计算端口);ConsistentHashPort -> 一致性哈希(计算端口)。ConsistentHash,SourcePort,ConsistentHashPort 只在报文转发中使用;Roundrobin和Source在请求代理和报文转发中使用。默认为:"Roundrobin" - Method *string `required:"false"` - - // VServer会话保持方式,默认关闭会话保持。枚举值:None -> 关闭;ServerInsert -> 自动生成KEY;UserDefined -> 用户自定义KEY。 - PersistenceType *string `required:"false"` - - // 根据PersistenceType确认; None和ServerInsert: 此字段无意义; UserDefined:此字段传入自定义会话保持String - PersistenceInfo *string `required:"false"` - - // ListenType为RequestProxy时表示空闲连接的回收时间,单位:秒,取值范围:时(0,86400],默认值为60;ListenType为PacketsTransmit时表示连接保持的时间,单位:秒,取值范围:[60,900],0 表示禁用连接保持 - ClientTimeout *int `required:"false"` - - // 健康检查类型,枚举值:Port -> 端口检查;Path -> 路径检查; - MonitorType *string `required:"false"` - - // 健康检查的域名 - Domain *string `required:"false"` - - // 健康检查的路径 - Path *string `required:"false"` -} - -// CreateVServerResponse is response schema for CreateVServer action -type CreateVServerResponse struct { - response.CommonBase - - // VServer实例的Id - VServerId string -} - -// NewCreateVServerRequest will create request of CreateVServer action. -func (c *ULBClient) NewCreateVServerRequest() *CreateVServerRequest { - req := &CreateVServerRequest{} - - // 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 -} - -// CreateVServer - 创建VServer实例,定义监听的协议和端口以及负载均衡算法 -func (c *ULBClient) CreateVServer(req *CreateVServerRequest) (*CreateVServerResponse, error) { - var err error - var res CreateVServerResponse - - err = c.client.InvokeAction("CreateVServer", req, &res) - if err != nil { - return &res, err - } - - return &res, nil -} 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 deleted file mode 100644 index fd0ed2f9d0..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_policy.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 ULB DeletePolicy - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/ucloud/request" - "github.com/ucloud/ucloud-sdk-go/ucloud/response" -) - -// DeletePolicyRequest is request schema for DeletePolicy action -type DeletePolicyRequest struct { - request.CommonBase - - // 内容转发策略ID - PolicyId *string `required:"true"` - - // 内容转发策略组ID - GroupId *string `required:"false"` - - // VServer 资源ID - VServerId *string `required:"false"` -} - -// DeletePolicyResponse is response schema for DeletePolicy action -type DeletePolicyResponse struct { - response.CommonBase -} - -// NewDeletePolicyRequest will create request of DeletePolicy action. -func (c *ULBClient) NewDeletePolicyRequest() *DeletePolicyRequest { - req := &DeletePolicyRequest{} - - // 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 -} - -// DeletePolicy - 删除内容转发策略 -func (c *ULBClient) DeletePolicy(req *DeletePolicyRequest) (*DeletePolicyResponse, error) { - var err error - var res DeletePolicyResponse - - err = c.client.InvokeAction("DeletePolicy", req, &res) - if err != nil { - return &res, err - } - - return &res, nil -} 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 deleted file mode 100644 index 3d8edb91d4..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_ulb.go +++ /dev/null @@ -1,47 +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 ULB DeleteULB - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/ucloud/request" - "github.com/ucloud/ucloud-sdk-go/ucloud/response" -) - -// DeleteULBRequest is request schema for DeleteULB action -type DeleteULBRequest struct { - request.CommonBase - - // 负载均衡实例的ID - ULBId *string `required:"true"` -} - -// DeleteULBResponse is response schema for DeleteULB action -type DeleteULBResponse struct { - response.CommonBase -} - -// NewDeleteULBRequest will create request of DeleteULB action. -func (c *ULBClient) NewDeleteULBRequest() *DeleteULBRequest { - req := &DeleteULBRequest{} - - // 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 -} - -// DeleteULB - 删除负载均衡实例 -func (c *ULBClient) DeleteULB(req *DeleteULBRequest) (*DeleteULBResponse, error) { - var err error - var res DeleteULBResponse - - err = c.client.InvokeAction("DeleteULB", req, &res) - if err != nil { - return &res, err - } - - return &res, nil -} 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 deleted file mode 100644 index 3456788241..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_vserver.go +++ /dev/null @@ -1,50 +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 ULB DeleteVServer - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/ucloud/request" - "github.com/ucloud/ucloud-sdk-go/ucloud/response" -) - -// DeleteVServerRequest is request schema for DeleteVServer action -type DeleteVServerRequest struct { - request.CommonBase - - // 负载均衡实例的ID - ULBId *string `required:"true"` - - // VServer实例的ID - VServerId *string `required:"true"` -} - -// DeleteVServerResponse is response schema for DeleteVServer action -type DeleteVServerResponse struct { - response.CommonBase -} - -// NewDeleteVServerRequest will create request of DeleteVServer action. -func (c *ULBClient) NewDeleteVServerRequest() *DeleteVServerRequest { - req := &DeleteVServerRequest{} - - // 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 -} - -// DeleteVServer - 删除VServer实例 -func (c *ULBClient) DeleteVServer(req *DeleteVServerRequest) (*DeleteVServerResponse, error) { - var err error - var res DeleteVServerResponse - - err = c.client.InvokeAction("DeleteVServer", req, &res) - if err != nil { - return &res, err - } - - return &res, nil -} 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 deleted file mode 100644 index e12372006d..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_ulb.go +++ /dev/null @@ -1,68 +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 ULB DescribeULB - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/ucloud/request" - "github.com/ucloud/ucloud-sdk-go/ucloud/response" -) - -// DescribeULBRequest is request schema for DescribeULB action -type DescribeULBRequest struct { - request.CommonBase - - // 数据偏移量,默认为0 - Offset *int `required:"false"` - - // 数据分页值,默认为20 - Limit *int `required:"false"` - - // 负载均衡实例的Id。 若指定则返回指定的负载均衡实例的信息; 若不指定则返回当前数据中心中所有的负载均衡实例的信息 - ULBId *string `required:"false"` - - // ULB所属的VPC - VPCId *string `required:"false"` - - // ULB所属的子网ID - SubnetId *string `required:"false"` - - // ULB所属的业务组ID - BusinessId *string `required:"false"` -} - -// DescribeULBResponse is response schema for DescribeULB action -type DescribeULBResponse struct { - response.CommonBase - - // 满足条件的ULB总数 - TotalCount int - - // ULB列表,每项参数详见 ULBSet - DataSet []ULBSet -} - -// NewDescribeULBRequest will create request of DescribeULB action. -func (c *ULBClient) NewDescribeULBRequest() *DescribeULBRequest { - req := &DescribeULBRequest{} - - // 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 -} - -// DescribeULB - 获取ULB详细信息 -func (c *ULBClient) DescribeULB(req *DescribeULBRequest) (*DescribeULBResponse, error) { - var err error - var res DescribeULBResponse - - err = c.client.InvokeAction("DescribeULB", req, &res) - if err != nil { - return &res, err - } - - return &res, nil -} 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 deleted file mode 100644 index 9ac69bc6cd..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_vserver.go +++ /dev/null @@ -1,62 +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 ULB DescribeVServer - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/ucloud/request" - "github.com/ucloud/ucloud-sdk-go/ucloud/response" -) - -// DescribeVServerRequest is request schema for DescribeVServer action -type DescribeVServerRequest struct { - request.CommonBase - - // 负载均衡实例的Id - ULBId *string `required:"true"` - - // VServer实例的Id;若指定则返回指定的VServer实例的信息; 若不指定则返回当前负载均衡实例下所有VServer的信息 - VServerId *string `required:"false"` - - // 数据分页值 - Limit *string `required:"false"` - - // 数据偏移量 - Offset *string `required:"false"` -} - -// DescribeVServerResponse is response schema for DescribeVServer action -type DescribeVServerResponse struct { - response.CommonBase - - // 满足条件的VServer总数 - TotalCount int - - // VServer列表,每项参数详见 ULBVServerSet - DataSet []ULBVServerSet -} - -// NewDescribeVServerRequest will create request of DescribeVServer action. -func (c *ULBClient) NewDescribeVServerRequest() *DescribeVServerRequest { - req := &DescribeVServerRequest{} - - // 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 -} - -// DescribeVServer - 获取ULB下的VServer的详细信息 -func (c *ULBClient) DescribeVServer(req *DescribeVServerRequest) (*DescribeVServerResponse, error) { - var err error - var res DescribeVServerResponse - - err = c.client.InvokeAction("DescribeVServer", req, &res) - if err != nil { - return &res, err - } - - return &res, nil -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/doc.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/doc.go deleted file mode 100644 index 6499e334a0..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/doc.go +++ /dev/null @@ -1,11 +0,0 @@ -/* - Package ulb include resources of ucloud ulb product - - See also - - - API: https://docs.ucloud.cn/api/ulb-api/index - - Product: https://www.ucloud.cn/site/product/ulb.html - - for detail. -*/ -package ulb 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 deleted file mode 100644 index 91fae690b6..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/release_backend.go +++ /dev/null @@ -1,50 +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 ULB ReleaseBackend - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/ucloud/request" - "github.com/ucloud/ucloud-sdk-go/ucloud/response" -) - -// ReleaseBackendRequest is request schema for ReleaseBackend action -type ReleaseBackendRequest struct { - request.CommonBase - - // 负载均衡实例的ID - ULBId *string `required:"true"` - - // 后端资源实例的ID(ULB后端ID,非资源自身ID) - BackendId *string `required:"true"` -} - -// ReleaseBackendResponse is response schema for ReleaseBackend action -type ReleaseBackendResponse struct { - response.CommonBase -} - -// NewReleaseBackendRequest will create request of ReleaseBackend action. -func (c *ULBClient) NewReleaseBackendRequest() *ReleaseBackendRequest { - req := &ReleaseBackendRequest{} - - // 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 -} - -// ReleaseBackend - 从VServer释放后端资源实例 -func (c *ULBClient) ReleaseBackend(req *ReleaseBackendRequest) (*ReleaseBackendResponse, error) { - var err error - var res ReleaseBackendResponse - - err = c.client.InvokeAction("ReleaseBackend", req, &res) - if err != nil { - return &res, err - } - - return &res, nil -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_backend_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_backend_set.go deleted file mode 100644 index 5008a2c81e..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_backend_set.go +++ /dev/null @@ -1,16 +0,0 @@ -package ulb - -/* - BackendSet - ulb添加rs时返回的信息 - - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. -*/ -type BackendSet struct { - - // rs的资源ID - BackendId string - - // rs对应的UHost ID - ResourceId string -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_policy_backend_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_policy_backend_set.go deleted file mode 100644 index 049eeb5f58..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_policy_backend_set.go +++ /dev/null @@ -1,25 +0,0 @@ -package ulb - -/* - PolicyBackendSet - 内容转发下rs详细信息 - - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. -*/ -type PolicyBackendSet struct { - - // 所添加的后端资源在ULB中的对象ID,(为ULB系统中使用,与资源自身ID无关 - BackendId string - - // 后端资源的对象ID - ObjectId string - - // 所添加的后端资源服务端口 - Port int - - // 后端资源的内网IP - PrivateIP string - - // 后端资源的实例名称 - ResourceName string -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulb_policy_backend_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulb_policy_backend_set.go deleted file mode 100644 index 89bc51211b..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulb_policy_backend_set.go +++ /dev/null @@ -1,19 +0,0 @@ -package ulb - -/* - UlbPolicyBackendSet - DescribePolicyGroup - - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. -*/ -type UlbPolicyBackendSet struct { - - // 后端资源实例的ID - BackendId string - - // 后端资源实例的内网IP - PrivateIP string - - // 后端资源实例的服务端口 - Port int -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulb_policy_group_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulb_policy_group_set.go deleted file mode 100644 index 87b7cd7852..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulb_policy_group_set.go +++ /dev/null @@ -1,19 +0,0 @@ -package ulb - -/* - UlbPolicyGroupSet - DescribePolicyGroup - - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. -*/ -type UlbPolicyGroupSet struct { - - // 内容转发策略组ID - GroupId string - - // 内容转发策略组名称 - GroupName string - - // 内容转发策略组详细信息,具体结构见 UlbPolicySet - PolicySet []UlbPolicySet -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulb_policy_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulb_policy_set.go deleted file mode 100644 index 06c2ac5320..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulb_policy_set.go +++ /dev/null @@ -1,25 +0,0 @@ -package ulb - -/* - UlbPolicySet - DescribePolicyGroup - - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. -*/ -type UlbPolicySet struct { - - // 内容转发策略组ID - PolicyId string - - // 内容转发匹配字段的类型,当前只支持按域名转发。枚举值为: Domain,按域名转发 - Type string - - // 内容转发匹配字段 - Match string - - // 内容转发策略组ID应用的VServer实例的ID - VServerId string - - // 内容转发策略组ID所应用的后端资源列表,具体结构见 UlbPolicyBackendSet - BackendSet []UlbPolicyBackendSet -} 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 deleted file mode 100644 index 2e39b99ce6..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbbackend_set.go +++ /dev/null @@ -1,37 +0,0 @@ -package ulb - -/* - ULBBackendSet - DescribeULB - - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. -*/ -type ULBBackendSet struct { - - // 后端资源实例的Id - BackendId string - - // 后端资源实例的类型 - ResourceType string - - // 后端资源实例的资源Id - ResourceId string - - // 后端资源实例的资源名字 - ResourceName string - - // 后端资源实例的内网IP - PrivateIP string - - // 后端资源实例服务的端口 - Port int - - // 后端资源实例的启用与否 - Enabled int - - // 后端资源实例的运行状态 - Status int - - // 后端资源实例的资源所在的子网的ID - SubnetId string -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbipset.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbipset.go deleted file mode 100644 index 521089ce4e..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbipset.go +++ /dev/null @@ -1,19 +0,0 @@ -package ulb - -/* - ULBIPSet - DescribeULB - - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. -*/ -type ULBIPSet struct { - - // 弹性IP的运营商信息,枚举值为: Bgp:BGP IP International:国际IP - OperatorName string - - // 弹性IP地址 - EIP string - - // 弹性IP的ID - EIPId string -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbpolicy_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbpolicy_set.go deleted file mode 100644 index b88e8efec2..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbpolicy_set.go +++ /dev/null @@ -1,34 +0,0 @@ -package ulb - -/* - ULBPolicySet - 内容转发详细列表 - - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. -*/ -type ULBPolicySet struct { - - // 内容转发Id,默认内容转发类型下为空。 - PolicyId string - - // 内容类型,枚举值:Custom -> 客户自定义;Default -> 默认内容转发 - PolicyType string - - // 内容转发匹配字段的类型,枚举值:Domain -> 域名;Path -> 路径; 默认内容转发类型下为空 - Type string - - // 内容转发匹配字段;默认内容转发类型下为空。 - Match string - - // 内容转发优先级,范围[1,9999],数字越大优先级越高。默认内容转发规则下为0。 - PolicyPriority int - - // 所属VServerId - VServerId string - - // 默认内容转发类型下返回当前rs总数 - TotalCount int - - // 内容转发下rs的详细信息,参考PolicyBackendSet - BackendSet []PolicyBackendSet -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbset.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbset.go deleted file mode 100644 index 5f53104964..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbset.go +++ /dev/null @@ -1,61 +0,0 @@ -package ulb - -/* - ULBSet - DescribeULB - - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. -*/ -type ULBSet struct { - - // 负载均衡的资源ID - ULBId string - - // 负载均衡的资源名称(内部记载,废弃) - ULBName string - - // 负载均衡的资源名称(资源系统中),缺省值“ULB” - Name string - - // 负载均衡的业务组名称,缺省值“Default” - Tag string - - // 负载均衡的备注,缺省值“” - Remark string - - // 带宽类型,枚举值为: 0,非共享带宽; 1,共享带宽 - BandwidthType int - - // 带宽 - Bandwidth int - - // ULB的创建时间,格式为Unix Timestamp - CreateTime int - - // ULB的到期时间,格式为Unix Timestamp - ExpireTime int - - // ULB的详细信息列表(废弃) - Resource []string - - // ULB的详细信息列表,具体结构见下方 ULBIPSet - IPSet []ULBIPSet - - // 负载均衡实例中存在的VServer实例列表,具体结构见下方 ULBVServerSet - VServerSet []ULBVServerSet - - // ULB 的类型 - ULBType string - - // ULB所在的VPC的ID - VPCId string - - // ULB 为 InnerMode 时,ULB 所属的子网ID,默认为空 - SubnetId string - - // ULB 所属的业务组ID - BusinessId string - - // ULB的内网IP,当ULBType为OuterMode时,该值为空 - PrivateIP string -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbsslset.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbsslset.go deleted file mode 100644 index a5ec42a2cf..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbsslset.go +++ /dev/null @@ -1,16 +0,0 @@ -package ulb - -/* - ULBSSLSet - DescribeULB - - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. -*/ -type ULBSSLSet struct { - - // SSL证书的Id - SSLId string - - // SSL证书的名字 - SSLName string -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbvserver_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbvserver_set.go deleted file mode 100644 index 752dd83d8f..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbvserver_set.go +++ /dev/null @@ -1,58 +0,0 @@ -package ulb - -/* - ULBVServerSet - DescribeULB - - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. -*/ -type ULBVServerSet struct { - - // VServer实例的Id - VServerId string - - // VServer实例的名字 - VServerName string - - // VServer实例的协议。 枚举值为:HTTP,TCP,UDP,HTTPS。 - Protocol string - - // VServer服务端口 - FrontendPort int - - // VServer负载均衡的模式,枚举值:Roundrobin -> 轮询;Source -> 源地址;ConsistentHash -> 一致性哈希;SourcePort -> 源地址(计算端口);ConsistentHashPort -> 一致性哈希(计算端口)。 - Method string - - // VServer会话保持方式。枚举值为: None -> 关闭会话保持; ServerInsert -> 自动生成; UserDefined -> 用户自定义。 - PersistenceType string - - // 根据PersistenceType确定: None或ServerInsert,此字段为空; UserDefined,此字段展示用户自定义会话string。 - PersistenceInfo string - - // 空闲连接的回收时间,单位:秒。 - ClientTimeout int - - // VServer的运行状态。枚举值: 0 -> rs全部运行正常;1 -> rs部分运行正常;2 -> rs全部运行异常。 - Status int - - // VServer绑定的SSL证书信息,具体结构见下方 ULBSSLSet - SSLSet []ULBSSLSet - - // 后端资源信息列表,具体结构见下方 ULBBackendSet - BackendSet []ULBBackendSet - - // 监听器类型,枚举值为: RequestProxy -> 请求代理;PacketsTransmit -> 报文转发 - ListenType string - - // 内容转发信息列表,具体结构见下方 ULBPolicySet - PolicySet []ULBPolicySet - - // 健康检查的类型,Port:端口,Path:路径 - MonitorType string - - // MonitorType 为 Path 时指定健康检查发送请求时HTTP HEADER 里的域名 - Domain string - - // MonitorType 为 Path 时指定健康检查发送请求时的路径,默认为 / - Path string -} 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 deleted file mode 100644 index 29ffb8dc18..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_backend_attribute.go +++ /dev/null @@ -1,56 +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 ULB UpdateBackendAttribute - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/ucloud/request" - "github.com/ucloud/ucloud-sdk-go/ucloud/response" -) - -// UpdateBackendAttributeRequest is request schema for UpdateBackendAttribute action -type UpdateBackendAttributeRequest struct { - request.CommonBase - - // 负载均衡资源ID - ULBId *string `required:"true"` - - // 后端资源实例的ID(ULB后端ID,非资源自身ID) - BackendId *string `required:"true"` - - // 后端资源服务端口,取值范围[1-65535] - Port *int `required:"false"` - - // 后端实例状态开关 - Enabled *int `required:"false"` -} - -// UpdateBackendAttributeResponse is response schema for UpdateBackendAttribute action -type UpdateBackendAttributeResponse struct { - response.CommonBase -} - -// NewUpdateBackendAttributeRequest will create request of UpdateBackendAttribute action. -func (c *ULBClient) NewUpdateBackendAttributeRequest() *UpdateBackendAttributeRequest { - req := &UpdateBackendAttributeRequest{} - - // 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 -} - -// UpdateBackendAttribute - 更新ULB后端资源实例(服务节点)属性 -func (c *ULBClient) UpdateBackendAttribute(req *UpdateBackendAttributeRequest) (*UpdateBackendAttributeResponse, error) { - var err error - var res UpdateBackendAttributeResponse - - err = c.client.InvokeAction("UpdateBackendAttribute", req, &res) - if err != nil { - return &res, err - } - - return &res, nil -} 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 deleted file mode 100644 index 6b34c7b85b..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_policy.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 ULB UpdatePolicy - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/ucloud/request" - "github.com/ucloud/ucloud-sdk-go/ucloud/response" -) - -// UpdatePolicyRequest is request schema for UpdatePolicy action -type UpdatePolicyRequest struct { - request.CommonBase - - // 需要添加内容转发策略的负载均衡实例ID - ULBId *string `required:"true"` - - // 需要添加内容转发策略的VServer实例ID - VServerId *string `required:"true"` - - // 转发规则的ID - PolicyId *string `required:"true"` - - // 内容转发策略应用的后端资源实例的ID,来源于 AllocateBackend 返回的 BackendId - BackendId []string `required:"true"` - - // 内容转发匹配字段 - Match *string `required:"true"` - - // 内容转发匹配字段的类型 - Type *string `required:"false"` -} - -// UpdatePolicyResponse is response schema for UpdatePolicy action -type UpdatePolicyResponse struct { - response.CommonBase - - // 转发规则的ID - PolicyId string -} - -// NewUpdatePolicyRequest will create request of UpdatePolicy action. -func (c *ULBClient) NewUpdatePolicyRequest() *UpdatePolicyRequest { - req := &UpdatePolicyRequest{} - - // 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 -} - -// UpdatePolicy - 更新内容转发规则,包括转发规则后的服务节点 -func (c *ULBClient) UpdatePolicy(req *UpdatePolicyRequest) (*UpdatePolicyResponse, error) { - var err error - var res UpdatePolicyResponse - - err = c.client.InvokeAction("UpdatePolicy", req, &res) - if err != nil { - return &res, err - } - - return &res, nil -} 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 deleted file mode 100644 index 1af3bbfa34..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_ulbattribute.go +++ /dev/null @@ -1,56 +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 ULB UpdateULBAttribute - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/ucloud/request" - "github.com/ucloud/ucloud-sdk-go/ucloud/response" -) - -// UpdateULBAttributeRequest is request schema for UpdateULBAttribute action -type UpdateULBAttributeRequest struct { - request.CommonBase - - // ULB资源ID - ULBId *string `required:"true"` - - // 名字 - Name *string `required:"false"` - - // 业务 - Tag *string `required:"false"` - - // 备注 - Remark *string `required:"false"` -} - -// UpdateULBAttributeResponse is response schema for UpdateULBAttribute action -type UpdateULBAttributeResponse struct { - response.CommonBase -} - -// NewUpdateULBAttributeRequest will create request of UpdateULBAttribute action. -func (c *ULBClient) NewUpdateULBAttributeRequest() *UpdateULBAttributeRequest { - req := &UpdateULBAttributeRequest{} - - // 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 -} - -// UpdateULBAttribute - 更新ULB名字业务组备注等属性字段 -func (c *ULBClient) UpdateULBAttribute(req *UpdateULBAttributeRequest) (*UpdateULBAttributeResponse, error) { - var err error - var res UpdateULBAttributeResponse - - err = c.client.InvokeAction("UpdateULBAttribute", req, &res) - if err != nil { - return &res, err - } - - return &res, nil -} 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 deleted file mode 100644 index a1120bf13f..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_vserver_attribute.go +++ /dev/null @@ -1,77 +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 ULB UpdateVServerAttribute - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/ucloud/request" - "github.com/ucloud/ucloud-sdk-go/ucloud/response" -) - -// UpdateVServerAttributeRequest is request schema for UpdateVServerAttribute action -type UpdateVServerAttributeRequest struct { - request.CommonBase - - // 负载均衡实例ID - ULBId *string `required:"true"` - - // VServer实例ID - VServerId *string `required:"true"` - - // VServer实例名称,若无此字段则不做修改 - VServerName *string `required:"false"` - - // VServer协议类型,请求代理只支持修改为 HTTP/HTTPS,报文转发VServer只支持修改为 TCP/UDP - Protocol *string `required:"false"` - - // VServer负载均衡算法,ConsistentHash,SourcePort,ConsistentHashPort 只在报文转发中使用;Roundrobin和Source在请求代理和报文转发中使用。 - Method *string `required:"false"` - - // VServer会话保持模式,若无此字段则不做修改。枚举值:None:关闭;ServerInsert:自动生成KEY;UserDefined:用户自定义KEY。 - PersistenceType *string `required:"false"` - - // 根据PersistenceType确定: None或ServerInsert, 此字段无意义; UserDefined, 则此字段传入用户自定义会话保持String. 若无此字段则不做修改 - PersistenceInfo *string `required:"false"` - - // 请求代理的VServer下表示空闲连接的回收时间,单位:秒,取值范围:时(0,86400],默认值为60;报文转发的VServer下表示回话保持的时间,单位:秒,取值范围:[60,900],0 表示禁用连接保持 - ClientTimeout *int `required:"false"` - - // 健康检查的类型,Port:端口,Path:路径 - MonitorType *string `required:"false"` - - // MonitorType 为 Path 时指定健康检查发送请求时HTTP HEADER 里的域名 - Domain *string `required:"false"` - - // MonitorType 为 Path 时指定健康检查发送请求时的路径,默认为 / - Path *string `required:"false"` -} - -// UpdateVServerAttributeResponse is response schema for UpdateVServerAttribute action -type UpdateVServerAttributeResponse struct { - response.CommonBase -} - -// NewUpdateVServerAttributeRequest will create request of UpdateVServerAttribute action. -func (c *ULBClient) NewUpdateVServerAttributeRequest() *UpdateVServerAttributeRequest { - req := &UpdateVServerAttributeRequest{} - - // 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 -} - -// UpdateVServerAttribute - 更新VServer实例属性 -func (c *ULBClient) UpdateVServerAttribute(req *UpdateVServerAttributeRequest) (*UpdateVServerAttributeResponse, error) { - var err error - var res UpdateVServerAttributeResponse - - err = c.client.InvokeAction("UpdateVServerAttribute", req, &res) - if err != nil { - return &res, err - } - - return &res, nil -} 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 4a188f5245..720886febc 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 @@ -32,7 +32,7 @@ type AllocateShareBandwidthRequest struct { type AllocateShareBandwidthResponse struct { response.CommonBase - // 共享带宽 ID + // 共享带宽资源Id ShareBandwidthId string } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/client.go index f0e18a7823..5229752e07 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/client.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/client.go @@ -5,10 +5,12 @@ import ( "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) +// UNetClient is the client of UNet type UNetClient struct { client *ucloud.Client } +// NewClient will return a instance of UNetClient func NewClient(config *ucloud.Config, credential *auth.Credential) *UNetClient { client := ucloud.NewClient(config, credential) return &UNetClient{ 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 ede007d581..e40db899b0 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,7 +12,7 @@ import ( type CreateFirewallRequest struct { request.CommonBase - // 防火墙规则,例如:TCP|22|192.168.1.1/22|DROP|LOW,第一个参数代表协议:第二个参数代表端口号,第三个参数为ip,第四个参数为ACCEPT(接受)和DROP(拒绝),第五个参数优先级:HIGH(高),MEDIUM(中),LOW(低) + // 防火墙规则,例如:TCP|22|192.168.1.1/22|DROP|LOW|禁用22端口,第一个参数代表协议:第二个参数代表端口号,第三个参数为ip,第四个参数为ACCEPT(接受)和DROP(拒绝),第五个参数优先级:HIGH(高),MEDIUM(中),LOW(低),第六个参数为该条规则的自定义备注 Rule []string `required:"true"` // 防火墙名称, 默认为Firewall @@ -29,7 +29,7 @@ type CreateFirewallRequest struct { type CreateFirewallResponse struct { response.CommonBase - // 防火墙 ID + // 防火墙ID FWId string } 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 da4c85bd7b..be0f28e800 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 @@ -29,7 +29,7 @@ type DescribeFirewallResourceResponse struct { // 资源列表,见 ResourceSet ResourceSet []ResourceSet - // 防火墙已绑定资源的总数 + // 绑定资源总数 TotalCount int } 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 3213fb4350..3822c94b57 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 @@ -32,7 +32,7 @@ type DescribeVIPRequest struct { type DescribeVIPResponse struct { response.CommonBase - // 内网VIP详情 + // 内网VIP详情,请见VIPDetailSet VIPSet []VIPDetailSet // 内网VIP地址列表 diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/doc.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/doc.go index f9caeecaa9..ed751644e1 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/doc.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/doc.go @@ -1,11 +1,11 @@ /* - Package unet include resources of ucloud unet product +Package unet include resources of ucloud unet product - See also +See also - - API: https://docs.ucloud.cn/api/unet-api/index - - Product: https://www.ucloud.cn/site/product/unet.html + - API: https://docs.ucloud.cn/api/unet-api/index + - Product: https://www.ucloud.cn/site/product/unet.html - for detail. +for detail. */ package unet 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 8d511701a7..463104bebb 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,10 +1,10 @@ package unet /* - EIPAddrSet - DescribeShareBandwidth +EIPAddrSet - DescribeShareBandwidth - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +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 { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_eippay_mode_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_eippay_mode_set.go index 37f03b9af9..801e52dea0 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_eippay_mode_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_eippay_mode_set.go @@ -1,10 +1,10 @@ package unet /* - EIPPayModeSet - GetEIPPayModeEIP +EIPPayModeSet - GetEIPPayModeEIP - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type EIPPayModeSet struct { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_eipprice_detail_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_eipprice_detail_set.go index cc5f86498f..55ce1a2ac4 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_eipprice_detail_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_eipprice_detail_set.go @@ -1,10 +1,10 @@ package unet /* - EIPPriceDetailSet - GetEIPPrice +EIPPriceDetailSet - GetEIPPrice - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type EIPPriceDetailSet struct { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_eipset_data.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_eipset_data.go index 9235d53cb1..136d8d9529 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_eipset_data.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_eipset_data.go @@ -1,15 +1,15 @@ package unet /* - EIPSetData - describeShareBandwidth +EIPSetData - describeShareBandwidth - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type EIPSetData struct { // EIP带宽值 - Badnwidth int + Bandwidth int // EIP的IP信息,详情见EIPAddrSet EIPAddr []EIPAddrSet diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_firewall_data_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_firewall_data_set.go index 6157ff5d84..887db5f066 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_firewall_data_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_firewall_data_set.go @@ -1,13 +1,19 @@ package unet /* - FirewallDataSet - DescribeFirewall +FirewallDataSet - DescribeFirewall - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type FirewallDataSet struct { + // 防火墙ID + FWId string + + // 安全组ID(即将废弃) + GroupId string + // 防火墙名称 Name string @@ -28,10 +34,4 @@ type FirewallDataSet struct { // 防火墙组中的规则列表,参见 FirewallRuleSet Rule []FirewallRuleSet - - // 防火墙 ID - FWId string - - // 安全组 ID(即将弃用) - GroupId string } 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 fa1e9e2fc3..53bf2fb62e 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 @@ -1,10 +1,10 @@ package unet /* - FirewallRuleSet - DescribeFirewall +FirewallRuleSet - DescribeFirewall - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type FirewallRuleSet struct { 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 9e7b5ee9bd..3231584d5c 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 @@ -1,10 +1,10 @@ package unet /* - ResourceSet - 资源信息 +ResourceSet - 资源信息 - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type ResourceSet struct { @@ -23,7 +23,7 @@ type ResourceSet struct { // 绑定资源的资源类型 ResourceType string - // 资源状态 + // 状态 Status int // 业务组 diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_share_bandwidth_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_share_bandwidth_set.go index 8881547699..2e34097a78 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_share_bandwidth_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_share_bandwidth_set.go @@ -1,10 +1,10 @@ package unet /* - ShareBandwidthSet - DescribeEIP +ShareBandwidthSet - DescribeEIP - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type ShareBandwidthSet struct { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_allocate_eipset.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_allocate_eipset.go index ef720e98dd..7e8d70d23c 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_allocate_eipset.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_allocate_eipset.go @@ -1,10 +1,10 @@ package unet /* - UnetAllocateEIPSet - AllocateEIP +UnetAllocateEIPSet - AllocateEIP - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type UnetAllocateEIPSet struct { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_bandwidth_package_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_bandwidth_package_set.go index c742ca6a53..7769f399b5 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_bandwidth_package_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_bandwidth_package_set.go @@ -1,10 +1,10 @@ package unet /* - UnetBandwidthPackageSet - DescribeBandwidthPackage +UnetBandwidthPackageSet - DescribeBandwidthPackage - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type UnetBandwidthPackageSet struct { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_bandwidth_usage_eipset.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_bandwidth_usage_eipset.go index 5a37ce65f0..3da7917e16 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_bandwidth_usage_eipset.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_bandwidth_usage_eipset.go @@ -1,10 +1,10 @@ package unet /* - UnetBandwidthUsageEIPSet - DescribeBandwidthUsage +UnetBandwidthUsageEIPSet - DescribeBandwidthUsage - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type UnetBandwidthUsageEIPSet struct { 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 0da957fda0..6f53fef5d7 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,10 +1,10 @@ package unet /* - UnetEIPAddrSet - DescribeEIP +UnetEIPAddrSet - DescribeEIP - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +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 { 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 24bc7cbb18..4746a5ed8d 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 @@ -1,10 +1,10 @@ package unet /* - UnetEIPResourceSet - DescribeEIP +UnetEIPResourceSet - DescribeEIP - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type UnetEIPResourceSet struct { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipset.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipset.go index 670c944853..d3f94714d6 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipset.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipset.go @@ -1,10 +1,10 @@ package unet /* - UnetEIPSet - DescribeEIP +UnetEIPSet - DescribeEIP - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type UnetEIPSet struct { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_share_bandwidth_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_share_bandwidth_set.go index ddd27f519f..7b568115e7 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_share_bandwidth_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_share_bandwidth_set.go @@ -1,10 +1,10 @@ package unet /* - UnetShareBandwidthSet - DescribeShareBandwidth +UnetShareBandwidthSet - DescribeShareBandwidth - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type UnetShareBandwidthSet struct { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_vipdetail_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_vipdetail_set.go index 92fd860525..44bcbf41a4 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_vipdetail_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_vipdetail_set.go @@ -1,22 +1,22 @@ package unet /* - VIPDetailSet - VIPDetailSet +VIPDetailSet - VIPDetailSet - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type VIPDetailSet struct { + // 地域 + Zone string + // 虚拟ip id VIPId string // 创建时间 CreateTime int - // 地域 - Zone string - // 真实主机ip RealIp string diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_vipset.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_vipset.go index 14cf3f77d6..af95ff8b3f 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_vipset.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_vipset.go @@ -1,10 +1,10 @@ package unet /* - VIPSet - VIPSet +VIPSet - VIPSet - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type VIPSet struct { 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 382c955625..8d96a55df3 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 @@ -15,7 +15,7 @@ type UpdateFirewallRequest struct { // 防火墙资源ID FWId *string `required:"true"` - // 防火墙规则,例如:TCP|22|192.168.1.1/22|DROP|LOW,第一个参数代表协议:第二个参数代表端口号,第三个参数为ip,第四个参数为ACCEPT(接受)和DROP(拒绝),第五个参数优先级:HIGH(高),MEDIUM(中),LOW(低) + // 防火墙规则,例如:TCP|22|192.168.1.1/22|DROP|LOW|禁用22端口,第一个参数代表协议:第二个参数代表端口号,第三个参数为ip,第四个参数为ACCEPT(接受)和DROP(拒绝),第五个参数优先级:HIGH(高),MEDIUM(中),LOW(低),第六个参数为该条规则的自定义备注 Rule []string `required:"true"` } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/client.go index 7adc020257..2405223832 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/client.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/client.go @@ -5,10 +5,12 @@ import ( "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) +// VPCClient is the client of VPC2.0 type VPCClient struct { client *ucloud.Client } +// NewClient will return a instance of VPCClient func NewClient(config *ucloud.Config, credential *auth.Credential) *VPCClient { client := ucloud.NewClient(config, credential) return &VPCClient{ diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/doc.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/doc.go index f107ed1d2f..8ab0f1da1e 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/doc.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/doc.go @@ -1,4 +1,4 @@ /* - Package vpc include resources of ucloud vpc 2.0 product +Package vpc include resources of ucloud vpc 2.0 product */ package vpc diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_resource_info.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_resource_info.go index a29cf9e980..69bfdad63e 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_resource_info.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_resource_info.go @@ -1,10 +1,10 @@ package vpc /* - ResourceInfo - 资源信息 +ResourceInfo - 资源信息 - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type ResourceInfo struct { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_vpcintercom_info.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_vpcintercom_info.go index f18037540a..600e4e899b 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_vpcintercom_info.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_vpcintercom_info.go @@ -1,10 +1,10 @@ package vpc /* - VPCIntercomInfo - +VPCIntercomInfo - - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type VPCIntercomInfo struct { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_vpcsubnet_info_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_vpcsubnet_info_set.go index 1dff1c0511..77bd78eed2 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_vpcsubnet_info_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_vpcsubnet_info_set.go @@ -1,10 +1,10 @@ package vpc /* - VPCSubnetInfoSet - DescribeSubnet +VPCSubnetInfoSet - DescribeSubnet - this model is auto created by ucloud code generater for open api, - you can also see https://docs.ucloud.cn for detail. +this model is auto created by ucloud code generater for open api, +you can also see https://docs.ucloud.cn for detail. */ type VPCSubnetInfoSet struct { 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 6722a77af5..f6147f2490 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/client.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/client.go @@ -6,6 +6,8 @@ package ucloud import ( "time" + "github.com/ucloud/ucloud-sdk-go/private/utils" + "github.com/ucloud/ucloud-sdk-go/private/protocol/http" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" "github.com/ucloud/ucloud-sdk-go/ucloud/log" @@ -48,6 +50,11 @@ func (c *Client) GetConfig() *Config { // InvokeAction will do an action request from a request struct and set response value into res struct pointer func (c *Client) InvokeAction(action string, req request.Common, resp response.Common) error { + return c.InvokeActionWithPatcher(action, req, resp, utils.RetCodePatcher) +} + +// InvokeActionWithPatcher will invoke action by patchers +func (c *Client) InvokeActionWithPatcher(action string, req request.Common, resp response.Common, patches ...utils.Patch) error { req.SetAction(action) req.SetRequestTime(time.Now()) @@ -68,7 +75,14 @@ func (c *Client) InvokeAction(action string, req request.Common, resp response.C httpResp, err = handler(c, httpReq, httpResp, err) } - err = c.unmarshalHTTPReponse(httpResp, resp) + // 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) + } + + err = c.unmarshalHTTPReponse(body, resp) if err != nil { return err } 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 16f1d249a5..a0faa6dbc5 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/config.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/config.go @@ -6,11 +6,16 @@ import ( "github.com/ucloud/ucloud-sdk-go/ucloud/log" ) +// Config is the config of ucloud sdk, use for setting up client type Config struct { // Region is the region of backend service // See also ... Region string `default:""` + // Zone is the zone of backend service + // See also ... + Zone string `default:""` + // ProjectId is the unique identify of project, used for organize resources, // Most of resources should belong to a project. // Sub-Account must have an project id. diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/error/server_error.go b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/error/server_error.go index 14b2b94654..f2cdc9bd6c 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/error/server_error.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/error/server_error.go @@ -7,8 +7,10 @@ import ( ) var ( + // ErrHTTPStatus is error type of http status ErrHTTPStatus = "server.HTTPStatusError" - ErrRetCode = "server.RetCodeError" + // ErrRetCode is error type of server return code is larger than 0 + ErrRetCode = "server.RetCodeError" ) // ServerError is the ucloud common error for server response @@ -62,7 +64,7 @@ func (e ServerError) Code() int { return e.retCode } -// HTTPStatusCode will return http status code +// StatusCode will return http status code func (e ServerError) StatusCode() int { return e.statusCode } @@ -82,8 +84,8 @@ func (e ServerError) Retryable() bool { return isIn(e.statusCode, []int{429, 502, 503, 504}) || e.retryable } -func isIn(i int, avaliables []int) bool { - for _, v := range avaliables { +func isIn(i int, availables []int) bool { + for _, v := range availables { if i == v { return true } 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 7834c9e6cc..2d58a1c3a5 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 @@ -19,6 +19,7 @@ func Init(level Level) { }) } +// Level is the log level of sdk logger type Level logrus.Level var ( 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 04a2afdca9..68c53ccb45 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/marshaler.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/marshaler.go @@ -3,7 +3,6 @@ package ucloud import ( "encoding/json" "fmt" - "regexp" "runtime" "github.com/pkg/errors" @@ -25,6 +24,10 @@ func (c *Client) SetupRequest(req request.Common) request.Common { req.SetRegion(cfg.Region) } + if len(req.GetZone()) == 0 && len(cfg.Zone) > 0 { + req.SetZone(cfg.Zone) + } + if len(req.GetProjectId()) == 0 && len(cfg.ProjectId) > 0 { req.SetProjectId(cfg.ProjectId) } @@ -47,10 +50,10 @@ func (c *Client) buildHTTPRequest(req request.Common) (*http.HttpRequest, error) return nil, errors.Errorf("convert request to map failed, %s", err) } - // check credential information is avaliable + // check credential information is available credential := c.GetCredential() if credential == nil { - return nil, errors.Errorf("invalid credential infomation, please set it before request.") + return nil, errors.Errorf("invalid credential information, please set it before request.") } config := c.GetConfig() @@ -71,18 +74,10 @@ func (c *Client) buildHTTPRequest(req request.Common) (*http.HttpRequest, error) } // unmarshalHTTPReponse will get body from http response and unmarshal it's data into response struct -func (c *Client) unmarshalHTTPReponse(httpResp *http.HttpResponse, resp response.Common) error { - body := httpResp.GetBody() +func (c *Client) unmarshalHTTPReponse(body []byte, resp response.Common) error { if len(body) < 0 { return nil } - body = patchForRetCodeString(body) - return json.Unmarshal([]byte(body), &resp) -} - -var patchForCodePattern = regexp.MustCompile(`"RetCode":\s*"(\d+)"`) - -func patchForRetCodeString(body []byte) []byte { - return patchForCodePattern.ReplaceAll(body, []byte(`"RetCode": $1`)) + return json.Unmarshal(body, &resp) } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/request/common.go b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/request/common.go index c2fbbf6657..2d18a7abe6 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/request/common.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/ucloud/request/common.go @@ -16,6 +16,9 @@ type Common interface { GetProjectId() string SetProjectId(string) error + GetZone() string + SetZone(string) error + SetRetryCount(int) GetRetryCount() int @@ -36,6 +39,7 @@ type Common interface { type CommonBase struct { Action *string Region *string + Zone *string ProjectId *string maxRetries int @@ -124,6 +128,20 @@ func (c *CommonBase) SetRegion(val string) error { return nil } +// GetZone will return zone of request +func (c *CommonBase) GetZone() string { + if c.Zone == nil { + return "" + } + return *c.Zone +} + +// SetZone will set zone of request +func (c *CommonBase) SetZone(val string) error { + c.Zone = &val + return nil +} + // GetProjectId will get project id of request func (c *CommonBase) GetProjectId() string { if c.ProjectId == 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 130c325d35..bfb012beb2 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.5.7" +const Version = "0.6.2" diff --git a/vendor/vendor.json b/vendor/vendor.json index 8f17e0e52e..f5941f62bf 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -33,106 +33,112 @@ "revisionTime": "2018-06-01T13:25:42Z" }, { - "checksumSHA1": "CM3d5OmqPG8/5JSZ4iDintmOxPY=", + "checksumSHA1": "THNAbJj3DHSRxNJh5ZGJjbNtzBI=", "path": "github.com/ucloud/ucloud-sdk-go/private/protocol/http", - "revision": "ae92fcdf66a5f34c27d8ae1f81b10033648275f4", - "revisionTime": "2018-10-24T10:31:01Z" + "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", + "revisionTime": "2018-11-21T10:11:50Z" }, { - "checksumSHA1": "cXu7QmFV8l7353qEiDeYyi4r54g=", + "checksumSHA1": "gvEfWRCM4e9t6XoaLM0epW3vnmE=", + "path": "github.com/ucloud/ucloud-sdk-go/private/services/udisk", + "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", + "revisionTime": "2018-11-21T10:11:50Z" + }, + { + "checksumSHA1": "6VGaaGQb6mJv9DJdl+DJUeIjHD0=", + "path": "github.com/ucloud/ucloud-sdk-go/private/services/uhost", + "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", + "revisionTime": "2018-11-21T10:11:50Z" + }, + { + "checksumSHA1": "7d7zSGzF3PLkOenjzNpm4qp08vc=", "path": "github.com/ucloud/ucloud-sdk-go/private/utils", - "revision": "ae92fcdf66a5f34c27d8ae1f81b10033648275f4", - "revisionTime": "2018-10-24T10:31:01Z" + "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", + "revisionTime": "2018-11-21T10:11:50Z" }, { - "checksumSHA1": "yMCT15wmLZ0Jtf8w0qgc8fGbS8A=", + "checksumSHA1": "A8H7kEMjrdhpEvbK21+RLBCCd24=", "path": "github.com/ucloud/ucloud-sdk-go/services/pathx", - "revision": "ae92fcdf66a5f34c27d8ae1f81b10033648275f4", - "revisionTime": "2018-10-24T10:31:01Z" + "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", + "revisionTime": "2018-11-21T10:11:50Z" }, { - "checksumSHA1": "DtQemSHmV3oVhUgqes+4rTSQ0bU=", + "checksumSHA1": "dyL5BqmH44GkLhHexeEfY1QXeVc=", "path": "github.com/ucloud/ucloud-sdk-go/services/uaccount", - "revision": "ae92fcdf66a5f34c27d8ae1f81b10033648275f4", - "revisionTime": "2018-10-24T10:31:01Z" + "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", + "revisionTime": "2018-11-21T10:11:50Z" }, { - "checksumSHA1": "/Q1QxXVSDx6egkzPBI4PxxBgpUI=", + "checksumSHA1": "qD7m2MHO4UJ/m/2fC1PWQsWgeRQ=", "path": "github.com/ucloud/ucloud-sdk-go/services/udisk", - "revision": "ae92fcdf66a5f34c27d8ae1f81b10033648275f4", - "revisionTime": "2018-10-24T10:31:01Z" + "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", + "revisionTime": "2018-11-21T10:11:50Z" }, { - "checksumSHA1": "mT4ix7tzri+ORhkQDUvNvRuGK4Y=", + "checksumSHA1": "1misM0pqLF7LVdkEtemvhvAs+nQ=", "path": "github.com/ucloud/ucloud-sdk-go/services/uhost", - "revision": "ae92fcdf66a5f34c27d8ae1f81b10033648275f4", - "revisionTime": "2018-10-24T10:31:01Z" - }, - { - "checksumSHA1": "xRS1wB0vZYNXb32v1gUZOjxULa8=", - "path": "github.com/ucloud/ucloud-sdk-go/services/ulb", - "revision": "ae92fcdf66a5f34c27d8ae1f81b10033648275f4", - "revisionTime": "2018-10-24T10:31:01Z" + "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", + "revisionTime": "2018-11-21T10:11:50Z" }, { - "checksumSHA1": "QbXRY5SSHJ7fMidexqgzQvseEBE=", + "checksumSHA1": "rTHjcXtmwEqyvuTz0gxXANcPoOc=", "path": "github.com/ucloud/ucloud-sdk-go/services/unet", - "revision": "ae92fcdf66a5f34c27d8ae1f81b10033648275f4", - "revisionTime": "2018-10-24T10:31:01Z" + "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", + "revisionTime": "2018-11-21T10:11:50Z" }, { - "checksumSHA1": "LnJNShxWW+DLunVWzgfaGa2+lSY=", + "checksumSHA1": "ehgKHU9X7+3T8JAkPrB8LHesNBU=", "path": "github.com/ucloud/ucloud-sdk-go/services/vpc", - "revision": "ae92fcdf66a5f34c27d8ae1f81b10033648275f4", - "revisionTime": "2018-10-24T10:31:01Z" + "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", + "revisionTime": "2018-11-21T10:11:50Z" }, { - "checksumSHA1": "UdftGOVglTitYFfgIsnk+MKu9x4=", + "checksumSHA1": "Q45sgjS2JMVzJPZSasoy18x5Sak=", "path": "github.com/ucloud/ucloud-sdk-go/ucloud", - "revision": "ae92fcdf66a5f34c27d8ae1f81b10033648275f4", - "revisionTime": "2018-10-24T10:31:01Z" + "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", + "revisionTime": "2018-11-21T10:11:50Z" }, { "checksumSHA1": "SYdYJOqUQHfcEMAOSQok5aQ+xGU=", "path": "github.com/ucloud/ucloud-sdk-go/ucloud/auth", - "revision": "ae92fcdf66a5f34c27d8ae1f81b10033648275f4", - "revisionTime": "2018-10-24T10:31:01Z" + "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", + "revisionTime": "2018-11-21T10:11:50Z" }, { - "checksumSHA1": "RqE8dhOl1gwfHj5e9X09VDa9VE8=", + "checksumSHA1": "OYlW/BJ3hfOqZoAM3IuqP/R+N/Q=", "path": "github.com/ucloud/ucloud-sdk-go/ucloud/error", - "revision": "ae92fcdf66a5f34c27d8ae1f81b10033648275f4", - "revisionTime": "2018-10-24T10:31:01Z" + "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", + "revisionTime": "2018-11-21T10:11:50Z" }, { "checksumSHA1": "WMTXD2ama/EmXjmBbAheUSie7P4=", "path": "github.com/ucloud/ucloud-sdk-go/ucloud/helpers/waiter", - "revision": "ae92fcdf66a5f34c27d8ae1f81b10033648275f4", - "revisionTime": "2018-10-24T10:31:01Z" + "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", + "revisionTime": "2018-11-21T10:11:50Z" }, { - "checksumSHA1": "ExftuufZDUOoEt4LlBX/GVYz3W4=", + "checksumSHA1": "H4lbTse9PlCXOogfpLCpqXSD8iE=", "path": "github.com/ucloud/ucloud-sdk-go/ucloud/log", - "revision": "ae92fcdf66a5f34c27d8ae1f81b10033648275f4", - "revisionTime": "2018-10-24T10:31:01Z" + "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", + "revisionTime": "2018-11-21T10:11:50Z" }, { - "checksumSHA1": "vJhTZT1X5lIdwqmZEWekIGs8tbw=", + "checksumSHA1": "subTc2MHCUgBF9kDR0GOOivl7hI=", "path": "github.com/ucloud/ucloud-sdk-go/ucloud/request", - "revision": "ae92fcdf66a5f34c27d8ae1f81b10033648275f4", - "revisionTime": "2018-10-24T10:31:01Z" + "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", + "revisionTime": "2018-11-21T10:11:50Z" }, { "checksumSHA1": "UYVTJ2g0IVPxfhSUS0l0/RHyrGg=", "path": "github.com/ucloud/ucloud-sdk-go/ucloud/response", - "revision": "ae92fcdf66a5f34c27d8ae1f81b10033648275f4", - "revisionTime": "2018-10-24T10:31:01Z" + "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", + "revisionTime": "2018-11-21T10:11:50Z" }, { - "checksumSHA1": "DYRmPB3XGrNFOa0zhPDnHxge4gE=", + "checksumSHA1": "fBACuzKR1u0WMySyxLrIWCByRUI=", "path": "github.com/ucloud/ucloud-sdk-go/ucloud/version", - "revision": "ae92fcdf66a5f34c27d8ae1f81b10033648275f4", - "revisionTime": "2018-10-24T10:31:01Z" + "revision": "e4a5beab94162b24b60e41b3df8bc8e565144030", + "revisionTime": "2018-11-21T10:11:50Z" }, { "checksumSHA1": "BGm8lKZmvJbf/YOJLeL1rw2WVjA=",