diff --git a/CHANGELOG.md b/CHANGELOG.md index ca5856194b..3979ba3f6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ ## Change Log +v0.1.3 +* integrate auto completion. +* Support uhost create, stop, delete and so on. + +v0.1.2 +* simplify config and completion. + v0.1.1 * UHost list; EIP list,delete and allocate; GlobalSSH list,delete,modify and create. \ No newline at end of file diff --git a/Makefile b/Makefile index 97306a0ed9..3e2bec1d02 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -export VERSION=0.1.2 +export VERSION=0.1.3 .PHONY : build build: - go install && mv ../../../../bin/ucloud-cli ../../../../bin/ucloud + go install && mv ../../../../bin/ucloud-cli /usr/local/bin/ucloud .PHONY : build_mac build_mac: diff --git a/README.md b/README.md index b982b18796..fd70da311b 100644 --- a/README.md +++ b/README.md @@ -12,27 +12,6 @@ You can use [Homebrew](https://brew.sh/) on macOS or [Linuxbrew](http://linuxbre ``` brew install ucloud ``` - -##### Download binary file -Archive links: -[Mac](http://ucloud-sdk.ufile.ucloud.com.cn/ucloud-cli-macosx-0.1.2-amd64.tgz) -[Linux](http://ucloud-sdk.ufile.ucloud.com.cn/ucloud-cli-linux-0.1.2-amd64.tgz) -[Windows](http://ucloud-sdk.ufile.ucloud.com.cn/ucloud-cli-windows-0.1.2-amd64.zip) - -SHA-256 checksum -``` -19b7a0803fc41ee689797a36fd67b288e993c383edf6087f56825a4d5bb17875 ucloud-cli-linux-0.1.2-amd64.tgz -ecc787f4045ea14d583801cd0cfa746be357d50756c2cf0ba879e405c2325d1c ucloud-cli-macosx-0.1.2-amd64.tgz -f48058ac96bb0283b18c660f0350eedba49d03a753775b0a2773b2081698b3f3 ucloud-cli-windows-0.1.2-amd64.zip -``` - -Download the binary file and extract to /usr/local/bin directory or add it to the $PATH. Take macOS as an example. -``` -$ curl -o ucloud-cli.tgz http://ucloud-sdk.ufile.ucloud.com.cn/ucloud-cli-macosx-0.1.2-amd64.tgz -$ echo "ecc787f4045ea14d583801cd0cfa746be357d50756c2cf0ba879e405c2325d1c *ucloud-cli-macosx-0.1.2-amd64.tgz" | shasum -a 256 -c -$ tar -zxf ucloud-cli.tgz -$ cp ucloud /usr/local/bin -``` ##### Build from source code If you have installed golang, run the following commands to install the UCloud CLI. @@ -45,12 +24,26 @@ $ cd ucloud-cli $ make install ``` +### Uninstall UCloud CLI + +Remove the executable file /usr/local/bin/ucloud and the directory $HOME/.ucloud + ### Config UCloud CLI -After install the cli, run 'ucloud config' to complete the cli configuration following the tips. Local settings will be saved in directory $HOME/.ucloud -Command 'ucloud ls --object [region|project]' display all the regions and projects. You can change the default region and prject by runing 'ucloud config set [region|project] xxx'. -Execute 'ucloud config --help' for more information. +After install the cli, run 'ucloud init' to complete the cli configuration following the tips. Local settings will be saved in directory $HOME/.ucloud -### Uninstall UCloud CLI +### Auto complete +Run 'ucloud --completion' for help -Remove the executable file /usr/local/bin/ucloud and the directory $HOME/.ucloud +#### Bash shell +Please append the following scripts to file ~/.bash_profile or ~/.bashrc. +``` +complete -C /usr/local/bin/ucloud ucloud +``` + +#### Zsh shell +Please append the following scripts to file ~/.zshrc. +``` +autoload -U +X bashcompinit && bashcompinit +complete -F /usr/local/bin/ucloud ucloud +``` \ No newline at end of file diff --git a/cmd/completion.go b/cmd/completion.go index 7ade3b5b3b..24bad7d2f4 100644 --- a/cmd/completion.go +++ b/cmd/completion.go @@ -15,9 +15,7 @@ package cmd import ( - "bytes" "fmt" - "io" "os" "os/exec" "regexp" @@ -25,43 +23,22 @@ import ( "strings" "github.com/spf13/cobra" - "github.com/ucloud/ucloud-cli/util" + . "github.com/ucloud/ucloud-cli/util" ) // NewCmdCompletion ucloud completion func NewCmdCompletion() *cobra.Command { - var desc = `Description: - On macOS, using bash - - On macOS, you will need to install bash-completion support via Homebrew first: - $ ucloud completion - $ brew install bash-completion - Follow the “caveats” section of brew’s output to add the appropriate bash completion path to your local .bash_profile. - and then generate bash completion scripts for ucloud - - On Linux, using bash - - On Linux, you may need to install the bash-completion package which is not installed by default. - $ ucloud completion - $ yum install bash-completion or apt-get install bash-completion - and then genreate bash completion scripts for ucloud - - Using zsh - > ucloud completion - - Restart session after auto completion -` var completionCmd = &cobra.Command{ Use: "completion", - Short: "Generates bash/zsh completion scripts", - Long: desc, + Short: "Turn on auto completion according to the prompt", + Long: "Turn on auto completion according to the prompt", Run: func(cmd *cobra.Command, args []string) { shell, ok := os.LookupEnv("SHELL") if ok { if strings.HasSuffix(shell, "bash") { - bashCompletion(cmd.Parent()) + bashCompletion(cmd) } else if strings.HasSuffix(shell, "zsh") { - zshCompletion(cmd.Parent()) + zshCompletion(cmd) } else { fmt.Println("Unknow shell: %", shell) } @@ -73,32 +50,43 @@ func NewCmdCompletion() *cobra.Command { return completionCmd } -var darwinBash = ` -Install bash-completion with command 'brew install bash-completion', and then append the following scripts to ~/.bash_profile +func bashCompletion(cmd *cobra.Command) { + platform := runtime.GOOS + if platform == "darwin" { + fmt.Println(`Please append 'complete -C /usr/local/bin/ucloud ucloud' to file '~/.bash_profile' +If the following scripts are included in '~/.bash_profile', please remove it. Those scripts used to auto complete words before ucloud cli v0.1.3" if [ -f $(brew --prefix)/etc/bash_completion ]; then . $(brew --prefix)/etc/bash_completion fi +source ~/.ucloud/ucloud.sh`) -source ~/.ucloud/ucloud.sh -` - -var linuxBash = ` -Ensure your have installed bash-completion, and then append the following scripts to ~/.bashrc + } else if platform == "linux" { + fmt.Println(`Please append 'complete -C /usr/local/bin/ucloud ucloud' to file '~/.bashrc' +If the following scripts are included in '~/.bashrc', please remove it. Those scripts used to auto complete words before ucloud cli v0.1.3" if [ -f /etc/bash_completion ]; then . /etc/bash_completion fi -source ~/.ucloud/ucloud.sh -` +source ~/.ucloud/ucloud.sh`) + } +} + +func zshCompletion(cmd *cobra.Command) { + fmt.Println(`Please append the following scripts to file '~/.zshrc'. +autoload -U +X bashcompinit && bashcompinit +complete -F /usr/local/bin/ucloud ucloud`) + fmt.Println("If the following scripts are included in '~/.bash_profile' or '~/.bashrc', please remove it. The scripts used to auto complete words before ucloud cli v0.1.3") + fmt.Printf("fpath=(~/%s $fpath)\n", ConfigPath) + fmt.Println("autoload -U +X compinit && compinit") +} func getBashVersion() (version string, err error) { lookupBashVersion := exec.Command("bash", "-version") out, err := lookupBashVersion.Output() if err != nil { - context.AppendError(err) - fmt.Println(err) + Cxt.PrintErr(err) } // Example @@ -119,202 +107,3 @@ func getBashVersion() (version string, err error) { } return } - -func bashCompletion(cmd *cobra.Command) { - home := util.GetHomePath() - shellPath := home + "/" + util.ConfigPath + "/ucloud.sh" - cmd.GenBashCompletionFile(shellPath) - fmt.Printf("Completion scripts has been written to '~/%s/ucloud.sh'\n", util.ConfigPath) - - platform := runtime.GOOS - - if platform == "darwin" { - fmt.Println(darwinBash) - } else if platform == "linux" { - fmt.Println(linuxBash) - } -} - -func zshCompletion(cmd *cobra.Command) { - home := util.GetHomePath() - shellPath := home + "/" + util.ConfigPath + "/_ucloud" - file, err := os.Create(shellPath) - if err != nil { - fmt.Println(err) - context.AppendError(err) - return - } - defer file.Close() - - runCompletionZsh(file, cmd) - fmt.Printf("Completion scripts was written to '~/%s/_ucloud'\n", util.ConfigPath) - - scripts := fmt.Sprintf("fpath=(~/%s $fpath)\n", util.ConfigPath) - scripts += "autoload -U +X compinit && compinit" - fmt.Printf("Please append the following scripts to your ~/.zshrc\n%s\n", scripts) -} - -//参考自 k8s.io/kubernetes/pkg/kubectl/cmd/completion.go -func runCompletionZsh(out io.Writer, cmd *cobra.Command) error { - zsh_head := "#compdef ucloud\n" - - out.Write([]byte(zsh_head)) - - zsh_initialization := ` -__ucloud_bash_source() { - alias shopt=':' - alias _expand=_bash_expand - alias _complete=_bash_comp - emulate -L sh - setopt kshglob noshglob braceexpand - - source "$@" -} - -__ucloud_type() { - # -t is not supported by zsh - if [ "$1" == "-t" ]; then - shift - - # fake Bash 4 to disable "complete -o nospace". Instead - # "compopt +-o nospace" is used in the code to toggle trailing - # spaces. We don't support that, but leave trailing spaces on - # all the time - if [ "$1" = "__ucloud_compopt" ]; then - echo builtin - return 0 - fi - fi - type "$@" -} - -__ucloud_compgen() { - local completions w - completions=( $(compgen "$@") ) || return $? - - # filter by given word as prefix - while [[ "$1" = -* && "$1" != -- ]]; do - shift - shift - done - if [[ "$1" == -- ]]; then - shift - fi - for w in "${completions[@]}"; do - if [[ "${w}" = "$1"* ]]; then - echo "${w}" - fi - done -} - -__ucloud_compopt() { - true # don't do anything. Not supported by bashcompinit in zsh -} - -__ucloud_ltrim_colon_completions() -{ - if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then - # Remove colon-word prefix from COMPREPLY items - local colon_word=${1%${1##*:}} - local i=${#COMPREPLY[*]} - while [[ $((--i)) -ge 0 ]]; do - COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"} - done - fi -} - -__ucloud_get_comp_words_by_ref() { - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[${COMP_CWORD}-1]}" - words=("${COMP_WORDS[@]}") - cword=("${COMP_CWORD[@]}") -} - -__ucloud_filedir() { - local RET OLD_IFS w qw - - __ucloud_debug "_filedir $@ cur=$cur" - if [[ "$1" = \~* ]]; then - # somehow does not work. Maybe, zsh does not call this at all - eval echo "$1" - return 0 - fi - - OLD_IFS="$IFS" - IFS=$'\n' - if [ "$1" = "-d" ]; then - shift - RET=( $(compgen -d) ) - else - RET=( $(compgen -f) ) - fi - IFS="$OLD_IFS" - - IFS="," __ucloud_debug "RET=${RET[@]} len=${#RET[@]}" - - for w in ${RET[@]}; do - if [[ ! "${w}" = "${cur}"* ]]; then - continue - fi - if eval "[[ \"\${w}\" = *.$1 || -d \"\${w}\" ]]"; then - qw="$(__ucloud_quote "${w}")" - if [ -d "${w}" ]; then - COMPREPLY+=("${qw}/") - else - COMPREPLY+=("${qw}") - fi - fi - done -} - -__ucloud_quote() { - if [[ $1 == \'* || $1 == \"* ]]; then - # Leave out first character - printf %q "${1:1}" - else - printf %q "$1" - fi -} - -autoload -U +X bashcompinit && bashcompinit - -# use word boundary patterns for BSD or GNU sed -LWORD='[[:<:]]' -RWORD='[[:>:]]' -if sed --help 2>&1 | grep -q GNU; then - LWORD='\<' - RWORD='\>' -fi - -__ucloud_convert_bash_to_zsh() { - sed \ - -e 's/declare -F/whence -w/' \ - -e 's/_get_comp_words_by_ref "\$@"/_get_comp_words_by_ref "\$*"/' \ - -e 's/local \([a-zA-Z0-9_]*\)=/local \1; \1=/' \ - -e 's/flags+=("\(--.*\)=")/flags+=("\1"); two_word_flags+=("\1")/' \ - -e 's/must_have_one_flag+=("\(--.*\)=")/must_have_one_flag+=("\1")/' \ - -e "s/${LWORD}_filedir${RWORD}/__ucloud_filedir/g" \ - -e "s/${LWORD}_get_comp_words_by_ref${RWORD}/__ucloud_get_comp_words_by_ref/g" \ - -e "s/${LWORD}__ltrim_colon_completions${RWORD}/__ucloud_ltrim_colon_completions/g" \ - -e "s/${LWORD}compgen${RWORD}/__ucloud_compgen/g" \ - -e "s/${LWORD}compopt${RWORD}/__ucloud_compopt/g" \ - -e "s/${LWORD}declare${RWORD}/builtin declare/g" \ - -e "s/\\\$(type${RWORD}/\$(__ucloud_type/g" \ - <<'BASH_COMPLETION_EOF' -` - out.Write([]byte(zsh_initialization)) - - buf := new(bytes.Buffer) - cmd.GenBashCompletion(buf) - out.Write(buf.Bytes()) - - zsh_tail := ` -BASH_COMPLETION_EOF -} - -__ucloud_bash_source <(__ucloud_convert_bash_to_zsh) -_complete ucloud 2>/dev/null -` - out.Write([]byte(zsh_tail)) - return nil -} diff --git a/cmd/configure.go b/cmd/configure.go index b119a009af..fce8063591 100644 --- a/cmd/configure.go +++ b/cmd/configure.go @@ -16,19 +16,19 @@ package cmd import ( "fmt" + "reflect" "strings" "github.com/spf13/cobra" - "github.com/ucloud/ucloud-cli/model" + . "github.com/ucloud/ucloud-cli/util" ) -var config = model.ConfigInstance +var config = ConfigInstance -//NewCmdConfig ucloud config -func NewCmdConfig() *cobra.Command { - var configDesc = `Public-key and private-key could be acquired from https://console.ucloud.cn/uapi/apikey.` - var helloUcloud = ` +const configDesc = `Public-key and private-key could be acquired from https://console.ucloud.cn/uapi/apikey.` + +const helloUcloud = ` _ _ _ _ _ _ _____ _ _ | | | | | | | | | | / __ \ | | | | |_| | ___| | | ___ | | | | / \/ | ___ _ _ __| | @@ -37,87 +37,117 @@ func NewCmdConfig() *cobra.Command { \_| |_/\___|_|_|\___/ \___/ \____/_|\___/ \__,_|\__,_| ` - var configCmd = &cobra.Command{ - Use: "config", - Short: "Config UCloud CLI options", - Long: `Config UCloud CLI options such as private-key,public-key,default region and default project-id.`, - Example: "ucloud config; ucloud config set region cn-bj2; ucloud config set project org-xxx", +//NewCmdInit ucloud init +func NewCmdInit() *cobra.Command { + cmd := &cobra.Command{ + Use: "init", + Short: "Initialize UCloud CLI options", + Long: `Initialize UCloud CLI options such as private-key,public-key,default region,zone and project.`, Run: func(cmd *cobra.Command, args []string) { - fmt.Println(configDesc) + Cxt.Println(configDesc) if len(config.PrivateKey) != 0 && len(config.PublicKey) != 0 { - fmt.Printf("Your have already configured public-key and private-key. Do you want to overwrite it? (y/n):") + Cxt.Printf("Your have already configured public-key and private-key. Do you want to overwrite it? (y/n):") var overwrite string _, err := fmt.Scanf("%s\n", &overwrite) if err != nil { - fmt.Println(err) + Cxt.Println(err) return } overwrite = strings.Trim(overwrite, " ") overwrite = strings.ToLower(overwrite) if overwrite != "yes" && overwrite != "y" { + printHello() return } } + config.ClearConfig() + ClientConfig.Region = "" + ClientConfig.ProjectId = "" config.ConfigPublicKey() config.ConfigPrivateKey() - region, err := getDefaultRegion() + region, zone, err := getDefaultRegion() if err != nil { - context.AppendError(err) - fmt.Println(err) - } else { - config.Region = region - fmt.Printf("Configured default region:%s\n", region) + Cxt.Println(err) + return } + config.Region = region + config.Zone = zone + Cxt.Printf("Configured default region:%s zone:%s\n", region, zone) - project, err := getDefaultProject() + projectId, projectName, err := getDefaultProject() if err != nil { - context.AppendError(err) - fmt.Println(err) - } else { - config.ProjectID = project - fmt.Printf("Configured default project:%s\n", project) + Cxt.Println(err) + return } - + config.ProjectID = projectId + Cxt.Printf("Configured default project:%s %s\n", projectId, projectName) config.SaveConfig() + printHello() + }, + } + return cmd +} - userInfo, err := getUserInfo() - - fmt.Printf("You are logged in as: [%s]\n", userInfo.UserEmail) +func printHello() { + userInfo, err := getUserInfo() + Cxt.Printf("You are logged in as: [%s]\n", userInfo.UserEmail) + certified := isUserCertified(userInfo) + if err != nil { + Cxt.PrintErr(err) + } else if certified == false { + Cxt.Println("\nWarning: Please authenticate the account with your valid documentation at 'https://accountv2.ucloud.cn/authentication'.") + } + Cxt.Println(helloUcloud) +} - certified := isUserCertified(userInfo) - if err != nil { - fmt.Println(err) - } else if certified == false { - fmt.Println("\nWarning: Please authenticate the account with your valid documentation at 'https://accountv2.ucloud.cn/authentication'.") +//NewCmdConfig ucloud config +func NewCmdConfig() *cobra.Command { + cfg := Config{} + cmd := &cobra.Command{ + Use: "config", + Short: "Configure UCloud CLI options", + Long: `Configure UCloud CLI options such as private-key,public-key,default region and default project-id.`, + Example: "ucloud config list; ucloud config --region cn-bj2", + Run: func(cmd *cobra.Command, args []string) { + tmpCfgVal := reflect.ValueOf(cfg) + configVal := reflect.ValueOf(config).Elem() + changed := false + for i := 0; i < tmpCfgVal.NumField(); i++ { + if fieldVal := tmpCfgVal.Field(i).String(); fieldVal != "" { + configVal.Field(i).SetString(fieldVal) + changed = true + } + } + if changed { + config.SaveConfig() + } else { + cmd.HelpFunc()(cmd, args) } - fmt.Println(helloUcloud) }, } - - configCmd.AddCommand(NewCmdConfigList()) - configCmd.AddCommand(NewCmdConfigClear()) - configCmd.AddCommand(NewCmdConfigSet()) - - originHelpFunc := configCmd.HelpFunc() - - configCmd.SetHelpFunc(func(cmd *cobra.Command, args []string) { - rootCmd := cmd.Parent() - rootCmd.Flags().MarkHidden("region") - rootCmd.Flags().MarkHidden("project-id") - originHelpFunc(cmd, args) - }) - return configCmd + flags := cmd.Flags() + flags.SortFlags = false + flags.StringVar(&cfg.PublicKey, "public-key", "", "Optional. Set public key") + flags.StringVar(&cfg.PrivateKey, "private-key", "", "Optional. Set private key") + flags.StringVar(&cfg.Region, "region", "", "Optional. Set default region. For instance 'cn-bj2' See 'ucloud region'") + flags.StringVar(&cfg.Zone, "zone", "", "Optional. Set default zone. For instance 'cn-bj2-02'. See 'ucloud region'") + flags.StringVar(&cfg.ProjectID, "project-id", "", "Optional. Set default project. For instance 'org-xxxxxx'. See 'ucloud project list") + + cmd.AddCommand(NewCmdConfigList()) + cmd.AddCommand(NewCmdConfigClear()) + + return cmd } -//NewCmdConfigList ucloud config ls +//NewCmdConfigList ucloud config list func NewCmdConfigList() *cobra.Command { - var configListCmd = &cobra.Command{ - Use: "ls", + configListCmd := &cobra.Command{ + Use: "list", Short: "list all settings", Long: `list all settings`, Run: func(cmd *cobra.Command, args []string) { - config.ListConfig() + config.ListConfig(global.json) }, } return configListCmd @@ -125,7 +155,7 @@ func NewCmdConfigList() *cobra.Command { //NewCmdConfigClear ucloud config clear func NewCmdConfigClear() *cobra.Command { - var configClearCmd = &cobra.Command{ + configClearCmd := &cobra.Command{ Use: "clear", Short: "clear all settings", Long: "clear all settings", @@ -135,34 +165,3 @@ func NewCmdConfigClear() *cobra.Command { } return configClearCmd } - -//NewCmdConfigSet ucloud config set -func NewCmdConfigSet() *cobra.Command { - - var configSetCmd = &cobra.Command{ - Use: "set", - Short: "Set a config value", - Long: "Set a config value, including private-key public-key region and project-id.", - Example: "ucloud config set region cn-bj2", - Run: func(cmd *cobra.Command, args []string) { - if len(args) != 2 { - fmt.Printf("Error: accepts 2 arg(s), received %d\n", len(args)) - return - } - switch args[0] { - case "region": - config.Region = args[1] - case "project-id": - config.ProjectID = args[1] - case "public-key": - config.PublicKey = args[1] - case "private-key": - config.PrivateKey = args[1] - default: - fmt.Println("Only public-key, private-key, region, project-id supported") - } - config.SaveConfig() - }, - } - return configSetCmd -} diff --git a/cmd/eip.go b/cmd/eip.go index 6a3c0299c4..fb7b2142e4 100644 --- a/cmd/eip.go +++ b/cmd/eip.go @@ -16,8 +16,13 @@ package cmd import ( "fmt" + "strconv" + "time" + + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/spf13/cobra" + . "github.com/ucloud/ucloud-cli/util" ) //NewCmdEIP ucloud eip @@ -36,74 +41,101 @@ func NewCmdEIP() *cobra.Command { return cmd } +//EIPRow 表格行 +type EIPRow struct { + Name string + IP string + ResourceID string + UGroup string + Billing string + Bandwidth string + BindResource string + Status string + ExpirationTime string +} + //NewCmdEIPList ucloud eip ls func NewCmdEIPList() *cobra.Command { - req := client.NewDescribeEIPRequest() - var cmd = &cobra.Command{ - Use: "ls", + req := BizClient.NewDescribeEIPRequest() + cmd := &cobra.Command{ + Use: "list", Short: "List all EIP instances", Long: `List all EIP instances`, Example: "ucloud eip ls", Run: func(cmd *cobra.Command, args []string) { - bindGlobalParam(req) - resp, err := client.DescribeEIP(req) + resp, err := BizClient.DescribeEIP(req) if err != nil { - fmt.Println("Error:", err) - return - } - if resp.RetCode == 0 { - for _, eip := range resp.EIPSet { - fmt.Printf("EIPId:%s, ", eip.EIPId) - for _, ip := range eip.EIPAddr { - fmt.Printf("IP:%-15s, Line:%s, ", ip.IP, ip.OperatorName) + HandleError(err) + } else { + if global.json { + PrintJSON(resp.EIPSet) + } else { + list := make([]EIPRow, 0) + for _, eip := range resp.EIPSet { + row := EIPRow{} + row.Name = eip.Name + for _, ip := range eip.EIPAddr { + row.IP += ip.IP + " " + ip.OperatorName + " " + } + row.ResourceID = eip.EIPId + row.UGroup = eip.Tag + row.Billing = eip.PayMode + row.Bandwidth = strconv.Itoa(eip.Bandwidth) + "Mb" + row.BindResource = fmt.Sprintf("%s(%s)", eip.Resource.ResourceName, eip.Resource.ResourceType) + row.Status = eip.Status + row.ExpirationTime = time.Unix(int64(eip.ExpireTime), 0).Format("2006-01-02") + list = append(list, row) } - fmt.Printf("BindResource: %s \n", eip.Resource.ResourceId) + PrintTable(list, []string{"Name", "IP", "ResourceID", "UGroup", "Billing", "Bandwidth", "BindResource", "Status", "ExpirationTime"}) } - } else { - fmt.Printf("Something wrong. RetCode:%d, Message: %s \n", resp.RetCode, resp.Message) } }, } + req.ProjectId = cmd.Flags().String("project-id", ConfigInstance.ProjectID, "Assign project-id") + req.Region = cmd.Flags().String("region", ConfigInstance.Region, "Assign region") return cmd } //NewCmdEIPAllocate ucloud eip allocate func NewCmdEIPAllocate() *cobra.Command { - var eipAllocateReq = client.NewAllocateEIPRequest() + var req = BizClient.NewAllocateEIPRequest() var cmd = &cobra.Command{ Use: "allocate", Short: "Allocate EIP", Long: "Allocate EIP", Example: "ucloud eip allocate --line Bgp --bandwidth 2", Run: func(cmd *cobra.Command, args []string) { - bindGlobalParam(eipAllocateReq) - resp, err := client.AllocateEIP(eipAllocateReq) + if *req.OperatorName == "BGP" { + *req.OperatorName = "Bgp" + } + resp, err := BizClient.AllocateEIP(req) if err != nil { - fmt.Println(err) + HandleError(err) } else { - if resp.RetCode == 0 { - for _, eip := range resp.EIPSet { - fmt.Printf("EIPId:%s,", eip.EIPId) - for _, ip := range eip.EIPAddr { - fmt.Printf("IP:%s,Line:%s \n", ip.IP, ip.OperatorName) - } + for _, eip := range resp.EIPSet { + Cxt.Printf("EIPId:%s,", eip.EIPId) + for _, ip := range eip.EIPAddr { + Cxt.Printf("IP:%s,Line:%s \n", ip.IP, ip.OperatorName) } - } else { - fmt.Printf("Something wrong. RetCode:%d, Message: %s \n", resp.RetCode, resp.Message) } } }, } cmd.Flags().SortFlags = false - cmd.Flags().StringVar(&eipAllocateReq.OperatorName, "line", "", "Line 'Bgp' or 'International'. 'Bgp' can be set in region cn-sh1,cn-sh2,cn-gd,cn-bj1 and cn-bj2. 'International' can be set in region hk,us-ca,th-bkk,kr-seoul,us-ws,ge-fra,sg,tw-kh and other oversea regions. Required") - cmd.Flags().IntVar(&eipAllocateReq.Bandwidth, "bandwidth", 0, "Bandwidth(Unit:Mbps). When paying by traffic, it ranges from 1 to 200; when paying by bandwidth, it ranges from 1 to 800, and when shared bandwidth is used, its value is 0. Required") - cmd.Flags().StringVar(&eipAllocateReq.PayMode, "pay-mode", "Bandwidth", "pay-mode is an enumeration value. 'Traffic','Bandwidth' or 'ShareBandwidth'") - cmd.Flags().IntVar(&eipAllocateReq.Quantity, "quantity", 1, "The quantity of EIP") - cmd.Flags().StringVar(&eipAllocateReq.ChargeType, "charge-type", "Month", "charge-type is an enumeration value. 'Year','Month', 'Dynamic'(Pay by the hour), 'Trial'(Need permission)") - cmd.Flags().StringVar(&eipAllocateReq.Tag, "tag", "Default", "Tag of your EIP.") - cmd.Flags().StringVar(&eipAllocateReq.Name, "name", "EIP", "Name of your EIP.") - cmd.Flags().StringVar(&eipAllocateReq.Remark, "remark", "", "Remark of your EIP.") - cmd.Flags().StringVar(&eipAllocateReq.CouponId, "coupon-id", "", "Coupon ID, The Coupon can deducte part of the payment") + req.ProjectId = cmd.Flags().String("project-id", ConfigInstance.ProjectID, "Assign project-id") + req.Region = cmd.Flags().String("region", ConfigInstance.Region, "Assign region") + req.OperatorName = cmd.Flags().String("line", "", "Required. 'BGP' or 'International'. 'BGP' could be set in China mainland regions, such as cn-bj2 etc. 'International' could be set in the regions beyond mainland, such as hk, tw-kh, us-ws etc.") + req.Bandwidth = cmd.Flags().Int("bandwidth", 0, "Required. Bandwidth(Unit:Mbps).The range of value related to network charge mode. By traffic [1, 200]; by bandwidth [1,800] (Unit: Mbps); it could be 0 if the eip belong to the shared bandwidth") + req.PayMode = cmd.Flags().String("charge-mode", "Bandwidth", "Optional. charge-mode is an enumeration value. 'Traffic','Bandwidth' or 'ShareBandwidth'") + req.Quantity = cmd.Flags().Int("quantity", 1, "Optional. The duration of the instance. N years/months.") + req.ChargeType = cmd.Flags().String("charge-type", "Month", "Optional. Enumeration value.'Year',pay yearly;'Month',pay monthly;'Dynamic', pay hourly(requires permission),'Trial', free trial(need permission)") + req.Tag = cmd.Flags().String("ugroup", "Default", "UGroup of your EIP.") + req.Name = cmd.Flags().String("name", "EIP", "Name of your EIP.") + req.Remark = cmd.Flags().String("remark", "", "Remark of your EIP.") + req.CouponId = cmd.Flags().String("coupon-id", "", "Coupon ID, The Coupon can deducte part of the payment") + cmd.Flags().SetFlagValues("line", []string{"BGP", "International"}) + cmd.Flags().SetFlagValues("charge-mode", []string{"Bandwidth", "Traffic", "ShareBandwidth"}) + cmd.Flags().SetFlagValues("charge-type", []string{"Month", "Year", "Dynamic", "Trial"}) cmd.MarkFlagRequired("line") cmd.MarkFlagRequired("bandwidth") return cmd @@ -111,96 +143,87 @@ func NewCmdEIPAllocate() *cobra.Command { //NewCmdEIPBind ucloud eip bind func NewCmdEIPBind() *cobra.Command { - var eipBindReq = client.NewBindEIPRequest() - var eipBindCmd = &cobra.Command{ + var req = BizClient.NewBindEIPRequest() + var cmd = &cobra.Command{ Use: "bind", Short: "Bind EIP with uhost", Long: "Bind EIP with uhost", Example: "ucloud eip bind --eip-id eip-xxx --resource-id uhost-xxx", Run: func(cmd *cobra.Command, args []string) { - bindGlobalParam(eipBindReq) - eipBindReq.ResourceType = "uhost" - resp, err := client.BindEIP(eipBindReq) + req.ResourceType = sdk.String("uhost") + _, err := BizClient.BindEIP(req) if err != nil { - fmt.Println(err) + HandleError(err) } else { - if resp.RetCode == 0 { - fmt.Printf("EIP: %v bind with %v:%v successfully \n", eipBindReq.EIPId, eipBindReq.ResourceType, eipBindReq.ResourceId) - } else { - fmt.Printf("Something wrong. RetCode:%d, Message: %s \n", resp.RetCode, resp.Message) - } + Cxt.Printf("EIP: [%s] bind with %s:[%s] successfully \n", *req.EIPId, *req.ResourceType, *req.ResourceId) } }, } - eipBindCmd.Flags().SortFlags = false - eipBindCmd.Flags().StringVar(&eipBindReq.EIPId, "eip-id", "", "EIPId to bind. Required") - eipBindCmd.Flags().StringVar(&eipBindReq.ResourceId, "resource-id", "", "ResourceID , which is the UHostId of uhost. Required") - eipBindCmd.MarkFlagRequired("eip-id") - eipBindCmd.MarkFlagRequired("resource-id") - return eipBindCmd + cmd.Flags().SortFlags = false + req.ProjectId = cmd.Flags().String("project-id", ConfigInstance.ProjectID, "Assign project-id") + req.Region = cmd.Flags().String("region", ConfigInstance.Region, "Assign region") + req.EIPId = cmd.Flags().String("eip-id", "", "EIPId to bind. Required") + req.ResourceId = cmd.Flags().String("resource-id", "", "ResourceID , which is the UHostId of uhost. Required") + cmd.MarkFlagRequired("eip-id") + cmd.MarkFlagRequired("resource-id") + return cmd } //NewCmdEIPUnbind ucloud eip unbind func NewCmdEIPUnbind() *cobra.Command { - var eipUnBindReq = client.NewUnBindEIPRequest() - var eipUnBindCmd = &cobra.Command{ + var req = BizClient.NewUnBindEIPRequest() + var cmd = &cobra.Command{ Use: "unbind", Short: "Unbind EIP with uhost", Long: "Unbind EIP with uhost", Example: "ucloud eip unbind --eip-id eip-xxx --resource-id uhost-xxx", Run: func(cmd *cobra.Command, args []string) { - bindGlobalParam(eipUnBindReq) - eipUnBindReq.ResourceType = "uhost" - resp, err := client.UnBindEIP(eipUnBindReq) + req.ResourceType = sdk.String("uhost") + _, err := BizClient.UnBindEIP(req) if err != nil { - fmt.Println(err) + HandleError(err) } else { - if resp.RetCode == 0 { - fmt.Printf("EIP: %v unbind with %v:%v successfully \n", eipUnBindReq.EIPId, eipUnBindReq.ResourceType, eipUnBindReq.ResourceId) - } else { - fmt.Printf("Something wrong. RetCode:%d, Message: %s \n", resp.RetCode, resp.Message) - } + Cxt.Printf("EIP: %s unbind with [%s]:[%s] successfully \n", *req.EIPId, *req.ResourceType, *req.ResourceId) } }, } - eipUnBindCmd.Flags().SortFlags = false - eipUnBindCmd.Flags().StringVar(&eipUnBindReq.EIPId, "eip-id", "", "EIPId to unbind. Required") - eipUnBindCmd.Flags().StringVar(&eipUnBindReq.ResourceId, "resource-id", "", "ResourceID , which is the UHostId of uhost. Required") - eipUnBindCmd.MarkFlagRequired("eip-id") - eipUnBindCmd.MarkFlagRequired("resource-id") + cmd.Flags().SortFlags = false + req.ProjectId = cmd.Flags().String("project-id", ConfigInstance.ProjectID, "Assign project-id") + req.Region = cmd.Flags().String("region", ConfigInstance.Region, "Assign region") + req.EIPId = cmd.Flags().String("eip-id", "", "EIPId to unbind. Required") + req.ResourceId = cmd.Flags().String("resource-id", "", "ResourceID , which is the UHostId of uhost. Required") + cmd.MarkFlagRequired("eip-id") + cmd.MarkFlagRequired("resource-id") - return eipUnBindCmd + return cmd } //NewCmdEIPRelease ucloud eip release func NewCmdEIPRelease() *cobra.Command { var ids []string - var eipReleaseCmd = &cobra.Command{ + var req = BizClient.NewReleaseEIPRequest() + var cmd = &cobra.Command{ Use: "release", Short: "Release EIP", Long: "Release EIP", Example: "ucloud eip release --eip-id eip-xx1 --eip-id eip-xx2", Run: func(cmd *cobra.Command, args []string) { for _, id := range ids { - var eipReleaseReq = client.NewReleaseEIPRequest() - bindGlobalParam(eipReleaseReq) - eipReleaseReq.EIPId = id - resp, err := client.ReleaseEIP(eipReleaseReq) + req.EIPId = &id + _, err := BizClient.ReleaseEIP(req) if err != nil { - fmt.Println(err) + HandleError(err) } else { - if resp.RetCode == 0 { - fmt.Printf("EIP: %v released \n", eipReleaseReq.EIPId) - } else { - fmt.Printf("Something wrong. RetCode:%d, Message: %s \n", resp.RetCode, resp.Message) - } + Cxt.Printf("EIP: %v released \n", *req.EIPId) } } }, } - eipReleaseCmd.Flags().StringArrayVarP(&ids, "eip-id", "", make([]string, 0), "EIPId of the EIP you want to release. Required") - eipReleaseCmd.MarkFlagRequired("eip-id") - eipReleaseCmd.MarkFlagRequired("bandwidth") - return eipReleaseCmd + req.ProjectId = cmd.Flags().String("project-id", ConfigInstance.ProjectID, "Assign project-id") + req.Region = cmd.Flags().String("region", ConfigInstance.Region, "Assign region") + cmd.Flags().StringArrayVarP(&ids, "eip-id", "", make([]string, 0), "EIPId of the EIP you want to release. Required") + cmd.MarkFlagRequired("eip-id") + cmd.MarkFlagRequired("bandwidth") + return cmd } diff --git a/cmd/globalssh.go b/cmd/globalssh.go index 843ca5da6d..52e6a41199 100644 --- a/cmd/globalssh.go +++ b/cmd/globalssh.go @@ -15,200 +15,260 @@ package cmd import ( - "fmt" - "strconv" + "strings" "github.com/spf13/cobra" + + . "github.com/ucloud/ucloud-cli/util" ) //NewCmdGssh ucloud gssh func NewCmdGssh() *cobra.Command { - var cmd = &cobra.Command{ + cmd := &cobra.Command{ Use: "gssh", - Short: "Create and manage globalssh instance", - Long: `Create and manage globalssh instance, such as create,modify,list and delete`, + Short: "Create,list,update and delete globalssh instance", + Long: `Create,list,update and delete globalssh instance`, } cmd.AddCommand(NewCmdGsshList()) cmd.AddCommand(NewCmdGsshCreate()) cmd.AddCommand(NewCmdGsshDelete()) cmd.AddCommand(NewCmdGsshModify()) + cmd.AddCommand(NewCmdGsshArea()) return cmd } +//GSSHRow gssh表格行 +type GSSHRow struct { + ResourceID string + SSHServerIP string + AcceleratingDomain string + SSHServerLocation string + SSHPort int + Remark string +} + //NewCmdGsshList ucloud gssh list func NewCmdGsshList() *cobra.Command { - req := client.NewDescribeGlobalSSHInstanceRequest() - var cmd = &cobra.Command{ - Use: "ls", + req := BizClient.NewDescribeGlobalSSHInstanceRequest() + cmd := &cobra.Command{ + Use: "list", Short: "List all GlobalSSH instances", Long: `List all GlobalSSH instances`, - Example: "ucloud gssh ls", + Example: "ucloud gssh list", Run: func(cmd *cobra.Command, args []string) { - bindGlobalParam(req) - resp, err := client.DescribeGlobalSSHInstance(req) + var areaMap = map[string]string{ + "洛杉矶": "LosAngeles", + "新加坡": "Singapore", + "香港": "HongKong", + "东京": "Tokyo", + "华盛顿": "Washington", + "法兰克福": "Frankfurt", + } + + resp, err := BizClient.DescribeGlobalSSHInstance(req) if err != nil { - fmt.Println("Error", err) + HandleError(err) } else { - if resp.RetCode == 0 { - for _, ins := range resp.InstanceSet { - fmt.Printf("InstanceID:%s, AcceleratingDomain:%s, TargetIP:%v, Port:%v, Remark:%s\n", ins.InstanceId, ins.AcceleratingDomain, ins.TargetIP, ins.Port, ins.Remark) - } + if global.json { + PrintJSON(resp.InstanceSet) } else { - fmt.Printf("Something wrong, RetCode:%d, Message:%s\n", resp.RetCode, resp.Message) + list := make([]GSSHRow, 0) + for _, gssh := range resp.InstanceSet { + row := GSSHRow{} + row.ResourceID = gssh.InstanceId + row.SSHServerIP = gssh.TargetIP + row.AcceleratingDomain = gssh.AcceleratingDomain + row.SSHPort = gssh.Port + row.Remark = gssh.Remark + if val, ok := areaMap[gssh.Area]; ok { + row.SSHServerLocation = val + } else { + row.SSHServerLocation = gssh.Area + } + list = append(list, row) + } + PrintTable(list, []string{"ResourceID", "SSHServerIP", "AcceleratingDomain", "SSHServerLocation", "SSHPort", "Remark"}) + } + } + }, + } + cmd.Flags().SortFlags = false + req.Region = cmd.Flags().String("region", ConfigInstance.Region, "Optional. Assign region") + req.ProjectId = cmd.Flags().String("project-id", ConfigInstance.ProjectID, "Optional. Assign project-id") + return cmd +} + +//NewCmdGsshArea ucloud gssh area +func NewCmdGsshArea() *cobra.Command { + req := BizClient.NewDescribeGlobalSSHAreaRequest() + cmd := &cobra.Command{ + Use: "area", + Short: "List SSH server locations and covered areas", + Long: "List SSH server locations and covered areas", + Run: func(cmd *cobra.Command, args []string) { + resp, err := BizClient.DescribeGlobalSSHArea(req) + if err != nil { + HandleError(err) + return + } + list := make([]GsshLocation, 0) + for _, item := range resp.AreaSet { + row := GsshLocation{ + AirportCode: item.AreaCode, + SSHServerLocation: areaCodeMap[item.AreaCode], + } + regionLabels := make([]string, 0) + for _, region := range item.RegionSet { + regionLabels = append(regionLabels, RegionLabel[region]) } + row.CoveredArea = strings.Join(regionLabels, ",") + list = append(list, row) } + + PrintTable(list, []string{"AirportCode", "SSHServerLocation", "CoveredArea"}) }, } return cmd } +//GsshLocation 服务地点和覆盖区域 +type GsshLocation struct { + AirportCode string + SSHServerLocation string + CoveredArea string +} + +var areaCodeMap = map[string]string{ + "LAX": "LosAngeles", + "SIN": "Singapore", + "HKG": "HongKong", + "HND": "Tokyo", + "IAD": "Washington", + "FRA": "Frankfurt", +} + //NewCmdGsshCreate ucloud gssh create func NewCmdGsshCreate() *cobra.Command { - var gsshCreateReq = client.NewCreateGlobalSSHInstanceRequest() - var cmd = &cobra.Command{ + req := BizClient.NewCreateGlobalSSHInstanceRequest() + cmd := &cobra.Command{ Use: "create", Short: "Create GlobalSSH instance", Long: "Create GlobalSSH instance", Example: "ucloud gssh create --area Washington --target-ip 8.8.8.8", Run: func(cmd *cobra.Command, args []string) { - bindGlobalParam(gsshCreateReq) - var areaMap = map[string]string{ - "LosAngeles": "洛杉矶", - "Singapore": "新加坡", - "HongKong": "香港", - "Tokyo": "东京", - "Washington": "华盛顿", - "Frankfurt": "法兰克福", - } - - port, err := strconv.Atoi(gsshCreateReq.Port) - if err != nil { - fmt.Println("Error:", err) - return + port := *req.Port + for code, area := range areaCodeMap { + if area == *req.AreaCode { + *req.AreaCode = code + } } if port < 1 || port > 65535 || port == 80 || port == 443 { - fmt.Println("The port number should be between 1 and 65535, and cannot be equal to 80 or 443") - return - } - - if area, ok := areaMap[gsshCreateReq.Area]; ok { - gsshCreateReq.Area = area - } else { - fmt.Println("Area should be one of LosAngeles,Singapore,HongKong,Tokyo,Washington,Frankfurt.") + Cxt.Println("The port number should be between 1 and 65535, and cannot be 80 or 443") return } - resp, err := client.CreateGlobalSSHInstance(gsshCreateReq) + resp, err := BizClient.CreateGlobalSSHInstance(req) if err != nil { - fmt.Println("Error:", err) + HandleError(err) } else { - if resp.RetCode == 0 { - fmt.Println("Succeed, GlobalSSHInstanceId:", resp.InstanceId) - } else { - fmt.Printf("Something wrong. RetCode:%d,Message:%s\n", resp.RetCode, resp.Message) - } + Cxt.Println("ResourceID:", resp.InstanceId) } }, } cmd.Flags().SortFlags = false - cmd.Flags().StringVar(&gsshCreateReq.Area, "area", "", "Location of the source server.Only supports six cities,LosAngeles,Singapore,HongKong,Tokyo,Washington,Frankfurt. Required") - cmd.Flags().StringVar(&gsshCreateReq.TargetIP, "target-ip", "", "IP of the source server. Required") - cmd.Flags().StringVar(&gsshCreateReq.Port, "port", "22", "Port of The SSH service between 1 and 65535. Do not use ports such as 80,443.") - cmd.Flags().StringVar(&gsshCreateReq.Remark, "remark", "", "Remark of your GlobalSSH.") - cmd.Flags().StringVar(&gsshCreateReq.CouponId, "coupon-id", "", "Coupon ID, The Coupon can deduct part of the payment") + req.AreaCode = cmd.Flags().String("area", "", "Required. Location of the source server. See 'ucloud gssh area'") + req.TargetIP = cmd.Flags().String("target-ip", "", "Required. IP of the source server. Required") + req.Region = cmd.Flags().String("region", "", "Optional. Assign region") + req.ProjectId = cmd.Flags().String("project-id", ConfigInstance.ProjectID, "Optional. Assign project-id") + req.Port = cmd.Flags().Int("port", 22, "Optional. Port of The SSH service between 1 and 65535. Do not use ports such as 80,443.") + req.Remark = cmd.Flags().String("remark", "", "Optional. Remark of your GlobalSSH.") + req.ChargeType = cmd.Flags().String("charge-type", "Month", "Optional.'Year',pay yearly;'Month',pay monthly;'Dynamic', pay hourly(requires access)") + req.Quantity = cmd.Flags().Int("quantity", 1, "Optional. The duration of the instance. N years/months.") + req.CouponId = cmd.Flags().String("coupon-id", "", "Optional. Coupon ID, The Coupon can deduct part of the payment,see DescribeCoupon or https://accountv2.ucloud.cn") cmd.MarkFlagRequired("area") cmd.MarkFlagRequired("target-ip") + cmd.Flags().SetFlagValues("area", []string{"LosAngeles", "Singapore", "HongKong", "Tokyo", "Washington", "Frankfurt"}) + cmd.Flags().SetFlagValues("charge-type", []string{"Month", "Year", "Dynamic", "Trial"}) return cmd } //NewCmdGsshDelete ucloud gssh delete func NewCmdGsshDelete() *cobra.Command { - var gsshDeleteReq = client.NewDeleteGlobalSSHInstanceRequest() - var gsshIds []string + var req = BizClient.NewDeleteGlobalSSHInstanceRequest() + var gsshIds *[]string var cmd = &cobra.Command{ Use: "delete", Short: "Delete GlobalSSH instance", Long: "Delete GlobalSSH instance", Example: "ucloud gssh delete --id uga-xx1 --id uga-xx2", Run: func(cmd *cobra.Command, args []string) { - bindGlobalParam(gsshDeleteReq) - for _, id := range gsshIds { - gsshDeleteReq.InstanceId = id - - if global.projectID != "" { - gsshDeleteReq.ProjectId = global.projectID - } - resp, err := client.DeleteGlobalSSHInstance(gsshDeleteReq) + for _, id := range *gsshIds { + req.InstanceId = &id + _, err := BizClient.DeleteGlobalSSHInstance(req) if err != nil { - fmt.Println("Error:", err) + HandleError(err) } else { - if resp.RetCode == 0 { - fmt.Printf("GlobalSSH(%s) was successfully deleted\n", id) - } else { - fmt.Printf("Something wrong. RetCode:%d, Message:%s\n", resp.RetCode, resp.Message) - } + Cxt.Printf("GlobalSSH[%s] was successfully deleted\n", id) } } }, } - cmd.Flags().StringArrayVar(&gsshIds, "id", make([]string, 0), "ID of the GlobalSSH instances you want to delete. Multiple values specified by multiple flags. Required") + 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") + 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("id") return cmd } //NewCmdGsshModify ucloud gssh modify func NewCmdGsshModify() *cobra.Command { - var gsshModifyPortReq = client.NewModifyGlobalSSHPortRequest() - var gsshModifyRemarkReq = client.NewModifyGlobalSSHRemarkRequest() + var gsshModifyPortReq = BizClient.NewModifyGlobalSSHPortRequest() + var gsshModifyRemarkReq = BizClient.NewModifyGlobalSSHRemarkRequest() + var region, project string var cmd = &cobra.Command{ - Use: "modify", - Short: "Modify GlobalSSH instance", - Long: "Modify GlobalSSH instance, including port and remark attribute", - Example: "ucloud gssh modify --id uga-xxx --port 22", + Use: "update", + Short: "Update GlobalSSH instance", + Long: "Update GlobalSSH instance, including port and remark attribute", + Example: "ucloud gssh update --id uga-xxx --port 22", Run: func(cmd *cobra.Command, args []string) { - bindGlobalParam(gsshModifyPortReq) - bindGlobalParam(gsshModifyRemarkReq) - if gsshModifyPortReq.Port == "" && gsshModifyRemarkReq.Remark == "" { - fmt.Println("port or remark required") + *gsshModifyPortReq.Region = region + *gsshModifyPortReq.ProjectId = project + *gsshModifyRemarkReq.Region = region + *gsshModifyRemarkReq.ProjectId = project + + if *gsshModifyPortReq.Port == 0 && *gsshModifyRemarkReq.Remark == "" { + Cxt.Println("port or remark required") } - if gsshModifyPortReq.Port != "" { - port, err := strconv.Atoi(gsshModifyPortReq.Port) - if err != nil { - fmt.Println("Error:", err) - return - } + if *gsshModifyPortReq.Port != 0 { + port := *gsshModifyPortReq.Port if port <= 1 || port >= 65535 || port == 80 || port == 443 { - fmt.Println("The port number should be between 1 and 65535, and cannot be equal to 80 or 443") + Cxt.Println("The port number should be between 1 and 65535, and cannot be equal to 80 or 443") return } gsshModifyPortReq.InstanceId = gsshModifyRemarkReq.InstanceId - resp, err := client.ModifyGlobalSSHPort(gsshModifyPortReq) + _, err := BizClient.ModifyGlobalSSHPort(gsshModifyPortReq) if err != nil { - fmt.Println("Error:", err) + HandleError(err) } else { - if resp.RetCode == 0 { - fmt.Println("Successfully modified") - } else { - fmt.Printf("Something wrong. RetCode:%d, Message: %s\n", resp.RetCode, resp.Message) - } + Cxt.Println("Successfully updated") } } - if gsshModifyRemarkReq.Remark != "" { - resp, err := client.ModifyGlobalSSHRemark(gsshModifyRemarkReq) + if *gsshModifyRemarkReq.Remark != "" { + _, err := BizClient.ModifyGlobalSSHRemark(gsshModifyRemarkReq) if err != nil { - fmt.Println("Error:", err) + HandleError(err) } else { - if resp.RetCode == 0 { - fmt.Println("Successfully modified") - } else { - fmt.Printf("Something wrong. RetCode:%d, Message: %s\n", resp.RetCode, resp.Message) - } + Cxt.Println("Successfully updated") } } }, } - cmd.Flags().StringVar(&gsshModifyPortReq.Port, "port", "", "Port of SSH service.") - cmd.Flags().StringVar(&gsshModifyRemarkReq.Remark, "remark", "", "Remark of your GlobalSSH.") - cmd.Flags().StringVar(&gsshModifyRemarkReq.InstanceId, "id", "", "InstanceID of your GlobalSSH. Required") + cmd.Flags().SortFlags = false + gsshModifyRemarkReq.InstanceId = cmd.Flags().String("resource-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("id") return cmd } diff --git a/cmd/image.go b/cmd/image.go new file mode 100644 index 0000000000..0ac0928ac6 --- /dev/null +++ b/cmd/image.go @@ -0,0 +1,91 @@ +// Copyright © 2018 NAME HERE tony.li@ucloud.cn +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cmd + +import ( + "strings" + + "github.com/spf13/cobra" + + . "github.com/ucloud/ucloud-cli/util" +) + +//NewCmdUImage ucloud uimage +func NewCmdUImage() *cobra.Command { + cmd := &cobra.Command{ + Use: "image", + Short: "List images", + Long: `List images`, + Args: cobra.NoArgs, + } + cmd.AddCommand(NewCmdUImageList()) + + return cmd +} + +//ImageRow 表格行 +type ImageRow struct { + ImageName string + ImageID string + BasicImage string + ExtensibleFeature string + CreationTime string + State string +} + +//NewCmdUImageList ucloud uimage list +func NewCmdUImageList() *cobra.Command { + req := 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) + if err != nil { + HandleError(err) + return + } + if global.json { + PrintJSON(resp.ImageSet) + } else { + list := make([]ImageRow, 0) + for _, image := range resp.ImageSet { + row := ImageRow{} + row.ImageName = image.ImageName + row.ImageID = image.ImageId + row.BasicImage = image.OsName + row.ExtensibleFeature = strings.Join(image.Features, ",") + row.CreationTime = FormatDate(image.CreateTime) + row.State = image.State + if row.State == "Available" { + list = append(list, row) + } + } + PrintTable(list, []string{"ImageName", "ImageID", "BasicImage", "ExtensibleFeature", "CreationTime", "State"}) + } + }, + } + 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") + return cmd +} diff --git a/cmd/list.go b/cmd/list.go deleted file mode 100644 index 7c47b53eb6..0000000000 --- a/cmd/list.go +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright © 2018 NAME HERE tony.li@ucloud.cn -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package cmd - -import ( - "encoding/json" - "fmt" - "io/ioutil" - - "github.com/spf13/cobra" - "github.com/ucloud/ucloud-cli/model" - "github.com/ucloud/ucloud-cli/util" - "github.com/ucloud/ucloud-sdk-go/service/uaccount" - "github.com/ucloud/ucloud-sdk-go/service/uaccount/types" -) - -//NewCmdList ucloud ls -func NewCmdList() *cobra.Command { - var listObject string - var cmd = &cobra.Command{ - Use: "ls", - Short: "List all regions or projects", - Long: "List all regions or projects", - Example: "ucloud ls --object region; ucloud ls --object project", - Run: func(cmd *cobra.Command, args []string) { - switch listObject { - case "region": - listRegion() - case "project": - listProject() - default: - fmt.Println("object should be region or project") - } - }, - } - cmd.Flags().StringVar(&listObject, "object", "", "Object to list,region or project. Required") - cmd.MarkFlagRequired("object") - return cmd -} - -func getDefaultRegion() (string, error) { - req := &uaccount.GetRegionRequest{} - resp, err := client.GetRegion(req) - if err != nil { - return "", err - } - if resp.RetCode != 0 { - return "", fmt.Errorf("Something wrong. RetCode:%d, Message:%s", resp.RetCode, resp.Message) - } - for _, region := range resp.Regions { - if region.IsDefault == true { - return region.Region, nil - } - } - return "", fmt.Errorf("No default region") -} - -func listRegion() error { - req := &uaccount.GetRegionRequest{} - resp, err := client.GetRegion(req) - if err != nil { - return err - } - if resp.RetCode != 0 { - return fmt.Errorf("Something wrong. RetCode:%d, Message:%s", resp.RetCode, resp.Message) - } - var regionMap = map[string]bool{} - var regionList []string - for _, region := range resp.Regions { - if _, ok := regionMap[region.Region]; !ok { - regionList = append(regionList, region.Region) - } - regionMap[region.Region] = true - } - for index, region := range regionList { - fmt.Printf("[%2d] %s\n", index, region) - } - return nil -} - -func getDefaultProject() (string, error) { - req := client.NewGetProjectListRequest() - resp, err := client.GetProjectList(req) - if err != nil { - return "", err - } - if resp.RetCode != 0 { - return "", fmt.Errorf("Something wrong. RetCode:%d, Message:%s", resp.RetCode, resp.Message) - } - for _, project := range resp.ProjectSet { - if project.IsDefault == true { - return project.ProjectId, nil - } - } - return "", fmt.Errorf("No default project") -} - -func listProject() error { - req := &uaccount.GetProjectListRequest{} - resp, err := client.GetProjectList(req) - if err != nil { - return err - } - if resp.RetCode != 0 { - return fmt.Errorf("Something wrong. RetCode:%d, Message:%s", resp.RetCode, resp.Message) - } - for _, project := range resp.ProjectSet { - fmt.Printf("ProjectId: %s, ProjectName:%s\n", project.ProjectId, project.ProjectName) - } - return nil -} - -func isUserCertified(userInfo *types.UserInfo) bool { - return userInfo.AuthState == "CERTIFIED" -} - -func getUserInfo() (*types.UserInfo, error) { - req := client.NewGetUserInfoRequest() - var userInfo types.UserInfo - resp, err := client.GetUserInfo(req) - - if err != nil { - return nil, err - } - - if resp.RetCode != 0 { - return nil, fmt.Errorf("Something wrong. RetCode:%d, Message:%s", resp.RetCode, resp.Message) - } - if len(resp.DataSet) == 1 { - userInfo = resp.DataSet[0] - model.ClientConfig.TracerData["userName"] = userInfo.UserEmail - model.ClientConfig.TracerData["userID"] = userInfo.UserEmail - model.ClientConfig.TracerData["companyName"] = userInfo.CompanyName - bytes, err := json.Marshal(userInfo) - if err != nil { - return nil, err - } - fileFullPath := util.GetConfigPath() + "/user.json" - err = ioutil.WriteFile(fileFullPath, bytes, 0600) - if err != nil { - return nil, err - } - } else { - return nil, fmt.Errorf("GetUserInfo DataSet length: %d", len(resp.DataSet)) - } - return &userInfo, nil -} diff --git a/cmd/project.go b/cmd/project.go new file mode 100644 index 0000000000..ea4122c132 --- /dev/null +++ b/cmd/project.go @@ -0,0 +1,150 @@ +// Copyright © 2018 NAME HERE tony.li@ucloud.cn +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cmd + +import ( + "github.com/spf13/cobra" + + "github.com/ucloud/ucloud-sdk-go/services/uaccount" + + . "github.com/ucloud/ucloud-cli/util" +) + +//NewCmdProject ucloud project +func NewCmdProject() *cobra.Command { + var cmd = &cobra.Command{ + Use: "project", + Short: "List,create,update and delete project", + Long: "List,create,update and delete project", + Example: "ucloud project", + } + cmd.AddCommand(NewCmdProjectList()) + cmd.AddCommand(NewCmdProjectCreate()) + cmd.AddCommand(NewCmdProjectUpdate()) + cmd.AddCommand(NewCmdProjectDelete()) + return cmd +} + +//NewCmdProjectList ucloud project list +func NewCmdProjectList() *cobra.Command { + var cmd = &cobra.Command{ + Use: "list", + Short: "List project", + Long: "List project", + Example: "ucloud project list", + Run: func(cmd *cobra.Command, args []string) { + listProject() + }, + } + return cmd +} + +//NewCmdProjectCreate ucloud project create +func NewCmdProjectCreate() *cobra.Command { + req := BizClient.NewCreateProjectRequest() + cmd := &cobra.Command{ + Use: "create", + Short: "Create project", + Long: "Create project", + Example: "ucloud project create --name xxx", + Run: func(cmd *cobra.Command, args []string) { + resp, err := BizClient.CreateProject(req) + if err != nil { + Cxt.PrintErr(err) + } else { + if resp.RetCode != 0 { + HandleBizError(resp) + } else { + Cxt.Printf("Project:%q created successfully.\n", resp.ProjectId) + } + } + }, + } + req.ProjectName = cmd.Flags().String("name", "", "The name of project") + req.ParentId = cmd.Flags().String("parent-id", "", "The parent project id") + cmd.MarkFlagRequired("name") + return cmd +} + +//NewCmdProjectUpdate ucloud project update +func NewCmdProjectUpdate() *cobra.Command { + req := BizClient.NewModifyProjectRequest() + cmd := &cobra.Command{ + Use: "update", + Short: "Update project name", + Long: "Update project name", + Example: "ucloud project update --id org-xxx --name new_name", + Run: func(cmd *cobra.Command, args []string) { + resp, err := BizClient.ModifyProject(req) + if err != nil { + Cxt.PrintErr(err) + } else { + if resp.RetCode != 0 { + HandleBizError(resp) + } else { + Cxt.Printf("Project:%s updated successfully.\n", *req.ProjectId) + } + } + }, + } + req.ProjectId = cmd.Flags().String("id", "", "The project id") + req.ProjectName = cmd.Flags().String("name", "", "The new name of project") + cmd.MarkFlagRequired("name") + cmd.MarkFlagRequired("id") + return cmd +} + +//NewCmdProjectDelete ucloud project delete +func NewCmdProjectDelete() *cobra.Command { + req := BizClient.NewTerminateProjectRequest() + cmd := &cobra.Command{ + Use: "delete", + Short: "Delete project", + Long: "Delete project", + Example: "ucloud project delete --id org-xxx", + Run: func(cmd *cobra.Command, args []string) { + resp, err := BizClient.TerminateProject(req) + if err != nil { + Cxt.PrintErr(err) + } else { + if resp.RetCode != 0 { + HandleBizError(resp) + } else { + Cxt.Printf("Project:%s deleted successfully.\n", *req.ProjectId) + } + } + }, + } + req.ProjectId = cmd.Flags().String("id", "", "The project id") + cmd.MarkFlagRequired("id") + return cmd +} + +func listProject() error { + req := &uaccount.GetProjectListRequest{} + resp, err := BizClient.GetProjectList(req) + if err != nil { + return err + } + if resp.RetCode != 0 { + return HandleBizError(resp) + } + if global.json { + PrintJSON(resp.ProjectSet) + } else { + PrintTable(resp.ProjectSet, []string{"ProjectId", "ProjectName"}) + } + return nil +} diff --git a/cmd/region.go b/cmd/region.go new file mode 100644 index 0000000000..0eae8f304f --- /dev/null +++ b/cmd/region.go @@ -0,0 +1,145 @@ +// Copyright © 2018 NAME HERE tony.li@ucloud.cn +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cmd + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "strings" + + "github.com/spf13/cobra" + + "github.com/ucloud/ucloud-sdk-go/services/uaccount" + + . "github.com/ucloud/ucloud-cli/util" +) + +//NewCmdRegion ucloud region +func NewCmdRegion() *cobra.Command { + var cmd = &cobra.Command{ + Use: "region", + Short: "List all region and zone", + Long: "List all region and zone", + Example: "ucloud region", + Run: func(cmd *cobra.Command, args []string) { + if err := listRegion(); err != nil { + Cxt.PrintErr(err) + } + }, + } + return cmd +} + +func getDefaultRegion() (string, string, error) { + req := &uaccount.GetRegionRequest{} + resp, err := BizClient.GetRegion(req) + if err != nil { + return "", "", err + } + if resp.RetCode != 0 { + return "", "", fmt.Errorf("Something wrong. RetCode:%d, Message:%s", resp.RetCode, resp.Message) + } + for _, region := range resp.Regions { + if region.IsDefault == true { + return region.Region, region.Zone, nil + } + } + return "", "", fmt.Errorf("No default region") +} + +//RegionTable 为显示region表格创建的类型 +type RegionTable struct { + Region string + Zones string +} + +func listRegion() error { + req := &uaccount.GetRegionRequest{} + resp, err := BizClient.GetRegion(req) + if err != nil { + return err + } + if resp.RetCode != 0 { + return fmt.Errorf("Something wrong. RetCode:%d, Message:%s", resp.RetCode, resp.Message) + } else { + regionList := make([]RegionTable, 0) + regionMap := make(map[string][]string) + for _, region := range resp.Regions { + regionMap[region.Region] = append(regionMap[region.Region], region.Zone) + } + for region, zones := range regionMap { + regionList = append(regionList, RegionTable{region, strings.Join(zones, ", ")}) + } + if global.json { + PrintJSON(regionList) + } else { + err = PrintTable(regionList, []string{"Region", "Zones"}) + } + } + return err +} + +func getDefaultProject() (string, string, error) { + req := BizClient.NewGetProjectListRequest() + resp, err := BizClient.GetProjectList(req) + if err != nil { + return "", "", err + } + if resp.RetCode != 0 { + return "", "", fmt.Errorf("Something wrong. RetCode:%d, Message:%s", resp.RetCode, resp.Message) + } + for _, project := range resp.ProjectSet { + if project.IsDefault == true { + return project.ProjectId, project.ProjectName, nil + } + } + return "", "", fmt.Errorf("No default project") +} + +func isUserCertified(userInfo *uaccount.UserInfo) bool { + return userInfo.AuthState == "CERTIFIED" +} + +func getUserInfo() (*uaccount.UserInfo, error) { + req := BizClient.NewGetUserInfoRequest() + var userInfo uaccount.UserInfo + resp, err := BizClient.GetUserInfo(req) + + if err != nil { + return nil, err + } + + if resp.RetCode != 0 { + return nil, fmt.Errorf("Something wrong. RetCode:%d, Message:%s", resp.RetCode, resp.Message) + } + if len(resp.DataSet) == 1 { + userInfo = resp.DataSet[0] + Cxt.AppendInfo("userName", userInfo.UserEmail) + Cxt.AppendInfo("companyName", userInfo.CompanyName) + bytes, err := json.Marshal(userInfo) + if err != nil { + return nil, err + } + fileFullPath := GetConfigPath() + "/user.json" + err = ioutil.WriteFile(fileFullPath, bytes, 0600) + if err != nil { + return nil, err + } + } else { + return nil, fmt.Errorf("GetUserInfo DataSet length: %d", len(resp.DataSet)) + } + return &userInfo, nil +} diff --git a/cmd/root.go b/cmd/root.go index 9dc9c1475d..4fc6fd6a3a 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -18,111 +18,148 @@ import ( "fmt" "os" + "github.com/Sirupsen/logrus" "github.com/spf13/cobra" - "github.com/ucloud/ucloud-cli/model" - "github.com/ucloud/ucloud-sdk-go/sdk/request" - "github.com/ucloud/ucloud-sdk-go/service" + + . "github.com/ucloud/ucloud-cli/util" ) //GlobalFlag 几乎所有接口都需要的参数,例如 region zone projectID type GlobalFlag struct { - region string - projectID string - debug bool + debug bool + json bool + version bool + completion bool + config bool + signup bool } var global GlobalFlag -var client = service.NewClient(model.ClientConfig, model.Credential) //NewCmdRoot 创建rootCmd rootCmd represents the base command when called without any subcommands func NewCmdRoot() *cobra.Command { var cmd = &cobra.Command{ Use: "ucloud", - Short: "UCloud CLI v" + version, + Short: "UCloud CLI v" + 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) + } else if global.completion { + NewCmdCompletion().Run(cmd, args) + } else if global.config { + config.ListConfig(global.json) + } else if global.signup { + NewCmdSignup().Run(cmd, args) + } else { + cmd.HelpFunc()(cmd, args) + } + }, } - cmd.PersistentFlags().StringVarP(&global.region, "region", "r", "", "Assign region(override default region of your config)") - cmd.PersistentFlags().StringVarP(&global.projectID, "project-id", "p", "", "Assign project-id(override default projec-id of your config)") cmd.PersistentFlags().BoolVarP(&global.debug, "debug", "d", false, "Running in debug mode") + cmd.PersistentFlags().BoolVarP(&global.json, "json", "j", false, "Print result in JSON format whenever possible") + cmd.Flags().BoolVar(&global.version, "version", false, "Display version") + cmd.Flags().BoolVar(&global.completion, "completion", false, "Turn on auto completion according to the prompt") + cmd.Flags().BoolVar(&global.config, "config", false, "Display configuration") + cmd.Flags().BoolVar(&global.signup, "signup", false, "Launch UCloud sign up page in browser") - cmd.AddCommand(NewCmdSignup()) + cmd.AddCommand(NewCmdInit()) cmd.AddCommand(NewCmdConfig()) - cmd.AddCommand(NewCmdList()) + cmd.AddCommand(NewCmdRegion()) + cmd.AddCommand(NewCmdProject()) cmd.AddCommand(NewCmdUHost()) cmd.AddCommand(NewCmdEIP()) cmd.AddCommand(NewCmdGssh()) - cmd.AddCommand(NewCmdCompletion()) - cmd.AddCommand(NewCmdVersion()) - + cmd.AddCommand(NewCmdUImage()) + cmd.AddCommand(NewCmdSubnet()) + cmd.AddCommand(NewCmdVPC()) + cmd.AddCommand(NewCmdFirewall()) return cmd } +const helpTmpl = `Usage:{{if .Runnable}} + {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}} [command]{{end}}{{if gt (len .Aliases) 0}} + +Aliases: + {{.NameAndAliases}}{{end}}{{if .HasExample}} + +Examples: +{{.Example}}{{end}}{{if .HasAvailableSubCommands}} + +Commands:{{range .Commands}}{{if .IsAvailableCommand}} + {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}} + +Flags: +{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}} + +Global Flags: +{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}} + +Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}} + {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}} + +Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}} +` + +//概要帮助信息模板 +const usageTmpl = `Usage:{{if .Runnable}} + {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}} [command] {{if $size:=len .Commands}} + {{"command may be" | printf "%-20s"}} {{range $index,$cmd:= .Commands}}{{if .IsAvailableCommand}}{{$cmd.Name}}{{if gt $size (add $index 2)}} | {{end}}{{end}}{{end}}{{end}}{{end}}{{if .HasAvailableFlags}} + {{"flags may be" | printf "%-20s"}} {{.Flags.FlagNames}} + +Use "{{.CommandPath}} --help" for details.{{end}} +` + // Execute adds all child commands to the root command and sets flags appropriately. // This is called by main.main(). It only needs to happen once to the rootCmd. func Execute() { - command := NewCmdRoot() - if err := command.Execute(); err != nil { - fmt.Println(err) + rootCmd := NewCmdRoot() + rootCmd.SetHelpTemplate(helpTmpl) + rootCmd.SetUsageTemplate(usageTmpl) + resetHelpFunc(rootCmd) + + if err := rootCmd.Execute(); err != nil { os.Exit(1) } } -var context *model.Context - func init() { cobra.EnableCommandSorting = false - client = service.NewClient(model.ClientConfig, model.Credential) - context = model.GetContext(os.Stdout, model.ClientConfig) cobra.OnInitialize(initialize) - model.ClientConfig.UserAgent = fmt.Sprintf("UCloud CLI v%s", version) - model.ClientConfig.TracerData["command"] = fmt.Sprintf("%v", os.Args) + Cxt.AppendInfo("command", fmt.Sprintf("%v", os.Args)) +} + +func resetHelpFunc(cmd *cobra.Command) { + for _, a := range os.Args { + if a == "-h" { + cmd.SetHelpTemplate(usageTmpl) + } + } } func initialize(cmd *cobra.Command) { if global.debug { - model.ClientConfig.LogLevel = 5 - model.ClientConfig.Logger = nil + logrus.SetLevel(logrus.DebugLevel) } - userInfo, err := model.LoadUserInfo() + userInfo, err := LoadUserInfo() if err == nil { - model.ClientConfig.TracerData["userName"] = userInfo.UserEmail - model.ClientConfig.TracerData["userID"] = userInfo.UserEmail - model.ClientConfig.TracerData["companyName"] = userInfo.CompanyName + Cxt.AppendInfo("userName", userInfo.UserEmail) + Cxt.AppendInfo("companyName", userInfo.CompanyName) } else { - context.AppendError(err) + Cxt.PrintErr(err) } - //上报服务对Origin请求头有限制,必须以'.ucloud.cn'结尾,因此这里伪造了一个sdk.ucloud.cn,跟其他上报区分 - model.ClientConfig.HTTPHeaders["Origin"] = "https://sdk.ucloud.cn" - - if (cmd.Name() != "config" && cmd.Name() != "completion" && cmd.Name() != "version") && cmd.Parent().Name() != "config" { + if (cmd.Name() != "config" && cmd.Name() != "init" && cmd.Name() != "version") && (cmd.Parent() != nil && cmd.Parent().Name() != "config") { if config.PrivateKey == "" { - fmt.Println("private-key is empty. Execute command 'ucloud config' to configure your private-key") + Cxt.Println("private-key is empty. Execute command 'ucloud init' or 'ucloud config' to configure your private-key") os.Exit(0) } if config.PublicKey == "" { - fmt.Println("public-key is empty. Execute command 'ucloud config' to configure your public-key") - os.Exit(0) - } - if config.Region == "" { - fmt.Println("Default region is empty. Execute command 'ucloud config set region' to configure your default region") + Cxt.Println("public-key is empty. Execute command 'ucloud init' or 'ucloud config' to configure your public-key") os.Exit(0) } - if config.ProjectID == "" { - fmt.Println("Default project-id is empty. Execute command 'ucloud config set project' to configure your default project-id") - os.Exit(0) - } - } -} - -func bindGlobalParam(req request.Common) { - if global.region != "" { - req.SetRegion(global.region) - } - if global.projectID != "" { - req.SetProjectId(global.projectID) } } diff --git a/cmd/signup.go b/cmd/signup.go index 649434aa32..6f5cb2546d 100644 --- a/cmd/signup.go +++ b/cmd/signup.go @@ -24,13 +24,12 @@ import ( //NewCmdSignup ucloud signup func NewCmdSignup() *cobra.Command { - var cmd = &cobra.Command{ - Use: "sign-up", - Short: "Launch UCloud sign-up page in browser", - Long: `Launch UCloud sign-up page in browser`, + Use: "signup", + Short: "Launch UCloud sign up page in browser", + Long: `Launch UCloud sign up page in browser`, Args: cobra.NoArgs, - Example: "ucloud sign-up", + Example: "ucloud signup", Run: func(cmd *cobra.Command, args []string) { openbrowser("https://passport.ucloud.cn/#register") }, diff --git a/cmd/uhost.go b/cmd/uhost.go index c4fea613e0..94f986c8dd 100644 --- a/cmd/uhost.go +++ b/cmd/uhost.go @@ -16,40 +16,369 @@ package cmd import ( "fmt" + "strings" "github.com/spf13/cobra" + + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/services/uhost" + + . "github.com/ucloud/ucloud-cli/util" ) //NewCmdUHost ucloud uhost func NewCmdUHost() *cobra.Command { - var cmd = &cobra.Command{ + cmd := &cobra.Command{ Use: "uhost", - Short: "List UHost instance", - Long: `List UHost instance`, + Short: "List,create,delete,stop,restart,poweroff or scale UHost instance", + Long: `List,create,delete,stop,restart,poweroff or scale UHost instance`, Args: cobra.NoArgs, } cmd.AddCommand(NewCmdUHostList()) + cmd.AddCommand(NewCmdUHostCreate()) + cmd.AddCommand(NewCmdUHostDelete()) + cmd.AddCommand(NewCmdUHostStop()) + cmd.AddCommand(NewCmdUHostStart()) + cmd.AddCommand(NewCmdUHostReboot()) + cmd.AddCommand(NewCmdUHostPoweroff()) + cmd.AddCommand(NewCmdUHostScale()) + return cmd } -//NewCmdUHostList ucloud uhost list +//UHostRow UHost表格行 +type UHostRow struct { + UHostName string + ResourceID string + UGroup string + ClassicNetwork string + Config string + Type string + CreationTime string + State string +} + +//NewCmdUHostList [ucloud uhost list] func NewCmdUHostList() *cobra.Command { - var cmd = &cobra.Command{ - Use: "ls", + req := BizClient.NewDescribeUHostInstanceRequest() + cmd := &cobra.Command{ + Use: "list", Short: "List all UHost Instances", Long: `List all UHost Instances`, Run: func(cmd *cobra.Command, args []string) { - req := client.NewDescribeUHostInstanceRequest() - bindGlobalParam(req) - resp, err := client.DescribeUHostInstance(req) + resp, err := BizClient.DescribeUHostInstance(req) if err != nil { - fmt.Println("Error:", err) + HandleError(err) return } - for _, uhost := range resp.UHostSet { - fmt.Printf("UHostID:%s\n", uhost.UHostId) + if global.json { + PrintJSON(resp.UHostSet) + } else { + list := make([]UHostRow, 0) + for _, host := range resp.UHostSet { + row := UHostRow{} + row.UHostName = host.Name + row.ResourceID = host.UHostId + row.UGroup = host.Tag + for _, ip := range host.IPSet { + if row.ClassicNetwork != "" { + row.ClassicNetwork += " | " + } + if ip.Type == "Private" { + row.ClassicNetwork += fmt.Sprintf("%s", ip.IP) + } else { + row.ClassicNetwork += fmt.Sprintf("%s %s", ip.IP, ip.Type) + } + } + osName := strings.SplitN(host.OsName, " ", 2) + cupCore := host.CPU + memorySize := host.Memory / 1024 + diskSize := 0 + for _, disk := range host.DiskSet { + if disk.Type == "Data" { + diskSize += disk.Size + } + } + row.Config = fmt.Sprintf("%s cpu:%d memory:%dG disk:%dG", osName[0], cupCore, memorySize, diskSize) + row.CreationTime = FormatDate(host.CreateTime) + row.State = host.State + row.Type = host.UHostType + "/" + host.HostType + list = append(list, row) + } + PrintTable(list, []string{"UHostName", "ResourceID", "UGroup", "ClassicNetwork", "Config", "Type", "CreationTime", "State"}) + } + }, + } + cmd.Flags().SortFlags = false + req.ProjectId = cmd.Flags().String("project-id", ConfigInstance.ProjectID, "Optional. Assign project-id") + req.Region = cmd.Flags().String("region", 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)") + req.Tag = cmd.Flags().String("ugroup", "", "Optional. UGroup") + req.Offset = cmd.Flags().Int("offset", 0, "Optional. Offset default 0") + req.Limit = cmd.Flags().Int("limit", 20, "Optional. Limit default 20, max value 100") + + return cmd +} + +//NewCmdUHostCreate [ucloud uhost create] +func NewCmdUHostCreate() *cobra.Command { + req := BizClient.NewCreateUHostInstanceRequest() + cmd := &cobra.Command{ + Use: "create", + Short: "Create UHost instance", + Long: "Create UHost instance", + Run: func(cmd *cobra.Command, args []string) { + *req.Memory *= 1024 + req.LoginMode = sdk.String("Password") + resp, err := BizClient.CreateUHostInstance(req) + if err != nil { + HandleError(err) + return + } + Cxt.Printf("UHost:%v created successfully!\n", resp.UHostIds) + }, + } + + n1Zone := map[string]bool{ + "cn-bj2-01": true, + "cn-bj2-03": true, + "cn-sh2-01": true, + "hk-01": true, + } + defaultUhostType := "N2" + if _, ok := n1Zone[ConfigInstance.Zone]; ok { + defaultUhostType = "N1" + } + + req.Disks = make([]uhost.UHostDisk, 2) + req.Disks[0].IsBoot = sdk.Bool(true) + req.Disks[0].Size = sdk.String("20") + req.Disks[1].IsBoot = sdk.Bool(false) + + flags := cmd.Flags() + flags.SortFlags = false + req.CPU = flags.Int("cpu", 4, "Required. The count of CPU cores. Optional parameters: {1, 2, 4, 8, 12, 16, 24, 32}") + req.Memory = flags.Int("memory", 8, "Required. Memory size. Unit: GB. Range: [1, 128], multiple of 2") + req.Password = flags.String("password", "", "Required. Password of the uhost user(root/ubuntu)") + req.ImageId = flags.String("image-id", "", "Required. The ID of image. see 'ucloud image list'") + req.VPCId = flags.String("vpc-id", "", "Optional. VPC ID. This field is required under VPC2.0. See 'ucloud vpc list'") + req.SubnetId = flags.String("subnet-id", "", "Optional. Subnet ID. This field is required under VPC2.0. See 'ucloud subnet list'") + req.Name = flags.String("name", "UHost", "Optional. UHost instance name") + req.ChargeType = flags.String("charge-type", "Month", "Optional.'Year',pay yearly;'Month',pay monthly;'Dynamic', pay hourly(requires access)") + req.Quantity = flags.Int("quantity", 1, "Optional. The duration of the instance. N years/months.") + req.ProjectId = flags.String("project-id", ConfigInstance.ProjectID, "Optional. Assign project-id") + req.Region = flags.String("region", ConfigInstance.Region, "Optional. Assign region") + req.Zone = flags.String("zone", ConfigInstance.Zone, "Optional. Assign availability zone") + req.UHostType = flags.String("type", defaultUhostType, "Optional. Default is 'N2' of which cpu is V4 and sata disk. also support 'N1' means V3 cpu and sata disk;'I2' means V4 cpu and ssd disk;'D1' means big data model;'G1' means GPU type, model for K80;'G2' model for P40; 'G3' model for V100") + req.NetCapability = flags.String("net-capability", "Normal", "Optional. Default is 'Normal', also support 'Super' which will enhance multiple times network capability as before") + req.Disks[0].Type = flags.String("boot-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[0].BackupType = flags.String("boot-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.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.String("data-disk-size", "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 DescribeSubnet.") + req.SecurityGroupId = flags.String("firewall-id", "", "Optional. Firewall Id, default: Web recommended firewall. see 'ucloud firewall list'.") + req.Tag = flags.String("ugroup", "Default", "Optional. Business group") + req.CouponId = flags.String("coupon-id", "", "Optional. Coupon ID, The Coupon can deduct part of the payment,see DescribeCoupon or https://accountv2.ucloud.cn") + + cmd.Flags().SetFlagValues("charge-type", []string{"Month", "Year", "Dynamic", "Trial"}) + cmd.Flags().SetFlagValues("cpu", []string{"1", "2", "4", "8", "12", "16", "24", "32"}) + cmd.Flags().SetFlagValues("type", []string{"N2", "N1", "I2", "D1", "G1", "G2", "G3"}) + cmd.Flags().SetFlagValues("net-capability", []string{"Normal", "Super"}) + cmd.Flags().SetFlagValues("boot-disk-type", []string{"LOCAL_NORMAL", "CLOUD_NORMAL", "LOCAL_SSD", "CLOUD_SSD", "EXCLUSIVE_LOCAL_DISK"}) + cmd.Flags().SetFlagValues("boot-disk-backup-type", []string{"NONE", "DATAARK"}) + cmd.Flags().SetFlagValues("data-disk-type", []string{"LOCAL_NORMAL", "CLOUD_NORMAL", "LOCAL_SSD", "CLOUD_SSD", "EXCLUSIVE_LOCAL_DISK"}) + cmd.Flags().SetFlagValues("data-disk-backup-type", []string{"NONE", "DATAARK"}) + + cmd.MarkFlagRequired("cpu") + cmd.MarkFlagRequired("memory") + cmd.MarkFlagRequired("password") + cmd.MarkFlagRequired("image-id") + + return cmd +} + +//NewCmdUHostDelete ucloud uhost delete +func NewCmdUHostDelete() *cobra.Command { + isDestory := sdk.Bool(false) + isEipReleased := sdk.Bool(false) + + req := BizClient.NewTerminateUHostInstanceRequest() + cmd := &cobra.Command{ + Use: "delete", + Short: "Delete Uhost instance", + Long: "Delete Uhost instance", + Run: func(cmd *cobra.Command, args []string) { + if *isDestory { + req.Destroy = sdk.Int(1) + } else { + req.Destroy = sdk.Int(0) + } + if *isEipReleased { + req.EIPReleased = sdk.String("yes") + } else { + req.EIPReleased = sdk.String("no") + } + resp, err := BizClient.TerminateUHostInstance(req) + if err != nil { + HandleError(err) + } else { + Cxt.Printf("UHost:[%v] deleted successfully!\n", resp.UHostId) + } + }, + } + + 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", "", "availability zone") + req.UHostId = cmd.Flags().String("resource-id", "", "ResourceID of the uhost instance( or UHostId)") + isDestory = cmd.Flags().Bool("destory", false, "false,the uhost instance will be thrown to UHost recycle If you have permission; true,the uhost instance will be deleted directly") + isEipReleased = cmd.Flags().Bool("eip-released", false, "false,Unbind EIP only; true, Unbind EIP and release it") + cmd.MarkFlagRequired("resource-id") + + return cmd +} + +//NewCmdUHostStop ucloud uhost stop +func NewCmdUHostStop() *cobra.Command { + req := BizClient.NewStopUHostInstanceRequest() + cmd := &cobra.Command{ + Use: "stop", + Short: "Shut down uhost instance", + Long: "Shut down uhost instance", + Run: func(cmd *cobra.Command, args []string) { + resp, err := BizClient.StopUHostInstance(req) + if err != nil { + HandleError(err) + } else { + Cxt.Printf("UHost:[%v] is shuting down. Wait a moment\n", resp.UhostId) + } + }, + } + 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", "", "Assign availability zone") + req.UHostId = cmd.Flags().String("resource-id", "", "ResourceID of the uhost instance( or UHostId)") + cmd.MarkFlagRequired("resource-id") + + return cmd +} + +//NewCmdUHostStart ucloud uhost start +func NewCmdUHostStart() *cobra.Command { + req := BizClient.NewStartUHostInstanceRequest() + cmd := &cobra.Command{ + Use: "start", + Short: "Start Uhost instance", + Long: "Start Uhost instance", + Example: "ucloud uhost start --resource-id uhost-xxx", + Run: func(cmd *cobra.Command, args []string) { + resp, err := BizClient.StartUHostInstance(req) + if err != nil { + HandleError(err) + } else { + Cxt.Printf("UHost:[%v] is starting. Wait a moment\n", resp.UhostId) + } + }, + } + 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", "", "Assign availability zone") + req.UHostId = cmd.Flags().String("resource-id", "", "ResourceID of the uhost instance( or UHostId)") + req.DiskPassword = cmd.Flags().String("disk-password", "", "Encrypted disk password") + cmd.MarkFlagRequired("resource-id") + return cmd +} + +//NewCmdUHostReboot ucloud uhost restart +func NewCmdUHostReboot() *cobra.Command { + req := BizClient.NewRebootUHostInstanceRequest() + cmd := &cobra.Command{ + Use: "restart", + Short: "Restart/reboot Uhost instance", + Long: "Restart/reboot Uhost instance", + Example: "ucloud uhost restart --resource-id uhost-xxx", + Run: func(cmd *cobra.Command, args []string) { + resp, err := BizClient.RebootUHostInstance(req) + if err != nil { + HandleError(err) + } else { + Cxt.Printf("UHost:[%v] is restarting. Wait a moment\n", resp.UhostId) + } + }, + } + 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", "", "Assign availability zone") + req.UHostId = cmd.Flags().String("resource-id", "", "ResourceID of the uhost instance( or UHostId)") + req.DiskPassword = cmd.Flags().String("disk-password", "", "Encrypted disk password") + cmd.MarkFlagRequired("resource-id") + return cmd +} + +//NewCmdUHostPoweroff ucloud uhost poweroff +func NewCmdUHostPoweroff() *cobra.Command { + req := BizClient.NewPoweroffUHostInstanceRequest() + cmd := &cobra.Command{ + Use: "poweroff", + Short: "Analog power off Uhost instnace. Danger! this operation may affect data integrity or cause file system corruption", + Long: "Analog power off Uhost instnace. Danger! this operation may affect data integrity or cause file system corruption", + Run: func(cmd *cobra.Command, args []string) { + resp, err := BizClient.PoweroffUHostInstance(req) + if err != nil { + HandleError(err) + } else { + Cxt.Printf("UHost:[%v] is power off\n", resp.UhostId) + } + }, + } + 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", "", "Assign availability zone") + req.UHostId = cmd.Flags().String("resource-id", "", "ResourceID of the uhost instance( or UHostId)") + return cmd +} + +//NewCmdUHostScale ucloud uhost scale +func NewCmdUHostScale() *cobra.Command { + req := BizClient.NewResizeUHostInstanceRequest() + cmd := &cobra.Command{ + Use: "scale", + Short: "Scale uhost instance,such as cpu core count, memory size, system disk size and data disk size", + Long: "Scale uhost instance,such as cpu core count, memory size, system disk size and data disk size", + Run: func(cmd *cobra.Command, args []string) { + if *req.CPU == 0 { + req.CPU = nil + } + if *req.Memory == 0 { + req.Memory = nil + } else { + *req.Memory *= 1024 + } + if *req.DiskSpace == 0 { + req.DiskSpace = nil + } + if *req.BootDiskSpace == 0 { + req.BootDiskSpace = nil + } + resp, err := BizClient.ResizeUHostInstance(req) + if err != nil { + HandleError(err) + } else { + Cxt.Printf("UHost:[%v] scaled\n", resp.UhostId) } }, } + 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", "", "Assign availability zone") + req.UHostId = cmd.Flags().String("resource-id", "", "ResourceID of the uhost instance( or UHostId)") + req.CPU = cmd.Flags().Int("cpu", 0, "The number of virtual CPU cores. Series1 {1, 2, 4, 8, 12, 16, 24, 32}. Series2 {1,2,4,8,16}") + req.Memory = cmd.Flags().Int("memory", 0, "memory size. Unit: GB. Range: [1, 128], multiple of 2") + req.DiskSpace = cmd.Flags().Int("data-disk-size", 0, "Data disk size,unit GB. Range[10,1000], SSD disk range[100,500]. Step 10") + req.BootDiskSpace = cmd.Flags().Int("system-disk-size", 0, "System disk size, unit GB. Range[20,100]. Step 10. System disk does not support shrinkage") + req.NetCapValue = cmd.Flags().Int("net-cap", 0, "NIC scale. 1,upgrade; 2,downgrade; 0,unchanged") + cmd.MarkFlagRequired("resource-id") return cmd } diff --git a/cmd/uhost_test.go b/cmd/uhost_test.go new file mode 100644 index 0000000000..1c930a9daa --- /dev/null +++ b/cmd/uhost_test.go @@ -0,0 +1,23 @@ +package cmd + +import ( + "testing" +) + +type listUhostTest struct { + expectedUhosts []string + expectedOut string +} + +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) +} diff --git a/cmd/unet.go b/cmd/unet.go new file mode 100644 index 0000000000..769cfbc64e --- /dev/null +++ b/cmd/unet.go @@ -0,0 +1,226 @@ +// Copyright © 2018 NAME HERE tony.li@ucloud.cn +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cmd + +import ( + "fmt" + "strings" + + "github.com/spf13/cobra" + . "github.com/ucloud/ucloud-cli/util" +) + +//NewCmdSubnet ucloud subnet +func NewCmdSubnet() *cobra.Command { + cmd := &cobra.Command{ + Use: "subnet", + Short: "List subnet", + Long: `List subnet`, + Args: cobra.NoArgs, + } + cmd.AddCommand(NewCmdSubnetList()) + + return cmd +} + +//SubnetRow 表格行 +type SubnetRow struct { + SubnetName string + ResourceID string + UGroup string + AffiliatedVPC string + NetworkSegment string + CreationTime string +} + +//NewCmdSubnetList ucloud subnet list +func NewCmdSubnetList() *cobra.Command { + req := BizClient.NewDescribeSubnetRequest() + cmd := &cobra.Command{ + Use: "list", + Short: "List subnet", + Long: `List subnet`, + Args: cobra.NoArgs, + Run: func(cmd *cobra.Command, args []string) { + resp, err := BizClient.DescribeSubnet(req) + if err != nil { + HandleError(err) + return + } + if global.json { + PrintJSON(resp.DataSet) + } else { + list := make([]SubnetRow, 0) + for _, sn := range resp.DataSet { + row := SubnetRow{} + row.SubnetName = sn.SubnetName + row.ResourceID = sn.SubnetId + row.UGroup = sn.Tag + row.AffiliatedVPC = fmt.Sprintf("%s/%s", sn.VPCName, sn.VPCId) + row.NetworkSegment = fmt.Sprintf("%s/%s", sn.Subnet, sn.Netmask) + row.CreationTime = FormatDate(sn.CreateTime) + list = append(list, row) + } + PrintTable(list, []string{"SubnetName", "ResourceID", "UGroup", "AffiliatedVPC", "NetworkSegment", "CreationTime"}) + } + }, + } + + flags := cmd.Flags() + flags.SortFlags = false + req.Region = flags.String("region", ConfigInstance.Region, "Optional. Region, see 'ucloud region'") + req.ProjectId = flags.String("project-id", ConfigInstance.ProjectID, "Optional. Project-id, see 'ucloud project list'") + flags.StringSliceVar(&req.SubnetIds, "subnet-id", []string{}, "Optional. Multiple values separated by commas") + req.VPCId = flags.String("vpc-id", "", "Optional. ResourceID of VPC") + req.Tag = flags.String("ugroup", "", "Optional. UGroup") + req.Offset = flags.Int("offset", 0, "Optional. offset default 0") + req.Limit = flags.Int("limit", 50, "Optional. max count") + + return cmd +} + +//NewCmdVPC ucloud vpc +func NewCmdVPC() *cobra.Command { + cmd := &cobra.Command{ + Use: "vpc", + Short: "List vpc", + Long: `List vpc`, + Args: cobra.NoArgs, + } + cmd.AddCommand(NewCmdVPCList()) + + return cmd +} + +//VPCRow 表格行 +type VPCRow struct { + VPCName string + ResourceID string + UGroup string + NetworkSegment string + SubnetCount int + CreationTime string +} + +//NewCmdVPCList ucloud vpc list +func NewCmdVPCList() *cobra.Command { + req := BizClient.NewDescribeVPCRequest() + cmd := &cobra.Command{ + Use: "list", + Short: "List vpc", + Long: "List vpc", + Args: cobra.NoArgs, + Run: func(cmd *cobra.Command, args []string) { + resp, err := BizClient.DescribeVPC(req) + if err != nil { + HandleError(err) + return + } + if global.json { + PrintJSON(resp.DataSet) + } else { + list := []VPCRow{} + for _, vpc := range resp.DataSet { + row := VPCRow{} + row.VPCName = vpc.Name + row.ResourceID = vpc.VPCId + row.UGroup = vpc.Tag + row.NetworkSegment = strings.Join(vpc.Network, ",") + row.SubnetCount = vpc.SubnetCount + row.CreationTime = FormatDate(vpc.CreateTime) + list = append(list, row) + } + PrintTable(list, []string{"VPCName", "ResourceID", "UGroup", "NetworkSegment", "SubnetCount", "CreationTime"}) + } + + }, + } + flags := cmd.Flags() + flags.SortFlags = false + req.Region = flags.String("region", ConfigInstance.Region, "Optional. Region, see 'ucloud region'") + req.ProjectId = flags.String("project-id", ConfigInstance.ProjectID, "Optional. Project-id, see 'ucloud project list'") + req.Tag = flags.String("ugroup", "", "Optional. UGroup") + flags.StringSliceVar(&req.VPCIds, "vpc-id", []string{}, "Optional. Multiple values separated by commas") + + return cmd +} + +//NewCmdFirewall ucloud firewall +func NewCmdFirewall() *cobra.Command { + cmd := &cobra.Command{ + Use: "firewall", + Short: "List extranet firewall", + Long: `List extranet firewall`, + Args: cobra.NoArgs, + } + cmd.AddCommand(NewCmdFirewallList()) + + return cmd +} + +//FirewallRow 表格行 +type FirewallRow struct { + ResourceID string + FirewallName string + Remark string + UGroup string + RuleAmount int + BoundResourceAmount int + CreationTime string +} + +//NewCmdFirewallList ucloud firewall list +func NewCmdFirewallList() *cobra.Command { + req := BizClient.NewDescribeFirewallRequest() + cmd := &cobra.Command{ + Use: "list", + Short: "List extranet firewall", + Long: `List extranet firewall`, + Run: func(cmd *cobra.Command, args []string) { + resp, err := BizClient.DescribeFirewall(req) + if err != nil { + HandleError(err) + return + } + if global.json { + PrintJSON(resp.DataSet) + } else { + list := []FirewallRow{} + for _, fw := range resp.DataSet { + row := FirewallRow{} + row.ResourceID = fw.FWId + row.FirewallName = fw.Name + row.Remark = fw.Remark + row.UGroup = fw.Tag + row.RuleAmount = len(fw.Rule) + row.BoundResourceAmount = fw.ResourceCount + row.CreationTime = FormatDate(fw.CreateTime) + list = append(list, row) + } + PrintTable(list, []string{"ResourceID", "FirewallName", "Remark", "UGroup", "RuleAmount", "BoundResourceAmount", "CreationTime"}) + } + }, + } + flags := cmd.Flags() + flags.SortFlags = false + req.Region = flags.String("region", ConfigInstance.Region, "Optional. Region, see 'ucloud region'") + req.ProjectId = flags.String("project-id", ConfigInstance.ProjectID, "Optional. Project-id, see 'ucloud project list'") + req.FWId = flags.String("firewall-id", "", "Optional. The Resource ID of firewall. Return all firewalls by default.") + req.ResourceType = flags.String("bound-resource-type", "", "Optional. The type of resource bound on the firewall") + req.ResourceId = flags.String("bound-resource-id", "", "Optional. The resource ID of resource bound on the firewall") + req.Offset = flags.String("offset", "0", "Optional. offset default 0") + req.Limit = flags.String("limit", "50", "Optional. max count") + return cmd +} diff --git a/cmd/version.go b/cmd/version.go deleted file mode 100644 index a7bcb1c8c8..0000000000 --- a/cmd/version.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright © 2018 NAME HERE tony.li@ucloud.cn -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package cmd - -import ( - "fmt" - - "github.com/spf13/cobra" -) - -var version = "0.1.2" - -//NewCmdVersion ucloud version -func NewCmdVersion() *cobra.Command { - return &cobra.Command{ - Use: "version", - Short: "Display UCloud CLI version", - Long: `Display UCloud CLI version`, - Run: func(cmd *cobra.Command, args []string) { - fmt.Println(version) - }, - } -} diff --git a/model/context.go b/model/context.go index dbac0eeff0..d02076e84f 100644 --- a/model/context.go +++ b/model/context.go @@ -4,8 +4,6 @@ import ( "fmt" "io" "sync" - - "github.com/ucloud/ucloud-sdk-go/sdk" ) var context *Context @@ -13,35 +11,48 @@ var once sync.Once // Context 执行环境 type Context struct { - writer io.Writer - clientConfig *sdk.ClientConfig + writer io.Writer + data map[string]interface{} +} + +//Print 打印一行 +func (c *Context) Print(a ...interface{}) (n int, err error) { + text := fmt.Sprint(a...) + n, err = c.writer.Write([]byte(text)) + return +} + +//Println 打印一行 +func (c *Context) Println(a ...interface{}) (n int, err error) { + text := fmt.Sprintln(a...) + n, err = c.writer.Write([]byte(text)) + return } -// Println 在当前执行环境打印一行 -func (p *Context) Println(a ...interface{}) (n int, err error) { - return fmt.Fprintln(p.writer, a...) +//Printf 根据格式字符串打印 +func (c *Context) Printf(format string, a ...interface{}) (n int, err error) { + text := fmt.Sprintf(format, a...) + n, err = c.writer.Write([]byte(text)) + return } -// Print 在当前执行环境打印一串 -func (p *Context) Print(a ...interface{}) (n int, err error) { - return fmt.Fprint(p.writer, a...) +//PrintErr 打印错误 +func (c *Context) PrintErr(uerr error) (n int, err error) { + text := fmt.Sprintf("Error:%v\n", uerr) + n, err = c.writer.Write([]byte(text)) + return } -//AppendError 添加上报的错误 -func (p *Context) AppendError(err error) { - tracerData := p.clientConfig.TracerData - errorStr, ok := tracerData["error"].(string) - if ok { - tracerData["error"] = errorStr + "->" + err.Error() - } else { - tracerData["error"] = err.Error() - } +//AppendInfo 添加记录 +func (c *Context) AppendInfo(key string, content interface{}) { + c.data[key] = content } // GetContext 创建一个单例的Context -func GetContext(writer io.Writer, clientConfig *sdk.ClientConfig) *Context { +func GetContext(writer io.Writer) *Context { once.Do(func() { - context = &Context{writer, clientConfig} + data := make(map[string]interface{}, 0) + context = &Context{writer, data} }) return context } diff --git a/model/context_test.go b/model/context_test.go index d0aae65dc0..066e220798 100644 --- a/model/context_test.go +++ b/model/context_test.go @@ -1,17 +1,20 @@ package model import ( + "fmt" "os" "testing" - - "github.com/ucloud/ucloud-sdk-go/sdk" ) -var context_test = Context{ +var ctx = Context{ os.Stdout, - &sdk.ClientConfig{}, } func TestPrintln(t *testing.T) { - context_test.Println("test print") + ctx.Println("test print") +} + +func TestPrintErr(t *testing.T) { + err := fmt.Errorf("error test") + ctx.PrintErr(err) } diff --git a/util/cli.go b/util/cli.go new file mode 100644 index 0000000000..db32ee4db8 --- /dev/null +++ b/util/cli.go @@ -0,0 +1,252 @@ +package util + +import ( + "bufio" + "encoding/json" + "fmt" + "io" + "os" + "reflect" + "runtime" + "strconv" + "strings" + "time" + "unicode" + + "github.com/ucloud/ucloud-sdk-go/sdk" + uerr "github.com/ucloud/ucloud-sdk-go/sdk/error" + "github.com/ucloud/ucloud-sdk-go/sdk/response" + service "github.com/ucloud/ucloud-sdk-go/services" + + "github.com/ucloud/ucloud-cli/model" +) + +//ConfigPath 配置文件路径 +const ConfigPath = ".ucloud" + +//GAP 表格列直接的间隔字符数 +const GAP = 2 + +//Cxt 上下文 +var Cxt = model.GetContext(os.Stdout) + +//SdkClient 用于上报数据 +var SdkClient *sdk.Client + +//BizClient 用于调用业务接口 +var BizClient *service.Client + +//GetHomePath 获取家目录 +func GetHomePath() string { + if runtime.GOOS == "windows" { + home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") + if home == "" { + home = os.Getenv("USERPROFILE") + } + return home + } + return os.Getenv("HOME") +} + +//MosaicString 对字符串敏感部分打马赛克 如公钥私钥 +func MosaicString(s string, beginChars, lastChars int) string { + r := len(s) - lastChars - beginChars + if r > 0 { + return s[:beginChars] + strings.Repeat("*", r) + s[(r+beginChars):] + } + return strings.Repeat("*", len(s)) +} + +//AppendToFile 添加到文件中 +func AppendToFile(name string, content string) error { + f, err := os.OpenFile(name, os.O_RDWR|os.O_APPEND, 0) + if err != nil { + return err + } + defer f.Close() + _, err = f.WriteString(fmt.Sprintf("\n%s\n", content)) + return err +} + +//LineInFile 检查某一行是否在某文件中 +func LineInFile(fileName string, lookFor string) bool { + f, err := os.Open(fileName) + if err != nil { + return false + } + defer f.Close() + r := bufio.NewReader(f) + prefix := []byte{} + for { + line, isPrefix, err := r.ReadLine() + if err == io.EOF { + return false + } + if err != nil { + return false + } + if isPrefix { + prefix = append(prefix, line...) + continue + } + line = append(prefix, line...) + if string(line) == lookFor { + return true + } + prefix = prefix[:0] + } +} + +//GetConfigPath 获取配置文件的绝对路径 +func GetConfigPath() string { + path := GetHomePath() + "/" + ConfigPath + if _, err := os.Stat(path); os.IsNotExist(err) { + err = os.MkdirAll(path, 0755) + if err != nil { + panic(err) + } + } + return path +} + +//HandleBizError 处理RetCode != 0 的业务异常 +func HandleBizError(resp response.Common) error { + format := "Something wrong. RetCode:%d. Message:%s\n" + Cxt.Printf(format, resp.GetRetCode(), resp.GetMessage()) + return fmt.Errorf(format, resp.GetRetCode(), resp.GetMessage()) +} + +//HandleError 处理错误,业务错误 和 HTTP错误 +func HandleError(err error) { + if uErr, ok := err.(uerr.Error); ok && uErr.Code() != 0 { + format := "Something wrong. RetCode:%d. Message:%s\n" + Cxt.Printf(format, uErr.Code(), uErr.Message()) + } else { + Cxt.PrintErr(err) + } +} + +//PrintJSON 以JSON格式打印数据集合 +func PrintJSON(dataSet interface{}) error { + bytes, err := json.MarshalIndent(dataSet, "", " ") + if err != nil { + return err + } + Cxt.Println(string(bytes)) + return nil +} + +//PrintTable 以表格方式打印数据集合 +func PrintTable(dataSet interface{}, fieldList []string) error { + dataSetVal := reflect.ValueOf(dataSet) + + switch dataSetVal.Kind() { + case reflect.Slice, reflect.Array: + displaySlice(dataSetVal, fieldList) + case reflect.Map: + displayMap(dataSetVal, fieldList) + default: + return fmt.Errorf("PrintTable expect array,slice or map, accept %T", dataSet) + } + return nil +} + +func displayMap(mapVal reflect.Value, fieldList []string) { + fmt.Println(mapVal, fieldList) + //todo +} + +func displaySlice(listVal reflect.Value, fieldList []string) { + showFieldMap := make(map[string]int) + for _, field := range fieldList { + showFieldMap[field] = len([]rune(field)) + } + rowList := make([]map[string]interface{}, 0) + for i := 0; i < listVal.Len(); i++ { + elemVal := listVal.Index(i) + elemType := elemVal.Type() + row := make(map[string]interface{}) + for j := 0; j < elemVal.NumField(); j++ { + field := elemVal.Field(j) + fieldName := elemType.Field(j).Name + if _, ok := showFieldMap[fieldName]; ok { + row[fieldName] = field.Interface() + text := fmt.Sprintf("%v", field.Interface()) + width := calcWidth(text) + if showFieldMap[fieldName] < width { + showFieldMap[fieldName] = width + } + } + } + rowList = append(rowList, row) + } + + for _, field := range fieldList { + tmpl := "%-" + strconv.Itoa(showFieldMap[field]+GAP) + "s" + fmt.Printf(tmpl, field) + } + fmt.Printf("\n") + + for _, row := range rowList { + for _, field := range fieldList { + cutWidth := calcCutWidth(fmt.Sprintf("%v", row[field])) + tmpl := "%-" + strconv.Itoa(showFieldMap[field]-cutWidth+GAP) + "v" + fmt.Printf(tmpl, row[field]) + } + fmt.Printf("\n") + } +} + +func calcCutWidth(text string) int { + set := []*unicode.RangeTable{unicode.Han} + width := 0 + for _, r := range text { + if unicode.IsOneOf(set, r) { + width++ + } + } + return width +} + +func calcWidth(text string) int { + set := []*unicode.RangeTable{unicode.Han} + width := 0 + for _, r := range text { + if unicode.IsOneOf(set, r) { + width += 2 + } else { + width++ + } + } + return width +} + +//FormatDate 格式化时间,把以秒为单位的时间戳格式化未年月日 +func FormatDate(seconds int) string { + return time.Unix(int64(seconds), 0).Format("2006-01-02") +} + +//RegionLabel regionlable +var RegionLabel = map[string]string{ + "cn-bj1": "Beijing1", + "cn-bj2": "Beijing2", + "cn-sh2": "Shanghai2", + "cn-gd": "Guangzhou", + "hk": "Hongkong", + "us-ca": "LosAngeles", + "us-ws": "Washington", + "ge-fra": "Frankfurt", + "th-bkk": "Bangkok", + "kr-seoul": "Seoul", + "sg": "Singapore", + "tw-kh": "Kaohsiung", + "rus-mosc": "Moscow", + "jpn-tky": "Tokyo", + "tw-tp": "TaiPei", + "uae-dubai": "Dubai", + "idn-jakarta": "Jakarta", + "ind-mumbai": "Bombay", + "bra-saopaulo": "SaoPaulo", + "uk-london": "London", + "afr-nigeria": "Lagos", +} diff --git a/util/sdk_test.go b/util/cli_test.go similarity index 60% rename from util/sdk_test.go rename to util/cli_test.go index 4d5a8a3d2d..1dd3cbadee 100644 --- a/util/sdk_test.go +++ b/util/cli_test.go @@ -5,6 +5,6 @@ import "testing" func TestGetHomePath(t *testing.T) { home := GetHomePath() if home == "" { - t.Errorf("home shoud not be empty") + t.Errorf("util.GetHomePath(), home shoud not be empty. Got :%q", home) } } diff --git a/model/config.go b/util/config.go similarity index 62% rename from model/config.go rename to util/config.go index 7502354821..7244d3ea5b 100644 --- a/model/config.go +++ b/util/config.go @@ -1,27 +1,31 @@ -package model +package util import ( "encoding/json" "fmt" "io/ioutil" + "os" "strings" "time" - "github.com/ucloud/ucloud-cli/util" "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/auth" - "github.com/ucloud/ucloud-sdk-go/service/uaccount/types" + service "github.com/ucloud/ucloud-sdk-go/services" + "github.com/ucloud/ucloud-sdk-go/services/uaccount" ) const configFile = "config.json" +//Version 版本号 +const Version = "0.1.3" + //ConfigPath 配置文件路径 //ConfigInstance 配置实例, 程序加载时生成 var ConfigInstance = &Config{} //ClientConfig 创建sdk client参数 -var ClientConfig *sdk.ClientConfig +var ClientConfig *sdk.Config //Credential 创建sdk client参数 var Credential *auth.Credential @@ -31,31 +35,32 @@ type Config struct { PublicKey string `json:"public_key"` PrivateKey string `json:"private_key"` Region string `json:"region"` + Zone string `json:"zone"` ProjectID string `json:"project_id"` } //ConfigPublicKey 输入公钥 func (p *Config) ConfigPublicKey() error { - context.Print("Your public-key:") + Cxt.Print("Your public-key:") _, err := fmt.Scanf("%s\n", &p.PublicKey) p.PublicKey = strings.TrimSpace(p.PublicKey) Credential.PublicKey = p.PublicKey p.SaveConfig() if err != nil { - context.Println(err) + Cxt.Println(err) } return err } //ConfigPrivateKey 输入私钥 func (p *Config) ConfigPrivateKey() error { - context.Print("Your private-key:") + Cxt.Print("Your private-key:") _, err := fmt.Scanf("%s\n", &p.PrivateKey) p.PrivateKey = strings.TrimSpace(p.PrivateKey) Credential.PrivateKey = p.PrivateKey p.SaveConfig() if err != nil { - context.Println(err) + Cxt.Println(err) } return err } @@ -63,10 +68,10 @@ func (p *Config) ConfigPrivateKey() error { //ConfigRegion 输入默认Region func (p *Config) ConfigRegion() error { p.LoadConfig() - context.Print("Default region:") + Cxt.Print("Default region:") _, err := fmt.Scanf("%s\n", &p.Region) if err != nil { - context.Println(err) + Cxt.PrintErr(err) return err } p.Region = strings.TrimSpace(p.Region) @@ -78,10 +83,10 @@ func (p *Config) ConfigRegion() error { //ConfigProjectID 输入默认ProjectID func (p *Config) ConfigProjectID() error { p.LoadConfig() - context.Print("Default project-id:") + Cxt.Print("Default project-id:") _, err := fmt.Scanf("%s\n", &p.ProjectID) if err != nil { - context.Println(err) + Cxt.Println(err) return err } p.ProjectID = strings.TrimSpace(p.ProjectID) @@ -91,14 +96,15 @@ func (p *Config) ConfigProjectID() error { } //GetClientConfig 用来生成sdkClient -func (p *Config) GetClientConfig(isDebug bool) *sdk.ClientConfig { +func (p *Config) GetClientConfig(isDebug bool) *sdk.Config { p.LoadConfig() - clientConfig := &sdk.ClientConfig{ + clientConfig := &sdk.Config{ Region: p.Region, ProjectId: p.ProjectID, - BaseUrl: "https://api.ucloud.cn/", - Timeout: 10 * time.Second, - LogLevel: 1, + BaseUrl: ClientConfig.BaseUrl, + Timeout: ClientConfig.Timeout, + UserAgent: ClientConfig.UserAgent, + LogLevel: ClientConfig.LogLevel, } if isDebug == true { clientConfig.LogLevel = 5 @@ -116,18 +122,15 @@ func (p *Config) GetCredential() *auth.Credential { } //ListConfig 查看配置 -func (p *Config) ListConfig() error { - +func (p *Config) ListConfig(json bool) error { tmpConfig := *p - tmpConfig.PrivateKey = util.MosaicString(tmpConfig.PrivateKey, 8, 5) - tmpConfig.PublicKey = util.MosaicString(tmpConfig.PublicKey, 8, 5) + tmpConfig.PrivateKey = MosaicString(tmpConfig.PrivateKey, 8, 5) + tmpConfig.PublicKey = MosaicString(tmpConfig.PublicKey, 8, 5) - bytes, err := json.MarshalIndent(tmpConfig, "", " ") - if err != nil { - return err + if json { + return PrintJSON(tmpConfig) } - context.Println(string(bytes)) - return nil + return PrintTable([]Config{tmpConfig}, []string{"PublicKey", "PrivateKey", "Region", "Zone", "ProjectID"}) } //ClearConfig 清空配置 @@ -142,30 +145,37 @@ func (p *Config) SaveConfig() error { if err != nil { return err } - fileFullPath := util.GetConfigPath() + "/" + configFile + fileFullPath := GetConfigPath() + "/" + configFile err = ioutil.WriteFile(fileFullPath, bytes, 0600) return err } //LoadConfig 从本地文件加载配置 func (p *Config) LoadConfig() error { - fileFullPath := util.GetConfigPath() + "/" + configFile - content, err := ioutil.ReadFile(fileFullPath) - if err != nil { - return err + fileFullPath := GetConfigPath() + "/" + configFile + if _, err := os.Stat(fileFullPath); os.IsNotExist(err) { + p = new(Config) + } else { + content, err := ioutil.ReadFile(fileFullPath) + if err != nil { + return err + } + json.Unmarshal(content, p) } - json.Unmarshal(content, p) return nil } //LoadUserInfo 从~/.ucloud/user.json加载用户信息 -func LoadUserInfo() (*types.UserInfo, error) { - fileFullPath := util.GetConfigPath() + "/user.json" +func LoadUserInfo() (*uaccount.UserInfo, error) { + fileFullPath := GetConfigPath() + "/user.json" + if _, err := os.Stat(fileFullPath); os.IsNotExist(err) { + return new(uaccount.UserInfo), nil + } content, err := ioutil.ReadFile(fileFullPath) if err != nil { return nil, err } - var user types.UserInfo + var user uaccount.UserInfo err = json.Unmarshal(content, &user) if err != nil { return nil, err @@ -175,10 +185,12 @@ func LoadUserInfo() (*types.UserInfo, error) { func init() { ConfigInstance.LoadConfig() - ClientConfig = &sdk.ClientConfig{ - Region: ConfigInstance.Region, + 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), LogLevel: 1, } @@ -186,4 +198,10 @@ func init() { PublicKey: ConfigInstance.PublicKey, PrivateKey: ConfigInstance.PrivateKey, } + + //sdkClient 用于上报数据 + SdkClient = sdk.NewClient(ClientConfig, Credential) + + //bizClient 用于调用业务接口 + BizClient = service.NewClient(ClientConfig, Credential) } diff --git a/util/sdk.go b/util/sdk.go deleted file mode 100644 index 9777ddaded..0000000000 --- a/util/sdk.go +++ /dev/null @@ -1,84 +0,0 @@ -package util - -import ( - "bufio" - "fmt" - "io" - "os" - "runtime" - "strings" -) - -const ConfigPath = ".ucloud" - -//GetHomePath 获取家目录 -func GetHomePath() string { - if runtime.GOOS == "windows" { - home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") - if home == "" { - home = os.Getenv("USERPROFILE") - } - return home - } - return os.Getenv("HOME") -} - -//MosaicString 对字符串敏感部分打马赛克 如公钥私钥 -func MosaicString(s string, beginChars, lastChars int) string { - r := len(s) - lastChars - beginChars - if r > 0 { - return s[:beginChars] + strings.Repeat("*", r) + s[(r+beginChars):] - } - return strings.Repeat("*", len(s)) -} - -//AppendToFile 添加到文件中 -func AppendToFile(name string, content string) error { - f, err := os.OpenFile(name, os.O_RDWR|os.O_APPEND, 0) - if err != nil { - return err - } - defer f.Close() - _, err = f.WriteString(fmt.Sprintf("\n%s\n", content)) - return err -} - -//LineInFile 检查某一行是否在某文件中 -func LineInFile(fileName string, lookFor string) bool { - f, err := os.Open(fileName) - if err != nil { - return false - } - defer f.Close() - r := bufio.NewReader(f) - prefix := []byte{} - for { - line, isPrefix, err := r.ReadLine() - if err == io.EOF { - return false - } - if err != nil { - return false - } - if isPrefix { - prefix = append(prefix, line...) - continue - } - line = append(prefix, line...) - if string(line) == lookFor { - return true - } - prefix = prefix[:0] - } -} - -func GetConfigPath() string { - path := GetHomePath() + "/" + ConfigPath - if _, err := os.Stat(path); os.IsNotExist(err) { - err = os.MkdirAll(path, 0755) - if err != nil { - panic(err) - } - } - return path -} diff --git a/vendor/github.com/spf13/cobra/README.md b/vendor/github.com/spf13/cobra/README.md index da256087d3..ce96133bee 100644 --- a/vendor/github.com/spf13/cobra/README.md +++ b/vendor/github.com/spf13/cobra/README.md @@ -16,7 +16,7 @@ Many of the most widely used Go projects are built using Cobra including: * [CockroachDB](http://www.cockroachlabs.com/) * [Bleve](http://www.blevesearch.com/) * [ProjectAtomic (enterprise)](http://www.projectatomic.io/) -* [GiantSwarm's swarm](https://github.com/giantswarm/cli) +* [Giant Swarm's gsctl](https://github.com/giantswarm/gsctl) * [Nanobox](https://github.com/nanobox-io/nanobox)/[Nanopack](https://github.com/nanopack) * [rclone](http://rclone.org/) * [nehm](https://github.com/bogem/nehm) @@ -152,7 +152,6 @@ In a Cobra app, typically the main.go file is very bare. It serves one purpose: package main import ( - "{pathToYourApp}/cmd" ) diff --git a/vendor/github.com/spf13/cobra/cobra.go b/vendor/github.com/spf13/cobra/cobra.go index 57bd65ba61..5e0b3241f6 100644 --- a/vendor/github.com/spf13/cobra/cobra.go +++ b/vendor/github.com/spf13/cobra/cobra.go @@ -19,6 +19,7 @@ package cobra import ( "fmt" "io" + "os" "reflect" "strconv" "strings" @@ -34,6 +35,7 @@ var templateFuncs = template.FuncMap{ "rpad": rpad, "gt": Gt, "eq": Eq, + "add": add, } var initializers []func(*Command) @@ -72,7 +74,7 @@ func AddTemplateFuncs(tmplFuncs template.FuncMap) { // OnInitialize sets the passed functions to be run when each command's // Execute method is called. -func OnInitialize(y ...func(cmd *Command)) { +func OnInitialize(y ...func(*Command)) { initializers = append(initializers, y...) } @@ -108,6 +110,16 @@ func Gt(a interface{}, b interface{}) bool { return left > right } +func add(a, b int) int { + return a + b +} + +//NeedComplete need complete or not +func NeedComplete() bool { + line := os.Getenv("COMP_LINE") + return line != "" +} + // FIXME Eq is unused by cobra and should be removed in a version 2. It exists only for compatibility with users of cobra. // Eq takes two types and checks whether they are equal. Supported types are int and string. Unsupported types will panic. diff --git a/vendor/github.com/spf13/cobra/command.go b/vendor/github.com/spf13/cobra/command.go index 80d1d3b778..c8a66c0f16 100644 --- a/vendor/github.com/spf13/cobra/command.go +++ b/vendor/github.com/spf13/cobra/command.go @@ -22,6 +22,7 @@ import ( "os" "path/filepath" "sort" + "strconv" "strings" flag "github.com/spf13/pflag" @@ -467,6 +468,7 @@ func shortHasNoOptDefVal(name string, fs *flag.FlagSet) bool { return flag.NoOptDefVal != "" } +//去除命令行末尾的flag相关字符 func stripFlags(args []string, c *Command) []string { if len(args) == 0 { return args @@ -817,6 +819,11 @@ func (c *Command) ExecuteC() (cmd *Command, err error) { // overriding c.InitDefaultHelpCmd() + if NeedComplete() { + err := c.complete() + return c, err + } + var args []string // Workaround FAIL with "go test -v" or "cobra.test -test.v", see #155 @@ -967,6 +974,96 @@ Simply type ` + c.Name() + ` help [path to command] for full details.`, c.AddCommand(c.helpCommand) } +//complete attampt to word completion +func (c *Command) complete() error { + line := os.Getenv("COMP_LINE") + if line == "" { + return nil + } + point := os.Getenv("COMP_POINT") + p, err := strconv.Atoi(point) + if err != nil { + return err + } + if length := len(line); p > length { + p = length + } + compLine := line[0:p] + lastSpaceIndex := strings.LastIndex(compLine, " ") + currentWord := compLine[lastSpaceIndex+1 : p] + args := strings.Fields(compLine)[1:] + compCmd, _, err := c.Root().Find(args) + if err != nil { + compCmd = c + } + compCmd.InitDefaultHelpFlag() + + //complete flags, flag values or sub commands + if length := len(args); length > 0 && strings.HasPrefix(args[length-1], "-") { //需要被补全的单词开头是‘-’时,补全flag和value + completeFlagValues(compCmd, args, currentWord) + } else if len(compCmd.Commands()) > 0 { //需要补全的单词开头没有‘-’,补全子命令 + completeSubCommands(compCmd, currentWord) + } else if length := len(args); length > 0 && compLine[p-1] != 32 { //需要补全的单词开头没有‘-’,前一个单词也不是命令,光标当前位置非空格,尝试补全参数值(value) + completeFlagValues(compCmd, args, currentWord) + } else { //需要补全的单词开头没有‘-’,也没有子命令,默认尝试补全参数 flag + completeFlags(compCmd, currentWord) + } + return nil +} + +func completeFlags(cmd *Command, word string) { + cmd.mergePersistentFlags() + cmd.Flags().VisitAll(func(f *flag.Flag) { + completedWord := "--" + f.Name + if strings.HasPrefix(completedWord, word) { + fmt.Fprintln(cmd.OutOrStdout(), completedWord) + } + }) +} + +func completeSubCommands(cmd *Command, word string) { + for _, cmd := range cmd.Commands() { + if strings.HasPrefix(cmd.Name(), word) { + fmt.Fprintln(cmd.OutOrStdout(), cmd.Name()) + } + } +} + +func completeFlagValues(cmd *Command, args []string, word string) { + cmd.mergePersistentFlags() + + var _flag *flag.Flag + var lastArg = args[len(args)-1] + + if strings.HasPrefix(lastArg, "--") { + _flag = cmd.Flags().Lookup(lastArg[2:]) + } else if strings.HasPrefix(lastArg, "-") && len(lastArg) == 2 { + _flag = cmd.Flags().ShorthandLookup(lastArg[1:]) + } else if len(args) >= 2 { + arg := args[len(args)-2] + _flag = cmd.Flags().Lookup(arg[2:]) + } + + if _flag == nil { + cmd.Flags().VisitAll(func(f *flag.Flag) { + completedWord := "--" + f.Name + if strings.HasPrefix(completedWord, word) { + fmt.Fprintln(cmd.OutOrStdout(), "--"+f.Name) + } + }) + return + } + + if _flag.Annotations != nil { + values := _flag.Annotations[flag.BashCompleteFlagValues] + for _, v := range values { + if strings.HasPrefix(v, word) { + fmt.Fprintln(cmd.OutOrStdout(), v) + } + } + } +} + // ResetCommands delete parent, subcommand and help command from c. func (c *Command) ResetCommands() { c.parent = nil diff --git a/vendor/github.com/spf13/pflag/bytes.go b/vendor/github.com/spf13/pflag/bytes.go index 67d5304570..12c58db9fe 100644 --- a/vendor/github.com/spf13/pflag/bytes.go +++ b/vendor/github.com/spf13/pflag/bytes.go @@ -1,7 +1,6 @@ package pflag import ( - "encoding/base64" "encoding/hex" "fmt" "strings" @@ -10,12 +9,10 @@ import ( // BytesHex adapts []byte for use as a flag. Value of flag is HEX encoded type bytesHexValue []byte -// String implements pflag.Value.String. func (bytesHex bytesHexValue) String() string { return fmt.Sprintf("%X", []byte(bytesHex)) } -// Set implements pflag.Value.Set. func (bytesHex *bytesHexValue) Set(value string) error { bin, err := hex.DecodeString(strings.TrimSpace(value)) @@ -28,7 +25,6 @@ func (bytesHex *bytesHexValue) Set(value string) error { return nil } -// Type implements pflag.Value.Type. func (*bytesHexValue) Type() string { return "bytesHex" } @@ -107,103 +103,3 @@ func BytesHex(name string, value []byte, usage string) *[]byte { func BytesHexP(name, shorthand string, value []byte, usage string) *[]byte { return CommandLine.BytesHexP(name, shorthand, value, usage) } - -// BytesBase64 adapts []byte for use as a flag. Value of flag is Base64 encoded -type bytesBase64Value []byte - -// String implements pflag.Value.String. -func (bytesBase64 bytesBase64Value) String() string { - return base64.StdEncoding.EncodeToString([]byte(bytesBase64)) -} - -// Set implements pflag.Value.Set. -func (bytesBase64 *bytesBase64Value) Set(value string) error { - bin, err := base64.StdEncoding.DecodeString(strings.TrimSpace(value)) - - if err != nil { - return err - } - - *bytesBase64 = bin - - return nil -} - -// Type implements pflag.Value.Type. -func (*bytesBase64Value) Type() string { - return "bytesBase64" -} - -func newBytesBase64Value(val []byte, p *[]byte) *bytesBase64Value { - *p = val - return (*bytesBase64Value)(p) -} - -func bytesBase64ValueConv(sval string) (interface{}, error) { - - bin, err := base64.StdEncoding.DecodeString(sval) - if err == nil { - return bin, nil - } - - return nil, fmt.Errorf("invalid string being converted to Bytes: %s %s", sval, err) -} - -// GetBytesBase64 return the []byte value of a flag with the given name -func (f *FlagSet) GetBytesBase64(name string) ([]byte, error) { - val, err := f.getFlagType(name, "bytesBase64", bytesBase64ValueConv) - - if err != nil { - return []byte{}, err - } - - return val.([]byte), nil -} - -// BytesBase64Var defines an []byte flag with specified name, default value, and usage string. -// The argument p points to an []byte variable in which to store the value of the flag. -func (f *FlagSet) BytesBase64Var(p *[]byte, name string, value []byte, usage string) { - f.VarP(newBytesBase64Value(value, p), name, "", usage) -} - -// BytesBase64VarP is like BytesBase64Var, but accepts a shorthand letter that can be used after a single dash. -func (f *FlagSet) BytesBase64VarP(p *[]byte, name, shorthand string, value []byte, usage string) { - f.VarP(newBytesBase64Value(value, p), name, shorthand, usage) -} - -// BytesBase64Var defines an []byte flag with specified name, default value, and usage string. -// The argument p points to an []byte variable in which to store the value of the flag. -func BytesBase64Var(p *[]byte, name string, value []byte, usage string) { - CommandLine.VarP(newBytesBase64Value(value, p), name, "", usage) -} - -// BytesBase64VarP is like BytesBase64Var, but accepts a shorthand letter that can be used after a single dash. -func BytesBase64VarP(p *[]byte, name, shorthand string, value []byte, usage string) { - CommandLine.VarP(newBytesBase64Value(value, p), name, shorthand, usage) -} - -// BytesBase64 defines an []byte flag with specified name, default value, and usage string. -// The return value is the address of an []byte variable that stores the value of the flag. -func (f *FlagSet) BytesBase64(name string, value []byte, usage string) *[]byte { - p := new([]byte) - f.BytesBase64VarP(p, name, "", value, usage) - return p -} - -// BytesBase64P is like BytesBase64, but accepts a shorthand letter that can be used after a single dash. -func (f *FlagSet) BytesBase64P(name, shorthand string, value []byte, usage string) *[]byte { - p := new([]byte) - f.BytesBase64VarP(p, name, shorthand, value, usage) - return p -} - -// BytesBase64 defines an []byte flag with specified name, default value, and usage string. -// The return value is the address of an []byte variable that stores the value of the flag. -func BytesBase64(name string, value []byte, usage string) *[]byte { - return CommandLine.BytesBase64P(name, "", value, usage) -} - -// BytesBase64P is like BytesBase64, but accepts a shorthand letter that can be used after a single dash. -func BytesBase64P(name, shorthand string, value []byte, usage string) *[]byte { - return CommandLine.BytesBase64P(name, shorthand, value, usage) -} diff --git a/vendor/github.com/spf13/pflag/flag.go b/vendor/github.com/spf13/pflag/flag.go index 5cc710ccdd..0032d447e1 100644 --- a/vendor/github.com/spf13/pflag/flag.go +++ b/vendor/github.com/spf13/pflag/flag.go @@ -122,6 +122,9 @@ const ( ExitOnError // PanicOnError will panic() if an error is found when parsing flags PanicOnError + + //BashCompleteFlagValues the key in Flag.Annotations + BashCompleteFlagValues = "bash_complete_flag_values" ) // ParseErrorsWhitelist defines the parsing errors that can be ignored @@ -491,6 +494,24 @@ func (f *FlagSet) SetAnnotation(name, key string, values []string) error { return nil } +//SetFlagValues set values for a flag. Useful when auto completing the flag value +func (f *FlagSet) SetFlagValues(name string, values []string) error { + return f.SetAnnotation(name, BashCompleteFlagValues, values) +} + +//GetFlagValues set values for a flag. Useful when auto completing the flag value +func (f *FlagSet) GetFlagValues(name string) ([]string, error) { + normalName := f.normalizeFlagName(name) + flag, ok := f.formal[normalName] + if !ok { + return nil, fmt.Errorf("no such flag -%v", name) + } + if flag.Annotations == nil { + flag.Annotations = map[string][]string{} + } + return flag.Annotations[BashCompleteFlagValues], nil +} + // Changed returns true if the flag was explicitly set during Parse() and false // otherwise func (f *FlagSet) Changed(name string) bool { @@ -739,6 +760,23 @@ func (f *FlagSet) FlagUsages() string { return f.FlagUsagesWrapped(0) } +//FlagNames returns a string containing all flags names in the FlagSet. Separated by " | " +func (f *FlagSet) FlagNames() string { + buf := new(bytes.Buffer) + sep := " | " + f.VisitAll(func(flag *Flag) { + if flag.Hidden { + return + } + line := fmt.Sprintf("--%s"+sep, flag.Name) + fmt.Fprint(buf, line) + }) + result := buf.String() + result = strings.Trim(result, sep) + result = wrap(22, 100, result) + return result +} + // PrintDefaults prints to standard error the default values of all defined command-line flags. func PrintDefaults() { CommandLine.PrintDefaults() diff --git a/vendor/github.com/spf13/pflag/string_to_int.go b/vendor/github.com/spf13/pflag/string_to_int.go deleted file mode 100644 index 5ceda3965d..0000000000 --- a/vendor/github.com/spf13/pflag/string_to_int.go +++ /dev/null @@ -1,149 +0,0 @@ -package pflag - -import ( - "bytes" - "fmt" - "strconv" - "strings" -) - -// -- stringToInt Value -type stringToIntValue struct { - value *map[string]int - changed bool -} - -func newStringToIntValue(val map[string]int, p *map[string]int) *stringToIntValue { - ssv := new(stringToIntValue) - ssv.value = p - *ssv.value = val - return ssv -} - -// Format: a=1,b=2 -func (s *stringToIntValue) Set(val string) error { - ss := strings.Split(val, ",") - out := make(map[string]int, len(ss)) - for _, pair := range ss { - kv := strings.SplitN(pair, "=", 2) - if len(kv) != 2 { - return fmt.Errorf("%s must be formatted as key=value", pair) - } - var err error - out[kv[0]], err = strconv.Atoi(kv[1]) - if err != nil { - return err - } - } - if !s.changed { - *s.value = out - } else { - for k, v := range out { - (*s.value)[k] = v - } - } - s.changed = true - return nil -} - -func (s *stringToIntValue) Type() string { - return "stringToInt" -} - -func (s *stringToIntValue) String() string { - var buf bytes.Buffer - i := 0 - for k, v := range *s.value { - if i > 0 { - buf.WriteRune(',') - } - buf.WriteString(k) - buf.WriteRune('=') - buf.WriteString(strconv.Itoa(v)) - i++ - } - return "[" + buf.String() + "]" -} - -func stringToIntConv(val string) (interface{}, error) { - val = strings.Trim(val, "[]") - // An empty string would cause an empty map - if len(val) == 0 { - return map[string]int{}, nil - } - ss := strings.Split(val, ",") - out := make(map[string]int, len(ss)) - for _, pair := range ss { - kv := strings.SplitN(pair, "=", 2) - if len(kv) != 2 { - return nil, fmt.Errorf("%s must be formatted as key=value", pair) - } - var err error - out[kv[0]], err = strconv.Atoi(kv[1]) - if err != nil { - return nil, err - } - } - return out, nil -} - -// GetStringToInt return the map[string]int value of a flag with the given name -func (f *FlagSet) GetStringToInt(name string) (map[string]int, error) { - val, err := f.getFlagType(name, "stringToInt", stringToIntConv) - if err != nil { - return map[string]int{}, err - } - return val.(map[string]int), nil -} - -// StringToIntVar defines a string flag with specified name, default value, and usage string. -// The argument p points to a map[string]int variable in which to store the values of the multiple flags. -// The value of each argument will not try to be separated by comma -func (f *FlagSet) StringToIntVar(p *map[string]int, name string, value map[string]int, usage string) { - f.VarP(newStringToIntValue(value, p), name, "", usage) -} - -// StringToIntVarP is like StringToIntVar, but accepts a shorthand letter that can be used after a single dash. -func (f *FlagSet) StringToIntVarP(p *map[string]int, name, shorthand string, value map[string]int, usage string) { - f.VarP(newStringToIntValue(value, p), name, shorthand, usage) -} - -// StringToIntVar defines a string flag with specified name, default value, and usage string. -// The argument p points to a map[string]int variable in which to store the value of the flag. -// The value of each argument will not try to be separated by comma -func StringToIntVar(p *map[string]int, name string, value map[string]int, usage string) { - CommandLine.VarP(newStringToIntValue(value, p), name, "", usage) -} - -// StringToIntVarP is like StringToIntVar, but accepts a shorthand letter that can be used after a single dash. -func StringToIntVarP(p *map[string]int, name, shorthand string, value map[string]int, usage string) { - CommandLine.VarP(newStringToIntValue(value, p), name, shorthand, usage) -} - -// StringToInt defines a string flag with specified name, default value, and usage string. -// The return value is the address of a map[string]int variable that stores the value of the flag. -// The value of each argument will not try to be separated by comma -func (f *FlagSet) StringToInt(name string, value map[string]int, usage string) *map[string]int { - p := map[string]int{} - f.StringToIntVarP(&p, name, "", value, usage) - return &p -} - -// StringToIntP is like StringToInt, but accepts a shorthand letter that can be used after a single dash. -func (f *FlagSet) StringToIntP(name, shorthand string, value map[string]int, usage string) *map[string]int { - p := map[string]int{} - f.StringToIntVarP(&p, name, shorthand, value, usage) - return &p -} - -// StringToInt defines a string flag with specified name, default value, and usage string. -// The return value is the address of a map[string]int variable that stores the value of the flag. -// The value of each argument will not try to be separated by comma -func StringToInt(name string, value map[string]int, usage string) *map[string]int { - return CommandLine.StringToIntP(name, "", value, usage) -} - -// StringToIntP is like StringToInt, but accepts a shorthand letter that can be used after a single dash. -func StringToIntP(name, shorthand string, value map[string]int, usage string) *map[string]int { - return CommandLine.StringToIntP(name, shorthand, value, usage) -} diff --git a/vendor/github.com/spf13/pflag/string_to_string.go b/vendor/github.com/spf13/pflag/string_to_string.go deleted file mode 100644 index 890a01afc0..0000000000 --- a/vendor/github.com/spf13/pflag/string_to_string.go +++ /dev/null @@ -1,160 +0,0 @@ -package pflag - -import ( - "bytes" - "encoding/csv" - "fmt" - "strings" -) - -// -- stringToString Value -type stringToStringValue struct { - value *map[string]string - changed bool -} - -func newStringToStringValue(val map[string]string, p *map[string]string) *stringToStringValue { - ssv := new(stringToStringValue) - ssv.value = p - *ssv.value = val - return ssv -} - -// Format: a=1,b=2 -func (s *stringToStringValue) Set(val string) error { - var ss []string - n := strings.Count(val, "=") - switch n { - case 0: - return fmt.Errorf("%s must be formatted as key=value", val) - case 1: - ss = append(ss, strings.Trim(val, `"`)) - default: - r := csv.NewReader(strings.NewReader(val)) - var err error - ss, err = r.Read() - if err != nil { - return err - } - } - - out := make(map[string]string, len(ss)) - for _, pair := range ss { - kv := strings.SplitN(pair, "=", 2) - if len(kv) != 2 { - return fmt.Errorf("%s must be formatted as key=value", pair) - } - out[kv[0]] = kv[1] - } - if !s.changed { - *s.value = out - } else { - for k, v := range out { - (*s.value)[k] = v - } - } - s.changed = true - return nil -} - -func (s *stringToStringValue) Type() string { - return "stringToString" -} - -func (s *stringToStringValue) String() string { - records := make([]string, 0, len(*s.value)>>1) - for k, v := range *s.value { - records = append(records, k+"="+v) - } - - var buf bytes.Buffer - w := csv.NewWriter(&buf) - if err := w.Write(records); err != nil { - panic(err) - } - w.Flush() - return "[" + strings.TrimSpace(buf.String()) + "]" -} - -func stringToStringConv(val string) (interface{}, error) { - val = strings.Trim(val, "[]") - // An empty string would cause an empty map - if len(val) == 0 { - return map[string]string{}, nil - } - r := csv.NewReader(strings.NewReader(val)) - ss, err := r.Read() - if err != nil { - return nil, err - } - out := make(map[string]string, len(ss)) - for _, pair := range ss { - kv := strings.SplitN(pair, "=", 2) - if len(kv) != 2 { - return nil, fmt.Errorf("%s must be formatted as key=value", pair) - } - out[kv[0]] = kv[1] - } - return out, nil -} - -// GetStringToString return the map[string]string value of a flag with the given name -func (f *FlagSet) GetStringToString(name string) (map[string]string, error) { - val, err := f.getFlagType(name, "stringToString", stringToStringConv) - if err != nil { - return map[string]string{}, err - } - return val.(map[string]string), nil -} - -// StringToStringVar defines a string flag with specified name, default value, and usage string. -// The argument p points to a map[string]string variable in which to store the values of the multiple flags. -// The value of each argument will not try to be separated by comma -func (f *FlagSet) StringToStringVar(p *map[string]string, name string, value map[string]string, usage string) { - f.VarP(newStringToStringValue(value, p), name, "", usage) -} - -// StringToStringVarP is like StringToStringVar, but accepts a shorthand letter that can be used after a single dash. -func (f *FlagSet) StringToStringVarP(p *map[string]string, name, shorthand string, value map[string]string, usage string) { - f.VarP(newStringToStringValue(value, p), name, shorthand, usage) -} - -// StringToStringVar defines a string flag with specified name, default value, and usage string. -// The argument p points to a map[string]string variable in which to store the value of the flag. -// The value of each argument will not try to be separated by comma -func StringToStringVar(p *map[string]string, name string, value map[string]string, usage string) { - CommandLine.VarP(newStringToStringValue(value, p), name, "", usage) -} - -// StringToStringVarP is like StringToStringVar, but accepts a shorthand letter that can be used after a single dash. -func StringToStringVarP(p *map[string]string, name, shorthand string, value map[string]string, usage string) { - CommandLine.VarP(newStringToStringValue(value, p), name, shorthand, usage) -} - -// StringToString defines a string flag with specified name, default value, and usage string. -// The return value is the address of a map[string]string variable that stores the value of the flag. -// The value of each argument will not try to be separated by comma -func (f *FlagSet) StringToString(name string, value map[string]string, usage string) *map[string]string { - p := map[string]string{} - f.StringToStringVarP(&p, name, "", value, usage) - return &p -} - -// StringToStringP is like StringToString, but accepts a shorthand letter that can be used after a single dash. -func (f *FlagSet) StringToStringP(name, shorthand string, value map[string]string, usage string) *map[string]string { - p := map[string]string{} - f.StringToStringVarP(&p, name, shorthand, value, usage) - return &p -} - -// StringToString defines a string flag with specified name, default value, and usage string. -// The return value is the address of a map[string]string variable that stores the value of the flag. -// The value of each argument will not try to be separated by comma -func StringToString(name string, value map[string]string, usage string) *map[string]string { - return CommandLine.StringToStringP(name, "", value, usage) -} - -// StringToStringP is like StringToString, but accepts a shorthand letter that can be used after a single dash. -func StringToStringP(name, shorthand string, value map[string]string, usage string) *map[string]string { - return CommandLine.StringToStringP(name, shorthand, value, usage) -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/auth/credential.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/auth/credential.go index 0e6dd99c24..5d924e6848 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/auth/credential.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/auth/credential.go @@ -14,6 +14,12 @@ type Credential struct { PrivateKey string } +// NewCredential will return credential config with default values +func NewCredential() Credential { + return Credential{} +} + +// CreateSign will encode query string to credential signature. func (c *Credential) CreateSign(query string) string { // replace "=" "&" str := strings.Replace(query, "&", "", -1) @@ -30,6 +36,7 @@ func (c *Credential) CreateSign(query string) string { return result } +// BuildCredentialedQuery will build query string with signature query param. func (c *Credential) BuildCredentialedQuery(query map[string]string) string { var queryList []string for k, v := range query { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/client.go index 4982a880a0..70fa9403dc 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/client.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/client.go @@ -1,68 +1,36 @@ package sdk import ( - "encoding/json" - "fmt" - "math/rand" - "net/http" - "net/url" - "runtime" "time" - "github.com/ucloud/ucloud-sdk-go/sdk/version" - - "github.com/ucloud/ucloud-sdk-go/sdk/response" - - "github.com/Sirupsen/logrus" - "github.com/parnurzeal/gorequest" - "github.com/ucloud/ucloud-sdk-go/sdk/auth" - uerr "github.com/ucloud/ucloud-sdk-go/sdk/error" "github.com/ucloud/ucloud-sdk-go/sdk/log" + "github.com/ucloud/ucloud-sdk-go/sdk/protocol/http" "github.com/ucloud/ucloud-sdk-go/sdk/request" - utrace "github.com/ucloud/ucloud-sdk-go/sdk/trace" - "github.com/ucloud/ucloud-sdk-go/sdk/utils" + "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +//Client 客户端 type Client struct { credential *auth.Credential - config *ClientConfig + config *Config + httpClient *http.HttpClient + + responseHandlers []ReponseHandler + httpResponseHandlers []HttpReponseHandler } // NewClient will create an client of ucloud sdk -func NewClient(config *ClientConfig, credential *auth.Credential) *Client { - if config.MaxRetries == 0 { - config.MaxRetries = 3 - } - - if config.Timeout == 0 { - config.Timeout = 30 * time.Second - } - - if config.Logger == nil { - log.Init(config.LogLevel) - config.Logger = logrus.WithField("client", "sdk") - } - - if config.Tracer == nil { - tracer := utrace.NewDasTracer() - config.Tracer = &tracer - } - - if config.TracerData == nil { - config.TracerData = make(map[string]interface{}) - } - - if config.HTTPHeaders == nil { - config.HTTPHeaders = make(map[string]string) - } - - config.HTTPHeaders["User-Agent"] = fmt.Sprintf("GO/%s GO-SDK/%s %s", runtime.Version(), version.Version, config.UserAgent) - - return &Client{ +func NewClient(config *Config, credential *auth.Credential) *Client { + client := Client{ credential: credential, config: config, } + + client.responseHandlers = append(client.responseHandlers, defaultResponseHandlers...) + client.httpResponseHandlers = append(client.httpResponseHandlers, defaultHttpResponseHandlers...) + log.Init(config.LogLevel) + return &client } // GetCredential will return the creadential config of client. @@ -71,208 +39,42 @@ func (c *Client) GetCredential() *auth.Credential { } // GetConfig will return the config of client. -func (c *Client) GetConfig() *ClientConfig { +func (c *Client) GetConfig() *Config { return c.config } -// DoRequest will send a real http request to api endpoint with retry. -func (c *Client) DoRequest(req *request.HttpRequest, resp response.Common) error { - config := c.GetConfig() - r, err := c.buildSuperAgent(req) - if err != nil { - return err - } - - tracer := config.Tracer - - traceinfo := utrace.NewDasTraceInfo() - traceinfo.SetSDKRequest(req.Query) - - // temporary method, should use new version sdk - sendWithTracer := func(sendType string) (*http.Response, error) { - startTime := time.Now() - innerHttpResp, body, err := c.send(r, sendType) - endTime := time.Now() - - // Unmarshal response - err = json.Unmarshal(body, &resp) - if err != nil { - return nil, err - } - - traceinfo.SetSDKResponse(resp) - traceinfo.SetExtraData("startTime", startTime.UnixNano()/1e6) - traceinfo.SetExtraData("endTime", endTime.UnixNano()/1e6) - traceinfo.SetExtraData("durationTime", endTime.Sub(startTime).Nanoseconds()/1e6) - - for k, v := range config.TracerData { - traceinfo.SetExtraData(k, v) - } - - if tracer != nil { - err = tracer.Send(&traceinfo, c.config.HTTPHeaders) - if err != nil { - fmt.Println(err) - } - } - - return innerHttpResp, nil - } - - httpResp, err := sendWithTracer("Send") - - // exponential backoff delay, maximum 8 minute about. - cfg := c.GetConfig() - for retryCount := 1; utils.IsRetryableError(err) || (httpResp != nil && utils.IsRetryableHTTPStatusCode(httpResp.StatusCode)); retryCount++ { - if retryCount > cfg.MaxRetries { - break - } - - delay := getExpBackoffDelay(retryCount) - time.Sleep(delay) - - httpResp, err = sendWithTracer("Retry") - } - - if err != nil { - if utils.IsTimeoutError(err) { - return uerr.TimeoutError - } else { - return uerr.SendRequestError - } - } - - if utils.IsErrorHTTPStatusCode(httpResp.StatusCode) { - return uerr.SendRequestError - } - - return nil -} - // 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 { - var err error - cfg := c.GetConfig() - defer logForAction(cfg.Logger, action, resp.(response.Common), &err) + c.SetupRequest(req, action) + req.SetRequestTime(time.Now()) - // Build query - query, err := utils.RequestToQuery(req) + httpReq, err := c.buildHTTPRequest(req) if err != nil { return err } - logrus.Infof("Request %#v", query) - - query["Action"] = action - if region := req.GetRegion(); err != nil && len(region) > 0 { - query["Region"] = region - } - if projectId := req.GetProjectId(); err != nil && len(projectId) > 0 { - query["ProjectId"] = projectId - } - - // Build request - httpReq := &request.HttpRequest{ - Url: cfg.BaseUrl, - Method: "GET", - Query: query, - } - - // Send request - err = c.DoRequest(httpReq, resp) + httpClient := http.NewHttpClient() + httpResp, err := httpClient.Send(httpReq) if err != nil { return err } - return nil -} - -func (c *Client) buildSuperAgent(req *request.HttpRequest) (*gorequest.SuperAgent, error) { - config := c.GetConfig() - r := gorequest.New() - r.ClearSuperAgent() - - for k, v := range utils.MergeMap(DefaultHeaders, config.HTTPHeaders, req.Header) { - r.Set(k, v) - } - - goVersion := runtime.Version() - ua := fmt.Sprintf("GO/%s GO-SDK/%s", goVersion, version.Version) - if config.UserAgent != "" { - ua += " " + config.UserAgent - } - r.Set("User-Agent", ua) - - r.Method = req.Method - if !utils.IsAvaliableMethod(r.Method) { - logrus.Errorf("invalid method %s", r.Method) - return nil, uerr.InvalidRequestError + // use response middleware to handle http response + // such as convert some http status to error + for _, handler := range c.httpResponseHandlers { + httpResp, err = handler(c, httpReq, httpResp, err) } - r.Url = req.Url - _, err := url.ParseRequestURI(req.Url) + err = c.UnmarshalHTTPReponse(httpResp, resp) if err != nil { - logrus.Error(err) - return nil, uerr.InvalidRequestError - } - - if len(req.Content) != 0 { - r.Send(req.Content) - } - - r.Errors = nil - - credential := c.GetCredential() - if credential == nil { - logrus.Errorln("invalid credential infomation, please set it before request.") - return nil, uerr.InvalidRequestError - } - - cfg := c.GetConfig() - r.Timeout(cfg.Timeout) - - r.Query(credential.BuildCredentialedQuery(req.Query)) - return r, nil -} - -func (c *Client) send(r *gorequest.SuperAgent, reqType string) (gorequest.Response, []byte, error) { - var err error - logger := c.GetConfig().Logger.WithField("type", reqType) - - logger.Debugf("%s %s?%s", r.Method, r.Url, r.QueryData.Encode()) - - resp, body, errs := r.EndBytes() - - if len(errs) > 0 { - err = errs[0] - logger.Errorf("%T: %s", err, err) - } else if resp != nil && resp.StatusCode > 400 { - logger.Warnf("%s", resp.Status) - } else { - err = nil - logger.Debugf("%s - %v", body, resp.StatusCode) - } - - return resp, body, err -} - -func logForAction(logger logrus.FieldLogger, action string, resp response.Common, err *error) { - logger = logger.WithField("action", action) - if err != nil && *err != nil { - logger.Errorf("Do %s faild, %s", action, (*err).Error()) - } else if resp != nil && resp.GetRetCode() != 0 { - logger.Errorf("Do %s faild, %s", action, resp.GetMessage()) - } else { - logger.Infof("Do %s successful!", action) + return err } -} -func getExpBackoffDelay(retryCount int) time.Duration { - minTime := 100 - if retryCount > 7 { - retryCount = 7 + // use response middle to build and convert response when response has been created. + // such as retry, report traceback, print log and etc. + for _, handler := range c.responseHandlers { + resp, err = handler(c, req, resp, err) } - delay := (1 << (uint(retryCount) * 2)) * (rand.Intn(minTime) + minTime) - return time.Duration(delay) * time.Millisecond + return err } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/config.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/config.go index 18678c5397..0fd67a88b8 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/config.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/config.go @@ -3,54 +3,51 @@ package sdk import ( "time" - "github.com/Sirupsen/logrus" - - utrace "github.com/ucloud/ucloud-sdk-go/sdk/trace" + "github.com/ucloud/ucloud-sdk-go/sdk/log" ) -type ClientConfig struct { +type Config struct { // Region is the region of backend service - // See also ... - Region string + // See also ... + Region 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. - // See also - ProjectId string + // See also ... + ProjectId string `default:""` // BaseUrl is the url of backend api // See also ... - BaseUrl string - - // Logger and LogLevel is the configuration of logrus, - // if logger not be set, use standard output with json formatter as default, - // if logLevel not be set, use INFO level as default. - Logger logrus.FieldLogger - LogLevel logrus.Level - - // Timeout is timeout for every request. - Timeout time.Duration - - // Trace will invoke when any request is completed. - Tracer utrace.Tracer - TracerData map[string]interface{} + BaseUrl string `default:"https://api.ucloud.cn"` - // UserAgent is an attribute for sdk client, used for distinguish who using sdk. + // UserAgent is an attribute for sdk client, used for distinguish who is using sdk. // See also https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent - // It will append to the end of sdk user-agent. + // It will be appended to the end of sdk user-agent. // eg. "Terraform/0.10.1" -> "GO/1.9.1 GO-SDK/0.1.0 Terraform/0.10.1" - // warn. it will conflict with the User-Agent of HTTPHeaders - UserAgent string + // NOTE: it will conflict with the User-Agent of HTTPHeaders + UserAgent string `default:""` - // HTTPHeaders is the specific headers sent to remote server via http protocal - // It is avaliabled when http protocal is enabled. - HTTPHeaders map[string]string - - // AutoRetry is a switch to enable retry policy for timeout/connect failing - // if AutoRetry is enabled, it will enable default retry policy using exponential backoff. - AutoRetry bool + // Timeout is timeout for every request. + Timeout time.Duration `default:"30s"` // MaxRetries is the number of max retry times. - MaxRetries int + // Set MaxRetries more than 0 to enable auto-retry for network and service availability problem + // if auto-retry is enabled, it will enable default retry policy using exponential backoff. + MaxRetries int `default:"0"` + + // LogLevel is equal to logrus level, + // if logLevel not be set, use INFO level as default. + LogLevel log.Level `default:"log.InfoLevel"` +} + +// NewConfig will return a new client config with default options. +func NewConfig() Config { + cfg := Config{ + BaseUrl: "https://api.ucloud.cn", + Timeout: 30 * time.Second, + MaxRetries: 0, + LogLevel: log.InfoLevel, + } + return cfg } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/error/client_error.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/error/client_error.go index 5e9a28d6ed..19c83c9795 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/error/client_error.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/error/client_error.go @@ -1,11 +1,81 @@ package error import ( - "errors" + "fmt" + "net" ) var ( - InvalidRequestError = errors.New("client.InvalidRequestError") - SendRequestError = errors.New("client.SendRequestError") - TimeoutError = errors.New("client.TimeoutError") + // ErrInvalidRequest is the error for invalid request took from user + ErrInvalidRequest = "client.InvalidRequestError" + + // ErrSendRequest is the error for sending request + ErrSendRequest = "client.SendRequestError" + + // ErrNetwork is the error for any network error caused by client or server network environment + // ErrNetwork can be caused by net errors of golang + // ErrNetwork is retryable + ErrNetwork = "client.NetworkError" + + // ErrUnexcepted is the error for any unexcepted error + ErrUnexcepted = "client.UnexceptedError" ) + +// ClientError is the ucloud common errorfor server response +type ClientError struct { + err error + name string + retryable bool +} + +func (e ClientError) Error() string { + return fmt.Sprintf("sdk:\n[%s] %s", e.name, e.err.Error()) +} + +// NewClientError will return a new instance of ClientError +func NewClientError(name string, err error) ClientError { + return ClientError{ + name: name, + err: err, + retryable: false, + } +} + +// Name will return error name +func (e ClientError) Name() string { + return e.name +} + +// Code will return server code +func (e ClientError) Code() int { + return -1 +} + +// HTTPStatusCode will return http status code +func (e ClientError) StatusCode() int { + return 0 +} + +// Message will return message +func (e ClientError) Message() string { + return e.err.Error() +} + +// OriginError will return the origin error that caused by +func (e ClientError) OriginError() error { + return e.err +} + +// Retryable will return if the error is retryable +func (e ClientError) Retryable() bool { + return e.name == ErrNetwork || e.retryable +} + +// IsNetworkError will check if the error raise from network problem +func IsNetworkError(err error) bool { + if err == nil { + return false + } + _, isNetError := err.(net.Error) + return isNetError +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/error/error.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/error/error.go new file mode 100644 index 0000000000..e10b0dcbb5 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/error/error.go @@ -0,0 +1,58 @@ +package error + +// Error is the ucloud sdk error +type Error interface { + error + + // name, should be client.xxx or server.xxx + Name() string + + // retcode for server api error, retcode > 0 will cause an error + Code() int + + // http status code, code >= 400 will case an error + StatusCode() int + + // message for server api error + Message() string + + // the origin error that sdk error caused from + OriginError() error + + // if the error is retryable + Retryable() bool +} + +// NewRetryableError will wrap any error as a retryable error +func NewRetryableError(err error) Error { + if e, ok := err.(ClientError); ok { + e.retryable = true + return e + } + + if e, ok := err.(ServerError); ok { + e.retryable = true + return e + } + + e := NewClientError(ErrUnexcepted, err) + e.retryable = true + return e +} + +// NewNonRetryableError will wrap any error as a non-retryable error +func NewNonRetryableError(err error) Error { + if e, ok := err.(ClientError); ok { + e.retryable = false + return e + } + + if e, ok := err.(ServerError); ok { + e.retryable = false + return e + } + + e := NewClientError(ErrUnexcepted, err) + e.retryable = false + return e +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/error/server_error.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/error/server_error.go index d32fcc57c3..cde2e93f86 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/error/server_error.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/error/server_error.go @@ -1,9 +1,100 @@ package error import ( - "errors" + "fmt" + + "github.com/pkg/errors" ) var ( - InternalError = errors.New("server.InternalError") + ErrHTTPStatus = "server.HTTPStatusError" + ErrRetCode = "server.RetCodeError" ) + +// ServerError is the ucloud common error for server response +type ServerError struct { + err error + name string + statusCode int + retCode int + message string + retryable bool +} + +func (e ServerError) Error() string { + if e.retCode > 0 { + return fmt.Sprintf("api:\n[%s] %v %s", e.name, e.retCode, e.message) + } + return fmt.Sprintf("api:\n[%s] %s", e.name, e.message) +} + +// NewServerStatusError will return a new instance of NewServerStatusError +func NewServerStatusError(statusCode int, message string) ServerError { + return ServerError{ + retCode: -1, + statusCode: statusCode, + message: message, + name: ErrHTTPStatus, + err: errors.Errorf("%s", message), + retryable: false, + } +} + +// NewServerCodeError will return a new instance of NewServerStatusError +func NewServerCodeError(retCode int, message string) ServerError { + return ServerError{ + retCode: retCode, + statusCode: 200, + message: message, + name: ErrRetCode, + err: errors.Errorf("%s", message), + retryable: false, + } +} + +// Name will return error name +func (e ServerError) Name() string { + return e.name +} + +// Code will return server code +func (e ServerError) Code() int { + return e.retCode +} + +// HTTPStatusCode will return http status code +func (e ServerError) StatusCode() int { + return e.statusCode +} + +// Message will return message +func (e ServerError) Message() string { + return e.message +} + +// OriginError will return the origin error that caused by +func (e ServerError) OriginError() error { + return e.err +} + +// Retryable will return if the error is retryable +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 { + if i == v { + return true + } + } + return false +} + +// IsCodeError will check if the error is the retuen code error +func IsCodeError(err error) bool { + if e, ok := err.(Error); ok && e.Name() == ErrRetCode { + return true + } + return false +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/handlers.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/handlers.go new file mode 100644 index 0000000000..c2e7c48693 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/handlers.go @@ -0,0 +1,102 @@ +package sdk + +import ( + "math/rand" + "time" + + uerr "github.com/ucloud/ucloud-sdk-go/sdk/error" + "github.com/ucloud/ucloud-sdk-go/sdk/log" + "github.com/ucloud/ucloud-sdk-go/sdk/protocol/http" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// ReponseHandler receive response and write data into this response memory area +type ReponseHandler func(c *Client, req request.Common, resp response.Common, err error) (response.Common, error) + +// HttpReponseHandler receive http response and return a new http response +type HttpReponseHandler func(c *Client, req *http.HttpRequest, resp *http.HttpResponse, err error) (*http.HttpResponse, error) + +var defaultResponseHandlers = []ReponseHandler{errorHandler, logHandler, retryHandler} +var defaultHttpResponseHandlers = []HttpReponseHandler{errorHTTPHandler, logDebugHTTPHandler} + +func retryHandler(c *Client, req request.Common, resp response.Common, err error) (response.Common, error) { + for retryCount := 1; err != nil && err.(uerr.Error).Retryable(); retryCount++ { + // if max retries number is reached, stop and raise last error + if retryCount > req.GetMaxretries() { + break + } + + // use exponential backoff constant as retry delay + delay := getExpBackoffDelay(retryCount) + time.Sleep(delay) + + req.SetRetryCount(retryCount) + + // the resp will be changed after invoke + err = c.InvokeAction(req.GetAction(), req, resp) + } + + return resp, err +} + +func getExpBackoffDelay(retryCount int) time.Duration { + minTime := 100 + if retryCount > 7 { + retryCount = 7 + } + + delay := (1 << (uint(retryCount) * 2)) * (rand.Intn(minTime) + minTime) + return time.Duration(delay) * time.Millisecond +} + +// errorHandler will normalize error to several specific error +func errorHandler(c *Client, req request.Common, resp response.Common, err error) (response.Common, error) { + if err != nil { + if _, ok := err.(uerr.Error); ok { + return resp, err + } + if uerr.IsNetworkError(err) { + return resp, uerr.NewClientError(uerr.ErrNetwork, err) + } + return resp, uerr.NewClientError(uerr.ErrSendRequest, err) + } + + if resp.GetRetCode() != 0 { + return resp, uerr.NewServerCodeError(resp.GetRetCode(), resp.GetMessage()) + } + + return resp, err +} + +func errorHTTPHandler(c *Client, req *http.HttpRequest, resp *http.HttpResponse, err error) (*http.HttpResponse, error) { + if statusErr, ok := err.(http.StatusError); ok { + return resp, uerr.NewServerStatusError(statusErr.StatusCode, statusErr.Message) + } + return resp, err +} + +func logHandler(c *Client, req request.Common, resp response.Common, err error) (response.Common, error) { + action := req.GetAction() + if err != nil { + log.Errorf("do %s failed, %s", action, err) + } else { + log.Infof("do %s successful!", action) + } + return resp, err +} + +func logDebugHTTPHandler(c *Client, req *http.HttpRequest, resp *http.HttpResponse, err error) (*http.HttpResponse, error) { + // TODO: move request debugging log to request handler + log.Debugf("%s", req) + + if err != nil { + log.Errorf("%s", err) + } else if resp.GetStatusCode() > 400 { + log.Warnf("%s", resp.GetStatusCode()) + } else { + log.Debugf("%s - %v", resp.GetBody(), resp.GetStatusCode()) + } + + return resp, err +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/log/logger.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/log/logger.go index 6d35f53955..a8e971837e 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/log/logger.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/log/logger.go @@ -3,11 +3,50 @@ package log import ( "os" - logrus "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" ) -func Init(level logrus.Level) { - logrus.SetFormatter(&logrus.JSONFormatter{}) - logrus.SetLevel(level) +// Init will init with level and default output (stdout) and formatter (text without color) +func Init(level Level) { + logrus.SetLevel(logrus.Level(level)) logrus.SetOutput(os.Stdout) + logrus.SetFormatter(&logrus.TextFormatter{ + DisableColors: false, + FullTimestamp: true, + }) } + +type Level logrus.Level + +var ( + PanicLevel = Level(logrus.PanicLevel) + FatalLevel = Level(logrus.FatalLevel) + ErrorLevel = Level(logrus.ErrorLevel) + WarnLevel = Level(logrus.WarnLevel) + InfoLevel = Level(logrus.InfoLevel) + DebugLevel = Level(logrus.DebugLevel) + + SetLevel = func(level Level) { logrus.SetLevel(logrus.Level(level)) } + GetLevel = func() Level { return Level(logrus.GetLevel()) } + + WithError = logrus.WithError + WithField = logrus.WithField + + Debug = logrus.Debug + Print = logrus.Print + Info = logrus.Info + Warn = logrus.Warn + Warning = logrus.Warning + Error = logrus.Error + Panic = logrus.Panic + Fatal = logrus.Fatal + + Debugf = logrus.Debugf + Printf = logrus.Printf + Infof = logrus.Infof + Warnf = logrus.Warnf + Warningf = logrus.Warningf + Errorf = logrus.Errorf + Panicf = logrus.Panicf + Fatalf = logrus.Fatalf +) diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/marshaler.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/marshaler.go new file mode 100644 index 0000000000..ca53e04071 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/marshaler.go @@ -0,0 +1,80 @@ +package sdk + +import ( + "encoding/json" + "fmt" + "runtime" + + "github.com/pkg/errors" + + "github.com/ucloud/ucloud-sdk-go/sdk/protocol/http" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" + "github.com/ucloud/ucloud-sdk-go/sdk/version" +) + +// SetupRequest will init request by client configuration +func (c *Client) SetupRequest(req request.Common, action string) request.Common { + cfg := c.GetConfig() + + req.SetAction(action) + + // set optional client level variables + if len(req.GetRegion()) == 0 && len(cfg.Region) > 0 { + req.SetRegion(cfg.Region) + } + + if len(req.GetProjectId()) == 0 && len(cfg.ProjectId) > 0 { + req.SetProjectId(cfg.ProjectId) + } + + if req.GetTimeout() == 0 && cfg.Timeout != 0 { + req.WithTimeout(cfg.Timeout) + } + + if req.GetMaxretries() == 0 && cfg.MaxRetries != 0 { + req.WithRetry(cfg.MaxRetries) + } + + return req +} + +func (c *Client) buildHTTPRequest(req request.Common) (*http.HttpRequest, error) { + // convert request struct to query map + query, err := request.ToQueryMap(req) + if err != nil { + return nil, errors.Errorf("convert request to map failed, %s", err) + } + + // check credential information is avaliable + credential := c.GetCredential() + if credential == nil { + return nil, errors.Errorf("invalid credential infomation, please set it before request.") + } + + config := c.GetConfig() + httpReq := http.NewHttpRequest() + httpReq.SetURL(config.BaseUrl) + httpReq.SetMethod("GET") + + // set timeout with client configuration + httpReq.SetTimeout(config.Timeout) + + // keep query stirng is ordered and append credential signiture as the last query param + httpReq.SetQueryString(credential.BuildCredentialedQuery(query)) + + ua := fmt.Sprintf("GO/%s GO-SDK/%s %s", runtime.Version(), version.Version, config.UserAgent) + httpReq.SetHeader("User-Agent", ua) + + return &httpReq, nil +} + +// 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() + if len(body) < 0 { + return nil + } + + return json.Unmarshal([]byte(body), &resp) +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/protocol/http/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/protocol/http/client.go new file mode 100644 index 0000000000..3f1c0188d7 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/protocol/http/client.go @@ -0,0 +1,79 @@ +package http + +import ( + "io/ioutil" + "net/http" + "time" + + "github.com/pkg/errors" +) + +// HttpClient used to send a real request via http to server +type HttpClient struct { +} + +// NewHttpClient will create a new HttpClient instance +func NewHttpClient() HttpClient { + return HttpClient{} +} + +// Send will send a real http request to remote server +func (c *HttpClient) Send(req *HttpRequest) (*HttpResponse, error) { + // build http.Client with timeout settings + httpClient, err := c.buildHTTPClient(req.GetTimeout()) + if err != nil { + return nil, err + } + + // convert sdk http request to origin http.Request + httpReq, err := req.buildHTTPRequest() + if err != nil { + return nil, err + } + + // TODO: enable tracer via `httptrace` package + resp, err := c.doHTTPRequest(httpClient, httpReq) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *HttpClient) buildHTTPClient(timeout time.Duration) (*http.Client, error) { + httpClient := http.Client{} + if timeout != 0 { + httpClient = http.Client{Timeout: timeout} + } + return &httpClient, nil +} + +func (c *HttpClient) doHTTPRequest(client *http.Client, req *http.Request) (*HttpResponse, error) { + // send request + httpResp, err := client.Do(req) + if err != nil { + return nil, errors.Errorf("cannot send request, %s", err) + } + defer httpResp.Body.Close() + + // raise status error + if httpResp.StatusCode >= 400 { + return nil, NewStatusError(httpResp.StatusCode, httpResp.Status) + } + + // read content + body, err := ioutil.ReadAll(httpResp.Body) + if err != nil { + return nil, errors.Errorf("cannot read response, %s", err) + } + + // build response wrapper + resp := NewHttpResponse() + resp.setHttpReponse(httpResp) + resp.setBody(body) + return resp, nil +} + +func (c *HttpClient) buildHTTPRequestWithTracer(req *http.Request) (*http.Request, error) { + // TODO: implement trace via httptrace + return req, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/defaults.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/protocol/http/defaults.go similarity index 70% rename from vendor/github.com/ucloud/ucloud-sdk-go/sdk/defaults.go rename to vendor/github.com/ucloud/ucloud-sdk-go/sdk/protocol/http/defaults.go index 40c423ffae..899602ad9b 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/defaults.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/protocol/http/defaults.go @@ -1,7 +1,13 @@ -package sdk +package http + +import ( + "time" +) // DefaultHeaders defined default http headers var DefaultHeaders = map[string]string{ "Content-Type": "application/x-www-form-urlencoded", // "X-SDK-VERSION": VERSION, } + +var DefaultTimeout = 30 * time.Second diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/protocol/http/error.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/protocol/http/error.go new file mode 100644 index 0000000000..6e10b957ca --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/protocol/http/error.go @@ -0,0 +1,23 @@ +package http + +import ( + "fmt" +) + +// StatusError is the error for http status code >= 400 +type StatusError struct { + StatusCode int + Message string +} + +func (e StatusError) Error() string { + return fmt.Sprintf("http status %v error", e.StatusCode) +} + +// NewStatusError will create a new status error +func NewStatusError(code int, message string) StatusError { + return StatusError{ + StatusCode: code, + Message: message, + } +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/protocol/http/request.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/protocol/http/request.go new file mode 100644 index 0000000000..1ff5c289d2 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/protocol/http/request.go @@ -0,0 +1,202 @@ +package http + +import ( + "fmt" + "net/http" + "net/url" + "strings" + "time" + + "github.com/pkg/errors" + "github.com/ucloud/ucloud-sdk-go/sdk/utils" +) + +var avaliableHTTPMethods = []string{"GET", "POST", "PUT", "DELETE", "OPTION", "HEAD", "PATCH"} + +type HttpRequest struct { + url string + method string + queryMap map[string]string + queryString string + headers map[string]string + + // body payload + formData map[string]string + requestBody []byte + + timeout time.Duration +} + +// NewHttpRequest will create a http request +func NewHttpRequest() HttpRequest { + return HttpRequest{ + queryMap: make(map[string]string), + headers: make(map[string]string), + formData: make(map[string]string), + timeout: DefaultTimeout, + } +} + +// SetURL will set url into request +func (h *HttpRequest) SetURL(val string) error { + // check url is valid + uri, err := url.ParseRequestURI(val) + if err != nil { + return errors.Errorf("url is invalid, got %s", val) + } + + err = h.SetQueryString(uri.RawQuery) + if err != nil { + return err + } + + h.url = val + return nil +} + +// GetURL will get request url value +func (h *HttpRequest) GetURL() string { + return h.url +} + +// SetMethod will set method of current request +func (h *HttpRequest) SetMethod(val string) error { + err := utils.CheckStringIn(val, avaliableHTTPMethods) + if err != nil { + return errors.Errorf("method is invalid, %s", err) + } + + h.method = strings.ToUpper(val) + return nil +} + +// GetMethod will get request url value +func (h *HttpRequest) GetMethod() string { + return h.method +} + +// SetQueryString will set query map by query string, +// it also save as query string attribute to keep query ordered. +func (h *HttpRequest) SetQueryString(val string) error { + // check url query is valid + values, err := url.ParseQuery(val) + if err != nil { + return errors.Errorf("url query is invalid, got %s", val) + } + + // copy url query into request query map, it will overwrite current query + for k, v := range values { + if len(v) > 0 { + h.SetQuery(k, v[0]) + } + } + + h.queryString = val + return nil +} + +// BuildQueryString will return the query string of this request, +// it will also append key-value of query map after existed query string +func (h *HttpRequest) BuildQueryString() (string, error) { + values := url.Values{} + for k, v := range h.queryMap { + values.Add(k, v) + } + + // if query string is not set by user, + // otherwise needn't keep them ordered, encode immediatly. + if h.queryString == "" { + return values.Encode(), nil + } + + // exclude query that existed in query string pass by user, + // to keep ordered from user definition + existsValues, _ := url.ParseQuery(h.queryString) + for k := range existsValues { + values.Del(k) + } + + // append query map after existed query string + qs := h.queryString + if len(values) > 0 { + qs += "&" + values.Encode() + } + + return qs, nil +} + +// SetQuery will store key-value data into query map +func (h *HttpRequest) SetQuery(k, v string) error { + if h.queryMap == nil { + h.queryMap = make(map[string]string) + } + h.queryMap[k] = v + return nil +} + +// GetQueryMap will get all of query as a map +func (h *HttpRequest) GetQueryMap() map[string]string { + return h.queryMap +} + +// SetTimeout will set timeout of current request +func (h *HttpRequest) SetTimeout(val time.Duration) error { + h.timeout = val + return nil +} + +// GetTimeout will get timeout of current request +func (h *HttpRequest) GetTimeout() time.Duration { + return h.timeout +} + +// SetHeader will set http header of current request +func (h *HttpRequest) SetHeader(k, v string) error { + if h.headers == nil { + h.headers = make(map[string]string) + } + h.headers[k] = v + return nil +} + +// GetHeaderMap wiil get all of header as a map +func (h *HttpRequest) GetHeaderMap() map[string]string { + return h.headers +} + +// SetRequestBody will set http body of current request +func (h *HttpRequest) SetRequestBody(val []byte) error { + h.requestBody = val + return nil +} + +// GetRequestBody will get origin http request ("net/http") +func (h *HttpRequest) GetRequestBody() []byte { + return h.requestBody +} + +func (h *HttpRequest) String() string { + if qs, err := h.BuildQueryString(); err == nil { + return fmt.Sprintf("%s?%s", h.GetURL(), qs) + } + return h.GetURL() +} + +func (h *HttpRequest) buildHTTPRequest() (*http.Request, error) { + qs, err := h.BuildQueryString() + if err != nil { + return nil, errors.Errorf("cannot build query string, %s", err) + } + + // NOTE: api.ucloud.cn has been supported request via form urlencoded data + url := fmt.Sprintf("%s?%s", h.GetURL(), qs) + httpReq, err := http.NewRequest(h.GetMethod(), url, nil) + if err != nil { + return nil, errors.Errorf("cannot build request, %s", err) + } + + for k, v := range utils.MergeMap(DefaultHeaders, h.GetHeaderMap()) { + httpReq.Header.Set(k, v) + } + return httpReq, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/protocol/http/response.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/protocol/http/response.go new file mode 100644 index 0000000000..1654fde351 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/protocol/http/response.go @@ -0,0 +1,38 @@ +package http + +import ( + "net/http" +) + +// HttpResponse is a simple wrapper of "net/http" response +type HttpResponse struct { + body []byte + originHttpResponse *http.Response // origin "net/http" response +} + +// NewHttpResponse will create a new response of http request +func NewHttpResponse() *HttpResponse { + return &HttpResponse{} +} + +// GetBody will get body from from sdk http request +func (h *HttpResponse) GetBody() []byte { + return h.body +} + +// GetStatusCode will return status code of origin http response +func (h *HttpResponse) GetStatusCode() int { + return h.originHttpResponse.StatusCode +} + +// setBody will set body into http response +// it usually used for restore the body already read from an stream +// it will also cause extra memory usage +func (h *HttpResponse) setBody(body []byte) error { + h.body = body + return nil +} + +func (h *HttpResponse) setHttpReponse(resp *http.Response) { + h.originHttpResponse = resp +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/request/common.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/request/common.go index 4b82041186..4f359afabd 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/request/common.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/request/common.go @@ -1,35 +1,118 @@ package request +import "time" + +// Common is the common request type Common interface { + GetAction() string + SetAction(string) error + GetRegion() string - SetRegion(string) + SetRegion(string) error GetProjectId() string - SetProjectId(string) + SetProjectId(string) error + + SetRetryCount(int) + GetRetryCount() int + + WithRetry(int) + GetMaxretries() int + + WithTimeout(time.Duration) + GetTimeout() time.Duration + + SetRequestTime(time.Time) + GetRequestTime() time.Time } +// CommonBase is the base struct of common request type CommonBase struct { - Region string + Action *string + Region *string + ProjectId *string + + maxRetries int + retryCount int + timeout time.Duration + requestTIme time.Time +} + +// SetRetryCount will set retry count of request +func (c *CommonBase) SetRetryCount(retryCount int) { + c.retryCount = retryCount +} + +// GetRetryCount will return retry count of request +func (c *CommonBase) GetRetryCount() int { + return c.retryCount +} + +// WithRetry will set max retry count of request +func (c *CommonBase) WithRetry(maxRetries int) { + c.maxRetries = maxRetries +} + +// GetMaxretries will return max retry count of request +func (c *CommonBase) GetMaxretries() int { + return c.maxRetries +} + +// WithTimeout will set timeout of request +func (c *CommonBase) WithTimeout(timeout time.Duration) { + c.timeout = timeout +} + +// GetTimeout will get timeout of request +func (c *CommonBase) GetTimeout() time.Duration { + return c.timeout +} + +// SetRequestTime will set timeout of request +func (c *CommonBase) SetRequestTime(requestTIme time.Time) { + c.requestTIme = requestTIme +} + +// GetRequestTime will get timeout of request +func (c *CommonBase) GetRequestTime() time.Time { + return c.requestTIme +} + +// GetAction will return action of request +func (c *CommonBase) GetAction() string { + return *c.Action +} - ProjectId string +// SetAction will set action of request +func (c *CommonBase) SetAction(val string) error { + c.Action = &val + return nil } // GetRegion will return region of request func (c *CommonBase) GetRegion() string { - return c.Region + if c.Region == nil { + return "" + } + return *c.Region } // SetRegion will set region of request -func (c *CommonBase) SetRegion(region string) { - c.Region = region +func (c *CommonBase) SetRegion(val string) error { + c.Region = &val + return nil } // GetProjectId will get project id of request func (c *CommonBase) GetProjectId() string { - return c.ProjectId + if c.ProjectId == nil { + return "" + } + return *c.ProjectId } // SetProjectId will set project id of request -func (c *CommonBase) SetProjectId(projectId string) { - c.ProjectId = projectId +func (c *CommonBase) SetProjectId(val string) error { + c.ProjectId = &val + return nil } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/request/encoder.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/request/encoder.go new file mode 100644 index 0000000000..bfe3a3d6f5 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/request/encoder.go @@ -0,0 +1,119 @@ +package request + +import ( + "errors" + "fmt" + "reflect" + "strconv" +) + +// ToQueryMap will convert a request to string map +func ToQueryMap(req Common) (map[string]string, error) { + v := reflect.ValueOf(req) + if v.Kind() == reflect.Ptr { + v = v.Elem() + } + + return encode(&v) +} + +func encodeOne(v *reflect.Value) (string, error) { + switch v.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return strconv.FormatInt(v.Int(), 10), nil + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32: + return strconv.FormatUint(v.Uint(), 10), nil + case reflect.Float32, reflect.Float64: + return strconv.FormatFloat(v.Float(), 'f', -1, 64), nil + case reflect.Bool: + return strconv.FormatBool(v.Bool()), nil + case reflect.String: + return v.String(), nil + case reflect.Ptr: + ptrValue := v.Elem() + return encodeOne(&ptrValue) + default: + message := fmt.Sprintf( + "Invalid variable type, type must be one of int-, uint-,"+ + " float-, bool, string and ptr, got %s", + v.Kind().String(), + ) + return "", errors.New(message) + } +} + +func encode(v *reflect.Value) (map[string]string, error) { + result := make(map[string]string) + + for i := 0; i < v.NumField(); i++ { + f := v.Field(i) + name := v.Type().Field(i).Name + + // skip unexported field + if !f.CanSet() { + continue + } + + switch f.Kind() { + case reflect.Slice, reflect.Array: + for i := 0; i < f.Len(); i++ { + item := f.Index(i) + if item.Kind() == reflect.Ptr && item.IsNil() { + continue + } + + keyPrefix := fmt.Sprintf("%s.%v", name, i) + + if item.Kind() == reflect.Struct { + kv, err := encode(&item) + if err != nil { + return result, err + } + + for k, v := range kv { + name := fmt.Sprintf("%s.%s", keyPrefix, k) + + if v != "" { + result[name] = v + } + } + } else { + s, err := encodeOne(&item) + if err != nil { + return result, err + } + + if s != "" { + result[keyPrefix] = s + } + } + } + case reflect.Struct: + m, err := encode(&f) + if err != nil { + return result, err + } + + // flatten composited struct into result map + for k, v := range m { + result[k] = v + } + default: + if f.Kind() == reflect.Ptr && f.IsNil() { + continue + } + + s, err := encodeOne(&f) + if err != nil { + return result, err + } + + // set field value into result + if s != "" { + result[name] = s + } + } + } + + return result, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/request/request.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/request/request.go deleted file mode 100644 index 13af729fd0..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/request/request.go +++ /dev/null @@ -1,17 +0,0 @@ -package request - -const ( - HTTP_REQUEST_TYPE_MULTIPART = "multipart" - HTTP_REQUEST_TYPE_JSON = "json" - HTTP_REQUEST_TYPE_STRING = "string" -) - -type HttpRequest struct { - Url string - Type string - Method string - Query map[string]string - Header map[string]string - Form map[string]string - Content []byte -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/response/response.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/response/response.go deleted file mode 100644 index a5d6eabd12..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/response/response.go +++ /dev/null @@ -1,5 +0,0 @@ -package response - -// HttpResponse is a simple wrapper of "net/http" response -type HttpResponse struct { -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/schema.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/schema.go new file mode 100644 index 0000000000..a2825bc091 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/schema.go @@ -0,0 +1,75 @@ +package sdk + +import ( + "time" + + "github.com/ucloud/ucloud-sdk-go/sdk/version" +) + +// Version is the version of sdk +const Version = version.Version + +// String will return a pointer to string +func String(val string) *string { + return &val +} + +// StringValue will return a string from string pointer +func StringValue(ptr *string) string { + if ptr != nil { + return *ptr + } + return "" +} + +// Int will return a pointer to int +func Int(val int) *int { + return &val +} + +// IntValue will return a int from int pointer +func IntValue(ptr *int) int { + if ptr != nil { + return *ptr + } + return 0 +} + +// Bool will return a pointer to bool +func Bool(val bool) *bool { + return &val +} + +// BoolValue will return a bool from bool pointer +func BoolValue(ptr *bool) bool { + if ptr != nil { + return *ptr + } + return false +} + +// Float64 will return a pointer to float64 +func Float64(val float64) *float64 { + return &val +} + +// Float64Value will return a float64 from float64 pointer +func Float64Value(ptr *float64) float64 { + if ptr != nil { + return *ptr + } + return 0.0 +} + +// TimeDuration will return a pointer to time.Duration +func TimeDuration(val time.Duration) *time.Duration { + return &val +} + +// TimeDurationValue will return a time.Duration from a time.Duration pointer +func TimeDurationValue(ptr *time.Duration) time.Duration { + if ptr != nil { + return *ptr + } + return 0 +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/trace/das.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/trace/das.go deleted file mode 100644 index 25e55b322a..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/trace/das.go +++ /dev/null @@ -1,105 +0,0 @@ -package trace - -import ( - "bytes" - "encoding/json" - "fmt" - "net/http" - - "github.com/Sirupsen/logrus" - "github.com/pkg/errors" - - "github.com/satori/go.uuid" - - "github.com/ucloud/ucloud-sdk-go/sdk/response" -) - -// DefaultDasURI is the default das api endpoint at internet. -const DefaultDasURI = "https://das-rpt.ucloud.cn/log" - -// DasTracer is a reporter to send traceback to remote trace system (named dasman) -type DasTracer struct { - URI string -} - -// NewDasTracer will create a new das tracer instance to send tracing report -func NewDasTracer() DasTracer { - return DasTracer{ - URI: DefaultDasURI, - } -} - -// Send will send trace information via a http(s)/tcp connection -func (d *DasTracer) Send(t TraceInfo, header map[string]string) error { - body, err := marshalTraceInfo(t) - if err != nil { - return err - } - client := &http.Client{} - req, err := http.NewRequest("POST", d.URI, bytes.NewReader(body)) - for key, value := range header { - req.Header.Add(key, value) - } - resp, err := client.Do(req) - - if err != nil { - fmt.Println(err) - return err - } - if resp.StatusCode != 200 { - return fmt.Errorf("invalid http status with tracer, %s", resp.Status) - } - return nil -} - -func marshalTraceInfo(t TraceInfo) ([]byte, error) { - // TODO: shouldn't use map, use new version sdk - query := t.GetSDKRequest().(map[string]string) - resp := t.GetSDKResponse().(response.Common) - extra := t.GetExtra() - - dataSet := make([]map[string]interface{}, 0) - dataItem := map[string]interface{}{ - "level": "info", //todo - "topic": "api", - "action": resp.GetAction(), - "command": extra["command"], - "error": extra["error"], - "req": query, - "res": map[string]interface{}{ - "Action": resp.GetAction(), - "RetCode": resp.GetRetCode(), - "Message": resp.GetMessage(), - }, - "st": extra["startTime"], - "rt": extra["endTime"], - "dt": extra["durationTime"], - } - - dataSet = append(dataSet, dataItem) - reqUUID := uuid.NewV4() - sessionID := uuid.NewV4() - payload := map[string]interface{}{ - "aid": "iywtleaa", - "uuid": reqUUID, - "sid": sessionID, - "cs": map[string]interface{}{ - "uname": extra["userName"], - // "cname": extra["companyName"], - }, - "ds": dataSet, - } - if action, ok := query["action"]; ok { - payload["action"] = action - } - - logrus.Infof("payload: %#v", payload) - marshaled, err := json.Marshal(payload) - if err != nil { - return nil, errors.Errorf("cannot to marshal traceinfo, %s", err) - } - for i := 0; i < len(marshaled); i++ { - marshaled[i] = ^marshaled[i] - } - return marshaled, nil -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/trace/iface.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/trace/iface.go deleted file mode 100644 index 7ddd1aa0ef..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/trace/iface.go +++ /dev/null @@ -1,25 +0,0 @@ -package trace - -// TraceInfo is the detail information of sdk invoking. -type TraceInfo interface { - GetSDKVersion() string - - GetSDKRequest() interface{} - SetSDKRequest(data interface{}) error - - GetSDKResponse() interface{} - SetSDKResponse(data interface{}) error - - IsError() bool - SetError(error) error - - GetTraceback() []StacktraceFrame - - SetExtraData(key string, val interface{}) error - GetExtra() map[string]interface{} -} - -// Tracer is used to send trace information -type Tracer interface { - Send(TraceInfo, map[string]string) error -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/trace/record.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/trace/record.go deleted file mode 100644 index 94c9377e6c..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/trace/record.go +++ /dev/null @@ -1,88 +0,0 @@ -package trace - -import ( - "github.com/ucloud/ucloud-sdk-go/sdk/version" -) - -// DasTraceInfo is an implementation of DasTraceInfo -type DasTraceInfo struct { - SDKVersion string - Channel string - - request interface{} - response interface{} - - err error - traceback []*StacktraceFrame - extra map[string]interface{} -} - -// NewDasTraceInfo will create a new trace info struct with default information -func NewDasTraceInfo() DasTraceInfo { - return DasTraceInfo{ - Channel: "ucloud", - SDKVersion: version.Version, - extra: make(map[string]interface{}), - } -} - -// GetSDKVersion will return version of sdk -func (d *DasTraceInfo) GetSDKVersion() string { - return d.SDKVersion -} - -// GetSDKRequest will return sdk request data -func (d *DasTraceInfo) GetSDKRequest() interface{} { - return d.request -} - -// SetSDKRequest will set sdk request data -func (d *DasTraceInfo) SetSDKRequest(data interface{}) error { - d.request = data - return nil -} - -// GetSDKResponse will return sdk request data -func (d *DasTraceInfo) GetSDKResponse() interface{} { - return d.response -} - -// SetSDKResponse will set sdk request data -func (d *DasTraceInfo) SetSDKResponse(data interface{}) error { - d.response = data - return nil -} - -// IsError will return if this trace record is error -func (d *DasTraceInfo) IsError() bool { - return d.err != nil -} - -// SetError wil set record with error -// if the error has traceback, it will save traceback into this trace infomation record. -func (d *DasTraceInfo) SetError(err error) error { - // TODO: capture error with stacktrace - d.err = err - return nil -} - -// GetTraceback will return all frames of stacktrace -// See also "github.com/pkg/errors" -func (d *DasTraceInfo) GetTraceback() []StacktraceFrame { - return []StacktraceFrame{} -} - -// SetExtraData will set some extra data will be sent to remote server -func (d *DasTraceInfo) SetExtraData(key string, val interface{}) error { - if d.extra == nil { - d.extra = make(map[string]interface{}) - } - - d.extra[key] = val - return nil -} - -// GetExtra will get the key-value map of extra data -func (d *DasTraceInfo) GetExtra() map[string]interface{} { - return d.extra -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/trace/stack.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/trace/stack.go deleted file mode 100644 index 842f1bd598..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/trace/stack.go +++ /dev/null @@ -1,24 +0,0 @@ -package trace - -// Stacktrace is record of golang stacktrack -type Stacktrace struct { - Frames []*StacktraceFrame `json:"frames"` -} - -// StacktraceFrame is the frame of stacktrace record by "github.com/pkg/errors" -// This stack is also same as "raven-go" -type StacktraceFrame struct { - // At least one required - Filename string `json:"filename,omitempty"` - Function string `json:"function,omitempty"` - Module string `json:"module,omitempty"` - - // Optional - Lineno int `json:"lineno,omitempty"` - Colno int `json:"colno,omitempty"` - AbsolutePath string `json:"abs_path,omitempty"` - ContextLine string `json:"context_line,omitempty"` - PreContext []string `json:"pre_context,omitempty"` - PostContext []string `json:"post_context,omitempty"` - InApp bool `json:"in_app"` -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/accessor.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/accessor.go new file mode 100644 index 0000000000..ea169eafee --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/accessor.go @@ -0,0 +1,67 @@ +package utils + +import ( + "reflect" + "strconv" + "strings" + + "github.com/pkg/errors" +) + +func ValueAtPath(v interface{}, path string) (interface{}, error) { + components := strings.Split(path, ".") + + rv := reflect.ValueOf(v) + for rv.Kind() == reflect.Ptr { + if rv.IsNil() { + return nil, errors.Errorf("object %#v is nil", v) + } + rv = rv.Elem() + } + + if rv.Kind() == reflect.Slice || rv.Kind() == reflect.Array { + i, err := strconv.Atoi(components[0]) + if err != nil { + return nil, errors.Errorf("path %s is invalid at index of array", path) + } + + itemV := rv.Index(i) + if !itemV.IsValid() { + return nil, errors.Errorf("path %s is invalid for map", path) + } + + if len(components) > 1 { + return ValueAtPath(itemV.Interface(), strings.Join(components[1:len(components)], ".")) + } else { + return itemV.Interface(), nil + } + } + + if rv.Kind() == reflect.Map && !rv.IsNil() { + itemV := rv.MapIndex(reflect.ValueOf(components[0])) + if !itemV.IsValid() { + return nil, errors.Errorf("path %s is invalid for map", path) + } + + if len(components) > 1 { + return ValueAtPath(itemV.Interface(), strings.Join(components[1:len(components)], ".")) + } else { + return itemV.Interface(), nil + } + } + + if rv.Kind() == reflect.Struct { + itemV := rv.FieldByName(components[0]) + if !itemV.IsValid() { + return nil, errors.Errorf("path %s is invalid for struct", path) + } + + if len(components) > 1 { + return ValueAtPath(itemV.Interface(), strings.Join(components[1:len(components)], ".")) + } else { + 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/sdk/utils/collection.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/collection.go index effc9df1c5..74fca88445 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/collection.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/collection.go @@ -1,5 +1,10 @@ package utils +import ( + "fmt" + "strings" +) + // MergeMap will merge two map and return a new map func MergeMap(args ...map[string]string) map[string]string { m := map[string]string{} @@ -17,3 +22,22 @@ func SetMapIfNotExists(m map[string]string, k string, v string) { m[k] = v } } + +// IsStringIn will return if the value is contains by an array +func IsStringIn(val string, avaliables []string) bool { + for _, choice := range avaliables { + if val == choice { + return true + } + } + + return false +} + +// CheckStringIn will check if the value is contains by an array +func CheckStringIn(val string, avaliables []string) error { + if IsStringIn(val, avaliables) { + return nil + } + return fmt.Errorf("got %s, should be one of %s", val, strings.Join(avaliables, ",")) +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/encoder.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/encoder.go deleted file mode 100644 index b8b34e2a46..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/encoder.go +++ /dev/null @@ -1,153 +0,0 @@ -package utils - -import ( - "errors" - "fmt" - "reflect" - "strconv" -) - -const NIL = "nil" - -// StructEncoder convert struct to map[string][string] -// Only allowed 1-layer struct, no recursive -type StructEncoder struct { - IsZeroValueOmitted bool -} - -func NewStructEncoder(isZeroValueOmitted bool) *StructEncoder { - return &StructEncoder{ - IsZeroValueOmitted: isZeroValueOmitted, - } -} - -func (e *StructEncoder) encodeInt(v *reflect.Value) (string, error) { - realV := v.Int() - if e.IsZeroValueOmitted && IsZeroValue(realV) { - return NIL, nil - } - return strconv.FormatInt(realV, 10), nil -} - -func (e *StructEncoder) encodeUint(v *reflect.Value) (string, error) { - realV := v.Uint() - if e.IsZeroValueOmitted && IsZeroValue(realV) { - return NIL, nil - } - return strconv.FormatUint(realV, 10), nil -} - -func (e *StructEncoder) encodeBool(v *reflect.Value) (string, error) { - realV := v.Bool() - if e.IsZeroValueOmitted && IsZeroValue(realV) { - return NIL, nil - } - return strconv.FormatBool(realV), nil -} - -func (e *StructEncoder) encodeString(v *reflect.Value) (string, error) { - realV := v.String() - if e.IsZeroValueOmitted && IsZeroValue(realV) { - return NIL, nil - } - return realV, nil -} - -func (e *StructEncoder) encodeFloat(v *reflect.Value) (string, error) { - realV := v.Float() - if e.IsZeroValueOmitted && IsZeroValue(realV) { - return NIL, nil - } - return strconv.FormatFloat(realV, 'E', -1, 64), nil -} - -func (e *StructEncoder) encodeInterface(v *reflect.Value) (string, error) { - // TODO: ... - return NIL, nil -} - -func (e *StructEncoder) encodeArray(v *reflect.Value) ([]string, error) { - result := make([]string, v.Len()) - for i := 0; i < v.Len(); i++ { - item := v.Index(i) - - encoded, err := e.encodeBuiltin(&item) - if err != nil { - return make([]string, 0), err - } - - result[i] = encoded - } - return result, nil -} - -func (e *StructEncoder) encodeBuiltin(v *reflect.Value) (string, error) { - switch v.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return e.encodeInt(v) - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32: - return e.encodeUint(v) - case reflect.Float32, reflect.Float64: - return e.encodeFloat(v) - case reflect.Bool: - return e.encodeBool(v) - case reflect.String: - return e.encodeString(v) - case reflect.Ptr: - ptrValue := v.Elem() - return e.encodeBuiltin(&ptrValue) - default: - return "", errors.New(fmt.Sprintf("Invalid variable type, type must be one of int-, uint-, float-, bool, string and ptr, got %s", v.Kind().String())) - } -} - -func (e *StructEncoder) encode(v *reflect.Value) (map[string]string, error) { - result := make(map[string]string) - - for i := 0; i < v.NumField(); i++ { - f := v.Field(i) - name := v.Type().Field(i).Name - - switch f.Kind() { - case reflect.Slice, reflect.Array: - encodedArray, err := e.encodeArray(&f) - if err != nil { - return result, err - } - - for index, encoded := range encodedArray { - if len(encoded) > 0 { - result[fmt.Sprintf("%s.%v", name, index)] = encoded - } - } - case reflect.Interface: - // TODO: implement ISO8601/RFC3339 like ucloudgo - continue - case reflect.Struct: - // resolve composite common struct - for i := 0; i < f.NumField(); i++ { - composited := f.Field(i) - name := f.Type().Field(i).Name - - encoded, err := e.encodeBuiltin(&composited) - if err != nil { - return result, err - } - - if encoded != NIL { - result[name] = encoded - } - } - default: - encoded, err := e.encodeBuiltin(&f) - if err != nil { - return result, err - } - - if encoded != NIL { - result[name] = encoded - } - } - } - return result, nil -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/request.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/request.go deleted file mode 100644 index 7f3490f9e1..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/request.go +++ /dev/null @@ -1,27 +0,0 @@ -package utils - -import ( - "reflect" - - "github.com/Sirupsen/logrus" - - uerr "github.com/ucloud/ucloud-sdk-go/sdk/error" -) - -// RequestToQuery used to convert an request struct to query -func RequestToQuery(req interface{}) (map[string]string, error) { - vReq := reflect.ValueOf(req) - if vReq.Kind() != reflect.Ptr { - logrus.Errorf("Request has type %s, want struct pointer.", vReq.Kind().String()) - return make(map[string]string), uerr.InvalidRequestError - } - - v := vReq.Elem() - if v.Kind() != reflect.Struct { - logrus.Errorf("Request has type %s, want struct pointer.", vReq.Kind().String()) - return make(map[string]string), uerr.InvalidRequestError - } - - encoder := NewStructEncoder(true) - return encoder.encode(&v) -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/style.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/style.go deleted file mode 100644 index 066b90ae3a..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/style.go +++ /dev/null @@ -1,35 +0,0 @@ -package utils - -import "unicode" - -// CamelToUnderscore will convert camel style naming to underscore style -func CamelToUnderscore(s string) string { - r := "" - var prev rune - for _, c := range s { - if unicode.IsLower(prev) && unicode.IsUpper(c) { - r += "_" - } - r += string(unicode.ToLower(c)) - prev = c - } - return r -} - -// UnderscoreToCamel will convert underscore style naming to camel style -func UnderscoreToCamel(s string) string { - r := "" - for i := 0; i < len(s); i++ { - c := s[i] - if c == '_' { - i++ // Skip the underscore - if i < len(s) { - r += string(unicode.ToUpper(rune(s[i]))) - } - continue - } - - r += string(c) - } - return r -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/validator.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/validator.go deleted file mode 100644 index 97dcb68548..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/validator.go +++ /dev/null @@ -1,90 +0,0 @@ -package utils - -import ( - "fmt" - "net" - "strings" -) - -var avaliableHTTPMethod = []string{"GET", "POST", "PUT", "DELETE", "OPTION", "HEAD", "PATCH"} - -// IsAvaliableMethod will check if a string is an avaliable http method. -func IsAvaliableMethod(method string) bool { - for _, m := range avaliableHTTPMethod { - if m == strings.ToUpper(method) { - return true - } - } - return false -} - -// IsZeroValue will check any value if it is a zero value of it't type. -func IsZeroValue(expr interface{}) bool { - if expr == nil { - return true - } - - switch v := expr.(type) { - case bool: - return false - case string: - return len(v) == 0 - case []byte: - return len(v) == 0 - case int: - return v == int(0) - case int32: - return v == int32(0) - case int64: - return v == int64(0) - case uint: - return v == uint(0) - case uint32: - return v == uint32(0) - case uint64: - return v == uint64(0) - case float32: - return v == float32(0.0) - case float64: - return v == float64(0.0) - default: - panic(fmt.Sprintf("unexpected type %T: %v", v, v)) - } -} - -// IsErrorHTTPStatusCode will check a http status is error -func IsErrorHTTPStatusCode(code int) bool { - if 400 <= code && code < 600 { - return true - } - return false -} - -// IsRetryableHTTPStatusCode will check a http status is retryable -func IsRetryableHTTPStatusCode(code int) bool { - retryableCodes := [...]int{429, 502, 503, 504} - for _, retryableCode := range retryableCodes { - if code == retryableCode { - return true - } - } - return false -} - -// IsTimeoutError will check if the error raise from network timeout -func IsTimeoutError(err error) bool { - if err == nil { - return false - } - netError, isNetError := err.(net.Error) - return isNetError && netError.Timeout() -} - -// IsRetryableError will check if the error is retryable -func IsRetryableError(err error) bool { - if err == nil { - return false - } - _, isNetError := err.(net.Error) - return isNetError -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/waiter.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/waiter.go index a32c159e2f..3a8f43104c 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/waiter.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/utils/waiter.go @@ -4,7 +4,7 @@ import ( "errors" "time" - "github.com/Sirupsen/logrus" + "github.com/ucloud/ucloud-sdk-go/sdk/log" ) // Waiter to wait sth until it completed. @@ -27,7 +27,7 @@ type FuncWaiter struct { // It will call the condition function to ensure state with interval. func (w *FuncWaiter) WaitForCompletion() error { for i := 0; ; i++ { - logrus.Infof("Waiting for completion ... attempted %v times, %v total", i, w.MaxAttempts) + log.Infof("Waiting for completion ... attempted %v times, %v total", i, w.MaxAttempts) if i >= w.MaxAttempts { return errors.New("maximum attemps are reached") diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/version.go b/vendor/github.com/ucloud/ucloud-sdk-go/sdk/version.go deleted file mode 100644 index 17a5c671ad..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/sdk/version.go +++ /dev/null @@ -1,5 +0,0 @@ -package sdk - -// VERSION is the version of sdk -// See also semantic version: https://semver.org/ -const VERSION = "1.0.0" diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/create_global_sshinstance.go b/vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/create_global_sshinstance.go deleted file mode 100644 index dcad893edb..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/create_global_sshinstance.go +++ /dev/null @@ -1,68 +0,0 @@ -//go:generate go run ../../private/cli/gen-api/main.go pathx CreateGlobalSSHInstance - -package pathx - -import ( - "github.com/ucloud/ucloud-sdk-go/sdk/request" - "github.com/ucloud/ucloud-sdk-go/sdk/response" -) - -type CreateGlobalSSHInstanceRequest struct { - request.CommonBase - - // Required, 填写支持SSH访问IP的地区名称,如“洛杉矶”,“新加坡”,“香港”,“东京”,“华盛顿” - Area string - - // Required, 被SSH访问的IP - TargetIP string - - // Required, SSH端口,禁止使用80,443等端口 - Port string - - // Optional, 备注信息 - Remark string - - // Optional, 支付方式,如按月、按年、按时 - ChargeType string - - // Optional, 购买数量 - Quantity string - - // Optional, 使用代金券可冲抵部分费用 - CouponId string -} - -type CreateGlobalSSHInstanceResponse struct { - response.CommonBase - - // 实例ID,资源唯一标识 - InstanceId string - - // 加速域名,访问该域名可就近接入 - AcceleratingDomain string -} - -// NewCreateGlobalSSHInstanceRequest will create request of CreateGlobalSSHInstance action. -func (c *PathXClient) NewCreateGlobalSSHInstanceRequest() *CreateGlobalSSHInstanceRequest { - cfg := c.client.GetConfig() - - return &CreateGlobalSSHInstanceRequest{ - CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, - }, - } -} - -// CreateGlobalSSHInstance - 创建GlobalSSH实例 -func (c *PathXClient) CreateGlobalSSHInstance(req *CreateGlobalSSHInstanceRequest) (*CreateGlobalSSHInstanceResponse, error) { - var err error - var res CreateGlobalSSHInstanceResponse - - err = c.client.InvokeAction("CreateGlobalSSHInstance", req, &res) - if err != nil { - return nil, err - } - - return &res, nil -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/describe_image.go b/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/describe_image.go deleted file mode 100644 index dd23a65575..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/describe_image.go +++ /dev/null @@ -1,69 +0,0 @@ -//go:generate go run ../../private/cli/gen-api/main.go uhost DescribeImage - -package uhost - -import ( - "github.com/ucloud/ucloud-sdk-go/sdk/request" - "github.com/ucloud/ucloud-sdk-go/sdk/response" - . "github.com/ucloud/ucloud-sdk-go/service/uhost/types" -) - -type DescribeImageRequest struct { - request.CommonBase - - // Optional, 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone string - - // Optional, 镜像类型。标准镜像:Base,镜像市场:Business, 自定义镜像:Custom,默认返回所有类型 - ImageType string - - // Optional, 操作系统类型:Linux, Windows 默认返回所有类型 - OsType string - - // Optional, 镜像Id - ImageId string - - // Optional, 列表起始位置偏移量,默认为0 - Offset int - - // Optional, 返回数据长度,默认为20 - Limit int - - // Optional, 是否返回价格:1返回,0不返回;默认不返回 - PriceSet int -} - -type DescribeImageResponse struct { - response.CommonBase - - // 满足条件的镜像总数 - TotalCount int - - // 镜像列表详见 UHostImageSet - ImageSet []UHostImageSet -} - -// NewDescribeImageRequest will create request of DescribeImage action. -func (c *UHostClient) NewDescribeImageRequest() *DescribeImageRequest { - cfg := c.client.GetConfig() - - return &DescribeImageRequest{ - CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, - }, - } -} - -// DescribeImage - 获取指定数据中心镜像列表,用户可通过指定操作系统类型,镜像Id进行过滤。 -func (c *UHostClient) DescribeImage(req *DescribeImageRequest) (*DescribeImageResponse, error) { - var err error - var res DescribeImageResponse - - err = c.client.InvokeAction("DescribeImage", req, &res) - if err != nil { - return nil, err - } - - return &res, nil -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/describe_uhost_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/describe_uhost_instance.go deleted file mode 100644 index 030eb67e8b..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/describe_uhost_instance.go +++ /dev/null @@ -1,63 +0,0 @@ -//go:generate go run ../../private/cli/gen-api/main.go uhost DescribeUHostInstance - -package uhost - -import ( - "github.com/ucloud/ucloud-sdk-go/sdk/request" - "github.com/ucloud/ucloud-sdk-go/sdk/response" - . "github.com/ucloud/ucloud-sdk-go/service/uhost/types" -) - -type DescribeUHostInstanceRequest struct { - request.CommonBase - - // Optional, 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone string - - // Optional, 【数组】UHost主机的资源ID,例如UHostIds.0代表希望获取信息 的主机1,UHostIds.1代表主机2。 如果不传入,则返回当前Region 所有符合条件的UHost实例。 - UHostIds []string - - // Optional, 要查询的业务组名称 - Tag string - - // Optional, 列表起始位置偏移量,默认为0 - Offset int - - // Optional, 返回数据长度,默认为20,最大100 - Limit int -} - -type DescribeUHostInstanceResponse struct { - response.CommonBase - - // UHostInstance总数 - TotalCount int - - // 云主机实例列表,每项参数可见下面 UHostInstanceSet - UHostSet []UHostInstanceSet -} - -// NewDescribeUHostInstanceRequest will create request of DescribeUHostInstance action. -func (c *UHostClient) NewDescribeUHostInstanceRequest() *DescribeUHostInstanceRequest { - cfg := c.client.GetConfig() - - return &DescribeUHostInstanceRequest{ - CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, - }, - } -} - -// DescribeUHostInstance - 获取主机或主机列表信息,并可根据数据中心,主机ID等参数进行过滤。 -func (c *UHostClient) DescribeUHostInstance(req *DescribeUHostInstanceRequest) (*DescribeUHostInstanceResponse, error) { - var err error - var res DescribeUHostInstanceResponse - - err = c.client.InvokeAction("DescribeUHostInstance", req, &res) - if err != nil { - return nil, err - } - - return &res, nil -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/allocate_backend.go b/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/allocate_backend.go deleted file mode 100644 index 235a804a34..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/allocate_backend.go +++ /dev/null @@ -1,62 +0,0 @@ -//go:generate go run ../../private/cli/gen-api/main.go ulb AllocateBackend - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/sdk/request" - "github.com/ucloud/ucloud-sdk-go/sdk/response" -) - -type AllocateBackendRequest struct { - request.CommonBase - - // Required, 负载均衡实例的ID - ULBId string - - // Required, VServer实例的ID - VServerId string - - // Required, 所添加的后端资源的类型 - ResourceType string - - // Required, 所添加的后端资源的资源ID - ResourceId string - - // Optional, 所添加的后端资源服务端口,取值范围[1-65535],默认80 - Port int - - // Optional, 后端实例状态开关,枚举值: 1:启用; 0:禁用 默认为启用 - Enabled int -} - -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 { - cfg := c.client.GetConfig() - - return &AllocateBackendRequest{ - CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, - }, - } -} - -// 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 nil, err - } - - return &res, nil -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/create_policy.go b/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/create_policy.go deleted file mode 100644 index 4b7c9c3a7e..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/create_policy.go +++ /dev/null @@ -1,59 +0,0 @@ -//go:generate go run ../../private/cli/gen-api/main.go ulb CreatePolicy - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/sdk/request" - "github.com/ucloud/ucloud-sdk-go/sdk/response" -) - -type CreatePolicyRequest struct { - request.CommonBase - - // Required, 需要添加内容转发策略的负载均衡实例ID - ULBId string - - // Required, 需要添加内容转发策略的VServer实例ID - VServerId string - - // Required, 内容转发策略应用的后端资源实例的ID,来源于 AllocateBackend 返回的 BackendId - BackendId []string - - // Required, 内容转发匹配字段 - Match string - - // Optional, 内容转发匹配字段的类型 - Type string -} - -type CreatePolicyResponse struct { - response.CommonBase - - // 内容转发策略ID - PolicyId string -} - -// NewCreatePolicyRequest will create request of CreatePolicy action. -func (c *ULBClient) NewCreatePolicyRequest() *CreatePolicyRequest { - cfg := c.client.GetConfig() - - return &CreatePolicyRequest{ - CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, - }, - } -} - -// 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 nil, err - } - - return &res, nil -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/create_ulb.go b/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/create_ulb.go deleted file mode 100644 index 55e13e5fb5..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/create_ulb.go +++ /dev/null @@ -1,71 +0,0 @@ -//go:generate go run ../../private/cli/gen-api/main.go ulb CreateULB - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/sdk/request" - "github.com/ucloud/ucloud-sdk-go/sdk/response" -) - -type CreateULBRequest struct { - request.CommonBase - - // Optional, 负载均衡的名字,默认值为“ULB” - ULBName string - - // Optional, 业务组 - Tag string - - // Optional, 备注 - Remark string - - // Optional, 创建的ULB是否为外网模式,默认即为外网模式 - OuterMode string - - // Optional, 创建的ULB是否为内网模式 - InnerMode string - - // Optional, 付费方式 - ChargeType string - - // Optional, ULB所在的VPC的ID, 如果不传则使用默认的VPC - VPCId string - - // Optional, 内网ULB 所属的子网ID,如果不传则使用默认的子网 - SubnetId string - - // Optional, ULB 所属的业务组ID,如果不传则使用默认的业务组 - BusinessId string -} - -type CreateULBResponse struct { - response.CommonBase - - // 负载均衡实例的Id - ULBId string -} - -// NewCreateULBRequest will create request of CreateULB action. -func (c *ULBClient) NewCreateULBRequest() *CreateULBRequest { - cfg := c.client.GetConfig() - - return &CreateULBRequest{ - CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, - }, - } -} - -// 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 nil, err - } - - return &res, nil -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/create_vserver.go b/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/create_vserver.go deleted file mode 100644 index 75439a9bce..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/create_vserver.go +++ /dev/null @@ -1,71 +0,0 @@ -//go:generate go run ../../private/cli/gen-api/main.go ulb CreateVServer - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/sdk/request" - "github.com/ucloud/ucloud-sdk-go/sdk/response" -) - -type CreateVServerRequest struct { - request.CommonBase - - // Required, 负载均衡实例ID - ULBId string - - // Optional, VServer实例名称,默认为"VServer" - VServerName string - - // Optional, 监听器类型,枚举值为:RequestProxy:请求代理;PacketsTransmit:报文转发;默认为RequestProxy - ListenType string - - // Optional, VServer实例的协议,请求代理模式下有 HTTP、HTTPS、TCP,报文转发下有 TCP,UDP - Protocol string - - // Optional, VServer后端端口,取值范围[1-65535];默认值为80 - FrontendPort int - - // Optional, VServer负载均衡模式, 默认为轮询模式,ConsistentHash,SourcePort,ConsistentHashPort 只在报文转发中使用;Roundrobin和Source在请求代理和报文转发中使用。 - Method string - - // Optional, VServer会话保持方式,默认关闭会话保持。枚举值:None:关闭;ServerInsert:自动生成KEY;UserDefined:用户自定义KEY。 - PersistenceType string - - // Optional, 根据PersistenceType确认; None和ServerInsert:此字段无意义; UserDefined:此字段传入自定义会话保持String - PersistenceInfo string - - // Optional, ListenType为RequestProxy时表示空闲连接的回收时间,单位:秒,取值范围:时(0,86400],默认值为60;ListenType为PacketsTransmit时表示连接保持的时间,单位:秒,取值范围:[60,900],0 表示禁用连接保持 - ClientTimeout int -} - -type CreateVServerResponse struct { - response.CommonBase - - // VServer实例的Id - VServerId string -} - -// NewCreateVServerRequest will create request of CreateVServer action. -func (c *ULBClient) NewCreateVServerRequest() *CreateVServerRequest { - cfg := c.client.GetConfig() - - return &CreateVServerRequest{ - CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, - }, - } -} - -// 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 nil, err - } - - return &res, nil -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/describe_ulb.go b/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/describe_ulb.go deleted file mode 100644 index 5e15e7e2b6..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/describe_ulb.go +++ /dev/null @@ -1,66 +0,0 @@ -//go:generate go run ../../private/cli/gen-api/main.go ulb DescribeULB - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/sdk/request" - "github.com/ucloud/ucloud-sdk-go/sdk/response" - . "github.com/ucloud/ucloud-sdk-go/service/ulb/types" -) - -type DescribeULBRequest struct { - request.CommonBase - - // Optional, 数据偏移量,默认为0 - Offset int - - // Optional, 数据分页值,默认为20 - Limit int - - // Optional, 负载均衡实例的Id。 若指定则返回指定的负载均衡实例的信息; 若不指定则返回当前数据中心中所有的负载均衡实例的信息 - ULBId string - - // Optional, ULB所属的VPC - VPCId string - - // Optional, ULB所属的子网ID - SubnetId string - - // Optional, ULB所属的业务组ID - BusinessId string -} - -type DescribeULBResponse struct { - response.CommonBase - - // 满足条件的ULB总数 - TotalCount int - - // ULB列表,每项参数详见 ULBSet - DataSet []ULBSet -} - -// NewDescribeULBRequest will create request of DescribeULB action. -func (c *ULBClient) NewDescribeULBRequest() *DescribeULBRequest { - cfg := c.client.GetConfig() - - return &DescribeULBRequest{ - CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, - }, - } -} - -// 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 nil, err - } - - return &res, nil -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/types/sslbinded_target_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/types/sslbinded_target_set.go deleted file mode 100644 index 7c02d902ff..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/types/sslbinded_target_set.go +++ /dev/null @@ -1,17 +0,0 @@ -package types - -// SSLBindedTargetSet - DescribeSSL -type SSLBindedTargetSet struct { - - // SSL证书绑定到的VServer的资源ID - VServerId string - - // 对应的VServer的名字 - VServerName string - - // VServer 所属的ULB实例的资源ID - ULBId string - - // ULB实例的名称 - ULBName string -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/types/ulbipset.go b/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/types/ulbipset.go deleted file mode 100644 index 97435834e1..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/types/ulbipset.go +++ /dev/null @@ -1,14 +0,0 @@ -package types - -// ULBIPSet - DescribeULB -type ULBIPSet struct { - - // 弹性IP的运营商信息,枚举值为: Telecom:电信IP Unicom:联通IP Duplet:双线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/service/ulb/types/ulbsslset.go b/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/types/ulbsslset.go deleted file mode 100644 index 6439d7e3f2..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/types/ulbsslset.go +++ /dev/null @@ -1,11 +0,0 @@ -package types - -// ULBSSLSet - DescribeULB -type ULBSSLSet struct { - - // SSL证书的Id - SSLId string - - // SSL证书的名字 - SSLName string -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/types/ulbvserver_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/types/ulbvserver_set.go deleted file mode 100644 index 58506c3218..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/types/ulbvserver_set.go +++ /dev/null @@ -1,41 +0,0 @@ -package types - -// ULBVServerSet - DescribeULB -type ULBVServerSet struct { - - // VServer实例的Id - VServerId string - - // VServer实例的名字 - VServerName string - - // VServer实例的协议。 枚举值为:HTTP,TCP,UDP,HTTPS。 - Protocol string - - // VServer服务端口 - FrontendPort int - - // VServer负载均衡的模式,具体的值参见 CreateVServer - Method string - - // VServer会话保持方式。枚举值为: None,关闭会话保持; ServerInsert,自动生成; UserDefined,用户自定义。 - PersistenceType string - - // 根据PersistenceType确定: None或ServerInsert,此字段为空; UserDefined,此字段展示用户自定义会话。 - PersistenceInfo string - - // 空闲连接的回收时间,单位:秒。 - ClientTimeout int - - // VServer的运行状态。枚举值: 0:运行正常;1:运行异常。 - Status int - - // VServer绑定的SSL证书信息,具体结构见下方 ULBSSLSet - SSLSet []ULBSSLSet - - // 后端资源信息列表,具体结构见下方 ULBBackendSet - VServerSet []ULBBackendSet - - // 监听器类型,枚举值为:RequestProxy:请求代理;PacketsTransmit:报文转发;默认为RequestProxy - ListenType string -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/update_vserver_attribute.go b/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/update_vserver_attribute.go deleted file mode 100644 index 3cd13fa621..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/update_vserver_attribute.go +++ /dev/null @@ -1,74 +0,0 @@ -//go:generate go run ../../private/cli/gen-api/main.go ulb UpdateVServerAttribute - -package ulb - -import ( - "github.com/ucloud/ucloud-sdk-go/sdk/request" - "github.com/ucloud/ucloud-sdk-go/sdk/response" -) - -type UpdateVServerAttributeRequest struct { - request.CommonBase - - // Required, 负载均衡实例ID - ULBId string - - // Required, VServer实例ID - VServerId string - - // Optional, VServer实例名称,若无此字段则不做修改 - VServerName string - - // Optional, VServer协议类型,请求代理只支持修改为 HTTP/HTTPS,报文转发VServer只支持修改为 TCP/UDP - Protocol string - - // Optional, VServer负载均衡算法,ConsistentHash,SourcePort,ConsistentHashPort 只在报文转发中使用;Roundrobin和Source在请求代理和报文转发中使用。 - Method string - - // Optional, VServer会话保持模式,若无此字段则不做修改。枚举值:None:关闭;ServerInsert:自动生成KEY;UserDefined:用户自定义KEY。 - PersistenceType string - - // Optional, 根据PersistenceType确定: None或ServerInsert, 此字段无意义; UserDefined, 则此字段传入用户自定义会话保持String. 若无此字段则不做修改 - PersistenceInfo string - - // Optional, 请求代理的VServer下表示空闲连接的回收时间,单位:秒,取值范围:时(0,86400],默认值为60;报文转发的VServer下表示回话保持的时间,单位:秒,取值范围:[60,900],0 表示禁用连接保持 - ClientTimeout string - - // Optional, 健康检查的类型,Port:端口,Path:路径 - MonitorType string - - // Optional, MonitorType 为 Path 时指定健康检查发送请求时HTTP HEADER 里的域名 - Domain string - - // Optional, MonitorType 为 Path 时指定健康检查发送请求时的路径,默认为 / - Path string -} - -type UpdateVServerAttributeResponse struct { - response.CommonBase -} - -// NewUpdateVServerAttributeRequest will create request of UpdateVServerAttribute action. -func (c *ULBClient) NewUpdateVServerAttributeRequest() *UpdateVServerAttributeRequest { - cfg := c.client.GetConfig() - - return &UpdateVServerAttributeRequest{ - CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, - }, - } -} - -// 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 nil, err - } - - return &res, nil -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/allocate_eip.go b/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/allocate_eip.go deleted file mode 100644 index 0fb134395e..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/allocate_eip.go +++ /dev/null @@ -1,75 +0,0 @@ -//go:generate go run ../../private/cli/gen-api/main.go unet AllocateEIP - -package unet - -import ( - "github.com/ucloud/ucloud-sdk-go/sdk/request" - "github.com/ucloud/ucloud-sdk-go/sdk/response" - . "github.com/ucloud/ucloud-sdk-go/service/unet/types" -) - -type AllocateEIPRequest struct { - request.CommonBase - - // Required, 弹性IP的线路如下: 国际: International BGP: Bgp 各地域允许的线路参数如下: cn-sh1: Bgp cn-sh2: Bgp cn-gd: Bgp cn-bj1: Bgp cn-bj2: Bgp hk: International us-ca: International th-bkk: International kr-seoul:International us-ws:International ge-fra:International sg:International tw-kh:International - OperatorName string - - // Required, 弹性IP的外网带宽, 单位为Mbps. 共享带宽模式必须指定0M带宽, 非共享带宽模式必须指定非0Mbps带宽. 各地域非共享带宽的带宽范围如下: 流量计费[1-200],带宽计费[1-800] - Bandwidth int - - // Optional, 业务组名称, 默认为 "Default" - Tag string - - // Optional, 付费方式, 枚举值为: Year, 按年付费; Month, 按月付费; Dynamic, 按需付费(需开启权限); Trial, 试用(需开启权限) 默认为按月付费 - ChargeType string - - // Optional, 购买时长, 默认: 1 - Quantity int - - // Optional, 弹性IP的计费模式. 枚举值: "Traffic", 流量计费; "Bandwidth", 带宽计费; "ShareBandwidth",共享带宽模式. 默认为 "Bandwidth". - PayMode string - - // Optional, 绑定的共享带宽Id,仅当PayMode为ShareBandwidth时有效 - ShareBandwidthId string - - // Optional, 弹性IP的名称, 默认为 "EIP" - Name string - - // Optional, 弹性IP的备注, 默认为空 - Remark string - - // Optional, 代金券ID, 默认不使用 - CouponId string -} - -type AllocateEIPResponse struct { - response.CommonBase - - // 申请到的EIP资源详情 参见 UnetAllocateEIPSet - EIPSet []UnetAllocateEIPSet -} - -// NewAllocateEIPRequest will create request of AllocateEIP action. -func (c *UNetClient) NewAllocateEIPRequest() *AllocateEIPRequest { - cfg := c.client.GetConfig() - - return &AllocateEIPRequest{ - CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, - }, - } -} - -// AllocateEIP - 根据提供信息, 申请弹性IP -func (c *UNetClient) AllocateEIP(req *AllocateEIPRequest) (*AllocateEIPResponse, error) { - var err error - var res AllocateEIPResponse - - err = c.client.InvokeAction("AllocateEIP", req, &res) - if err != nil { - return nil, err - } - - return &res, nil -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/bind_eip.go b/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/bind_eip.go deleted file mode 100644 index 4741f118ae..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/bind_eip.go +++ /dev/null @@ -1,50 +0,0 @@ -//go:generate go run ../../private/cli/gen-api/main.go unet BindEIP - -package unet - -import ( - "github.com/ucloud/ucloud-sdk-go/sdk/request" - "github.com/ucloud/ucloud-sdk-go/sdk/response" -) - -type BindEIPRequest struct { - request.CommonBase - - // Required, 弹性IP的资源Id - EIPId string - - // Required, 弹性IP请求绑定的资源类型, 枚举值为: uhost: 云主机; vrouter: 虚拟路由器; ulb, 负载均衡器 upm: 物理机; hadoophost: 大数据集群;fortresshost:堡垒机;udockhost:容器;udhost:私有专区主机;natgw:natgw;udb:udb;vpngw:ipsec vpn;ucdr:云灾备;dbaudit:数据库审计; - ResourceType string - - // Required, 弹性IP请求绑定的资源ID - ResourceId string -} - -type BindEIPResponse struct { - response.CommonBase -} - -// NewBindEIPRequest will create request of BindEIP action. -func (c *UNetClient) NewBindEIPRequest() *BindEIPRequest { - cfg := c.client.GetConfig() - - return &BindEIPRequest{ - CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, - }, - } -} - -// BindEIP - 将尚未使用的弹性IP绑定到指定的资源 -func (c *UNetClient) BindEIP(req *BindEIPRequest) (*BindEIPResponse, error) { - var err error - var res BindEIPResponse - - err = c.client.InvokeAction("BindEIP", req, &res) - if err != nil { - return nil, err - } - - return &res, nil -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/types/unet_allocate_eipset.go b/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/types/unet_allocate_eipset.go deleted file mode 100644 index 5c99c7fb67..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/types/unet_allocate_eipset.go +++ /dev/null @@ -1,11 +0,0 @@ -package types - -// UnetAllocateEIPSet - AllocateEIP -type UnetAllocateEIPSet struct { - - // 申请到的EIP资源ID - EIPId string - - // 申请到的IPv4地址. 如果在请求参数中OperatorName为Duplet, 则EIPAddr中会含有两个IP地址, 一个为电信IP, 一个为联通IP. 其余情况下, EIPAddr只含有一个IP. 参见 UnetEIPAddrSet - EIPAddr []UnetEIPAddrSet -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/un_bind_eip.go b/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/un_bind_eip.go deleted file mode 100644 index ecb1342cf3..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/un_bind_eip.go +++ /dev/null @@ -1,50 +0,0 @@ -//go:generate go run ../../private/cli/gen-api/main.go unet UnBindEIP - -package unet - -import ( - "github.com/ucloud/ucloud-sdk-go/sdk/request" - "github.com/ucloud/ucloud-sdk-go/sdk/response" -) - -type UnBindEIPRequest struct { - request.CommonBase - - // Required, 弹性IP的资源Id - EIPId string - - // Required, 弹性IP请求解绑的资源类型, 枚举值为: uhost: 云主机; vrouter: 虚拟路由器; ulb, 负载均衡器 upm: 物理机; hadoophost: 大数据集群;fortresshost:堡垒机;udockhost:容器;udhost:私有专区主机;natgw:natgw;udb:udb;vpngw:ipsec vpn;ucdr:云灾备;dbaudit:数据库审计; - ResourceType string - - // Required, 弹性IP请求解绑的资源ID - ResourceId string -} - -type UnBindEIPResponse struct { - response.CommonBase -} - -// NewUnBindEIPRequest will create request of UnBindEIP action. -func (c *UNetClient) NewUnBindEIPRequest() *UnBindEIPRequest { - cfg := c.client.GetConfig() - - return &UnBindEIPRequest{ - CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, - }, - } -} - -// UnBindEIP - 将弹性IP从资源上解绑 -func (c *UNetClient) UnBindEIP(req *UnBindEIPRequest) (*UnBindEIPResponse, error) { - var err error - var res UnBindEIPResponse - - err = c.client.InvokeAction("UnBindEIP", req, &res) - if err != nil { - return nil, err - } - - return &res, nil -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/types/resource_info.go b/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/types/resource_info.go deleted file mode 100644 index 1522e8141b..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/types/resource_info.go +++ /dev/null @@ -1,17 +0,0 @@ -package types - -// ResourceInfo - 资源信息 -type ResourceInfo struct { - - // 资源名称 - Name string - - // 资源id - ResourceId string - - // 资源类型 - ResourceType int - - // ip地址 - IP string -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/types/vpcinfo_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/types/vpcinfo_set.go deleted file mode 100644 index 8d366216f5..0000000000 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/types/vpcinfo_set.go +++ /dev/null @@ -1,29 +0,0 @@ -package types - -// VPCInfoSet - VPC信息 -type VPCInfoSet struct { - - // - VPCId string - - // - Network []string - - // - SubnetCount int - - // - CreateTime int // uxiao is string - - // - UpdateTime int // uxiao is string - - // - Tag string - - // - Remark string - - // - Name string -} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/client.go similarity index 53% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/client.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/client.go index b7117d7bdf..f8b42d2c03 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/client.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/client.go @@ -1,14 +1,14 @@ -package service +package services import ( "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/auth" - "github.com/ucloud/ucloud-sdk-go/service/pathx" - "github.com/ucloud/ucloud-sdk-go/service/uaccount" - "github.com/ucloud/ucloud-sdk-go/service/uhost" - "github.com/ucloud/ucloud-sdk-go/service/ulb" - "github.com/ucloud/ucloud-sdk-go/service/unet" - "github.com/ucloud/ucloud-sdk-go/service/vpc" + "github.com/ucloud/ucloud-sdk-go/services/pathx" + "github.com/ucloud/ucloud-sdk-go/services/uaccount" + "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" ) type Client struct { @@ -25,7 +25,8 @@ type Client struct { pathx.PathXClient } -func NewClient(config *sdk.ClientConfig, credential *auth.Credential) *Client { +// NewClient will return a aggregate client +func NewClient(config *sdk.Config, credential *auth.Credential) *Client { return &Client{ *uaccount.NewClient(config, credential), diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/client.go similarity index 74% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/client.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/client.go index 01246ed100..624f3f961f 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/client.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/client.go @@ -9,7 +9,7 @@ type PathXClient struct { client *sdk.Client } -func NewClient(config *sdk.ClientConfig, credential *auth.Credential) *PathXClient { +func NewClient(config *sdk.Config, credential *auth.Credential) *PathXClient { client := sdk.NewClient(config, credential) return &PathXClient{ client: client, diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/create_global_sshinstance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/create_global_sshinstance.go new file mode 100644 index 0000000000..5c897181c4 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/create_global_sshinstance.go @@ -0,0 +1,78 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api PathX CreateGlobalSSHInstance + +package pathx + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// CreateGlobalSSHInstanceRequest is request schema for CreateGlobalSSHInstance action +type CreateGlobalSSHInstanceRequest struct { + request.CommonBase + + // 填写支持SSH访问IP的地区名称,如“洛杉矶”,“新加坡”,“香港”,“东京”,“华盛顿”,“法兰克福”。Area和AreaCode两者必填一个 + Area *string `required:"true"` + + // 被SSH访问的IP + TargetIP *string `required:"true"` + + // SSH端口,1-65535且不能使用80,443端口 + Port *int `required:"true"` + + // AreaCode, 区域航空港国际通用代码。Area和AreaCode两者必填一个 + AreaCode *string `required:"true"` + + // 备注信息 + Remark *string `required:"false"` + + // 支付方式,如按月、按年、按时 + ChargeType *string `required:"false"` + + // 购买数量 + Quantity *int `required:"false"` + + // 使用代金券可冲抵部分费用 + CouponId *string `required:"false"` +} + +// CreateGlobalSSHInstanceResponse is response schema for CreateGlobalSSHInstance action +type CreateGlobalSSHInstanceResponse struct { + response.CommonBase + + // 实例ID,资源唯一标识 + InstanceId string + + // 加速域名,访问该域名可就近接入 + AcceleratingDomain string + + // 提示信息 + Message string +} + +// NewCreateGlobalSSHInstanceRequest will create request of CreateGlobalSSHInstance action. +func (c *PathXClient) NewCreateGlobalSSHInstanceRequest() *CreateGlobalSSHInstanceRequest { + cfg := c.client.GetConfig() + + return &CreateGlobalSSHInstanceRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// CreateGlobalSSHInstance - 创建GlobalSSH实例 +func (c *PathXClient) CreateGlobalSSHInstance(req *CreateGlobalSSHInstanceRequest) (*CreateGlobalSSHInstanceResponse, error) { + var err error + var res CreateGlobalSSHInstanceResponse + + err = c.client.InvokeAction("CreateGlobalSSHInstance", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/delete_global_sshinstance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/delete_global_sshinstance.go similarity index 61% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/delete_global_sshinstance.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/delete_global_sshinstance.go index 6db3c155f6..55d37b7980 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/delete_global_sshinstance.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/delete_global_sshinstance.go @@ -1,21 +1,28 @@ -//go:generate go run ../../private/cli/gen-api/main.go pathx DeleteGlobalSSHInstance +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api PathX DeleteGlobalSSHInstance package pathx import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +// DeleteGlobalSSHInstanceRequest is request schema for DeleteGlobalSSHInstance action type DeleteGlobalSSHInstanceRequest struct { request.CommonBase - // Required, 实例Id,资源的唯一标识 - InstanceId string + // 实例Id,资源的唯一标识 + InstanceId *string `required:"true"` } +// DeleteGlobalSSHInstanceResponse is response schema for DeleteGlobalSSHInstance action type DeleteGlobalSSHInstanceResponse struct { response.CommonBase + + // 提示信息 + Message string } // NewDeleteGlobalSSHInstanceRequest will create request of DeleteGlobalSSHInstance action. @@ -24,8 +31,8 @@ func (c *PathXClient) NewDeleteGlobalSSHInstanceRequest() *DeleteGlobalSSHInstan return &DeleteGlobalSSHInstanceRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/describe_global_ssharea.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/describe_global_ssharea.go new file mode 100644 index 0000000000..2c1eb252f0 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/describe_global_ssharea.go @@ -0,0 +1,48 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api PathX DescribeGlobalSSHArea + +package pathx + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// DescribeGlobalSSHAreaRequest is request schema for DescribeGlobalSSHArea action +type DescribeGlobalSSHAreaRequest struct { + request.CommonBase + +} + +// DescribeGlobalSSHAreaResponse is response schema for DescribeGlobalSSHArea action +type DescribeGlobalSSHAreaResponse struct { + response.CommonBase + + // 支持GlobalSSH的地区 + AreaSet []GlobalSSHArea + + // 提示信息 + Message string + +} + +// NewDescribeGlobalSSHAreaRequest will create request of DescribeGlobalSSHArea action. +func (c *PathXClient) NewDescribeGlobalSSHAreaRequest() *DescribeGlobalSSHAreaRequest { + req := &DescribeGlobalSSHAreaRequest{} + c.client.SetupRequest(req, "DescribeGlobalSSHArea") + return req +} + +// DescribeGlobalSSHArea - 获取GlobalSSH覆盖的地区列表 用于控制显示哪些机房地域可以使用SSH特性 +func (c *PathXClient) DescribeGlobalSSHArea(req *DescribeGlobalSSHAreaRequest) (*DescribeGlobalSSHAreaResponse, error) { + var err error + var res DescribeGlobalSSHAreaResponse + + err = c.client.InvokeAction("DescribeGlobalSSHArea", req, &res) + if err != nil { + return &res, err + } + + return &res, nil +} + diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/describe_global_sshinstance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/describe_global_sshinstance.go similarity index 67% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/describe_global_sshinstance.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/describe_global_sshinstance.go index f6c7cca25c..18334eb38b 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/describe_global_sshinstance.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/describe_global_sshinstance.go @@ -1,20 +1,23 @@ -//go:generate go run ../../private/cli/gen-api/main.go pathx DescribeGlobalSSHInstance +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api PathX DescribeGlobalSSHInstance package pathx import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" - . "github.com/ucloud/ucloud-sdk-go/service/pathx/types" ) +// DescribeGlobalSSHInstanceRequest is request schema for DescribeGlobalSSHInstance action type DescribeGlobalSSHInstanceRequest struct { request.CommonBase - // Optional, 实例ID,资源唯一标识 - InstanceId string + // 实例ID,资源唯一标识 + InstanceId *string `required:"false"` } +// DescribeGlobalSSHInstanceResponse is response schema for DescribeGlobalSSHInstance action type DescribeGlobalSSHInstanceResponse struct { response.CommonBase @@ -28,8 +31,8 @@ func (c *PathXClient) NewDescribeGlobalSSHInstanceRequest() *DescribeGlobalSSHIn return &DescribeGlobalSSHInstanceRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/doc.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/doc.go similarity index 100% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/doc.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/doc.go diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/modify_global_sshport.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/modify_global_sshport.go similarity index 58% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/modify_global_sshport.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/modify_global_sshport.go index d59c1c2c9e..76954b3ee5 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/modify_global_sshport.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/modify_global_sshport.go @@ -1,24 +1,31 @@ -//go:generate go run ../../private/cli/gen-api/main.go pathx ModifyGlobalSSHPort +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api PathX ModifyGlobalSSHPort package pathx import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +// ModifyGlobalSSHPortRequest is request schema for ModifyGlobalSSHPort action type ModifyGlobalSSHPortRequest struct { request.CommonBase - // Required, 实例ID,资源唯一标识 - InstanceId string + // 实例ID,资源唯一标识 + InstanceId *string `required:"true"` - // Required, 调整后的SSH登陆端口 - Port string + // 调整后的SSH登陆端口 + Port *int `required:"true"` } +// ModifyGlobalSSHPortResponse is response schema for ModifyGlobalSSHPort action type ModifyGlobalSSHPortResponse struct { response.CommonBase + + // 提示信息 + Message string } // NewModifyGlobalSSHPortRequest will create request of ModifyGlobalSSHPort action. @@ -27,8 +34,8 @@ func (c *PathXClient) NewModifyGlobalSSHPortRequest() *ModifyGlobalSSHPortReques return &ModifyGlobalSSHPortRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/modify_global_sshremark.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/modify_global_sshremark.go similarity index 58% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/modify_global_sshremark.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/modify_global_sshremark.go index b0dbc1d5b5..a749ec237d 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/modify_global_sshremark.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/modify_global_sshremark.go @@ -1,24 +1,31 @@ -//go:generate go run ../../private/cli/gen-api/main.go pathx ModifyGlobalSSHRemark +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api PathX ModifyGlobalSSHRemark package pathx import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +// ModifyGlobalSSHRemarkRequest is request schema for ModifyGlobalSSHRemark action type ModifyGlobalSSHRemarkRequest struct { request.CommonBase - // Required, 实例ID,资源唯一标识 - InstanceId string + // 实例ID,资源唯一标识 + InstanceId *string `required:"true"` - // Optional, 备注信息,不填默认为空字符串 - Remark string + // 备注信息,不填默认为空字符串 + Remark *string `required:"false"` } +// ModifyGlobalSSHRemarkResponse is response schema for ModifyGlobalSSHRemark action type ModifyGlobalSSHRemarkResponse struct { response.CommonBase + + // 接口返回消息 + Message string } // NewModifyGlobalSSHRemarkRequest will create request of ModifyGlobalSSHRemark action. @@ -27,8 +34,8 @@ func (c *PathXClient) NewModifyGlobalSSHRemarkRequest() *ModifyGlobalSSHRemarkRe return &ModifyGlobalSSHRemarkRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } 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 new file mode 100644 index 0000000000..ec93285a2d --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/types_global_ssharea.go @@ -0,0 +1,22 @@ + +package pathx + +/* + 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. +*/ +type GlobalSSHArea struct { + + // GlobalSSH覆盖的地区,如香港、东京、洛杉矶等 + Area string + + // 地区代号,以地区AirPort Code + AreaCode string + + // ucloud机房代号构成的数组,如["hk","us-ca"] + RegionSet []string + +} + diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/types/global_sshinfo.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/types_global_sshinfo.go similarity index 70% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/types/global_sshinfo.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/types_global_sshinfo.go index e3266ad671..03531069b6 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/pathx/types/global_sshinfo.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/pathx/types_global_sshinfo.go @@ -1,6 +1,11 @@ -package types +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. +*/ type GlobalSSHInfo struct { // 实例ID,资源唯一标识 diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/client.go similarity index 74% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/client.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/client.go index ac86f5fa16..fd6fe5719d 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/client.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/client.go @@ -9,7 +9,7 @@ type UAccountClient struct { client *sdk.Client } -func NewClient(config *sdk.ClientConfig, credential *auth.Credential) *UAccountClient { +func NewClient(config *sdk.Config, credential *auth.Credential) *UAccountClient { client := sdk.NewClient(config, credential) return &UAccountClient{ client: client, diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/create_project.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/create_project.go new file mode 100644 index 0000000000..43582ce874 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/create_project.go @@ -0,0 +1,54 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UAccount CreateProject + +package uaccount + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// CreateProjectRequest is request schema for CreateProject action +type CreateProjectRequest struct { + request.CommonBase + + // 项目名称 + ProjectName *string `required:"true"` + + // 项目父节点Id, 不填写创建顶层项目 + ParentId *string `required:"false"` +} + +// CreateProjectResponse is response schema for CreateProject action +type CreateProjectResponse struct { + response.CommonBase + + // 所创建项目的Id + ProjectId string +} + +// NewCreateProjectRequest will create request of CreateProject action. +func (c *UAccountClient) NewCreateProjectRequest() *CreateProjectRequest { + cfg := c.client.GetConfig() + + return &CreateProjectRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// CreateProject - 创建项目 +func (c *UAccountClient) CreateProject(req *CreateProjectRequest) (*CreateProjectResponse, error) { + var err error + var res CreateProjectResponse + + err = c.client.InvokeAction("CreateProject", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/doc.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/doc.go similarity index 100% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/doc.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/doc.go diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/get_project_list.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/get_project_list.go similarity index 64% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/get_project_list.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/get_project_list.go index 5994613cff..ef72b1b8bd 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/get_project_list.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/get_project_list.go @@ -1,20 +1,23 @@ -//go:generate go run ../../private/cli/gen-api/main.go uaccount GetProjectList +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UAccount GetProjectList package uaccount import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" - . "github.com/ucloud/ucloud-sdk-go/service/uaccount/types" ) +// GetProjectListRequest is request schema for GetProjectList action type GetProjectListRequest struct { request.CommonBase - // Optional, 是否是财务账号(Yes: 是, No: 否) - IsFinance string + // 是否是财务账号(Yes: 是, No: 否) + IsFinance *string `required:"false"` } +// GetProjectListResponse is response schema for GetProjectList action type GetProjectListResponse struct { response.CommonBase @@ -31,8 +34,8 @@ func (c *UAccountClient) NewGetProjectListRequest() *GetProjectListRequest { return &GetProjectListRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/get_region.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/get_region.go similarity index 67% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/get_region.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/get_region.go index 9c2f688eb0..f45ae2c291 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/get_region.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/get_region.go @@ -1,17 +1,20 @@ -//go:generate go run ../../private/cli/gen-api/main.go uaccount GetRegion +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UAccount GetRegion package uaccount import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" - . "github.com/ucloud/ucloud-sdk-go/service/uaccount/types" ) +// GetRegionRequest is request schema for GetRegion action type GetRegionRequest struct { request.CommonBase } +// GetRegionResponse is response schema for GetRegion action type GetRegionResponse struct { response.CommonBase @@ -25,8 +28,8 @@ func (c *UAccountClient) NewGetRegionRequest() *GetRegionRequest { return &GetRegionRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/get_user_info.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/get_user_info.go similarity index 66% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/get_user_info.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/get_user_info.go index ee8877bbda..b04c906e12 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/get_user_info.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/get_user_info.go @@ -1,17 +1,20 @@ -//go:generate go run ../../private/cli/gen-api/main.go uaccount GetUserInfo +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UAccount GetUserInfo package uaccount import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" - . "github.com/ucloud/ucloud-sdk-go/service/uaccount/types" ) +// GetUserInfoRequest is request schema for GetUserInfo action type GetUserInfoRequest struct { request.CommonBase } +// GetUserInfoResponse is response schema for GetUserInfo action type GetUserInfoResponse struct { response.CommonBase @@ -25,8 +28,8 @@ func (c *UAccountClient) NewGetUserInfoRequest() *GetUserInfoRequest { return &GetUserInfoRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/modify_project.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/modify_project.go new file mode 100644 index 0000000000..5ac66dc739 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/modify_project.go @@ -0,0 +1,48 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UAccount ModifyProject + +package uaccount + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// ModifyProjectRequest is request schema for ModifyProject action +type ModifyProjectRequest struct { + request.CommonBase + + // 新的项目名称 + ProjectName *string `required:"true"` +} + +// ModifyProjectResponse is response schema for ModifyProject action +type ModifyProjectResponse struct { + response.CommonBase +} + +// NewModifyProjectRequest will create request of ModifyProject action. +func (c *UAccountClient) NewModifyProjectRequest() *ModifyProjectRequest { + cfg := c.client.GetConfig() + + return &ModifyProjectRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// ModifyProject - 修改项目 +func (c *UAccountClient) ModifyProject(req *ModifyProjectRequest) (*ModifyProjectResponse, error) { + var err error + var res ModifyProjectResponse + + err = c.client.InvokeAction("ModifyProject", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/terminate_project.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/terminate_project.go new file mode 100644 index 0000000000..fdbe968203 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/terminate_project.go @@ -0,0 +1,45 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UAccount TerminateProject + +package uaccount + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// TerminateProjectRequest is request schema for TerminateProject action +type TerminateProjectRequest struct { + request.CommonBase +} + +// TerminateProjectResponse is response schema for TerminateProject action +type TerminateProjectResponse struct { + response.CommonBase +} + +// NewTerminateProjectRequest will create request of TerminateProject action. +func (c *UAccountClient) NewTerminateProjectRequest() *TerminateProjectRequest { + cfg := c.client.GetConfig() + + return &TerminateProjectRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// TerminateProject - 删除项目 +func (c *UAccountClient) TerminateProject(req *TerminateProjectRequest) (*TerminateProjectResponse, error) { + var err error + var res TerminateProjectResponse + + err = c.client.InvokeAction("TerminateProject", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/types/project_list_info.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_project_list_info.go similarity index 67% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/types/project_list_info.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_project_list_info.go index ff7b5a4db8..8df6549c11 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/types/project_list_info.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_project_list_info.go @@ -1,6 +1,11 @@ -package types +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. +*/ type ProjectListInfo struct { // 项目ID diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/types/region_info.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_region_info.go similarity index 63% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/types/region_info.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_region_info.go index bdd6987e28..99eb846908 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/types/region_info.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_region_info.go @@ -1,6 +1,11 @@ -package types +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. +*/ type RegionInfo struct { // 数据中心ID diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/types/user_info.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_user_info.go similarity index 79% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/types/user_info.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_user_info.go index ff4416ce2d..7d99026c4c 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/uaccount/types/user_info.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uaccount/types_user_info.go @@ -1,6 +1,11 @@ -package types +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. +*/ type UserInfo struct { // 用户Id diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/client.go similarity index 74% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/client.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/client.go index 34d81e328b..2ea7f4f102 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/client.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/client.go @@ -9,7 +9,7 @@ type UHostClient struct { client *sdk.Client } -func NewClient(config *sdk.ClientConfig, credential *auth.Credential) *UHostClient { +func NewClient(config *sdk.Config, credential *auth.Credential) *UHostClient { client := sdk.NewClient(config, credential) return &UHostClient{ client: client, diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/copy_custom_image.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/copy_custom_image.go new file mode 100644 index 0000000000..2f6abe1f61 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/copy_custom_image.go @@ -0,0 +1,66 @@ +//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 CopyCustomImage + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// CopyCustomImageRequest is request schema for CopyCustomImage action +type CopyCustomImageRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` + + // 源镜像Id, 参见 DescribeImage + SourceImageId *string `required:"true"` + + // 目标项目Id, 参见 GetProjectList + TargetProjectId *string `required:"true"` + + // 目标地域,不跨地域不用填 + TargetRegion *string `required:"false"` + + // 目标镜像名称 + TargetImageName *string `required:"false"` + + // 目标镜像描述 + TargetImageDescription *string `required:"false"` +} + +// CopyCustomImageResponse is response schema for CopyCustomImage action +type CopyCustomImageResponse struct { + response.CommonBase + + // 目标镜像Id + TargetImageId string +} + +// NewCopyCustomImageRequest will create request of CopyCustomImage action. +func (c *UHostClient) NewCopyCustomImageRequest() *CopyCustomImageRequest { + cfg := c.client.GetConfig() + + return &CopyCustomImageRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// CopyCustomImage - 复制自制镜像 +func (c *UHostClient) CopyCustomImage(req *CopyCustomImageRequest) (*CopyCustomImageResponse, error) { + var err error + var res CopyCustomImageResponse + + err = c.client.InvokeAction("CopyCustomImage", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/create_custom_image.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/create_custom_image.go new file mode 100644 index 0000000000..fb01711084 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/create_custom_image.go @@ -0,0 +1,60 @@ +//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 CreateCustomImage + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// CreateCustomImageRequest is request schema for CreateCustomImage action +type CreateCustomImageRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` + + // UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) + UHostId *string `required:"true"` + + // 镜像名称 + ImageName *string `required:"true"` + + // 镜像描述 + ImageDescription *string `required:"false"` +} + +// CreateCustomImageResponse is response schema for CreateCustomImage action +type CreateCustomImageResponse struct { + response.CommonBase + + // 镜像Id + ImageId string +} + +// NewCreateCustomImageRequest will create request of CreateCustomImage action. +func (c *UHostClient) NewCreateCustomImageRequest() *CreateCustomImageRequest { + cfg := c.client.GetConfig() + + return &CreateCustomImageRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// CreateCustomImage - 从指定UHost实例,生成自定义镜像。 +func (c *UHostClient) CreateCustomImage(req *CreateCustomImageRequest) (*CreateCustomImageResponse, error) { + var err error + var res CreateCustomImageResponse + + err = c.client.InvokeAction("CreateCustomImage", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/create_uhost_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/create_uhost_instance.go similarity index 50% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/create_uhost_instance.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/create_uhost_instance.go index 60741d1cf1..11d4cfe386 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/create_uhost_instance.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/create_uhost_instance.go @@ -3,119 +3,123 @@ package uhost import ( "encoding/base64" + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +type UHostDisk struct { + Size *string `required:"true"` + Type *string `required:"true"` + IsBoot *bool `required:"true"` + BackupType *string `required:"false"` +} + +// CreateUHostInstanceRequest is request schema for CreateUHostInstance action type CreateUHostInstanceRequest struct { request.CommonBase - // 地域。 参见 [地域和可用区列表](../summary/regionlist.html) - Region string - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone string - - // 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html) - ProjectId string + Zone *string `required:"true"` // 镜像ID。 请通过 [DescribeImage](describe_image.html)获取 - ImageId string + ImageId *string `required:"true"` // UHost密码,LoginMode为Password时此项必须(密码需使用base64进行编码) - Password string + Password *string `required:"true"` + + // 磁盘大小,单位GB。系统盘的默认大小为镜像大小。数据盘必传。 + Disks []UHostDisk `required:"true"` // UHost实例名称。默认:UHost - Name string + Name *string `required:"false"` // 业务组。默认:Default(Default即为未分组) - Tag string + Tag *string `required:"false"` // 计费模式。枚举值为: Year,按年付费; Month,按月付费; Dynamic,按小时付费(需开启权限)。默认为月付 - ChargeType string + ChargeType *string `required:"false"` // 购买时长。默认: 1。按小时购买(Dynamic)时无需此参数。 月付时,此参数传0,代表了购买至月末。 - Quantity int + Quantity *int `required:"false"` - // 云主机机型。枚举值:N1:系列1标准型;N2:系列2标准型;I1: 系列1高IO型;I2,系列2高IO型; D1: 系列1大数据机型;G1: 系列1GPU型;G2:系列2GPU型;北京A、北京C、上海二A、香港A可用区默认N1,其他机房默认N2。不同机房的主机类型支持情况不同。详情请参考控制台。 - UHostType string + // 云主机机型。枚举值:N1:系列1标准型;N2:系列2标准型;I1: 系列1高IO型;I2,系列2高IO型; D1: 系列1大数据机型;G1: 系列1GPU型,型号为K80;G2:系列2GPU型,型号为P40;G3:系列2GPU型,型号为V100;北京A、北京C、上海二A、香港A可用区默认N1,其他机房默认N2。不同机房的主机类型支持情况不同。详情请参考控制台。 + UHostType *string `required:"false"` // 虚拟CPU核数。 单位:个。可选参数:{1,2,4,8,12,16,24,32}。默认值: 4 - CPU int + CPU *int `required:"false"` // 内存大小。单位:MB。范围 :[1024, 131072], 取值为2的幂次方。默认值:8192。 - Memory int + Memory *int `required:"false"` // GPU卡核心数。仅GPU机型支持此字段;系列1可选1,2;系列2可选1,2,3,4。GPU可选数量与CPU有关联,详情请参考控制台。 - GPU int + GPU *int `required:"false"` // 主机登陆模式。密码(默认选项): Password,key: KeyPair(此项暂不支持) - LoginMode string + LoginMode *string `required:"false"` + + // 【暂不支持】Keypair公钥,LoginMode为KeyPair时此项必须 + KeyPair *string `required:"false"` - // 磁盘类型,同时设定系统盘和数据盘的磁盘类型。枚举值为:LocalDisk,本地磁盘; UDisk,云硬盘;默认为LocalDisk。仅部分可用区支持云硬盘方式的主机存储方式,具体请查询控制台。 - StorageType string + // 【待废弃,不建议调用】磁盘类型,同时设定系统盘和数据盘的磁盘类型。枚举值为:LocalDisk,本地磁盘; UDisk,云硬盘;默认为LocalDisk。仅部分可用区支持云硬盘方式的主机存储方式,具体请查询控制台。 + StorageType *string `required:"false"` - // 系统盘大小。 单位:GB, 范围[20,100], 步长:10 - BootDiskSpace int + // 【待废弃,不建议调用】系统盘大小。 单位:GB, 范围[20,100], 步长:10 + BootDiskSpace *int `required:"false"` - // 数据盘大小。 单位:GB, 范围[0,8000], 步长:10, 默认值:20,云盘支持0-8000;本地普通盘支持0-2000;本地SSD盘(包括所有GPU机型)支持100-1000 - DiskSpace int + // 【待废弃,不建议调用】数据盘大小。 单位:GB, 范围[0,8000], 步长:10, 默认值:20,云盘支持0-8000;本地普通盘支持0-2000;本地SSD盘(包括所有GPU机型)支持100-1000 + DiskSpace *int `required:"false"` // 网络增强。目前仅Normal(不开启) 和Super(开启)可用。默认Normal。 不同机房的网络增强支持情况不同。详情请参考控制台。 - NetCapability string + NetCapability *string `required:"false"` - // 是否开启方舟特性。Yes为开启方舟,No为关闭方舟。Basic为免费基础快照模式(暂不支持)。 - TimemachineFeature string + // 是否开启方舟特性。Yes为开启方舟,No为关闭方舟。目前仅选择普通本地盘+普通本地盘 或 SSD云盘+普通云盘的组合支持开启方舟。 + TimemachineFeature *string `required:"false"` // 是否开启热升级特性。True为开启,False为未开启,默认False。仅系列1云主机需要使用此字段,系列2云主机根据镜像是否支持云主机。 - HotplugFeature bool + HotplugFeature *bool `required:"false"` // 加密盘的密码。若输入此字段,自动选择加密盘。加密盘需要权限位。 - DiskPassword string + DiskPassword *string `required:"false"` // 网络ID(VPC2.0情况下无需填写)。VPC1.0情况下,若不填写,代表选择基础网络; 若填写,代表选择子网。参见DescribeSubnet。 - NetworkId string + NetworkId *string `required:"false"` // VPC ID。VPC2.0下需要填写此字段。 - VPCId string + VPCId *string `required:"false"` // 子网ID。VPC2.0下需要填写此字段。 - SubnetId string + SubnetId *string `required:"false"` // 【数组】创建云主机时指定内网IP。当前只支持一个内网IP。调用方式举例:PrivateIp.0=x.x.x.x。 - PrivateIp []string + PrivateIp []string `required:"false"` + + // 创建云主机时指定Mac。调用方式举例:PrivateMac="xx:xx:xx:xx:xx:xx"。 + PrivateMac *string `required:"false"` // 防火墙Id,默认:Web推荐防火墙。如何查询SecurityGroupId请参见 [DescribeSecurityGroup](../unet-api/describe_security_group.html) - SecurityGroupId string + SecurityGroupId *string `required:"false"` - // 代金券ID。请通过DescribeCoupon接口查询,或登录用户中心查看 - CouponId string -} + // 【暂不支持】cloudinit方式下,用户初始化脚本 + UserDataScript *string `required:"false"` -// NewCreateUHostInstanceRequest will create request of CreateUHostInstance action. -func (c *UHostClient) NewCreateUHostInstanceRequest() *CreateUHostInstanceRequest { - cfg := c.client.GetConfig() + // 【已废弃】宿主机类型,N2,N1 + HostType *string `required:"false"` - return &CreateUHostInstanceRequest{ - CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, - }, - } + // 【暂不支持】是否安装UGA。'yes': 安装;其他或者不填:不安装。 + InstallAgent *string `required:"false"` + + // 【内部参数】资源类型 + ResourceType *int `required:"false"` + + // 代金券ID。请通过DescribeCoupon接口查询,或登录用户中心查看 + CouponId *string `required:"false"` } +// CreateUHostInstanceResponse is response schema for CreateUHostInstance action type CreateUHostInstanceResponse struct { response.CommonBase - // Message, if an error was occupy, return the error message - Message string - - // 操作返回码 - RetCode int - - // 操作名称 - Action string - // UHost实例Id集合 UHostIds []string @@ -123,11 +127,23 @@ type CreateUHostInstanceResponse struct { IPs []string } +// NewCreateUHostInstanceRequest will create request of CreateUHostInstance action. +func (c *UHostClient) NewCreateUHostInstanceRequest() *CreateUHostInstanceRequest { + cfg := c.client.GetConfig() + + return &CreateUHostInstanceRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + // CreateUHostInstance - 指定数据中心,根据资源使用量创建指定数量的UHost实例。 func (c *UHostClient) CreateUHostInstance(req *CreateUHostInstanceRequest) (*CreateUHostInstanceResponse, error) { var err error var res CreateUHostInstanceResponse - req.Password = base64.StdEncoding.EncodeToString([]byte(req.Password)) + req.Password = sdk.String(base64.StdEncoding.EncodeToString([]byte(sdk.StringValue(req.Password)))) err = c.client.InvokeAction("CreateUHostInstance", req, &res) if err != nil { diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_image.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_image.go new file mode 100644 index 0000000000..478b5bed67 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_image.go @@ -0,0 +1,72 @@ +//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 DescribeImage + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// DescribeImageRequest is request schema for DescribeImage action +type DescribeImageRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` + + // 镜像类型。标准镜像:Base,镜像市场:Business, 自定义镜像:Custom,默认返回所有类型 + ImageType *string `required:"false"` + + // 操作系统类型:Linux, Windows 默认返回所有类型 + OsType *string `required:"false"` + + // 镜像Id + ImageId *string `required:"false"` + + // 列表起始位置偏移量,默认为0 + Offset *int `required:"false"` + + // 返回数据长度,默认为20 + Limit *int `required:"false"` + + // 是否返回价格:1返回,0不返回;默认不返回 + PriceSet *int `required:"false"` +} + +// DescribeImageResponse is response schema for DescribeImage action +type DescribeImageResponse struct { + response.CommonBase + + // 满足条件的镜像总数 + TotalCount int + + // 镜像列表详见 UHostImageSet + ImageSet []UHostImageSet +} + +// NewDescribeImageRequest will create request of DescribeImage action. +func (c *UHostClient) NewDescribeImageRequest() *DescribeImageRequest { + cfg := c.client.GetConfig() + + return &DescribeImageRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// DescribeImage - 获取指定数据中心镜像列表,用户可通过指定操作系统类型,镜像Id进行过滤。 +func (c *UHostClient) DescribeImage(req *DescribeImageRequest) (*DescribeImageResponse, error) { + var err error + var res DescribeImageResponse + + err = c.client.InvokeAction("DescribeImage", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_uhost_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_uhost_instance.go new file mode 100644 index 0000000000..4bf6ba20a3 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_uhost_instance.go @@ -0,0 +1,69 @@ +//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 DescribeUHostInstance + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// DescribeUHostInstanceRequest is request schema for DescribeUHostInstance action +type DescribeUHostInstanceRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` + + // 【数组】UHost主机的资源ID,例如UHostIds.0代表希望获取信息 的主机1,UHostIds.1代表主机2。 如果不传入,则返回当前Region 所有符合条件的UHost实例。 + UHostIds []string `required:"false"` + + // 要查询的业务组名称 + Tag *string `required:"false"` + + // 1:普通云主机;2:抢占型云主机;如不传此参数,默认全部获取 + LifeCycle *int `required:"false"` + + // 列表起始位置偏移量,默认为0 + Offset *int `required:"false"` + + // 返回数据长度,默认为20,最大100 + Limit *int `required:"false"` +} + +// DescribeUHostInstanceResponse is response schema for DescribeUHostInstance action +type DescribeUHostInstanceResponse struct { + response.CommonBase + + // UHostInstance总数 + TotalCount int + + // 云主机实例列表,每项参数可见下面 UHostInstanceSet + UHostSet []UHostInstanceSet +} + +// NewDescribeUHostInstanceRequest will create request of DescribeUHostInstance action. +func (c *UHostClient) NewDescribeUHostInstanceRequest() *DescribeUHostInstanceRequest { + cfg := c.client.GetConfig() + + return &DescribeUHostInstanceRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// DescribeUHostInstance - 获取主机或主机列表信息,并可根据数据中心,主机ID等参数进行过滤。 +func (c *UHostClient) DescribeUHostInstance(req *DescribeUHostInstanceRequest) (*DescribeUHostInstanceResponse, error) { + var err error + var res DescribeUHostInstanceResponse + + err = c.client.InvokeAction("DescribeUHostInstance", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_uhost_tags.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_uhost_tags.go new file mode 100644 index 0000000000..07114dca6b --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_uhost_tags.go @@ -0,0 +1,54 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UHost DescribeUHostTags + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// DescribeUHostTagsRequest is request schema for DescribeUHostTags action +type DescribeUHostTagsRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` +} + +// DescribeUHostTagsResponse is response schema for DescribeUHostTags action +type DescribeUHostTagsResponse struct { + response.CommonBase + + // 已有主机的业务组总个数 + TotalCount int + + // 业务组集合见 UHostTagSet + TagSet []UHostTagSet +} + +// NewDescribeUHostTagsRequest will create request of DescribeUHostTags action. +func (c *UHostClient) NewDescribeUHostTagsRequest() *DescribeUHostTagsRequest { + cfg := c.client.GetConfig() + + return &DescribeUHostTagsRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// DescribeUHostTags - 获取指定数据中心的业务组列表。 +func (c *UHostClient) DescribeUHostTags(req *DescribeUHostTagsRequest) (*DescribeUHostTagsResponse, error) { + var err error + var res DescribeUHostTagsResponse + + err = c.client.InvokeAction("DescribeUHostTags", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/doc.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/doc.go similarity index 100% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/doc.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/doc.go diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/enums.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/enums.go similarity index 70% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/enums.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/enums.go index 7cebbd2018..7b7614f34f 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/enums.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/enums.go @@ -1,7 +1,7 @@ package uhost // State is the state of UHost instance -type State = string +type State string // Enum values for State const ( @@ -13,3 +13,8 @@ const ( StateInstallFail State = "InstallFail" StateRebooting State = "Rebooting" ) + +// MarshalValue will marshal state value to string +func (enum State) MarshalValue() (string, error) { + return string(enum), nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_instance_price.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_instance_price.go new file mode 100644 index 0000000000..98134a073b --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_instance_price.go @@ -0,0 +1,93 @@ +//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 GetUHostInstancePrice + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// GetUHostInstancePriceRequest is request schema for GetUHostInstancePrice action +type GetUHostInstancePriceRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` + + // 镜像Id,可通过 [DescribeImage](describe_image.html) 获取镜像ID + ImageId *string `required:"true"` + + // 虚拟CPU核心数,单位: 个,范围: [1,16],最小值为1,其他值是2的整数倍 + CPU *int `required:"true"` + + // 内存容量大小,单位: MB,范围: [2048,65536],步长: 2048 不同机房的网络增强支持情况不同。详情请参考控制台。 + Memory *int `required:"true"` + + // 购买台数,范围[1,5] + Count *int `required:"true"` + + // 磁盘 + Disks []UHostDisk + + // GPU核心数,单位:个,范围[0,4] + GPU *int `required:"false"` + + // 计费类型。Year,Month,Dynamic,默认返回全部计费方式对应的价格 + ChargeType *string `required:"false"` + + // 磁盘类型,同时设定系统盘和数据盘, 枚举值为:LocalDisk,本地磁盘; UDisk,云硬盘; 默认为LocalDisk 仅部分可用区支持云硬盘方式的主机存储方式,具体请查询控制台。 + StorageType *string `required:"false"` + + // 数据盘大小,单位: GB,范围[0,1000],步长: 10,默认值: 0 + DiskSpace *int `required:"false"` + + // 网络增强 默认是Normal, 目前仅支持Normal(不开启) 和 Super(开启网络增强)。 不同机房的网络增强支持情况不同。详情请参考控制台。 + NetCapability *string `required:"false"` + + // 方舟机型。No,Yes。默认是No。 + TimemachineFeature *string `required:"false"` + + // 主机类型 Normal: 标准机型 SSD:SSD机型 BigData:大数据 GPU:GPU型G1(原GPU型) GPU_G2:GPU型G2 GPU_G3:GPU型G3 不同机房的主机类型支持情况不同。详情请参考控制台。 + UHostType *string `required:"false"` + + // 1:普通云主机;2:抢占性云主机;默认普通 + LifeCycle *int `required:"false"` + + // 购买时长。默认: 1。按小时购买(Dynamic)时无需此参数。 月付时,此参数传0,代表了购买至月末。 + Quantity *int `required:"false"` +} + +// GetUHostInstancePriceResponse is response schema for GetUHostInstancePrice action +type GetUHostInstancePriceResponse struct { + response.CommonBase + + // 价格列表 UHostPriceSet + PriceSet []UHostPriceSet +} + +// NewGetUHostInstancePriceRequest will create request of GetUHostInstancePrice action. +func (c *UHostClient) NewGetUHostInstancePriceRequest() *GetUHostInstancePriceRequest { + cfg := c.client.GetConfig() + + return &GetUHostInstancePriceRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// GetUHostInstancePrice - 根据UHost实例配置,获取UHost实例的价格。 +func (c *UHostClient) GetUHostInstancePrice(req *GetUHostInstancePriceRequest) (*GetUHostInstancePriceResponse, error) { + var err error + var res GetUHostInstancePriceResponse + + err = c.client.InvokeAction("GetUHostInstancePrice", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_instance_vnc_info.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_instance_vnc_info.go new file mode 100644 index 0000000000..268e50c316 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_instance_vnc_info.go @@ -0,0 +1,63 @@ +//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 GetUHostInstanceVncInfo + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// GetUHostInstanceVncInfoRequest is request schema for GetUHostInstanceVncInfo action +type GetUHostInstanceVncInfoRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` + + // UHost实例ID 参见 [DescribeUHostInstance](./describe_uhost_instance.html) + UHostId *string `required:"true"` +} + +// GetUHostInstanceVncInfoResponse is response schema for GetUHostInstanceVncInfo action +type GetUHostInstanceVncInfoResponse struct { + response.CommonBase + + // UHost实例ID + UhostId string + + // Vnc登录IP + VncIP string + + // Vnc登录端口 + VncPort int + + // Vnc 登录密码 + VncPassword string +} + +// NewGetUHostInstanceVncInfoRequest will create request of GetUHostInstanceVncInfo action. +func (c *UHostClient) NewGetUHostInstanceVncInfoRequest() *GetUHostInstanceVncInfoRequest { + cfg := c.client.GetConfig() + + return &GetUHostInstanceVncInfoRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// GetUHostInstanceVncInfo - 获取指定UHost实例的管理VNC配置详细信息。 +func (c *UHostClient) GetUHostInstanceVncInfo(req *GetUHostInstanceVncInfoRequest) (*GetUHostInstanceVncInfoResponse, error) { + var err error + var res GetUHostInstanceVncInfoResponse + + err = c.client.InvokeAction("GetUHostInstanceVncInfo", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_upgrade_price.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_upgrade_price.go new file mode 100644 index 0000000000..86fdb94bed --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/get_uhost_upgrade_price.go @@ -0,0 +1,75 @@ +//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 GetUHostUpgradePrice + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// GetUHostUpgradePriceRequest is request schema for GetUHostUpgradePrice action +type GetUHostUpgradePriceRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` + + // UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) + UHostId *string `required:"true"` + + // 虚拟CPU核心数,单位: 个,范围: [1,16],最小值为1,其他值是2的整数倍 默认值是该主机当前CPU数。 + CPU *int `required:"false"` + + // 内存容量大小,单位: MB,范围: [2048,65536],步长: 2048 北京BGP C机房最小支持1024(限Linux系统)。 默认值是该主机当前内存大小。 + Memory *int `required:"false"` + + // 数据盘大小,单位: GB,范围[0,1000],步长: 10, 默认值是该主机当前数据盘大小。 + DiskSpace *int `required:"false"` + + // 系统大小,单位: GB,范围[20,100],步长: 10。 + BootDiskSpace *int `required:"false"` + + // 方舟机型。No,Yes。默认是No。 + TimemachineFeature *string `required:"false"` + + // 网卡升降级(1,表示升级,2表示降级,0表示不变) + NetCapValue *int `required:"false"` + + // 主机系列,目前支持N1,N2 + HostType *string `required:"false"` +} + +// GetUHostUpgradePriceResponse is response schema for GetUHostUpgradePrice action +type GetUHostUpgradePriceResponse struct { + response.CommonBase + + // 升级差价 + Price float32 +} + +// NewGetUHostUpgradePriceRequest will create request of GetUHostUpgradePrice action. +func (c *UHostClient) NewGetUHostUpgradePriceRequest() *GetUHostUpgradePriceRequest { + cfg := c.client.GetConfig() + + return &GetUHostUpgradePriceRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// GetUHostUpgradePrice - 获取UHost实例升级配置的价格。 +func (c *UHostClient) GetUHostUpgradePrice(req *GetUHostUpgradePriceRequest) (*GetUHostUpgradePriceResponse, error) { + var err error + var res GetUHostUpgradePriceResponse + + err = c.client.InvokeAction("GetUHostUpgradePrice", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} 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..71f16f8742 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/import_custom_image.go @@ -0,0 +1,69 @@ +//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/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/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 { + cfg := c.client.GetConfig() + + return &ImportCustomImageRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// 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 nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_name.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_name.go new file mode 100644 index 0000000000..00758003ae --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_name.go @@ -0,0 +1,57 @@ +//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 ModifyUHostInstanceName + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// ModifyUHostInstanceNameRequest is request schema for ModifyUHostInstanceName action +type ModifyUHostInstanceNameRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` + + // UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) + UHostId *string `required:"true"` + + // UHost实例名称 + Name *string `required:"false"` +} + +// ModifyUHostInstanceNameResponse is response schema for ModifyUHostInstanceName action +type ModifyUHostInstanceNameResponse struct { + response.CommonBase + + // UHost实例ID + UhostId string +} + +// NewModifyUHostInstanceNameRequest will create request of ModifyUHostInstanceName action. +func (c *UHostClient) NewModifyUHostInstanceNameRequest() *ModifyUHostInstanceNameRequest { + cfg := c.client.GetConfig() + + return &ModifyUHostInstanceNameRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// ModifyUHostInstanceName - 修改指定UHost实例名称,需要给出数据中心,UHostId,及新的实例名称。 +func (c *UHostClient) ModifyUHostInstanceName(req *ModifyUHostInstanceNameRequest) (*ModifyUHostInstanceNameResponse, error) { + var err error + var res ModifyUHostInstanceNameResponse + + err = c.client.InvokeAction("ModifyUHostInstanceName", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_remark.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_remark.go new file mode 100644 index 0000000000..eeeb7e2540 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_remark.go @@ -0,0 +1,57 @@ +//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 ModifyUHostInstanceRemark + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// ModifyUHostInstanceRemarkRequest is request schema for ModifyUHostInstanceRemark action +type ModifyUHostInstanceRemarkRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` + + // UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) + UHostId *string `required:"true"` + + // 备注 + Remark *string `required:"false"` +} + +// ModifyUHostInstanceRemarkResponse is response schema for ModifyUHostInstanceRemark action +type ModifyUHostInstanceRemarkResponse struct { + response.CommonBase + + // UHost实例ID + UhostId string +} + +// NewModifyUHostInstanceRemarkRequest will create request of ModifyUHostInstanceRemark action. +func (c *UHostClient) NewModifyUHostInstanceRemarkRequest() *ModifyUHostInstanceRemarkRequest { + cfg := c.client.GetConfig() + + return &ModifyUHostInstanceRemarkRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// ModifyUHostInstanceRemark - 修改指定UHost实例备注信息。 +func (c *UHostClient) ModifyUHostInstanceRemark(req *ModifyUHostInstanceRemarkRequest) (*ModifyUHostInstanceRemarkResponse, error) { + var err error + var res ModifyUHostInstanceRemarkResponse + + err = c.client.InvokeAction("ModifyUHostInstanceRemark", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_tag.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_tag.go new file mode 100644 index 0000000000..b00aba7880 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/modify_uhost_instance_tag.go @@ -0,0 +1,57 @@ +//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 ModifyUHostInstanceTag + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// ModifyUHostInstanceTagRequest is request schema for ModifyUHostInstanceTag action +type ModifyUHostInstanceTagRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` + + // UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) + UHostId *string `required:"true"` + + // 业务组名称 + Tag *string `required:"false"` +} + +// ModifyUHostInstanceTagResponse is response schema for ModifyUHostInstanceTag action +type ModifyUHostInstanceTagResponse struct { + response.CommonBase + + // UHost实例ID + UhostId string +} + +// NewModifyUHostInstanceTagRequest will create request of ModifyUHostInstanceTag action. +func (c *UHostClient) NewModifyUHostInstanceTagRequest() *ModifyUHostInstanceTagRequest { + cfg := c.client.GetConfig() + + return &ModifyUHostInstanceTagRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// ModifyUHostInstanceTag - 修改指定UHost实例业务组标识。 +func (c *UHostClient) ModifyUHostInstanceTag(req *ModifyUHostInstanceTagRequest) (*ModifyUHostInstanceTagResponse, error) { + var err error + var res ModifyUHostInstanceTagResponse + + err = c.client.InvokeAction("ModifyUHostInstanceTag", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/poweroff_uhost_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/poweroff_uhost_instance.go new file mode 100644 index 0000000000..f784bd848b --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/poweroff_uhost_instance.go @@ -0,0 +1,54 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UHost PoweroffUHostInstance + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// PoweroffUHostInstanceRequest is request schema for PoweroffUHostInstance action +type PoweroffUHostInstanceRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` + + // UHost实例ID 参见 [DescribeUHostInstance](./describe_uhost_instance.html) + UHostId *string `required:"true"` +} + +// PoweroffUHostInstanceResponse is response schema for PoweroffUHostInstance action +type PoweroffUHostInstanceResponse struct { + response.CommonBase + + // UHost实例ID + UhostId string +} + +// NewPoweroffUHostInstanceRequest will create request of PoweroffUHostInstance action. +func (c *UHostClient) NewPoweroffUHostInstanceRequest() *PoweroffUHostInstanceRequest { + cfg := c.client.GetConfig() + + return &PoweroffUHostInstanceRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// PoweroffUHostInstance - 直接关闭UHost实例电源,无需等待实例正常关闭。 +func (c *UHostClient) PoweroffUHostInstance(req *PoweroffUHostInstanceRequest) (*PoweroffUHostInstanceResponse, error) { + var err error + var res PoweroffUHostInstanceResponse + + err = c.client.InvokeAction("PoweroffUHostInstance", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/reboot_uhost_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/reboot_uhost_instance.go new file mode 100644 index 0000000000..7e8b6a7b13 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/reboot_uhost_instance.go @@ -0,0 +1,57 @@ +//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 RebootUHostInstance + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// RebootUHostInstanceRequest is request schema for RebootUHostInstance action +type RebootUHostInstanceRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` + + // UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) + UHostId *string `required:"true"` + + // 加密盘密码 + DiskPassword *string `required:"false"` +} + +// RebootUHostInstanceResponse is response schema for RebootUHostInstance action +type RebootUHostInstanceResponse struct { + response.CommonBase + + // UHost实例ID + UhostId string +} + +// NewRebootUHostInstanceRequest will create request of RebootUHostInstance action. +func (c *UHostClient) NewRebootUHostInstanceRequest() *RebootUHostInstanceRequest { + cfg := c.client.GetConfig() + + return &RebootUHostInstanceRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// RebootUHostInstance - 重新启动UHost实例,需要指定数据中心及UHostID两个参数的值。 +func (c *UHostClient) RebootUHostInstance(req *RebootUHostInstanceRequest) (*RebootUHostInstanceResponse, error) { + var err error + var res RebootUHostInstanceResponse + + err = c.client.InvokeAction("RebootUHostInstance", req, &res) + if err != nil { + return nil, 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 new file mode 100644 index 0000000000..822428d7c4 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/reinstall_uhost_instance.go @@ -0,0 +1,69 @@ +//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 ReinstallUHostInstance + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// ReinstallUHostInstanceRequest is request schema for ReinstallUHostInstance action +type ReinstallUHostInstanceRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` + + // UHost实例资源ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) + UHostId *string `required:"true"` + + // 如果创建UHost实例时LoginMode为Password,则必须填写,如果LoginMode为KeyPair,不需要填写 (密码格式使用BASE64编码;LoginMode不可变更) + Password *string `required:"false"` + + // 镜像Id,默认使用原镜像 参见 [DescribeImage](describe_image.html) + ImageId *string `required:"false"` + + // 是否保留数据盘,保留:Yes,不报留:No, 默认:Yes;如果是从Windows重装为Linux或反之,则无法保留数据盘 + ReserveDisk *string `required:"false"` + + // 云灾备指明191 + ResourceType *int `required:"false"` + + // 针对非私有子网主机,可自定义DNS。n可为0-2 + DNSServers []string `required:"false"` +} + +// ReinstallUHostInstanceResponse is response schema for ReinstallUHostInstance action +type ReinstallUHostInstanceResponse struct { + response.CommonBase + + // UHost实例资源ID + UhostId string +} + +// NewReinstallUHostInstanceRequest will create request of ReinstallUHostInstance action. +func (c *UHostClient) NewReinstallUHostInstanceRequest() *ReinstallUHostInstanceRequest { + cfg := c.client.GetConfig() + + return &ReinstallUHostInstanceRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// ReinstallUHostInstance - 重新安装指定UHost实例的操作系统 +func (c *UHostClient) ReinstallUHostInstance(req *ReinstallUHostInstanceRequest) (*ReinstallUHostInstanceResponse, error) { + var err error + var res ReinstallUHostInstanceResponse + + err = c.client.InvokeAction("ReinstallUHostInstance", req, &res) + if err != nil { + return nil, err + } + + return &res, 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 new file mode 100644 index 0000000000..d99046608a --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/reset_uhost_instance_password.go @@ -0,0 +1,57 @@ +//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 ResetUHostInstancePassword + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// ResetUHostInstancePasswordRequest is request schema for ResetUHostInstancePassword action +type ResetUHostInstancePasswordRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` + + // UHost实例ID + UHostId *string `required:"true"` + + // UHost新密码(密码格式使用BASE64编码) + Password *string `required:"true"` +} + +// ResetUHostInstancePasswordResponse is response schema for ResetUHostInstancePassword action +type ResetUHostInstancePasswordResponse struct { + response.CommonBase + + // UHost实例ID + UhostId string +} + +// NewResetUHostInstancePasswordRequest will create request of ResetUHostInstancePassword action. +func (c *UHostClient) NewResetUHostInstancePasswordRequest() *ResetUHostInstancePasswordRequest { + cfg := c.client.GetConfig() + + return &ResetUHostInstancePasswordRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// ResetUHostInstancePassword - 重置UHost实例的管理员密码。 +func (c *UHostClient) ResetUHostInstancePassword(req *ResetUHostInstancePasswordRequest) (*ResetUHostInstancePasswordResponse, error) { + var err error + var res ResetUHostInstancePasswordResponse + + err = c.client.InvokeAction("ResetUHostInstancePassword", req, &res) + if err != nil { + return nil, err + } + + return &res, 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 new file mode 100644 index 0000000000..466cdd6a46 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/resize_uhost_instance.go @@ -0,0 +1,69 @@ +//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 ResizeUHostInstance + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// ResizeUHostInstanceRequest is request schema for ResizeUHostInstance action +type ResizeUHostInstanceRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` + + // UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) + UHostId *string `required:"true"` + + // 虚拟CPU核数,单位:个,系列1范围:[1,16],系列2范围:[1,32],最小值为1,其他值是2的倍数,默认值为当前实例的CPU核数 + CPU *int `required:"false"` + + // 内存大小,单位:MB,范围[2048,131072],步长:2048,默认值为当前实例的内存大小(BGP-C数据中心最小支持1024,限Linux系统) + Memory *int `required:"false"` + + // 数据盘大小,单位:GB,范围[10,1000]; SSD机型,单位:GB,范围[100,500];步长:10,默认值为当前实例的数据盘大小,数据盘不支持缩容,因此不允许输入比当前实例数据盘大小的值 + DiskSpace *int `required:"false"` + + // 系统盘大小,单位:GB,范围[20,100],步长:10,系统盘不支持缩容,因此不允许输入比当前实例系统盘小的值 + BootDiskSpace *int `required:"false"` + + // 网卡升降级(1,表示升级,2表示降级,0表示不变) + NetCapValue *int `required:"false"` +} + +// ResizeUHostInstanceResponse is response schema for ResizeUHostInstance action +type ResizeUHostInstanceResponse struct { + response.CommonBase + + // UHost实例ID + UhostId string +} + +// NewResizeUHostInstanceRequest will create request of ResizeUHostInstance action. +func (c *UHostClient) NewResizeUHostInstanceRequest() *ResizeUHostInstanceRequest { + cfg := c.client.GetConfig() + + return &ResizeUHostInstanceRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// ResizeUHostInstance - 修改指定UHost实例的资源配置,如CPU核心数,内存容量大小,磁盘空间大小,网络增强等。 +func (c *UHostClient) ResizeUHostInstance(req *ResizeUHostInstanceRequest) (*ResizeUHostInstanceResponse, error) { + var err error + var res ResizeUHostInstanceResponse + + err = c.client.InvokeAction("ResizeUHostInstance", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} 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 new file mode 100644 index 0000000000..393cb1d028 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/start_uhost_instance.go @@ -0,0 +1,57 @@ +//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 StartUHostInstance + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// StartUHostInstanceRequest is request schema for StartUHostInstance action +type StartUHostInstanceRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` + + // UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) + UHostId *string `required:"true"` + + // 加密盘密码 + DiskPassword *string `required:"false"` +} + +// StartUHostInstanceResponse is response schema for StartUHostInstance action +type StartUHostInstanceResponse struct { + response.CommonBase + + // UHost实例ID + UhostId string +} + +// NewStartUHostInstanceRequest will create request of StartUHostInstance action. +func (c *UHostClient) NewStartUHostInstanceRequest() *StartUHostInstanceRequest { + cfg := c.client.GetConfig() + + return &StartUHostInstanceRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// StartUHostInstance - 启动处于关闭状态的UHost实例,需要指定数据中心及UHostID两个参数的值。 +func (c *UHostClient) StartUHostInstance(req *StartUHostInstanceRequest) (*StartUHostInstanceResponse, error) { + var err error + var res StartUHostInstanceResponse + + err = c.client.InvokeAction("StartUHostInstance", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/stop_uhost_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/stop_uhost_instance.go similarity index 59% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/stop_uhost_instance.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/stop_uhost_instance.go index eecfc73dbe..5dd009179d 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/stop_uhost_instance.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/stop_uhost_instance.go @@ -1,22 +1,26 @@ -//go:generate go run ../../private/cli/gen-api/main.go uhost StopUHostInstance +//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 StopUHostInstance package uhost import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +// StopUHostInstanceRequest is request schema for StopUHostInstance action type StopUHostInstanceRequest struct { request.CommonBase - // Optional, 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone string + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` - // Required, UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) - UHostId string + // UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html) + UHostId *string `required:"true"` } +// StopUHostInstanceResponse is response schema for StopUHostInstance action type StopUHostInstanceResponse struct { response.CommonBase @@ -30,8 +34,8 @@ func (c *UHostClient) NewStopUHostInstanceRequest() *StopUHostInstanceRequest { return &StopUHostInstanceRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/terminate_custom_image.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/terminate_custom_image.go new file mode 100644 index 0000000000..8b613d0e57 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/terminate_custom_image.go @@ -0,0 +1,54 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UHost TerminateCustomImage + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// TerminateCustomImageRequest is request schema for TerminateCustomImage action +type TerminateCustomImageRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` + + // 自制镜像ID 参见 [DescribeImage](describe_image.html) + ImageId *string `required:"true"` +} + +// TerminateCustomImageResponse is response schema for TerminateCustomImage action +type TerminateCustomImageResponse struct { + response.CommonBase + + // 自制镜像Id + ImageId string +} + +// NewTerminateCustomImageRequest will create request of TerminateCustomImage action. +func (c *UHostClient) NewTerminateCustomImageRequest() *TerminateCustomImageRequest { + cfg := c.client.GetConfig() + + return &TerminateCustomImageRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// TerminateCustomImage - 删除用户自定义镜像 +func (c *UHostClient) TerminateCustomImage(req *TerminateCustomImageRequest) (*TerminateCustomImageResponse, error) { + var err error + var res TerminateCustomImageResponse + + err = c.client.InvokeAction("TerminateCustomImage", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/terminate_uhost_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/terminate_uhost_instance.go similarity index 51% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/terminate_uhost_instance.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/terminate_uhost_instance.go index 473820cb95..3dac44bf4e 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/terminate_uhost_instance.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/terminate_uhost_instance.go @@ -1,25 +1,32 @@ -//go:generate go run ../../private/cli/gen-api/main.go uhost TerminateUHostInstance +//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 TerminateUHostInstance package uhost import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +// TerminateUHostInstanceRequest is request schema for TerminateUHostInstance action type TerminateUHostInstanceRequest struct { request.CommonBase - // Optional, 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone string + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` - // Required, UHost资源Id 参见 [DescribeUHostInstance](describe_uhost_instance.html) - UHostId string + // UHost资源Id 参见 [DescribeUHostInstance](describe_uhost_instance.html) + UHostId *string `required:"true"` + + // 是否直接删除,0表示按照原来的逻辑(有回收站权限,则进入回收站),1表示直接删除 + Destroy *int `required:"false"` - // Optional, 是否直接删除,0表示按照原来的逻辑(有回收站权限,则进入回收站),1表示直接删除 - Destroy int + // 是否释放绑定的EIP。yes: 解绑EIP后,并释放;其他值或不填:解绑EIP。 + EIPReleased *string `required:"false"` } +// TerminateUHostInstanceResponse is response schema for TerminateUHostInstance action type TerminateUHostInstanceResponse struct { response.CommonBase @@ -28,6 +35,9 @@ type TerminateUHostInstanceResponse struct { // 放入回收站:"Yes", 彻底删除:“No” InRecycle string + + // 主机 ID + UHostId string } // NewTerminateUHostInstanceRequest will create request of TerminateUHostInstance action. @@ -36,8 +46,8 @@ func (c *UHostClient) NewTerminateUHostInstanceRequest() *TerminateUHostInstance return &TerminateUHostInstanceRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/types/uhost_disk_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_disk_set.go similarity index 62% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/types/uhost_disk_set.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_disk_set.go index ba55a67e00..063071611a 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/types/uhost_disk_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_disk_set.go @@ -1,6 +1,11 @@ -package types +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. +*/ type UHostDiskSet struct { // 磁盘类型。系统盘: Boot,数据盘: Data,网络盘:Udisk @@ -10,7 +15,7 @@ type UHostDiskSet struct { DiskId string // UDisk名字(仅当磁盘是UDisk时返回) - Name int + Name string // 磁盘盘符 Drive string @@ -29,4 +34,10 @@ type UHostDiskSet struct { // Yes: 加密 No: 非加密 Encrypted string + + // LOCAL_NOMAL| CLOUD_NORMAL| LOCAL_SSD| CLOUD_SSD|EXCLUSIVE_LOCAL_DISK + DiskType string + + // True| False + IsBoot string } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/types/uhost_image_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_image_set.go similarity index 85% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/types/uhost_image_set.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_image_set.go index 3eb4b74598..330ad37752 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/types/uhost_image_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_image_set.go @@ -1,6 +1,11 @@ -package types +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. +*/ type UHostImageSet struct { // 镜像ID diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/types/uhost_instance_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_instance_set.go similarity index 85% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/types/uhost_instance_set.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_instance_set.go index 65dd1eb288..52aec6c129 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/types/uhost_instance_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_instance_set.go @@ -1,17 +1,22 @@ -package types +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. +*/ type UHostInstanceSet struct { + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone string + // UHost实例ID UHostId string - // UHost类型,枚举为:N1:标准型系列1;N2:标准型系列2 ;I1:高IO型系列1;I2:高IO型系列2;D1:大数据型系列1;G1:GPU型系列1;G2:GPU型系列2 + // UHost类型,枚举为:N1:标准型系列1;N2:标准型系列2 ;I1:高IO型系列1;I2:高IO型系列2;D1:大数据型系列1;G1:GPU型系列1;G2:GPU型系列2;G3:GPU型系列2 UHostType string - // 可用区。参见 [可用区列表](../summary/regionlist.html) - Zone string - // 系统盘与数据盘的磁盘类型。 枚举值为:LocalDisk,本地磁盘; UDisk,云硬盘 StorageType string @@ -92,4 +97,10 @@ type UHostInstanceSet struct { // 主机的生命周期类型。目前仅支持Normal:普通; LifeCycle string + + // 主机的 GPU 数量 + GPU int + + // 系统盘状态 Normal: 已初始化完成 + BootDiskState string } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/types/uhost_ipset.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_ipset.go similarity index 58% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/types/uhost_ipset.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_ipset.go index 92bb5db4ff..18d877f171 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/types/uhost_ipset.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_ipset.go @@ -1,9 +1,14 @@ -package types +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. +*/ type UHostIPSet struct { - // 电信: China-telecom,联通: China-unicom, 国际: Internation,BGP: Bgp,内网: Private 双线: Duplet + // 国际: Internation,BGP: Bgp,内网: Private Type string // IP资源ID (内网IP无对应的资源ID) 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 new file mode 100644 index 0000000000..40fa923f3f --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_price_set.go @@ -0,0 +1,10 @@ +package uhost + +// UHostPriceSet is a set to describe the price of uhost +type UHostPriceSet struct { + // 付费方式, 预付费:Year 按年,Month 按月,Dynamic 按需;后付费:Postpay(按月) + ChargeType string + + // 费用(元) + Price int +} 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 new file mode 100644 index 0000000000..7eceabcb3b --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_uhost_tag_set.go @@ -0,0 +1,19 @@ +package uhost + +/* + UHostTagSet - DescribeUHostTags + + 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 { + + // 业务组名称 + Tag string + + // 该业务组中包含的主机个数 + TotalCount int + + // 可用区 + Zone string +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/upgrade_to_ark_uhost_instance.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/upgrade_to_ark_uhost_instance.go new file mode 100644 index 0000000000..21f87c2be7 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/upgrade_to_ark_uhost_instance.go @@ -0,0 +1,57 @@ +//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 UpgradeToArkUHostInstance + +package uhost + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// UpgradeToArkUHostInstanceRequest is request schema for UpgradeToArkUHostInstance action +type UpgradeToArkUHostInstanceRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"true"` + + // UHost主机的资源ID,例如UHostIds.0代表希望升级的主机1,UHostIds.1代表主机2。 + UHostIds []string `required:"true"` + + // 代金券ID 请参考DescribeCoupon接口 + CouponId *string `required:"false"` +} + +// UpgradeToArkUHostInstanceResponse is response schema for UpgradeToArkUHostInstance action +type UpgradeToArkUHostInstanceResponse struct { + response.CommonBase + + // UHost主机的资源ID数组 + UHostSet []string +} + +// NewUpgradeToArkUHostInstanceRequest will create request of UpgradeToArkUHostInstance action. +func (c *UHostClient) NewUpgradeToArkUHostInstanceRequest() *UpgradeToArkUHostInstanceRequest { + cfg := c.client.GetConfig() + + return &UpgradeToArkUHostInstanceRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// UpgradeToArkUHostInstance - 普通升级为方舟机型 +func (c *UHostClient) UpgradeToArkUHostInstance(req *UpgradeToArkUHostInstanceRequest) (*UpgradeToArkUHostInstanceResponse, error) { + var err error + var res UpgradeToArkUHostInstanceResponse + + err = c.client.InvokeAction("UpgradeToArkUHostInstance", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/wait_until_uhost_instance_state.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/wait_until_uhost_instance_state.go similarity index 68% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/wait_until_uhost_instance_state.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/wait_until_uhost_instance_state.go index 0610c03235..23e48e0c29 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/uhost/wait_until_uhost_instance_state.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/wait_until_uhost_instance_state.go @@ -3,6 +3,7 @@ package uhost import ( "time" + "github.com/ucloud/ucloud-sdk-go/sdk" uerr "github.com/ucloud/ucloud-sdk-go/sdk/error" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/utils" @@ -11,11 +12,11 @@ import ( type WaitUntilUHostInstanceStateRequest struct { request.CommonBase - Interval time.Duration - MaxAttempts int + Interval *time.Duration + MaxAttempts *int DescribeRequest *DescribeUHostInstanceRequest - State string - IgnoreError bool + State State + IgnoreError *bool } // NewWaitUntilUHostInstanceStateRequest will create request of WaitUntilUHostInstanceState action. @@ -24,8 +25,8 @@ func (c *UHostClient) NewWaitUntilUHostInstanceStateRequest() *WaitUntilUHostIns return &WaitUntilUHostInstanceStateRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } @@ -33,24 +34,24 @@ func (c *UHostClient) NewWaitUntilUHostInstanceStateRequest() *WaitUntilUHostIns // WaitUntilUHostInstanceState will pending current goroutine until the state has changed to expected state. func (c *UHostClient) WaitUntilUHostInstanceState(req *WaitUntilUHostInstanceStateRequest) error { waiter := utils.FuncWaiter{ - Interval: req.Interval, - MaxAttempts: req.MaxAttempts, - IgnoreError: req.IgnoreError, + Interval: sdk.TimeDurationValue(req.Interval), + MaxAttempts: sdk.IntValue(req.MaxAttempts), + IgnoreError: sdk.BoolValue(req.IgnoreError), Checker: func() (bool, error) { resp, err := c.DescribeUHostInstance(req.DescribeRequest) + if err != nil { - switch err { - case uerr.InvalidRequestError: - return false, err - default: + skipErrors := []string{uerr.ErrNetwork, uerr.ErrHTTPStatus, uerr.ErrRetCode} + if uErr, ok := err.(uerr.Error); ok && utils.IsStringIn(uErr.Name(), skipErrors) { return false, nil } + return false, err } // TODO: Ensure if it is any data consistency problem? // Such as creating a new uhost, but cannot describe it's correct state immediately ... for _, uhost := range resp.UHostSet { - if uhost.State != req.State { + if val, _ := req.State.MarshalValue(); uhost.State != val { return false, nil } } 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 new file mode 100644 index 0000000000..4bfa85ba35 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/allocate_backend.go @@ -0,0 +1,66 @@ +//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/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/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 { + cfg := c.client.GetConfig() + + return &AllocateBackendRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// 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 nil, 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 new file mode 100644 index 0000000000..9913f1552b --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/allocate_backend_batch.go @@ -0,0 +1,57 @@ +//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/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/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"` +} + +// AllocateBackendBatchResponse is response schema for AllocateBackendBatch action +type AllocateBackendBatchResponse struct { + response.CommonBase + + // 所添加的后端资源ID,(为ULB系统中使用,与资源自身ID无关),可用于 UpdateBackendAttribute/UpdateBackendAttributeBatch/ReleaseBackend + BackendId string +} + +// NewAllocateBackendBatchRequest will create request of AllocateBackendBatch action. +func (c *ULBClient) NewAllocateBackendBatchRequest() *AllocateBackendBatchRequest { + cfg := c.client.GetConfig() + + return &AllocateBackendBatchRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// 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 nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/bind_ssl.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/bind_ssl.go new file mode 100644 index 0000000000..280b018081 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/bind_ssl.go @@ -0,0 +1,54 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api ULB BindSSL + +package ulb + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// BindSSLRequest is request schema for BindSSL action +type BindSSLRequest struct { + request.CommonBase + + // 所绑定ULB实例ID + ULBId *string `required:"true"` + + // 所绑定VServer实例ID + VServerId *string `required:"true"` + + // SSL证书的Id + SSLId *string `required:"true"` +} + +// BindSSLResponse is response schema for BindSSL action +type BindSSLResponse struct { + response.CommonBase +} + +// NewBindSSLRequest will create request of BindSSL action. +func (c *ULBClient) NewBindSSLRequest() *BindSSLRequest { + cfg := c.client.GetConfig() + + return &BindSSLRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// BindSSL - 将SSL证书绑定到VServer +func (c *ULBClient) BindSSL(req *BindSSLRequest) (*BindSSLResponse, error) { + var err error + var res BindSSLResponse + + err = c.client.InvokeAction("BindSSL", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/client.go similarity index 74% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/client.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/client.go index 977e179b29..76dadfb468 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/client.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/client.go @@ -9,7 +9,7 @@ type ULBClient struct { client *sdk.Client } -func NewClient(config *sdk.ClientConfig, credential *auth.Credential) *ULBClient { +func NewClient(config *sdk.Config, credential *auth.Credential) *ULBClient { client := sdk.NewClient(config, credential) return &ULBClient{ client: client, 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 new file mode 100644 index 0000000000..b334996768 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_policy.go @@ -0,0 +1,63 @@ +//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/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/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 { + cfg := c.client.GetConfig() + + return &CreatePolicyRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// 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 nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_policy_group.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_policy_group.go new file mode 100644 index 0000000000..82b315b3ed --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_policy_group.go @@ -0,0 +1,51 @@ +//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 CreatePolicyGroup + +package ulb + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// CreatePolicyGroupRequest is request schema for CreatePolicyGroup action +type CreatePolicyGroupRequest struct { + request.CommonBase + + // 内容转发策略组名称,默认为空 + GroupName *string `required:"false"` +} + +// CreatePolicyGroupResponse is response schema for CreatePolicyGroup action +type CreatePolicyGroupResponse struct { + response.CommonBase + + // 内容转发策略组的Id + GroupId string +} + +// NewCreatePolicyGroupRequest will create request of CreatePolicyGroup action. +func (c *ULBClient) NewCreatePolicyGroupRequest() *CreatePolicyGroupRequest { + cfg := c.client.GetConfig() + + return &CreatePolicyGroupRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// CreatePolicyGroup - 创建内容转发策略组 +func (c *ULBClient) CreatePolicyGroup(req *CreatePolicyGroupRequest) (*CreatePolicyGroupResponse, error) { + var err error + var res CreatePolicyGroupResponse + + err = c.client.InvokeAction("CreatePolicyGroup", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_ssl.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_ssl.go new file mode 100644 index 0000000000..f0e3be8eba --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_ssl.go @@ -0,0 +1,66 @@ +//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 CreateSSL + +package ulb + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// CreateSSLRequest is request schema for CreateSSL action +type CreateSSLRequest struct { + request.CommonBase + + // SSL证书的名字,默认值为空 + SSLName *string `required:"true"` + + // 所添加的SSL证书类型,目前只支持Pem格式 + SSLType *string `required:"false"` + + // SSL证书的完整内容,包括用户证书、加密证书的私钥、CA证书 + SSLContent *string `required:"false"` + + // 用户的证书 + UserCert *string `required:"false"` + + // 加密证书的私钥 + PrivateKey *string `required:"false"` + + // CA证书 + CaCert *string `required:"false"` +} + +// CreateSSLResponse is response schema for CreateSSL action +type CreateSSLResponse struct { + response.CommonBase + + // SSL证书的Id + SSLId string +} + +// NewCreateSSLRequest will create request of CreateSSL action. +func (c *ULBClient) NewCreateSSLRequest() *CreateSSLRequest { + cfg := c.client.GetConfig() + + return &CreateSSLRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// CreateSSL - 创建SSL证书,可以把整个 Pem 证书内容传过来,或者把证书、私钥、CA证书分别传过来 +func (c *ULBClient) CreateSSL(req *CreateSSLRequest) (*CreateSSLResponse, error) { + var err error + var res CreateSSLResponse + + err = c.client.InvokeAction("CreateSSL", req, &res) + if err != nil { + return nil, 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 new file mode 100644 index 0000000000..f149b9637f --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_ulb.go @@ -0,0 +1,75 @@ +//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/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/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 { + cfg := c.client.GetConfig() + + return &CreateULBRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// 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 nil, 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 new file mode 100644 index 0000000000..e6c6ff207b --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/create_vserver.go @@ -0,0 +1,84 @@ +//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/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/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 { + cfg := c.client.GetConfig() + + return &CreateVServerRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// 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 nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/delete_policy.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_policy.go similarity index 56% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/delete_policy.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_policy.go index 3b1ec43b1e..42ad55a06f 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/delete_policy.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_policy.go @@ -1,25 +1,29 @@ -//go:generate go run ../../private/cli/gen-api/main.go ulb DeletePolicy +//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/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +// DeletePolicyRequest is request schema for DeletePolicy action type DeletePolicyRequest struct { request.CommonBase - // Required, 内容转发策略ID - PolicyId string + // 内容转发策略ID + PolicyId *string `required:"true"` - // Optional, 内容转发策略组ID - GroupId string + // 内容转发策略组ID + GroupId *string `required:"false"` - // Optional, VServer 资源ID - VServerId string + // VServer 资源ID + VServerId *string `required:"false"` } +// DeletePolicyResponse is response schema for DeletePolicy action type DeletePolicyResponse struct { response.CommonBase } @@ -30,8 +34,8 @@ func (c *ULBClient) NewDeletePolicyRequest() *DeletePolicyRequest { return &DeletePolicyRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_policy_group.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_policy_group.go new file mode 100644 index 0000000000..58220e1e54 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_policy_group.go @@ -0,0 +1,48 @@ +//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 DeletePolicyGroup + +package ulb + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// DeletePolicyGroupRequest is request schema for DeletePolicyGroup action +type DeletePolicyGroupRequest struct { + request.CommonBase + + // 内容转发策略组ID + GroupId *string `required:"true"` +} + +// DeletePolicyGroupResponse is response schema for DeletePolicyGroup action +type DeletePolicyGroupResponse struct { + response.CommonBase +} + +// NewDeletePolicyGroupRequest will create request of DeletePolicyGroup action. +func (c *ULBClient) NewDeletePolicyGroupRequest() *DeletePolicyGroupRequest { + cfg := c.client.GetConfig() + + return &DeletePolicyGroupRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// DeletePolicyGroup - 删除内容转发策略组 +func (c *ULBClient) DeletePolicyGroup(req *DeletePolicyGroupRequest) (*DeletePolicyGroupResponse, error) { + var err error + var res DeletePolicyGroupResponse + + err = c.client.InvokeAction("DeletePolicyGroup", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_ssl.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_ssl.go new file mode 100644 index 0000000000..17ac633caf --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_ssl.go @@ -0,0 +1,48 @@ +//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 DeleteSSL + +package ulb + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// DeleteSSLRequest is request schema for DeleteSSL action +type DeleteSSLRequest struct { + request.CommonBase + + // SSL证书的ID + SSLId *string `required:"true"` +} + +// DeleteSSLResponse is response schema for DeleteSSL action +type DeleteSSLResponse struct { + response.CommonBase +} + +// NewDeleteSSLRequest will create request of DeleteSSL action. +func (c *ULBClient) NewDeleteSSLRequest() *DeleteSSLRequest { + cfg := c.client.GetConfig() + + return &DeleteSSLRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// DeleteSSL - 删除SSL证书 +func (c *ULBClient) DeleteSSL(req *DeleteSSLRequest) (*DeleteSSLResponse, error) { + var err error + var res DeleteSSLResponse + + err = c.client.InvokeAction("DeleteSSL", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/delete_ulb.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_ulb.go similarity index 62% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/delete_ulb.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_ulb.go index 590c9b823a..874cb9b5d2 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/delete_ulb.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_ulb.go @@ -1,19 +1,23 @@ -//go:generate go run ../../private/cli/gen-api/main.go ulb DeleteULB +//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/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +// DeleteULBRequest is request schema for DeleteULB action type DeleteULBRequest struct { request.CommonBase - // Required, 负载均衡实例的ID - ULBId string + // 负载均衡实例的ID + ULBId *string `required:"true"` } +// DeleteULBResponse is response schema for DeleteULB action type DeleteULBResponse struct { response.CommonBase } @@ -24,8 +28,8 @@ func (c *ULBClient) NewDeleteULBRequest() *DeleteULBRequest { return &DeleteULBRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/delete_vserver.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_vserver.go similarity index 59% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/delete_vserver.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_vserver.go index 9d987ca785..3a99522813 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/delete_vserver.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/delete_vserver.go @@ -1,22 +1,26 @@ -//go:generate go run ../../private/cli/gen-api/main.go ulb DeleteVServer +//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/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +// DeleteVServerRequest is request schema for DeleteVServer action type DeleteVServerRequest struct { request.CommonBase - // Required, 负载均衡实例的ID - ULBId string + // 负载均衡实例的ID + ULBId *string `required:"true"` - // Required, VServer实例的ID - VServerId string + // VServer实例的ID + VServerId *string `required:"true"` } +// DeleteVServerResponse is response schema for DeleteVServer action type DeleteVServerResponse struct { response.CommonBase } @@ -27,8 +31,8 @@ func (c *ULBClient) NewDeleteVServerRequest() *DeleteVServerRequest { return &DeleteVServerRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_policy_group.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_policy_group.go new file mode 100644 index 0000000000..3b35d89dee --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_policy_group.go @@ -0,0 +1,57 @@ +//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 DescribePolicyGroup + +package ulb + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// DescribePolicyGroupRequest is request schema for DescribePolicyGroup action +type DescribePolicyGroupRequest struct { + request.CommonBase + + // 内容转发策略组ID + GroupId *string `required:"false"` + + // 数据偏移量,默认值为0 + Offset *int `required:"false"` + + // 数据分页值,默认为20 + Limit *int `required:"false"` +} + +// DescribePolicyGroupResponse is response schema for DescribePolicyGroup action +type DescribePolicyGroupResponse struct { + response.CommonBase + + // 内容转发策略组列表,具体结构见 UlbPolicyGroupSet + DataSet []UlbPolicyGroupSet +} + +// NewDescribePolicyGroupRequest will create request of DescribePolicyGroup action. +func (c *ULBClient) NewDescribePolicyGroupRequest() *DescribePolicyGroupRequest { + cfg := c.client.GetConfig() + + return &DescribePolicyGroupRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// DescribePolicyGroup - 获取内容转发组详细信息 +func (c *ULBClient) DescribePolicyGroup(req *DescribePolicyGroupRequest) (*DescribePolicyGroupResponse, error) { + var err error + var res DescribePolicyGroupResponse + + err = c.client.InvokeAction("DescribePolicyGroup", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_ssl.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_ssl.go new file mode 100644 index 0000000000..0d868f4a7c --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_ssl.go @@ -0,0 +1,60 @@ +//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 DescribeSSL + +package ulb + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// DescribeSSLRequest is request schema for DescribeSSL action +type DescribeSSLRequest struct { + request.CommonBase + + // SSL证书的Id + SSLId *string `required:"false"` + + // 数据分页值,默认为20 + Limit *int `required:"false"` + + // 数据偏移量,默认值为0 + Offset *int `required:"false"` +} + +// DescribeSSLResponse is response schema for DescribeSSL action +type DescribeSSLResponse struct { + response.CommonBase + + // 满足条件的SSL证书总数 + TotalCount string + + // SSL证书详细信息,具体结构见 ULBSSLSet + DataSet []ULBSSLSet +} + +// NewDescribeSSLRequest will create request of DescribeSSL action. +func (c *ULBClient) NewDescribeSSLRequest() *DescribeSSLRequest { + cfg := c.client.GetConfig() + + return &DescribeSSLRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// DescribeSSL - 获取SSL证书信息 +func (c *ULBClient) DescribeSSL(req *DescribeSSLRequest) (*DescribeSSLResponse, error) { + var err error + var res DescribeSSLResponse + + err = c.client.InvokeAction("DescribeSSL", req, &res) + if err != nil { + return nil, 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 new file mode 100644 index 0000000000..cc276018f4 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_ulb.go @@ -0,0 +1,69 @@ +//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/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/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 { + cfg := c.client.GetConfig() + + return &DescribeULBRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// 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 nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/describe_vserver.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_vserver.go similarity index 58% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/describe_vserver.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_vserver.go index b7f96682b5..0e520abcf6 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/describe_vserver.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/describe_vserver.go @@ -1,23 +1,26 @@ -//go:generate go run ../../private/cli/gen-api/main.go ulb DescribeVServer +//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/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" - . "github.com/ucloud/ucloud-sdk-go/service/ulb/types" ) +// DescribeVServerRequest is request schema for DescribeVServer action type DescribeVServerRequest struct { request.CommonBase - // Required, 负载均衡实例的Id - ULBId string + // 负载均衡实例的Id + ULBId *string `required:"true"` - // Optional, VServer实例的Id;若指定则返回指定的VServer实例的信息; 若不指定则返回当前负载均衡实例下所有VServer的信息 - VServerId string + // VServer实例的Id;若指定则返回指定的VServer实例的信息; 若不指定则返回当前负载均衡实例下所有VServer的信息 + VServerId *string `required:"false"` } +// DescribeVServerResponse is response schema for DescribeVServer action type DescribeVServerResponse struct { response.CommonBase @@ -34,8 +37,8 @@ func (c *ULBClient) NewDescribeVServerRequest() *DescribeVServerRequest { return &DescribeVServerRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/doc.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/doc.go similarity index 100% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/doc.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/doc.go diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/release_backend.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/release_backend.go similarity index 58% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/release_backend.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/release_backend.go index faa2115759..eabdd8680e 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/release_backend.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/release_backend.go @@ -1,22 +1,26 @@ -//go:generate go run ../../private/cli/gen-api/main.go ulb ReleaseBackend +//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/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +// ReleaseBackendRequest is request schema for ReleaseBackend action type ReleaseBackendRequest struct { request.CommonBase - // Required, 负载均衡实例的ID - ULBId string + // 负载均衡实例的ID + ULBId *string `required:"true"` - // Required, 后端资源实例的ID(ULB后端ID,非资源自身ID) - BackendId string + // 后端资源实例的ID(ULB后端ID,非资源自身ID) + BackendId *string `required:"true"` } +// ReleaseBackendResponse is response schema for ReleaseBackend action type ReleaseBackendResponse struct { response.CommonBase } @@ -27,8 +31,8 @@ func (c *ULBClient) NewReleaseBackendRequest() *ReleaseBackendRequest { return &ReleaseBackendRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } 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 new file mode 100644 index 0000000000..049eeb5f58 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_policy_backend_set.go @@ -0,0 +1,25 @@ +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 new file mode 100644 index 0000000000..89bc51211b --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulb_policy_backend_set.go @@ -0,0 +1,19 @@ +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 new file mode 100644 index 0000000000..87b7cd7852 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulb_policy_group_set.go @@ -0,0 +1,19 @@ +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 new file mode 100644 index 0000000000..06c2ac5320 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulb_policy_set.go @@ -0,0 +1,25 @@ +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/service/ulb/types/ulbbackend_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbbackend_set.go similarity index 75% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/types/ulbbackend_set.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbbackend_set.go index b265d9cec7..2e39b99ce6 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/types/ulbbackend_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbbackend_set.go @@ -1,6 +1,11 @@ -package types +package ulb -// ULBBackendSet - DescribeULB +/* + 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 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 new file mode 100644 index 0000000000..521089ce4e --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbipset.go @@ -0,0 +1,19 @@ +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 new file mode 100644 index 0000000000..b88e8efec2 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbpolicy_set.go @@ -0,0 +1,34 @@ +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/service/ulb/types/ulbset.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbset.go similarity index 87% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/types/ulbset.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbset.go index fe39b9cf29..5f53104964 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/ulb/types/ulbset.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbset.go @@ -1,6 +1,11 @@ -package types +package ulb -// ULBSet - DescribeULB +/* + 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 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 new file mode 100644 index 0000000000..a5ec42a2cf --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbsslset.go @@ -0,0 +1,16 @@ +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 new file mode 100644 index 0000000000..752dd83d8f --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/types_ulbvserver_set.go @@ -0,0 +1,58 @@ +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/unbind_ssl.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/unbind_ssl.go new file mode 100644 index 0000000000..83fa3ad07e --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/unbind_ssl.go @@ -0,0 +1,54 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api ULB UnbindSSL + +package ulb + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// UnbindSSLRequest is request schema for UnbindSSL action +type UnbindSSLRequest struct { + request.CommonBase + + // 所绑定ULB实例ID + ULBId *string `required:"true"` + + // 所绑定VServer实例ID + VServerId *string `required:"true"` + + // SSL证书的Id + SSLId *string `required:"true"` +} + +// UnbindSSLResponse is response schema for UnbindSSL action +type UnbindSSLResponse struct { + response.CommonBase +} + +// NewUnbindSSLRequest will create request of UnbindSSL action. +func (c *ULBClient) NewUnbindSSLRequest() *UnbindSSLRequest { + cfg := c.client.GetConfig() + + return &UnbindSSLRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// UnbindSSL - 从VServer解绑SSL证书 +func (c *ULBClient) UnbindSSL(req *UnbindSSLRequest) (*UnbindSSLResponse, error) { + var err error + var res UnbindSSLResponse + + err = c.client.InvokeAction("UnbindSSL", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} 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 new file mode 100644 index 0000000000..2d7b93f2ab --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_backend_attribute.go @@ -0,0 +1,57 @@ +//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/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/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 { + cfg := c.client.GetConfig() + + return &UpdateBackendAttributeRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// 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 nil, 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 new file mode 100644 index 0000000000..f992e840bf --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_policy.go @@ -0,0 +1,66 @@ +//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/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/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 { + cfg := c.client.GetConfig() + + return &UpdatePolicyRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// 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 nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_policy_group_attribute.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_policy_group_attribute.go new file mode 100644 index 0000000000..6f4cae7cfb --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_policy_group_attribute.go @@ -0,0 +1,51 @@ +//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 UpdatePolicyGroupAttribute + +package ulb + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// UpdatePolicyGroupAttributeRequest is request schema for UpdatePolicyGroupAttribute action +type UpdatePolicyGroupAttributeRequest struct { + request.CommonBase + + // 内容转发策略组ID + GroupId *string `required:"true"` + + // 修改策略转发组名称 + GroupName *string `required:"false"` +} + +// UpdatePolicyGroupAttributeResponse is response schema for UpdatePolicyGroupAttribute action +type UpdatePolicyGroupAttributeResponse struct { + response.CommonBase +} + +// NewUpdatePolicyGroupAttributeRequest will create request of UpdatePolicyGroupAttribute action. +func (c *ULBClient) NewUpdatePolicyGroupAttributeRequest() *UpdatePolicyGroupAttributeRequest { + cfg := c.client.GetConfig() + + return &UpdatePolicyGroupAttributeRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// UpdatePolicyGroupAttribute - 更新内容转发策略组属性 +func (c *ULBClient) UpdatePolicyGroupAttribute(req *UpdatePolicyGroupAttributeRequest) (*UpdatePolicyGroupAttributeResponse, error) { + var err error + var res UpdatePolicyGroupAttributeResponse + + err = c.client.InvokeAction("UpdatePolicyGroupAttribute", req, &res) + if err != nil { + return nil, 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 new file mode 100644 index 0000000000..94cda7ed56 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_ulbattribute.go @@ -0,0 +1,57 @@ +//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/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/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 { + cfg := c.client.GetConfig() + + return &UpdateULBAttributeRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// 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 nil, 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 new file mode 100644 index 0000000000..e3c1c079d5 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/ulb/update_vserver_attribute.go @@ -0,0 +1,78 @@ +//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/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/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 { + cfg := c.client.GetConfig() + + return &UpdateVServerAttributeRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// 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 nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/allocate_eip.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/allocate_eip.go new file mode 100644 index 0000000000..caf56299f4 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/allocate_eip.go @@ -0,0 +1,78 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet AllocateEIP + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// AllocateEIPRequest is request schema for AllocateEIP action +type AllocateEIPRequest struct { + request.CommonBase + + // 弹性IP的线路如下: 国际: International BGP: Bgp 各地域允许的线路参数如下: cn-sh1: Bgp cn-sh2: Bgp cn-gd: Bgp cn-bj1: Bgp cn-bj2: Bgp hk: International us-ca: International th-bkk: International kr-seoul:International us-ws:International ge-fra:International sg:International tw-kh:International.其他海外线路均为 International + OperatorName *string `required:"true"` + + // 弹性IP的外网带宽, 单位为Mbps. 共享带宽模式必须指定0M带宽, 非共享带宽模式必须指定非0Mbps带宽. 各地域非共享带宽的带宽范围如下: 流量计费[1-200],带宽计费[1-800] + Bandwidth *int `required:"true"` + + // 业务组名称, 默认为 "Default" + Tag *string `required:"false"` + + // 付费方式, 枚举值为: Year, 按年付费; Month, 按月付费; Dynamic, 按需付费(需开启权限); Trial, 试用(需开启权限) 默认为按月付费 + ChargeType *string `required:"false"` + + // 购买时长, 默认: 1 + Quantity *int `required:"false"` + + // 弹性IP的计费模式. 枚举值: "Traffic", 流量计费; "Bandwidth", 带宽计费; "ShareBandwidth",共享带宽模式. 默认为 "Bandwidth". + PayMode *string `required:"false"` + + // 绑定的共享带宽Id,仅当PayMode为ShareBandwidth时有效 + ShareBandwidthId *string `required:"false"` + + // 弹性IP的名称, 默认为 "EIP" + Name *string `required:"false"` + + // 弹性IP的备注, 默认为空 + Remark *string `required:"false"` + + // 代金券ID, 默认不使用 + CouponId *string `required:"false"` +} + +// AllocateEIPResponse is response schema for AllocateEIP action +type AllocateEIPResponse struct { + response.CommonBase + + // 申请到的EIP资源详情 参见 UnetAllocateEIPSet + EIPSet []UnetAllocateEIPSet +} + +// NewAllocateEIPRequest will create request of AllocateEIP action. +func (c *UNetClient) NewAllocateEIPRequest() *AllocateEIPRequest { + cfg := c.client.GetConfig() + + return &AllocateEIPRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// AllocateEIP - 根据提供信息, 申请弹性IP +func (c *UNetClient) AllocateEIP(req *AllocateEIPRequest) (*AllocateEIPResponse, error) { + var err error + var res AllocateEIPResponse + + err = c.client.InvokeAction("AllocateEIP", req, &res) + if err != nil { + return nil, 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 new file mode 100644 index 0000000000..59639f298b --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/allocate_share_bandwidth.go @@ -0,0 +1,60 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet AllocateShareBandwidth + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// AllocateShareBandwidthRequest is request schema for AllocateShareBandwidth action +type AllocateShareBandwidthRequest struct { + request.CommonBase + + // 共享带宽名字 + Name *string `required:"true"` + + // 付费方式:Year 按年,Month 按月,Dynamic 按时; + ChargeType *string `required:"true"` + + // 共享带宽值 + ShareBandwidth *int `required:"true"` + + // 购买时长 + Quantity *int `required:"false"` + + // 共享带宽保底值(后付费) + ShareBandwidthGuarantee *int `required:"false"` +} + +// AllocateShareBandwidthResponse is response schema for AllocateShareBandwidth action +type AllocateShareBandwidthResponse struct { + response.CommonBase +} + +// NewAllocateShareBandwidthRequest will create request of AllocateShareBandwidth action. +func (c *UNetClient) NewAllocateShareBandwidthRequest() *AllocateShareBandwidthRequest { + cfg := c.client.GetConfig() + + return &AllocateShareBandwidthRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// AllocateShareBandwidth - 开通共享带宽 +func (c *UNetClient) AllocateShareBandwidth(req *AllocateShareBandwidthRequest) (*AllocateShareBandwidthResponse, error) { + var err error + var res AllocateShareBandwidthResponse + + err = c.client.InvokeAction("AllocateShareBandwidth", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/allocate_vip.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/allocate_vip.go new file mode 100644 index 0000000000..a9c5885e54 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/allocate_vip.go @@ -0,0 +1,75 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet AllocateVIP + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// AllocateVIPRequest is request schema for AllocateVIP action +type AllocateVIPRequest struct { + request.CommonBase + + // 可用区 + Zone *string `required:"false"` + + // 指定vip所属的VPC + VPCId *string `required:"true"` + + // 子网id + SubnetId *string `required:"true"` + + // 申请数量,默认: 1 + Count *int `required:"false"` + + // vip名,默认为VIP + Name *string `required:"false"` + + // 业务组名称,默认为Default + Tag *string `required:"false"` + + // 备注 + Remark *string `required:"false"` + + // 业务组 + BusinessId *string `required:"false"` +} + +// AllocateVIPResponse is response schema for AllocateVIP action +type AllocateVIPResponse struct { + response.CommonBase + + // 申请到的VIP资源相关信息 + VIPSet []VIPSet + + // 申请到的VIP地址 + DataSet []string +} + +// NewAllocateVIPRequest will create request of AllocateVIP action. +func (c *UNetClient) NewAllocateVIPRequest() *AllocateVIPRequest { + cfg := c.client.GetConfig() + + return &AllocateVIPRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// AllocateVIP - 根据提供信息,申请内网VIP(Virtual IP),多用于高可用程序作为漂移IP。 +func (c *UNetClient) AllocateVIP(req *AllocateVIPRequest) (*AllocateVIPResponse, error) { + var err error + var res AllocateVIPResponse + + err = c.client.InvokeAction("AllocateVIP", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/associate_eipwith_share_bandwidth.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/associate_eipwith_share_bandwidth.go new file mode 100644 index 0000000000..d8e2d2e58a --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/associate_eipwith_share_bandwidth.go @@ -0,0 +1,51 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet AssociateEIPWithShareBandwidth + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// AssociateEIPWithShareBandwidthRequest is request schema for AssociateEIPWithShareBandwidth action +type AssociateEIPWithShareBandwidthRequest struct { + request.CommonBase + + // 要加入共享带宽的EIP的资源Id + EIPIds []string `required:"true"` + + // 共享带宽ID + ShareBandwidthId *string `required:"true"` +} + +// AssociateEIPWithShareBandwidthResponse is response schema for AssociateEIPWithShareBandwidth action +type AssociateEIPWithShareBandwidthResponse struct { + response.CommonBase +} + +// NewAssociateEIPWithShareBandwidthRequest will create request of AssociateEIPWithShareBandwidth action. +func (c *UNetClient) NewAssociateEIPWithShareBandwidthRequest() *AssociateEIPWithShareBandwidthRequest { + cfg := c.client.GetConfig() + + return &AssociateEIPWithShareBandwidthRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// AssociateEIPWithShareBandwidth - 将EIP加入共享带宽 +func (c *UNetClient) AssociateEIPWithShareBandwidth(req *AssociateEIPWithShareBandwidthRequest) (*AssociateEIPWithShareBandwidthResponse, error) { + var err error + var res AssociateEIPWithShareBandwidthResponse + + err = c.client.InvokeAction("AssociateEIPWithShareBandwidth", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/bind_eip.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/bind_eip.go new file mode 100644 index 0000000000..8443173044 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/bind_eip.go @@ -0,0 +1,54 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet BindEIP + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// BindEIPRequest is request schema for BindEIP action +type BindEIPRequest struct { + request.CommonBase + + // 弹性IP的资源Id + EIPId *string `required:"true"` + + // 弹性IP请求绑定的资源类型, 枚举值为: uhost: 云主机; vrouter: 虚拟路由器; ulb, 负载均衡器 upm: 物理机; hadoophost: 大数据集群;fortresshost:堡垒机;udockhost:容器;udhost:私有专区主机;natgw:natgw;udb:udb;vpngw:ipsec vpn;ucdr:云灾备;dbaudit:数据库审计; + ResourceType *string `required:"true"` + + // 弹性IP请求绑定的资源ID + ResourceId *string `required:"true"` +} + +// BindEIPResponse is response schema for BindEIP action +type BindEIPResponse struct { + response.CommonBase +} + +// NewBindEIPRequest will create request of BindEIP action. +func (c *UNetClient) NewBindEIPRequest() *BindEIPRequest { + cfg := c.client.GetConfig() + + return &BindEIPRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// BindEIP - 将尚未使用的弹性IP绑定到指定的资源 +func (c *UNetClient) BindEIP(req *BindEIPRequest) (*BindEIPResponse, error) { + var err error + var res BindEIPResponse + + err = c.client.InvokeAction("BindEIP", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/client.go similarity index 74% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/unet/client.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/unet/client.go index 7617f3f963..ac1d45e66a 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/client.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/client.go @@ -9,7 +9,7 @@ type UNetClient struct { client *sdk.Client } -func NewClient(config *sdk.ClientConfig, credential *auth.Credential) *UNetClient { +func NewClient(config *sdk.Config, credential *auth.Credential) *UNetClient { client := sdk.NewClient(config, credential) return &UNetClient{ client: client, diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/create_bandwidth_package.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/create_bandwidth_package.go new file mode 100644 index 0000000000..0f7840ba64 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/create_bandwidth_package.go @@ -0,0 +1,63 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet CreateBandwidthPackage + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// CreateBandwidthPackageRequest is request schema for CreateBandwidthPackage action +type CreateBandwidthPackageRequest struct { + request.CommonBase + + // 带宽大小(单位Mbps), 取值范围[2,800] (最大值受地域限制) + Bandwidth *int `required:"true"` + + // 所绑定弹性IP的资源ID + EIPId *string `required:"true"` + + // 带宽包有效时长, 取值范围为大于0的整数, 即该带宽包在EnableTime到 EnableTime+TimeRange时间段内生效 + TimeRange *int `required:"true"` + + // 生效时间, 格式为 Unix timestamp, 默认为立即开通 + EnableTime *int `required:"false"` + + // 代金券ID + CouponId *string `required:"false"` +} + +// CreateBandwidthPackageResponse is response schema for CreateBandwidthPackage action +type CreateBandwidthPackageResponse struct { + response.CommonBase + + // 所创建带宽包的资源ID + BandwidthPackageId string +} + +// NewCreateBandwidthPackageRequest will create request of CreateBandwidthPackage action. +func (c *UNetClient) NewCreateBandwidthPackageRequest() *CreateBandwidthPackageRequest { + cfg := c.client.GetConfig() + + return &CreateBandwidthPackageRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// CreateBandwidthPackage - 为非共享带宽模式下, 已绑定资源实例的带宽计费弹性IP附加临时带宽包 +func (c *UNetClient) CreateBandwidthPackage(req *CreateBandwidthPackageRequest) (*CreateBandwidthPackageResponse, error) { + var err error + var res CreateBandwidthPackageResponse + + err = c.client.InvokeAction("CreateBandwidthPackage", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} 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 new file mode 100644 index 0000000000..4af99503f8 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/create_firewall.go @@ -0,0 +1,60 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet CreateFirewall + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// CreateFirewallRequest is request schema for CreateFirewall action +type CreateFirewallRequest struct { + request.CommonBase + + // 防火墙规则,例如:TCP|22|192.168.1.1/22|DROP|LOW,第一个参数代表协议:第二个参数代表端口号,第三个参数为ip,第四个参数为ACCEPT(接受)和DROP(拒绝),第五个参数优先级:HIGH(高),MEDIUM(中),LOW(低) + Rule []string `required:"true"` + + // 防火墙名称, 默认为Firewall + Name *string `required:"false"` + + // 防火墙业务组,默认为Default + Tag *string `required:"false"` + + // 防火墙描述,默认为空 + Remark *string `required:"false"` +} + +// CreateFirewallResponse is response schema for CreateFirewall action +type CreateFirewallResponse struct { + response.CommonBase + + // 防火墙 ID + FWId string +} + +// NewCreateFirewallRequest will create request of CreateFirewall action. +func (c *UNetClient) NewCreateFirewallRequest() *CreateFirewallRequest { + cfg := c.client.GetConfig() + + return &CreateFirewallRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// CreateFirewall - 创建防火墙 +func (c *UNetClient) CreateFirewall(req *CreateFirewallRequest) (*CreateFirewallResponse, error) { + var err error + var res CreateFirewallResponse + + err = c.client.InvokeAction("CreateFirewall", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/delete_bandwidth_package.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/delete_bandwidth_package.go new file mode 100644 index 0000000000..64cc8b6601 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/delete_bandwidth_package.go @@ -0,0 +1,48 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet DeleteBandwidthPackage + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// DeleteBandwidthPackageRequest is request schema for DeleteBandwidthPackage action +type DeleteBandwidthPackageRequest struct { + request.CommonBase + + // 带宽包资源ID + BandwidthPackageId *string `required:"true"` +} + +// DeleteBandwidthPackageResponse is response schema for DeleteBandwidthPackage action +type DeleteBandwidthPackageResponse struct { + response.CommonBase +} + +// NewDeleteBandwidthPackageRequest will create request of DeleteBandwidthPackage action. +func (c *UNetClient) NewDeleteBandwidthPackageRequest() *DeleteBandwidthPackageRequest { + cfg := c.client.GetConfig() + + return &DeleteBandwidthPackageRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// DeleteBandwidthPackage - 删除弹性IP上已附加带宽包 +func (c *UNetClient) DeleteBandwidthPackage(req *DeleteBandwidthPackageRequest) (*DeleteBandwidthPackageResponse, error) { + var err error + var res DeleteBandwidthPackageResponse + + err = c.client.InvokeAction("DeleteBandwidthPackage", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/delete_firewall.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/delete_firewall.go new file mode 100644 index 0000000000..425bc0bd0b --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/delete_firewall.go @@ -0,0 +1,48 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet DeleteFirewall + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// DeleteFirewallRequest is request schema for DeleteFirewall action +type DeleteFirewallRequest struct { + request.CommonBase + + // 防火墙资源ID + FWId *string `required:"true"` +} + +// DeleteFirewallResponse is response schema for DeleteFirewall action +type DeleteFirewallResponse struct { + response.CommonBase +} + +// NewDeleteFirewallRequest will create request of DeleteFirewall action. +func (c *UNetClient) NewDeleteFirewallRequest() *DeleteFirewallRequest { + cfg := c.client.GetConfig() + + return &DeleteFirewallRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// DeleteFirewall - 删除防火墙 +func (c *UNetClient) DeleteFirewall(req *DeleteFirewallRequest) (*DeleteFirewallResponse, error) { + var err error + var res DeleteFirewallResponse + + err = c.client.InvokeAction("DeleteFirewall", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_bandwidth_package.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_bandwidth_package.go new file mode 100644 index 0000000000..82df0fdd46 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_bandwidth_package.go @@ -0,0 +1,57 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet DescribeBandwidthPackage + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// DescribeBandwidthPackageRequest is request schema for DescribeBandwidthPackage action +type DescribeBandwidthPackageRequest struct { + request.CommonBase + + // 返回数据分页值, 取值范围为 [0,10000000] 之间的整数, 默认为20 + Limit *int `required:"false"` + + // 返回数据偏移量, 默认为0 + Offset *int `required:"false"` +} + +// DescribeBandwidthPackageResponse is response schema for DescribeBandwidthPackage action +type DescribeBandwidthPackageResponse struct { + response.CommonBase + + // 满足条件的带宽包总数 + TotalCount int + + // 带宽包详细信息, 参见 UnetBandwidthPackageSet + DataSets []UnetBandwidthPackageSet +} + +// NewDescribeBandwidthPackageRequest will create request of DescribeBandwidthPackage action. +func (c *UNetClient) NewDescribeBandwidthPackageRequest() *DescribeBandwidthPackageRequest { + cfg := c.client.GetConfig() + + return &DescribeBandwidthPackageRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// DescribeBandwidthPackage - 获取某地域下的带宽包信息 +func (c *UNetClient) DescribeBandwidthPackage(req *DescribeBandwidthPackageRequest) (*DescribeBandwidthPackageResponse, error) { + var err error + var res DescribeBandwidthPackageResponse + + err = c.client.InvokeAction("DescribeBandwidthPackage", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_bandwidth_usage.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_bandwidth_usage.go new file mode 100644 index 0000000000..431b6bd52e --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_bandwidth_usage.go @@ -0,0 +1,60 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet DescribeBandwidthUsage + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// DescribeBandwidthUsageRequest is request schema for DescribeBandwidthUsage action +type DescribeBandwidthUsageRequest struct { + request.CommonBase + + // 返回数据分页值, 取值范围为 [0,10000000] 之间的整数, 默认为20 + Limit *int `required:"false"` + + // 返回数据偏移量, 默认为0 + OffSet *int `required:"false"` + + // 弹性IP的资源Id. 如果为空, 则返回当前 Region中符合条件的所有EIP的带宽用量, n为自然数 + EIPIds []string `required:"false"` +} + +// DescribeBandwidthUsageResponse is response schema for DescribeBandwidthUsage action +type DescribeBandwidthUsageResponse struct { + response.CommonBase + + // EIPSet中的元素个数 + TotalCount int + + // 单个弹性IP的带宽用量详细信息, 详见 UnetBandwidthUsageEIPSet, 如没有弹性IP资源则没有该返回值。 + EIPSet []UnetBandwidthUsageEIPSet +} + +// NewDescribeBandwidthUsageRequest will create request of DescribeBandwidthUsage action. +func (c *UNetClient) NewDescribeBandwidthUsageRequest() *DescribeBandwidthUsageRequest { + cfg := c.client.GetConfig() + + return &DescribeBandwidthUsageRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// DescribeBandwidthUsage - 获取带宽用量信息 +func (c *UNetClient) DescribeBandwidthUsage(req *DescribeBandwidthUsageRequest) (*DescribeBandwidthUsageResponse, error) { + var err error + var res DescribeBandwidthUsageResponse + + err = c.client.InvokeAction("DescribeBandwidthUsage", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/describe_eip.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_eip.go similarity index 59% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/unet/describe_eip.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_eip.go index c4abffb9c7..fbab36327f 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/describe_eip.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_eip.go @@ -1,26 +1,29 @@ -//go:generate go run ../../private/cli/gen-api/main.go unet DescribeEIP +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet DescribeEIP package unet import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" - . "github.com/ucloud/ucloud-sdk-go/service/unet/types" ) +// DescribeEIPRequest is request schema for DescribeEIP action type DescribeEIPRequest struct { request.CommonBase - // Optional, 弹性IP的资源ID如果为空, 则返回当前 Region中符合条件的的所有EIP - EIPIds []string + // 弹性IP的资源ID如果为空, 则返回当前 Region中符合条件的的所有EIP + EIPIds []string `required:"false"` - // Optional, 数据偏移量, 默认为0 - Offset int + // 数据偏移量, 默认为0 + Offset *int `required:"false"` - // Optional, 数据分页值, 默认为20 - Limit int + // 数据分页值, 默认为20 + Limit *int `required:"false"` } +// DescribeEIPResponse is response schema for DescribeEIP action type DescribeEIPResponse struct { response.CommonBase @@ -40,8 +43,8 @@ func (c *UNetClient) NewDescribeEIPRequest() *DescribeEIPRequest { return &DescribeEIPRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_firewall.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_firewall.go new file mode 100644 index 0000000000..83eabd0eea --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_firewall.go @@ -0,0 +1,63 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet DescribeFirewall + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// DescribeFirewallRequest is request schema for DescribeFirewall action +type DescribeFirewallRequest struct { + request.CommonBase + + // 防火墙ID,默认为返回所有防火墙 + FWId *string `required:"false"` + + // 绑定防火墙组的资源类型,如uhost + ResourceType *string `required:"false"` + + // 绑定防火墙组的资源ID + ResourceId *string `required:"false"` + + // 返回数据长度,默认为20,最大10000000 + Limit *string `required:"false"` + + // 列表起始位置偏移量,默认为0 + Offset *string `required:"false"` +} + +// DescribeFirewallResponse is response schema for DescribeFirewall action +type DescribeFirewallResponse struct { + response.CommonBase + + // 获取的防火墙组详细信息 参见 FirewallDataSet + DataSet []FirewallDataSet +} + +// NewDescribeFirewallRequest will create request of DescribeFirewall action. +func (c *UNetClient) NewDescribeFirewallRequest() *DescribeFirewallRequest { + cfg := c.client.GetConfig() + + return &DescribeFirewallRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// DescribeFirewall - 获取防火墙组信息 +func (c *UNetClient) DescribeFirewall(req *DescribeFirewallRequest) (*DescribeFirewallResponse, error) { + var err error + var res DescribeFirewallResponse + + err = c.client.InvokeAction("DescribeFirewall", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} 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 new file mode 100644 index 0000000000..c65e92eb7b --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_firewall_resource.go @@ -0,0 +1,57 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet DescribeFirewallResource + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// DescribeFirewallResourceRequest is request schema for DescribeFirewallResource action +type DescribeFirewallResourceRequest struct { + request.CommonBase + + // 防火墙ID + FWId *int `required:"true"` + + // 返回数据长度,默认为20,最大10000000 + Limit *string `required:"false"` + + // 列表起始位置偏移量,默认为0 + Offset *string `required:"false"` +} + +// DescribeFirewallResourceResponse is response schema for DescribeFirewallResource action +type DescribeFirewallResourceResponse struct { + response.CommonBase + + // 资源列表,见 ResourceSet + ResourceSet []ResourceSet +} + +// NewDescribeFirewallResourceRequest will create request of DescribeFirewallResource action. +func (c *UNetClient) NewDescribeFirewallResourceRequest() *DescribeFirewallResourceRequest { + cfg := c.client.GetConfig() + + return &DescribeFirewallResourceRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// DescribeFirewallResource - 获取防火墙组所绑定资源的外网IP +func (c *UNetClient) DescribeFirewallResource(req *DescribeFirewallResourceRequest) (*DescribeFirewallResourceResponse, error) { + var err error + var res DescribeFirewallResourceResponse + + err = c.client.InvokeAction("DescribeFirewallResource", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_share_bandwidth.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_share_bandwidth.go new file mode 100644 index 0000000000..9173564211 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_share_bandwidth.go @@ -0,0 +1,51 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet DescribeShareBandwidth + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// DescribeShareBandwidthRequest is request schema for DescribeShareBandwidth action +type DescribeShareBandwidthRequest struct { + request.CommonBase + + // 需要返回的共享带宽Id + ShareBandwidthIds []string `required:"false"` +} + +// DescribeShareBandwidthResponse is response schema for DescribeShareBandwidth action +type DescribeShareBandwidthResponse struct { + response.CommonBase + + // 共享带宽信息组 参见 UnetShareBandwidthSet + DataSet []UnetShareBandwidthSet +} + +// NewDescribeShareBandwidthRequest will create request of DescribeShareBandwidth action. +func (c *UNetClient) NewDescribeShareBandwidthRequest() *DescribeShareBandwidthRequest { + cfg := c.client.GetConfig() + + return &DescribeShareBandwidthRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// DescribeShareBandwidth - 获取共享带宽信息 +func (c *UNetClient) DescribeShareBandwidth(req *DescribeShareBandwidthRequest) (*DescribeShareBandwidthResponse, error) { + var err error + var res DescribeShareBandwidthResponse + + err = c.client.InvokeAction("DescribeShareBandwidth", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} 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 new file mode 100644 index 0000000000..7aebafe25c --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/describe_vip.go @@ -0,0 +1,69 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet DescribeVIP + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// DescribeVIPRequest is request schema for DescribeVIP action +type DescribeVIPRequest struct { + request.CommonBase + + // 可用区。参见 [可用区列表](../summary/regionlist.html) + Zone *string `required:"false"` + + // vpc的id,指定SubnetId时必填 + VPCId *string `required:"false"` + + // 子网id,不指定则获取VPCId下的所有vip + SubnetId *string `required:"false"` + + // 业务组名称, 默认为 Default + Tag *string `required:"false"` + + // 业务组 + BusinessId *string `required:"false"` +} + +// DescribeVIPResponse is response schema for DescribeVIP action +type DescribeVIPResponse struct { + response.CommonBase + + // 内网VIP详情 + VIPSet []VIPDetailSet + + // 内网VIP地址列表 + DataSet []string + + // vip数量 + TotalCount int +} + +// NewDescribeVIPRequest will create request of DescribeVIP action. +func (c *UNetClient) NewDescribeVIPRequest() *DescribeVIPRequest { + cfg := c.client.GetConfig() + + return &DescribeVIPRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// DescribeVIP - 获取内网VIP详细信息 +func (c *UNetClient) DescribeVIP(req *DescribeVIPRequest) (*DescribeVIPResponse, error) { + var err error + var res DescribeVIPResponse + + err = c.client.InvokeAction("DescribeVIP", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/disassociate_eipwith_share_bandwidth.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/disassociate_eipwith_share_bandwidth.go new file mode 100644 index 0000000000..99d207f0a0 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/disassociate_eipwith_share_bandwidth.go @@ -0,0 +1,57 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet DisassociateEIPWithShareBandwidth + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// DisassociateEIPWithShareBandwidthRequest is request schema for DisassociateEIPWithShareBandwidth action +type DisassociateEIPWithShareBandwidthRequest struct { + request.CommonBase + + // 共享带宽ID + ShareBandwidthId *string `required:"true"` + + // 移出共享带宽后,EIP的外网带宽, 单位为Mbps. 各地域带宽范围如下: 流量计费[1-200],带宽计费[1-800] + Bandwidth *int `required:"true"` + + // EIP的资源Id;默认移出该共享带宽下所有的EIP + EIPIds []string `required:"false"` + + // 移出共享带宽后,EIP的计费模式. 枚举值: "Traffic", 流量计费; "Bandwidth", 带宽计费; 默认为 "Bandwidth". + PayMode *string `required:"false"` +} + +// DisassociateEIPWithShareBandwidthResponse is response schema for DisassociateEIPWithShareBandwidth action +type DisassociateEIPWithShareBandwidthResponse struct { + response.CommonBase +} + +// NewDisassociateEIPWithShareBandwidthRequest will create request of DisassociateEIPWithShareBandwidth action. +func (c *UNetClient) NewDisassociateEIPWithShareBandwidthRequest() *DisassociateEIPWithShareBandwidthRequest { + cfg := c.client.GetConfig() + + return &DisassociateEIPWithShareBandwidthRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// DisassociateEIPWithShareBandwidth - 将EIP移出共享带宽 +func (c *UNetClient) DisassociateEIPWithShareBandwidth(req *DisassociateEIPWithShareBandwidthRequest) (*DisassociateEIPWithShareBandwidthResponse, error) { + var err error + var res DisassociateEIPWithShareBandwidthResponse + + err = c.client.InvokeAction("DisassociateEIPWithShareBandwidth", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/doc.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/doc.go similarity index 100% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/unet/doc.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/unet/doc.go diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eippay_mode.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eippay_mode.go new file mode 100644 index 0000000000..a3e17f05dc --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eippay_mode.go @@ -0,0 +1,51 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet GetEIPPayMode + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// GetEIPPayModeRequest is request schema for GetEIPPayMode action +type GetEIPPayModeRequest struct { + request.CommonBase + + // 弹性IP的资源Id + EIPId []string `required:"true"` +} + +// GetEIPPayModeResponse is response schema for GetEIPPayMode action +type GetEIPPayModeResponse struct { + response.CommonBase + + // EIP的计费模式, 参见 EIPPayModeSet + EIPPayMode []EIPPayModeSet +} + +// NewGetEIPPayModeRequest will create request of GetEIPPayMode action. +func (c *UNetClient) NewGetEIPPayModeRequest() *GetEIPPayModeRequest { + cfg := c.client.GetConfig() + + return &GetEIPPayModeRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// GetEIPPayMode - 获取弹性IP计费模式 +func (c *UNetClient) GetEIPPayMode(req *GetEIPPayModeRequest) (*GetEIPPayModeResponse, error) { + var err error + var res GetEIPPayModeResponse + + err = c.client.InvokeAction("GetEIPPayMode", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eipprice.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eipprice.go new file mode 100644 index 0000000000..994e1d2005 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eipprice.go @@ -0,0 +1,60 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet GetEIPPrice + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// GetEIPPriceRequest is request schema for GetEIPPrice action +type GetEIPPriceRequest struct { + request.CommonBase + + // 弹性IP的线路如下: 国际: International BGP: Bgp 各地域允许的线路参数如下: cn-sh1: Bgp cn-sh2: Bgp cn-gd: Bgp cn-bj1: Bgp cn-bj2: Bgp hk: International us-ca: International th-bkk: International kr-seoul:International us-ws:International ge-fra:International sg:International tw-kh:International.其他海外线路均为 International + OperatorName *string `required:"true"` + + // 弹性IP的外网带宽, 单位为Mbps, 范围 [0-800] + Bandwidth *int `required:"true"` + + // 付费方式, 枚举值为: Year, 按年付费; Month, 按月付费; Dynamic, 按需付费(需开启权限); 默认为获取三种价格 + ChargeType *string `required:"false"` + + // 弹性IP计费方式r. 枚举值为: Traffic, 流量计费; Bandwidth, 带宽计费; "ShareBandwidth",共享带宽模式. 默认为Bandwidth + PayMode *string `required:"false"` +} + +// GetEIPPriceResponse is response schema for GetEIPPrice action +type GetEIPPriceResponse struct { + response.CommonBase + + // 弹性IP价格详情 详情见 EIPPriceDetailSet + PriceSet []EIPPriceDetailSet +} + +// NewGetEIPPriceRequest will create request of GetEIPPrice action. +func (c *UNetClient) NewGetEIPPriceRequest() *GetEIPPriceRequest { + cfg := c.client.GetConfig() + + return &GetEIPPriceRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// GetEIPPrice - 获取弹性IP价格 +func (c *UNetClient) GetEIPPrice(req *GetEIPPriceRequest) (*GetEIPPriceResponse, error) { + var err error + var res GetEIPPriceResponse + + err = c.client.InvokeAction("GetEIPPrice", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eipupgrade_price.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eipupgrade_price.go new file mode 100644 index 0000000000..033625f6c4 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/get_eipupgrade_price.go @@ -0,0 +1,54 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet GetEIPUpgradePrice + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// GetEIPUpgradePriceRequest is request schema for GetEIPUpgradePrice action +type GetEIPUpgradePriceRequest struct { + request.CommonBase + + // 弹性IP的资源ID + EIPId *string `required:"true"` + + // 弹性IP的外网带宽, 单位为Mbps, 范围 [1-800] + Bandwidth *int `required:"true"` +} + +// GetEIPUpgradePriceResponse is response schema for GetEIPUpgradePrice action +type GetEIPUpgradePriceResponse struct { + response.CommonBase + + // 调整带宽后的EIP价格, 单位为"元", 如需退费此处为负值 + Price float32 +} + +// NewGetEIPUpgradePriceRequest will create request of GetEIPUpgradePrice action. +func (c *UNetClient) NewGetEIPUpgradePriceRequest() *GetEIPUpgradePriceRequest { + cfg := c.client.GetConfig() + + return &GetEIPUpgradePriceRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// GetEIPUpgradePrice - 获取弹性IP带宽改动价格 +func (c *UNetClient) GetEIPUpgradePrice(req *GetEIPUpgradePriceRequest) (*GetEIPUpgradePriceResponse, error) { + var err error + var res GetEIPUpgradePriceResponse + + err = c.client.InvokeAction("GetEIPUpgradePrice", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/grant_firewall.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/grant_firewall.go new file mode 100644 index 0000000000..2808fab9ba --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/grant_firewall.go @@ -0,0 +1,54 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet GrantFirewall + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// GrantFirewallRequest is request schema for GrantFirewall action +type GrantFirewallRequest struct { + request.CommonBase + + // 防火墙资源ID + FWId *string `required:"true"` + + // 所应用资源类型,如UHost + ResourceType *string `required:"true"` + + // 所应用资源ID + ResourceId *string `required:"true"` +} + +// GrantFirewallResponse is response schema for GrantFirewall action +type GrantFirewallResponse struct { + response.CommonBase +} + +// NewGrantFirewallRequest will create request of GrantFirewall action. +func (c *UNetClient) NewGrantFirewallRequest() *GrantFirewallRequest { + cfg := c.client.GetConfig() + + return &GrantFirewallRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// GrantFirewall - 将防火墙应用到资源上 +func (c *UNetClient) GrantFirewall(req *GrantFirewallRequest) (*GrantFirewallResponse, error) { + var err error + var res GrantFirewallResponse + + err = c.client.InvokeAction("GrantFirewall", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/modify_eipbandwidth.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/modify_eipbandwidth.go new file mode 100644 index 0000000000..871f1a4892 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/modify_eipbandwidth.go @@ -0,0 +1,51 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet ModifyEIPBandwidth + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// ModifyEIPBandwidthRequest is request schema for ModifyEIPBandwidth action +type ModifyEIPBandwidthRequest struct { + request.CommonBase + + // 弹性IP的资源ID + EIPId *string `required:"true"` + + // 弹性IP的外网带宽, 单位为Mbps. 各地域的带宽值范围如下:流量计费[1-200],带宽计费[1-800] + Bandwidth *int `required:"true"` +} + +// ModifyEIPBandwidthResponse is response schema for ModifyEIPBandwidth action +type ModifyEIPBandwidthResponse struct { + response.CommonBase +} + +// NewModifyEIPBandwidthRequest will create request of ModifyEIPBandwidth action. +func (c *UNetClient) NewModifyEIPBandwidthRequest() *ModifyEIPBandwidthRequest { + cfg := c.client.GetConfig() + + return &ModifyEIPBandwidthRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// ModifyEIPBandwidth - 调整弹性IP的外网带宽 +func (c *UNetClient) ModifyEIPBandwidth(req *ModifyEIPBandwidthRequest) (*ModifyEIPBandwidthResponse, error) { + var err error + var res ModifyEIPBandwidthResponse + + err = c.client.InvokeAction("ModifyEIPBandwidth", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/modify_eipweight.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/modify_eipweight.go new file mode 100644 index 0000000000..7f208c371b --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/modify_eipweight.go @@ -0,0 +1,51 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet ModifyEIPWeight + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// ModifyEIPWeightRequest is request schema for ModifyEIPWeight action +type ModifyEIPWeightRequest struct { + request.CommonBase + + // 弹性IP的资源ID + EIPId *string `required:"true"` + + // 外网出口权重, 范围[0-100] 取值为0时, 该弹性IP不会被使用. 取值为100时, 同主机下只会使用这个弹性IP,其他弹性IP不会被使用 请勿将多个绑定在同一资源的弹性IP设置为相同权重 + Weight *int `required:"true"` +} + +// ModifyEIPWeightResponse is response schema for ModifyEIPWeight action +type ModifyEIPWeightResponse struct { + response.CommonBase +} + +// NewModifyEIPWeightRequest will create request of ModifyEIPWeight action. +func (c *UNetClient) NewModifyEIPWeightRequest() *ModifyEIPWeightRequest { + cfg := c.client.GetConfig() + + return &ModifyEIPWeightRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// ModifyEIPWeight - 修改弹性IP的外网出口权重 +func (c *UNetClient) ModifyEIPWeight(req *ModifyEIPWeightRequest) (*ModifyEIPWeightResponse, error) { + var err error + var res ModifyEIPWeightResponse + + err = c.client.InvokeAction("ModifyEIPWeight", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/release_eip.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_eip.go similarity index 63% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/unet/release_eip.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_eip.go index 19fc9797f8..fddeb8e0b5 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/release_eip.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_eip.go @@ -1,19 +1,23 @@ -//go:generate go run ../../private/cli/gen-api/main.go unet ReleaseEIP +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet ReleaseEIP package unet import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +// ReleaseEIPRequest is request schema for ReleaseEIP action type ReleaseEIPRequest struct { request.CommonBase - // Required, 弹性IP的资源ID - EIPId string + // 弹性IP的资源ID + EIPId *string `required:"true"` } +// ReleaseEIPResponse is response schema for ReleaseEIP action type ReleaseEIPResponse struct { response.CommonBase } @@ -24,8 +28,8 @@ func (c *UNetClient) NewReleaseEIPRequest() *ReleaseEIPRequest { return &ReleaseEIPRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_share_bandwidth.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_share_bandwidth.go new file mode 100644 index 0000000000..b195dcf043 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_share_bandwidth.go @@ -0,0 +1,54 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet ReleaseShareBandwidth + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// ReleaseShareBandwidthRequest is request schema for ReleaseShareBandwidth action +type ReleaseShareBandwidthRequest struct { + request.CommonBase + + // 共享带宽ID + ShareBandwidthId *string `required:"true"` + + // 关闭共享带宽后,各EIP恢复为的带宽值 + EIPBandwidth *int `required:"true"` + + // Bandwidth 带宽计费, Traffic 转流量计费 + PayMode *string `required:"false"` +} + +// ReleaseShareBandwidthResponse is response schema for ReleaseShareBandwidth action +type ReleaseShareBandwidthResponse struct { + response.CommonBase +} + +// NewReleaseShareBandwidthRequest will create request of ReleaseShareBandwidth action. +func (c *UNetClient) NewReleaseShareBandwidthRequest() *ReleaseShareBandwidthRequest { + cfg := c.client.GetConfig() + + return &ReleaseShareBandwidthRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// ReleaseShareBandwidth - 关闭共享带宽 +func (c *UNetClient) ReleaseShareBandwidth(req *ReleaseShareBandwidthRequest) (*ReleaseShareBandwidthResponse, error) { + var err error + var res ReleaseShareBandwidthResponse + + err = c.client.InvokeAction("ReleaseShareBandwidth", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_vip.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_vip.go new file mode 100644 index 0000000000..ad73e51666 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/release_vip.go @@ -0,0 +1,51 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet ReleaseVIP + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// ReleaseVIPRequest is request schema for ReleaseVIP action +type ReleaseVIPRequest struct { + request.CommonBase + + // 可用区 + Zone *string `required:"false"` + + // 内网VIP的id + VIPId *string `required:"true"` +} + +// ReleaseVIPResponse is response schema for ReleaseVIP action +type ReleaseVIPResponse struct { + response.CommonBase +} + +// NewReleaseVIPRequest will create request of ReleaseVIP action. +func (c *UNetClient) NewReleaseVIPRequest() *ReleaseVIPRequest { + cfg := c.client.GetConfig() + + return &ReleaseVIPRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// ReleaseVIP - 释放VIP资源 +func (c *UNetClient) ReleaseVIP(req *ReleaseVIPRequest) (*ReleaseVIPResponse, error) { + var err error + var res ReleaseVIPResponse + + err = c.client.InvokeAction("ReleaseVIP", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/resize_share_bandwidth.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/resize_share_bandwidth.go new file mode 100644 index 0000000000..c4c39d9a0b --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/resize_share_bandwidth.go @@ -0,0 +1,51 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet ResizeShareBandwidth + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// ResizeShareBandwidthRequest is request schema for ResizeShareBandwidth action +type ResizeShareBandwidthRequest struct { + request.CommonBase + + // 带宽值,单位为Mb,范围 [20-5000] (最大值受地域限制) + ShareBandwidth *int `required:"true"` + + // 共享带宽的Id + ShareBandwidthId *string `required:"true"` +} + +// ResizeShareBandwidthResponse is response schema for ResizeShareBandwidth action +type ResizeShareBandwidthResponse struct { + response.CommonBase +} + +// NewResizeShareBandwidthRequest will create request of ResizeShareBandwidth action. +func (c *UNetClient) NewResizeShareBandwidthRequest() *ResizeShareBandwidthRequest { + cfg := c.client.GetConfig() + + return &ResizeShareBandwidthRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// ResizeShareBandwidth - 调整共享带宽的带宽值 +func (c *UNetClient) ResizeShareBandwidth(req *ResizeShareBandwidthRequest) (*ResizeShareBandwidthResponse, error) { + var err error + var res ResizeShareBandwidthResponse + + err = c.client.InvokeAction("ResizeShareBandwidth", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/set_eippay_mode.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/set_eippay_mode.go new file mode 100644 index 0000000000..7faa4405c9 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/set_eippay_mode.go @@ -0,0 +1,54 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet SetEIPPayMode + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// SetEIPPayModeRequest is request schema for SetEIPPayMode action +type SetEIPPayModeRequest struct { + request.CommonBase + + // 弹性IP的资源Id + EIPId *string `required:"true"` + + // 计费模式. 枚举值:"Traffic", 流量计费模式; "Bandwidth", 带宽计费模式 + PayMode *string `required:"true"` + + // 调整的目标带宽值, 单位Mbps. 各地域的带宽值范围如下: 流量计费[1-200],其余情况[1-800] + Bandwidth *int `required:"true"` +} + +// SetEIPPayModeResponse is response schema for SetEIPPayMode action +type SetEIPPayModeResponse struct { + response.CommonBase +} + +// NewSetEIPPayModeRequest will create request of SetEIPPayMode action. +func (c *UNetClient) NewSetEIPPayModeRequest() *SetEIPPayModeRequest { + cfg := c.client.GetConfig() + + return &SetEIPPayModeRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// SetEIPPayMode - 设置弹性IP计费模式, 切换时会涉及付费/退费. +func (c *UNetClient) SetEIPPayMode(req *SetEIPPayModeRequest) (*SetEIPPayModeResponse, error) { + var err error + var res SetEIPPayModeResponse + + err = c.client.InvokeAction("SetEIPPayMode", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} 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 new file mode 100644 index 0000000000..8d511701a7 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_eipaddr_set.go @@ -0,0 +1,16 @@ +package unet + +/* + EIPAddrSet - DescribeShareBandwidth + + this model is auto created by ucloud code generater for open api, + you can also see https://docs.ucloud.cn for detail. +*/ +type EIPAddrSet struct { + + // 运营商信息, 枚举值为: Telecom 电信; Unicom: 联通; Duplet: 双线; Bgp: BGP; International: 国际. + OperatorName string + + // 弹性IP地址 + IP string +} 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 new file mode 100644 index 0000000000..37f03b9af9 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_eippay_mode_set.go @@ -0,0 +1,16 @@ +package unet + +/* + EIPPayModeSet - GetEIPPayModeEIP + + 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 { + + // EIP的资源ID + EIPId string + + // EIP的计费模式. 枚举值为:Bandwidth, 带宽计费;Traffic, 流量计费; "ShareBandwidth",共享带宽模式 + EIPPayMode string +} 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 new file mode 100644 index 0000000000..ab2beaa15b --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_eipprice_detail_set.go @@ -0,0 +1,19 @@ +package unet + +/* + EIPPriceDetailSet - GetEIPPrice + + 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 { + + // 弹性IP付费方式 + ChargeType string + + // 弹性IP价格, 单位"元" + Price float32 + + // 资源有效期, 以Unix Timestamp表示 + PurchaseValue int +} 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 new file mode 100644 index 0000000000..6157ff5d84 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_firewall_data_set.go @@ -0,0 +1,37 @@ +package unet + +/* + FirewallDataSet - DescribeFirewall + + 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 { + + // 防火墙名称 + Name string + + // 防火墙业务组 + Tag string + + // 防火墙备注 + Remark string + + // 防火墙绑定资源数量 + ResourceCount int + + // 防火墙组创建时间,格式为Unix Timestamp + CreateTime int + + // 防火墙组类型,枚举值为: "user defined", 用户自定义防火墙; "recommend web", 默认Web防火墙; "recommend non web", 默认非Web防火墙 + Type string + + // 防火墙组中的规则列表,参见 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 new file mode 100644 index 0000000000..fa1e9e2fc3 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_firewall_rule_set.go @@ -0,0 +1,25 @@ +package unet + +/* + FirewallRuleSet - DescribeFirewall + + 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 { + + // 源地址 + SrcIP string + + // 优先级 + Priority string + + // 协议类型 + ProtocolType string + + // 目标端口 + DstPort string + + // 防火墙动作 + RuleAction string +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_resource_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_resource_set.go new file mode 100644 index 0000000000..f66ad22612 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_resource_set.go @@ -0,0 +1,34 @@ +package unet + +/* + ResourceSet - 资源信息 + + 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 { + + // 名称 + Name string + + // 内网IP + PrivateIP string + + // 备注 + Remark string + + // 绑定该防火墙的资源id + ResourceID string + + // 绑定资源的资源类型 + ResourceType string + + // 状态 + Status string + + // 业务组 + Tag string + + // 可用区 + Zone string +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/types/share_bandwidth_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_share_bandwidth_set.go similarity index 51% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/unet/types/share_bandwidth_set.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_share_bandwidth_set.go index 01d3500679..8881547699 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/types/share_bandwidth_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_share_bandwidth_set.go @@ -1,6 +1,11 @@ -package types +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. +*/ 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 new file mode 100644 index 0000000000..ef720e98dd --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_allocate_eipset.go @@ -0,0 +1,16 @@ +package unet + +/* + UnetAllocateEIPSet - AllocateEIP + + 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 { + + // 申请到的EIP资源ID + EIPId string + + // 申请到的IPv4地址. + EIPAddr []UnetEIPAddrSet +} 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 new file mode 100644 index 0000000000..c742ca6a53 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_bandwidth_package_set.go @@ -0,0 +1,31 @@ +package unet + +/* + UnetBandwidthPackageSet - DescribeBandwidthPackage + + 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 { + + // 带宽包的资源ID + BandwidthPackageId string + + // 生效时间, 格式为 Unix Timestamp + EnableTime int + + // 失效时间, 格式为 Unix Timestamp + DisableTime int + + // 创建时间, 格式为 Unix Timestamp + CreateTime int + + // 带宽包的临时带宽值, 单位Mbps + Bandwidth int + + // 带宽包所绑定弹性IP的资源ID + EIPId string + + // 带宽包所绑定弹性IP的详细信息,只有当EIPId对应双线IP时, EIPAddr的长度为2, 其他情况, EIPAddr长度均为1.参见 EIPAddrSet + EIPAddr []EIPAddrSet +} 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 new file mode 100644 index 0000000000..731dcc805e --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_bandwidth_usage_eipset.go @@ -0,0 +1,16 @@ +package unet + +/* + UnetBandwidthUsageEIPSet - DescribeBandwidthUsage + + 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 { + + // 最近5分钟带宽用量, 单位Mbps + CurBandwidth float32 + + // 弹性IP资源ID + EIPId string +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/types/unet_eipaddr_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipaddr_set.go similarity index 54% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/unet/types/unet_eipaddr_set.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipaddr_set.go index 73f8a3f90c..0da957fda0 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/types/unet_eipaddr_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipaddr_set.go @@ -1,6 +1,11 @@ -package types +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. +*/ type UnetEIPAddrSet struct { // 运营商信息如: 电信: Telecom, 联通: Unicom, 国际: International, Duplet: 双线IP(电信+联通), BGP: Bgp diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/types/unet_eipresource_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipresource_set.go similarity index 64% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/unet/types/unet_eipresource_set.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipresource_set.go index df57e70647..24bc7cbb18 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/types/unet_eipresource_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipresource_set.go @@ -1,6 +1,11 @@ -package types +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. +*/ type UnetEIPResourceSet struct { // 已绑定的资源类型, 枚举值为: uhost, 云主机;vrouter:虚拟路由器;ulb:负载均衡器 diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/types/unet_eipset.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipset.go similarity index 90% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/unet/types/unet_eipset.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipset.go index cbfc800518..670c944853 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/unet/types/unet_eipset.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_eipset.go @@ -1,6 +1,11 @@ -package types +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. +*/ type UnetEIPSet struct { // 弹性IP的资源ID 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 new file mode 100644 index 0000000000..540b68ed13 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_unet_share_bandwidth_set.go @@ -0,0 +1,34 @@ +package unet + +/* + UnetShareBandwidthSet - DescribeShareBandwidth + + 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 { + + // 共享带宽值(预付费)/共享带宽峰值(后付费), 单位Mbps + Bandwidth int + + // 共享带宽的资源ID + ShareBandwidthId string + + // 付费方式, 预付费:Year 按年,Month 按月,Dynamic 按需;后付费:PostPay(按月) + ChargeType string + + // 创建时间, 格式为Unix Timestamp + CreateTime int + + // 过期时间, 格式为Unix Timestamp + ExpireTime int + + // EIP信息,详情见 EIPAddrSet + EIPSet []EIPAddrSet + + // 共享带宽保底值(后付费) + BandwidthGuarantee int + + // 共享带宽后付费开始计费时间(后付费) + PostPayStartTime int +} 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 new file mode 100644 index 0000000000..d81fb7dbf6 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_vipdetail_set.go @@ -0,0 +1,31 @@ +package unet + +/* + VIPDetailSet - VIPDetailSet + + 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 { + + // 虚拟ip id + VIPId string + + // 创建时间 + CreateTime string + + // 地域 + Zone string + + // 真实主机ip + RealIp string + + // 虚拟ip + VIP string + + // 子网id + SubnetId string + + // VPC id + VPCId 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 new file mode 100644 index 0000000000..14cf3f77d6 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/types_vipset.go @@ -0,0 +1,19 @@ +package unet + +/* + VIPSet - VIPSet + + 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 { + + // 虚拟ip + VIP string + + // 虚拟ip id + VIPId string + + // VPC id + VPCId string +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/un_bind_eip.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/un_bind_eip.go new file mode 100644 index 0000000000..fabe77ff29 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/un_bind_eip.go @@ -0,0 +1,54 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet UnBindEIP + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// UnBindEIPRequest is request schema for UnBindEIP action +type UnBindEIPRequest struct { + request.CommonBase + + // 弹性IP的资源Id + EIPId *string `required:"true"` + + // 弹性IP请求解绑的资源类型, 枚举值为: uhost: 云主机; vrouter: 虚拟路由器; ulb, 负载均衡器 upm: 物理机; hadoophost: 大数据集群;fortresshost:堡垒机;udockhost:容器;udhost:私有专区主机;natgw:natgw;udb:udb;vpngw:ipsec vpn;ucdr:云灾备;dbaudit:数据库审计; + ResourceType *string `required:"true"` + + // 弹性IP请求解绑的资源ID + ResourceId *string `required:"true"` +} + +// UnBindEIPResponse is response schema for UnBindEIP action +type UnBindEIPResponse struct { + response.CommonBase +} + +// NewUnBindEIPRequest will create request of UnBindEIP action. +func (c *UNetClient) NewUnBindEIPRequest() *UnBindEIPRequest { + cfg := c.client.GetConfig() + + return &UnBindEIPRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// UnBindEIP - 将弹性IP从资源上解绑 +func (c *UNetClient) UnBindEIP(req *UnBindEIPRequest) (*UnBindEIPResponse, error) { + var err error + var res UnBindEIPResponse + + err = c.client.InvokeAction("UnBindEIP", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_eipattribute.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_eipattribute.go new file mode 100644 index 0000000000..7c20525f9e --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_eipattribute.go @@ -0,0 +1,57 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet UpdateEIPAttribute + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// UpdateEIPAttributeRequest is request schema for UpdateEIPAttribute action +type UpdateEIPAttributeRequest struct { + request.CommonBase + + // EIP资源ID + EIPId *string `required:"true"` + + // 名字(Name Tag Remark都为空则报错) + Name *string `required:"false"` + + // 业务 + Tag *string `required:"false"` + + // 备注 + Remark *string `required:"false"` +} + +// UpdateEIPAttributeResponse is response schema for UpdateEIPAttribute action +type UpdateEIPAttributeResponse struct { + response.CommonBase +} + +// NewUpdateEIPAttributeRequest will create request of UpdateEIPAttribute action. +func (c *UNetClient) NewUpdateEIPAttributeRequest() *UpdateEIPAttributeRequest { + cfg := c.client.GetConfig() + + return &UpdateEIPAttributeRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// UpdateEIPAttribute - 更新弹性IP名称,业务组,备注等属性字段 +func (c *UNetClient) UpdateEIPAttribute(req *UpdateEIPAttributeRequest) (*UpdateEIPAttributeResponse, error) { + var err error + var res UpdateEIPAttributeResponse + + err = c.client.InvokeAction("UpdateEIPAttribute", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} 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 new file mode 100644 index 0000000000..df913848b5 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_firewall.go @@ -0,0 +1,54 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet UpdateFirewall + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// UpdateFirewallRequest is request schema for UpdateFirewall action +type UpdateFirewallRequest struct { + request.CommonBase + + // 防火墙资源ID + FWId *string `required:"true"` + + // 防火墙规则,例如:TCP|22|192.168.1.1/22|DROP|LOW,第一个参数代表协议:第二个参数代表端口号,第三个参数为ip,第四个参数为ACCEPT(接受)和DROP(拒绝),第五个参数优先级:HIGH(高),MEDIUM(中),LOW(低) + Rule []string `required:"true"` +} + +// UpdateFirewallResponse is response schema for UpdateFirewall action +type UpdateFirewallResponse struct { + response.CommonBase + + // 防火墙id + FWId string +} + +// NewUpdateFirewallRequest will create request of UpdateFirewall action. +func (c *UNetClient) NewUpdateFirewallRequest() *UpdateFirewallRequest { + cfg := c.client.GetConfig() + + return &UpdateFirewallRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// UpdateFirewall - 更新防火墙规则 +func (c *UNetClient) UpdateFirewall(req *UpdateFirewallRequest) (*UpdateFirewallResponse, error) { + var err error + var res UpdateFirewallResponse + + err = c.client.InvokeAction("UpdateFirewall", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_firewall_attribute.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_firewall_attribute.go new file mode 100644 index 0000000000..250c1c6443 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_firewall_attribute.go @@ -0,0 +1,57 @@ +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api UNet UpdateFirewallAttribute + +package unet + +import ( + "github.com/ucloud/ucloud-sdk-go/sdk" + "github.com/ucloud/ucloud-sdk-go/sdk/request" + "github.com/ucloud/ucloud-sdk-go/sdk/response" +) + +// UpdateFirewallAttributeRequest is request schema for UpdateFirewallAttribute action +type UpdateFirewallAttributeRequest struct { + request.CommonBase + + // 防火墙资源ID + FWId *string `required:"true"` + + // 防火墙名称,默认为空,为空则不做修改。Name,Tag,Remark必须填写1个及以上 + Name *string `required:"false"` + + // 防火墙业务组,默认为空,为空则不做修改。Name,Tag,Remark必须填写1个及以上 + Tag *string `required:"false"` + + // 防火墙备注,默认为空,为空则不做修改。Name,Tag,Remark必须填写1个及以上 + Remark *string `required:"false"` +} + +// UpdateFirewallAttributeResponse is response schema for UpdateFirewallAttribute action +type UpdateFirewallAttributeResponse struct { + response.CommonBase +} + +// NewUpdateFirewallAttributeRequest will create request of UpdateFirewallAttribute action. +func (c *UNetClient) NewUpdateFirewallAttributeRequest() *UpdateFirewallAttributeRequest { + cfg := c.client.GetConfig() + + return &UpdateFirewallAttributeRequest{ + CommonBase: request.CommonBase{ + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), + }, + } +} + +// UpdateFirewallAttribute - 更新防火墙规则 +func (c *UNetClient) UpdateFirewallAttribute(req *UpdateFirewallAttributeRequest) (*UpdateFirewallAttributeResponse, error) { + var err error + var res UpdateFirewallAttributeResponse + + err = c.client.InvokeAction("UpdateFirewallAttribute", req, &res) + if err != nil { + return nil, err + } + + return &res, nil +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/add_vpcnetwork.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/add_vpcnetwork.go similarity index 60% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/add_vpcnetwork.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/add_vpcnetwork.go index ed2041d9ab..1fe27f889a 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/add_vpcnetwork.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/add_vpcnetwork.go @@ -1,22 +1,26 @@ -//go:generate go run ../../private/cli/gen-api/main.go vpc AddVPCNetwork +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api VPC AddVPCNetwork package vpc import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +// AddVPCNetworkRequest is request schema for AddVPCNetwork action type AddVPCNetworkRequest struct { request.CommonBase - // Required, 源VPC短ID - VPCId string + // 源VPC短ID + VPCId *string `required:"true"` - // Required, 增加网段 - Network []string + // 增加网段 + Network []string `required:"true"` } +// AddVPCNetworkResponse is response schema for AddVPCNetwork action type AddVPCNetworkResponse struct { response.CommonBase } @@ -27,8 +31,8 @@ func (c *VPCClient) NewAddVPCNetworkRequest() *AddVPCNetworkRequest { return &AddVPCNetworkRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/client.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/client.go similarity index 74% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/client.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/client.go index 555deea89a..c62ec2fff1 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/client.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/client.go @@ -9,7 +9,7 @@ type VPCClient struct { client *sdk.Client } -func NewClient(config *sdk.ClientConfig, credential *auth.Credential) *VPCClient { +func NewClient(config *sdk.Config, credential *auth.Credential) *VPCClient { client := sdk.NewClient(config, credential) return &VPCClient{ client: client, diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/create_subnet.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_subnet.go similarity index 50% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/create_subnet.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_subnet.go index 67289bddc5..d7aef26296 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/create_subnet.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_subnet.go @@ -1,34 +1,38 @@ -//go:generate go run ../../private/cli/gen-api/main.go vpc CreateSubnet +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api VPC CreateSubnet package vpc import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +// CreateSubnetRequest is request schema for CreateSubnet action type CreateSubnetRequest struct { request.CommonBase - // Required, VPC资源ID - VPCId string + // VPC资源ID + VPCId *string `required:"true"` - // Required, 子网网络地址,例如192.168.0.0 - Subnet string + // 子网网络地址,例如192.168.0.0 + Subnet *string `required:"true"` - // Optional, 子网网络号位数,默认为24 - Netmask int + // 子网网络号位数,默认为24 + Netmask *int `required:"false"` - // Optional, 子网名称,默认为Subnet - SubnetName string + // 子网名称,默认为Subnet + SubnetName *string `required:"false"` - // Optional, 业务组名称,默认为Default - Tag string + // 业务组名称,默认为Default + Tag *string `required:"false"` - // Optional, 备注 - Remark string + // 备注 + Remark *string `required:"false"` } +// CreateSubnetResponse is response schema for CreateSubnet action type CreateSubnetResponse struct { response.CommonBase @@ -42,8 +46,8 @@ func (c *VPCClient) NewCreateSubnetRequest() *CreateSubnetRequest { return &CreateSubnetRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/create_vpc.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_vpc.go similarity index 56% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/create_vpc.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_vpc.go index bcf7b6dfff..fb7d3f6ce6 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/create_vpc.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_vpc.go @@ -1,28 +1,32 @@ -//go:generate go run ../../private/cli/gen-api/main.go vpc CreateVPC +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api VPC CreateVPC package vpc import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +// CreateVPCRequest is request schema for CreateVPC action type CreateVPCRequest struct { request.CommonBase - // Required, VPC名称 - Name string + // VPC名称 + Name *string `required:"true"` - // Required, VPC网段 - Network []string + // VPC网段 + Network []string `required:"true"` - // Optional, 业务组名称 - Tag string + // 业务组名称 + Tag *string `required:"false"` - // Optional, 备注 - Remark string + // 备注 + Remark *string `required:"false"` } +// CreateVPCResponse is response schema for CreateVPC action type CreateVPCResponse struct { response.CommonBase @@ -36,8 +40,8 @@ func (c *VPCClient) NewCreateVPCRequest() *CreateVPCRequest { return &CreateVPCRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/create_vpcintercom.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_vpcintercom.go similarity index 52% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/create_vpcintercom.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_vpcintercom.go index 2dad2a694f..fbddfeb846 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/create_vpcintercom.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_vpcintercom.go @@ -1,28 +1,32 @@ -//go:generate go run ../../private/cli/gen-api/main.go vpc CreateVPCIntercom +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api VPC CreateVPCIntercom package vpc import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +// CreateVPCIntercomRequest is request schema for CreateVPCIntercom action type CreateVPCIntercomRequest struct { request.CommonBase - // Required, 源VPC短ID - VPCId string + // 源VPC短ID + VPCId *string `required:"true"` - // Required, 目的VPC短ID - DstVPCId string + // 目的VPC短ID + DstVPCId *string `required:"true"` - // Optional, 目的所在地域(如果目的VPC和源VPC不在同一个地域,两个地域需要建立跨域通道,且该字段必选) - DstRegion string + // 目的所在地域(如果目的VPC和源VPC不在同一个地域,两个地域需要建立跨域通道,且该字段必选) + DstRegion *string `required:"false"` - // Optional, 目的项目ID - DstProjectId string + // 目的项目ID + DstProjectId *string `required:"false"` } +// CreateVPCIntercomResponse is response schema for CreateVPCIntercom action type CreateVPCIntercomResponse struct { response.CommonBase } @@ -33,8 +37,8 @@ func (c *VPCClient) NewCreateVPCIntercomRequest() *CreateVPCIntercomRequest { return &CreateVPCIntercomRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/delete_subnet.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_subnet.go similarity index 62% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/delete_subnet.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_subnet.go index 4155f7c5f0..cdb5edda99 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/delete_subnet.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_subnet.go @@ -1,19 +1,23 @@ -//go:generate go run ../../private/cli/gen-api/main.go vpc DeleteSubnet +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api VPC DeleteSubnet package vpc import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +// DeleteSubnetRequest is request schema for DeleteSubnet action type DeleteSubnetRequest struct { request.CommonBase - // Required, 子网ID - SubnetId string + // 子网ID + SubnetId *string `required:"true"` } +// DeleteSubnetResponse is response schema for DeleteSubnet action type DeleteSubnetResponse struct { response.CommonBase } @@ -24,8 +28,8 @@ func (c *VPCClient) NewDeleteSubnetRequest() *DeleteSubnetRequest { return &DeleteSubnetRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/delete_vpc.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_vpc.go similarity index 62% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/delete_vpc.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_vpc.go index 1cb2df40e2..5a503a0900 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/delete_vpc.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_vpc.go @@ -1,19 +1,23 @@ -//go:generate go run ../../private/cli/gen-api/main.go vpc DeleteVPC +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api VPC DeleteVPC package vpc import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +// DeleteVPCRequest is request schema for DeleteVPC action type DeleteVPCRequest struct { request.CommonBase - // Required, VPC资源Id - VPCId string + // VPC资源Id + VPCId *string `required:"true"` } +// DeleteVPCResponse is response schema for DeleteVPC action type DeleteVPCResponse struct { response.CommonBase } @@ -24,8 +28,8 @@ func (c *VPCClient) NewDeleteVPCRequest() *DeleteVPCRequest { return &DeleteVPCRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/delete_vpcintercom.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_vpcintercom.go similarity index 83% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/delete_vpcintercom.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_vpcintercom.go index 380869ce79..272f9d3a5f 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/delete_vpcintercom.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_vpcintercom.go @@ -1,8 +1,7 @@ -//go:generate go run ../../private/cli/gen-api/main.go vpc DeleteVPCIntercom - package vpc import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) @@ -11,16 +10,16 @@ type DeleteVPCIntercomRequest struct { request.CommonBase // Required, 源VPC短ID - VPCId string + VPCId *string // Required, 目的VPC短ID - DstVPCId string + DstVPCId *string // Optional, 目的所在地域 - DstRegion string + DstRegion *string // Optional, 目的项目ID(如果目的VPC和源VPC不在同一个地域,两个地域需要建立跨域通道,且该字段必选) - DstProjectId string + DstProjectId *string // uxiao is int } type DeleteVPCIntercomResponse struct { @@ -33,8 +32,8 @@ func (c *VPCClient) NewDeleteVPCIntercomRequest() *DeleteVPCIntercomRequest { return &DeleteVPCIntercomRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/describe_subnet.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_subnet.go similarity index 50% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/describe_subnet.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_subnet.go index 20f079e7e2..de66f1f949 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/describe_subnet.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_subnet.go @@ -1,38 +1,41 @@ -//go:generate go run ../../private/cli/gen-api/main.go vpc DescribeSubnet +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api VPC DescribeSubnet package vpc import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" - . "github.com/ucloud/ucloud-sdk-go/service/vpc/types" ) +// DescribeSubnetRequest is request schema for DescribeSubnet action type DescribeSubnetRequest struct { request.CommonBase - // Optional, 子网id数组,适用于一次查询多个子网信息 - SubnetIds []string + // 子网id数组,适用于一次查询多个子网信息 + SubnetIds []string `required:"false"` - // Optional, 子网id,适用于一次查询一个子网信息 - SubnetId string + // 子网id,适用于一次查询一个子网信息 + SubnetId *string `required:"false"` - // Optional, VPC资源id - VPCId string + // VPC资源id + VPCId *string `required:"false"` - // Optional, 业务组名称,默认为Default - Tag string + // 业务组名称,默认为Default + Tag *string `required:"false"` - // Optional, 业务组 - BusinessId string + // 业务组 + BusinessId *string `required:"false"` - // Optional, 默认为0 - Offset int + // 默认为0 + Offset *int `required:"false"` - // Optional, 默认为20 - Limit int + // 默认为20 + Limit *int `required:"false"` } +// DescribeSubnetResponse is response schema for DescribeSubnet action type DescribeSubnetResponse struct { response.CommonBase @@ -49,8 +52,8 @@ func (c *VPCClient) NewDescribeSubnetRequest() *DescribeSubnetRequest { return &DescribeSubnetRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/describe_subnet_resource.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_subnet_resource.go similarity index 59% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/describe_subnet_resource.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_subnet_resource.go index 750be23dec..9e857c2188 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/describe_subnet_resource.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_subnet_resource.go @@ -1,29 +1,32 @@ -//go:generate go run ../../private/cli/gen-api/main.go vpc DescribeSubnetResource +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api VPC DescribeSubnetResource package vpc import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" - . "github.com/ucloud/ucloud-sdk-go/service/vpc/types" ) +// DescribeSubnetResourceRequest is request schema for DescribeSubnetResource action type DescribeSubnetResourceRequest struct { request.CommonBase - // Required, 子网id - SubnetId string + // 子网id + SubnetId *string `required:"true"` - // Optional, 资源类型 - ResourceType string + // 资源类型 + ResourceType *string `required:"false"` - // Optional, 分页号 - Offset int + // 分页号 + Offset *int `required:"false"` - // Optional, 单页limit - Limit int + // 单页limit + Limit *int `required:"false"` } +// DescribeSubnetResourceResponse is response schema for DescribeSubnetResource action type DescribeSubnetResourceResponse struct { response.CommonBase @@ -40,8 +43,8 @@ func (c *VPCClient) NewDescribeSubnetResourceRequest() *DescribeSubnetResourceRe return &DescribeSubnetResourceRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/describe_vpc.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_vpc.go similarity index 58% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/describe_vpc.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_vpc.go index 74c1222df6..57b5cf439b 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/describe_vpc.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_vpc.go @@ -1,28 +1,31 @@ -//go:generate go run ../../private/cli/gen-api/main.go vpc DescribeVPC +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api VPC DescribeVPC package vpc import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" - . "github.com/ucloud/ucloud-sdk-go/service/vpc/types" ) +// DescribeVPCRequest is request schema for DescribeVPC action type DescribeVPCRequest struct { request.CommonBase - // Optional, VPCId - VPCIds []string + // VPCId + VPCIds []string `required:"false"` - // Optional, 业务组名称 - Tag string + // 业务组名称 + Tag *string `required:"false"` } +// DescribeVPCResponse is response schema for DescribeVPC action type DescribeVPCResponse struct { response.CommonBase - // - DataSet []VPCInfoSet + // vpc信息 + DataSet []VPCInfo } // NewDescribeVPCRequest will create request of DescribeVPC action. @@ -31,8 +34,8 @@ func (c *VPCClient) NewDescribeVPCRequest() *DescribeVPCRequest { return &DescribeVPCRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/describe_vpcintercom.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_vpcintercom.go similarity index 57% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/describe_vpcintercom.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_vpcintercom.go index 8909a69538..e5315cb526 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/describe_vpcintercom.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_vpcintercom.go @@ -1,45 +1,34 @@ -//go:generate go run ../../private/cli/gen-api/main.go vpc DescribeVPCIntercom +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api VPC DescribeVPCIntercom package vpc import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +// DescribeVPCIntercomRequest is request schema for DescribeVPCIntercom action type DescribeVPCIntercomRequest struct { request.CommonBase - // Required, VPC短ID - VPCId string + // VPC短ID + VPCId *string `required:"true"` - // Optional, 目的地域 - DstRegion string + // 目的地域 + DstRegion *string `required:"false"` - // Optional, 目的项目ID - DstProjectId string + // 目的项目ID + DstProjectId *string `required:"false"` } +// DescribeVPCIntercomResponse is response schema for DescribeVPCIntercom action type DescribeVPCIntercomResponse struct { response.CommonBase - // VPC的地址空间 - Network []string - - // 所属地域 - DstRegion string - - // VPC名字 - Name string - - // 项目Id - ProjectId string - - // vpc_id - VPCId string - - // 业务组(未分组显示为 Default) - Tag string + // 联通VPC信息数组 + DataSet []VPCIntercomInfo } // NewDescribeVPCIntercomRequest will create request of DescribeVPCIntercom action. @@ -48,8 +37,8 @@ func (c *VPCClient) NewDescribeVPCIntercomRequest() *DescribeVPCIntercomRequest return &DescribeVPCIntercomRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } 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 new file mode 100644 index 0000000000..b1817d5ca7 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_resource_info.go @@ -0,0 +1,22 @@ +package vpc + +/* + ResourceInfo - 资源信息 + + 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 { + + // 资源名称 + Name string + + // 资源id + ResourceId string + + // 资源类型 + ResourceType int + + // ip地址 + IP string +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_vpcinfo.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_vpcinfo.go new file mode 100644 index 0000000000..ec41d70baf --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_vpcinfo.go @@ -0,0 +1,29 @@ +package vpc + +// VPCInfo - vpc信息 +type VPCInfo struct { + + // 业务组 + Tag string + + // 创建时间 + CreateTime int + + // vpc名称 + Name string + + // vpc地址空间 + Network []string + + // vpc地址空间信息 + NetworkInfo []VPCNetworkInfo + + // vpc中子网数量 + SubnetCount int + + // 更新时间 + UpdateTime int + + // vpc的资源ID + VPCId string +} 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 new file mode 100644 index 0000000000..f18037540a --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_vpcintercom_info.go @@ -0,0 +1,28 @@ +package vpc + +/* + VPCIntercomInfo - + + 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 { + + // 项目Id + ProjectId string + + // VPC的地址空间 + Network []string + + // 所属地域 + DstRegion string + + // VPC名字 + Name string + + // VPCId + VPCId string + + // 业务组(未分组显示为 Default) + Tag string +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_vpcnetwork_info.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_vpcnetwork_info.go new file mode 100644 index 0000000000..f150a673a9 --- /dev/null +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_vpcnetwork_info.go @@ -0,0 +1,11 @@ +package vpc + +// VPCNetworkInfo - vpc地址空间信息 +type VPCNetworkInfo struct { + + // 地址空间段 + Network string + + // 地址空间中子网数量 + SubnetCount int +} diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/types/vpcsubnet_info_set.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_vpcsubnet_info_set.go similarity index 71% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/types/vpcsubnet_info_set.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_vpcsubnet_info_set.go index 76e9ec3bb1..1dff1c0511 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/types/vpcsubnet_info_set.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_vpcsubnet_info_set.go @@ -1,6 +1,11 @@ -package types +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. +*/ type VPCSubnetInfoSet struct { // VPC id @@ -28,7 +33,7 @@ type VPCSubnetInfoSet struct { Tag string // 子网类型 - SubnetType int // uxiao is string + SubnetType int // 子网网段 Subnet string diff --git a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/update_subnet_attribute.go b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/update_subnet_attribute.go similarity index 56% rename from vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/update_subnet_attribute.go rename to vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/update_subnet_attribute.go index a4580a5f9f..d4fd412773 100644 --- a/vendor/github.com/ucloud/ucloud-sdk-go/service/vpc/update_subnet_attribute.go +++ b/vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/update_subnet_attribute.go @@ -1,25 +1,29 @@ -//go:generate go run ../../private/cli/gen-api/main.go vpc UpdateSubnetAttribute +//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. +//go:generate ucloud-gen-go-api VPC UpdateSubnetAttribute package vpc import ( + "github.com/ucloud/ucloud-sdk-go/sdk" "github.com/ucloud/ucloud-sdk-go/sdk/request" "github.com/ucloud/ucloud-sdk-go/sdk/response" ) +// UpdateSubnetAttributeRequest is request schema for UpdateSubnetAttribute action type UpdateSubnetAttributeRequest struct { request.CommonBase - // Required, 子网ID - SubnetId string + // 子网ID + SubnetId *string `required:"true"` - // Optional, 子网名称(如果Name不填写,Tag必须填写) - Name string + // 子网名称(如果Name不填写,Tag必须填写) + Name *string `required:"false"` - // Optional, 业务组名称(如果Tag不填写,Name必须填写) - Tag string + // 业务组名称(如果Tag不填写,Name必须填写) + Tag *string `required:"false"` } +// UpdateSubnetAttributeResponse is response schema for UpdateSubnetAttribute action type UpdateSubnetAttributeResponse struct { response.CommonBase } @@ -30,8 +34,8 @@ func (c *VPCClient) NewUpdateSubnetAttributeRequest() *UpdateSubnetAttributeRequ return &UpdateSubnetAttributeRequest{ CommonBase: request.CommonBase{ - Region: cfg.Region, - ProjectId: cfg.ProjectId, + Region: sdk.String(cfg.Region), + ProjectId: sdk.String(cfg.ProjectId), }, } } diff --git a/vendor/vendor.json b/vendor/vendor.json index 971b06996c..b651a43eae 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -41,148 +41,112 @@ "versionExact": "v1.2.0" }, { - "checksumSHA1": "zHmEQb9FRs60HHDF5J2H+ZuVtQE=", + "checksumSHA1": "jK3uwh4rFn9LP7STDqPRer+lR8A=", "path": "github.com/spf13/cobra", - "revision": "06f6db4b7fae3c7ca087b54962027d824753e4b3", - "revisionTime": "2018-08-23T13:01:45Z" + "revision": "8d114be902bc9f08717804830a55c48378108a28", + "revisionTime": "2018-09-15T22:22:04Z" }, { - "checksumSHA1": "egfheShGROUlwCTjbXjQJTYsGMg=", + "checksumSHA1": "9ay5PqAnQlhXvDO8XEmizyHGl2g=", "path": "github.com/spf13/pflag", - "revision": "d929dcbb10863323c436af3cf76cb16a6dfc9b29", - "revisionTime": "2018-08-21T11:45:17Z" + "revision": "3ebe029320b2676d667ae88da602a5f854788a8a", + "revisionTime": "2018-06-01T13:25:42Z" }, { - "checksumSHA1": "hViBXqXEr+ZUETMlvRxMcHKNI6c=", + "checksumSHA1": "eg9yP8cqx0TjXmHJEdAJqE3gyBo=", "path": "github.com/ucloud/ucloud-sdk-go/sdk", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" + "revision": "8471d87e6b2b90aa037a6150202f5b5ad548efac", + "revisionTime": "2018-09-29T03:21:41Z" }, { - "checksumSHA1": "kqXMcnOXU7He34CAoSBDBQAME2s=", + "checksumSHA1": "tB0591CydX+bIeZBUGio6M+f60c=", "path": "github.com/ucloud/ucloud-sdk-go/sdk/auth", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" + "revision": "8471d87e6b2b90aa037a6150202f5b5ad548efac", + "revisionTime": "2018-09-29T03:21:41Z" }, { - "checksumSHA1": "wOO2LY9hCd5eyp9WRbCrJy3zzvQ=", + "checksumSHA1": "hSTCAUasOgfEb/+G+N4NvN8uQkc=", "path": "github.com/ucloud/ucloud-sdk-go/sdk/error", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" + "revision": "8471d87e6b2b90aa037a6150202f5b5ad548efac", + "revisionTime": "2018-09-29T03:21:41Z" }, { - "checksumSHA1": "I7NV3zm5ExrbD6ogXTUdPz930Z8=", + "checksumSHA1": "/b53orhhtAUsfQASNxNUDHrLMOs=", "path": "github.com/ucloud/ucloud-sdk-go/sdk/log", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" + "revision": "8471d87e6b2b90aa037a6150202f5b5ad548efac", + "revisionTime": "2018-09-29T03:21:41Z" }, { - "checksumSHA1": "oSfATLS72L0Y4+hd8k76gTa6lsc=", - "path": "github.com/ucloud/ucloud-sdk-go/sdk/request", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" + "checksumSHA1": "b/6W9bAAXuj8lSUUD+hZ5Z8keso=", + "path": "github.com/ucloud/ucloud-sdk-go/sdk/protocol/http", + "revision": "8471d87e6b2b90aa037a6150202f5b5ad548efac", + "revisionTime": "2018-09-29T03:21:41Z" }, { - "checksumSHA1": "0DLtqRUzBsRFyWqPqFtI02PcF+E=", - "path": "github.com/ucloud/ucloud-sdk-go/sdk/response", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" + "checksumSHA1": "AAzfj4QD4ciy5T5/NTdXXFbQaM0=", + "path": "github.com/ucloud/ucloud-sdk-go/sdk/request", + "revision": "8471d87e6b2b90aa037a6150202f5b5ad548efac", + "revisionTime": "2018-09-29T03:21:41Z" }, { - "checksumSHA1": "eeQfx9gZbyiKofr1J5O0o5dGInw=", - "path": "github.com/ucloud/ucloud-sdk-go/sdk/trace", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" + "checksumSHA1": "HCMg2rR9UBZW3UC7b7AvmtZQxpM=", + "path": "github.com/ucloud/ucloud-sdk-go/sdk/response", + "revision": "8471d87e6b2b90aa037a6150202f5b5ad548efac", + "revisionTime": "2018-09-29T03:21:41Z" }, { - "checksumSHA1": "WBkmTEwVcm+6Cps0+kil4L+ffvE=", + "checksumSHA1": "3cL9T8ACmx1ZXicXrkNnsqc5xCQ=", "path": "github.com/ucloud/ucloud-sdk-go/sdk/utils", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" + "revision": "8471d87e6b2b90aa037a6150202f5b5ad548efac", + "revisionTime": "2018-09-29T03:21:41Z" }, { "checksumSHA1": "5MnC8CI9JbOOZOQWq7whOvhup2Y=", "path": "github.com/ucloud/ucloud-sdk-go/sdk/version", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" - }, - { - "checksumSHA1": "Ngl9bT2IqFJR0Kq0qGc5xuapb0k=", - "path": "github.com/ucloud/ucloud-sdk-go/service", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" - }, - { - "checksumSHA1": "L+JnwP7o1GbbGoQ2wyi6EYrF5To=", - "path": "github.com/ucloud/ucloud-sdk-go/service/pathx", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" - }, - { - "checksumSHA1": "TEP6eRPe4l08pGDj64ZrjGAzIZs=", - "path": "github.com/ucloud/ucloud-sdk-go/service/pathx/types", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" - }, - { - "checksumSHA1": "WxKpu4lEtkuMAo5mgBs0V0vOHcI=", - "path": "github.com/ucloud/ucloud-sdk-go/service/uaccount", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" - }, - { - "checksumSHA1": "vOeBGVw2ZuLFARtqxDXUEiGQsbk=", - "path": "github.com/ucloud/ucloud-sdk-go/service/uaccount/types", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" - }, - { - "checksumSHA1": "CsmyE+4sE7EAxn4HFLXq+58gBGA=", - "path": "github.com/ucloud/ucloud-sdk-go/service/uhost", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" + "revision": "8471d87e6b2b90aa037a6150202f5b5ad548efac", + "revisionTime": "2018-09-29T03:21:41Z" }, { - "checksumSHA1": "TdFY6UJYaLE3BmXt4fxteAqgbV4=", - "path": "github.com/ucloud/ucloud-sdk-go/service/uhost/types", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" + "checksumSHA1": "aXbWhUfOHiL3NjTlj2v3C5hU9no=", + "path": "github.com/ucloud/ucloud-sdk-go/services", + "revision": "8471d87e6b2b90aa037a6150202f5b5ad548efac", + "revisionTime": "2018-09-29T03:21:41Z" }, { - "checksumSHA1": "TmNghm/XWsb8OqNtNO7CGwz9U+Q=", - "path": "github.com/ucloud/ucloud-sdk-go/service/ulb", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" + "checksumSHA1": "aN4Bk2HKVo/4M3AyJlxUl5MUJRk=", + "path": "github.com/ucloud/ucloud-sdk-go/services/pathx", + "revision": "8471d87e6b2b90aa037a6150202f5b5ad548efac", + "revisionTime": "2018-09-29T03:21:41Z" }, { - "checksumSHA1": "qkjTq70UQVjHF9IZVFG8HyYlygg=", - "path": "github.com/ucloud/ucloud-sdk-go/service/ulb/types", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" + "checksumSHA1": "ucPcghcs8j5mRy8LR6Vx8CPIBm0=", + "path": "github.com/ucloud/ucloud-sdk-go/services/uaccount", + "revision": "8471d87e6b2b90aa037a6150202f5b5ad548efac", + "revisionTime": "2018-09-29T03:21:41Z" }, { - "checksumSHA1": "jJHFw/vy0DSyrhCmBJKeZGrsoQY=", - "path": "github.com/ucloud/ucloud-sdk-go/service/unet", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" + "checksumSHA1": "Ad+sYxCN6jH8OrYqS5+VeCo89+0=", + "path": "github.com/ucloud/ucloud-sdk-go/services/uhost", + "revision": "8471d87e6b2b90aa037a6150202f5b5ad548efac", + "revisionTime": "2018-09-29T03:21:41Z" }, { - "checksumSHA1": "N0LPR3wb7l5lgw6vd2k6OpCdtPY=", - "path": "github.com/ucloud/ucloud-sdk-go/service/unet/types", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" + "checksumSHA1": "QbFoTfc5uOcgLndYfv64HNTgFB8=", + "path": "github.com/ucloud/ucloud-sdk-go/services/ulb", + "revision": "8471d87e6b2b90aa037a6150202f5b5ad548efac", + "revisionTime": "2018-09-29T03:21:41Z" }, { - "checksumSHA1": "TtaufQ3Qpmwls+tvoHERIgi+WnM=", - "path": "github.com/ucloud/ucloud-sdk-go/service/vpc", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" + "checksumSHA1": "KsWYFHz25FnFBZQP34S42kAKi/I=", + "path": "github.com/ucloud/ucloud-sdk-go/services/unet", + "revision": "8471d87e6b2b90aa037a6150202f5b5ad548efac", + "revisionTime": "2018-09-29T03:21:41Z" }, { - "checksumSHA1": "/OpzOU5VwjgYozUtY8kM2tIqQWE=", - "path": "github.com/ucloud/ucloud-sdk-go/service/vpc/types", - "revision": "e16a479eae8309d7f90f5653bdbd76664da4972b", - "revisionTime": "2018-08-30T08:55:37Z" + "checksumSHA1": "yZmx26gITM54gRVWTEBJ2StZ0ts=", + "path": "github.com/ucloud/ucloud-sdk-go/services/vpc", + "revision": "8471d87e6b2b90aa037a6150202f5b5ad548efac", + "revisionTime": "2018-09-29T03:21:41Z" }, { "checksumSHA1": "BGm8lKZmvJbf/YOJLeL1rw2WVjA=",